gh-90872: Fix subprocess.Popen.wait() for negative timeout (#116989)

On Windows, subprocess.Popen.wait() no longer calls
WaitForSingleObject() with a negative timeout: pass 0 ms if the
timeout is negative.
This commit is contained in:
Victor Stinner
2024-03-19 14:42:44 +01:00
committed by GitHub
parent 408e127159
commit 27cf3ed00c
3 changed files with 21 additions and 0 deletions

View File

@@ -1586,6 +1586,8 @@ class Popen:
"""Internal implementation of wait() on Windows."""
if timeout is None:
timeout_millis = _winapi.INFINITE
elif timeout <= 0:
timeout_millis = 0
else:
timeout_millis = int(timeout * 1000)
if self.returncode is None: