asyncio: Use 'collections.abc.Coroutine' in asyncio.iscoroutine (in 3.5)

This commit is contained in:
Yury Selivanov 2015-05-13 15:21:41 -04:00
parent d08c363c26
commit c58cca5951
1 changed files with 8 additions and 0 deletions

View File

@ -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."""