mirror of
https://github.com/rehan-remade/universal-modder.git
synced 2026-11-05 01:37:40 +00:00
[GH-ISSUE #152] um kb search crashes with UnicodeEncodeError on Windows (cp1252) #35
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
rehan-remade/universal-modder#35
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @olovorgo-discord on GitHub (Oct 8, 2026).
Original GitHub issue: https://github.com/rehan-remade/universal-modder/issues/152
What
um kb search <term>crashes on Windows when a matching field note contains a character outside cp1252:Repro
um0.2.0 installed viauv tool install git+https://github.com/rehan-remade/universal-modderum kb search aoe— crashes while printing hits fromknowledge/games/age-of-empires-ii-de/san-franciscans-civ.md(that note contains non-cp1252 characters)Root cause
Python picks the console's legacy encoding (cp1252) for stdout on Windows, and kb.py prints raw note text (hit snippets) that can contain characters cp1252 can't represent.
Workaround
$env:PYTHONUTF8 = "1"before runningum kb— works fine.Suggested fix
Reconfigure stdout to UTF-8 at startup in
um/cli.pymain (e.g.sys.stdout.reconfigure(encoding="utf-8")guarded by try/except), or sanitize hit text before printing. Same latent issue in any other subcommand that prints note/repo text.@rehan-remade commented on GitHub (Oct 10, 2026):
Thanks for the precise report and the workaround. #154 makes
umreconfigure stdout and stderr to UTF-8 at startup, which is the fix you suggested, and adds a test that runsum kb showunderPYTHONIOENCODING=cp1252. This closes once that merges. Until then,$env:PYTHONUTF8 = "1"is the workaround.