Skip to content

[mypyc] Skip recursive setup for frame-private nested functions - #22187

Open
p-sawicki wants to merge 1 commit into
python:masterfrom
p-sawicki:fix-recursive-setup-private-frame
Open

p-sawicki wants to merge 1 commit into
python:masterfrom
p-sawicki:fix-recursive-setup-private-frame

Conversation

@p-sawicki

@p-sawicki p-sawicki commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

The recursive setup could cause AttributeError at runtime when a function contains both a frame-private as well as a captured nested function. The setup would add the frame-private function object as an attribute to the env class and access it even though it was never initialized.

Fix by omitting the recursive setup since it's not needed - a frame-private nested function can't call itself.

Also fix possibly inconsistent storage for a redefined nested function that is captured in one branch and not captured in another by using original_def in capture/free variable checks.

@p-sawicki p-sawicki changed the title [mypyc] Fix recursive setup for frame-private nested functions [mypyc] Skip recursive setup for frame-private nested functions Oct 12, 2026
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