Message365774
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 tem3.py), 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:49 | terry.reedy | set | recipients:
+ terry.reedy |
2020-04-04 19:28:49 | terry.reedy | set | messageid: <1586028529.92.0.773288395215.issue40180@roundup.psfhosted.org> |
2020-04-04 19:28:49 | terry.reedy | link | issue40180 messages |
2020-04-04 19:28:49 | terry.reedy | create | |
|