blob: c14f480eeb8c25be7ea19321991024138a49f862 [file] [log] [blame]
Guido van Rossum3bead091992-01-27 17:00:37 +00001# Python test set -- part 3, built-in operations.
2
3
4print '3. Operations'
Fred Drake762c1cb2000-08-31 19:48:52 +00005print 'XXX Mostly not yet implemented'
6
7
8print '3.1 Dictionary lookups succeed even if __cmp__() raises an exception'
9
10# SourceForge bug #112558:
11# http://sourceforge.net/bugs/?func=detailbug&bug_id=112558&group_id=5470
12
13class BadDictKey:
14 def __hash__(self):
15 return hash(self.__class__)
16
17 def __cmp__(self, other):
18 if isinstance(other, self.__class__):
19 print "raising error"
20 raise RuntimeError, "gotcha"
21 return other
22
23d = {}
24x1 = BadDictKey()
25x2 = BadDictKey()
26d[x1] = 1
27d[x2] = 2
28print "No exception passed through."