]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Oops, I missed this one again (test_univnewlines fails):
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Mon, 19 Nov 2007 21:14:47 +0000 (21:14 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Mon, 19 Nov 2007 21:14:47 +0000 (21:14 +0000)
Some incremental decoders return multiple characters, even when fed with
only one more byte. In this case the tell() state must subtract the
number of extra characters.

Lib/io.py

index d2d2fbcf887748f8e60d27cce99d278f2706acc1..364e6d0be3f529a25cac445f974313d71755df2a 100644 (file)
--- a/Lib/io.py
+++ b/Lib/io.py
@@ -1283,7 +1283,7 @@ class TextIOWrapper(TextIOBase):
                     decoder_buffer, decoder_state = decoder.getstate()
                     return self._encode_decoder_state(
                         decoder_state,
-                        position + (i+1) - len(decoder_buffer))
+                        position + (i+1) - len(decoder_buffer) - (n - needed))
             raise IOError("Can't reconstruct logical file position")
         finally:
             decoder.setstate(saved_state)