[New-bugs-announce] [issue46940] Suggestion messages don't properly work in nested getattr calls
Pablo Galindo Salgado
report at bugs.python.org
Sun Mar 6 15:14:41 EST 2022
New submission from Pablo Galindo Salgado <pablogsal at gmail.com>:
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".
----------
assignee: pablogsal
messages: 414623
nosy: pablogsal
priority: normal
severity: normal
status: open
title: Suggestion messages don't properly work in nested getattr calls
versions: Python 3.10, Python 3.11
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46940>
_______________________________________
More information about the New-bugs-announce
mailing list