Commit 3bae7ddf authored by Fred Drake's avatar Fred Drake

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.
parent 5cc6d6e5
......@@ -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 = []
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment