[pypy-commit] pypy default: issue1902 followup: fix another thinko which omitted the rewind
pjenvey
noreply at buildbot.pypy.org
Fri Jan 2 20:47:09 CET 2015
Author: Philip Jenvey <pjenvey at underboss.org>
Branch:
Changeset: r75209:fe589b2b1ccc
Date: 2015-01-02 11:46 -0800
http://bitbucket.org/pypy/pypy/changeset/fe589b2b1ccc/
Log: issue1902 followup: fix another thinko which omitted the rewind
diff --git a/pypy/module/_io/interp_bufferedio.py b/pypy/module/_io/interp_bufferedio.py
--- a/pypy/module/_io/interp_bufferedio.py
+++ b/pypy/module/_io/interp_bufferedio.py
@@ -565,7 +565,7 @@
# Flush the write buffer if necessary
if self.writable:
- self._writer_flush_unlocked(space)
+ self._flush_and_rewind_unlocked(space)
self._reader_reset_buf()
# Read whole blocks, and don't buffer them
diff --git a/pypy/module/_io/test/test_io.py b/pypy/module/_io/test/test_io.py
--- a/pypy/module/_io/test/test_io.py
+++ b/pypy/module/_io/test/test_io.py
@@ -362,3 +362,32 @@
f.read(1)
f.seek(-1, 1)
f.write(b'')
+
+ def test_issue1902_2(self):
+ import _io
+ with _io.open(self.tmpfile, 'w+b', 4096) as f:
+ f.write(b'\xff' * 13569)
+ f.flush()
+ f.seek(0, 0)
+
+ f.read(1)
+ f.seek(-1, 1)
+ f.write(b'\xff')
+ f.seek(1, 0)
+ f.read(4123)
+ f.seek(-4123, 1)
+
+ def test_issue1902_3(self):
+ import _io
+ buffer_size = 4096
+ with _io.open(self.tmpfile, 'w+b', buffer_size) as f:
+ f.write(b'\xff' * buffer_size * 3)
+ f.flush()
+ f.seek(0, 0)
+
+ f.read(1)
+ f.seek(-1, 1)
+ f.write(b'\xff')
+ f.seek(1, 0)
+ f.read(buffer_size * 2)
+ assert f.tell() == 1 + buffer_size * 2
More information about the pypy-commit
mailing list