diff --git a/Python/bytecodes.c b/Python/bytecodes.c index cfce9da3d77376..968e912545f1e6 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -3114,10 +3114,12 @@ dummy_func( _PyInterpreterFrame *new_frame = _PyEvalFramePushAndInit_Ex(tstate, (PyFunctionObject *)func, locals, nargs, callargs, kwargs); - STACK_SHRINK(2); /* get rid of func and NULL */ + // Need to manually shrinkg the stack since we exit with DISPATCH_INLINED. + STACK_SHRINK(oparg + 3); if (new_frame == NULL) { goto error; } + frame->return_offset = 0; DISPATCH_INLINED(new_frame); } result = PyObject_Call(func, callargs, kwargs); diff --git a/Python/ceval.c b/Python/ceval.c index 5597ff4a67219b..958689debc87f8 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1513,6 +1513,7 @@ _PyEvalFramePushAndInit_Ex(PyThreadState *tstate, PyFunctionObject *func, { bool has_dict = (kwargs != NULL && PyDict_GET_SIZE(kwargs) > 0); PyObject *kwnames = NULL; + PyObject *const *newargs; if (has_dict) { newargs = _PyStack_UnpackDict(tstate, _PyTuple_ITEMS(callargs), nargs, kwargs, &kwnames); if (newargs == NULL) { diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 026b27c1f4106a..d19de3aed2e538 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -3860,10 +3860,11 @@ _PyInterpreterFrame *new_frame = _PyEvalFramePushAndInit_Ex(tstate, (PyFunctionObject *)func, locals, nargs, callargs, kwargs); - STACK_SHRINK(2); /* get rid of func and NULL */ + STACK_SHRINK(oparg + 3); if (new_frame == NULL) { goto error; } + frame->return_offset = 0; DISPATCH_INLINED(new_frame); } result = PyObject_Call(func, callargs, kwargs);