René's URL Explorer Experiment


Title: Make SystemExit.code a writable attribute set at init by kangdora · Pull Request #8282 · RustPython/RustPython · GitHub

Open Graph Title: Make SystemExit.code a writable attribute set at init by kangdora · Pull Request #8282 · RustPython/RustPython

X Title: Make SystemExit.code a writable attribute set at init by kangdora · Pull Request #8282 · RustPython/RustPython

Description: Closes #8230 This PR follows our AI policy Summary SystemExit.code was a read-only getset recomputed from args on every access, so assigning or deleting exc.code raised AttributeError, and mutating exc.args after init changed code. It is now stored in a dedicated struct field (#[repr(C)] with a PyBaseException base, the same approach as OSError), set at __init__ time — writable, deletable, and independent from args after init, as in CPython. Keeping it in a field rather than the instance dict leaves SystemExit().__dict__ empty, matching CPython. A second commit updates handle_exit_exception to read the exit status from the code attribute like CPython's handle_system_exit; without it, reassigning exc.code would not affect the process exit status: import sys try: sys.exit(1) except SystemExit as e: e.code = 0 # before: AttributeError: ... not writable raise # process exit status — before: 1, after: 0 (matches CPython) Test plan Verified against CPython 3.14.6: attribute write/delete including the subclass repro from #8230, exit statuses for sys.exit() / sys.exit(3) / sys.exit('msg') / raise SystemExit(1, 2), and the re-raise case above. Lib/test/test_exceptions.py, Lib/test/test_sys.py: no regressions (the single test_badisinstance failure is pre-existing on main). test_threading / test_io thread-finalization cases pass (SystemExit is now created via the full constructor path, not new_exception). cargo fmt / cargo clippy: clean (no new warnings). Assisted-by: Claude Code:claude-fable-5 Summary by CodeRabbit Summary by CodeRabbit Bug Fixes Improved handling of SystemExit during termination, including finalization and non-main threads. Exit codes are now derived from SystemExit.code (with None mapping to 0; integer values supported). SystemExit output is generated more reliably from the code value when present. SystemExit created via exit (and internal thread exit) now follows the same raising path, ensuring consistent behavior with provided exit values.

Open Graph Description: Closes #8230 This PR follows our AI policy Summary SystemExit.code was a read-only getset recomputed from args on every access, so assigning or deleting exc.code raised AttributeError, and mutati...

