Issue #17934: Add a clear() method to frame objects, to help clean up expensive details (local variables) and break reference cycles.

This commit is contained in:
Antoine Pitrou 2013-08-05 23:26:40 +02:00
parent c53204b947
commit 58720d6145
10 changed files with 80 additions and 10 deletions

View file

@ -1182,6 +1182,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
stack_pointer = f->f_stacktop;
assert(stack_pointer != NULL);
f->f_stacktop = NULL; /* remains NULL unless yield suspends frame */
f->f_executing = 1;
if (co->co_flags & CO_GENERATOR && !throwflag) {
if (f->f_exc_type != NULL && f->f_exc_type != Py_None) {
@ -3206,6 +3207,7 @@ fast_yield:
/* pop frame */
exit_eval_frame:
Py_LeaveRecursiveCall();
f->f_executing = 0;
tstate->frame = f->f_back;
return retval;