Commit 7db2ce6e authored by Stefan Behnel's avatar Stefan Behnel

merged in Vitja's generators fix

parents eecc7543 5d30ad61
......@@ -193,9 +193,8 @@ class PostParse(ScopeTrackingTransform):
collector = YieldNodeCollector()
collector.visitchildren(node.result_expr)
if collector.yields or isinstance(node.result_expr, ExprNodes.YieldExprNode):
body = ExprNodes.YieldExprNode(
node.result_expr.pos, arg=node.result_expr)
body = Nodes.ExprStatNode(node.result_expr.pos, expr=body)
body = Nodes.ExprStatNode(
node.result_expr.pos, expr=node.result_expr)
else:
body = Nodes.ReturnStatNode(
node.result_expr.pos, value=node.result_expr)
......
......@@ -295,10 +295,11 @@ def test_inside_lambda():
>>> obj = test_inside_lambda()()
>>> next(obj)
1
>>> obj.send('a')
>>> next(obj)
2
>>> obj.send('b')
('a', 'b')
>>> next(obj)
Traceback (most recent call last):
StopIteration
"""
return lambda:((yield 1), (yield 2))
......
......@@ -7,10 +7,6 @@ except ImportError:
def next(it):
return it.next()
if hasattr(__builtins__, 'GeneratorExit'):
GeneratorExit = __builtins__.GeneratorExit
else: # < 2.5
GeneratorExit = StopIteration
def very_simple():
"""
......@@ -280,10 +276,11 @@ def test_inside_lambda():
>>> obj = test_inside_lambda()()
>>> next(obj)
1
>>> obj.send('a')
>>> next(obj)
2
>>> obj.send('b')
('a', 'b')
>>> next(obj)
Traceback (most recent call last):
StopIteration
"""
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