Commit 4abd0ca8 authored by Vitja Makarov's avatar Vitja Makarov

Merge branch 'master' of github.com:vitek/cython

parents 719f7569 3f34de4e
......@@ -2983,8 +2983,6 @@ class GeneratorBodyDefNode(DefNode):
# Generate closure function definitions
self.body.generate_function_definitions(lenv, code)
# generate lambda function definitions
self.generate_lambda_definitions(lenv, code)
# Generate C code for header and body of function
code.enter_cfunc_scope()
......
......@@ -1377,8 +1377,8 @@ class MarkClosureVisitor(CythonTransform):
collector.visitchildren(node)
if collector.yields:
for i, yield_expr in enumerate(collector.yields):
yield_expr.label_num = i + 1
for i, yield_expr in enumerate(collector.yields, 1):
yield_expr.label_num = i
gbody = Nodes.GeneratorBodyDefNode(pos=node.pos,
name=node.name,
......
......@@ -299,3 +299,19 @@ def test_inside_lambda():
('a', 'b')
"""
return lambda:((yield 1), (yield 2))
def test_nested_gen(int n):
"""
>>> [list(a) for a in test_nested_gen(5)]
[[], [0], [0, 1], [0, 1, 2], [0, 1, 2, 3]]
"""
for a in range(n):
yield (b for b in range(a))
def test_lambda(n):
"""
>>> [i() for i in test_lambda(3)]
[0, 1, 2]
"""
for i in range(n):
yield lambda : i
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