Commit 924f1dad authored by Vitja Makarov's avatar Vitja Makarov

Support nested yields

parent aa4e15d3
......@@ -1332,6 +1332,7 @@ class YieldNodeCollector(TreeVisitor):
if self.has_return_value:
error(node.pos, "'yield' outside function")
self.yields.append(node)
self.visitchildren(node)
def visit_ReturnStatNode(self, node):
if node.value:
......
......@@ -272,3 +272,18 @@ def test_copied_yield(foo):
"""
with foo:
yield 1
def test_nested_yield():
"""
>>> obj = test_nested_yield()
>>> next(obj)
1
>>> obj.send(2)
2
>>> obj.send(3)
3
>>> obj.send(4)
Traceback (most recent call last):
StopIteration
"""
yield (yield (yield 1))
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