Skip to content

[3.15] gh-159288: Avoid segfault by adding missing recursion checks when walking lazy import chains (GH-159289) - #159416

Merged
Yhg1s merged 1 commit into
python:3.15from
miss-islington:backport-2588362-3.15
Oct 14, 2026
Merged

Yhg1s merged 1 commit into
python:3.15from
miss-islington:backport-2588362-3.15

Conversation

@miss-islington

@miss-islington miss-islington commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Add missing recursion checks when walking lazy import chains

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.
(cherry picked from commit 2588362)

Co-authored-by: Brittany Reynoso breynoso@meta.com

…en walking lazy import chains (pythonGH-159289)

Add missing recursion checks when walking lazy import chains

`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.
(cherry picked from commit 25883627946b7cbcf7286acfe2a2019382375325)

Co-authored-by: Brittany Reynoso <breynoso@meta.com>
@Yhg1s
Yhg1s merged commit 72ab890 into python:3.15 Oct 14, 2026
56 checks passed
@miss-islington
miss-islington deleted the backport-2588362-3.15 branch October 14, 2026 14:46
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.

3 participants