Commit e946e51b authored by Vitja Makarov's avatar Vitja Makarov

Fix yield inside lambda

parent 94f84295
...@@ -193,9 +193,8 @@ class PostParse(ScopeTrackingTransform): ...@@ -193,9 +193,8 @@ class PostParse(ScopeTrackingTransform):
collector = YieldNodeCollector() collector = YieldNodeCollector()
collector.visitchildren(node.result_expr) collector.visitchildren(node.result_expr)
if collector.yields or isinstance(node.result_expr, ExprNodes.YieldExprNode): if collector.yields or isinstance(node.result_expr, ExprNodes.YieldExprNode):
body = ExprNodes.YieldExprNode( body = Nodes.ExprStatNode(
node.result_expr.pos, arg=node.result_expr) node.result_expr.pos, expr=node.result_expr)
body = Nodes.ExprStatNode(node.result_expr.pos, expr=body)
else: else:
body = Nodes.ReturnStatNode( body = Nodes.ReturnStatNode(
node.result_expr.pos, value=node.result_expr) node.result_expr.pos, value=node.result_expr)
......
...@@ -291,10 +291,11 @@ def test_inside_lambda(): ...@@ -291,10 +291,11 @@ def test_inside_lambda():
>>> obj = test_inside_lambda()() >>> obj = test_inside_lambda()()
>>> next(obj) >>> next(obj)
1 1
>>> obj.send('a') >>> next(obj)
2 2
>>> obj.send('b') >>> next(obj)
('a', 'b') Traceback (most recent call last):
StopIteration
""" """
return lambda:((yield 1), (yield 2)) return lambda:((yield 1), (yield 2))
......
...@@ -276,10 +276,11 @@ def test_inside_lambda(): ...@@ -276,10 +276,11 @@ def test_inside_lambda():
>>> obj = test_inside_lambda()() >>> obj = test_inside_lambda()()
>>> next(obj) >>> next(obj)
1 1
>>> obj.send('a') >>> next(obj)
2 2
>>> obj.send('b') >>> next(obj)
('a', 'b') Traceback (most recent call last):
StopIteration
""" """
return lambda:((yield 1), (yield 2)) return lambda:((yield 1), (yield 2))
......
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