-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
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+
class DetectDeletion:
deleted = False
def __del__(self):
DetectDeletion.deleted = True
def gen(x): yield 1
g = gen(DetectDeletion())
g.close() # or alternatively: g.gi_frame.clear()
assert DetectDeletion.deleted
del gIntroduced in:
CPython versions tested on:
3.11, 3.12, 3.14, 3.13, 3.15
Operating systems tested on:
No response
Linked PRs
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error