Commit d817949d authored by Craig Citro's avatar Craig Citro

Fix an error with coercing C ints in boolean context.

parent dc4c6c5c
...@@ -6268,7 +6268,12 @@ class CoerceToPyTypeNode(CoercionNode): ...@@ -6268,7 +6268,12 @@ class CoerceToPyTypeNode(CoercionNode):
return False return False
def coerce_to_boolean(self, env): def coerce_to_boolean(self, env):
return self.arg.coerce_to_boolean(env).coerce_to_temp(env) arg_type = self.arg.type
if (arg_type == PyrexTypes.c_bint_type or
(arg_type.is_pyobject and arg_type.name == 'bool')):
return self.arg.coerce_to_temp(env)
else:
return CoerceToBooleanNode(self, env)
def coerce_to_integer(self, env): def coerce_to_integer(self, env):
# If not already some C integer type, coerce to longint. # If not already some C integer type, coerce to longint.
......
def test():
"""
>>> test()
True
"""
cdef int x = 5
print bool(x)
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