[Python-checkins] r70285 - in python/branches/release30-maint/Lib: io.py test/test_memoryio.py

benjamin.peterson python-checkins at python.org
Mon Mar 9 22:16:41 CET 2009


Author: benjamin.peterson
Date: Mon Mar  9 22:16:41 2009
New Revision: 70285

Log:
fix StringIO newline translation #5456

Modified:
   python/branches/release30-maint/Lib/io.py
   python/branches/release30-maint/Lib/test/test_memoryio.py

Modified: python/branches/release30-maint/Lib/io.py
==============================================================================
--- python/branches/release30-maint/Lib/io.py	(original)
+++ python/branches/release30-maint/Lib/io.py	Mon Mar  9 22:16:41 2009
@@ -1942,13 +1942,12 @@
             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
 

Modified: python/branches/release30-maint/Lib/test/test_memoryio.py
==============================================================================
--- python/branches/release30-maint/Lib/test/test_memoryio.py	(original)
+++ python/branches/release30-maint/Lib/test/test_memoryio.py	Mon Mar  9 22:16:41 2009
@@ -376,6 +376,10 @@
     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()
 


More information about the Python-checkins mailing list