diff options
author | Yury Selivanov <yury@magic.io> | 2017-10-06 02:08:57 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-06 02:08:57 -0400 |
commit | faa135acbfcd55f79fb97f7525c8aa6f5a5b6a22 (patch) | |
tree | 8fd008b849b322699e20e18f92a179c06f7b0580 /Python/ceval.c | |
parent | 86566702f311f8e90600e85350f6b6769a384ea5 (diff) | |
download | cpython-git-faa135acbfcd55f79fb97f7525c8aa6f5a5b6a22.tar.gz |
bpo-31709: Drop support for asynchronous __aiter__. (#3903)
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 52 |
1 files changed, 7 insertions, 45 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index cf0c6c9ae2..86ffec42b3 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1708,7 +1708,6 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag) TARGET(GET_AITER) { unaryfunc getter = NULL; PyObject *iter = NULL; - PyObject *awaitable = NULL; PyObject *obj = TOP(); PyTypeObject *type = Py_TYPE(obj); @@ -1735,57 +1734,20 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag) goto error; } - if (Py_TYPE(iter)->tp_as_async != NULL && - Py_TYPE(iter)->tp_as_async->am_anext != NULL) { - - /* Starting with CPython 3.5.2 __aiter__ should return - asynchronous iterators directly (not awaitables that - resolve to asynchronous iterators.) - - Therefore, we check if the object that was returned - from __aiter__ has an __anext__ method. If it does, - we wrap it in an awaitable that resolves to `iter`. + if (Py_TYPE(iter)->tp_as_async == NULL || + Py_TYPE(iter)->tp_as_async->am_anext == NULL) { - See http://bugs.python.org/issue27243 for more - details. - */ - - PyObject *wrapper = _PyAIterWrapper_New(iter); - Py_DECREF(iter); - SET_TOP(wrapper); - DISPATCH(); - } - - awaitable = _PyCoro_GetAwaitableIter(iter); - if (awaitable == NULL) { - _PyErr_FormatFromCause( + SET_TOP(NULL); + PyErr_Format( PyExc_TypeError, - "'async for' received an invalid object " - "from __aiter__: %.100s", + "'async for' received an object from __aiter__ " + "that does not implement __anext__: %.100s", Py_TYPE(iter)->tp_name); - - SET_TOP(NULL); Py_DECREF(iter); goto error; - } else { - Py_DECREF(iter); - - if (PyErr_WarnFormat( - PyExc_DeprecationWarning, 1, - "'%.100s' implements legacy __aiter__ protocol; " - "__aiter__ should return an asynchronous " - "iterator, not awaitable", - type->tp_name)) - { - /* Warning was converted to an error. */ - Py_DECREF(awaitable); - SET_TOP(NULL); - goto error; - } } - SET_TOP(awaitable); - PREDICT(LOAD_CONST); + SET_TOP(iter); DISPATCH(); } |