mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Issue #20435: Fix _pyio.StringIO.getvalue() to take into account newline translation settings.
This commit is contained in:
commit
1328e9d0a0
3 changed files with 19 additions and 1 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue