diff options
author | Yury Selivanov <yselivanov@sprymix.com> | 2015-07-03 13:11:54 -0400 |
---|---|---|
committer | Yury Selivanov <yselivanov@sprymix.com> | 2015-07-03 13:11:54 -0400 |
commit | d48fb485d9d6597b1048f6131a28cb14979349af (patch) | |
tree | c5937eb56fc234ac626c58f7bf7e925aef09ffe0 /Lib/inspect.py | |
parent | 11e6d79eca724697f096ba465046c8ea4f8cf86d (diff) | |
parent | fdbeb2b4b67e1e44c96127a06cf1bdf878f4f7ca (diff) | |
download | cpython-git-d48fb485d9d6597b1048f6131a28cb14979349af.tar.gz |
Merge 3.5 (Issue #24400)
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index f48769e514..45679cfc0b 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -207,6 +207,13 @@ def iscoroutine(object): """Return true if the object is a coroutine.""" return isinstance(object, types.CoroutineType) +def isawaitable(object): + """Return true is object can be passed to an ``await`` expression.""" + return (isinstance(object, types.CoroutineType) or + isinstance(object, types.GeneratorType) and + object.gi_code.co_flags & CO_ITERABLE_COROUTINE or + isinstance(object, collections.abc.Awaitable)) + def istraceback(object): """Return true if the object is a traceback. |