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.

Author erickt
Recipients erickt
Date 2009-03-09.00:09:53
SpamBayes Score 0.0037287816
Marked as misclassified No
Message-id <1236557394.75.0.991537518962.issue5451@psf.upfronthosting.co.za>
In-reply-to
Content
I noticed that io.StringIO is inconsistent with open on how newlines are 
handled. The default approach open uses is universal newlines:

>>> with open('foo', 'w') as f:
...   f.write('hello hi\r\nla la\r\n')
... 
17
>>> open('foo').readlines()
['hello hi\n', 'la la\n']

io.StringIO, however, defaults to just treating \n as newlines:

>>> io.StringIO('hello hi\r\nla la \r\n').readlines()
['hello hi\r\n', 'la la \r\n']

The attached patch changes this so that if the newline keyword isn't 
specified, then StringIO will act just like open with respect to 
keywords. It will then produce this:

>>> io.StringIO('hello hi\r\nla la \r\n').readlines()
['hello hi\n', 'la la \n']
History
Date User Action Args
2009-03-09 00:09:54ericktsetrecipients: + erickt
2009-03-09 00:09:54ericktsetmessageid: <1236557394.75.0.991537518962.issue5451@psf.upfronthosting.co.za>
2009-03-09 00:09:53ericktlinkissue5451 messages
2009-03-09 00:09:53ericktcreate