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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4