blob: 4c76a8fa51a6c1f82ddec1372e95f9ce34e2da35 [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
Fred Drake004d5e62000-10-23 17:22:08 +000013class BadDictKey:
14 def __hash__(self):
15 return hash(self.__class__)
Fred Drake762c1cb2000-08-31 19:48:52 +000016
Fred Drake004d5e62000-10-23 17:22:08 +000017 def __cmp__(self, other):
18 if isinstance(other, self.__class__):
19 print "raising error"
20 raise RuntimeError, "gotcha"
21 return other
Fred Drake762c1cb2000-08-31 19:48:52 +000022
23d = {}
24x1 = BadDictKey()
25x2 = BadDictKey()
26d[x1] = 1
27d[x2] = 2
28print "No exception passed through."