| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ca82910 commit eb698fe
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,7 +25,6 @@ PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *); | |||
| 25 | 25 | PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *); | |
| 26 | 26 | PyAPI_FUNC(void) _PyEval_SetCoroutineWrapper(PyObject *); | |
| 27 | 27 | PyAPI_FUNC(PyObject *) _PyEval_GetCoroutineWrapper(void); | |
| 28 | - PyAPI_FUNC(PyObject *) _PyEval_ApplyCoroutineWrapper(PyObject *); | ||
| 29 | 28 | #endif | |
| 30 | 29 | ||
| 31 | 30 | struct _frame; /* Avoid including frameobject.h */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -146,6 +146,8 @@ static void format_exc_unbound(PyCodeObject *co, int oparg); | |||
| 146 | 146 | static PyObject * unicode_concatenate(PyObject *, PyObject *, | |
| 147 | 147 | PyFrameObject *, unsigned char *); | |
| 148 | 148 | static PyObject * special_lookup(PyObject *, _Py_Identifier *); | |
| 149 | + static PyObject * apply_coroutine_wrapper(PyObject *); | ||
| 150 | + | ||
| 149 | 151 | ||
| 150 | 152 | #define NAME_ERROR_MSG \ | |
| 151 | 153 | "name '%.200s' is not defined" | |
@@ -3935,7 +3937,7 @@ _PyEval_EvalCodeWithName(PyObject *_co, PyObject *globals, PyObject *locals, | |||
| 3935 | 3937 | return NULL; | |
| 3936 | 3938 | ||
| 3937 | 3939 | if (co->co_flags & (CO_COROUTINE | CO_ITERABLE_COROUTINE)) | |
| 3938 | - return _PyEval_ApplyCoroutineWrapper(gen); | ||
| 3940 | + return apply_coroutine_wrapper(gen); | ||
| 3939 | 3941 | ||
| 3940 | 3942 | return gen; | |
| 3941 | 3943 | } | |
@@ -4401,33 +4403,6 @@ _PyEval_GetCoroutineWrapper(void) | |||
| 4401 | 4403 | return tstate->coroutine_wrapper; | |
| 4402 | 4404 | } | |
| 4403 | 4405 | ||
| 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 | - | ||
| 4431 | 4406 | PyObject * | |
| 4432 | 4407 | PyEval_GetBuiltins(void) | |
| 4433 | 4408 | { | |
@@ -5257,6 +5232,33 @@ unicode_concatenate(PyObject *v, PyObject *w, | |||
| 5257 | 5232 | return res; | |
| 5258 | 5233 | } | |
| 5259 | 5234 | ||
| 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 | + | ||
| 5260 | 5262 | #ifdef DYNAMIC_EXECUTION_PROFILE | |
| 5261 | 5263 | ||
| 5262 | 5264 | static PyObject * | |
| Back | FazBrowse Home | New Git URL |
0 commit comments