Skip to content

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

@brittanyrey brittanyrey commented Oct 5, 2026 •

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

LGTM!

Comment thread Misc/NEWS.d/next/Core_and_Builtins/2026-10-05-03-25-30.gh-issue-158824.h-hJj7.rst Outdated
@brittanyrey

Copy link
Copy Markdown
Contributor Author

Updated the news entry per request

@encukou
encukou merged commit 56f9837 into python:main Oct 8, 2026
89 of 105 checks passed
@encukou encukou added awaiting merge needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Oct 8, 2026
@miss-islington-app

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

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 bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Oct 8, 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.

3 participants