Commit 23668f32 authored by Stefan Behnel's avatar Stefan Behnel

fix ticket #145: the result of 'True or 5' must not be coerced into an integer

parent 819991ce
......@@ -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)
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment