[Python-checkins] python/dist/src/Lib/test test_set.py, 1.16.2.1, 1.16.2.2

rhettinger@users.sourceforge.net rhettinger at users.sourceforge.net
Sat Aug 13 01:48:00 CEST 2005


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8678/Lib/test

Modified Files:
      Tag: release24-maint
	test_set.py 
Log Message:
* SF bug #1257731:  Fix logic in set.__contains__(), set.remove(),
  and set.discard for handling keys that both inherite from set and
  define their own __hash__() function.

* Fixed O(n) performance issue with set.pop() which should have been
  an O(1) process.



Index: test_set.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_set.py,v
retrieving revision 1.16.2.1
retrieving revision 1.16.2.2
diff -u -d -r1.16.2.1 -r1.16.2.2
--- test_set.py	19 Jun 2005 05:53:14 -0000	1.16.2.1
+++ test_set.py	12 Aug 2005 23:47:50 -0000	1.16.2.2
@@ -212,6 +212,19 @@
             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
 



More information about the Python-checkins mailing list