fix ticket #145: the result of 'True or 5' must not be coerced into an integer
authorStefan Behnel <scoder@users.berlios.de>
Tue, 4 May 2010 19:00:24 +0000 (21:00 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Tue, 4 May 2010 19:00:24 +0000 (21:00 +0200)
Cython/Compiler/ExprNodes.py
tests/bugs.txt

index eb164973603bba1e176e769c589868251f9ed614..4eeca967f8063d192dbbab4e098dbcecda6d53a2 100755 (executable)
@@ -5305,6 +5305,14 @@ class BoolBinopNode(ExprNode):
         self.operand1.analyse_types(env)
         self.operand2.analyse_types(env)
         self.type = PyrexTypes.spanning_type(self.operand1.type, self.operand2.type)
+        if self.type.is_numeric and self.type is not PyrexTypes.c_bint_type:
+            # special case: if one of the results is a bint and the other
+            # is another C integer, we must prevent returning a numeric
+            # type so that we do not loose the ability to coerce to a
+            # Python bool
+            if self.operand1.type is PyrexTypes.c_bint_type or \
+                   self.operand2.type is PyrexTypes.c_bint_type:
+                self.type = py_object_type
         self.operand1 = self.operand1.coerce_to(self.type, env)
         self.operand2 = self.operand2.coerce_to(self.type, env)
         
index c75f5e71bce4f24c492986120209a427ae580af5..8a3837d4037abb8f68e524a5e232fbee17338389 100644 (file)
@@ -9,7 +9,6 @@ missing_baseclass_in_predecl_T262
 cfunc_call_tuple_args_T408
 cascaded_list_unpacking_T467
 compile.cpp_operators
-bint_binop_T145
 
 # CPython regression tests that don't current work:
 pyregr.test_threadsignals