Skip to content

fix(minimax-xlsx): scripts crash printing ✓/→ through non-UTF8 Windows pipes - #111

Open
quickbeard wants to merge 1 commit into
MiniMax-AI:mainfrom
quickbeard:fix/windows-console-encoding
Open

fix(minimax-xlsx): scripts crash printing ✓/→ through non-UTF8 Windows pipes#111
quickbeard wants to merge 1 commit into
MiniMax-AI:mainfrom
quickbeard:fix/windows-console-encoding

Conversation

@quickbeard

@quickbeard quickbeard commented Aug 4, 2026

Copy link
Copy Markdown

Fixes #110.

Problem

Every script in skills/minimax-xlsx/scripts/ prints non-ASCII characters (, , , ). On Windows, Python encodes piped stdout with the legacy ANSI codepage (e.g. cp1252), which cannot represent them — the first such print raises UnicodeEncodeError and kills the script mid-operation, even though the underlying work (packing, validation, …) succeeded. Piped output is the common case: agent shells capture script output through pipes, as do installers and CI.

Observed in the wild on Windows 10 / Python 3.14 during an offline install verification (full traceback in #110); reproducible on any OS with:

PYTHONIOENCODING=cp1252 python3 skills/minimax-xlsx/scripts/xlsx_pack.py \
  skills/minimax-xlsx/templates/minimal_xlsx /tmp/test.xlsx | cat

Fix

Add a small startup snippet to each of the ten scripts, right after the import block:

for _stream in (sys.stdout, sys.stderr):
    try:
        _stream.reconfigure(errors="replace")
    except (AttributeError, ValueError):
        pass

Unencodable characters degrade to ? instead of crashing. On UTF-8 terminals (all of Linux/macOS, and Windows consoles) output is byte-identical to before; exit codes and file outputs are untouched everywhere. The try/except keeps the scripts safe under detached/wrapped streams.

Verified: the repro above crashes before this change and completes with exit 0 after (the renders as ? under cp1252, verbatim under UTF-8). All ten scripts still compile (python -m py_compile).


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Windows Python uses the legacy ANSI codepage (e.g. cp1252) for piped
stdout, and every script here prints characters it cannot encode -
UnicodeEncodeError killed xlsx_pack.py during install verification.
Reconfigure stdout/stderr with errors="replace" so output degrades to
"?" instead of crashing.
@quickbeard
quickbeard force-pushed the fix/windows-console-encoding branch from 4c49643 to f8dab70 Compare August 4, 2026 13:07
@quickbeard quickbeard changed the title minimax-xlsx: don't crash printing ✓/→ through non-UTF8 Windows pipes fix: minimax-xlsx scripts crash printing ✓/→ through non-UTF8 Windows pipes Aug 4, 2026
@quickbeard quickbeard changed the title fix: minimax-xlsx scripts crash printing ✓/→ through non-UTF8 Windows pipes fix(minimax-xlsx): scripts crash printing ✓/→ through non-UTF8 Windows pipes Aug 4, 2026
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.

minimax-xlsx: scripts crash with UnicodeEncodeError on Windows when output is piped

1 participant