New submission from Devin Jeanpierre: If a subclass has abstract methods, it fails to instantiate... unless it's a metaclass, and then it succeeds.
>>> import abc >>> class A(metaclass=abc.ABCMeta): ... @abc.abstractmethod ... def foo(self): pass ... >>> class B(A): pass ... >>> B() Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: Can't instantiate abstract class B with abstract methods foo >>> class C(A, type): pass ... >>> class c(metaclass=C): pass ... >>> C('', (), {}) <class '__main__.'> >>> ---------- components: Library (Lib) messages: 243540 nosy: Devin Jeanpierre priority: normal severity: normal status: open title: ABCs don't fail metaclass instantiation versions: Python 2.7, Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24235> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com