]> granicus.if.org Git - python/commitdiff
Should use posix_error here.
authorHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
Sun, 5 Dec 2010 04:16:47 +0000 (04:16 +0000)
committerHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>
Sun, 5 Dec 2010 04:16:47 +0000 (04:16 +0000)
Lib/test/test_ntpath.py
Modules/posixmodule.c

index 237aec01f49417f3f04eb30a2ff3fb5abef8c9d0..646495098230d8075df79a51e540fc1518b22688 100644 (file)
@@ -248,7 +248,7 @@ class TestNtpath(unittest.TestCase):
             self.assertFalse(ntpath.sameopenfile(tf1.fileno(), tf2.fileno()))
             # Make sure invalid values don't cause issues on win32
             if sys.platform == "win32":
-                with self.assertRaises(ValueError):
+                with self.assertRaises(OSError):
                     # Invalid file descriptors shouldn't display assert
                     # dialogs (#4804)
                     ntpath.sameopenfile(-1, -1)
index 34190ddba59d717652e8ce429df2536a3a232ee8..01da01df280cb23bc5908180c4f5d4c1a29379bc 100644 (file)
@@ -2803,14 +2803,12 @@ posix__getfileinformation(PyObject *self, PyObject *args)
     if (!PyArg_ParseTuple(args, "i:_getfileinformation", &fd))
         return NULL;
 
-    if (!_PyVerify_fd(fd)) {
-        PyErr_SetString(PyExc_ValueError, "received invalid file descriptor");
-        return NULL;
-    }
+    if (!_PyVerify_fd(fd))
+        return posix_error();
 
     hFile = (HANDLE)_get_osfhandle(fd);
     if (hFile == INVALID_HANDLE_VALUE)
-        return win32_error("_getfileinformation", NULL);
+        return posix_error();
 
     if (!GetFileInformationByHandle(hFile, &info))
         return win32_error("_getfileinformation", NULL);