You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
generator.close() doesn't clear frame on newly created generators #142766
Since Python 3.12, generator.close() and generator.gi_frame.clear() do not clear the generator's frame, if the generator is in the FRAME_CREATED state.
The following passes on Python 3.11 and earlier and fails on Python 3.12+
classDetectDeletion:
deleted=Falsedef__del__(self):
DetectDeletion.deleted=Truedefgen(x): yield1g=gen(DetectDeletion())
g.close() # or alternatively: g.gi_frame.clear()assertDetectDeletion.deleteddelg
Activity
colesbury commentedon Dec 15, 2025
cc @markshannon - I think this is a bug, but I want to check in case this was an intentional behavior change.
markshannon commentedon Dec 16, 2025
It's a bug.
Want to fix it or shall I?
colesbury commentedon Dec 16, 2025
I can make the PR
pythongh-142766: Clear frame when `generator.close()` is called
Merge branch 'pythongh-142766-gen-close' into pythongh-120321-gen-fra…
gh-142766: Clear frame when `generator.close()` is called (gh-142838)
pythongh-142766: Clear frame when `generator.close()` is called (pyth…
[3.13] pythongh-142766: Clear frame when `generator.close()` is called (
[3.14] gh-142766: Clear frame when `generator.close()` is called (gh-…
[3.13] gh-142766: Clear frame when `generator.close()` is called (gh-…