You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2009-03-09.00:16:24.760>created_at=<Date2009-03-09.00:09:53.705>labels= ['type-bug', 'library']
title='patch to make io.StringIO consistent with open with respect to newlines'updated_at=<Date2009-03-09.01:04:09.555>user='https://bugs.python.org/erickt'
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']
Thanks Benjamin. Could the documentation for StringIO be updated then? The
docs for io.StringIO 1 says that io.TextIOWrapper implements the
constructor, but TextIOWrapper defaults newline to None 2, and there's
nothing that states that io.StringIO changes the default to newline='\n'.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: