From: Yury Selivanov Date: Wed, 13 May 2015 19:21:41 +0000 (-0400) Subject: asyncio: Use 'collections.abc.Coroutine' in asyncio.iscoroutine (in 3.5) X-Git-Tag: v3.5.0b1~149^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c58cca5951ebab752020750e52334300342e54db;p=thirdparty%2FPython%2Fcpython.git asyncio: Use 'collections.abc.Coroutine' in asyncio.iscoroutine (in 3.5) --- diff --git a/Lib/asyncio/coroutines.py b/Lib/asyncio/coroutines.py index 20c45798dce6..1e0a70497f89 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."""