summaryrefslogtreecommitdiffstats
path: root/Lib/weakref.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-09-06 14:51:01 (GMT)
committerFred Drake <fdrake@acm.org>2001-09-06 14:51:01 (GMT)
commitb663a2ccbdd9bbd9a13f0cea743af709c53ec0c1 (patch)
treea5f922843d2754785a93696d4a96c68c668ef5bc /Lib/weakref.py
parent7b219b4a926905a1357a70db4309ba52e0d7447d (diff)
downloadcpython-b663a2ccbdd9bbd9a13f0cea743af709c53ec0c1.zip
cpython-b663a2ccbdd9bbd9a13f0cea743af709c53ec0c1.tar.gz
cpython-b663a2ccbdd9bbd9a13f0cea743af709c53ec0c1.tar.bz2
Add __delitem__() support for WeakKeyDictionary.
This closes SF bug #458860.
Diffstat (limited to 'Lib/weakref.py')
-rw-r--r--Lib/weakref.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/weakref.py b/Lib/weakref.py
index 1d21e79..c71d04b 100644
--- a/Lib/weakref.py
+++ b/Lib/weakref.py
@@ -146,6 +146,13 @@ class WeakKeyDictionary(UserDict.UserDict):
del data[k]
self._remove = remove
+ def __delitem__(self, key):
+ for ref in self.data.iterkeys():
+ o = ref()
+ if o == key:
+ del self.data[ref]
+ return
+
def __getitem__(self, key):
return self.data[ref(key)]