Skip to content

fix(cli): print on a non-UTF-8 Windows console - #16

Merged
Atri10 merged 1 commit into
mainfrom
fix/windows-help-encoding
Oct 19, 2026
Merged

Atri10 merged 1 commit into
mainfrom
fix/windows-help-encoding

Conversation

@Atri10

@Atri10 Atri10 commented Oct 19, 2026

Copy link
Copy Markdown
Owner

The v2.0.2 Windows matrix failed in two places, both caught after the tag:

  • test_help_lists_the_command_surface: print(__doc__) raised UnicodeEncodeError because a Windows pipe inherits cp1252 and the help text contains →.
  • test_the_exec_bit_runs_it_directly: Windows has no exec bit, and CreateProcess refuses to run a .py file directly (WinError 193).

Fix

  • cli.main reconfigures stdout and stderr to UTF-8 where the stream supports it. Help, error text, and ensure_ascii=False JSON now survive a redirect under a non-UTF-8 code page; a title with non-Latin text is preserved instead of crashing.
  • The bare-launcher test skips on Windows. The portable python3 <skill>/scripts/executor spelling remains tested everywhere and is what the skills document.

Verification

  • python3 scripts/run_tests.py — 741 tests, 100% branch coverage
  • python3 scripts/sync_engine.py --check — in sync
  • python3 scripts/validate_skills.py — clean
  • python3 scripts/lint-prompt-injection.py skills/ — clean
  • Simulated cp1252 stdio: PYTHONIOENCODING=cp1252 executor --help exits 0, and new preserves a Japanese title in JSON
  • The Windows matrix on this PR is the real confirmation; merge only after it is green.

Bumps the engine to 2.0.3; the release follows the merge.

Windows pipes inherit the locale code page, so print(__doc__) raised
UnicodeEncodeError on the help arrow (U+2192) before it wrote a line.
main now reconfigures stdout and stderr to UTF-8 where the stream supports
it, which also keeps ensure_ascii=False JSON intact when a title contains
non-Latin text.

The bare-launcher test is POSIX-only: Windows has no exec bit and
CreateProcess cannot run a .py file without a registered association. The
portable python3 <skill>/scripts/executor spelling stays the documented,
tested form.

Bumps the engine to 2.0.3 and syncs the bundle.
@Atri10
Atri10 merged commit 8179340 into main Oct 19, 2026
5 checks passed
@Atri10
Atri10 deleted the fix/windows-help-encoding branch October 19, 2026 11:33
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