fix: force UTF-8 through the exec-command pipe (Windows cp1252 crash)#649
Open
weegens-aaron wants to merge 1 commit into
Open
fix: force UTF-8 through the exec-command pipe (Windows cp1252 crash)#649weegens-aaron wants to merge 1 commit into
weegens-aaron wants to merge 1 commit into
Conversation
/flux/about died with UnicodeEncodeError on Windows: the exec runner spawns scripts with stdout on a pipe, so the child Python defaults its stdio to the legacy codepage (cp1252) and crashes the moment a script prints an emoji. The parent-side text=True decode mojibakes for the same reason. - exec runner (central fix, covers all exec: scripts): inject PYTHONIOENCODING=utf-8 into the child env and decode captured output explicitly as UTF-8 with errors=replace. Deliberately the narrowest lever: PYTHONUTF8 is NOT set, since full UTF-8 mode would also flip the default open() encoding for every Python child of every exec command; PYTHONIOENCODING alone is verified sufficient, including for older installed scripts still on Rich's legacy-Windows path. The test pins its absence so it can't sneak back without a conscious decision. - flux_about.py: legacy_windows=False keeps Rich off the win32 LegacyWindowsTerm path (stdout is a pipe, not a console handle; that path both crashes on cp1252 and strips the ANSI the runner re-renders via Text.from_ansi) - flux_* scripts: best-effort sys.stdout.reconfigure(utf-8) so standalone runs in a cp1252 console survive too - ci: add a windows-latest job scoped to the exec-runner encoding tests. The bug is Windows-only (macOS/Linux children default to UTF-8 stdio), so the existing macos-only matrix provides zero regression protection for it; the full suite has pre-existing, unrelated Windows failures, so the job runs only the tests pinning this contract. - tests: pin the UTF-8 env/decode contract plus an end-to-end child-Python emoji round-trip; fix two pre-existing TestExecTokenExpansion tests that hard-coded POSIX paths/quoting and failed on Windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/flux/about died with UnicodeEncodeError on Windows: the exec runner spawns scripts with stdout on a pipe, so the child Python defaults its stdio to the legacy codepage (cp1252) and crashes the moment a script prints an emoji. The parent-side text=True decode mojibakes for the same reason.
exec runner (central fix, covers all exec: scripts): inject PYTHONIOENCODING=utf-8 into the child env and decode captured output explicitly as UTF-8 with errors=replace. Deliberately the narrowest lever: PYTHONUTF8 is NOT set, since full UTF-8 mode would also flip the default open() encoding for every Python child of every exec command; PYTHONIOENCODING alone is verified sufficient, including for older installed scripts still on Rich's legacy-Windows path. The test pins its absence so it can't sneak back without a conscious decision.
flux_about.py: legacy_windows=False keeps Rich off the win32 LegacyWindowsTerm path (stdout is a pipe, not a console handle; that path both crashes on cp1252 and strips the ANSI the runner re-renders via Text.from_ansi)
flux_* scripts: best-effort sys.stdout.reconfigure(utf-8) so standalone runs in a cp1252 console survive too
ci: add a windows-latest job scoped to the exec-runner encoding tests. The bug is Windows-only (macOS/Linux children default to UTF-8 stdio), so the existing macos-only matrix provides zero regression protection for it; the full suite has pre-existing, unrelated Windows failures, so the job runs only the tests pinning this contract.
tests: pin the UTF-8 env/decode contract plus an end-to-end child-Python emoji round-trip; fix two pre-existing TestExecTokenExpansion tests that hard-coded POSIX paths/quoting and failed on Windows