]> granicus.if.org Git - python/commitdiff
Issue #28639: Fix inspect.isawaitable to always return bool
authorYury Selivanov <yury@magic.io>
Wed, 9 Nov 2016 00:57:44 +0000 (19:57 -0500)
committerYury Selivanov <yury@magic.io>
Wed, 9 Nov 2016 00:57:44 +0000 (19:57 -0500)
Patch by Justin Mayfield.

Lib/inspect.py
Misc/NEWS

index 0fd03827763ec66323c9fdc0b92200964c679cd0..e6dae1e0489dd67f774bd88cf56c94a1b720ed1d 100644 (file)
@@ -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):
index c66a5217d2322ede95df0b2593851bb95e536d6d..7512e1a4d802c5bfb66eb001032197cbba7a2157 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -450,6 +450,9 @@ Library
 - Issue #28613: Fix get_event_loop() return the current loop if 
   called from coroutines/callbacks.
 
+- Issue #28639: Fix inspect.isawaitable to always return bool
+  Patch by Justin Mayfield.
+
 IDLE
 ----