mirror of
https://github.com/p-e-w/heretic.git
synced 2026-10-14 02:17:55 +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:
parent
00185db9fc
commit
3f68a0d4e5
1 changed files with 8 additions and 0 deletions
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue