[3.14] GH-100964: Fix reference cycle in exhausted generator frames (GH-141112) (#142902)

GH-100964: Fix reference cycle in exhausted generator frames (GH-141112)
(cherry picked from commit 92243dc62c)

Co-authored-by: Savannah Ostrowski <savannah@python.org>
This commit is contained in:
Miss Islington (bot) 2025-12-17 20:48:18 +01:00 committed by GitHub
parent 25a94708e5
commit 7134b407dc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 1 deletions

View file

@ -1920,9 +1920,9 @@ clear_gen_frame(PyThreadState *tstate, _PyInterpreterFrame * frame)
tstate->exc_info = gen->gi_exc_state.previous_item;
gen->gi_exc_state.previous_item = NULL;
assert(frame->frame_obj == NULL || frame->frame_obj->f_frame == frame);
frame->previous = NULL;
_PyFrame_ClearExceptCode(frame);
_PyErr_ClearExcState(&gen->gi_exc_state);
frame->previous = NULL;
}
void