@@ -154,11 +154,12 @@ lltrace_instruction(_PyInterpreterFrame *frame,
154154static void
155155lltrace_resume_frame (_PyInterpreterFrame * frame )
156156{
157- PyFunctionObject * f = frame -> f_func ;
158- if (f == NULL ) {
157+ PyObject * fobj = frame -> f_funcobj ;
158+ if (fobj == NULL || ! PyFunction_Check ( fobj ) ) {
159159 printf ("\nResuming frame." );
160160 return ;
161161 }
162+ PyFunctionObject * f = (PyFunctionObject * )fobj ;
162163 PyObject * type , * value , * traceback ;
163164 PyErr_Fetch (& type , & value , & traceback );
164165 PyObject * name = f -> func_qualname ;
@@ -2619,7 +2620,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
26192620 TARGET (COPY_FREE_VARS ) {
26202621 /* Copy closure variables to free variables */
26212622 PyCodeObject * co = frame -> f_code ;
2622- PyObject * closure = frame -> f_func -> func_closure ;
2623+ assert (PyFunction_Check (frame -> f_funcobj ));
2624+ PyObject * closure = ((PyFunctionObject * )frame -> f_funcobj )-> func_closure ;
26232625 int offset = co -> co_nlocals + co -> co_nplaincellvars ;
26242626 assert (oparg == co -> co_nfreevars );
26252627 for (int i = 0 ; i < oparg ; ++ i ) {
@@ -4897,7 +4899,9 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
48974899 }
48984900
48994901 TARGET (RETURN_GENERATOR ) {
4900- PyGenObject * gen = (PyGenObject * )_Py_MakeCoro (frame -> f_func );
4902+ assert (PyFunction_Check (frame -> f_funcobj ));
4903+ PyFunctionObject * func = (PyFunctionObject * )frame -> f_funcobj ;
4904+ PyGenObject * gen = (PyGenObject * )_Py_MakeCoro (func );
49014905 if (gen == NULL ) {
49024906 goto error ;
49034907 }
@@ -4919,7 +4923,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
49194923 /* Make sure that frame is in a valid state */
49204924 frame -> stacktop = 0 ;
49214925 frame -> f_locals = NULL ;
4922- Py_INCREF (frame -> f_func );
4926+ Py_INCREF (frame -> f_funcobj );
49234927 Py_INCREF (frame -> f_code );
49244928 /* Restore previous cframe and return. */
49254929 tstate -> cframe = cframe .previous ;
0 commit comments