]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.14] gh-136421: Load `_datetime` static types during interpreter initialization...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 21 Jul 2025 23:23:05 +0000 (01:23 +0200)
committerGitHub <noreply@github.com>
Mon, 21 Jul 2025 23:23:05 +0000 (19:23 -0400)
commitecd97caaf5923764d22f6bd29339b8416c0c1917
tree543dec9de45258ad7ba6967ff58c8971e6ad306a
parent718fc5b1393d9ce52fc0353fb361818e865e3e45
[3.14] gh-136421: Load `_datetime` static types during interpreter initialization (GH-136583) (GH-136943)

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.
(cherry picked from commit a10960699a2b3e4e62896331c4f9cfd162ebf440)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
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