Commit 3279d914 authored by Stefan Behnel's avatar Stefan Behnel

work around missing temp variable declaration when a multiplied tuple ends up as cached constant

parent 6fc4bd3c
......@@ -4432,8 +4432,17 @@ class SequenceNode(ExprNode):
code.error_goto_if_null(self.result(), self.pos)))
code.put_gotref(self.py_result())
if mult:
counter = code.funcstate.allocate_temp(self.mult_factor.type, manage_ref=False)
offset = '%s * %s + ' % (counter, arg_count)
# FIXME: can't use a temp variable here as the code may
# end up in the constant building function. Temps
# currently don't work there.
#counter = code.funcstate.allocate_temp(self.mult_factor.type, manage_ref=False)
counter = '__pyx_n'
code.putln('{ Py_ssize_t %s;' % counter)
if arg_count == 1:
offset = counter + ' + '
else:
offset = '%s * %s + ' % (counter, arg_count)
code.putln('for (%s=0; %s < %s; %s++) {' % (
counter, counter, mult, counter
))
......@@ -4452,7 +4461,8 @@ class SequenceNode(ExprNode):
code.put_giveref(arg.py_result())
if mult:
code.putln('}')
code.funcstate.release_temp(counter)
#code.funcstate.release_temp(counter)
code.putln('}')
def generate_subexpr_disposal_code(self, code):
if self.mult_factor:
......
......@@ -167,6 +167,14 @@ def multiplied_lists_with_side_effects():
"""
return [side_effect(1), side_effect(2), side_effect(3)] * 5
@cython.test_fail_if_path_exists("//MulNode")
def multiplied_const_tuple():
"""
>>> multiplied_const_tuple() == (1,2) * 5
True
"""
return (1,2) * 5
@cython.test_fail_if_path_exists("//PrimaryCmpNode")
def compile_time_DEF():
"""
......
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