]> granicus.if.org Git - python/commitdiff
Test case to exercise fix for error propogation bug in dictionarys.
authorFred Drake <fdrake@acm.org>
Thu, 31 Aug 2000 19:48:52 +0000 (19:48 +0000)
committerFred Drake <fdrake@acm.org>
Thu, 31 Aug 2000 19:48:52 +0000 (19:48 +0000)
Lib/test/output/test_operations
Lib/test/test_operations.py

index 2accbd71fbfdd14f77d4c7be6c6a9c8f650d6eb1..32eff3f21a8acf68e6b6cc273214b284641e0303 100644 (file)
@@ -1,3 +1,6 @@
 test_operations
 3. Operations
-XXX Not yet implemented
+XXX Mostly not yet implemented
+3.1 Dictionary lookups succeed even if __cmp__() raises an exception
+raising error
+No exception passed through.
index 1a75065190bfc2b35964987ea7d1fbf96efb1ade..c14f480eeb8c25be7ea19321991024138a49f862 100644 (file)
@@ -2,4 +2,27 @@
 
 
 print '3. Operations'
-print 'XXX Not yet implemented'
+print 'XXX Mostly not yet implemented'
+
+
+print '3.1 Dictionary lookups succeed even if __cmp__() raises an exception'
+
+# SourceForge bug #112558:
+# http://sourceforge.net/bugs/?func=detailbug&bug_id=112558&group_id=5470
+
+class BadDictKey: 
+    def __hash__(self): 
+        return hash(self.__class__) 
+
+    def __cmp__(self, other): 
+        if isinstance(other, self.__class__): 
+            print "raising error" 
+            raise RuntimeError, "gotcha" 
+        return other 
+
+d = {}
+x1 = BadDictKey()
+x2 = BadDictKey()
+d[x1] = 1
+d[x2] = 2
+print "No exception passed through."