diff -r 5673cf852daa Doc/library/os.rst --- a/Doc/library/os.rst Sat Oct 01 01:06:51 2016 -0500 +++ b/Doc/library/os.rst Sat Oct 01 23:50:09 2016 +0530 @@ -3511,7 +3511,7 @@ .. versionadded:: 3.3 -.. function:: waitpid(pid, options) +.. function:: waitpid(pid, options=0) The details of this function differ on Unix and Windows. diff -r 5673cf852daa Lib/distutils/spawn.py --- a/Lib/distutils/spawn.py Sat Oct 01 01:06:51 2016 -0500 +++ b/Lib/distutils/spawn.py Sat Oct 01 23:50:09 2016 +0530 @@ -135,7 +135,7 @@ # (ie. keep waiting if it's merely stopped) while True: try: - pid, status = os.waitpid(pid, 0) + pid, status = os.waitpid(pid) except OSError as exc: if not DEBUG: cmd = executable diff -r 5673cf852daa Lib/http/server.py --- a/Lib/http/server.py Sat Oct 01 01:06:51 2016 -0500 +++ b/Lib/http/server.py Sat Oct 01 23:50:09 2016 +0530 @@ -1107,7 +1107,7 @@ pid = os.fork() if pid != 0: # Parent - pid, sts = os.waitpid(pid, 0) + pid, sts = os.waitpid(pid) # throw away additional data [see bug #427345] while select.select([self.rfile], [], [], 0)[0]: if not self.rfile.read(1): diff -r 5673cf852daa Lib/os.py --- a/Lib/os.py Sat Oct 01 01:06:51 2016 -0500 +++ b/Lib/os.py Sat Oct 01 23:50:09 2016 +0530 @@ -911,7 +911,7 @@ if mode == P_NOWAIT: return pid # Caller is responsible for waiting! while 1: - wpid, sts = waitpid(pid, 0) + wpid, sts = waitpid(pid) if WIFSTOPPED(sts): continue elif WIFSIGNALED(sts): diff -r 5673cf852daa Lib/pty.py --- a/Lib/pty.py Sat Oct 01 01:06:51 2016 -0500 +++ b/Lib/pty.py Sat Oct 01 23:50:09 2016 +0530 @@ -167,4 +167,4 @@ tty.tcsetattr(STDIN_FILENO, tty.TCSAFLUSH, mode) os.close(master_fd) - return os.waitpid(pid, 0)[1] + return os.waitpid(pid)[1] diff -r 5673cf852daa Lib/socketserver.py --- a/Lib/socketserver.py Sat Oct 01 01:06:51 2016 -0500 +++ b/Lib/socketserver.py Sat Oct 01 23:50:09 2016 +0530 @@ -561,7 +561,7 @@ # above max_children. while len(self.active_children) >= self.max_children: try: - pid, _ = os.waitpid(-1, 0) + pid, _ = os.waitpid(-1) self.active_children.discard(pid) except ChildProcessError: # we don't have any children, we're done diff -r 5673cf852daa Lib/subprocess.py --- a/Lib/subprocess.py Sat Oct 01 01:06:51 2016 -0500 +++ b/Lib/subprocess.py Sat Oct 01 23:50:09 2016 +0530 @@ -295,7 +295,7 @@ sts = os.system("mycmd" + " myarg") ==> p = Popen("mycmd" + " myarg", shell=True) -pid, sts = os.waitpid(p.pid, 0) +pid, sts = os.waitpid(p.pid) Note: @@ -1545,7 +1545,7 @@ if errpipe_data: try: - pid, sts = os.waitpid(self.pid, 0) + pid, sts = os.waitpid(self.pid) if pid == self.pid: self._handle_exitstatus(sts) else: diff -r 5673cf852daa Lib/test/eintrdata/eintr_tester.py --- a/Lib/test/eintrdata/eintr_tester.py Sat Oct 01 01:06:51 2016 -0500 +++ b/Lib/test/eintrdata/eintr_tester.py Sat Oct 01 23:50:09 2016 +0530 @@ -101,7 +101,7 @@ proc.wait() def test_waitpid(self): - self._test_wait_single(lambda pid: os.waitpid(pid, 0)) + self._test_wait_single(lambda pid: os.waitpid(pid)) @unittest.skipUnless(hasattr(os, 'wait4'), 'requires wait4()') def test_wait4(self): diff -r 5673cf852daa Lib/test/test_mailbox.py --- a/Lib/test/test_mailbox.py Sat Oct 01 01:06:51 2016 -0500 +++ b/Lib/test/test_mailbox.py Sat Oct 01 23:50:09 2016 +0530 @@ -1066,7 +1066,7 @@ # Signal the child it can now release the lock and exit. p.send(b'p') # Wait for child to exit. Locking should now succeed. - exited_pid, status = os.waitpid(pid, 0) + exited_pid, status = os.waitpid(pid) self._box.lock() self._box.unlock() diff -r 5673cf852daa Lib/test/test_os.py --- a/Lib/test/test_os.py Sat Oct 01 01:06:51 2016 -0500 +++ b/Lib/test/test_os.py Sat Oct 01 23:50:09 2016 +0530 @@ -2183,7 +2183,7 @@ args = [sys.executable, '-c', 'pass'] # Add an implicit test for PyUnicode_FSConverter(). pid = os.spawnv(os.P_NOWAIT, _PathLike(args[0]), args) - status = os.waitpid(pid, 0) + status = os.waitpid(pid) self.assertEqual(status, (pid, 0)) @@ -2268,7 +2268,7 @@ def test_nowait(self): args = self.create_args() pid = os.spawnv(os.P_NOWAIT, args[0], args) - result = os.waitpid(pid, 0) + result = os.waitpid(pid) self.assertEqual(result[0], pid) status = result[1] if hasattr(os, 'WIFEXITED'): diff -r 5673cf852daa Lib/test/test_platform.py --- a/Lib/test/test_platform.py Sat Oct 01 01:06:51 2016 -0500 +++ b/Lib/test/test_platform.py Sat Oct 01 23:50:09 2016 +0530 @@ -255,7 +255,7 @@ else: # parent - cpid, sts = os.waitpid(pid, 0) + cpid, sts = os.waitpid(pid) self.assertEqual(cpid, pid) self.assertEqual(sts, 0) diff -r 5673cf852daa Lib/test/test_posix.py --- a/Lib/test/test_posix.py Sat Oct 01 01:06:51 2016 -0500 +++ b/Lib/test/test_posix.py Sat Oct 01 23:50:09 2016 +0530 @@ -171,7 +171,7 @@ os.chdir(os.path.split(sys.executable)[0]) posix.execve(fp, [sys.executable, '-c', 'pass'], os.environ) else: - self.assertEqual(os.waitpid(pid, 0), (pid, 0)) + self.assertEqual(os.waitpid(pid), (pid)) finally: os.close(fp) diff -r 5673cf852daa Lib/test/test_pty.py --- a/Lib/test/test_pty.py Sat Oct 01 01:06:51 2016 -0500 +++ b/Lib/test/test_pty.py Sat Oct 01 23:50:09 2016 +0530 @@ -173,7 +173,7 @@ ## 'Good: OSError was raised.', '']: ## raise TestFailed("Unexpected output from child: %r" % line) - (pid, status) = os.waitpid(pid, 0) + (pid, status) = os.waitpid(pid) res = status >> 8 debug("Child (%d) exited with status %d (%d)." % (pid, res, status)) if res == 1: diff -r 5673cf852daa Lib/test/test_socketserver.py --- a/Lib/test/test_socketserver.py Sat Oct 01 01:06:51 2016 -0500 +++ b/Lib/test/test_socketserver.py Sat Oct 01 23:50:09 2016 +0530 @@ -63,7 +63,7 @@ # Don't raise an exception; it would be caught by the test harness. os._exit(72) yield None - pid2, status = os.waitpid(pid, 0) + pid2, status = os.waitpid(pid) testcase.assertEqual(pid2, pid) testcase.assertEqual(72 << 8, status) @@ -373,7 +373,7 @@ class ForkingErrorTestServer(socketserver.ForkingMixIn, BaseErrorTestServer): def wait_done(self): [child] = self.active_children - os.waitpid(child, 0) + os.waitpid(child) self.active_children.clear() diff -r 5673cf852daa Lib/test/test_ssl.py --- a/Lib/test/test_ssl.py Sat Oct 01 01:06:51 2016 -0500 +++ b/Lib/test/test_ssl.py Sat Oct 01 23:50:09 2016 +0530 @@ -230,7 +230,7 @@ else: os.close(wfd) self.addCleanup(os.close, rfd) - _, status = os.waitpid(pid, 0) + _, status = os.waitpid(pid) self.assertEqual(status, 0) child_random = os.read(rfd, 16) diff -r 5673cf852daa Lib/test/test_subprocess.py --- a/Lib/test/test_subprocess.py Sat Oct 01 01:06:51 2016 -0500 +++ b/Lib/test/test_subprocess.py Sat Oct 01 23:50:09 2016 +0530 @@ -2359,7 +2359,7 @@ stderr=subprocess.PIPE) as proc: pass # p should have been wait()ed on, and removed from the _active list - self.assertRaises(OSError, os.waitpid, pid, 0) + self.assertRaises(OSError, os.waitpid, pid) self.assertNotIn(ident, [id(o) for o in subprocess._active]) def test_close_fds_after_preexec(self): diff -r 5673cf852daa Lib/test/test_threading.py --- a/Lib/test/test_threading.py Sat Oct 01 01:06:51 2016 -0500 +++ b/Lib/test/test_threading.py Sat Oct 01 23:50:09 2016 +0530 @@ -472,7 +472,7 @@ if pid == 0: os._exit(1 if t.is_alive() else 0) else: - pid, status = os.waitpid(pid, 0) + pid, status = os.waitpid(pid) self.assertEqual(0, status) def test_main_thread(self): @@ -501,7 +501,7 @@ print(main.ident == threading.current_thread().ident) print(main.ident == threading.get_ident()) else: - os.waitpid(pid, 0) + os.waitpid(pid) """ _, out, err = assert_python_ok("-c", code) data = out.decode().replace('\r', '') @@ -526,7 +526,7 @@ # we have to flush before exit. sys.stdout.flush() else: - os.waitpid(pid, 0) + os.waitpid(pid) th = threading.Thread(target=f) th.start() @@ -694,7 +694,7 @@ script = """if 1: childpid = os.fork() if childpid != 0: - os.waitpid(childpid, 0) + os.waitpid(childpid) sys.exit(0) t = threading.Thread(target=joiningfunc, @@ -715,7 +715,7 @@ def worker(): childpid = os.fork() if childpid != 0: - os.waitpid(childpid, 0) + os.waitpid(childpid) sys.exit(0) t = threading.Thread(target=joiningfunc, @@ -782,7 +782,7 @@ # just fork a child process and wait it pid = os.fork() if pid > 0: - os.waitpid(pid, 0) + os.waitpid(pid) else: os._exit(0) @@ -815,7 +815,7 @@ else: os._exit(1) else: - _, status = os.waitpid(pid, 0) + _, status = os.waitpid(pid) self.assertEqual(0, status) for t in threads: diff -r 5673cf852daa Lib/test/test_tracemalloc.py --- a/Lib/test/test_tracemalloc.py Sat Oct 01 01:06:51 2016 -0500 +++ b/Lib/test/test_tracemalloc.py Sat Oct 01 23:50:09 2016 +0530 @@ -290,7 +290,7 @@ finally: os._exit(exitcode) else: - pid2, status = os.waitpid(pid, 0) + pid2, status = os.waitpid(pid) self.assertTrue(os.WIFEXITED(status)) exitcode = os.WEXITSTATUS(status) self.assertEqual(exitcode, 0) diff -r 5673cf852daa Lib/test/test_uuid.py --- a/Lib/test/test_uuid.py Sat Oct 01 01:06:51 2016 -0500 +++ b/Lib/test/test_uuid.py Sat Oct 01 23:50:09 2016 +0530 @@ -403,7 +403,7 @@ os.close(fds[1]) self.addCleanup(os.close, fds[0]) parent_value = uuid.uuid4().hex - os.waitpid(pid, 0) + os.waitpid(pid) child_value = os.read(fds[0], 100).decode('latin-1') self.assertNotEqual(parent_value, child_value) diff -r 5673cf852daa Modules/clinic/posixmodule.c.h --- a/Modules/clinic/posixmodule.c.h Sat Oct 01 01:06:51 2016 -0500 +++ b/Modules/clinic/posixmodule.c.h Sat Oct 01 23:50:09 2016 +0530 @@ -2963,7 +2963,7 @@ #if defined(HAVE_WAITPID) PyDoc_STRVAR(os_waitpid__doc__, -"waitpid($module, pid, options, /)\n" +"waitpid($module, /, pid, options=0)\n" "--\n" "\n" "Wait for completion of a given child process.\n" @@ -2974,19 +2974,21 @@ "The options argument is ignored on Windows."); #define OS_WAITPID_METHODDEF \ - {"waitpid", (PyCFunction)os_waitpid, METH_VARARGS, os_waitpid__doc__}, + {"waitpid", (PyCFunction)os_waitpid, METH_FASTCALL, os_waitpid__doc__}, static PyObject * os_waitpid_impl(PyObject *module, pid_t pid, int options); static PyObject * -os_waitpid(PyObject *module, PyObject *args) +os_waitpid(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; + static const char * const _keywords[] = {"pid", "options", NULL}; + static _PyArg_Parser _parser = {"" _Py_PARSE_PID "|i:waitpid", _keywords, 0}; pid_t pid; - int options; - - if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "i:waitpid", + int options = 0; + + if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, &pid, &options)) { goto exit; } @@ -3001,7 +3003,7 @@ #if defined(HAVE_CWAIT) PyDoc_STRVAR(os_waitpid__doc__, -"waitpid($module, pid, options, /)\n" +"waitpid($module, /, pid, options=0)\n" "--\n" "\n" "Wait for completion of a given process.\n" @@ -3012,19 +3014,21 @@ "The options argument is ignored on Windows."); #define OS_WAITPID_METHODDEF \ - {"waitpid", (PyCFunction)os_waitpid, METH_VARARGS, os_waitpid__doc__}, + {"waitpid", (PyCFunction)os_waitpid, METH_FASTCALL, os_waitpid__doc__}, static PyObject * os_waitpid_impl(PyObject *module, intptr_t pid, int options); static PyObject * -os_waitpid(PyObject *module, PyObject *args) +os_waitpid(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; + static const char * const _keywords[] = {"pid", "options", NULL}; + static _PyArg_Parser _parser = {"" _Py_PARSE_INTPTR "|i:waitpid", _keywords, 0}; intptr_t pid; - int options; - - if (!PyArg_ParseTuple(args, "" _Py_PARSE_INTPTR "i:waitpid", + int options = 0; + + if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, &pid, &options)) { goto exit; } @@ -6148,4 +6152,4 @@ #ifndef OS_GETRANDOM_METHODDEF #define OS_GETRANDOM_METHODDEF #endif /* !defined(OS_GETRANDOM_METHODDEF) */ -/*[clinic end generated code: output=b9ed5703d2feb0d9 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=271dd33f2c82eb95 input=a9049054013a1b77]*/ diff -r 5673cf852daa Modules/posixmodule.c --- a/Modules/posixmodule.c Sat Oct 01 01:06:51 2016 -0500 +++ b/Modules/posixmodule.c Sat Oct 01 23:50:09 2016 +0530 @@ -6825,8 +6825,7 @@ /*[clinic input] os.waitpid pid: pid_t - options: int - / + options: int = 0 Wait for completion of a given child process. @@ -6838,7 +6837,7 @@ static PyObject * os_waitpid_impl(PyObject *module, pid_t pid, int options) -/*[clinic end generated code: output=5c37c06887a20270 input=0bf1666b8758fda3]*/ +/*[clinic end generated code: output=5c37c06887a20270 input=dea600de625eec93]*/ { pid_t res; int async_err = 0; @@ -6860,8 +6859,7 @@ /*[clinic input] os.waitpid pid: intptr_t - options: int - / + options: int = 0 Wait for completion of a given process. @@ -6873,7 +6871,7 @@ static PyObject * os_waitpid_impl(PyObject *module, intptr_t pid, int options) -/*[clinic end generated code: output=be836b221271d538 input=40f2440c515410f8]*/ +/*[clinic end generated code: output=be836b221271d538 input=ae2f154feb382cba]*/ { int status; intptr_t res;