-
-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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-98624 Add mutex to unittest.mock.NonCallableMock #98688
gh-98624 Add mutex to unittest.mock.NonCallableMock #98688
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR.
I left a few comments from my side and please feel free to take them or leave them.
A more general question would be - do we have a way to automated-test this?
I've been thinking about that too. It's really hard to test because it's such a subtle race condition. The test I created in the minimal reproducible example for #98624 only consistently demonstrates the bug because I added synchronization directly inside the standard library. Without doing that, I believe any test would only fail non-deterministically rather than every time. Would it be ok to just add a link to the issue in the comments? Unless you or someone else can think of a way to test this bug consistently? |
Oops, I didn't realize re-requesting a review would remove the request for @cjw296! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look good to me. Let's see what Chris @cjw296 says.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me :-)
Thanks @noah-weingarden for the PR, and @cjw296 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11. |
Thanks @noah-weingarden for the PR, and @cjw296 for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10. |
…8688) * Added lock to NonCallableMock in unittest.mock * Add blurb * Nitpick blurb * Edit comment based on @Jason-Y-Z's review * Add link to GH issue (cherry picked from commit 0346edd) Co-authored-by: noah-weingarden <33741795+noah-weingarden@users.noreply.github.com>
GH-98797 is a backport of this pull request to the 3.11 branch. |
…8688) * Added lock to NonCallableMock in unittest.mock * Add blurb * Nitpick blurb * Edit comment based on @Jason-Y-Z's review * Add link to GH issue (cherry picked from commit 0346edd) Co-authored-by: noah-weingarden <33741795+noah-weingarden@users.noreply.github.com>
GH-98798 is a backport of this pull request to the 3.10 branch. |
@pablogsal - how far are we backporting bugfixes now? 3.6 onwards right? ;-) |
3.10 onwards unless it's security-related. |
Thanks for looking into this! :) |
@ambv - wow, for many of us, 3.10 is the "new shiny we're super excited about eventually moving on to"! |
* Added lock to NonCallableMock in unittest.mock * Add blurb * Nitpick blurb * Edit comment based on @Jason-Y-Z's review * Add link to GH issue
Closes #98624. I'm open to any and all feedback!
unittest.mock
#98624