Skip to content

fix: force UTF-8 through the exec-command pipe (Windows cp1252 crash)#649

Open
weegens-aaron wants to merge 1 commit into
mpfaffenberger:mainfrom
weegens-aaron:fix/flux-windows-os
Open

fix: force UTF-8 through the exec-command pipe (Windows cp1252 crash)#649
weegens-aaron wants to merge 1 commit into
mpfaffenberger:mainfrom
weegens-aaron:fix/flux-windows-os

Conversation

@weegens-aaron

Copy link
Copy Markdown
Contributor

/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

/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
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