mirror of
https://github.com/python/cpython.git
synced 2025-08-28 04:35:02 +00:00
GH-102748: remove legacy support for generator based coroutines from asyncio.iscoroutine
(#102749)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
parent
fbe82fdd77
commit
adaed17341
4 changed files with 14 additions and 2 deletions
|
@ -237,6 +237,10 @@ asyncio
|
||||||
* Add C implementation of :func:`asyncio.current_task` for 4x-6x speedup.
|
* Add C implementation of :func:`asyncio.current_task` for 4x-6x speedup.
|
||||||
(Contributed by Itamar Ostricher and Pranav Thulasiram Bhat in :gh:`100344`.)
|
(Contributed by Itamar Ostricher and Pranav Thulasiram Bhat in :gh:`100344`.)
|
||||||
|
|
||||||
|
* :func:`asyncio.iscoroutine` now returns ``False`` for generators as
|
||||||
|
:mod:`asyncio` does not support legacy generator-based coroutines.
|
||||||
|
(Contributed by Kumar Aditya in :gh:`102748`.)
|
||||||
|
|
||||||
inspect
|
inspect
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,7 @@ def iscoroutinefunction(func):
|
||||||
|
|
||||||
# Prioritize native coroutine check to speed-up
|
# Prioritize native coroutine check to speed-up
|
||||||
# asyncio.iscoroutine.
|
# asyncio.iscoroutine.
|
||||||
_COROUTINE_TYPES = (types.CoroutineType, types.GeneratorType,
|
_COROUTINE_TYPES = (types.CoroutineType, collections.abc.Coroutine)
|
||||||
collections.abc.Coroutine)
|
|
||||||
_iscoroutine_typecache = set()
|
_iscoroutine_typecache = set()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,12 @@ class CoroutineTests(BaseTest):
|
||||||
|
|
||||||
self.assertTrue(asyncio.iscoroutine(FakeCoro()))
|
self.assertTrue(asyncio.iscoroutine(FakeCoro()))
|
||||||
|
|
||||||
|
def test_iscoroutine_generator(self):
|
||||||
|
def foo(): yield
|
||||||
|
|
||||||
|
self.assertFalse(asyncio.iscoroutine(foo()))
|
||||||
|
|
||||||
|
|
||||||
def test_iscoroutinefunction(self):
|
def test_iscoroutinefunction(self):
|
||||||
async def foo(): pass
|
async def foo(): pass
|
||||||
self.assertTrue(asyncio.iscoroutinefunction(foo))
|
self.assertTrue(asyncio.iscoroutinefunction(foo))
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
:func:`asyncio.iscoroutine` now returns ``False`` for generators as
|
||||||
|
:mod:`asyncio` does not support legacy generator-based coroutines.
|
||||||
|
Patch by Kumar Aditya.
|
Loading…
Add table
Add a link
Reference in a new issue