]> granicus.if.org Git - python/commitdiff
Merged revisions 68763,68773 via svnmerge from
authorBenjamin Peterson <benjamin@python.org>
Mon, 19 Jan 2009 17:53:36 +0000 (17:53 +0000)
committerBenjamin Peterson <benjamin@python.org>
Mon, 19 Jan 2009 17:53:36 +0000 (17:53 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r68763 | kristjan.jonsson | 2009-01-19 07:10:27 -0600 (Mon, 19 Jan 2009) | 2 lines

  Issue 4957
  Let os.ftruncate raise OSError like documented.
........
  r68773 | benjamin.peterson | 2009-01-19 09:51:27 -0600 (Mon, 19 Jan 2009) | 1 line

  simplify code
........

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

index f7471e55b9ffdad5f1006393bd8ba91b36d6c31c..a2e611fe9e0264df11de9e68e78bbc88fcd00846 100644 (file)
@@ -624,10 +624,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 490999386abac60a00bc54abef10f0d417713de3..69b69787c55fac65a3ba85aae1b46519808573b3 100644 (file)
@@ -5114,10 +5114,8 @@ posix_ftruncate(PyObject *self, PyObject *args)
        Py_BEGIN_ALLOW_THREADS
        res = ftruncate(fd, length);
        Py_END_ALLOW_THREADS
-       if (res < 0) {
-               PyErr_SetFromErrno(PyExc_IOError);
-               return NULL;
-       }
+       if (res < 0)
+               return posix_error();
        Py_INCREF(Py_None);
        return Py_None;
 }