Skip to content

[3.14] gh-136421: Load _datetime static types during interpreter initialization (GH-136583) #136943

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 21, 2025

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jul 21, 2025

_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 a109606)

Co-authored-by: Peter Bierma zintensitydev@gmail.com

…tialization (pythonGH-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>
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @ZeroIntensity for commit 4912c10 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F136943%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Jul 21, 2025
@ZeroIntensity
Copy link
Member

@hugovk Just want to make sure that this one is good with you before landing it. It fixes crashes with the subinterpreter APIs, but is also a risky change in the sense that we're making _datetime static (and thus required to build CPython).

@hugovk
Copy link
Member

hugovk commented Jul 21, 2025

@ZeroIntensity Go ahead when the buildbots are ready, thanks for the ping.

@ZeroIntensity
Copy link
Member

Most of them have passed, I'm confident that this is good to go.

@ZeroIntensity ZeroIntensity merged commit ecd97ca into python:3.14 Jul 21, 2025
123 of 126 checks passed
@zanieb
Copy link
Contributor

zanieb commented Jul 22, 2025

For future reference, this did break our downstream build at astral-sh/python-build-standalone#710 — it's not a big deal but I was surprised to see a change like this in the release candidate. Seems like a decent trade-off given it was fixing crashes, but figure the signal might be helpful.

@geofft
Copy link
Contributor

geofft commented Jul 22, 2025

Yes but that's because we're reimplementing Modules/Setup for complicated reasons, right? If I understand correctly, the build system in CPython was stable into the release candidate, we're just choosing to mess around with implementation details of the build system that I don't think CPython should be expected to keep stable, if I understand correctly. (And our build correctly failed because we have checks that our reimplementation matches what is actually distributed by CPython.)

@zanieb
Copy link
Contributor

zanieb commented Jul 23, 2025

Yeah our situation is bespoke, but changes to how extension modules are built are still significant. I'm not really sure what there is to debate though, since I agree with you and was just leaving the note for reference :)

@ZeroIntensity
Copy link
Member

Thanks for the heads up. Would it be helpful to perhaps document this in the whatsnew somewhere?

@zanieb
Copy link
Contributor

zanieb commented Jul 23, 2025

I don't think that'd make a difference to me, I found this pull request pretty easily. Maybe another downstream will feel differently though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy