This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author amaury.forgeotdarc
Recipients amaury.forgeotdarc, christian.heimes, gvanrossum
Date 2007-11-06.00:21:36
SpamBayes Score 0.21038641
Marked as misclassified No
Message-id <1194308496.75.0.337158380504.issue1395@psf.upfronthosting.co.za>
In-reply-to
Content
When reading a Windows text file one byte at a time, \r\n get split into
two function calls, and the user receives two \n.

The following test fails (put it somewhere in test_io.py, inside
TextIOWrapperTest for example)

    def testReadOneByOne(self):
        txt = io.TextIOWrapper(io.BytesIO(b"AA\r\nBB"))
        reads = ""
        while True:
            c = txt.read(1)
            if not c:
                break
            reads += c
        self.assertEquals(reads, "AA\nBB")
        # AssertionError: 'AA\n\nBB' != 'AA\nBB'

Note that replacing read(1) by read(2) gives the correct result.

This problem is why test_netrc fails on Windows. It may also be the root
cause for issue 1142 (when \r\n position is just a multiple of the
_CHUNK_SIZE).
It also possible that the correction to this problem will have good
effects on test_mailbox, which uses tell() and seek() intensively.
History
Date User Action Args
2007-11-06 00:21:36amaury.forgeotdarcsetspambayes_score: 0.210386 -> 0.21038641
recipients: + amaury.forgeotdarc, gvanrossum, christian.heimes
2007-11-06 00:21:36amaury.forgeotdarcsetspambayes_score: 0.210386 -> 0.210386
messageid: <1194308496.75.0.337158380504.issue1395@psf.upfronthosting.co.za>
2007-11-06 00:21:36amaury.forgeotdarclinkissue1395 messages
2007-11-06 00:21:36amaury.forgeotdarccreate