fix(scripts): stop check-prerequisites text mode crashing on a legacy stdout code page - #3890
Open
jawwad-ali wants to merge 1 commit into
Open
fix(scripts): stop check-prerequisites text mode crashing on a legacy stdout code page#3890jawwad-ali wants to merge 1 commit into
jawwad-ali wants to merge 1 commit into
Conversation
… code page _check_file/_check_dir hard-code U+2713/U+2717 and print() them to sys.stdout. On Windows sys.stdout falls back to the ANSI code page whenever stdout is not a console — which is every time an agent or a workflow step captures the output — and U+2713 is unencodable in cp1252: stdout encoding: cp1252 UnicodeEncodeError: 'charmap' codec can't encode character '✓' So text mode aborted right after printing "AVAILABLE_DOCS:", losing every per-document line. Fall back to ASCII when stdout cannot encode the glyph. "[OK]"/"[FAIL]" is the rendering these markers already have in-tree: Test-FileExists in scripts/powershell/common.ps1 emits exactly those, and normalize_status_text in tests/parity_helpers.py maps the glyphs onto them, so the twins already treat the two forms as equivalent. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This was referenced Jul 31, 2026
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.
Problem
_check_file/_check_dirinscripts/python/check_prerequisites.pyhard-code the U+2713 / U+2717 glyphs andprint()them tosys.stdout:On Windows
sys.stdoutfalls back to the ANSI code page whenever stdout is not a console — a pipe or a file redirect, which is exactly how an agent or a workflow step invokes these scripts. U+2713 is unencodable in cp1252.Reproduction on current
main(81bf741)Text mode therefore aborts right after printing
AVAILABLE_DOCS:, so the caller gets a header with no document lines under it — and a non-zero exit for a repository that is perfectly healthy.Fix
Downgrade to ASCII only when stdout cannot encode the glyph, so a UTF-8 console is unaffected:
[OK]/[FAIL]is not invented — it is the ASCII rendering these markers already have in this repo:scripts/powershell/common.ps1:243Write-Output " [OK] $Description"scripts/powershell/common.ps1:246Write-Output " [FAIL] $Description"tests/parity_helpers.py:130-131text.replace(" ✓ ", " [OK] ").replace(" ✗ ", " [FAIL] ")The PowerShell twin emits the ASCII form natively, and the parity helper maps the glyphs onto it — so the test suite already treats the two forms as equivalent output. Nothing downstream distinguishes them.
Breaking risk: a UTF-8-capable stdout still gets the glyphs, byte-identical to today. The only case that changes is one that previously raised and truncated the report. Callers parsing the marker are already required to accept both forms, per
normalize_status_text.Scope note
scripts/python/setup_tasks.py:58-65carries a byte-identical block and crashes the same way. I kept this PR to one script — happy to extend it to the twin here or as a follow-up, whichever you prefer.Verification
PYTHONIOENCODING=cp1252) fails on unpatchedsrcand passes with the fix. File: 1 failed → 12 passed, 8 skipped.mainbaseline captured on81bf741(0 pre-existing in scope).uvx ruff@0.15.0 check src tests→ cleanNote this test file is also touched by my open #3785 (a comment-only change to
scripts/python/common.py), so expect a trivial append conflict if that merges first — happy to rebase.Written with assistance from Claude Code. Bug found, reproduced, and verified by me on current
main.