From: Fred Drake Date: Thu, 31 Aug 2000 19:48:52 +0000 (+0000) Subject: Test case to exercise fix for error propogation bug in dictionarys. X-Git-Tag: v2.0b1~119 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=762c1cb3e351ed133055609ce48a3b140665ff37;p=python Test case to exercise fix for error propogation bug in dictionarys. --- diff --git a/Lib/test/output/test_operations b/Lib/test/output/test_operations index 2accbd71fb..32eff3f21a 100644 --- a/Lib/test/output/test_operations +++ b/Lib/test/output/test_operations @@ -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. diff --git a/Lib/test/test_operations.py b/Lib/test/test_operations.py index 1a75065190..c14f480eeb 100644 --- a/Lib/test/test_operations.py +++ b/Lib/test/test_operations.py @@ -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."