Commits

Armin Rigo committed 594758a Merge

merge heads

Comments (0)

Files changed (3)

lib-python/conftest.py

     RegrTest('test_inspect.py'),
     RegrTest('test_int.py', core=True),
     RegrTest('test_int_literal.py', core=True),
-    RegrTest('test_io.py'),
+    RegrTest('test_io.py', usemodules='array binascii'),
     RegrTest('test_ioctl.py'),
     RegrTest('test_isinstance.py', core=True),
     RegrTest('test_iter.py', core=True),

pypy/module/_io/interp_bufferedio.py

             raise operationerrfmt(space.w_ValueError,
                 "whence must be between 0 and 2, not %d", whence)
         self._check_closed(space, "seek of closed file")
-        if whence != 2 and self.readable:
+        if whence != 2 and self.readable and self.read_end != -1:
             # Check if seeking leaves us inside the current buffer, so as to
             # return quickly if possible. Also, we needn't take the lock in
             # this fast path.

pypy/module/_io/test/test_bufferedio.py

         f.seek(0)
         assert f.read() == 'a\nbxxxx'
 
+    def test_simple_read_after_write(self):
+        import _io
+        raw = _io.FileIO(self.tmpfile, 'wb+')
+        f = _io.BufferedRandom(raw)
+        f.write('abc')
+        f.seek(0)
+        assert f.read() == 'abc'
+
     def test_write_rewind_write(self):
         # Various combinations of reading / writing / seeking
         # backwards / writing again