[Python-checkins] r70184 - in python/branches/py3k/Lib: _pyio.py test/test_io.py
benjamin.peterson
python-checkins at python.org
Thu Mar 5 01:42:09 CET 2009
Author: benjamin.peterson
Date: Thu Mar 5 01:42:09 2009
New Revision: 70184
Log:
fix #4862 in _pyio: reset the decoder on seek(0)
Modified:
python/branches/py3k/Lib/_pyio.py
python/branches/py3k/Lib/test/test_io.py
Modified: python/branches/py3k/Lib/_pyio.py
==============================================================================
--- python/branches/py3k/Lib/_pyio.py (original)
+++ python/branches/py3k/Lib/_pyio.py Thu Mar 5 01:42:09 2009
@@ -1667,7 +1667,9 @@
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'')
Modified: python/branches/py3k/Lib/test/test_io.py
==============================================================================
--- python/branches/py3k/Lib/test/test_io.py (original)
+++ python/branches/py3k/Lib/test/test_io.py Thu Mar 5 01:42:09 2009
@@ -1706,6 +1706,8 @@
f.write(data)
f.seek(0)
self.assertEquals(f.read(), data * 2)
+ f.seek(0)
+ self.assertEquals(f.read(), data * 2)
self.assertEquals(buf.getvalue(), (data * 2).encode(encoding))
def test_read_one_by_one(self):
More information about the Python-checkins
mailing list