Skip to content

GH-151619: Ensure non-module global/builtin namespaces are watched for lazy imports#151762

Open
brandtbucher wants to merge 2 commits into
python:mainfrom
brandtbucher:codex/lazy-import-dict-watchers
Open

GH-151619: Ensure non-module global/builtin namespaces are watched for lazy imports#151762
brandtbucher wants to merge 2 commits into
python:mainfrom
brandtbucher:codex/lazy-import-dict-watchers

Conversation

@brandtbucher

@brandtbucher brandtbucher commented Jun 19, 2026

Copy link
Copy Markdown
Member

Using non-module global or builtin namespaces (such as dictionaries passed to exec) can currently cause cached global loads to produce unresolved lazy imports. Check for this and make sure all relevant namespaces are watched when specializing global loads.

Separately: this patch preserves the behavior that lazy imports in the builtins are resolved when they're looked up. This seems like sort of a niche edge case, but I think the current behavior makes sense (builtins is a module, after all).

@brandtbucher brandtbucher added type-bug An unexpected behavior, bug, or error interpreter-core (Objects, Python, Grammar, and Parser dirs) topic-lazy-imports needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review interpreter-core (Objects, Python, Grammar, and Parser dirs) needs backport to 3.15 pre-release feature fixes, bugs and security fixes topic-lazy-imports type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant