@@ -2595,6 +2595,29 @@ create_managed_weakref_nogc_type(PyObject *self, PyObject *Py_UNUSED(args))
25952595}
25962596
25972597
2598+ static PyObject *
2599+ noop_eval (PyThreadState * tstate , struct _PyInterpreterFrame * f , int exc )
2600+ {
2601+ return NULL ;
2602+ }
2603+
2604+ static PyObject *
2605+ test_interpreter_setevalframefunc (PyObject * self , PyObject * Py_UNUSED (args ))
2606+ {
2607+ PyInterpreterState * interp = PyInterpreterState_Get ();
2608+ PyUnstable_FrameEvalFunction eval_func ;
2609+
2610+ eval_func = PyUnstable_InterpreterState_GetEvalFrameFunc (interp );
2611+
2612+ PyUnstable_InterpreterState_SetEvalFrameFunc (interp , noop_eval );
2613+ assert (PyUnstable_InterpreterState_GetEvalFrameFunc (interp ) == noop_eval );
2614+
2615+ PyUnstable_InterpreterState_SetEvalFrameFunc (interp , eval_func );
2616+
2617+ Py_RETURN_NONE ;
2618+ }
2619+
2620+
25982621static PyMethodDef TestMethods [] = {
25992622 {"set_errno" , set_errno , METH_VARARGS },
26002623 {"test_config" , test_config , METH_NOARGS },
@@ -2691,6 +2714,8 @@ static PyMethodDef TestMethods[] = {
26912714 {"toggle_reftrace_printer" , toggle_reftrace_printer , METH_O },
26922715 {"create_managed_weakref_nogc_type" ,
26932716 create_managed_weakref_nogc_type , METH_NOARGS },
2717+ {"test_interpreter_setevalframefunc" ,
2718+ test_interpreter_setevalframefunc , METH_NOARGS },
26942719 {NULL , NULL } /* sentinel */
26952720};
26962721
0 commit comments