Commit ce66d553 authored by Stefan Behnel's avatar Stefan Behnel

fix ticket #631: temp leak when deleting slices

parent 13ed9319
......@@ -2605,6 +2605,7 @@ class SliceIndexNode(ExprNode):
self.start_code(),
self.stop_code()))
self.generate_subexpr_disposal_code(code)
self.free_subexpr_temps(code)
def generate_slice_guard_code(self, code, target_size):
if not self.base.type.is_array:
......
......@@ -60,3 +60,23 @@ def del_list_int(L, int i):
"""
del L[i]
return L
def del_temp_slice(a):
"""
>>> class A(object):
... attr = [1,2,3]
>>> a = A()
>>> a.attr
[1, 2, 3]
>>> del_temp_slice(a)
[]
>>> a.attr
[]
>>> del_temp_slice(a)
[]
>>> a.attr
[]
"""
while a.attr:
del a.attr[:]
return a.attr
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