Skip to content

gh-150579: use lazy imports for concurrent.futures#150585

Merged
gpshead merged 2 commits into
python:mainfrom
henryiii:henryiii/fix/lazyconcurrentfutures
Jul 3, 2026
Merged

gh-150579: use lazy imports for concurrent.futures#150585
gpshead merged 2 commits into
python:mainfrom
henryiii:henryiii/fix/lazyconcurrentfutures

Conversation

@henryiii

@henryiii henryiii commented May 29, 2026

Copy link
Copy Markdown
Contributor

This module has a manual lazy import hack using __getattr__. Now that lazy imports exist and cannot be disabled, this could use lazy imports instead.

Key differences: this will now show up in sys.lazy_modules when accessed. Error messages should be a bit better without the wrapper __getattr__ involved. That's the only differences I can think of.

Closes #150579 (though that can be closed without this, the bug was already fixed in #144957).

This module has a manual lazy import hack using `__getattr__`. Now that lazy imports exist and cannot be disabled, this could use lazy imports instead.

Key differences: this will now show up in sys.lazy_modules when accessed. Error messages should be a bit better without the wrapper `__getattr__` involved.  That's the only differences I can think of.

Signed-off-by: Henry Schreiner <henryfs@princeton.edu>

@gpshead gpshead left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea, thanks!

@gpshead gpshead added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jul 3, 2026
@gpshead gpshead self-assigned this Jul 3, 2026
@gpshead gpshead force-pushed the henryiii/fix/lazyconcurrentfutures branch from e390518 to cdd9aef Compare July 3, 2026 17:37
@gpshead gpshead enabled auto-merge (squash) July 3, 2026 17:39
@gpshead gpshead merged commit 423ae0f into python:main Jul 3, 2026
51 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @henryiii for the PR, and @gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Jul 3, 2026

Copy link
Copy Markdown

GH-152975 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jul 3, 2026
gpshead added a commit that referenced this pull request Jul 4, 2026
…#152975)

gh-150579: use lazy imports for concurrent.futures (GH-150585)

This module has a manual lazy import hack using `__getattr__`. Now that lazy imports exist and cannot be disabled, this could use lazy imports instead.

Key differences: this will now show up in sys.lazy_modules when accessed. Error messages should be a bit better without the wrapper `__getattr__` involved.  That's the only differences I can think of.
(cherry picked from commit 423ae0f)

Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
Co-authored-by: Henry Schreiner <henryfs@princeton.edu>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3.15: Lazy imports break with __getattr__ (concurrent.futures)

2 participants