-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
gh-118272: Clear generator frame's locals when the generator is closed #118277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: Thomas Grainger <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, LGTM!
Thanks @iritkatriel for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12. |
Sorry, @iritkatriel, I could not cleanly backport this to
|
_PyFrame_ClearLocals(_PyInterpreterFrame *frame) | ||
{ | ||
assert(frame->stacktop >= 0); | ||
for (int i = 0; i < frame->stacktop; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think frame->stacktop = 0;
needs to come before the loop to prevent the GC seeing freed objects.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me make a fix for that. NM, approved gh-118478 instead.
… closed (python#118277) Co-authored-by: Thomas Grainger <[email protected]>
Fixes #118272.
Co-authored-by: Thomas Grainger [email protected]