summaryrefslogtreecommitdiffstats
path: root/Lib/_collections_abc.py
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2015-07-03 17:11:35 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2015-07-03 17:11:35 (GMT)
commitfdbeb2b4b67e1e44c96127a06cf1bdf878f4f7ca (patch)
tree249f7190feeef1e18f5c88b5987f6e632193df33 /Lib/_collections_abc.py
parent2ab5b092e5a82390c236708b7c163a32dfc928a1 (diff)
downloadcpython-fdbeb2b4b67e1e44c96127a06cf1bdf878f4f7ca.zip
cpython-fdbeb2b4b67e1e44c96127a06cf1bdf878f4f7ca.tar.gz
cpython-fdbeb2b4b67e1e44c96127a06cf1bdf878f4f7ca.tar.bz2
Issue #24400: Resurrect inspect.isawaitable()
collections.abc.Awaitable and collections.abc.Coroutine no longer use __instancecheck__ hook to detect generator-based coroutines. inspect.isawaitable() can be used to detect generator-based coroutines and to distinguish them from regular generator objects.
Diffstat (limited to 'Lib/_collections_abc.py')
-rw-r--r--Lib/_collections_abc.py17
1 files changed, 1 insertions, 16 deletions
diff --git a/Lib/_collections_abc.py b/Lib/_collections_abc.py
index ba6a9b8..f89bb6f 100644
--- a/Lib/_collections_abc.py
+++ b/Lib/_collections_abc.py
@@ -81,22 +81,7 @@ class Hashable(metaclass=ABCMeta):
return NotImplemented
-class _AwaitableMeta(ABCMeta):
-
- def __instancecheck__(cls, instance):
- # This hook is needed because we can't add
- # '__await__' method to generator objects, and
- # we can't register GeneratorType on Awaitable.
- # NB: 0x100 = CO_ITERABLE_COROUTINE
- # (We don't want to import 'inspect' module, as
- # a dependency for 'collections.abc')
- if (instance.__class__ is generator and
- instance.gi_code.co_flags & 0x100):
- return True
- return super().__instancecheck__(instance)
-
-
-class Awaitable(metaclass=_AwaitableMeta):
+class Awaitable(metaclass=ABCMeta):
__slots__ = ()