Skip to content

gh-159288: Avoid segfault by adding missing recursion checks when walking lazy import chains - #159289

Open
brittanyrey wants to merge 1 commit into
python:mainfrom
brittanyrey:b-lazy-import-deep-chain
Open

brittanyrey wants to merge 1 commit into
python:mainfrom
brittanyrey:b-lazy-import-deep-chain

Conversation

@brittanyrey

@brittanyrey brittanyrey commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

lazy import a.b.c as d nests one placeholder per name component. lazy_import_path() and lazy_import_replay_from() recursed over that chain without a recursion check, so a very long dotted name could overflow the stack.

Add guards to raise a RecursionError instead of failing into a segfault.

`lazy import a.b.c as d` nests one placeholder per name component.
lazy_import_path() and lazy_import_replay_from() recursed over that
chain without a recursion check, so a very long dotted name could
overflow the C stack. Raise RecursionError instead, as the rest of
lazy import resolution does.
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