-
-
Notifications
You must be signed in to change notification settings - Fork 31.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-116664: Ensure thread-safe dict access in _warnings #116768
gh-116664: Ensure thread-safe dict access in _warnings #116768
Conversation
cedf1cf
to
4d4371c
Compare
Python/_warnings.c
Outdated
*module = PyUnicode_FromString("<string>"); | ||
if (*module == NULL) | ||
goto handle_error; | ||
} | ||
else { | ||
assert(Py_IsNone(*module) || PyUnicode_Check(*module)); |
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.
I think we need to handle the case where *module
(i.e., __name__
) is not None
and not a unicode object because Python code can set __name__
arbitrarily.
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.
4f3cd02 should fix that case:
If None or a unicode object, return successfully; else decref and fall through to the no-key case.
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.
Note, there is no test case for this in the test suite.
Thanks for the review! |
…116768) Replace _PyDict_GetItemWithError() with PyDict_GetItemRef().
…116768) Replace _PyDict_GetItemWithError() with PyDict_GetItemRef().
…116768) Replace _PyDict_GetItemWithError() with PyDict_GetItemRef().
Replace _PyDict_GetItemWithError() with PyDict_GetItemRef().
_warnings.c
thread-safe in free-threaded build #116664