fix result types for C math operations on Python booleans
authorStefan Behnel <scoder@users.berlios.de>
Thu, 25 Nov 2010 06:44:59 +0000 (07:44 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Thu, 25 Nov 2010 06:44:59 +0000 (07:44 +0100)
Cython/Compiler/ExprNodes.py

index 9bcd2b98c9263920afcedaa76c5982d9c46e6cb6..86fc0bff8b88933aaeb6b2ed54ee1b8ed94c3c7d 100755 (executable)
@@ -5651,7 +5651,12 @@ class NumBinopNode(BinopNode):
     
     def compute_c_result_type(self, type1, type2):
         if self.c_types_okay(type1, type2):
-            return PyrexTypes.widest_numeric_type(type1, type2)
+            widest_type = PyrexTypes.widest_numeric_type(type1, type2)
+            if widest_type is PyrexTypes.c_bint_type:
+                if self.operator not in '|^&':
+                    # False + False == 0 # not False!
+                    widest_type = PyrexTypes.c_int_type
+            return widest_type
         else:
             return None