Message414623
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". |
|
Date |
User |
Action |
Args |
2022-03-06 20:14:41 | pablogsal | set | recipients:
+ pablogsal |
2022-03-06 20:14:41 | pablogsal | set | messageid: <1646597681.21.0.64157062994.issue46940@roundup.psfhosted.org> |
2022-03-06 20:14:41 | pablogsal | link | issue46940 messages |
2022-03-06 20:14:41 | pablogsal | create | |
|