summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-11-06 16:38:34 (GMT)
committerFred Drake <fdrake@acm.org>2001-11-06 16:38:34 (GMT)
commit752eda459ae8f61b08c898c5a857b2151856881b (patch)
treec67469020972a427bd3a85ff1a48199e0ed7589d /Lib
parent3bae7ddf8e63889b185235f85a6695bc05d59059 (diff)
downloadcpython-752eda459ae8f61b08c898c5a857b2151856881b.zip
cpython-752eda459ae8f61b08c898c5a857b2151856881b.tar.gz
cpython-752eda459ae8f61b08c898c5a857b2151856881b.tar.bz2
Add a regression test for SF bug #478536: If a value cannot be weakly
referenced, WeakKeyDictionary.has_key() should return 0 instead of raising TypeError.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_weakref.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index 87c1670..1623039 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -272,7 +272,7 @@ class MappingTestCase(TestBase):
def test_weak_keys(self):
#
# This exercises d.copy(), d.items(), d[] = v, d[], del d[],
- # len(d).
+ # len(d), d.has_key().
#
dict, objects = self.make_weak_keyed_dict()
for o in objects:
@@ -294,6 +294,10 @@ class MappingTestCase(TestBase):
del objects, o
self.assert_(len(dict) == 0,
"deleting the keys did not clear the dictionary")
+ o = Object(42)
+ dict[o] = "What is the meaning of the universe?"
+ self.assert_(dict.has_key(o))
+ self.assert_(not dict.has_key(34))
def test_weak_keyed_iters(self):
dict, objects = self.make_weak_keyed_dict()