>>> class A(object): ... def __eq__(self, other): ... raise IndexError ... def __hash__(self): ... return hash(1) ... >>> d = {A(): 3} >>> d[1] Traceback (most recent call last): File "", line 1, in File "", line 3, in __eq__ IndexError >>>