summaryrefslogtreecommitdiffstats
path: root/Lib/_pyio.py
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2014-02-02 22:37:29 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2014-02-02 22:37:29 (GMT)
commit57839a6349d7443855bc04d7f5c32f9f38929111 (patch)
tree86465f1dfcd80566048522ed571c46d950227c09 /Lib/_pyio.py
parent6bb21c48bcfac71a9c301b34b71e703dadd2e6ae (diff)
downloadcpython-57839a6349d7443855bc04d7f5c32f9f38929111.zip
cpython-57839a6349d7443855bc04d7f5c32f9f38929111.tar.gz
cpython-57839a6349d7443855bc04d7f5c32f9f38929111.tar.bz2
Issue #20435: Fix _pyio.StringIO.getvalue() to take into account newline translation settings.
Diffstat (limited to 'Lib/_pyio.py')
-rw-r--r--Lib/_pyio.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index a9b0064..9a2a1aa 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -2060,7 +2060,13 @@ class StringIO(TextIOWrapper):
def getvalue(self):
self.flush()
- return self.buffer.getvalue().decode(self._encoding, self._errors)
+ decoder = self._decoder or self._get_decoder()
+ old_state = decoder.getstate()
+ decoder.reset()
+ try:
+ return decoder.decode(self.buffer.getvalue(), final=True)
+ finally:
+ decoder.setstate(old_state)
def __repr__(self):
# TextIOWrapper tells the encoding in its repr. In StringIO,