[Python-checkins] cpython (3.5): Issue #25118: Fix a regression of Python 3.5.0 in os.waitpid() on Windows.

victor.stinner python-checkins at python.org
Tue Sep 15 10:26:28 CEST 2015


https://hg.python.org/cpython/rev/9a80c687c28d
changeset:   98004:9a80c687c28d
branch:      3.5
parent:      98002:849bdcbff518
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Tue Sep 15 10:11:03 2015 +0200
summary:
  Issue #25118: Fix a regression of Python 3.5.0 in os.waitpid() on Windows.

Add an unit test on os.waitpid()

files:
  Lib/test/test_os.py   |  6 ++++++
  Misc/NEWS             |  2 ++
  Modules/posixmodule.c |  4 ++--
  3 files changed, 10 insertions(+), 2 deletions(-)


diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -2078,6 +2078,12 @@
         # 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.
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -14,6 +14,8 @@
 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
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -7021,7 +7021,7 @@
         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 @@
     } 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;

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list