Skip to content

Preserve interpreter-boundary diagnostics and syslog restrictions - #9365

Merged
youknowone merged 4 commits into
RustPython:mainfrom
youknowdot:split/thread-unraisable-unicode
Oct 26, 2026
Merged

youknowone merged 4 commits into
RustPython:mainfrom
youknowdot:split/thread-unraisable-unicode

Conversation

@youknowdot

@youknowdot youknowdot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Preserve exception diagnostics across two existing production VM boundaries:

  • Build _thread unraisable-hook messages from the callable's WTF-8 representation instead of replacing lone surrogates through Rust Display.
  • Wrap code/function cross-interpreter marshal failures as NotShareableError, preserving the original exception as __cause__ and CPython's serialization/deserialization message.

The existing Option<String> unraisable entry point remains unchanged. Hook/audit dispatch, failure handling and finalization behavior are preserved. This does not change the lossy stderr fallback or other generator/deallocator message producers.

The marshal change is limited to two existing private helpers. Successful operations and existing callers are unchanged. No new cross-interpreter mode, test C API, subinterpreter lifecycle, GC ownership, native-monitoring API or fixture registration is included.

CPython 3.15 sources: thread producer, Unicode formatting, marshal error boundaries, code/function callers.

Validation

All four gates passed on exact composed head 3df6951343b5; normal commit hooks also passed.

Four compile-only gates cover VM-library cargo check and strict cargo clippy -- -D warnings, using --no-default-features --features compiler,host_env,stdio,gc,doc with and without threading. All use locked/offline dependencies and Rust 1.99.0. These are selected feature sets, not Cargo default features or full-workspace validation.

No runtime tests were run. The existing test_thread.ThreadRunningTests.test_unraisable_exception starts a thread and covers an ordinary representation, not the surrogate boundary. Canonical XI tests require native fixtures or interpreter lifecycle work outside this patch. No test markers or fixtures are changed; full workspace and C API tests remain unrun.

RustPython's existing marshal path calls the Python module rather than CPython's direct C implementation; this pre-existing difference remains. This patch is not a claim of full serialization parity.

AI assistance: OpenAI Codex (model identifier unavailable), also disclosed in the commit trailers.

Queue and syslog interpreter-boundary follow-up

Match the CPython 3.15 syslog guards: reject subinterpreter openlog() and closelog() before auditing or host mutation, and reject implicit syslog() opening after its audit event when the logger has not already been opened by the main interpreter. Already-open logging and setlogmask() are unchanged. This does not redesign global logger locking or interpreter lifecycle.

Migrate Lib/concurrent/interpreters/_queues.py through scripts/update_lib to that exact CPython commit, removing the unused eager pickle import and exception targets. Native serialization imports pickle on demand. Public import timing, incidental module attributes, and debug exception locals can nevertheless differ; this is not claimed to be unobservable.

The follow-up source tree was recovered exactly and validated anew in a fresh workspace using official Rust 1.99.0 and normal repository hooks. Four sequential, bounded, locked/offline compile-only gates cover default CLI cargo check, frozen-stdlib CLI cargo check, cargo check -p rustpython-stdlib --lib, and strict cargo clippy -p rustpython-stdlib --lib -- -D warnings. Linux default stdlib features compile the Unix syslog guards. Full source, toolchain, and extracted dependency-source hashes/membership were checked before and after each gate. System Python/native OS libraries remain an explicitly trusted managed-environment boundary, not a fully hermetic build claim.

No Python module imports, syslog calls, queue/thread/interpreter-lifecycle, or serialization runtime tests were run for this follow-up. No fixtures or test selections were changed. Full workspace and C-API runtime suites remain unrun. Earlier VM-feature receipts above describe their original head, not a rerun on this follow-up tree.

Exact follow-up head: 5fb5e68cdc31868e1c43c6787dc27ba334410221 (tree 7d406e46c4cc9c7592e3aa5eeccdaf59f3f2ba47). All four fresh compile-only gates and normal commit hooks passed. Prior public head 3df69513 had all 25 hosted CI checks succeed in run 40191688907; that result does not validate this follow-up head. New-head hosted CI remains pending after publication.

Keep the callable representation as WTF-8 for unraisable hooks and audit callbacks. Preserve the existing String entry point and stderr fallback; this does not claim lossless stderr rendering.

Assisted-by: OpenAI Codex:model unavailable
Use the existing From<&str> implementation to copy the message prefix without changing Unicode semantics.

Assisted-by: OpenAI Codex:model unavailable
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • 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

