[pypy-svn] r78102 - in pypy/branch/fast-forward/pypy/module/_io: . test

afa at codespeak.net afa at codespeak.net
Wed Oct 20 00:40:46 CEST 2010


Author: afa
Date: Wed Oct 20 00:40:45 2010
New Revision: 78102

Modified:
   pypy/branch/fast-forward/pypy/module/_io/interp_fileio.py
   pypy/branch/fast-forward/pypy/module/_io/test/test_fileio.py
Log:
Properly wrap OSError in FileIO.seek()


Modified: pypy/branch/fast-forward/pypy/module/_io/interp_fileio.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_io/interp_fileio.py	(original)
+++ pypy/branch/fast-forward/pypy/module/_io/interp_fileio.py	Wed Oct 20 00:40:45 2010
@@ -233,7 +233,11 @@
     @unwrap_spec('self', ObjSpace, r_longlong, int)
     def seek_w(self, space, pos, whence=0):
         self._check_closed(space)
-        pos = os.lseek(self.fd, pos, whence)
+        try:
+            pos = os.lseek(self.fd, pos, whence)
+        except OSError, e:
+            raise wrap_oserror(space, e,
+                               exception_name='w_IOError')
         return space.wrap(pos)
 
     @unwrap_spec('self', ObjSpace)

Modified: pypy/branch/fast-forward/pypy/module/_io/test/test_fileio.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/_io/test/test_fileio.py	(original)
+++ pypy/branch/fast-forward/pypy/module/_io/test/test_fileio.py	Wed Oct 20 00:40:45 2010
@@ -35,7 +35,6 @@
     def test_readline(self):
         import _io
         f = _io.FileIO(self.tmpfile, 'rb')
-        f.seek(0)
         assert f.readline() == 'a\n'
         assert f.readline() == 'b\n'
         assert f.readline() == 'c'
@@ -58,3 +57,10 @@
         assert f2.read() == "test"
         f.close()
         f2.close()
+
+    def test_seek(self):
+        import _io
+        f = _io.FileIO(self.tmpfile, 'rb')
+        f.seek(0)
+        self.posix.close(f.fileno())
+        raises(IOError, f.seek, 0)



More information about the Pypy-commit mailing list