René's URL Explorer Experiment


Title: Align shutdown flush and unraisable reporting with CPython by youknowone · Pull Request #9810 · RustPython/RustPython · GitHub

Open Graph Title: Align shutdown flush and unraisable reporting with CPython by youknowone · Pull Request #9810 · RustPython/RustPython

X Title: Align shutdown flush and unraisable reporting with CPython by youknowone · Pull Request #9810 · RustPython/RustPython

Description: Close #9690 This carries the commits of #9690, rebased onto current main, plus two follow-up fixes found while reviewing it. Summary Align shutdown stream failures and unraisable exception reporting with CPython 3.15, using one fallible default writer for sys.__unraisablehook__ and the VM fallback. Read sys.stderr and sys.unraisablehook directly from the sys dict and keep the selected stream alive across callbacks. Format through traceback._print_exception_bltin(exc, file) with a native fallback, including the and cases. Keep the audit order, and call the user hook during finalization too. Flush stdout/stderr after exit callbacks and before module cleanup. A stdout failure is reported as Exception ignored while flushing sys.stdout; a stderr failure is counted without writing to the broken stream. Either one makes the exit status 120, even when a nonzero status was requested. At shutdown, buffered and text I/O locks wait at most one second (_enter_buffered_busy). If the wait fails, a fatal diagnostic is written to fd 2 without running Python code. input() keeps one process-wide terminal reader, so read-ahead lines are not lost between calls or threads. A reentrant read raises instead. Remove the test_cmd_line.test_stdout_flush_at_shutdown expected failure. Follow-ups added on top of #9690: __del__ failures pass no unraisable object, so the output is Exception ignored while calling deallocator : rather than repeating the function repr after the message. FileIO read, readall, write and close errors no longer carry filename; only open errors do. A failed stdout flush now prints OSError: [Errno 9] Bad file descriptor, without : ''. Validation These cases match CPython 3.15 output and exit status: shutdown flush failure, flush failure after sys.exit(3), user hook at shutdown, __del__ with failing repr/str, failing hook, None hook, deleted hook, broken sys.stderr, and an exception type without __module__. rustpython -m test test_cmd_line test_io.test_fileio test_io.test_general test_sys passes. test_daemon_threads_shutdown_* needs the walltime resource, so the lock-timeout path was skipped in this run. cargo clippy --workspace --all-targets --features threading ... -D warnings, cargo test -p rustpython-common --features threading, cargo test -p rustpython-host_env and extra_tests/snippets/stdlib_input_readline.py pass. AI assistance: the original commits were written with OpenAI Codex. Review, follow-up fixes and validation were done with Claude and Grok. 🤖 Generated with Claude Code Summary by CodeRabbit Bug Fixes Improved interactive input() behavior across terminal changes and redirected output. Nested input calls now fail with a clear runtime error instead of re-entering readline. Improved exception and unraisable-error output, including traceback formatting and fallback messages when formatting fails. Shutdown now flushes standard output and error after exit callbacks. Flush failures are reflected in the shutdown result. During interpreter shutdown, I/O locks wait briefly for other threads; reentrant access reports an error, while prolonged contention triggers a fatal diagnostic.

Open Graph Description: Close #9690 This carries the commits of #9690, rebased onto current main, plus two follow-up fixes found while reviewing it. Summary Align shutdown stream failures and unraisable exception reportin...

X Description: Close #9690 This carries the commits of #9690, rebased onto current main, plus two follow-up fixes found while reviewing it. Summary Align shutdown stream failures and unraisable exception reportin...

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

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:6d0c63d8-c0ce-2971-5530-1e7aec265e22
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idC982:158DF1:1635A4C:1D53BA7:6B01FE6C
html-safe-nonce7b568d50bdd43641640cdcaa37e707674a5b71e630180e46b0c03923ca6b4fa2
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOTgyOjE1OERGMToxNjM1QTRDOjFENTNCQTc6NkIwMUZFNkMiLCJ2aXNpdG9yX2lkIjoiNTAxNjEyNDQwNjM1NzAyODkyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac03e55c0ad950d723ae67bdacac472748a081902b1e2cf976f946bb123fb6e905
hovercard-subject-tagpull_request:5268391724
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/9810/files
twitter:imagehttps://avatars.githubusercontent.com/u/69878?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/69878?s=400&v=4
og:image:altClose #9690 This carries the commits of #9690, rebased onto current main, plus two follow-up fixes found while reviewing it. Summary Align shutdown stream failures and unraisable exception reportin...
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/9810/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fpull%2F9810%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%2F9810%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/9810/files
Reloadhttps://github.com/RustPython/RustPython/pull/9810/files
Reloadhttps://github.com/RustPython/RustPython/pull/9810/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
youknowonehttps://github.com/youknowone
RustPython:mainhttps://github.com/RustPython/RustPython/tree/main
youknowone:shutdown-unraisable-reporting-20261104https://github.com/youknowone/RustPython/tree/shutdown-unraisable-reporting-20261104
Conversation 6 https://github.com/RustPython/RustPython/pull/9810
Commits 10 https://github.com/RustPython/RustPython/pull/9810/commits
Checks 28 https://github.com/RustPython/RustPython/pull/9810/checks
Files changed https://github.com/RustPython/RustPython/pull/9810/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9810/files
Align shutdown flush and unraisable reporting with CPython https://github.com/RustPython/RustPython/pull/9810/files#top
Show all changes 10 commits https://github.com/RustPython/RustPython/pull/9810/files
8c6137f Align shutdown flush and unraisable reporting with CPython youknowdot Nov 4, 2026 https://github.com/RustPython/RustPython/pull/9810/commits/8c6137f978d7780e4ef192460e852b4695f10246
1395ec6 Fix shutdown CI locks and preserve input read-ahead youknowdot Nov 5, 2026 https://github.com/RustPython/RustPython/pull/9810/commits/1395ec6fde6514991263321fc26f3b68c6647e29
ce71742 Adapt unraisable fallback to current traceback writer codex Nov 7, 2026 https://github.com/RustPython/RustPython/pull/9810/commits/ce71742fac04f13f3fb590ca383d82ce9753471d
9b2749d Use core RefCell for retained input reader codex Nov 7, 2026 https://github.com/RustPython/RustPython/pull/9810/commits/9b2749d091e1992e233959be6d7e84cb4cf75c6d
c70cb65 Mark timed mutex tests with explicit test cfg codex Nov 7, 2026 https://github.com/RustPython/RustPython/pull/9810/commits/c70cb65925b4729d3c267074feffd03a3dd7f67c
059f39f Share interactive input read-ahead across threads codex Nov 7, 2026 https://github.com/RustPython/RustPython/pull/9810/commits/059f39f6d3ecdcec9dc7d1adf12d29033d6d8c07
290ca50 Exercise input from the result audit hook codex Nov 7, 2026 https://github.com/RustPython/RustPython/pull/9810/commits/290ca5018993f45ff47cbb5d6e79e50ffdaf8537
f0d1a17 Drain both terminals while testing input redirection codex Nov 8, 2026 https://github.com/RustPython/RustPython/pull/9810/commits/f0d1a1790f82faea7776aae8d7eddd8bbeebaa4f
f00fc6a Report __del__ failures without an unraisable object youknowone Nov 11, 2026 https://github.com/RustPython/RustPython/pull/9810/commits/f00fc6a8885519f00fc50bb5b0d4af3f621890ca
a0ee443 Raise FileIO read, write, and close errors without a filename youknowone Nov 11, 2026 https://github.com/RustPython/RustPython/pull/9810/commits/a0ee443e025e0c0ae5201292bc3dfa686726eb83
Clear filters https://github.com/RustPython/RustPython/pull/9810/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9810/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9810/files
test_cmd_line.py https://github.com/RustPython/RustPython/pull/9810/files#diff-128fff16ea63b541718887f5c714e0c1a357414fe1146b4893ef699e8853e3b0
thread_mutex.rs https://github.com/RustPython/RustPython/pull/9810/files#diff-037464c3c77d981a319a904278e36a8c9ee055ee4496400260052e725be0579b
readline.rs https://github.com/RustPython/RustPython/pull/9810/files#diff-96460472d349df3dc6f7eff5fb7c7cc5222399575726eb4e78c8d1e9e963acaf
exceptions.rs https://github.com/RustPython/RustPython/pull/9810/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
core.rs https://github.com/RustPython/RustPython/pull/9810/files#diff-29e5bc70b379859cc90757773e821848e53dff65ce99167408b6f547bc317196
_io.rs https://github.com/RustPython/RustPython/pull/9810/files#diff-90825edc73ec293e0ed3b2dbed7f0a492b1f8e51c25747326089a912267bdd3e
builtins.rs https://github.com/RustPython/RustPython/pull/9810/files#diff-ce8bd80bb61ce870dbf04415913693df814ebda260d3fc784b689a657e694ca3
sys.rs https://github.com/RustPython/RustPython/pull/9810/files#diff-e7f7c10b81f88d7af77af76257284e18e72ed9da63ff63675a9e9cb31c8d262d
interpreter.rs https://github.com/RustPython/RustPython/pull/9810/files#diff-2361f366cc46771907dbd3b09eb8b9c839e7f059710345f2265c1753862a1b20
mod.rs https://github.com/RustPython/RustPython/pull/9810/files#diff-fe30ecf7c6b462e46e0874a55a05ea0edba83cefad5ac7a86e7137fa8f86ba74
vm_object.rs https://github.com/RustPython/RustPython/pull/9810/files#diff-8d455749c67df5f6030ce84784d39256f31f0bec713e953d171a27fd300d1d27
stdlib_input_readline.py https://github.com/RustPython/RustPython/pull/9810/files#diff-abdb2e67e5d52e656c33dc926f5130084a2fedbf560ef6251604ffce79449b8a
Lib/test/test_cmd_line.pyhttps://github.com/RustPython/RustPython/pull/9810/files#diff-128fff16ea63b541718887f5c714e0c1a357414fe1146b4893ef699e8853e3b0
View file https://github.com/youknowone/RustPython/blob/a0ee443e025e0c0ae5201292bc3dfa686726eb83/Lib/test/test_cmd_line.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9810/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9810/files#diff-128fff16ea63b541718887f5c714e0c1a357414fe1146b4893ef699e8853e3b0
https://github.com/RustPython/RustPython/pull/9810/files#diff-128fff16ea63b541718887f5c714e0c1a357414fe1146b4893ef699e8853e3b0
crates/common/src/lock/thread_mutex.rshttps://github.com/RustPython/RustPython/pull/9810/files#diff-037464c3c77d981a319a904278e36a8c9ee055ee4496400260052e725be0579b
View file https://github.com/youknowone/RustPython/blob/a0ee443e025e0c0ae5201292bc3dfa686726eb83/crates/common/src/lock/thread_mutex.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9810/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9810/files#diff-037464c3c77d981a319a904278e36a8c9ee055ee4496400260052e725be0579b
https://github.com/RustPython/RustPython/pull/9810/files#diff-037464c3c77d981a319a904278e36a8c9ee055ee4496400260052e725be0579b
https://github.com/RustPython/RustPython/pull/9810/files#diff-037464c3c77d981a319a904278e36a8c9ee055ee4496400260052e725be0579b
coderabbitaihttps://github.com/apps/coderabbitai
Nov 11, 2026https://github.com/RustPython/RustPython/pull/9810/files#r4544430364
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9810/files
https://github.com/RustPython/RustPython/pull/9810/files#diff-037464c3c77d981a319a904278e36a8c9ee055ee4496400260052e725be0579b
https://github.com/RustPython/RustPython/pull/9810/files#diff-037464c3c77d981a319a904278e36a8c9ee055ee4496400260052e725be0579b
crates/host_env/src/readline.rshttps://github.com/RustPython/RustPython/pull/9810/files#diff-96460472d349df3dc6f7eff5fb7c7cc5222399575726eb4e78c8d1e9e963acaf
View file https://github.com/youknowone/RustPython/blob/a0ee443e025e0c0ae5201292bc3dfa686726eb83/crates/host_env/src/readline.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9810/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9810/files#diff-96460472d349df3dc6f7eff5fb7c7cc5222399575726eb4e78c8d1e9e963acaf
https://github.com/RustPython/RustPython/pull/9810/files#diff-96460472d349df3dc6f7eff5fb7c7cc5222399575726eb4e78c8d1e9e963acaf
https://github.com/RustPython/RustPython/pull/9810/files#diff-96460472d349df3dc6f7eff5fb7c7cc5222399575726eb4e78c8d1e9e963acaf
https://github.com/RustPython/RustPython/pull/9810/files#diff-96460472d349df3dc6f7eff5fb7c7cc5222399575726eb4e78c8d1e9e963acaf
crates/vm/src/exceptions.rshttps://github.com/RustPython/RustPython/pull/9810/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
View file https://github.com/youknowone/RustPython/blob/a0ee443e025e0c0ae5201292bc3dfa686726eb83/crates/vm/src/exceptions.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9810/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9810/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
https://github.com/RustPython/RustPython/pull/9810/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
https://github.com/RustPython/RustPython/pull/9810/files#diff-f527bc3e68302079a32d6da36816531e3e22dd31ff91ef0ff0f2688673712747
crates/vm/src/object/core.rshttps://github.com/RustPython/RustPython/pull/9810/files#diff-29e5bc70b379859cc90757773e821848e53dff65ce99167408b6f547bc317196
View file https://github.com/youknowone/RustPython/blob/a0ee443e025e0c0ae5201292bc3dfa686726eb83/crates/vm/src/object/core.rs
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/RustPython/RustPython/pull/9810/{{ revealButtonHref }}
https://github.com/RustPython/RustPython/pull/9810/files#diff-29e5bc70b379859cc90757773e821848e53dff65ce99167408b6f547bc317196
https://github.com/RustPython/RustPython/pull/9810/files#diff-29e5bc70b379859cc90757773e821848e53dff65ce99167408b6f547bc317196
https://github.com/RustPython/RustPython/pull/9810/files#diff-29e5bc70b379859cc90757773e821848e53dff65ce99167408b6f547bc317196
https://github.com/RustPython/RustPython/pull/9810/files#diff-29e5bc70b379859cc90757773e821848e53dff65ce99167408b6f547bc317196
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9810/files
Please reload this pagehttps://github.com/RustPython/RustPython/pull/9810/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.