From ce66d5537aa3d9a333347bfa248ad77dd75e12d1 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sun, 19 Dec 2010 19:55:56 +0100 Subject: [PATCH] fix ticket #631: temp leak when deleting slices --- Cython/Compiler/ExprNodes.py | 1 + tests/run/delete.pyx | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) 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 -- 2.26.2