Skip to content

gh-156341: Fix threading local fallback import - #157042

Open
Sohel2309 wants to merge 2 commits into
python:mainfrom
Sohel2309:fix-156341-threading-local
Open

gh-156341: Fix threading local fallback import#157042
Sohel2309 wants to merge 2 commits into
python:mainfrom
Sohel2309:fix-156341-threading-local

Conversation

@Sohel2309

@Sohel2309 Sohel2309 commented Sep 6, 2026

Copy link
Copy Markdown

Fixes #156341.

When _thread._local is unavailable, importing threading falls back to the pure Python _threading_local implementation. The fallback currently creates a circular initialization path that prevents threading from importing.

This change delays _thread_local_info initialization until after the main thread is registered and updates the fallback implementation to use the threading module explicitly.

Adds a regression test for the fallback import path.

@python-cla-bot

python-cla-bot Bot commented Sep 6, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@bedevere-app

bedevere-app Bot commented Sep 6, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

@Sohel2309 Sohel2309 changed the title Fix threading local fallback import gh-156341: Fix threading local fallback import Sep 6, 2026
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.

Broken circular import between threading and _threading_local

1 participant