Commit d832f463 authored by Stefan Behnel's avatar Stefan Behnel

use plain constants for Python bool values instead of coerced C ints

parent 1d98bd20
......@@ -947,7 +947,18 @@ class BoolNode(ConstNode):
return self.value
def calculate_result_code(self):
return str(int(self.value))
if self.type.is_pyobject:
return self.value and 'Py_True' or 'Py_False'
else:
return str(int(self.value))
def coerce_to(self, dst_type, env):
if dst_type.is_pyobject and self.type.is_int:
return BoolNode(
self.pos, value=self.value,
constant_result=self.constant_result,
type=Builtin.bool_type)
return ConstNode.coerce_to(self, dst_type, env)
class NullNode(ConstNode):
......
......@@ -27,6 +27,7 @@ def unop_floats():
@cython.test_fail_if_path_exists(
"//UnaryMinusNode",
"//UnaryPlusNode",
"//CoerceToPyTypeNode",
)
def unop_py_floats_tuple():
"""
......
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