@@ -146,6 +146,8 @@ static void format_exc_unbound(PyCodeObject *co, int oparg);
146146static PyObject * unicode_concatenate (PyObject * , PyObject * ,
147147 PyFrameObject * , unsigned char * );
148148static PyObject * special_lookup (PyObject * , _Py_Identifier * );
149+ static PyObject * apply_coroutine_wrapper (PyObject * );
150+
149151
150152#define NAME_ERROR_MSG \
151153 "name '%.200s' is not defined"
@@ -3935,7 +3937,7 @@ _PyEval_EvalCodeWithName(PyObject *_co, PyObject *globals, PyObject *locals,
39353937 return NULL ;
39363938
39373939 if (co -> co_flags & (CO_COROUTINE | CO_ITERABLE_COROUTINE ))
3938- return _PyEval_ApplyCoroutineWrapper (gen );
3940+ return apply_coroutine_wrapper (gen );
39393941
39403942 return gen ;
39413943 }
@@ -4401,33 +4403,6 @@ _PyEval_GetCoroutineWrapper(void)
44014403 return tstate -> coroutine_wrapper ;
44024404}
44034405
4404- PyObject *
4405- _PyEval_ApplyCoroutineWrapper (PyObject * gen )
4406- {
4407- PyObject * wrapped ;
4408- PyThreadState * tstate = PyThreadState_GET ();
4409- PyObject * wrapper = tstate -> coroutine_wrapper ;
4410-
4411- if (tstate -> in_coroutine_wrapper ) {
4412- assert (wrapper != NULL );
4413- PyErr_Format (PyExc_RuntimeError ,
4414- "coroutine wrapper %.150R attempted "
4415- "to recursively wrap %.150R" ,
4416- wrapper ,
4417- gen );
4418- return NULL ;
4419- }
4420-
4421- if (wrapper == NULL ) {
4422- return gen ;
4423- }
4424-
4425- tstate -> in_coroutine_wrapper = 1 ;
4426- wrapped = PyObject_CallFunction (wrapper , "N" , gen );
4427- tstate -> in_coroutine_wrapper = 0 ;
4428- return wrapped ;
4429- }
4430-
44314406PyObject *
44324407PyEval_GetBuiltins (void )
44334408{
@@ -5257,6 +5232,33 @@ unicode_concatenate(PyObject *v, PyObject *w,
52575232 return res ;
52585233}
52595234
5235+ static PyObject *
5236+ apply_coroutine_wrapper (PyObject * gen )
5237+ {
5238+ PyObject * wrapped ;
5239+ PyThreadState * tstate = PyThreadState_GET ();
5240+ PyObject * wrapper = tstate -> coroutine_wrapper ;
5241+
5242+ if (tstate -> in_coroutine_wrapper ) {
5243+ assert (wrapper != NULL );
5244+ PyErr_Format (PyExc_RuntimeError ,
5245+ "coroutine wrapper %.200R attempted "
5246+ "to recursively wrap %.200R" ,
5247+ wrapper ,
5248+ gen );
5249+ return NULL ;
5250+ }
5251+
5252+ if (wrapper == NULL ) {
5253+ return gen ;
5254+ }
5255+
5256+ tstate -> in_coroutine_wrapper = 1 ;
5257+ wrapped = PyObject_CallFunction (wrapper , "N" , gen );
5258+ tstate -> in_coroutine_wrapper = 0 ;
5259+ return wrapped ;
5260+ }
5261+
52605262#ifdef DYNAMIC_EXECUTION_PROFILE
52615263
52625264static PyObject *
0 commit comments