[issue1029] py3k: io.StringIO.getvalue() returns \r\n

Amaury Forgeot d'Arc report at bugs.python.org
Tue Aug 28 11:00:55 CEST 2007


Amaury Forgeot d'Arc added the comment:

Here is a new version of the class, which removes the 'newline' argument
from the constructor.
I also removed the 'encoding' argument, since this is really an
implementation detail of the underlying buffer.

Index: Lib/io.py
===================================================================
--- Lib/io.py	(revision 57564)
+++ Lib/io.py	(working copy)
@@ -1390,10 +1390,10 @@

     # XXX This is really slow, but fully functional

-    def __init__(self, initial_value="", encoding="utf-8", newline=None):
+    def __init__(self, initial_value=""):
         super(StringIO, self).__init__(BytesIO(),
-                                       encoding=encoding,
-                                       newline=newline)
+                                       encoding="utf-8",
+                                       newline='\n')
         if initial_value:
             if not isinstance(initial_value, basestring):
                 initial_value = str(initial_value)

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1029>
__________________________________


More information about the Python-bugs-list mailing list