FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-118272: Clear generator frame's locals when the generator is closed by iritkatriel · Pull Request #118277 · python/cpython · GitHub

/ cpython Public

gh-118272: Clear generator frame's locals when the generator is closed - #118277

Merged
iritkatriel merged 2 commits into
python:mainfrom
iritkatriel:gh-118272
Apr 30, 2024
Merged

gh-118272: Clear generator frame's locals when the generator is closed#118277
iritkatriel merged 2 commits into
python:mainfrom
iritkatriel:gh-118272

Conversation

iritkatriel commented Apr 25, 2024
edited
Loading

Copy link
Copy Markdown
Member

iritkatriel added type-bug An unexpected behavior, bug, or error interpreter-core (Objects, Python, Grammar, and Parser dirs) needs backport to 3.12 only security fixes labels Apr 25, 2024
Comment thread Lib/test/test_generators.py Outdated
Co-authored-by: Thomas Grainger <tagrain@gmail.com>

gvanrossum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yeah, LGTM!

iritkatriel merged commit 1f16b4c into python:main Apr 30, 2024

Copy link
Copy Markdown

Thanks @iritkatriel for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

Copy link
Copy Markdown

Sorry, @iritkatriel, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 1f16b4ce569f222af74fcbb7b2ef98eee2398d20 3.12

Comment thread Python/frame.c
_PyFrame_ClearLocals(_PyInterpreterFrame *frame)
{
assert(frame->stacktop >= 0);
for (int i = 0; i < frame->stacktop; i++) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think frame->stacktop = 0; needs to come before the loop to prevent the GC seeing freed objects.

gvanrossum May 1, 2024
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Let me make a fix for that. NM, approved gh-118478 instead.

SonicField pushed a commit to SonicField/cpython that referenced this pull request May 8, 2024
… closed (python#118277)

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
hugovk removed the needs backport to 3.12 only security fixes label Feb 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generator .close does not release resources

5 participants


Back | FazBrowse Home | New Git URL