New submission from Amaury Forgeot d'Arc:
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.
----------
messages: 57147
nosy: amaury.forgeotdarc, gvanrossum, tiran
severity: normal
status: open
title: py3k: duplicated line endings when using read(1)
versions: Python 3.0
__________________________________
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1395>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com