Skip to content

gh-152297: Reify dotted lazy imports with the full dotted name#152307

Closed
Kuhai9801 wants to merge 3 commits into
python:mainfrom
Kuhai9801:gh-152297-dotted-lazy-import-minimal
Closed

gh-152297: Reify dotted lazy imports with the full dotted name#152307
Kuhai9801 wants to merge 3 commits into
python:mainfrom
Kuhai9801:gh-152297-dotted-lazy-import-minimal

Conversation

@Kuhai9801

@Kuhai9801 Kuhai9801 commented Jun 26, 2026

Copy link
Copy Markdown

Fix lazy reification for dotted imports so lazy import pkg.sub calls __import__ with the full dotted name, matching eager import behavior.

The regression tests cover custom __import__ hooks and first-use loading of the dotted target.

Tests:

  • git diff --check
  • GitHub Actions required checks after squash

@python-cla-bot

python-cla-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@Kuhai9801 Kuhai9801 force-pushed the gh-152297-dotted-lazy-import-minimal branch 3 times, most recently from 85a1a27 to e2f3da0 Compare June 28, 2026 07:35
@Kuhai9801 Kuhai9801 force-pushed the gh-152297-dotted-lazy-import-minimal branch from e2f3da0 to 18ced5b Compare June 28, 2026 08:16
@Kuhai9801 Kuhai9801 marked this pull request as ready for review June 28, 2026 08:45
@Kuhai9801

Copy link
Copy Markdown
Author

The remaining Emscripten failure appears unrelated to this PR; it fails in test_profiling thread startup, outside the lazy-import changes.

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

Thanks for the PR! I think this still misses one dotted import case.

Comment thread Python/import.c
);
Py_DECREF(name);
}
obj = _PyEval_ImportNameWithImport(

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.

Unless I am missing something, lazy import pkg.sub as alias still misses this. That path goes through _PyEval_LazyImportFrom() and reifies as __import__("pkg", fromlist=("sub",)), while eager import pkg.sub as alias calls __import__("pkg.sub", fromlist=()). We should fix/test that case as well.

@Kuhai9801 Kuhai9801 requested a review from markshannon as a code owner June 28, 2026 18:59
@pablogsal

pablogsal commented Jun 28, 2026

Copy link
Copy Markdown
Member

Sorry I am going to also close this PR. You keep using AI without reviewing the code is producing and this is making review harder. You also keep adding api functions to everywhere which I don't understand why is needed. You are not weighting on the changes you produce

Please stop this behavior or we will need to escalate

@pablogsal pablogsal closed this Jun 28, 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.

2 participants