diff options
author | Yury Selivanov <yselivanov@sprymix.com> | 2015-05-12 13:38:57 -0400 |
---|---|---|
committer | Yury Selivanov <yselivanov@sprymix.com> | 2015-05-13 15:19:05 -0400 |
commit | 3a09a93277afc2cdb43badf92a2c85c2789813f6 (patch) | |
tree | 22e4ae7c8bf300424e867d1e6d1e5b2c011117bc | |
parent | 6ac55b2ae73fcd639c49523266aa4b85482a8cc3 (diff) | |
download | trollius-git-3a09a93277afc2cdb43badf92a2c85c2789813f6.tar.gz |
Use collections.abc.Coroutine for asyncio.iscoroutine() when available.
-rw-r--r-- | asyncio/coroutines.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/asyncio/coroutines.py b/asyncio/coroutines.py index 20c4579..1e0a704 100644 --- a/asyncio/coroutines.py +++ b/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.""" |