Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Nested attribute lookup for improved error messages executes property code #145413

Open
Labels
stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error
@Hiumee

Description

@Hiumee

Bug report

Bug description:

The new error messages for nested attributes will execute descriptors/property code

Modified example from the change log. Gave the property a side effect (print)

fromdataclassesimportdataclassfrommathimportpi@dataclassclassCircle:radius:float@propertydefarea(self)->float:print("Property 'area' accessed")returnpi*self.radius**2classContainer:def__init__(self,inner:Circle)->None:self.inner=innercircle=Circle(radius=4.0)container=Container(circle)print(container.area)

Output

Property 'area' accessedTraceback (most recent call last):  File "<stdin>", line 1, in <module>    print(container.area)          ^^^^^^^^^^^^^^AttributeError: 'Container' object has no attribute 'area'. Did you mean '.inner.area' instead of '.area'?

Expected would be to not execute the code. This does not happen when theContainer class has a property suggested

PR incoming

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2026 Movatter.jp