Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue1188] universal newlines doesn't identify CRLF during tell()

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Sep 21, 2007, 5:33 PM

Post #1 of 5 (226 views)
Permalink
[issue1188] universal newlines doesn't identify CRLF during tell()

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>
<http://bugs.python.org/issue1188>
__________________________________
Attachments: univnewline_tell-r58227.diff (0.98 KB)


report at bugs

Sep 21, 2007, 5:33 PM

Post #2 of 5 (220 views)
Permalink
[issue1188] universal newlines doesn't identify CRLF during tell() [In reply to]

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>
<http://bugs.python.org/issue1188>
__________________________________
Attachments: univnewline_tell-r58227.diff (0.98 KB)


report at bugs

Sep 21, 2007, 5:35 PM

Post #3 of 5 (216 views)
Permalink
[issue1188] universal newlines doesn't identify CRLF during tell() [In reply to]

Philip Jenvey
added the comment:

make that against r58227

__________________________________
Tracker <report [at] bugs>
<http://bugs.python.org/issue1188>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Sep 21, 2007, 5:35 PM

Post #4 of 5 (216 views)
Permalink
[issue1188] universal newlines doesn't identify CRLF during tell() [In reply to]

Changes by
Philip Jenvey
:


----------
type: -> behavior

__________________________________
Tracker <report [at] bugs>
<http://bugs.python.org/issue1188>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Sep 22, 2007, 1:18 PM

Post #5 of 5 (215 views)
Permalink
[issue1188] universal newlines doesn't identify CRLF during tell() [In reply to]

Guido van Rossum added the comment:

Thanks!
Committed revision 58232.

----------
assignee: -> gvanrossum
nosy: +gvanrossum
resolution: -> accepted
status: open -> closed

__________________________________
Tracker <report [at] bugs>
<http://bugs.python.org/issue1188>
__________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.