diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2014-02-02 22:38:48 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2014-02-02 22:38:48 (GMT) |
commit | 1328e9d0a0bacdd49d7026d3d883354bb01356dc (patch) | |
tree | fda069df0da9a9939ee610896485f9882e8d8e49 /Lib/_pyio.py | |
parent | 2f2ecaa48461fc4a8987f5b20f01fa61da90be51 (diff) | |
parent | 57839a6349d7443855bc04d7f5c32f9f38929111 (diff) | |
download | cpython-1328e9d0a0bacdd49d7026d3d883354bb01356dc.zip cpython-1328e9d0a0bacdd49d7026d3d883354bb01356dc.tar.gz cpython-1328e9d0a0bacdd49d7026d3d883354bb01356dc.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.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py index edfb9b9..3961969 100644 --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -2067,7 +2067,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, |