classification
Title: Unexpected universal newline behavior (newline duplication) in Windows
Type: behavior Stage:
Components: IO Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: alexandre.vassalotti, jaraco, terry.reedy
Priority: normal Keywords: patch

Created on 2009-05-27 20:01 by jaraco, last changed 2009-06-12 21:21 by alexandre.vassalotti. This issue is now closed.

Files
File name Uploaded Description Edit
issue5645_release26-maint.patch jaraco, 2009-06-05 02:28
Messages (6)
msg88438 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2009-05-27 20:01
Per http://bugs.python.org/issue5265, I'm opening up a new ticket. 
Universal newline behavior works as expected under Linux but differently
under Windows.

PS C:\Users\jaraco> python
Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit
(Intel)] on win32
>>> import io
>>> io.StringIO('foo\r\nbar\r\n', newline=None).read()
u'foo\n\nbar\n\n'

As you can see, the newlines get duplicated.

The problem doesn't seem to be with universal newline support in
general, but the StringIO implementation in particular.

PS C:\Users\jaraco\projects\formworx> python
Python 2.6.2 (r262:71605, Apr 14 2009, 22:46:50) [MSC v.1500 64 bit
(AMD64)] on win32
>>> open("testnl.txt", "wb").write("foo\r\nbar\r\n")
>>> open("testnl.txt", "rU").read()
'foo\nbar\n'
msg88528 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2009-05-29 20:06
FWIW, WindowsXP, Py3.1b1, May 7

>>> io.StringIO('foo\r\nbar\r\n', newline=None).read()
'foo\nbar\n'

I believe there were changes to io after April 14 for May 7 release, so
this may be fixed in 2.6.3 branch already.
msg88582 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2009-05-30 21:30
I checked out the latest code from /branches/release26-maint and
compiled it.  Indeed the problem still exists.

Python 2.6.2+ (release26-maint:73061M, May 30 2009, 16:57:28) [MSC
v.1500 32 bit (Intel)] on win32
>>> import io
>>> io.StringIO('foo\r\nbar\r\n', newline=None).read()
u'foo\n\nbar\n\n'
msg88914 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2009-06-04 22:24
Can you check if the patch in issue #5645 fix the bug?
msg88917 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2009-06-05 02:28
Indeed, that patch works.  I'm attaching the same patch applicable to
branches/release26-maint.
msg89303 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2009-06-12 21:21
Patch backported in r73399. Thanks!
History
Date User Action Args
2009-06-12 21:21:28alexandre.vassalottisetstatus: open -> closed
resolution: fixed
messages: + msg89303
2009-06-05 02:28:03jaracosetfiles: + issue5645_release26-maint.patch
keywords: + patch
messages: + msg88917
2009-06-04 22:24:21alexandre.vassalottisetnosy: + alexandre.vassalotti
messages: + msg88914
2009-05-30 21:30:41jaracosetmessages: + msg88582
2009-05-29 20:06:43terry.reedysetnosy: + terry.reedy
messages: + msg88528
2009-05-27 20:03:46jaracosettype: behavior
2009-05-27 20:01:42jaracocreate