# ----- Non-error return cleanup
code.put_label(code.return_label)
-
+ code.put_xdecref(Naming.retval_cname, py_object_type)
code.putln('%s->%s.resume_label = -1;' % (Naming.cur_scope_cname, Naming.obj_base_cname))
code.put_finish_refcount_context()
code.putln('return NULL;');
collector.visitchildren(node)
if collector.yields:
- if collector.returns and not collector.has_return_value:
- error(collector.returns[0].pos, "'return' inside generators not yet supported ")
+ #if collector.returns and not collector.has_return_value:
+ # error(collector.returns[0].pos, "'return' inside generators not yet supported ")
gbody = Nodes.GeneratorBodyDefNode(pos=node.pos,
name=node.name,
return 0
yield
-def xxx():
- yield
- return
-
yield
class Foo:
_ERRORS = u"""
3:4: 'return' with argument inside generator
7:4: 'yield' outside function
-11:4: 'return' inside generators not yet supported
-13:0: 'yield' not supported here
-16:4: 'yield' not supported here
+9:0: 'yield' not supported here
+12:4: 'yield' not supported here
"""
for i in args:
yield i
+def test_return(a):
+ """
+ >>> d = dict()
+ >>> obj = test_return(d)
+ >>> next(obj)
+ 1
+ >>> next(obj)
+ Traceback (most recent call last):
+ StopIteration
+ >>> d['i_was_here']
+ True
+ """
+ yield 1
+ a['i_was_here'] = True
+ return