Uh oh!
There was an error while loading. Please reload this page.
gh-71587: Drop local reference cache to _strptime module in _datetime - #120224
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
_strptime module in _datetime_strptime module in _datetimeneonene
commented
Jun 9, 2024
@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, |
ericsnowcurrently
commented
Jun 12, 2024
That definitely could work. It's worth looking into for 3.14. |
Uh oh!
There was an error while loading. Please reload this page.
ericsnowcurrently
commented
Jun 12, 2024
This should be backported to 3.13, right? |
neonene
commented
Jun 12, 2024
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. |
ericsnowcurrently
commented
Jun 12, 2024
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 |
ericsnowcurrently
commented
Jun 12, 2024
@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. |
neonene
commented
Jun 12, 2024
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_datetimemodule use its own reference cache to_strptimemodule. The cache will be the same as the reference insys.modulesof the corresponding interpreter_strptimemodule on eachstrptime()function call.Main interpreter:
Sub interpreter:
cc @ericsnowcurrently@erlend-aasland