summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_os.py3
-rw-r--r--Modules/posixmodule.c6
2 files changed, 3 insertions, 6 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index f7471e5..a2e611f 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -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"):
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 4909993..69b6978 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -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;
}