mirror of
https://github.com/python/cpython.git
synced 2025-01-27 03:24:35 +08:00
WeakKeyDictionary.has_key(): If the key being tested is not weakly
referencable (weakref.ref() raises TypeError), return 0 instead of propogating the TypeError. This closes SF bug #478536; bugfix candidate.
This commit is contained in:
parent
5cc6d6e58e
commit
3bae7ddf8e
@ -179,7 +179,11 @@ class WeakKeyDictionary(UserDict.UserDict):
|
||||
return self.data.get(ref(key),default)
|
||||
|
||||
def has_key(self, key):
|
||||
return self.data.has_key(ref(key))
|
||||
try:
|
||||
wr = ref(key)
|
||||
except TypeError:
|
||||
return 0
|
||||
return self.data.has_key(wr)
|
||||
|
||||
def items(self):
|
||||
L = []
|
||||
|
Loading…
Reference in New Issue
Block a user