Commit d19d6396 authored by Stefan Behnel's avatar Stefan Behnel

fix #442: non-pyobject for-in-loop targets failed with enumerate() optimisation

parent a2bbb8f0
......@@ -237,10 +237,6 @@ class IterationTransform(Visitor.VisitorTransform):
# nothing we can do here, I guess
return node
if iterable_target.type is not PyrexTypes.py_object_type:
# this may need conversion, could be made to work
return node
temp = UtilNodes.LetRefNode(ExprNodes.IntNode(enumerate_function.pos,
value='0',
type=counter_type,
......@@ -276,6 +272,7 @@ class IterationTransform(Visitor.VisitorTransform):
stats = loop_body)
node.target = iterable_target
node.item = node.item.coerce_to(iterable_target.type, self.current_scope)
node.iterator.sequence = enumerate_function.arg_tuple.args[0]
# recurse into loop to check for further optimisations
......
......@@ -12,7 +12,7 @@ def go_py_enumerate():
for i,k in enumerate(range(1,5)):
print i, k
#T442 @cython.test_fail_if_path_exists("//SimpleCallNode//NameNode[@name = 'enumerate']")
@cython.test_fail_if_path_exists("//SimpleCallNode//NameNode[@name = 'enumerate']")
def go_c_enumerate():
"""
>>> go_c_enumerate()
......@@ -25,7 +25,7 @@ def go_c_enumerate():
for i,k in enumerate(range(1,5)):
print i, k
#T442 @cython.test_fail_if_path_exists("//SimpleCallNode//NameNode[@name = 'enumerate']")
@cython.test_fail_if_path_exists("//SimpleCallNode//NameNode[@name = 'enumerate']")
def go_c_enumerate_step():
"""
>>> go_c_enumerate_step()
......@@ -97,7 +97,7 @@ def py_enumerate_continue(*t):
continue
print u"::", i, k
# T442 @cython.test_fail_if_path_exists("//SimpleCallNode//NameNode[@name = 'enumerate']")
@cython.test_fail_if_path_exists("//SimpleCallNode//NameNode[@name = 'enumerate']")
def empty_c_enumerate():
"""
>>> empty_c_enumerate()
......@@ -132,7 +132,7 @@ def multi_enumerate():
for a,(b,(c,d)) in enumerate(enumerate(enumerate(range(1,5)))):
print a,b,c,d
# T442 @cython.test_fail_if_path_exists("//SimpleCallNode")
@cython.test_fail_if_path_exists("//SimpleCallNode")
def multi_c_enumerate():
"""
>>> multi_c_enumerate()
......@@ -145,7 +145,7 @@ def multi_c_enumerate():
for a,(b,(c,d)) in enumerate(enumerate(enumerate(range(1,5)))):
print a,b,c,d
# T442 @cython.test_fail_if_path_exists("//SimpleCallNode")
@cython.test_fail_if_path_exists("//SimpleCallNode")
def convert_target_enumerate(L):
"""
>>> convert_target_enumerate([2,3,5])
......
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