mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-21 03:39:54 +00:00
fix(scripts): fix UnicodeEncodeError in footgun checker on Windows
The check-windows-footguns.py script outputs a checkmark (U+2713) and cross (U+2717) to report results. Windows terminals default to cp1252, which cannot encode these characters, so running the script on Windows threw a UnicodeEncodeError before any results were printed. This made the tool completely unusable on the exact platform it exists to help -- a developer on Windows trying to check their code for Windows-safety issues would just get a crash instead. Fix: reconfigure stdout and stderr to UTF-8 at the start of main(), before any output is produced. Verified on Windows 11 Home with Python 3.13 (terminal defaulting to cp1252).
This commit is contained in:
@@ -551,6 +551,14 @@ def print_rules() -> None:
|
||||
|
||||
|
||||
def main(argv: list[str]) -> int:
|
||||
# Windows terminals default to cp1252, which can't encode the ✓/✗
|
||||
# characters used in the output. Reconfigure streams to UTF-8 so the
|
||||
# script works correctly on the very platform it is designed to help.
|
||||
if hasattr(sys.stdout, "reconfigure"):
|
||||
sys.stdout.reconfigure(encoding="utf-8")
|
||||
if hasattr(sys.stderr, "reconfigure"):
|
||||
sys.stderr.reconfigure(encoding="utf-8")
|
||||
|
||||
args = parse_args(argv)
|
||||
|
||||
if args.list:
|
||||
|
||||
Reference in New Issue
Block a user