mirror of
https://github.com/python/cpython.git
synced 2025-08-26 19:55:24 +00:00
Bug #1196315: fix weakref.WeakValueDictionary constructor.
This commit is contained in:
parent
4c560ea05b
commit
9166e1a24a
2 changed files with 3 additions and 1 deletions
|
@ -43,12 +43,12 @@ class WeakValueDictionary(UserDict.UserDict):
|
|||
# way in).
|
||||
|
||||
def __init__(self, *args, **kw):
|
||||
UserDict.UserDict.__init__(self, *args, **kw)
|
||||
def remove(wr, selfref=ref(self)):
|
||||
self = selfref()
|
||||
if self is not None:
|
||||
del self.data[wr.key]
|
||||
self._remove = remove
|
||||
UserDict.UserDict.__init__(self, *args, **kw)
|
||||
|
||||
def __getitem__(self, key):
|
||||
o = self.data[key]()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue