From: Stefan Behnel Date: Sun, 19 Dec 2010 18:55:56 +0000 (+0100) Subject: fix ticket #631: temp leak when deleting slices X-Git-Tag: 0.14.1rc0~13^2~11 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ce66d5537aa3d9a333347bfa248ad77dd75e12d1;p=cython.git fix ticket #631: temp leak when deleting slices --- diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 2ecddeb4..c0440641 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -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: diff --git a/tests/run/delete.pyx b/tests/run/delete.pyx index b0626581..2aabbf42 100644 --- a/tests/run/delete.pyx +++ b/tests/run/delete.pyx @@ -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