File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11test_operations
223. Operations
3- XXX Not yet implemented
3+ XXX Mostly not yet implemented
4+ 3.1 Dictionary lookups succeed even if __cmp__() raises an exception
5+ raising error
6+ No exception passed through.
Original file line number Diff line number Diff line change 22
33
44print '3. Operations'
5- print 'XXX Not yet implemented'
5+ print 'XXX Mostly not yet implemented'
6+
7+
8+ print '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+
13+ class 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+
23+ d = {}
24+ x1 = BadDictKey ()
25+ x2 = BadDictKey ()
26+ d [x1 ] = 1
27+ d [x2 ] = 2
28+ print "No exception passed through."
You can’t perform that action at this time.
0 commit comments