diff options
author | Fred Drake <fdrake@acm.org> | 2001-11-06 16:36:53 +0000 |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2001-11-06 16:36:53 +0000 |
commit | 3bae7ddf8e63889b185235f85a6695bc05d59059 (patch) | |
tree | 89fa20dc9987888ae333311e2b37c52a826d1b36 /Lib/weakref.py | |
parent | 5cc6d6e58eee602f24e60c1737e3f059986e102f (diff) | |
download | cpython-git-3bae7ddf8e63889b185235f85a6695bc05d59059.tar.gz |
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.
Diffstat (limited to 'Lib/weakref.py')
-rw-r--r-- | Lib/weakref.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/weakref.py b/Lib/weakref.py index 39ec33049d..967458d989 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 = [] |