diff options
author | Raymond Hettinger <python@rcn.com> | 2005-08-12 23:58:22 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2005-08-12 23:58:22 (GMT) |
commit | 97979ddc141b88cfd81bdf02404d0337a603f7cf (patch) | |
tree | f11d43a741e1e74ebd632d542620f00e9f0120b6 | |
parent | b02c35e2081847cff27b55861184444fd22bc4f0 (diff) | |
download | cpython-97979ddc141b88cfd81bdf02404d0337a603f7cf.zip cpython-97979ddc141b88cfd81bdf02404d0337a603f7cf.tar.gz cpython-97979ddc141b88cfd81bdf02404d0337a603f7cf.tar.bz2 |
* Fix SF #1257731. Make __contains__(), remove(), and discard() only do
a frozenset conversion when the initial search attempt fails with a
TypeError and the key is some type of set. Add a testcase.
* Eliminate a duplicate if-stmt.
-rw-r--r-- | Lib/test/test_set.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py index a21d53c..f393712 100644 --- a/Lib/test/test_set.py +++ b/Lib/test/test_set.py @@ -213,6 +213,19 @@ class TestJointOps(unittest.TestCase): elem.sub = elem elem.set = set([elem]) + def test_subclass_with_custom_hash(self): + # Bug #1257731 + class H(self.thetype): + def __hash__(self): + return id(self) + s=H() + f=set() + f.add(s) + self.assert_(s in f) + f.remove(s) + f.add(s) + f.discard(s) + class TestSet(TestJointOps): thetype = set |