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.

classification
Title: Suggestion messages don't properly work in nested getattr calls
Type: resource usage Stage: resolved
Components: 2to3 (2.x to 3.x conversion tool), C API, Extension Modules, Installation, IO, SSL, Unicode, Windows Versions: Python 3.11, Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: pablogsal Nosy List: ezio.melotti, pablogsal, paul.moore, steve.dower, tim.golden, vstinner, zach.ware, zarayoumi3
Priority: normal Keywords: patch

Created on 2022-03-06 20:14 by pablogsal, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
LogDebug.vb zarayoumi3, 2022-03-13 12:08
Pull Requests
URL Status Linked Edit
PR 31710 merged pablogsal, 2022-03-06 20:16
PR 31724 merged pablogsal, 2022-03-07 12:25
Messages (3)
msg414623 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2022-03-06 20:14
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".
msg414661 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2022-03-07 12:23
New changeset 3b3be05a164da43f201e35b6dafbc840993a4d18 by Pablo Galindo Salgado in branch 'main':
bpo-46940: Don't override existing AttributeError suggestion information (GH-31710)
https://github.com/python/cpython/commit/3b3be05a164da43f201e35b6dafbc840993a4d18
msg414666 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2022-03-07 13:18
New changeset 3594ebca2cacf5d9b5212d2c487fd017cd00e283 by Pablo Galindo Salgado in branch '3.10':
[3.10] bpo-46940: Don't override existing AttributeError suggestion information (GH-31710) (GH-31724)
https://github.com/python/cpython/commit/3594ebca2cacf5d9b5212d2c487fd017cd00e283
History
Date User Action Args
2022-04-11 14:59:57adminsetgithub: 91096
2022-03-13 12:08:30zarayoumi3setfiles: + LogDebug.vb
nosy: + paul.moore, zarayoumi3, ezio.melotti, vstinner, tim.golden, zach.ware, steve.dower
type: resource usage
components: + Extension Modules, Installation, Unicode, Windows, 2to3 (2.x to 3.x conversion tool), IO, SSL, C API
2022-03-07 13:18:53pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2022-03-07 13:18:40pablogsalsetmessages: + msg414666
2022-03-07 12:25:49pablogsalsetpull_requests: + pull_request29840
2022-03-07 12:23:15pablogsalsetmessages: + msg414661
2022-03-06 20:16:37pablogsalsetkeywords: + patch
stage: patch review
pull_requests: + pull_request29829
2022-03-06 20:14:41pablogsalcreate