@@ -4645,14 +4645,14 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
4645
4645
PyObject * function = PEEK (oparg + 1 );
4646
4646
if (Py_TYPE (function ) == & PyFunction_Type ) {
4647
4647
PyCodeObject * code = (PyCodeObject * )PyFunction_GET_CODE (function );
4648
- STACK_SHRINK (oparg + 1 );
4649
4648
if ((code -> co_flags & (CO_GENERATOR | CO_COROUTINE | CO_ASYNC_GENERATOR )) == 0 ) {
4650
- InterpreterFrame * new_frame = _PyEval_FrameFromPyFunctionAndArgs (tstate , stack_pointer + 1 , oparg , function );
4649
+ InterpreterFrame * new_frame = _PyEval_FrameFromPyFunctionAndArgs (tstate , stack_pointer - oparg , oparg , function );
4651
4650
if (new_frame == NULL ) {
4652
4651
// When we exit here, we own all variables in the stack (the frame creation has not stolen
4653
4652
// any variable) so we need to clean the whole stack (done in the "error" label).
4654
4653
goto error ;
4655
4654
}
4655
+ STACK_SHRINK (oparg + 1 );
4656
4656
assert (tstate -> interp -> eval_frame != NULL );
4657
4657
// The frame has stolen all the arguments from the stack, so there is no need to clean them up.```
4658
4658
Py_DECREF (function );
@@ -4664,8 +4664,9 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
4664
4664
else {
4665
4665
/* Callable is a generator or coroutine function: create coroutine or generator. */
4666
4666
PyObject * locals = code -> co_flags & CO_OPTIMIZED ? NULL : PyFunction_GET_GLOBALS (function );
4667
- res = make_coro (tstate , PyFunction_AS_FRAME_CONSTRUCTOR (function ), locals , stack_pointer + 1 , oparg , NULL );
4668
- for (int i = 0 ; i < oparg + 1 ; i ++ ) {
4667
+ res = make_coro (tstate , PyFunction_AS_FRAME_CONSTRUCTOR (function ), locals , stack_pointer - oparg , oparg , NULL );
4668
+ STACK_SHRINK (oparg + 1 );
4669
+ for (int i = 0 ; i < oparg + 1 ; i ++ ) {
4669
4670
Py_DECREF (stack_pointer [i ]);
4670
4671
}
4671
4672
}
0 commit comments