bpo-43216: Remove @asyncio.coroutine (GH-26369)

Remove the @asyncio.coroutine decorator
enabling legacy generator-based coroutines to be compatible with async/await
code; remove asyncio.coroutines.CoroWrapper used for wrapping
legacy coroutine objects in the debug mode.

The decorator has been deprecated
since Python 3.8 and the removal was initially scheduled for Python 3.10.
This commit is contained in:
Illia Volochii 2021-07-01 16:13:59 +03:00 committed by GitHub
parent 3623aaa78c
commit a1092f6249
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 85 additions and 763 deletions

View file

@ -148,9 +148,6 @@ other coroutines::
* a *coroutine object*: an object returned by calling a
*coroutine function*.
asyncio also supports legacy :ref:`generator-based
<asyncio_generator_based_coro>` coroutines.
.. rubric:: Tasks
@ -1042,60 +1039,3 @@ Task Object
in the :func:`repr` output of a task object.
.. versionadded:: 3.8
.. _asyncio_generator_based_coro:
Generator-based Coroutines
==========================
.. note::
Support for generator-based coroutines is **deprecated** and
is scheduled for removal in Python 3.10.
Generator-based coroutines predate async/await syntax. They are
Python generators that use ``yield from`` expressions to await
on Futures and other coroutines.
Generator-based coroutines should be decorated with
:func:`@asyncio.coroutine <asyncio.coroutine>`, although this is not
enforced.
.. decorator:: coroutine
Decorator to mark generator-based coroutines.
This decorator enables legacy generator-based coroutines to be
compatible with async/await code::
@asyncio.coroutine
def old_style_coroutine():
yield from asyncio.sleep(1)
async def main():
await old_style_coroutine()
This decorator should not be used for :keyword:`async def`
coroutines.
.. deprecated-removed:: 3.8 3.10
Use :keyword:`async def` instead.
.. function:: iscoroutine(obj)
Return ``True`` if *obj* is a :ref:`coroutine object <coroutine>`.
This method is different from :func:`inspect.iscoroutine` because
it returns ``True`` for generator-based coroutines.
.. function:: iscoroutinefunction(func)
Return ``True`` if *func* is a :ref:`coroutine function
<coroutine>`.
This method is different from :func:`inspect.iscoroutinefunction`
because it returns ``True`` for generator-based coroutine functions
decorated with :func:`@coroutine <coroutine>`.