Commit 59820426 authored by Vitja Makarov's avatar Vitja Makarov

CondExprNode: fix casting in assignment

parent efbac550
......@@ -8003,7 +8003,7 @@ class CondExprNode(ExprNode):
def eval_and_get(self, code, expr):
expr.generate_evaluation_code(code)
expr.make_owned_reference(code)
code.putln("%s = %s;" % (self.result(), expr.result()))
code.putln('%s = %s;' % (self.result(), expr.result_as(self.ctype())))
expr.generate_post_assignment_code(code)
expr.free_temps(code)
......
# mode: run
# tag: if_else_expr
cdef class Foo:
def __repr__(self):
return '<Foo>'
cpdef test_type_cast(Foo obj, cond):
"""
# Regression test: obj must be cast to (PyObject *) here
>>> test_type_cast(Foo(), True)
[<Foo>]
>>> test_type_cast(Foo(), False)
<Foo>
"""
return [obj] if cond else obj
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