Skip to content

Commit c58cca5

Browse files
committed
asyncio: Use 'collections.abc.Coroutine' in asyncio.iscoroutine (in 3.5)
1 parent d08c363 commit c58cca5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Lib/asyncio/coroutines.py

+8
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@
5353
_is_native_coro_code = lambda code: (code.co_flags &
5454
inspect.CO_COROUTINE)
5555

56+
try:
57+
from collections.abc import Coroutine as CoroutineABC
58+
except ImportError:
59+
CoroutineABC = None
60+
5661

5762
# Check for CPython issue #21209
5863
def has_yield_from_bug():
@@ -219,6 +224,9 @@ def iscoroutinefunction(func):
219224

220225

221226
_COROUTINE_TYPES = (types.GeneratorType, CoroWrapper)
227+
if CoroutineABC is not None:
228+
_COROUTINE_TYPES += (CoroutineABC,)
229+
222230

223231
def iscoroutine(obj):
224232
"""Return True if obj is a coroutine object."""

0 commit comments

Comments
 (0)