[issue11610] Improving property to accept abstract methods

Darren Dale report at bugs.python.org
Sun May 15 01:42:33 CEST 2011


Darren Dale <dsdale24 at gmail.com> added the comment:

It just occurred to me, there is a potential problem with abstractproperty and the decorator syntax in my patch:

class Foo:

    @abstractproperty
    def p(self): pass
    # p is abstract, but has no abstract methods

    @p.setter
    def p(self, val): pass
    # p has no abstract properties, at this point it becomes an instance
    # of property, not abstractproperty

    @p.deleter
    @abstractmethod
    def p(self): pass
    # the deleter was tagged as abstract, but p was already a
    # regular property. There is no way to turn a regular
    # property into an abstractproperty, so the abstractedness
    # of the deleter is not respected.

Really, the ideal approach is the original one: provide the builtin property with an __isabstractmethod__ attribute, which is set to True if the property has any abstract methods, and False otherwise. (My C is probably too weak to modify the property builtin on my own).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11610>
_______________________________________


More information about the Python-bugs-list mailing list