Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9053d75

Browse files
committed
Merged revisions 68763,68773 via svnmerge from
svn+ssh://[email protected]/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 ........
1 parent 6214edd commit 9053d75

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

Lib/test/test_os.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,10 +624,9 @@ def test_fpathconf(self):
624624
if hasattr(os, "fpathconf"):
625625
self.assertRaises(OSError, os.fpathconf, 10, "PC_NAME_MAX")
626626

627-
#this is a weird one, it raises IOError unlike the others
628627
def test_ftruncate(self):
629628
if hasattr(os, "ftruncate"):
630-
self.assertRaises(IOError, os.ftruncate, 10, 0)
629+
self.assertRaises(OSError, os.ftruncate, 10, 0)
631630

632631
def test_lseek(self):
633632
if hasattr(os, "lseek"):

Modules/posixmodule.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5114,10 +5114,8 @@ posix_ftruncate(PyObject *self, PyObject *args)
51145114
Py_BEGIN_ALLOW_THREADS
51155115
res = ftruncate(fd, length);
51165116
Py_END_ALLOW_THREADS
5117-
if (res < 0) {
5118-
PyErr_SetFromErrno(PyExc_IOError);
5119-
return NULL;
5120-
}
5117+
if (res < 0)
5118+
return posix_error();
51215119
Py_INCREF(Py_None);
51225120
return Py_None;
51235121
}

0 commit comments

Comments
 (0)