diff options
Diffstat (limited to 'Python/frame.c')
-rw-r--r-- | Python/frame.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Python/frame.c b/Python/frame.c index 9578747..771de75 100644 --- a/Python/frame.c +++ b/Python/frame.c @@ -83,7 +83,7 @@ take_ownership(PyFrameObject *f, InterpreterFrame *frame) } void -_PyFrame_Clear(InterpreterFrame * frame) +_PyFrame_Clear(InterpreterFrame *frame) { /* It is the responsibility of the owning generator/coroutine * to have cleared the enclosing generator, if any. */ @@ -107,3 +107,16 @@ _PyFrame_Clear(InterpreterFrame * frame) Py_DECREF(frame->f_func); Py_DECREF(frame->f_code); } + +InterpreterFrame * +_PyFrame_Push(PyThreadState *tstate, PyFunctionObject *func) +{ + PyCodeObject *code = (PyCodeObject *)func->func_code; + size_t size = code->co_nlocalsplus + code->co_stacksize + FRAME_SPECIALS_SIZE; + InterpreterFrame *new_frame = _PyThreadState_BumpFramePointer(tstate, size); + if (new_frame == NULL) { + return NULL; + } + _PyFrame_InitializeSpecials(new_frame, func, NULL, code->co_nlocalsplus); + return new_frame; +} |