Skip to content

Fix UTF-8 startup option precedence and refresh canonical tests - #9422

Merged
youknowone merged 3 commits into
RustPython:mainfrom
youknowdot:youknowdot/utf8-startup-settings-315-20261028
Oct 28, 2026
Merged

youknowone merged 3 commits into
RustPython:mainfrom
youknowdot:youknowdot/utf8-startup-settings-315-20261028

Conversation

@youknowdot

@youknowdot youknowdot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Resolve the first explicit -X utf8 before PYTHONUTF8, so an invalid environment value cannot override a valid command-line setting. Keep the Python3.15 UTF-8 default and empty-environment handling; align invalid-value diagnostics with pinned CPython.

  • Refresh test_utf8_mode and test_c_locale_coercion using the actual scripts/update_lib migrate pipeline from CPython3.15.0 d220409a13b77de7a6c30abe16ea90db01528edc.

  • Narrow the existing test_env_var expected failure to Windows only. Its portable settings branches are source-reviewed; Windows still lacks PYTHONLEGACYWINDOWSFSENCODING, so that existing failure remains. Retire only the stale test_stdio expected failure after repeated Linux CI unexpected successes; all four other existing markers and all reasons remain unchanged.

  • Allow only monotonic narrowing of an existing unconditional expected failure through updater metadata, with same target/reason/order. Add focused updater tests rejecting new targets, reordered/duplicated markers, changed reasons, skip/success conversions and conditional broadening.

  • Normalize explicitly configured standard-stream encodings using the existing codec registry's CodecInfo.name, as CPython does before stdio construction. Ordinary TextIOWrapper keeps its spelling behavior.

Scope

No PEP538 process-locale initialization/coercion or Windows legacy filesystem encoding implementation. No changes to the already-enabled UTF-8 default or existing strict behavior for explicitly configured standard streams. The locale module's existing CPython-only coercion guard is preserved. Existing unguarded external-locale configuration behavior is not claimed fixed.

Validation

  • 224 updater tests passed.
  • Normal configured precommit checks passed.
  • Focused cargo check --locked --offline -j1 -p rustpython --lib --no-default-features --features threading,stdlib,stdio,importlib,host_env,doc,ucd_3_2_0 passed.
  • Same-scope Clippy with -- -D warnings passed.
  • Both migrated test files verified exact updater output; only the reviewed env_var marker scope and runtime-proven test_stdio marker retirement changed.

RustPython runtime suites for this branch have not run locally; the available executable belongs to another branch and does not validate this fix. This is not a full workspace/default-feature/CAPI or platform validation claim. The marker narrowing rests on explicit case-by-case settings-source review, not a claimed runtime pass. Hosted CI results are recorded below; this remains a draft for maintainer review.

CI follow-up

Initial CI on d5b160a2d96bbaa0f77462ea3683ffc89c9a9a2d exposed the new canonical test_with_ioencoding failure on macOS and Linux: PYTHONIOENCODING=UTF-8 was retained literally instead of resolving to the canonical utf-8 codec name. The VM bootstrap fix follows pinned CPython Objects/unicodeobject.c config_get_codec_name/init_stdio_encoding; it adds no test edits or skips. Ten bounded startup probes on the pinned CPython 3.15.0 binary verified alias names, error policies, empty/default values, and rejection of invalid codec names; these are oracle results, not a RustPython runtime pass. Follow-up commit d5341f63c274a1b5ab2d34b03e0cde1b7c651811: final-source focused check passed in 1m29s and strict Clippy in 1m37s, with both changed-source hashes verified and normal commit hooks passed. Correctness CI was pending at that follow-up; final-head results are recorded below.

Passing-test marker retirement

After d5341f63c274a1b5ab2d34b03e0cde1b7c651811, Linux correctness CI passed test_c_locale_coercion and failed only because canonical test_stdio unexpectedly succeeded in both initial execution and rerun. Commit 04b7a2682a827aecb98d44215a5065602f24413b removes exactly its one stale decorator via actual update_lib migrate; assertions, all other guards and native code are unchanged. The test has the same three piped subprocess cases on all platforms and exercises the shared stdio bootstrap. Windows/macOS outcomes were not yet verified at retirement time; final-head CI results are recorded below. Normal hooks and all 224 updater tests passed. No additional Rust build or local RustPython runtime is claimed for this marker-only follow-up.

Hosted CI status

Verified on final head 04b7a2682a827aecb98d44215a5065602f24413b: correctness CI run 40641575189 completed successfully with all 24 jobs passing, and dependency check 40641571678 also succeeded. The final hosted Linux, macOS, and Windows results now validate the normalization fix and stale-marker retirement in their configured suites. This does not establish the deliberately excluded process-locale or Windows legacy filesystem-encoding support, and does not change the no-local-RustPython-runtime limitation above. The PR remains a draft for maintainer review.

Resolve the first explicit UTF-8 option before environment validation and align startup diagnostics with CPython 3.15. Refresh canonical encoding tests through update_lib and narrow the existing environment test failure to Windows. Support only monotonic expected-failure narrowing in updater metadata with focused regression tests.

Assisted-by: OpenAI Codex: model version unavailable
@coderabbitai

coderabbitai Bot commented Oct 28, 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.

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

📦 Library Dependencies

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

[x] test: cpython/Lib/test/test_utf8_mode.py (TODO: 5)

dependencies:

dependent tests: (no tests depend on utf8_mode)

[x] test: cpython/Lib/test/test_c_locale_coercion.py

dependencies:

dependent tests: (no tests depend on c_locale_coercion)

Legend:

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

Resolve explicit stdio encodings through CodecInfo.name before creating standard streams, matching CPython initialization. Preserve ordinary TextIOWrapper spelling and existing standard-stream error policies; leave canonical tests unchanged.

Assisted-by: OpenAI Codex: model version unavailable
@codspeed

codspeed Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 4 skipped benchmarks1


Comparing youknowdot:youknowdot/utf8-startup-settings-315-20261028 (d5341f6) with main (058bebf)

Open in CodSpeed

Footnotes

  1. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

The configured-codec normalization fix makes canonical test_stdio pass in both Linux CI attempts. Remove only its stale expectedFailure through update_lib, preserving canonical assertions and all other platform guards.

Assisted-by: OpenAI Codex: model version unavailable
@youknowone
youknowone marked this pull request as ready for review October 28, 2026 09:23
@youknowone
youknowone merged commit e833153 into RustPython:main Oct 28, 2026
29 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

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 ⚠️ Failed 2026-10-28T09:24:27.032630Z
We couldn’t complete this review. Comment @codex review to try again.
04b7a26 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.

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.

3 participants