mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
fix #4862 in _pyio: reset the decoder on seek(0)
This commit is contained in:
parent
03cfa7365d
commit
9363a65b2c
2 changed files with 5 additions and 1 deletions
|
|
@ -1667,7 +1667,9 @@ class TextIOWrapper(TextIOBase):
|
|||
self._snapshot = None
|
||||
|
||||
# Restore the decoder to its state from the safe start point.
|
||||
if self._decoder or dec_flags or chars_to_skip:
|
||||
if cookie == 0 and self._decoder:
|
||||
self._decoder.reset()
|
||||
elif self._decoder or dec_flags or chars_to_skip:
|
||||
self._decoder = self._decoder or self._get_decoder()
|
||||
self._decoder.setstate((b'', dec_flags))
|
||||
self._snapshot = (dec_flags, b'')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue