⚡ Sangsakala Proxy 🏠 Home
Skip to content

Preserve native script filenames through execution - #9688

Draft
youknowdot wants to merge 1 commit into
RustPython:mainfrom
youknowdot:fix/linux-command-line-decoding-20261104
Draft

youknowdot wants to merge 1 commit into
RustPython:mainfrom
youknowdot:fix/linux-command-line-decoding-20261104

Conversation

@youknowdot

Copy link
Copy Markdown
Contributor

Summary

Keep native script paths lossless instead of requiring UTF-8 during command-line parsing and file execution.

  • Preserve OsString/Path through script arguments, absolute paths, working directories, sys.path[0], and PYTHONSTARTUP.
  • Pass Python filenames to loaders and __file__, retain them in nested co_filename, and keep original filenames in compiler warnings and syntax-error attributes.
  • Reuse the existing recursive code-filename helper and filename-aware warning machinery.
  • Handle surrogate filenames in traceback display/source lookup, code repr, importer filtering, _imp, and signal-safe faulthandler output.

This targets the Linux failure in test_cmd_line_script.CmdLineTest.test_non_ascii. Its expected-failure marker remains until an actual RustPython pass is observed. No tests, assertions, or standard-library files are changed.

Reference

Compared with CPython 3.15.0 script/startup execution, file execution, script-directory handling, and signal-safe ASCII traceback output.

Validation

  • cargo check --locked --offline -p rustpython -p rustpython-vm -p rustpython-stdlib --tests passes.
  • cargo clippy --locked --offline -p rustpython -p rustpython-vm -p rustpython-stdlib --tests -- -D warnings passes.
  • cargo check --locked --offline -p rustpython --no-default-features --lib --bin rustpython passes, with two existing unused-item warnings in unchanged src/main.rs.
  • Independent source review and normal commit hooks.
  • The unmodified upstream test_cmd_line_script.CmdLineTest.test_non_ascii passes on CPython 3.15.0.
  • Six external CPython 3.15 reference cases pass: absolute/relative filenames, non-UTF-8 working directory, nested/marshalled code filenames, faulthandler escaping, warnings promoted to errors, and syntax-error filenames. These establish reference behavior, not RustPython test results.

Native RustPython execution was not performed locally because the required runtime guard is unavailable. Full workspace/C-API runtime tests and cross-platform execution remain unverified. Existing general audit-event and SyntaxError.args-tuple gaps are outside this change.

AI assistance: implementation, reference comparison, and source review were assisted by OpenAI Codex; model version is not exposed.

Keep OS paths native until Python conversion and retain surrogate-bearing filenames across execution, diagnostics, and signal-safe tracebacks.

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.

1 participant