[New-bugs-announce] [issue24235] ABCs don't fail metaclass instantiation
Devin Jeanpierre
report at bugs.python.org
Mon May 18 23:48:56 CEST 2015
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 <report at bugs.python.org>
<http://bugs.python.org/issue24235>
_______________________________________
More information about the New-bugs-announce
mailing list