gh-136421: Load _datetime static types during interpreter initialization (GH-136583)

`_datetime` is a special module, because it's the only non-builtin C extension that contains static types. As such, it would initialize static types in the module's execution function, which can run concurrently. Since static type initialization is not thread-safe, this caused crashes. This fixes it by moving the initialization of `_datetime`'s static types to interpreter startup (where all other static types are initialized), which is already properly protected through other locks.
This commit is contained in:
Peter Bierma 2025-07-21 12:47:26 -05:00 committed by GitHub
parent 80b2d60a51
commit a10960699a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 111 additions and 95 deletions

View file

@ -12,6 +12,8 @@ posix posixmodule.c
_signal signalmodule.c
_tracemalloc _tracemalloc.c
_suggestions _suggestions.c
# needs libm and on some platforms librt
_datetime _datetimemodule.c
# modules used by importlib, deepfreeze, freeze, runpy, and sysconfig
_codecs _codecsmodule.c