Commit 5827f4c9 authored by Stefan Behnel's avatar Stefan Behnel

fix refnanny code for del statement inside of generators

parent 37724ccc
......@@ -1861,6 +1861,8 @@ class NameNode(AtomicExprNode):
code.put_error_if_unbound(self.pos, self.entry)
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.putln('%s = NULL;' % self.result())
else:
......
......@@ -350,3 +350,15 @@ def test_generator_cleanup():
yield 1
finally:
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