Commit 77ca23c
committed
fix(continuous-learning-v2): reconfigure stdout to UTF-8 on Windows
`instinct-cli.py status` prints a confidence bar using the box-drawing
characters █ and ░. On Windows the default console codec is cp1250 /
cp1252, and Python's stdout inherits it, so the print statement crashes
with:
UnicodeEncodeError: 'charmap' codec can't encode characters in
position 4-13: character maps to <undefined>
This affects any Windows user whose console is not manually set to
`chcp 65001`, even after #353 (file I/O UTF-8) and #216 (.md glob) —
those fixes cover reading instinct files, but the crash happens on the
*output* side when rendering the status table.
Fix: reconfigure `sys.stdout` / `sys.stderr` to UTF-8 at startup, guarded
by `sys.platform == "win32"`. The reconfigure call is wrapped in
`try/except` because a caller may pipe into something that doesn't
support reconfigure (e.g., a captured buffer in tests).
No-op on Linux/macOS.
Verified locally on Windows 11 / Python 3.14 / cp1250 console:
`instinct-cli.py status` now prints all 155 instincts from
`~/.claude/homunculus/instincts/` without crashing.1 parent 9d766af commit 77ca23c
1 file changed
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
31 | 41 | | |
32 | 42 | | |
33 | 43 | | |
| |||
0 commit comments