Skip to content

gh-153236: Propagate lazy submodule import errors#153237

Merged
pablogsal merged 1 commit into
python:mainfrom
pablogsal:gh-153236-lazy-submodule-errors
Jul 18, 2026
Merged

gh-153236: Propagate lazy submodule import errors#153237
pablogsal merged 1 commit into
python:mainfrom
pablogsal:gh-153236-lazy-submodule-errors

Conversation

@pablogsal

@pablogsal pablogsal commented Jul 6, 2026

Copy link
Copy Markdown
Member

I have chosen to make lazy submodule resolution explicit instead of classifying the exception after a failed import. A real module can raise ModuleNotFoundError with its own name while executing, so the exception doesn reliably tell us whether the finder failed or the loader failed.

I think the superior way here is to do this in importlib's find/load boundary. No spec means the lazy submodule is absent and attribute lookup can continue. Once a spec exists, the submodule is real, so any later exception propagates normally.

@pablogsal

Copy link
Copy Markdown
Member Author

CC @brittanyrey

@pablogsal
pablogsal force-pushed the gh-153236-lazy-submodule-errors branch from 9a3039d to 1c296cf Compare July 6, 2026 23:14
@brettcannon
brettcannon removed their request for review July 7, 2026 18:01
@kumaraditya303
kumaraditya303 removed their request for review July 8, 2026 09:35
@johnslavik
johnslavik self-requested a review July 18, 2026 11:06
@pablogsal
pablogsal force-pushed the gh-153236-lazy-submodule-errors branch from 1c296cf to d183e5f Compare July 18, 2026 11:31
@pablogsal
pablogsal force-pushed the gh-153236-lazy-submodule-errors branch from d183e5f to 9a64b35 Compare July 18, 2026 11:49
@pablogsal
pablogsal merged commit 0a09daf into python:main Jul 18, 2026
54 checks passed
@pablogsal
pablogsal deleted the gh-153236-lazy-submodule-errors branch July 18, 2026 12:28
@pablogsal pablogsal added the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jul 18, 2026
@miss-islington-app

Copy link
Copy Markdown

Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Jul 18, 2026

Copy link
Copy Markdown

GH-153936 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 Jul 18, 2026
pablogsal added a commit that referenced this pull request Jul 18, 2026
…153936)

gh-153236: Propagate lazy submodule import errors (GH-153237)
(cherry picked from commit 0a09daf)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant