-
-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-90872: Fix subprocess.Popen.wait() for negative timeout #116989
Conversation
On Windows, subprocess.Popen.wait() no longer calls WaitForSingleObject() with a negative timeout: pass 0 ms if the timeout is negative.
How difficult is to write test? |
I added a test. Please review the updated change. |
How difficult is to write test without mocking? |
I would prefer to not have to reimplement "wait until a process completes" in test_subprocess. What is the problem with mocking? |
I prefer the mocking in this case, as it's testing a change to our logic. Fixing the DWORD converter would be worth a deeper test, but we know its behaviour right now is wrong, and so we just want to make sure we don't pass it a risky value. |
I have it on my TODO list for 3 years: see https://discuss.python.org/t/conversion-between-python-and-c-integers/44117 discussion. Changing the default behavior is non trivial. It's a low-priority for me. So I wrote this "trivial" change to fix at least subprocess. Anyway, if DWORD converter is changed, I suppose that in the future, it will raise an exception (maybe after a deprecation period), so it's better to not pass negative values :-) |
The change itself in this PR is simple, and it can go without tests (if it is difficult to write proper tests). My concern is that it may be not enough, and there may be other places that need a fix for this case or similar cases. If it is not too difficult, I would prefer a test without mocking. |
This change does have a test, it's just the originally observed (bad) behaviour does not. |
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12. |
Sorry, @vstinner, I could not cleanly backport this to
|
Sorry, @vstinner, I could not cleanly backport this to
|
GH-117002 is a backport of this pull request to the 3.12 branch. |
GH-117003 is a backport of this pull request to the 3.11 branch. |
Merged, thanks for your reviews! |
…hon#116989) On Windows, subprocess.Popen.wait() no longer calls WaitForSingleObject() with a negative timeout: pass 0 ms if the timeout is negative. (cherry picked from commit 27cf3ed)
…hon#116989) On Windows, subprocess.Popen.wait() no longer calls WaitForSingleObject() with a negative timeout: pass 0 ms if the timeout is negative.
…hon#116989) On Windows, subprocess.Popen.wait() no longer calls WaitForSingleObject() with a negative timeout: pass 0 ms if the timeout is negative.
…hon#116989) On Windows, subprocess.Popen.wait() no longer calls WaitForSingleObject() with a negative timeout: pass 0 ms if the timeout is negative.
On Windows, subprocess.Popen.wait() no longer calls WaitForSingleObject() with a negative timeout: pass 0 ms if the timeout is negative.