]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-136421: Load `_datetime` static types during interpreter initialization (GH-136583)
authorPeter Bierma <zintensitydev@gmail.com>
Mon, 21 Jul 2025 17:47:26 +0000 (12:47 -0500)
committerGitHub <noreply@github.com>
Mon, 21 Jul 2025 17:47:26 +0000 (13:47 -0400)
commita10960699a2b3e4e62896331c4f9cfd162ebf440
tree8b77af281590c5ffb81e89527aaf3cc606fd6917
parent80b2d60a51cfd824d025eb8b3ec500acce5c010c
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.
Include/internal/pycore_pylifecycle.h
Lib/test/datetimetester.py
Misc/NEWS.d/next/Core_and_Builtins/2025-07-12-09-59-14.gh-issue-136421.ZD1rNj.rst [new file with mode: 0644]
Modules/Setup.bootstrap.in
Modules/Setup.stdlib.in
Modules/_datetimemodule.c
PCbuild/_freeze_module.vcxproj
Python/pylifecycle.c