diff options
| author | Antoine Pitrou <solipsis@pitrou.net> | 2010-05-15 20:33:07 (GMT) |
|---|---|---|
| committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-05-15 20:33:07 (GMT) |
| commit | c400610321dcd16bff1e45ecb72a51244d43fbac (patch) | |
| tree | 07a476a4be7d7eacf4fd8d25bb4d3faa96cf9a0a /Lib/io.py | |
| parent | 6f1cfc1c12ce2bad4241dae14860acba7d4b294b (diff) | |
| download | cpython-c400610321dcd16bff1e45ecb72a51244d43fbac.zip cpython-c400610321dcd16bff1e45ecb72a51244d43fbac.tar.gz cpython-c400610321dcd16bff1e45ecb72a51244d43fbac.tar.bz2 | |
Issue #7640: In the new `io` module, fix relative seek() for buffered
readable streams when the internal buffer isn't empty. Patch by Pascal
Chambon.
Diffstat (limited to 'Lib/io.py')
| -rw-r--r-- | Lib/io.py | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -1199,6 +1199,10 @@ class BufferedRandom(BufferedWriter, BufferedReader): self.flush() # First do the raw seek, then empty the read buffer, so that # if the raw seek fails, we don't lose buffered data forever. + if self._read_buf and whence == 1: + # Undo read ahead. + with self._read_lock: + self.raw.seek(self._read_pos - len(self._read_buf), 1) pos = self.raw.seek(pos, whence) with self._read_lock: self._reset_read_buf() |
