From 338916dae736de4d3844ad1a98aadfb49f47719b Mon Sep 17 00:00:00 2001 From: Timofey Ivankov Date: Sat, 19 Sep 2026 13:42:45 +0300 Subject: [PATCH 1/2] gh-157786: Document that asyncio does not support generator-based coroutines --- Doc/library/asyncio-task.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst index 1a13ad387f89b22..33599d199964c41 100644 --- a/Doc/library/asyncio-task.rst +++ b/Doc/library/asyncio-task.rst @@ -175,6 +175,9 @@ other coroutines:: * a *coroutine object*: an object returned by calling a *coroutine function*. + Generator-based coroutines, created with :func:`types.coroutine`, are + covered by neither term and are not supported by asyncio. + .. rubric:: Tasks @@ -242,6 +245,8 @@ Creating tasks Wrap the *coro* :ref:`coroutine ` into a :class:`Task` and schedule its execution. Return the Task object. + :exc:`TypeError` is raised if *coro* is not a coroutine declared with + :keyword:`async def`. The full function signature is largely the same as that of the :class:`Task` constructor (or factory) - all of the keyword arguments to @@ -1220,6 +1225,10 @@ Introspection .. versionadded:: 3.4 + .. versionchanged:: 3.12 + Generator-based coroutines are no longer supported, and ``False`` + is returned for them. + .. _asyncio-task-obj: Task object From 2c82ca25877a76c316fde991e5c6ad697a1446bb Mon Sep 17 00:00:00 2001 From: Timofey Ivankov Date: Sun, 20 Sep 2026 11:39:55 +0300 Subject: [PATCH 2/2] removal of duplicates --- Doc/library/asyncio-task.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst index 33599d199964c41..6df87d4d71a3657 100644 --- a/Doc/library/asyncio-task.rst +++ b/Doc/library/asyncio-task.rst @@ -245,8 +245,6 @@ Creating tasks Wrap the *coro* :ref:`coroutine ` into a :class:`Task` and schedule its execution. Return the Task object. - :exc:`TypeError` is raised if *coro* is not a coroutine declared with - :keyword:`async def`. The full function signature is largely the same as that of the :class:`Task` constructor (or factory) - all of the keyword arguments to