1992-01-27 13:00:37 -04:00
|
|
|
# Python test set -- part 3, built-in operations.
|
|
|
|
|
|
|
|
|
|
|
|
print '3. Operations'
|
2000-08-31 16:48:52 -03:00
|
|
|
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
|
|
|
|
|
2000-10-23 14:22:08 -03:00
|
|
|
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
|
2000-08-31 16:48:52 -03:00
|
|
|
|
|
|
|
d = {}
|
|
|
|
x1 = BadDictKey()
|
|
|
|
x2 = BadDictKey()
|
|
|
|
d[x1] = 1
|
|
|
|
d[x2] = 2
|
|
|
|
print "No exception passed through."
|