@@ -2243,6 +2243,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
22432243 goto error ;
22442244 }
22452245 CALL_STAT_INC (frames_pushed );
2246+ Py_INCREF (getitem );
22462247 _PyFrame_InitializeSpecials (new_frame , getitem ,
22472248 NULL , code -> co_nlocalsplus );
22482249 STACK_SHRINK (2 );
@@ -4585,7 +4586,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
45854586 STACK_SHRINK (call_shape .postcall_shrink );
45864587 // The frame has stolen all the arguments from the stack,
45874588 // so there is no need to clean them up.
4588- Py_DECREF (function );
45894589 if (new_frame == NULL ) {
45904590 goto error ;
45914591 }
@@ -4670,7 +4670,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
46704670 new_frame -> localsplus [i ] = NULL ;
46714671 }
46724672 STACK_SHRINK (call_shape .postcall_shrink );
4673- Py_DECREF (func );
46744673 _PyFrame_SetStackPointer (frame , stack_pointer );
46754674 new_frame -> previous = frame ;
46764675 frame = cframe .current_frame = new_frame ;
@@ -4707,7 +4706,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
47074706 new_frame -> localsplus [i ] = NULL ;
47084707 }
47094708 STACK_SHRINK (call_shape .postcall_shrink );
4710- Py_DECREF (func );
47114709 _PyFrame_SetStackPointer (frame , stack_pointer );
47124710 new_frame -> previous = frame ;
47134711 frame = cframe .current_frame = new_frame ;
@@ -6072,7 +6070,7 @@ initialize_locals(PyThreadState *tstate, PyFunctionObject *func,
60726070 return -1 ;
60736071}
60746072
6075- /* Consumes all the references to the args */
6073+ /* Consumes references to func and all the args */
60766074static InterpreterFrame *
60776075_PyEvalFramePushAndInit (PyThreadState * tstate , PyFunctionObject * func ,
60786076 PyObject * locals , PyObject * const * args ,
@@ -6126,7 +6124,9 @@ _PyEval_Vector(PyThreadState *tstate, PyFunctionObject *func,
61266124 PyObject * const * args , size_t argcount ,
61276125 PyObject * kwnames )
61286126{
6129- /* _PyEvalFramePushAndInit consumes all the references to its arguments */
6127+ /* _PyEvalFramePushAndInit consumes the references
6128+ * to func and all its arguments */
6129+ Py_INCREF (func );
61306130 for (size_t i = 0 ; i < argcount ; i ++ ) {
61316131 Py_INCREF (args [i ]);
61326132 }
0 commit comments