Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:
Here's an example in PEP 3119 that appears to work but actually bypasses the method: from abc import ABCMeta, abstractmethod class Sized(metaclass=ABCMeta): @abstractmethod def __hash__(self): return 0 @classmethod def __instancecheck__(cls, x): print('Called') return hasattr(x, "__len__") @classmethod def __subclasscheck__(cls, C): return hasattr(C, "__bases__") and hasattr(C, "__len__") $ python3.10 -i demo_3119.py >>> isinstance([], Sized) True ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue45791> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com