[New-bugs-announce] [issue5996] abstract class instantiable when subclassing dict
johannes raggam
report at bugs.python.org
Mon May 11 16:06:03 CEST 2009
New submission from johannes raggam <raggam-nl at adm.at>:
when declaring a abstract base class with an abstract property or method
and subclassing from dict, the class is instantiable (instanceable?).
>>> import abc
>>> class A(object):
... __metaclass__ = abc.ABCMeta
... @abc.abstractproperty
... def abstract(self): return True
...
>>> a = A()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Can't instantiate abstract class A with abstract methods abstract
>>>
>>> class A2(dict):
... __metaclass__ = abc.ABCMeta
... @abc.abstractproperty
... def abstract(self): return True
...
>>> a2 = A2()
>>>
although, when using the dict definition from __builtin__.pi directly,
the abc behaves like expected. but this may be a bug in the
c-implementation from dict.
platform:
Python 2.6.2 (r262:71600, Apr 25 2009, 21:56:41)
[GCC 4.3.2] on linux2
----------
components: Library (Lib)
messages: 87574
nosy: thet
severity: normal
status: open
title: abstract class instantiable when subclassing dict
type: behavior
versions: Python 2.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5996>
_______________________________________
More information about the New-bugs-announce
mailing list