[Python-ideas] Allow isinstance second argument to be a set of types

Jim Jewett jimjjewett at gmail.com
Thu Jul 7 19:22:33 CEST 2011


On Wed, Jul 6, 2011 at 7:35 PM, Benjamin Peterson <benjamin at python.org> wrote:

> class Evil(type):
>    def __iter__(self):
>        return range(42)

> class Accomplice(metaclass=Evil):
>    pass

... leading to isinstance(x, 42) rather than isinstance(x, Evil) if
the iterable check is done too soon.

So, at a minimum, this class should be in the test suite to guard
against future ill-fated optimizations.

-jJ



More information about the Python-ideas mailing list