From c58cca5951ebab752020750e52334300342e54db Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Wed, 13 May 2015 15:21:41 -0400 Subject: asyncio: Use 'collections.abc.Coroutine' in asyncio.iscoroutine (in 3.5) --- Lib/asyncio/coroutines.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Lib/asyncio/coroutines.py b/Lib/asyncio/coroutines.py index 20c4579..1e0a704 100644 --- a/Lib/asyncio/coroutines.py +++ b/Lib/asyncio/coroutines.py @@ -53,6 +53,11 @@ else: _is_native_coro_code = lambda code: (code.co_flags & inspect.CO_COROUTINE) +try: + from collections.abc import Coroutine as CoroutineABC +except ImportError: + CoroutineABC = None + # Check for CPython issue #21209 def has_yield_from_bug(): @@ -219,6 +224,9 @@ def iscoroutinefunction(func): _COROUTINE_TYPES = (types.GeneratorType, CoroWrapper) +if CoroutineABC is not None: + _COROUTINE_TYPES += (CoroutineABC,) + def iscoroutine(obj): """Return True if obj is a coroutine object.""" -- cgit v0.12