GNOME Bugzilla – Bug 547481
g_data_input_stream_read_line behaves not as stated in the docs
Last modified: 2008-12-01 19:11:06 UTC
I'm wrapping the function in PyGObject. It apparently doesn't return line with newlines included as it claims in the docs: "Returns: a string with the line that was read in (including the newlines). Set length to a gsize to get the length of the read line. Returns NULL on an error." If this can help, here is a test case in Python: class TestDataInputStream(unittest.TestCase): def setUp(self): self.base_stream = gio.MemoryInputStream() self.data_stream = gio.DataInputStream(self.base_stream) def test_read_line(self): self.base_stream.add_data('foo\nbar\n\nbaz') self.assertEquals('foo\n', self.data_stream.read_line()) self.assertEquals('bar\n', self.data_stream.read_line()) self.assertEquals('\n', self.data_stream.read_line()) self.assertEquals('baz', self.data_stream.read_line()) As I see, it returns 'foo', 'bar', '', 'baz' instead of expected values.
2008-11-28 Matthias Clasen <mclasen@redhat.com> Bug 547481 – g_data_input_stream_read_line behaves not as stated in the docs * gdatainputstream.c (g_data_input_stream_read_line): Behave as documented and include the line end in the returned string. Pointed out by Paul Pogonyshev. * tests/data-input-stream.c: Fix the read_line test to test the documented behaviour.
Uhm? Why not change the docs instead of breaking all apps that currently use this?
I honestly wasn't sure which way to go here. If you prefer to keep it the way it was and update the docs. I've reverted it to the old behaviour now.
For the record, I think this way (to change docs) is better now. I'd prefer having newlines returned, but not after one stable version already strips them.