summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-11-06 16:36:53 (GMT)
committerFred Drake <fdrake@acm.org>2001-11-06 16:36:53 (GMT)
commit3bae7ddf8e63889b185235f85a6695bc05d59059 (patch)
tree89fa20dc9987888ae333311e2b37c52a826d1b36
parent5cc6d6e58eee602f24e60c1737e3f059986e102f (diff)
downloadcpython-3bae7ddf8e63889b185235f85a6695bc05d59059.zip
cpython-3bae7ddf8e63889b185235f85a6695bc05d59059.tar.gz
cpython-3bae7ddf8e63889b185235f85a6695bc05d59059.tar.bz2
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.
-rw-r--r--Lib/weakref.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/weakref.py b/Lib/weakref.py
index 39ec330..967458d 100644
--- a/Lib/weakref.py
+++ b/Lib/weakref.py
@@ -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 = []