]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
* Fix SF #1257731. Make __contains__(), remove(), and discard() only do
authorRaymond Hettinger <python@rcn.com>
Fri, 12 Aug 2005 23:58:22 +0000 (23:58 +0000)
committerRaymond Hettinger <python@rcn.com>
Fri, 12 Aug 2005 23:58:22 +0000 (23:58 +0000)
  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.

Lib/test/test_set.py

index a21d53c726454f2526cc08319499e5d61b7eaea7..f393712b84f1c1e8cbb814f405916fccef8784e7 100644 (file)
@@ -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