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 dunric
Recipients dunric, eryksun, martin.panter
Date 2015-09-02.18:47:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1441219629.86.0.981038973422.issue24983@psf.upfronthosting.co.za>
In-reply-to
Content
This looks a bit inconsistent. See following version with "manual" getter definition:

class MyClass(object):
    def __init__(self, *args, **kwargs):
        # setting access to getter by attribute
        # without use of property decorator
        self.__dict__['myproperty'] = self._myproperty()

    def __getattr__(self, name):
        print('__getattr__ <<', name)
        raise AttributeError(name)
        return 'need know the question'

    def _myproperty(self):
        print(self.missing_attribute)
        return 42

my_inst = MyClass()
print(my_inst.myproperty)

# Produces (expected) output
__getattr__ << missing_attribute
Traceback (most recent call last):
  File "a.py", line 55, in <module>
    my_inst = MyClass()
  File "a.py", line 33, in __init__
    self.__dict__['myproperty'] = self._myproperty()
  File "a.py", line 48, in _myproperty
    print(self.missing_attribute)
  File "a.py", line 37, in __getattr__
    raise AttributeError(name)
AttributeError: missing_attribute


I'd expect the original version using property decorator would behave the same way. Possible issue in property class implementation ?
History
Date User Action Args
2015-09-02 18:47:09dunricsetrecipients: + dunric, martin.panter, eryksun
2015-09-02 18:47:09dunricsetmessageid: <1441219629.86.0.981038973422.issue24983@psf.upfronthosting.co.za>
2015-09-02 18:47:09dunriclinkissue24983 messages
2015-09-02 18:47:09dunriccreate