From 2e659ce36f9f48abc7515f83037274fbfb1f779e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Mon, 19 Jan 2009 13:10:27 +0000 Subject: Issue 4957 Let os.ftruncate raise OSError like documented. --- Lib/test/test_os.py | 3 +-- Modules/posixmodule.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 2c9d9bf..5c94d7d 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -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"): diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index a1c3444..915d30d 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -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); -- cgit v0.12