diff options
Diffstat (limited to 'Python')
-rw-r--r-- | Python/frame.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Python/frame.c b/Python/frame.c index db9d133..ec390e7 100644 --- a/Python/frame.c +++ b/Python/frame.c @@ -95,6 +95,17 @@ take_ownership(PyFrameObject *f, _PyInterpreterFrame *frame) } void +_PyFrame_ClearLocals(_PyInterpreterFrame *frame) +{ + assert(frame->stacktop >= 0); + for (int i = 0; i < frame->stacktop; i++) { + Py_XDECREF(frame->localsplus[i]); + } + frame->stacktop = 0; + Py_CLEAR(frame->f_locals); +} + +void _PyFrame_ClearExceptCode(_PyInterpreterFrame *frame) { /* It is the responsibility of the owning generator/coroutine @@ -114,11 +125,7 @@ _PyFrame_ClearExceptCode(_PyInterpreterFrame *frame) } Py_DECREF(f); } - assert(frame->stacktop >= 0); - for (int i = 0; i < frame->stacktop; i++) { - Py_XDECREF(frame->localsplus[i]); - } - Py_XDECREF(frame->f_locals); + _PyFrame_ClearLocals(frame); Py_DECREF(frame->f_funcobj); } |