From: Benjamin Peterson Date: Mon, 9 Mar 2009 21:16:41 +0000 (+0000) Subject: fix StringIO newline translation #5456 X-Git-Tag: 3.0~326 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=412a189cdefd0f2e363fe3cc2d8806876ac74854;p=thirdparty%2FPython%2Fcpython.git fix StringIO newline translation #5456 --- diff --git a/Lib/io.py b/Lib/io.py index c2c1067a2d03..9a34d1664779 100644 --- a/Lib/io.py +++ b/Lib/io.py @@ -1942,13 +1942,12 @@ try: self._seennl |= (lf and self._LF) | (cr and self._CR) \ | (crlf and self._CRLF) + output = input if self._readtranslate: if crlf: output = input.replace("\r\n", "\n") if cr: output = input.replace("\r", "\n") - else: - output = input return output diff --git a/Lib/test/test_memoryio.py b/Lib/test/test_memoryio.py index d1745bcd3fdf..1aad3a50d13b 100644 --- a/Lib/test/test_memoryio.py +++ b/Lib/test/test_memoryio.py @@ -376,6 +376,10 @@ class PyStringIOTest(MemoryTestMixin, unittest.TestCase): ioclass = io._StringIO EOF = "" + def test_newline_none(self): + memio = self.ioclass('hello\r\nhi\r\n', newline=None) + self.assertEqual(memio.readlines(), ["hello\n", "hi\n"]) + def test_relative_seek(self): memio = self.ioclass()