Title: universal newlines doesn't identify CRLF during tell()
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.6
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: gvanrossum Nosy List: gvanrossum, pjenvey
Priority: normal Keywords:

Created on 2007-09-22 00:33 by pjenvey, last changed 2007-09-22 20:18 by gvanrossum. This issue is now closed.

File name Uploaded Description Edit
univnewline_tell-r58227.diff pjenvey, 2007-09-22 00:33
Messages (3)
msg56085 - (view) Author: Philip Jenvey (pjenvey) * (Python committer) Date: 2007-09-22 00:33
tell() will skip the next LF (after a CR sets f_skipnextlf) when 
universal newline support is enabled; essentially doing part of the work 
of read(). However it does not identify CRLF as a newline, as read() 
would, e.g.:

>>> open('/tmp/crlf', 'wb').write('CRLF\r\nEOF')
>>> fp = open('/tmp/crlf', 'U')
>>> fp.newlines # correct when read()ing
>>> fp = open('/tmp/crlf', 'U')
>>> fp.readline()
>>> fp.newlines
>>> fp.tell()
>>> fp.newlines # tell() skipped ahead..
>>> fp.readline()
>>> fp.newlines # ..but never identified CRLF

The following patch makes tell() mark CRLF as a newline in this case, 
and ensures so with an added test to It's against 
trunk, r28227
msg56086 - (view) Author: Philip Jenvey (pjenvey) * (Python committer) Date: 2007-09-22 00:35
make that against r58227
msg56092 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2007-09-22 20:18
Committed revision 58232.
Date User Action Args
2007-09-22 20:18:25gvanrossumsetstatus: open -> closed
assignee: gvanrossum
resolution: accepted
messages: + msg56092
nosy: + gvanrossum
2007-09-22 00:35:28pjenveysettype: behavior
2007-09-22 00:35:10pjenveysetmessages: + msg56086
2007-09-22 00:33:37pjenveycreate