You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
gh-146302: make Py_IsInitialized() thread-safe and reflect true init completion
Py_IsInitialized() previously returned 1 before Py_InitializeEx() had
finished, because the runtime flag was set before site.py was imported.
This caused a race in embedders like PyO3 where a second thread could
observe an initialized interpreter before sys.path was fully configured.
Move the initialized=1 store to the end of init_interp_main(), after
site import, lazy imports, tier 2 optimizer, and dict watcher setup.
Access both `initialized` and `core_initialized` through new inline
accessors that use acquire/release atomics, eliminating the C-standard
data race and ensuring correct visibility on weakly-ordered
architectures.
Fix PySys_AddAuditHook() to check core_initialized (not initialized)
when deciding whether a thread state is available, since tstate exists
after core init completes.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0 commit comments