bpo-39274: Ensure Fraction.__bool__() returns a bool (GH-18017)


Some numerator types used (specifically NumPy) decides to not
return a Python boolean for the "a != b" operation. Using the equivalent
call to bool() guarantees a bool return also for such types.
(cherry picked from commit 427c84f13f7719e6014a21bd1b81efdc02a046fb)

Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
diff --git a/Lib/fractions.py b/Lib/fractions.py
index e774d58..e4fcc89 100644
--- a/Lib/fractions.py
+++ b/Lib/fractions.py
@@ -636,7 +636,9 @@
 
     def __bool__(a):
         """a != 0"""
-        return a._numerator != 0
+        # bpo-39274: Use bool() because (a._numerator != 0) can return an
+        # object which is not a bool.
+        return bool(a._numerator)
 
     # support for pickling, copy, and deepcopy