This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Devin Jeanpierre
Recipients Devin Jeanpierre
Date 2015-05-18.21:48:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1431985736.79.0.831498694265.issue24235@psf.upfronthosting.co.za>
In-reply-to
Content
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__.'>
>>>
History
Date User Action Args
2015-05-18 21:48:56Devin Jeanpierresetrecipients: + Devin Jeanpierre
2015-05-18 21:48:56Devin Jeanpierresetmessageid: <1431985736.79.0.831498694265.issue24235@psf.upfronthosting.co.za>
2015-05-18 21:48:56Devin Jeanpierrelinkissue24235 messages
2015-05-18 21:48:56Devin Jeanpierrecreate