gh-141563: make PyDateTime_IMPORT thread-safe#144210
Merged
kumaraditya303 merged 6 commits intopython:mainfrom Feb 9, 2026
Merged
gh-141563: make PyDateTime_IMPORT thread-safe#144210kumaraditya303 merged 6 commits intopython:mainfrom
PyDateTime_IMPORT thread-safe#144210kumaraditya303 merged 6 commits intopython:mainfrom
Conversation
ea5a3ea to
a6f6595
Compare
3b08a06 to
96a62cb
Compare
96a62cb to
36a06c8
Compare
vstinner
reviewed
Jan 27, 2026
vstinner
reviewed
Feb 2, 2026
|
|
||
| #define PyDateTime_IMPORT \ | ||
| PyDateTimeAPI = (PyDateTime_CAPI *)PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0) | ||
| static inline PyDateTime_CAPI * |
scoder
reviewed
Feb 10, 2026
| PyDateTimeAPI = (PyDateTime_CAPI *)PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0) | ||
| static inline PyDateTime_CAPI * | ||
| _PyDateTime_IMPORT(void) { | ||
| PyDateTime_CAPI *val = _Py_atomic_load_ptr(&PyDateTimeAPI); |
Contributor
There was a problem hiding this comment.
I'm now seeing this error in external code that includes datetime.h:
…/cpython_install/include/python3.15/datetime.h:201:22: error: cannot initialize a variable of type 'PyDateTime_CAPI *' with an rvalue of type 'void *'
201 | PyDateTime_CAPI *val = _Py_atomic_load_ptr(&PyDateTimeAPI);
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Probably just missing a cast.
Member
There was a problem hiding this comment.
Do you get the error with C or C++?
Member
There was a problem hiding this comment.
Ah, there is a compiler error in C++. I wrote #144667 to add the missing cast, but also to add checks for compiler warnings (to test_cext and test_cppext).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
datetimeC API is not thread-safe #141563