changeset: 96491:d11cb1218489 branch: 3.5 parent: 96489:c835dd16539a user: Yury Selivanov date: Tue Jun 02 22:30:31 2015 -0400 files: Include/ceval.h Python/ceval.c description: Issue 24342: No need to use PyAPI_FUNC for _PyEval_ApplyCoroutineWrapper diff -r c835dd16539a -r d11cb1218489 Include/ceval.h --- a/Include/ceval.h Tue Jun 02 19:06:47 2015 -0400 +++ b/Include/ceval.h Tue Jun 02 22:30:31 2015 -0400 @@ -25,7 +25,6 @@ PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *); PyAPI_FUNC(void) _PyEval_SetCoroutineWrapper(PyObject *); PyAPI_FUNC(PyObject *) _PyEval_GetCoroutineWrapper(void); -PyAPI_FUNC(PyObject *) _PyEval_ApplyCoroutineWrapper(PyObject *); #endif struct _frame; /* Avoid including frameobject.h */ diff -r c835dd16539a -r d11cb1218489 Python/ceval.c --- a/Python/ceval.c Tue Jun 02 19:06:47 2015 -0400 +++ b/Python/ceval.c Tue Jun 02 22:30:31 2015 -0400 @@ -146,6 +146,8 @@ static PyObject * unicode_concatenate(PyObject *, PyObject *, PyFrameObject *, unsigned char *); static PyObject * special_lookup(PyObject *, _Py_Identifier *); +static PyObject * apply_coroutine_wrapper(PyObject *); + #define NAME_ERROR_MSG \ "name '%.200s' is not defined" @@ -3935,7 +3937,7 @@ return NULL; if (co->co_flags & (CO_COROUTINE | CO_ITERABLE_COROUTINE)) - return _PyEval_ApplyCoroutineWrapper(gen); + return apply_coroutine_wrapper(gen); return gen; } @@ -4402,33 +4404,6 @@ } PyObject * -_PyEval_ApplyCoroutineWrapper(PyObject *gen) -{ - PyObject *wrapped; - PyThreadState *tstate = PyThreadState_GET(); - PyObject *wrapper = tstate->coroutine_wrapper; - - if (tstate->in_coroutine_wrapper) { - assert(wrapper != NULL); - PyErr_Format(PyExc_RuntimeError, - "coroutine wrapper %.150R attempted " - "to recursively wrap %.150R", - wrapper, - gen); - return NULL; - } - - if (wrapper == NULL) { - return gen; - } - - tstate->in_coroutine_wrapper = 1; - wrapped = PyObject_CallFunction(wrapper, "N", gen); - tstate->in_coroutine_wrapper = 0; - return wrapped; -} - -PyObject * PyEval_GetBuiltins(void) { PyFrameObject *current_frame = PyEval_GetFrame(); @@ -5257,6 +5232,33 @@ return res; } +static PyObject * +apply_coroutine_wrapper(PyObject *gen) +{ + PyObject *wrapped; + PyThreadState *tstate = PyThreadState_GET(); + PyObject *wrapper = tstate->coroutine_wrapper; + + if (tstate->in_coroutine_wrapper) { + assert(wrapper != NULL); + PyErr_Format(PyExc_RuntimeError, + "coroutine wrapper %.200R attempted " + "to recursively wrap %.200R", + wrapper, + gen); + return NULL; + } + + if (wrapper == NULL) { + return gen; + } + + tstate->in_coroutine_wrapper = 1; + wrapped = PyObject_CallFunction(wrapper, "N", gen); + tstate->in_coroutine_wrapper = 0; + return wrapped; +} + #ifdef DYNAMIC_EXECUTION_PROFILE static PyObject *