FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-158824: Fix `__getattr__` blocking reification of lazy imports by brittanyrey · Pull Request #158825 · python/cpython · GitHub

Repository navigation

gh-158824: Fix __getattr__ blocking reification of lazy imports - #158825

Merged
encukou merged 4 commits into
python:mainfrom
brittanyrey:b-lazy-module-getattr-precedence
Oct 8, 2026
Merged

encukou merged 4 commits into
python:mainfrom
brittanyrey:b-lazy-module-getattr-precedence

Conversation

brittanyrey commented Oct 5, 2026 •
edited
Loading

Copy link
Copy Markdown
Contributor

Module attribute lookup called the module's getattr before resolving a lazy import placeholder.
That was the fix for gh-144957, needed while lazy from imports put placeholders into the source module. gh-150052 removed that, so the check now only shadows a module's own lazy imports.

This fixes that issue and adds a new load bearing test.

When a module attribute was a lazy import placeholder, module attribute
lookup called the module's __getattr__ before resolving it. This was
needed while lazy from-imports published placeholders on the source
module. That no longer happens, so the check only affected the module's
own lazy imports: a catch-all __getattr__ hid them, unlike eager imports.

Resolve the placeholder directly.

pablogsal 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM!

Copy link
Copy Markdown
Contributor Author

Updated the news entry per request

encukou merged commit 56f9837 into python:main Oct 8, 2026
89 of 105 checks passed

Copy link
Copy Markdown

Thanks @brittanyrey for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

bedevere-app Bot commented Oct 8, 2026

Copy link
Copy Markdown

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

bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Oct 8, 2026
brittanyrey deleted the b-lazy-module-getattr-precedence branch October 9, 2026 13:41
encukou pushed a commit that referenced this pull request Oct 12, 2026
…rts (GH-158825) (GH-159022)

When a module attribute was a lazy import placeholder, module attribute
lookup called the module's __getattr__ before resolving it. This was
needed while lazy from-imports published placeholders on the source
module. That no longer happens, so the check only affected the module's
own lazy imports: a catch-all __getattr__ hid them, unlike eager imports.

Resolve the placeholder directly.
(cherry picked from commit 56f9837)

Co-authored-by: Brittany Reynoso <breynoso@meta.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

3 participants


Back | FazBrowse Home | New Git URL