]> granicus.if.org Git - python/commitdiff
Issue 4957
authorKristján Valur Jónsson <kristjan@ccpgames.com>
Mon, 19 Jan 2009 13:10:27 +0000 (13:10 +0000)
committerKristján Valur Jónsson <kristjan@ccpgames.com>
Mon, 19 Jan 2009 13:10:27 +0000 (13:10 +0000)
Let os.ftruncate raise OSError like documented.

Lib/test/test_os.py
Modules/posixmodule.c

index 2c9d9bff693e9ece0549669d9c0f93ad9ac72b0b..5c94d7dbf8af7627a94b73a2b3f30d6da7cf6108 100644 (file)
@@ -570,10 +570,9 @@ class TestInvalidFD(unittest.TestCase):
         if hasattr(os, "fpathconf"):
             self.assertRaises(OSError, os.fpathconf, 10, "PC_NAME_MAX")
 
-    #this is a weird one, it raises IOError unlike the others
     def test_ftruncate(self):
         if hasattr(os, "ftruncate"):
-            self.assertRaises(IOError, os.ftruncate, 10, 0)
+            self.assertRaises(OSError, os.ftruncate, 10, 0)
 
     def test_lseek(self):
         if hasattr(os, "lseek"):
index a1c344465d0711fc5f339ae11b7ae41d4435cfdc..915d30d3dfb7826d6c252940a4df4a36afe2d5c2 100644 (file)
@@ -6633,7 +6633,7 @@ posix_ftruncate(PyObject *self, PyObject *args)
        res = ftruncate(fd, length);
        Py_END_ALLOW_THREADS
        if (res < 0) {
-               PyErr_SetFromErrno(PyExc_IOError);
+               posix_error();
                return NULL;
        }
        Py_INCREF(Py_None);