Title: Nested AttributeError improved messages don't work with properties · Issue #146171 · python/cpython · GitHub
Open Graph Title: Nested AttributeError improved messages don't work with properties · Issue #146171 · python/cpython
X Title: Nested AttributeError improved messages don't work with properties · Issue #146171 · python/cpython
Description: The Python 3.15 improved error message for nested attribute access doesn't seem to work on properties. Rationale Take the example from the What's new in Python 3.15 docs: from dataclasses import dataclass @dataclass class Circle: radius:...
Open Graph Description: The Python 3.15 improved error message for nested attribute access doesn't seem to work on properties. Rationale Take the example from the What's new in Python 3.15 docs: from dataclasses import da...
X Description: The Python 3.15 improved error message for nested attribute access doesn't seem to work on properties. Rationale Take the example from the What's new in Python 3.15 docs: from dataclasses i...
Opengraph URL: https://github.com/python/cpython/issues/146171
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Nested AttributeError improved messages don't work with properties","articleBody":"The Python 3.15 improved error message for nested attribute access doesn't seem to work on properties.\n\n### Rationale\n\nTake the example from the [What's new in Python 3.15](https://docs.python.org/3.15/whatsnew/3.15.html#whatsnew315-improved-error-messages) docs:\n\n```py\nfrom dataclasses import dataclass\n\n@dataclass\nclass Circle:\n radius: float\n\n @property\n def area(self) -\u003e float:\n return pi * self.radius**2\n\nclass Container:\n def __init__(self, inner: Circle) -\u003e None:\n self.inner = inner\n\ncircle = Circle(radius=4.0)\ncontainer = Container(circle)\nprint(container.area)\n```\n\nRunning it with the CPython main branch or Python 3.15.0a1 through Python 3.15.0a7 (with uv) produces the following error:\n\n```py\nTraceback (most recent call last):\n File \"/Users/rodrigogs/Documents/cpython/../tmp/circle.py\", line 17, in \u003cmodule\u003e\n print(container.area)\n ^^^^^^^^^^^^^^\nAttributeError: 'Container' object has no attribute 'area'\n```\n\nIf you remove `@property` or if you try accessing `container.radius` instead, you get the respective improved messages:\n\n```py\n# After removing `@property` from `area`:\nTraceback (most recent call last):\n File \"/Users/rodrigogs/Documents/cpython/../tmp/circle_no_prop.py\", line 16, in \u003cmodule\u003e\n print(container.area)\n ^^^^^^^^^^^^^^\nAttributeError: 'Container' object has no attribute 'area'. Did you mean: 'inner.area'?\n\n# ---\n\n# Accessing `radius` instead of the property `area`:\nTraceback (most recent call last):\n File \"/Users/rodrigogs/Documents/cpython/../tmp/circle_radius.py\", line 17, in \u003cmodule\u003e\n print(container.radius)\n ^^^^^^^^^^^^^^^^\nAttributeError: 'Container' object has no attribute 'radius'. Did you mean: 'inner.radius'?\n```\n\n### Helper scripts for easier testing\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003ecircle.py\u003c/code\u003e — original example that doesn't work\u003c/summary\u003e\n\n```py\nfrom dataclasses import dataclass\n\n@dataclass\nclass Circle:\n radius: float\n\n @property\n def area(self) -\u003e float:\n return pi * self.radius**2\n\nclass Container:\n def __init__(self, inner: Circle) -\u003e None:\n self.inner = inner\n\ncircle = Circle(radius=4.0)\ncontainer = Container(circle)\nprint(container.area)\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003ecircle_radius.py\u003c/code\u003e — accessing radius works\u003c/summary\u003e\n\n```py\nfrom dataclasses import dataclass\n\n@dataclass\nclass Circle:\n radius: float\n\n @property\n def area(self) -\u003e float:\n return pi * self.radius**2\n\nclass Container:\n def __init__(self, inner: Circle) -\u003e None:\n self.inner = inner\n\ncircle = Circle(radius=4.0)\ncontainer = Container(circle)\nprint(container.radius)\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ccode\u003ecircle_no_prop.py\u003c/code\u003e — removing the property works\u003c/summary\u003e\n\n```py\nfrom dataclasses import dataclass\n\n@dataclass\nclass Circle:\n radius: float\n\n # @property\n def area(self) -\u003e float:\n return pi * self.radius**2\n\nclass Container:\n def __init__(self, inner: Circle) -\u003e None:\n self.inner = inner\n\ncircle = Circle(radius=4.0)\ncontainer = Container(circle)\nprint(container.area)\n```\n\n\u003c/details\u003e\n\n### CPython versions tested on:\n\n3.15, CPython main branch\n\n### Operating systems tested on:\n\nmacOS\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-146188\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/rodrigogiraoserrao","@type":"Person","name":"rodrigogiraoserrao"},"datePublished":"2026-03-19T14:28:37.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/146171/cpython/issues/146171"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:395f1846-757d-4ec6-e728-703c20ec837c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A284:1C9E58:5C05FA:7EFC7E:6A512024 |
| html-safe-nonce | fe695f48d5a4e816d7a176384fb285a8855ddcc85aa07b0df07de733c33042c5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMjg0OjFDOUU1ODo1QzA1RkE6N0VGQzdFOjZBNTEyMDI0IiwidmlzaXRvcl9pZCI6IjUxODA0MzI4MTc5NzczNjg2MTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0bdb232306cedfa029dcd28a23ee5bcc635f6697629a5a8ce6eff6d202240889 |
| hovercard-subject-tag | issue:4102104363 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/146171/issue_layout |
| twitter:image | https://opengraph.githubassets.com/eca2e3b0d2090d5359aa172d904709d0881c22837ce42cf6c32622adb22d17f0/python/cpython/issues/146171 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/eca2e3b0d2090d5359aa172d904709d0881c22837ce42cf6c32622adb22d17f0/python/cpython/issues/146171 |
| og:image:alt | The Python 3.15 improved error message for nested attribute access doesn't seem to work on properties. Rationale Take the example from the What's new in Python 3.15 docs: from dataclasses import da... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rodrigogiraoserrao |
| hostname | github.com |
| expected-hostname | github.com |
| None | 689b683944b0d7f015d0e776452c970832fa81b82dc15284469b556ecced715b |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 942b51ed3bd5feee3d5e2719f890a5fe286edbbb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width