[mypyc] Fix compiler crash for empty async with body by JukkaL · Pull Request #21984 · python/mypy · GitHub
Skip to content

[mypyc] Fix compiler crash for empty async with body - #21984

Merged
JukkaL merged 2 commits into
masterfrom
mypyc-fix-async-with-spill
Sep 15, 2026
Merged

JukkaL merged 2 commits into
masterfrom
mypyc-fix-async-with-spill

Conversation

@JukkaL

@JukkaL JukkaL commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Fix a regression introduced by #21982. CFG cleanup correctly removes an unreachable exception-handler block, but generated resume cleanup paths still reference its raw CPy_CatchError CallC result. This leaves malformed IR and causes a KeyError during reference count insertion.

Keep the saved exception state in a register so it remains available across the generated control flow. Add regression coverage for compiling and running an async with statement with an empty body.

I used coding agent assist.

Fix a regression introduced by #21982. CFG cleanup correctly removes an unreachable exception-handler block, but generated resume cleanup paths still reference its raw CPy_CatchError CallC result. This leaves malformed IR and causes a KeyError during reference count insertion.

Keep the saved exception state in a register so it remains available across the generated control flow. Add regression coverage for compiling and running an async with statement with an empty body.
@JukkaL
JukkaL merged commit 0331d04 into master Sep 15, 2026
18 checks passed
@JukkaL
JukkaL deleted the mypyc-fix-async-with-spill branch September 15, 2026 08:23
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.

2 participants