⚡ Sangsakala Proxy 🏠 Home
Skip to content

Snapshot startup filesystem encoding on Linux - #9689

Draft
youknowdot wants to merge 2 commits into
RustPython:mainfrom
youknowdot:fix/startup-locale-filesystem-20261104
Draft

youknowdot wants to merge 2 commits into
RustPython:mainfrom
youknowdot:fix/startup-locale-filesystem-20261104

Conversation

@youknowdot

Copy link
Copy Markdown
Contributor

Summary

  • Initialize the Linux command-line locale with CPython 3.15's environment precedence and PEP 538 coercion. Keep embedded startup non-mutating; the executable explicitly opts into the unsafe, single-threaded process-startup contract.
  • Snapshot filesystem encoding in interpreter configuration. Share the fixed configuration with subinterpreters, keep Python codec objects local to each interpreter, and preserve filesystem behavior after later LC_CTYPE changes.
  • Reuse native UTF-8, ASCII and Latin-1 codecs. GNU Linux uses an owned locale snapshot for wider-codec bootstrap, then switches to the initialized codec registry.
  • Make filesystem decoding fallible throughout startup and OS-facing callers. Preserve Python exceptions, retain accepted sockets until address conversion succeeds, and close received ancillary descriptors if conversion fails.
  • Stop using frozen filesystem encoding for the internal current-locale conversion helper.

This addresses the runtime cause behind the Linux test_utf8_mode.UTF8ModeTests.test_cmd_line expected failure. No test code or decorators are changed because a RustPython runtime pass is not yet available.

CPython reference

Compared against CPython v3.15.0:

Validation

  • Passed cargo check -p rustpython --lib --bin rustpython.
  • Passed strict Clippy: cargo clippy -p rustpython-host_env -p rustpython-vm -p rustpython-stdlib -p rustpython --lib --bin rustpython -- -D warnings.
  • Passed no-host VM compilation: cargo check -p rustpython-vm --no-default-features --features compiler.
  • Normal commit hooks passed.
  • An out-of-tree, bounded host-helper probe passed 40 decode/encode roundtrips across C, C.UTF-8, ISO-8859-1, ISO-8859-5 and GB2312, including embedded NUL and malformed/incomplete input. Snapshot stability after changing LC_CTYPE and typed encoding errors passed.
  • Fifteen host-helper startup cases matched CPython 3.15.0 output and warning stderr exactly, including environment precedence, ignored Python controls, coercion warnings, invalid locale settings and LC_NUMERIC behavior.
  • Unmodified CPython 3.15.0 test_cmd_line and test_filesystemencoding reference cases passed.
  • Separate source review completed. No repository test additions, skips or expected-failure removals.

The host-helper probe does not execute RustPython's VM or interpreter. Local RustPython runtime and aggregate workspace/C-API suites were not run because no verified runtime guard is available. This draft needs hosted CI and runtime review. Only the GNU Linux Rust target is installed; Windows/WASI call sites were source-reviewed but not cross-compiled.

Scope and integration

Non-Linux filesystem behavior is preserved. Non-GNU Linux supports existing native fast codecs and retains its previous UTF-8 behavior for wider CODESETs. This does not add arbitrary embedded filesystem-codec overrides, Windows legacy mbcs support, complete raw -m parsing, or non-UTF-8 getpath configuration strings.

VirtualMachine::fsdecode and dependent Rust path-result helpers now return PyResult; embedding callers must propagate errors. check_initialization lets embedded callers inspect startup failures without diagnostics or process exit.

This overlaps #9688 (native script filenames). A disposable composition of current main 9d657b02e4, #9688 and this patch passed cargo check -p rustpython --lib --bin rustpython after resolving the cant_open_file overlap and propagating four additional fsdecode results in src/lib.rs and crates/vm/src/vm/python_run.rs. Those merge-time adjustments are prepared separately; neither standalone branch includes the other PR.

AI assistance

This is maintainer-directed Python 3.15 upgrade work. OpenAI Codex assisted with investigation, implementation, source review and validation. Model version was not exposed. No human runtime validation is claimed.

Initialize the Linux CLI locale explicitly, snapshot filesystem conversion for bootstrap and subinterpreters, and propagate codec failures without panicking or leaking socket descriptors.

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

Regenerate the Linux-only marker through update_lib using the two exact-head hosted CI unexpected-success observations. Preserve all other test code and platform handling.

Assisted-by: dot:frontier-intelligence
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.

1 participant