mirror of
https://github.com/python/cpython.git
synced 2025-08-24 10:45:53 +00:00
bpo-36933: Remove sys.set_coroutine_wrapper (marked for removal in 3.8) (GH-13577)
It has been documented as deprecated and to be removed in 3.8; From a comment on another thread – which I can't find ; leave get_coro_wrapper() for now, but always return `None`. https://bugs.python.org/issue36933
This commit is contained in:
parent
436c2b0d67
commit
3880f263d2
11 changed files with 7 additions and 287 deletions
|
@ -4143,19 +4143,8 @@ _PyEval_EvalCodeWithName(PyObject *_co, PyObject *globals, PyObject *locals,
|
|||
/* Handle generator/coroutine/asynchronous generator */
|
||||
if (co->co_flags & (CO_GENERATOR | CO_COROUTINE | CO_ASYNC_GENERATOR)) {
|
||||
PyObject *gen;
|
||||
PyObject *coro_wrapper = tstate->coroutine_wrapper;
|
||||
int is_coro = co->co_flags & CO_COROUTINE;
|
||||
|
||||
if (is_coro && tstate->in_coroutine_wrapper) {
|
||||
assert(coro_wrapper != NULL);
|
||||
_PyErr_Format(tstate, PyExc_RuntimeError,
|
||||
"coroutine wrapper %.200R attempted "
|
||||
"to recursively wrap %.200R",
|
||||
coro_wrapper,
|
||||
co);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* Don't need to keep the reference to f_back, it will be set
|
||||
* when the generator is resumed. */
|
||||
Py_CLEAR(f->f_back);
|
||||
|
@ -4175,14 +4164,6 @@ _PyEval_EvalCodeWithName(PyObject *_co, PyObject *globals, PyObject *locals,
|
|||
|
||||
_PyObject_GC_TRACK(f);
|
||||
|
||||
if (is_coro && coro_wrapper != NULL) {
|
||||
PyObject *wrapped;
|
||||
tstate->in_coroutine_wrapper = 1;
|
||||
wrapped = PyObject_CallFunction(coro_wrapper, "N", gen);
|
||||
tstate->in_coroutine_wrapper = 0;
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
return gen;
|
||||
}
|
||||
|
||||
|
@ -4633,26 +4614,6 @@ _PyEval_GetCoroutineOriginTrackingDepth(void)
|
|||
return tstate->coroutine_origin_tracking_depth;
|
||||
}
|
||||
|
||||
void
|
||||
_PyEval_SetCoroutineWrapper(PyObject *wrapper)
|
||||
{
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
|
||||
if (PySys_Audit("sys.set_coroutine_wrapper", NULL) < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Py_XINCREF(wrapper);
|
||||
Py_XSETREF(tstate->coroutine_wrapper, wrapper);
|
||||
}
|
||||
|
||||
PyObject *
|
||||
_PyEval_GetCoroutineWrapper(void)
|
||||
{
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
return tstate->coroutine_wrapper;
|
||||
}
|
||||
|
||||
void
|
||||
_PyEval_SetAsyncGenFirstiter(PyObject *firstiter)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue