René's URL Explorer Experiment


Title: Store SyntaxError members in struct fields instead of the instance dict by devyubin · Pull Request #8348 · RustPython/RustPython · GitHub

Open Graph Title: Store SyntaxError members in struct fields instead of the instance dict by devyubin · Pull Request #8348 · RustPython/RustPython

X Title: Store SyntaxError members in struct fields instead of the instance dict by devyubin · Pull Request #8348 · RustPython/RustPython

Description: Part of #8345 This PR follows our AI policy Summary SyntaxError's members were stored as None class-attribute placeholders plus per-instance __dict__ entries, so SyntaxError('m').__dict__ was non-empty ({'print_file_and_line': None}, plus filename/lineno/offset/text for the (msg, tuple) form) unlike CPython, and they weren't backed by descriptors. They're now struct fields on PySyntaxError (#[repr(C)] + base field, the same approach as SystemExit in #8282 and StopIteration in #8301), exposed via #[pygetset] — writable, deletable, independent from args, with an empty __dict__ as in CPython. IndentationError, TabError, and _IncompleteInputError inherit the fields. Re-initialization now resets end_lineno/end_offset, so a 4-element location tuple after a 6-element one no longer keeps stale values (matches CPython's gh-146250 fix): e = SyntaxError("msg", ("file.py", 1, 2, "txt", 2, 3)) e.__init__("new", ("new.py", 4, 5, "t")) print(e.end_lineno, e.end_offset) # before: 2 3 after: None None (matches CPython) new_exception is also routed through the real constructor for exception types that carry additional payload (now including SyntaxError), instead of building a base-sized PyBaseException. Without this, the compile-error path (new_exception_msg(syntax_error, …), ~15 call sites) would allocate a wrong-sized payload — a debug-assert panic, and out-of-bounds reads in release. Test plan Verified against CPython 3.14.6: msg/filename/lineno/offset/text/end_lineno/end_offset for SyntaxError(), the 4-tuple, and the 6-tuple forms; write/delete; re-init reset; empty __dict__; IndentationError/TabError inheritance; and the compile-error path (compile("1 +", ...) renders the caret and sets lineno/msg). test_exceptions: no regressions — test_syntax_error_memory_leak now passes; the single test_badisinstance failure is pre-existing on main (an unrelated empty-message RecursionError). test_syntax / test_compile: pass. cargo fmt / cargo clippy: clean (no new warnings). Unmarks test_exceptions's test_syntax_error_memory_leak (removes its @expectedFailure) — it now passes. Notes: Like StopIteration.value in #8301, the members are getset_descriptors rather than CPython's member_descriptors; both are data descriptors and behave the same for get/set/delete. msg is initialized in the constructor (not only __init__) so TabError still renders its message. TabError's __init__ slot is not reached during construction — a pre-existing limitation for two-level exception subclasses — so its location members (lineno/offset/…) are not populated from a direct TabError(msg, tuple) call; the compile path sets them via attribute assignment, so raised TabErrors are unaffected. Fixing that inheritance is out of scope here. Assisted-by: Claude Code:claude-fable-5 Summary by CodeRabbit Bug Fixes Improved SyntaxError handling for message, filename, line number, offset, source text, and end-position details. Added stricter validation for how location information is provided, including correct handling of supported shapes and end-position constraints. Improved exception creation compatibility when exception types use different internal payload layouts.

Open Graph Description: Part of #8345 This PR follows our AI policy Summary SyntaxError's members were stored as None class-attribute placeholders plus per-instance __dict__ entries, so SyntaxError('m').__d...

X Description: Part of #8345 This PR follows our AI policy Summary SyntaxError's members were stored as None class-attribute placeholders plus per-instance __dict__ entries, so SyntaxError('m&a...

Opengraph URL: https://github.com/RustPython/RustPython/pull/8348

X: @github

direct link

Domain: github.com

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/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:3ad49c48-d9d4-e98f-a184-1d6a069bef93
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idED0E:2F9718:30B5293:4151CE4:6B01FA0A
html-safe-nonce72d28922f3b676683f1ffcd83e1506a4ba48d8bcf761241c5bae1551b518d623
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFRDBFOjJGOTcxODozMEI1MjkzOjQxNTFDRTQ6NkIwMUZBMEEiLCJ2aXNpdG9yX2lkIjoiNTcwNjUxMjk1NDM0Nzk5NjI2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac0e4f42fdd3774380f05ce9ce6089bcf2cf8bc8552ffdc06586cfb82dda58f4ab
hovercard-subject-tagpull_request:4108404848
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/RustPython/RustPython/pull/8348/files
twitter:imagehttps://avatars.githubusercontent.com/u/80163835?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/80163835?s=400&v=4
og:image:altPart of #8345 This PR follows our AI policy Summary SyntaxError's members were stored as None class-attribute placeholders plus per-instance __dict__ entries, so SyntaxError('m').__d...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git
octolytics-dimension-user_id39710557
octolytics-dimension-user_loginRustPython
octolytics-dimension-repository_id135201145
octolytics-dimension-repository_nwoRustPython/RustPython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id135201145
octolytics-dimension-repository_network_root_nwoRustPython/RustPython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
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

Links:

Skip to contenthttps://github.com/RustPython/RustPython/pull/8348/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F8348%2Ffiles
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%2FRustPython%2FRustPython%2Fpull%2F8348%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=RustPython%2FRustPython
Reloadhttps://github.com/RustPython/RustPython/pull/8348/files
Reloadhttps://github.com/RustPython/RustPython/pull/8348/files
Reloadhttps://github.com/RustPython/RustPython/pull/8348/files
RustPythonhttps://github.com/RustPython
RustPythonhttps://github.com/RustPython/RustPython
Codehttps://github.com/RustPython/RustPython
Issues195 (195)https://github.com/RustPython/RustPython/issues
Pull requests133 (133)https://github.com/RustPython/RustPython/pulls
Discussionshttps://github.com/RustPython/RustPython/discussions
Actionshttps://github.com/RustPython/RustPython/actions
Projectshttps://github.com/RustPython/RustPython/projects
Wikihttps://github.com/RustPython/RustPython/wiki
Security and qualityhttps://github.com/RustPython/RustPython/security
Insightshttps://github.com/RustPython/RustPython/insights
Sign up for GitHub https://github.com/signup?return_to=%2FRustPython%2FRustPython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2FRustPython%2FRustPython%2Fissues%2Fnew%2Fchoose
devyubinhttps://github.com/devyubin
RustPython:mainhttps://github.com/RustPython/RustPython/tree/main
devyubin:syntax-error-struct-fieldshttps://github.com/devyubin/RustPython/tree/syntax-error-struct-fields
Conversation 14 https://github.com/RustPython/RustPython/pull/8348
Commits 3 https://github.com/RustPython/RustPython/pull/8348/commits
Checks 1 https://github.com/RustPython/RustPython/pull/8348/checks
Files changed https://github.com/RustPython/RustPython/pull/8348/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8348/files
Store SyntaxError members in struct fields instead of the instance dict https://github.com/RustPython/RustPython/pull/8348/files#top
Show all changes 3 commits https://github.com/RustPython/RustPython/pull/8348/files
343f9b3 Store SyntaxError members in struct fields instead of class attributes devyubin Jul 22, 2026 https://github.com/RustPython/RustPython/pull/8348/commits/343f9b3cf7b55950ead20c20c6352a94dc1a2345
2890281 Coerce SyntaxError location argument from any sequence devyubin Jul 23, 2026 https://github.com/RustPython/RustPython/pull/8348/commits/28902810c6070b29b27dacc65f1fea516ca0bcc1
153bdee Surface construction errors from new_exception instead of panicking devyubin Jul 24, 2026 https://github.com/RustPython/RustPython/pull/8348/commits/153bdee4d4cf0c214963afb648384382870891f6
Clear filters https://github.com/RustPython/RustPython/pull/8348/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8348/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8348/files
test_exceptions.py https://github.com/RustPython/RustPython/pull/8348/files#diff-3dbd58a46964dc5908595a1caa552fa3f5e2e46610679634ffc1064fd7cc3c8f
exceptions.rs https://github.com/RustPython/RustPython/pull/8348/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
vm_new.rs https://github.com/RustPython/RustPython/pull/8348/files#diff-0ed409205fe13b41775e66f6be22c13146e9aebf1000a069a10b39293f219a7b
Lib/test/test_exceptions.pyhttps://github.com/RustPython/RustPython/pull/8348/files#diff-3dbd58a46964dc5908595a1caa552fa3f5e2e46610679634ffc1064fd7cc3c8f
View file https://github.com/RustPython/RustPython/blob/153bdee4d4cf0c214963afb648384382870891f6/Lib/test/test_exceptions.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8348/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8348/files#diff-3dbd58a46964dc5908595a1caa552fa3f5e2e46610679634ffc1064fd7cc3c8f
https://github.com/RustPython/RustPython/pull/8348/files#diff-3dbd58a46964dc5908595a1caa552fa3f5e2e46610679634ffc1064fd7cc3c8f
crates/vm/src/exceptions.rshttps://github.com/RustPython/RustPython/pull/8348/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
View file https://github.com/RustPython/RustPython/blob/153bdee4d4cf0c214963afb648384382870891f6/crates/vm/src/exceptions.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8348/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8348/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
https://github.com/RustPython/RustPython/pull/8348/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
https://github.com/RustPython/RustPython/pull/8348/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
https://github.com/RustPython/RustPython/pull/8348/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
https://github.com/RustPython/RustPython/pull/8348/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
https://github.com/RustPython/RustPython/pull/8348/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
https://github.com/RustPython/RustPython/pull/8348/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
https://github.com/RustPython/RustPython/pull/8348/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
https://github.com/RustPython/RustPython/pull/8348/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
https://github.com/RustPython/RustPython/pull/8348/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
crates/vm/src/vm/vm_new.rshttps://github.com/RustPython/RustPython/pull/8348/files#diff-0ed409205fe13b41775e66f6be22c13146e9aebf1000a069a10b39293f219a7b
View file https://github.com/RustPython/RustPython/blob/153bdee4d4cf0c214963afb648384382870891f6/crates/vm/src/vm/vm_new.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8348/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8348/files#diff-0ed409205fe13b41775e66f6be22c13146e9aebf1000a069a10b39293f219a7b
https://github.com/RustPython/RustPython/pull/8348/files#diff-0ed409205fe13b41775e66f6be22c13146e9aebf1000a069a10b39293f219a7b
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8348/files
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.