Comment @coderabbitai help to get the list of available commands.

Wrap failures from existing code/function serialization helpers as NotShareableError, matching the CPython 3.15 marshal boundary while retaining the original exception cause. No new test C API or lifecycle behavior.

Assisted-by: OpenAI Codex:model-unavailable
@youknowdot youknowdot changed the title Preserve Unicode in thread unraisable messages Preserve exception diagnostics across VM boundaries Oct 25, 2026
Reject subinterpreter openlog/closelog before audit or host mutation, and
reject implicit syslog opening after audit when the process logger is not
already open, matching CPython 3.15 guard placement and error text.
Already-open logging and setlogmask remain unchanged.

Migrate concurrent/interpreters/_queues.py through scripts/update_lib to
CPython d220409a13b77de7a6c30abe16ea90db01528edc, removing unused eager
pickle import and exception targets. Native serialization imports pickle
on demand; module import timing and debug locals may nevertheless differ.

No new fixtures or interpreter lifecycle mechanisms are introduced.

Assisted-by: OpenAI Codex:model version unavailable
@youknowdot youknowdot changed the title Preserve exception diagnostics across VM boundaries Preserve interpreter-boundary diagnostics and syslog restrictions Oct 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 Library Dependencies

The following Lib/ modules were modified. Here are their dependencies:

[ ] lib: cpython/Lib/profiling
[ ] test: cpython/Lib/test/test_profiling

dependencies:

  • profiling (native: main, _child_monitor, _css_utils, _format_utils, _lsprof, _remote_debugging, binary_collector, binary_reader, cli, collector, constants, display, dump, errors, gecko_collector, heatmap_collector, importlib.machinery, importlib.resources, importlib.util, itertools, jsonl_collector, live_collector, marshal, math, module_utils, opcode_utils, profiling.tracing, profiling.tracing._utils, pstats_collector, sample, stack_collector, string_table, sys, time, trend_tracker, widgets)
    • curses (native: _curses, _curses_panel, curses.ascii, has_key, sys)
    • io (native: _io, _thread, errno, msvcrt, sys)
    • opcode (native: _opcode, builtins)
    • platform (native: _wmi, itertools, sys, vms_lib, winreg)
    • site (native: _io, _pyrepl.main, _pyrepl.pager, _pyrepl.readline, _pyrepl.unix_console, _pyrepl.windows_console, atexit, builtins, errno, readline, sitecustomize, sys, usercustomize)
    • sysconfig (native: _sysconfig, _winapi, importlib.machinery, importlib.util, os.path, sys)
    • _colorize, abc, argparse, base64, collections, contextlib, dataclasses, functools, html, json, linecache, locale, optparse, os, pathlib, pstats, re, runpy, selectors, socket, statistics, subprocess, tempfile, threading, traceback, types, typing, uuid, webbrowser

dependent tests: (3 tests)

  • profiling: test_profiling
    • cProfile: test_cprofile test_pstats

[x] lib: cpython/Lib/concurrent
[x] test: cpython/Lib/test/test_concurrent_futures (TODO: 1)
[ ] test: cpython/Lib/test/test_interpreters
[ ] test: cpython/Lib/test/test__interpreters.py
[ ] test: cpython/Lib/test/test__interpchannels.py
[ ] test: cpython/Lib/test/test_crossinterp.py

dependencies:

  • concurrent

dependent tests: (17 tests)

  • concurrent: test_asyncio test_compileall test_concurrent_futures test_context test_external_inspection test_genericalias test_inspect test_struct test_sys test_threading test_types test_wmi
    • asyncio: test_asyncio test_logging test_os test_pdb test_unittest

Legend:

  • [+] path exists in CPython
  • [x] up-to-date, [ ] outdated

@youknowone
youknowone marked this pull request as ready for review October 26, 2026 05:15
@youknowone
youknowone merged commit 1052e61 into RustPython:main Oct 26, 2026
30 checks passed
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-26T05:15:45.410477Z 5fb5e68 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

youknowdot added a commit to youknowdot/RustPython that referenced this pull request Oct 26, 2026
Adopt landed RustPython#9365 Wtf8Buf thread diagnostics and current main wasm dependency updates without rewriting the published integration stack. Preserve removed Python-source Rust oracle tests and existing runtime fixtures.

The final composition with the following tooling/export cleanup was validated by VM default/threading checks and strict Clippy. Rust sources here are identical to that final tested tree; this intermediate complete tree was not separately built. No interpreter or lifecycle runtime was executed.

Assisted-by: OpenAI Codex:model version unavailable
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