Author terry.reedy
Recipients terry.reedy
Date 2020-04-04.19:28:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Consider class Object defined as follows:

import types
class Type(type):
    __class__ = property({}.__getitem__, {}.__setitem__)
class Object(metaclass=Type):
    __slots__ = '__class__'

isinstance(Object, ob) is true for type and Type and false for anything else.  But for the examples of the latter that I tried, (list, int, types.CodeType, types.MethodType, see attached, it incorrectly raises
  KeyError: <class '__main__.Object'> 

I cannot find the C source for isinstance.  In Python/bltinmodule.c, function builtin_isinstance_impl wraps
  retval = PyObject_IsInstance(obj, class_or_tuple);
but grepping for PyObject_IsInstance in *.c and *.h only returned other calls.
Date User Action Args
2020-04-04 19:28:49terry.reedysetrecipients: + terry.reedy
2020-04-04 19:28:49terry.reedysetmessageid: <>
2020-04-04 19:28:49terry.reedylinkissue40180 messages
2020-04-04 19:28:49terry.reedycreate