René's URL Explorer Experiment


Title: Generate `AttributeError` messages from their context · Issue #153785 · python/cpython · GitHub

Open Graph Title: Generate `AttributeError` messages from their context · Issue #153785 · python/cpython

X Title: Generate `AttributeError` messages from their context · Issue #153785 · python/cpython

Description: Feature or enhancement Proposal: People very often raise AttributeError(name) (~40 occurrences in CPython repo) or raise AttributeError (bare, this is rarer), but when displaying the traceback this misses either the object targeted or bo...

Open Graph Description: Feature or enhancement Proposal: People very often raise AttributeError(name) (~40 occurrences in CPython repo) or raise AttributeError (bare, this is rarer), but when displaying the traceback this...

X Description: Feature or enhancement Proposal: People very often raise AttributeError(name) (~40 occurrences in CPython repo) or raise AttributeError (bare, this is rarer), but when displaying the traceback this...

Opengraph URL: https://github.com/python/cpython/issues/153785

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Generate `AttributeError` messages from their context","articleBody":"# Feature or enhancement\n\n### Proposal:\n\nPeople very often `raise AttributeError(name)` (~40 occurrences in CPython repo) or `raise AttributeError` (bare, this is rarer), but when displaying the traceback this misses either the object targeted or both the object and the attribute name.\n\nThat information is already there. `AttributeError.obj` and `AttributeError.name` is automatically set via `_PyObject_SetAttributeErrorContext` and now is only used to calculate attribute suggestions. Let's improve error messages with it too.\n\nConsider a few examples where the user could raise a bare `AttributeError` or `AttributeError(\"attr\")`, how we handle it (`-`), and how we *could* handle it (`+`):\n\n```py\nimport traceback\n\nclass Foo1:\n    def __getattr__(self, name):\n        raise AttributeError(name)\n\ntry:\n    Foo1().missing1\nexcept AttributeError as a:\n    print(f\"-{traceback.format_exc().splitlines()[-1]}\")\n    print(f\"+AttributeError: {a.obj} has no attribute {a.name!r}\\n\")\n\nclass Foo2:\n    def __getattr__(self, name):\n        raise AttributeError\n\ntry:\n    Foo2().missing2\nexcept AttributeError as a:\n    print(f\"-{traceback.format_exc().splitlines()[-1]}\")\n    print(f\"+AttributeError: {a.obj} has no attribute {a.name!r}\\n\")\n\nimport mod1  # def __getattr__(name): raise AttributeError(name)\ntry:\n    mod1.missing3\nexcept AttributeError as a:\n    print(f\"-{traceback.format_exc().splitlines()[-1]}\")\n    print(f\"+AttributeError: {a.obj} has no attribute {a.name!r}\\n\")\n\nimport mod2  # def __getattr__(name): raise AttributeError\ntry:\n    mod2.missing4\nexcept AttributeError as a:\n    print(f\"-{traceback.format_exc().splitlines()[-1]}\")\n    print(f\"+AttributeError: {a.obj} has no attribute {a.name!r}\\n\")\n```\n\n```diff\n-AttributeError: missing1\n+AttributeError: \u003c__main__.Foo1 object at 0x109f2c8a0> has no attribute 'missing1'\n\n-AttributeError\n+AttributeError: \u003c__main__.Foo2 object at 0x109f2c8a0> has no attribute 'missing2'\n\n-AttributeError: missing3\n+AttributeError: \u003cmodule 'mod1' from './Python/cpython/mod1.py'> has no attribute 'missing3'\n\n-AttributeError\n+AttributeError: \u003cmodule 'mod2' from './Python/cpython/mod2.py'> has no attribute 'missing4'\n```\n\nIf we generate messages from collected context, we'll also fix some edge cases in the stdlib and snake knows where else. Consider this `functools.singledispatchmethod` edge case:\n\n```py\nfrom functools import singledispatchmethod\n \nclass C:\n    @singledispatchmethod\n    def sdm(self, a):\n        pass\n        \nC().sdm.__code__\n```\n\nwhich currently fails with `-` but could be `+`:\n\n```diff\n-AttributeError: . Did you mean: '__call__'?\n+AttributeError: '_singledispatchmethod_get' object has no attribute '__code__'. Did you mean: '__call__'?\n```\n\n\n### Has this already been discussed elsewhere?\n\nThis is a minor feature, which does not need previous discussion elsewhere\n\n### Links to previous discussion of this feature:\n\n_No response_\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-153786\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/johnslavik","@type":"Person","name":"johnslavik"},"datePublished":"2026-07-15T23:40:10Z","url":"https://github.com/python/cpython/issues/153785"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:8695d20e-253c-b878-4ca6-c6c948740624
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC4B8:FC5BE:381956D:4A7E2E6:6B0211E9
html-safe-noncedc6237e60d54e56b9b1b8d20a83691748a79438c5fa15044180b35f881add85a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNEI4OkZDNUJFOjM4MTk1NkQ6NEE3RTJFNjo2QjAyMTFFOSIsInZpc2l0b3JfaWQiOiIzNjkxMzQzMDgwNjYyODk3MTI5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac833512fd175609c20bf63697d8e03efc1881656da107318aa47d467ca2b42fab
hovercard-subject-tagissue:4897204284
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/153785/issue_layout
twitter:imagehttps://opengraph.githubassets.com/19c8e63aa5b561539e50f0ccff6d899293bec9294124b0ea646b3f4655586f46/python/cpython/issues/153785
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/19c8e63aa5b561539e50f0ccff6d899293bec9294124b0ea646b3f4655586f46/python/cpython/issues/153785
og:image:altFeature or enhancement Proposal: People very often raise AttributeError(name) (~40 occurrences in CPython repo) or raise AttributeError (bare, this is rarer), but when displaying the traceback this...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamejohnslavik
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/153785#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F153785
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F153785
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/153785
Reloadhttps://github.com/python/cpython/issues/153785
Reloadhttps://github.com/python/cpython/issues/153785
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/153785
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/153785
Generate AttributeError messages from their contexthttps://github.com/python/cpython/issues/153785#top
https://github.com/johnslavik
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
https://github.com/johnslavik
johnslavikhttps://github.com/johnslavik
on Jul 15, 2026https://github.com/python/cpython/issues/153785#issue-4897204284
gh-153785: Generate AttributeError messages from context #153786https://github.com/python/cpython/pull/153786
johnslavikhttps://github.com/johnslavik
on Jul 15, 2026https://github.com/python/cpython/issues/153785#event-28042256989
johnslavikhttps://github.com/johnslavik
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
on Jul 15, 2026https://github.com/python/cpython/issues/153785#event-28042257363
https://github.com/jonathandung
jonathandunghttps://github.com/jonathandung
on Jul 16, 2026https://github.com/python/cpython/issues/153785#issuecomment-4987296431
johnslavikhttps://github.com/johnslavik
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
on Jul 16, 2026https://github.com/python/cpython/issues/153785#event-28061902260
vstinnerhttps://github.com/vstinner
on Jul 24, 2026https://github.com/python/cpython/issues/153785#event-28435147543
gh-153785: Generate `AttributeError` messages from context (#153786)https://github.com/python/cpython/commit/ae72d0c92bf57448e256cdf8cfac7d4fd345b1a4
gh-153785https://github.com/python/cpython/issues/153785
#153786https://github.com/python/cpython/pull/153786
ae72d0chttps://github.com/python/cpython/commit/ae72d0c92bf57448e256cdf8cfac7d4fd345b1a4
https://github.com/johnslavik
johnslavikhttps://github.com/johnslavik
on Jul 24, 2026https://github.com/python/cpython/issues/153785#issuecomment-5069824119
johnslavikhttps://github.com/johnslavik
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jul 24, 2026https://github.com/python/cpython/issues/153785#event-28435583975
mbeijenhttps://github.com/mbeijen
on Aug 14, 2026https://github.com/python/cpython/issues/153785#event-29455488200
pythongh-153785: Generate `AttributeError` messages from context (pyt…https://github.com/mbeijen/cpython/commit/9eecaa8122bd74fcbfca603f8ff1d585a9731170
pythongh-153785https://github.com/python/cpython/issues/153785
pyt…https://github.com/python/cpython/pull/153786
9eecaa8https://github.com/mbeijen/cpython/commit/9eecaa8122bd74fcbfca603f8ff1d585a9731170
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/153785
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/153785
johnslavikhttps://github.com/johnslavik
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
type-featureA feature request or enhancementhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-feature%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.