[issue2325] isinstance(anything, MetaclassThatDefinesInstancecheck) raises instead of returning False

Amaury Forgeot d'Arc report at bugs.python.org
Mon Jun 30 14:46:01 CEST 2008


Amaury Forgeot d'Arc <amauryfa at gmail.com> added the comment:

I think the best is to ignore __instancecheck__ when
"cls.__instancecheck__" is returned as an unbound method. In this case,
we try "type(cls).__instancecheck__" instead.

Here is a patch along this idea.
I had to disable a test named "Evil", because in this case isinstance()
simply falls back to the original algorithm.

I don't know if this is applicable to 3.0: unbound methods don't exist
any more.

----------
nosy: +amaury.forgeotdarc
Added file: http://bugs.python.org/file10783/instancecheck.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2325>
_______________________________________


More information about the Python-bugs-list mailing list