-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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-71587: Drop local reference cache to _strptime
module in _datetime
#120224
Conversation
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
_strptime
module in _datetime
_strptime
module in _datetime
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.
LGTM
@kumaraditya303 Thanks for the review. @ericsnowcurrently Maybe off-topic now, but is it possible to access the module state through a static type like: // pycore_typeobject.h
typedef struct {
PyTypeObject *type;
int isbuiltin;
....
+ PyObject *current_ext_module // weak ref? or borrowed ref?
} managed_static_type_state; Then, |
That definitely could work. It's worth looking into for 3.14. |
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.
LGTM
This should be backported to 3.13, right? |
I agree to the 3.13 backport. |
Thanks @neonene for the PR, and @ericsnowcurrently for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
…_datetime` (pythongh-120224) The _strptime module object was cached in a static local variable (in the datetime.strptime() implementation). That's a problem when it crosses isolation boundaries, such as reinitializing the runtme or between interpreters. This change fixes the problem by dropping the static variable, instead always relying on the normal sys.modules cache (via PyImport_Import()). (cherry picked from commit 127c1d2) Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
GH-120424 is a backport of this pull request to the 3.13 branch. |
I just realized this fixes a long-standing problem and is not related to the recent work on |
Thanks @neonene for the PR, and @ericsnowcurrently for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
Sorry, @neonene and @ericsnowcurrently, I could not cleanly backport this to
|
@neonene, would you have time to do the 3.12 backport? I'm sure it won't require much effort. |
…`_datetime` (gh-120424) The _strptime module object was cached in a static local variable (in the datetime.strptime() implementation). That's a problem when it crosses isolation boundaries, such as reinitializing the runtme or between interpreters. This change fixes the problem by dropping the static variable, instead always relying on the normal sys.modules cache (via PyImport_Import()). (cherry picked from commit 127c1d2, AKA gh-120224) Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
GH-120431 is a backport of this pull request to the 3.12 branch. |
Thanks @ericsnowcurrently, @erlend-aasland for reviewing this, and thanks again @kumaraditya303. |
…`_datetime` (gh-120431) The _strptime module object was cached in a static local variable (in the datetime.strptime() implementation). That's a problem when it crosses isolation boundaries, such as reinitializing the runtme or between interpreters. This change fixes the problem by dropping the static variable, instead always relying on the normal sys.modules cache (via PyImport_Import()). (cherry picked from commit 127c1d2, AKA gh-120224)
…_datetime` (pythongh-120224) The _strptime module object was cached in a static local variable (in the datetime.strptime() implementation). That's a problem when it crosses isolation boundaries, such as reinitializing the runtme or between interpreters. This change fixes the problem by dropping the static variable, instead always relying on the normal sys.modules cache (via PyImport_Import()).
…_datetime` (pythongh-120224) The _strptime module object was cached in a static local variable (in the datetime.strptime() implementation). That's a problem when it crosses isolation boundaries, such as reinitializing the runtme or between interpreters. This change fixes the problem by dropping the static variable, instead always relying on the normal sys.modules cache (via PyImport_Import()).
…_datetime` (pythongh-120224) The _strptime module object was cached in a static local variable (in the datetime.strptime() implementation). That's a problem when it crosses isolation boundaries, such as reinitializing the runtme or between interpreters. This change fixes the problem by dropping the static variable, instead always relying on the normal sys.modules cache (via PyImport_Import()).
For 3.13 and newer, this PR fixes the following errors
by making each loadedby importing_datetime
module use its own reference cache to_strptime
module. The cache will be the same as the reference insys.modules
of the corresponding interpreter_strptime
module on eachstrptime()
function call.Main interpreter:
Sub interpreter:
cc @ericsnowcurrently @erlend-aasland