Issue481404

classification
Title: CR removed on reading text on unix
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: bckfnn, bzhou, cgroves
Priority: low Keywords:

Created on 2001-11-13.18:52:54 by bckfnn, last changed 2007-12-02.21:16:32 by cgroves.

Messages
msg467 (view) Author: Finn Bock (bckfnn) Date: 2001-11-13.18:52:54
When reading a file opened with the 'b' flag on unix 
cause any CR character to be removed from data.

This does not match the behaviour of CPython.

>>> f = open("foo", "w")
>>> f.write("abc\r\n")
>>> f.close()
>>> f = open("foo")
>>> f.readline()
'abc\n'
>>>
msg468 (view) Author: Brian Zhou (bzhou) Date: 2002-07-12.17:57:40
Logged In: YES 
user_id=145274

It happens on both Unix and Windows, but only with text read.

>>> f = open('foo', 'w')
>>> f.write('abc\r\n')
>>> f.close()

C:\>od -x foo
0000000000      6261    0D63    0A0D
0000000006
C:\>python -c "print open('foo', 'rb').readlines()"
['abc\r\r\n']
C:\>\jython-2.1\jython -c "print open('foo', 'rb').readlines()"
['abc\r\r\n']
C:\>python -c "print open('foo').readlines()"
['abc\r\n']
C:\>\jython-2.1\jython -c "print open('foo').readlines()"
['abc\n', '\n']

$ od -x foo
0000000 6261 0d63 000a
0000005
$ python2 -c "print open('foo', 'rb').readlines()"
['abc\r\n']
$ jython -c "print open('foo', 'rb').readlines()"
['abc\r\n']
$ python2 -c "print open('foo').readlines()"
['abc\r\n']
$ jython -c "print open('foo').readlines()"
['abc\n']
msg469 (view) Author: Charlie Groves (cgroves) Date: 2007-12-02.21:16:32
This appears to be fixed with the PyFile cleanup.
History
Date User Action Args
2001-11-13 18:52:54bckfnncreate