Commit 15bedf56 authored by Stefan Behnel's avatar Stefan Behnel

merged 0.17 branch into master

parents 19c2e5a9 dfb2d745
...@@ -1867,6 +1867,8 @@ class NameNode(AtomicExprNode): ...@@ -1867,6 +1867,8 @@ class NameNode(AtomicExprNode):
code.put_error_if_unbound(self.pos, self.entry) code.put_error_if_unbound(self.pos, self.entry)
if self.entry.type.is_pyobject: if self.entry.type.is_pyobject:
if self.entry.in_closure:
code.put_gotref(self.result()) # generator
code.put_decref(self.result(), self.ctype()) code.put_decref(self.result(), self.ctype())
code.putln('%s = NULL;' % self.result()) code.putln('%s = NULL;' % self.result())
else: else:
......
...@@ -350,3 +350,15 @@ def test_generator_cleanup(): ...@@ -350,3 +350,15 @@ def test_generator_cleanup():
yield 1 yield 1
finally: finally:
print('cleanup') print('cleanup')
def test_del_in_generator():
"""
>>> [ s for s in test_del_in_generator() ]
['abcabcabc', 'abcabcabc']
"""
x = len('abc') * 'abc'
a = x
yield x
del x
yield a
del a
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