X Description: Closes #8230 This PR follows our AI policy Summary SystemExit.code was a read-only getset recomputed from args on every access, so assigning or deleting exc.code raised AttributeError, and mutati...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:10878450-216d-b1d6-90f6-2152bc585fcc
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA822:969D6:1899973:21377EC:6A597BD1
html-safe-noncee687c6e62f0f476c0c16928eb5ab7071c629e62e78e069d4c402191df0727b81
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBODIyOjk2OUQ2OjE4OTk5NzM6MjEzNzdFQzo2QTU5N0JEMSIsInZpc2l0b3JfaWQiOiI3MzQ2MTE3NDA3ODAxOTY1NTIyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacf092ea059a23d8ee911309529bb2237a633129510242a7f5bb85b05c5d633287
hovercard-subject-tagpull_request:4048728696
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/8282/files
twitter:imagehttps://avatars.githubusercontent.com/u/182498567?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/182498567?s=400&v=4
og:image:altCloses #8230 This PR follows our AI policy Summary SystemExit.code was a read-only getset recomputed from args on every access, so assigning or deleting exc.code raised AttributeError, and mutati...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonea540949572872b935b393b36db38922db390ae71c859537d741b8f3eb7e545b5
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
release624bb50a7497aa346bef8cc3743af408a9ea10ca
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/RustPython/RustPython/pull/8282/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F8282%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
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
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://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
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F8282%2Ffiles
Sign up https://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/8282/files
Reloadhttps://github.com/RustPython/RustPython/pull/8282/files
Reloadhttps://github.com/RustPython/RustPython/pull/8282/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8282/files
RustPython https://github.com/RustPython
RustPythonhttps://github.com/RustPython/RustPython
Notifications https://github.com/login?return_to=%2FRustPython%2FRustPython
Fork 1.5k https://github.com/login?return_to=%2FRustPython%2FRustPython
Star 22.2k https://github.com/login?return_to=%2FRustPython%2FRustPython
Code https://github.com/RustPython/RustPython
Issues 287 https://github.com/RustPython/RustPython/issues
Pull requests 104 https://github.com/RustPython/RustPython/pulls
Discussions https://github.com/RustPython/RustPython/discussions
Actions https://github.com/RustPython/RustPython/actions
Projects https://github.com/RustPython/RustPython/projects
Models https://github.com/RustPython/RustPython/models
Wiki https://github.com/RustPython/RustPython/wiki
Security and quality 0 https://github.com/RustPython/RustPython/security
Insights https://github.com/RustPython/RustPython/pulse
Code https://github.com/RustPython/RustPython
Issues https://github.com/RustPython/RustPython/issues
Pull requests https://github.com/RustPython/RustPython/pulls
Discussions https://github.com/RustPython/RustPython/discussions
Actions https://github.com/RustPython/RustPython/actions
Projects https://github.com/RustPython/RustPython/projects
Models https://github.com/RustPython/RustPython/models
Wiki https://github.com/RustPython/RustPython/wiki
Security and quality https://github.com/RustPython/RustPython/security
Insights https://github.com/RustPython/RustPython/pulse
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
youknowonehttps://github.com/youknowone
RustPython:mainhttps://github.com/RustPython/RustPython/tree/main
kangdora:fix-systemexit-codehttps://github.com/kangdora/RustPython/tree/fix-systemexit-code
Conversation 3 https://github.com/RustPython/RustPython/pull/8282
Commits 5 https://github.com/RustPython/RustPython/pull/8282/commits
Checks 25 https://github.com/RustPython/RustPython/pull/8282/checks
Files changed 4 https://github.com/RustPython/RustPython/pull/8282/files
Make SystemExit.code a writable attribute set at init https://github.com/RustPython/RustPython/pull/8282/files#top
Show all changes 5 commits https://github.com/RustPython/RustPython/pull/8282/files
7ed3e04 Make SystemExit.code a writable attribute set at init kangdora Jul 13, 2026 https://github.com/RustPython/RustPython/pull/8282/commits/7ed3e0415d923d1ad8d198b3561afa79fa0adb00
58652ba Read exit status from SystemExit.code in handle_exit_exception kangdora Jul 13, 2026 https://github.com/RustPython/RustPython/pull/8282/commits/58652babfafbda3d3c5104d827113aa6109711f3
4d6ac3f Merge branch 'RustPython:main' into fix-systemexit-code kangdora Jul 13, 2026 https://github.com/RustPython/RustPython/pull/8282/commits/4d6ac3f837b5b8f9339a7a6d5512961b45a03414
fb8f7b1 Store SystemExit.code in a struct field instead of the instance dict kangdora Jul 14, 2026 https://github.com/RustPython/RustPython/pull/8282/commits/fb8f7b197d6b19683610fa21d96534ee4f90545b
9d3d2de Create SystemExit through the full constructor path kangdora Jul 14, 2026 https://github.com/RustPython/RustPython/pull/8282/commits/9d3d2de8c373b4b87fec21d9a45ea138c8bc60ff
Clear filters https://github.com/RustPython/RustPython/pull/8282/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8282/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8282/files
exceptions.rs https://github.com/RustPython/RustPython/pull/8282/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
_thread.rs https://github.com/RustPython/RustPython/pull/8282/files#diff-0006354bf5c0b6258c334f326e9c125eae4c55e8dae289a4990e76d7503885cb
builtins.rs https://github.com/RustPython/RustPython/pull/8282/files#diff-ce8bd80bb61ce870dbf04415913693df814ebda260d3fc784b689a657e694ca3
mod.rs https://github.com/RustPython/RustPython/pull/8282/files#diff-fe30ecf7c6b462e46e0874a55a05ea0edba83cefad5ac7a86e7137fa8f86ba74
crates/vm/src/exceptions.rshttps://github.com/RustPython/RustPython/pull/8282/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
View file https://github.com/kangdora/RustPython/blob/9d3d2de8c373b4b87fec21d9a45ea138c8bc60ff/crates/vm/src/exceptions.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8282/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8282/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
https://github.com/RustPython/RustPython/pull/8282/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
https://github.com/RustPython/RustPython/pull/8282/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
https://github.com/RustPython/RustPython/pull/8282/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
https://github.com/RustPython/RustPython/pull/8282/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
https://github.com/RustPython/RustPython/pull/8282/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
https://github.com/RustPython/RustPython/pull/8282/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
https://github.com/RustPython/RustPython/pull/8282/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
crates/vm/src/stdlib/_thread.rshttps://github.com/RustPython/RustPython/pull/8282/files#diff-0006354bf5c0b6258c334f326e9c125eae4c55e8dae289a4990e76d7503885cb
View file https://github.com/kangdora/RustPython/blob/9d3d2de8c373b4b87fec21d9a45ea138c8bc60ff/crates/vm/src/stdlib/_thread.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8282/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8282/files#diff-0006354bf5c0b6258c334f326e9c125eae4c55e8dae289a4990e76d7503885cb
https://github.com/RustPython/RustPython/pull/8282/files#diff-0006354bf5c0b6258c334f326e9c125eae4c55e8dae289a4990e76d7503885cb
crates/vm/src/stdlib/builtins.rshttps://github.com/RustPython/RustPython/pull/8282/files#diff-ce8bd80bb61ce870dbf04415913693df814ebda260d3fc784b689a657e694ca3
View file https://github.com/kangdora/RustPython/blob/9d3d2de8c373b4b87fec21d9a45ea138c8bc60ff/crates/vm/src/stdlib/builtins.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8282/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8282/files#diff-ce8bd80bb61ce870dbf04415913693df814ebda260d3fc784b689a657e694ca3
https://github.com/RustPython/RustPython/pull/8282/files#diff-ce8bd80bb61ce870dbf04415913693df814ebda260d3fc784b689a657e694ca3
crates/vm/src/vm/mod.rshttps://github.com/RustPython/RustPython/pull/8282/files#diff-fe30ecf7c6b462e46e0874a55a05ea0edba83cefad5ac7a86e7137fa8f86ba74
View file https://github.com/kangdora/RustPython/blob/9d3d2de8c373b4b87fec21d9a45ea138c8bc60ff/crates/vm/src/vm/mod.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/8282/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/8282/files#diff-fe30ecf7c6b462e46e0874a55a05ea0edba83cefad5ac7a86e7137fa8f86ba74
https://github.com/RustPython/RustPython/pull/8282/files#diff-fe30ecf7c6b462e46e0874a55a05ea0edba83cefad5ac7a86e7137fa8f86ba74
https://github.com/RustPython/RustPython/pull/8282/files#diff-fe30ecf7c6b462e46e0874a55a05ea0edba83cefad5ac7a86e7137fa8f86ba74
https://github.com/RustPython/RustPython/pull/8282/files#diff-fe30ecf7c6b462e46e0874a55a05ea0edba83cefad5ac7a86e7137fa8f86ba74
Please reload this pagehttps://github.com/RustPython/RustPython/pull/8282/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.