[New-bugs-announce] [issue1188] universal newlines doesn't identify CRLF during tell()

Philip Jenvey report at bugs.python.org
Sat Sep 22 02:33:37 CEST 2007


New submission from 
					Philip Jenvey
				:

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

----------
components: Library (Lib)
files: univnewline_tell-r58227.diff
messages: 56085
nosy: pjenvey
severity: normal
status: open
title: universal newlines doesn't identify CRLF during tell()
versions: Python 2.6

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1188>
__________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: univnewline_tell-r58227.diff
Type: application/octet-stream
Size: 1003 bytes
Desc: not available
Url : http://mail.python.org/pipermail/new-bugs-announce/attachments/20070922/0e5ec3d1/attachment.obj 


More information about the New-bugs-announce mailing list