Index: Lib/test/test_io.py
===================================================================
--- Lib/test/test_io.py (revision 57506)
+++ Lib/test/test_io.py (working copy)
@@ -189,6 +189,12 @@
f = io.BytesIO(data)
self.read_ops(f, True)
+ def test_stringio_getvalue(self):
+ f = io.StringIO()
+ data = "Hello world\n\x82"
+ f.write(data)
+ self.assertEqual(data, f.getvalue())
+
def test_large_file_ops(self):
# On Windows and Mac OSX this test comsumes large resources; It takes
# a long time to build the >2GB file and takes >2GB of disk space
Index: Lib/io.py
===================================================================
--- Lib/io.py (revision 57506)
+++ Lib/io.py (working copy)
@@ -1370,4 +1370,5 @@
def getvalue(self):
self.flush()
- return self.buffer.getvalue().decode(self._encoding)
+ value = self.buffer.getvalue().decode(self._encoding)
+ return self._replacenl(value)