Skip to content

gh-158597: Keep private import hooks out of shared lazy submodules - #162392

Open
pablogsal wants to merge 1 commit into
python:mainfrom
pablogsal:gh-158597-isolate-lazy-import-hooks
Open

pablogsal wants to merge 1 commit into
python:mainfrom
pablogsal:gh-158597-isolate-lazy-import-hooks

Conversation

@pablogsal

Copy link
Copy Markdown
Member

When two namespaces lazily import the same submodule, a later declaration with private builtins can replace the shared entry. Another namespace can then call that declaration's __import__ hook.

Use a neutral entry for private builtins mappings, which already resolve the full dotted name through their own hook. The entry cannot replace an ordinary declaration. Direct lazy bindings retain their hook. With only private declarations, shared package access follows the lazy from path. That path bypasses __import__ for the child request.

This addresses the hook-selection case from the discussion on gh-158521, related to gh-158597.

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.

1 participant