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): ...@@ -947,7 +947,18 @@ class BoolNode(ConstNode):
return self.value return self.value
def calculate_result_code(self): 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): class NullNode(ConstNode):
......
...@@ -27,6 +27,7 @@ def unop_floats(): ...@@ -27,6 +27,7 @@ def unop_floats():
@cython.test_fail_if_path_exists( @cython.test_fail_if_path_exists(
"//UnaryMinusNode", "//UnaryMinusNode",
"//UnaryPlusNode", "//UnaryPlusNode",
"//CoerceToPyTypeNode",
) )
def unop_py_floats_tuple(): 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