[Python-Dev] Dict suppressing exceptions

Jim Jewett jimjjewett at gmail.com
Fri Aug 11 22:22:07 CEST 2006


Martin v. Löwis wrote:

> Now I looked at it, and think that the recipe is broken. It should
> add an __eq__ method which is

>   def __eq__(self, other):
>       return type(self) is type(other) \
>           and self.EnumType is other.EnumType \
>           and self.__value==other.__value)

Absolutely.  But the point is that there are a lot of these broken
objects out there; this one was on a 5-star recipe that has been
around for a while, and still no one caught it.  That suggests the bug
could reasonably be in any 3rd-party library.

The existence of a (common) bug in someone else's code shouldn't keep
me from using a dictionary of objects.

hash was just changed to support the common use of id, even though
some people argued it was *really* a bug in the classes themselves.
This is a similar situation.

-jJ


More information about the Python-Dev mailing list