From: Fred Drake Date: Fri, 2 Feb 2001 15:13:24 +0000 (+0000) Subject: WeakDictionary.items(): Do not allow (key,ref) pairs to leak out for X-Git-Tag: v2.1a2~19 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=312a5dc539b583abcbbf006942a4ceead9b9172b;p=thirdparty%2FPython%2Fcpython.git WeakDictionary.items(): Do not allow (key,ref) pairs to leak out for dead references. --- diff --git a/Lib/weakref.py b/Lib/weakref.py index f6e07c91acc8..cc7b494c913c 100644 --- a/Lib/weakref.py +++ b/Lib/weakref.py @@ -67,12 +67,12 @@ class WeakDictionary(UserDict.UserDict): return o def items(self): - L = self.data.items() - for i in range(len(L)): + L = [] + for key, ref in self.data.items(): key, ref = L[i] o = ref() if o is not None: - L[i] = key, o + L.append((key, o)) return L def popitem(self):