mirror of https://github.com/python/cpython
asyncio: Use 'collections.abc.Coroutine' in asyncio.iscoroutine.
This commit is contained in:
commit
af928b65fc
|
@ -53,6 +53,11 @@ else:
|
||||||
_is_native_coro_code = lambda code: (code.co_flags &
|
_is_native_coro_code = lambda code: (code.co_flags &
|
||||||
inspect.CO_COROUTINE)
|
inspect.CO_COROUTINE)
|
||||||
|
|
||||||
|
try:
|
||||||
|
from collections.abc import Coroutine as CoroutineABC
|
||||||
|
except ImportError:
|
||||||
|
CoroutineABC = None
|
||||||
|
|
||||||
|
|
||||||
# Check for CPython issue #21209
|
# Check for CPython issue #21209
|
||||||
def has_yield_from_bug():
|
def has_yield_from_bug():
|
||||||
|
@ -219,6 +224,9 @@ def iscoroutinefunction(func):
|
||||||
|
|
||||||
|
|
||||||
_COROUTINE_TYPES = (types.GeneratorType, CoroWrapper)
|
_COROUTINE_TYPES = (types.GeneratorType, CoroWrapper)
|
||||||
|
if CoroutineABC is not None:
|
||||||
|
_COROUTINE_TYPES += (CoroutineABC,)
|
||||||
|
|
||||||
|
|
||||||
def iscoroutine(obj):
|
def iscoroutine(obj):
|
||||||
"""Return True if obj is a coroutine object."""
|
"""Return True if obj is a coroutine object."""
|
||||||
|
|
Loading…
Reference in New Issue