Commit 9053d754 authored by Benjamin Peterson's avatar Benjamin Peterson

Merged revisions 68763,68773 via svnmerge from

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
........
parent 6214edd1
...@@ -624,10 +624,9 @@ class TestInvalidFD(unittest.TestCase): ...@@ -624,10 +624,9 @@ class TestInvalidFD(unittest.TestCase):
if hasattr(os, "fpathconf"): if hasattr(os, "fpathconf"):
self.assertRaises(OSError, os.fpathconf, 10, "PC_NAME_MAX") self.assertRaises(OSError, os.fpathconf, 10, "PC_NAME_MAX")
#this is a weird one, it raises IOError unlike the others
def test_ftruncate(self): def test_ftruncate(self):
if hasattr(os, "ftruncate"): if hasattr(os, "ftruncate"):
self.assertRaises(IOError, os.ftruncate, 10, 0) self.assertRaises(OSError, os.ftruncate, 10, 0)
def test_lseek(self): def test_lseek(self):
if hasattr(os, "lseek"): if hasattr(os, "lseek"):
......
...@@ -5114,10 +5114,8 @@ posix_ftruncate(PyObject *self, PyObject *args) ...@@ -5114,10 +5114,8 @@ posix_ftruncate(PyObject *self, PyObject *args)
Py_BEGIN_ALLOW_THREADS Py_BEGIN_ALLOW_THREADS
res = ftruncate(fd, length); res = ftruncate(fd, length);
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
if (res < 0) { if (res < 0)
PyErr_SetFromErrno(PyExc_IOError); return posix_error();
return NULL;
}
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment