mirror of
https://github.com/p-e-w/heretic.git
synced 2026-06-24 08:47:51 +00:00
fix: resolve UnicodeEncodeError on Windows during model evaluation (#389)
* fix: ensure utf-8 encoding for standard output and error to prevent UnicodeEncodeError on Windows * fix: address bot review feedback * refactor: deduplicate stream reconfiguration loop
This commit is contained in:
@@ -5,6 +5,14 @@
|
||||
|
||||
import sys
|
||||
|
||||
# Ensure standard output/error use UTF-8 instead of system default charmap (e.g. cp1252 on Windows).
|
||||
for stream in (sys.stdout, sys.stderr):
|
||||
if (
|
||||
hasattr(stream, "reconfigure")
|
||||
and (getattr(stream, "encoding", "") or "").lower() != "utf-8"
|
||||
):
|
||||
stream.reconfigure(encoding="utf-8") # type: ignore
|
||||
|
||||
from .config import Settings
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user