Commit 9de47b5e authored by Stefan Behnel's avatar Stefan Behnel

fix for-from loop in list comprehensions

parent ccd65093
...@@ -625,8 +625,12 @@ class ComprehensionTransform(VisitorTransform): ...@@ -625,8 +625,12 @@ class ComprehensionTransform(VisitorTransform):
# replace name references in the loop code by their temp node # replace name references in the loop code by their temp node
self.visitchildren(node, ['loop']) self.visitchildren(node, ['loop'])
self.comprehension_targets = outer_comprehension_targets loop = node.loop
if type(loop) is Nodes.ForFromStatNode and loop.target.type.is_numeric:
loop.loopvar_node = loop.target
node.loop = TempsBlockNode(node.pos, body=node.loop, temps=temps) node.loop = TempsBlockNode(node.pos, body=node.loop, temps=temps)
self.comprehension_targets = outer_comprehension_targets
return node return node
def visit_NameNode(self, node): def visit_NameNode(self, node):
......
u"""
>>> for_else()
30
>>> print( u'*'.join(int_comp()) )
00*01*02
"""
def for_else():
cdef int i, j=0, k=2
for i from 0 <= i < 10:
j += k
else:
k = j+10
return k
def int_comp():
cdef int i
return tuple([ u"%02d" % i
for i from 0 <= i < 3 ])
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