From: Raymond Hettinger Date: Fri, 12 Aug 2005 23:58:22 +0000 (+0000) Subject: * Fix SF #1257731. Make __contains__(), remove(), and discard() only do X-Git-Tag: v2.5a0~1523 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=97979ddc141b88cfd81bdf02404d0337a603f7cf;p=thirdparty%2FPython%2Fcpython.git * 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. --- diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py index a21d53c72645..f393712b84f1 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