Add __delitem__() support for WeakKeyDictionary.

This closes SF bug #458860.
This commit is contained in:
Fred Drake 2001-09-06 14:51:01 +00:00
parent 7b219b4a92
commit b663a2ccbd
1 changed files with 7 additions and 0 deletions

View File

@ -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)]