Skip to content

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

Open
brittanyrey wants to merge 4 commits into
python:mainfrom
brittanyrey:b-lazy-module-getattr-precedence
Open

brittanyrey wants to merge 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

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.

2 participants