fix(scripts): force UTF-8 stdout in design_system.py on Windows (#112)#390
Merged
mrgoonie merged 1 commit intoJun 25, 2026
Merged
Conversation
design_system.py prints box-drawing characters and swatches (--, OK marks, block swatches), but unlike search.py it never reconfigured stdout. On a non-UTF-8 Windows console (cp1252/gbk) running the CLI crashes with UnicodeEncodeError, the same failure reported in nextlevelbuilder#112 for search.py. Mirror the wrapper search.py already uses: re-wrap stdout/stderr in a UTF-8 TextIOWrapper when the console encoding is not UTF-8. Applied to the source of truth and the synced cli/assets copy. Verified: the CLI runs clean under PYTHONIOENCODING=cp1252 (exit 0, no UnicodeEncodeError) while still emitting the box/swatch output; check:assets passes. Related to nextlevelbuilder#112 (search.py is already fixed on main; this covers the remaining design_system.py instance).
Contributor
Author
|
@mrgoonie more cleanup |
mrgoonie
approved these changes
Jun 25, 2026
mrgoonie
left a comment
Contributor
There was a problem hiding this comment.
Maintainer review: approved. This is a narrow fix for the remaining Windows non-UTF-8 console path in design_system.py, mirrors the existing search.py stdout/stderr UTF-8 wrapper, and keeps source-of-truth plus packaged cli/assets copies in sync. Verified locally: npm run check:assets passes, and PYTHONIOENCODING=cp1252 python3 src/ui-ux-pro-max/scripts/design_system.py "saas dashboard" exits successfully while emitting the box/swatch output instead of raising UnicodeEncodeError. Duplicate/prior-work search only found this PR for the design_system.py-specific gap; related #112 search.py behavior is already fixed on main.
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.
What & why
On a non-UTF-8 Windows console (cp1252/gbk), running
design_system.pyas a CLI crashes withUnicodeEncodeError-- the same class of failure reported in #112 forsearch.py. The script prints box-drawing characters, check marks, and block swatches, but unlikesearch.pyit never reconfigured stdout.Note: the
search.pyinstance from #112 is already fixed on main (it wraps stdout/stderr in a UTF-8TextIOWrapperat lines 23-27). This PR covers the remainingdesign_system.pygap.Change
Mirror
search.py's wrapper indesign_system.py:Applied to the source of truth (
src/ui-ux-pro-max/scripts/) and the syncedcli/assets/copy. The check is idempotent, so it is a no-op whensearch.pyimportsdesign_system(stdout is already UTF-8 by then).Verification
PYTHONIOENCODING=cp1252 python design_system.py "saas dashboard" --format ascii-> exit 0, noUnicodeEncodeError, still emits the box/swatch output (50 lines with non-ASCII).npm run check:assetspasses (both copies in sync).Related to #112.