summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2015-06-03 02:30:31 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2015-06-03 02:30:31 (GMT)
commiteb698fe68c38bf7d2eb0bebbccdcef5dfa0eccfd (patch)
tree2089c50d5439d46530f9c9ac7f4e4b8d0eaf598b /Python
parentca829102213c466ffecb1e464be5c8cb3967d961 (diff)
downloadcpython-eb698fe68c38bf7d2eb0bebbccdcef5dfa0eccfd.zip
cpython-eb698fe68c38bf7d2eb0bebbccdcef5dfa0eccfd.tar.gz
cpython-eb698fe68c38bf7d2eb0bebbccdcef5dfa0eccfd.tar.bz2
Issue 24342: No need to use PyAPI_FUNC for _PyEval_ApplyCoroutineWrapper
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c58
1 files changed, 30 insertions, 28 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 2a1db17..96ed6ed 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -146,6 +146,8 @@ static void format_exc_unbound(PyCodeObject *co, int oparg);
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 @@ _PyEval_EvalCodeWithName(PyObject *_co, PyObject *globals, PyObject *locals,
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 @@ _PyEval_GetCoroutineWrapper(void)
}
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 @@ unicode_concatenate(PyObject *v, PyObject *w,
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 *