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.

classification
Title: universal newlines doesn't identify CRLF during tell()
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.6
process
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 2022-04-11 14:56 by admin. This issue is now closed.

Files
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.read()
'CRLF\nEOF'
>>> fp.newlines # correct when read()ing
'\r\n'
>>> fp = open('/tmp/crlf', 'U')
>>> fp.readline()
'CRLF\n'
>>> fp.newlines
>>> fp.tell()
6L
>>> fp.newlines # tell() skipped ahead..
>>> fp.readline()
'EOF'
>>> 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 test_univnewlines.py. 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
Thanks!
Committed revision 58232.
History
Date User Action Args
2022-04-11 14:56:27adminsetgithub: 45529
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