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 pablogsal
Recipients pablogsal
Date 2022-03-06.20:14:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1646597681.21.0.64157062994.issue46940@roundup.psfhosted.org>
In-reply-to
Content
Consider this code:

class A:
    __slots__ = [
        "_color",
    ]

    color = None

    @property
    def color(self):
        return self._color


A().color


Executing this shows:

Traceback (most recent call last):
  File "/Users/pgalindo3/lel.py", line 21, in <module>
    A().color
  File "/Users/pgalindo3/lel.py", line 18, in color
    return self._color
AttributeError: 'A' object has no attribute '_color'. Did you mean: '_color'?

This is because the nested getattr call of "@property" overrides the metadata information in the exception object and it tries to produce an error message for the attribute "color" instead of "_color".
History
Date User Action Args
2022-03-06 20:14:41pablogsalsetrecipients: + pablogsal
2022-03-06 20:14:41pablogsalsetmessageid: <1646597681.21.0.64157062994.issue46940@roundup.psfhosted.org>
2022-03-06 20:14:41pablogsallinkissue46940 messages
2022-03-06 20:14:41pablogsalcreate