New submission from Erick Tryzelaar <idade...@users.sourceforge.net>:
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'] ---------- components: Library (Lib) files: 0001-Make-StringIO-consistent-with-open-wrt-newlines.patch keywords: patch message_count: 1.0 messages: 83341 nosy: erickt nosy_count: 1.0 severity: normal status: open title: patch to make io.StringIO consistent with open with respect to newlines type: behavior versions: Python 3.1 Added file: http://bugs.python.org/file13276/0001-Make-StringIO-consistent-with-open-wrt-newlines.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5451> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com