mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00: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
1 changed files with 5 additions and 1 deletions
|
@ -179,7 +179,11 @@ class WeakKeyDictionary(UserDict.UserDict):
|
||||||
return self.data.get(ref(key),default)
|
return self.data.get(ref(key),default)
|
||||||
|
|
||||||
def has_key(self, key):
|
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):
|
def items(self):
|
||||||
L = []
|
L = []
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue