@@ -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 );
@@ -4590,7 +4591,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
45904591 STACK_SHRINK (call_shape .postcall_shrink );
45914592 // The frame has stolen all the arguments from the stack,
45924593 // so there is no need to clean them up.
4593- Py_DECREF (function );
45944594 if (new_frame == NULL ) {
45954595 goto error ;
45964596 }
@@ -4675,7 +4675,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
46754675 new_frame -> localsplus [i ] = NULL ;
46764676 }
46774677 STACK_SHRINK (call_shape .postcall_shrink );
4678- Py_DECREF (func );
46794678 _PyFrame_SetStackPointer (frame , stack_pointer );
46804679 new_frame -> previous = frame ;
46814680 frame = cframe .current_frame = new_frame ;
@@ -4712,7 +4711,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
47124711 new_frame -> localsplus [i ] = NULL ;
47134712 }
47144713 STACK_SHRINK (call_shape .postcall_shrink );
4715- Py_DECREF (func );
47164714 _PyFrame_SetStackPointer (frame , stack_pointer );
47174715 new_frame -> previous = frame ;
47184716 frame = cframe .current_frame = new_frame ;
@@ -6077,7 +6075,7 @@ initialize_locals(PyThreadState *tstate, PyFunctionObject *func,
60776075 return -1 ;
60786076}
60796077
6080- /* Consumes all the references to the args */
6078+ /* Consumes references to func and all the args */
60816079static InterpreterFrame *
60826080_PyEvalFramePushAndInit (PyThreadState * tstate , PyFunctionObject * func ,
60836081 PyObject * locals , PyObject * const * args ,
@@ -6131,7 +6129,9 @@ _PyEval_Vector(PyThreadState *tstate, PyFunctionObject *func,
61316129 PyObject * const * args , size_t argcount ,
61326130 PyObject * kwnames )
61336131{
6134- /* _PyEvalFramePushAndInit consumes all the references to its arguments */
6132+ /* _PyEvalFramePushAndInit consumes the references
6133+ * to func and all its arguments */
6134+ Py_INCREF (func );
61356135 for (size_t i = 0 ; i < argcount ; i ++ ) {
61366136 Py_INCREF (args [i ]);
61376137 }
0 commit comments