From c0215dfbc1156267e3b14145c49195c843cd0721 Mon Sep 17 00:00:00 2001 From: Yury Selivanov Date: Tue, 8 Nov 2016 19:57:44 -0500 Subject: Issue #28639: Fix inspect.isawaitable to always return bool Patch by Justin Mayfield. --- Lib/inspect.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Lib/inspect.py') diff --git a/Lib/inspect.py b/Lib/inspect.py index 0fd0382776..e6dae1e048 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -207,10 +207,10 @@ def iscoroutine(object): return isinstance(object, types.CoroutineType) def isawaitable(object): - """Return true is object can be passed to an ``await`` expression.""" + """Return true if 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 + bool(object.gi_code.co_flags & CO_ITERABLE_COROUTINE) or isinstance(object, collections.abc.Awaitable)) def istraceback(object): -- cgit v1.2.1