GH-100964: Fix reference cycle in exhausted generator frames (#141112)

This commit is contained in:
Savannah Ostrowski 2025-12-17 11:21:45 -08:00 committed by GitHub
parent 25397f9541
commit 92243dc62c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 1 deletions

View file

@ -2309,9 +2309,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