summaryrefslogtreecommitdiffstats
path: root/Lib/_pyio.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-03-05 00:42:09 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-03-05 00:42:09 (GMT)
commit9363a65b2ceb1b9cb9b14a1711d7d2310673a0a0 (patch)
treea399a6f732273464722a00629b70ad5794d8ebb8 /Lib/_pyio.py
parent03cfa7365d7fc7c1020aab3845e49356f961f767 (diff)
downloadcpython-9363a65b2ceb1b9cb9b14a1711d7d2310673a0a0.zip
cpython-9363a65b2ceb1b9cb9b14a1711d7d2310673a0a0.tar.gz
cpython-9363a65b2ceb1b9cb9b14a1711d7d2310673a0a0.tar.bz2
fix #4862 in _pyio: reset the decoder on seek(0)
Diffstat (limited to 'Lib/_pyio.py')
-rw-r--r--Lib/_pyio.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index 5f2e400..a2ee952 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -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'')