Skip to content

Conversation

@neonene
Copy link
Contributor

@neoneneneonene commented Apr 16, 2025

This converts the IsoCalendarDate heap type back to the static type used in 3.12,
so that the _datetime will not heavily depend on its module state.

Unlike #132665, this does not extend the interpreter state.

Previous attempt

Currently, the _datetime module is cached in sys.modules. We acquire the cache through a weakref in each interpreter's dict, checking if a module was once loaded before in order not to re-initialize the C-API static types.
This PR directly caches the module into the interp dict, allowing the cache to be released only when replaced with a new one. It may be memory inefficient, but the module needs to keep alive even after sys.modules is unavailable.

@neoneneneonene changed the title gh-132413: datetime: Fix crash when used during interpreter shutdowngh-132413: datetime: Fix crash when used during interp shutdownApr 16, 2025
@neoneneneonene marked this pull request as ready for review April 16, 2025 14:48
@neonene
Copy link
ContributorAuthor

@neoneneneonene marked this pull request as draft April 17, 2025 21:03
@neonene

This comment was marked as outdated.

@neoneneneonene closed this Apr 18, 2025
@neoneneneonene reopened this Apr 20, 2025
@neoneneneonene changed the title gh-132413: datetime: Fix crash when used during interp shutdowngh-132413: Fix crash in _datetime when used at shutdown (alt)Apr 20, 2025
@neoneneneonene marked this pull request as ready for review April 20, 2025 23:07
@neoneneneonene closed this Apr 27, 2025
@neoneneneonene reopened this Apr 30, 2025
@neoneneneonene closed this Apr 30, 2025
@neoneneneonene reopened this May 7, 2025
@neoneneneonene changed the title gh-132413: Fix crash in _datetime when used at shutdown (alt)gh-132413: Fix crash in _datetime when used at shutdownMay 7, 2025
@neonene
Copy link
ContributorAuthor

neonene commented May 8, 2025

Please take a look.

@neoneneneonene marked this pull request as draft June 30, 2025 21:34
@neoneneneonene closed this Jul 2, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@neonene