summaryrefslogtreecommitdiff
path: root/Doc/library/inspect.rst
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2015-07-03 13:11:35 -0400
committerYury Selivanov <yselivanov@sprymix.com>2015-07-03 13:11:35 -0400
commitfdbeb2b4b67e1e44c96127a06cf1bdf878f4f7ca (patch)
tree249f7190feeef1e18f5c88b5987f6e632193df33 /Doc/library/inspect.rst
parent2ab5b092e5a82390c236708b7c163a32dfc928a1 (diff)
downloadcpython-git-fdbeb2b4b67e1e44c96127a06cf1bdf878f4f7ca.tar.gz
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 'Doc/library/inspect.rst')
-rw-r--r--Doc/library/inspect.rst19
1 files changed, 19 insertions, 0 deletions
diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst
index d21672f75e..66b92384f0 100644
--- a/Doc/library/inspect.rst
+++ b/Doc/library/inspect.rst
@@ -310,6 +310,25 @@ attributes:
.. versionadded:: 3.5
+.. function:: isawaitable(object)
+
+ Return true if the object can be used in :keyword:`await` expression.
+
+ Can also be used to distinguish generator-based coroutines from regular
+ generators::
+
+ def gen():
+ yield
+ @types.coroutine
+ def gen_coro():
+ yield
+
+ assert not isawaitable(gen())
+ assert isawaitable(gen_coro())
+
+ .. versionadded:: 3.5
+
+
.. function:: istraceback(object)
Return true if the object is a traceback.