Hello, I've found that abstractmethod and similar decorators "don't work" in classes, inherited from built-in types other than object. For example:
>>> import abc >>> class MyBase(metaclass=abc.ABCMeta): @abc.abstractmethod def foo(): pass >>> MyBase() Traceback (most recent call last): File "<pyshell#8>", line 1, in <module> MyBase() TypeError: Can't instantiate abstract class MyBase with abstract methods foo So far so good, but: >>> class MyList(list, MyBase): pass >>> MyList() [] >>> MyList.__abstractmethods__ frozenset({'foo'}) This is unexpected, since MyList still doesn't implement foo. Should this be considered a bug? I don't see this in documentation. The underlying reason is that __abstractmethods__ is checked in object_new, but built-in types typically call tp_alloc directly, thus skipping the check. Eugene _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com