]> granicus.if.org Git - python/commitdiff
Issue #25118: Fix a regression of Python 3.5.0 in os.waitpid() on Windows.
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 15 Sep 2015 08:11:03 +0000 (10:11 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 15 Sep 2015 08:11:03 +0000 (10:11 +0200)
Add an unit test on os.waitpid()

Lib/test/test_os.py
Misc/NEWS
Modules/posixmodule.c

index 245309ec0535d69fb565c00bfc336fcaee910367..bb717cc6614186049c77ca27212d4a0ea141d612 100644 (file)
@@ -2078,6 +2078,12 @@ class PidTests(unittest.TestCase):
         # We are the parent of our subprocess
         self.assertEqual(int(stdout), os.getpid())
 
+    def test_waitpid(self):
+        args = [sys.executable, '-c', 'pass']
+        pid = os.spawnv(os.P_NOWAIT, args[0], args)
+        status = os.waitpid(pid, 0)
+        self.assertEqual(status, (pid, 0))
+
 
 # The introduction of this TestCase caused at least two different errors on
 # *nix buildbots. Temporarily skip this to let the buildbots move along.
index 96e13feba347b9524dc487cfc617a32ea3600b38..bd4bd44673072148546d66fcf68e78022aeec41a 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -14,6 +14,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #25118: Fix a regression of Python 3.5.0 in os.waitpid() on Windows.
+
 - Issue #24684: socket.socket.getaddrinfo() now calls
   PyUnicode_AsEncodedString() instead of calling the encode() method of the
   host, to handle correctly custom string with an encode() method which doesn't
index c0baf6ac693bf30eef86d1f076d71706ecd0dded..854a7491c5f712cda940384ed7e85cdb9aa8fc61 100644 (file)
@@ -7021,7 +7021,7 @@ os_waitpid_impl(PyModuleDef *module, Py_intptr_t pid, int options)
         res = _cwait(&status, pid, options);
         Py_END_ALLOW_THREADS
     } while (res < 0 && errno == EINTR && !(async_err = PyErr_CheckSignals()));
-    if (res != 0)
+    if (res < 0)
         return (!async_err) ? posix_error() : NULL;
 
     /* shift the status left a byte so this is more like the POSIX waitpid */
@@ -7731,7 +7731,7 @@ os_open_impl(PyModuleDef *module, path_t *path, int flags, int mode,
     } while (fd < 0 && errno == EINTR && !(async_err = PyErr_CheckSignals()));
     _Py_END_SUPPRESS_IPH
 
-    if (fd == -1) {
+    if (fd < 0) {
         if (!async_err)
             PyErr_SetFromErrnoWithFilenameObject(PyExc_OSError, path->object);
         return -1;