[issue31127] Abstract classes derived from built-in classes don't block instance creation
New submission from Kevin Shweh: The only check that prevents instantiating abstract classes is in object.__new__, but most built-in classes never actually call object.__new__. That means you can do stuff like import abc class Foo(list, metaclass=abc.ABCMeta): @abc.abstractmethod def abstract(self): pass Foo() and the Foo() call will silently succeed. Ideally, the Foo() call should fail. Other options include having the Foo class definition itself fail, or just making a note in the documentation describing the limitation. (As far as I can see, this is currently undocumented.) ---------- assignee: docs@python components: Documentation, Library (Lib) messages: 299810 nosy: Kevin Shweh, docs@python priority: normal severity: normal status: open title: Abstract classes derived from built-in classes don't block instance creation type: behavior versions: Python 2.7, Python 3.6 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue31127> _______________________________________
R. David Murray added the comment: This is a duplidate of issue 5996. It is not clear if we are going to treat it as a bug or a doc bug. ---------- nosy: +r.david.murray resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> abstract class instantiable when subclassing dict _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue31127> _______________________________________
participants (2)
-
Kevin Shweh
-
R. David Murray