Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion messages don't properly work in nested getattr calls #91096

Closed
pablogsal opened this issue Mar 6, 2022 · 4 comments
Closed

Suggestion messages don't properly work in nested getattr calls #91096

pablogsal opened this issue Mar 6, 2022 · 4 comments
Assignees
Labels

Comments

@pablogsal
Copy link
Member

BPO 46940
Nosy @pfmoore, @vstinner, @tjguk, @ezio-melotti, @zware, @zooba, @pablogsal
PRs
  • bpo-46940: Don't override existing AttributeError suggestion information #31710
  • [3.10] bpo-46940: Don't override existing AttributeError suggestion information (GH-31710) #31724
  • Files
  • LogDebug.vb
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/pablogsal'
    closed_at = <Date 2022-03-07.13:18:53.909>
    created_at = <Date 2022-03-06.20:14:41.195>
    labels = ['expert-2to3', '3.10', 'performance', 'extension-modules', 'expert-C-API', 'expert-unicode', 'expert-SSL', 'expert-installation', 'expert-IO', '3.11', 'OS-windows']
    title = "Suggestion messages don't properly work in nested getattr calls"
    updated_at = <Date 2022-03-13.12:08:30.739>
    user = 'https://github.com/pablogsal'

    bugs.python.org fields:

    activity = <Date 2022-03-13.12:08:30.739>
    actor = 'zarayoumi3'
    assignee = 'pablogsal'
    closed = True
    closed_date = <Date 2022-03-07.13:18:53.909>
    closer = 'pablogsal'
    components = ['Extension Modules', 'Installation', 'Unicode', 'Windows', '2to3 (2.x to 3.x conversion tool)', 'IO', 'SSL', 'C API']
    creation = <Date 2022-03-06.20:14:41.195>
    creator = 'pablogsal'
    dependencies = []
    files = ['50670']
    hgrepos = []
    issue_num = 46940
    keywords = ['patch']
    message_count = 3.0
    messages = ['414623', '414661', '414666']
    nosy_count = 8.0
    nosy_names = ['paul.moore', 'vstinner', 'tim.golden', 'ezio.melotti', 'zach.ware', 'steve.dower', 'pablogsal', 'zarayoumi3']
    pr_nums = ['31710', '31724']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'resource usage'
    url = 'https://bugs.python.org/issue46940'
    versions = ['Python 3.10', 'Python 3.11']

    @pablogsal
    Copy link
    Member Author

    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".

    @pablogsal pablogsal added 3.10 only security fixes 3.11 only security fixes labels Mar 6, 2022
    @pablogsal pablogsal self-assigned this Mar 6, 2022
    @pablogsal pablogsal added 3.10 only security fixes 3.11 only security fixes labels Mar 6, 2022
    @pablogsal pablogsal self-assigned this Mar 6, 2022
    @pablogsal
    Copy link
    Member Author

    New changeset 3b3be05 by Pablo Galindo Salgado in branch 'main':
    bpo-46940: Don't override existing AttributeError suggestion information (GH-31710)
    3b3be05

    @pablogsal
    Copy link
    Member Author

    New changeset 3594ebc by Pablo Galindo Salgado in branch '3.10':
    [3.10] bpo-46940: Don't override existing AttributeError suggestion information (GH-31710) (GH-31724)
    3594ebc

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @vrodou
    Copy link

    vrodou commented May 1, 2022

    #92100

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants