diff options
Diffstat (limited to 'Lib/_pyio.py')
-rw-r--r-- | Lib/_pyio.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py index 0bfdeaa..16d025b 100644 --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -2224,8 +2224,9 @@ class TextIOWrapper(TextIOBase): self.buffer.write(b) if self._line_buffering and (haslf or "\r" in s): self.flush() - self._set_decoded_chars('') - self._snapshot = None + if self._snapshot is not None: + self._set_decoded_chars('') + self._snapshot = None if self._decoder: self._decoder.reset() return length @@ -2539,8 +2540,9 @@ class TextIOWrapper(TextIOBase): # Read everything. result = (self._get_decoded_chars() + decoder.decode(self.buffer.read(), final=True)) - self._set_decoded_chars('') - self._snapshot = None + if self._snapshot is not None: + self._set_decoded_chars('') + self._snapshot = None return result else: # Keep reading chunks until we have size characters to return. |