fix(excalidraw-diagram-generator): force UTF-8 stdout so add-arrow/add-icon don't crash on Windows#1914
Open
brainit-consulting wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
main, but PRs should target staged.
The main branch is auto-published from staged and should not receive direct PRs.
Please close this PR and re-open it against the staged branch.
You can change the base branch using the Edit button at the top of this PR,
or run: gh pr edit 1914 --base staged
cc71352 to
36cdc52
Compare
…add-icon so the success print doesn't crash on Windows cp1252
…add-icon so the success print doesn't crash on Windows cp1252
Contributor
🔍 Skill Validator Results
Summary
Full validator output```text Found 1 skill(s) [excalidraw-diagram-generator] 📊 excalidraw-diagram-generator: 5,862 BPE tokens [chars/4: 5,926] (comprehensive ✗), 43 sections, 22 code blocks [excalidraw-diagram-generator] ⚠ Skill is 5,862 BPE tokens (chars/4 estimate: 5,926) — "comprehensive" skills hurt performance by 2.9pp on average. Consider splitting into 2–3 focused skills. ✅ All checks passed (1 skill(s)) ``` |
Author
|
Thanks for the heads-up. Retargeted this PR to |
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
On Windows,
add-arrow.pyandadd-icon-to-diagram.pycrash at the very end of an otherwisesuccessful run. Both finish by printing a check mark, e.g.:
On a standard Windows console Python's stdout uses the
cp1252code page, which cannot encodeU+2713(✓). That print raisesUnicodeEncodeError, so the script exits with code 1 even though ithas already saved the file. The edit lands, but any caller that checks the exit code sees a failure.
It is also easy to misdiagnose, because the traceback goes to stdout while stderr stays empty.
Repro (Windows, default code page):
This makes the two scripts unreliable when driven from automation (or any tool that checks exit codes)
on Windows.
Fix
Reconfigure stdout to UTF-8 at the start of
main()in both scripts. This is the same guard alreadyused by
split-excalidraw-library.pyin the samescripts/directory, so this just brings the othertwo scripts in line:
No behavior change on macOS/Linux; on Windows the success message now prints and the script exits 0.
Verification
On Windows with the default cp1252 console:
add-arrow.py ...-> exit 1,charmaperror raised after the file was already savedadd-arrow.py ...-> prints✓ Successfully added arrow to diagram, exit 0Two files, +3/-0 each, no functional change beyond the encoding fix.
🤖 Generated with Claude Code