Skip to content

Conversation

@pull
Copy link

@pull pull bot commented Feb 10, 2026

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )


📚 Documentation preview 📚: https://cpython-previews--747.org.readthedocs.build/

gpshead and others added 8 commits February 10, 2026 14:08
Fix a race condition where a thread could receive a partially-initialized
module when another thread's import fails. The race occurs when:

1. Thread 1 starts importing, adds module to sys.modules
2. Thread 2 sees the module in sys.modules via the fast path
3. Thread 1's import fails, removes module from sys.modules
4. Thread 2 returns a stale module reference not in sys.modules

The fix adds verification after the "skip lock" optimization in both Python
and C code paths to check if the module is still in sys.modules. If the
module was removed (due to import failure), we retry the import so the
caller receives the actual exception from the import failure rather than
a stale module reference.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Fix compilation on C++.

Add test on PyDateTime_IMPORT in test_cext and test_cppext.
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
The 'module' argument is now always needed to call the test_datetime
method.
@pull pull bot locked and limited conversation to collaborators Feb 10, 2026
@pull pull bot added the ⤵️ pull label Feb 10, 2026
@pull pull bot merged commit eb6d0e0 into tj-python:main Feb 10, 2026
7 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants