⚡ Sangsakala Proxy 🏠 Home
Skip to content

Align shutdown flush and unraisable reporting with CPython - #9690

Draft
youknowone wants to merge 1 commit into
RustPython:mainfrom
youknowdot:shutdown-unraisable-reporting-20261104
Draft

youknowone wants to merge 1 commit into
RustPython:mainfrom
youknowdot:shutdown-unraisable-reporting-20261104

Conversation

@youknowone

Copy link
Copy Markdown
Member

Summary

Align shutdown stream failures and unraisable exception reporting with CPython 3.15, using one shared fallible writer instead of separate default-hook and VM fallback implementations.

  • Retain the selected stderr object through callbacks, preserve Python strings, and use the existing traceback formatter with that explicit file. Keep a native fallback when the formatter is unavailable, including CPython's repr/str failure handling.
  • Read standard streams and the unraisable hook directly from the sys dictionary. Preserve audit ordering and invoke an available user hook during finalization.
  • Flush after exit callbacks and before module cleanup. Report stdout failures with the shutdown-specific message, count stderr failures without reporting through the broken stream, and return status 120 for either stream failure even after a nonzero requested exit status.

The remaining test_cmd_line.test_stdout_flush_at_shutdown expected failure motivates this group. Its marker is unchanged; this PR does not claim the test passes or full shutdown parity. No Lib files or tests are edited, and no thread, GC, or signal algorithm is replaced.

Reference

Compared against CPython 3.15 commit d220409a13b77de7a6c30abe16ea90db01528edc:

Validation

  • Independent source review, rustfmt, and git diff --check passed.
  • cargo clippy --locked --offline -p rustpython-vm --all-targets --features threading -- -D warnings passed.
  • cargo clippy --locked --offline -p rustpython-vm --all-targets passed with the existing no-thread Arc<BufferWrite> warning at _ctypes/base.rs:2246.
  • Normal commit hooks passed.
  • RustPython execution, runtime tests, and workspace-wide tests have not been run because the runtime safety guard has not been verified. This remains a draft for guarded runtime validation, including shutdown failures, hook callbacks, traceback import failure, and broken/custom streams.

AI assistance: OpenAI Codex (dot) assisted with implementation, CPython source comparison, and review. Model version is not exposed. Validation limits are stated above.

Share the fallible default writer, retain the selected output stream across callbacks, and keep user hooks available during finalization. Flush after exit callbacks and propagate either stream failure to exit status 120.

Assisted-by: OpenAI Codex:model version not exposed
@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants