v2-on-ui #4
@@ -35,6 +35,14 @@ import pathlib
|
||||
import urllib.parse
|
||||
from collections import Counter
|
||||
|
||||
# 控制台编码兜底:Windows 中文控制台(pre-commit 钩子环境,代码页 936/GBK)下打印
|
||||
# ⚠️/📋 等非 GBK 字符会抛 UnicodeEncodeError → 钩子带 traceback 以退出码 1 死亡,
|
||||
# 而这类告警本身「不拦提交」。启动处统一把 stdout/stderr 切到 UTF-8 + errors="replace"
|
||||
# 兜底;hasattr 守卫兼容 stdout/stderr 被替换成无 reconfigure 的对象(如 None)。
|
||||
for _stream in (sys.stdout, sys.stderr):
|
||||
if hasattr(_stream, "reconfigure"):
|
||||
_stream.reconfigure(encoding="utf-8", errors="replace")
|
||||
|
||||
REPO_ROOT = pathlib.Path(__file__).resolve().parent.parent
|
||||
|
||||
# 不参与检查的路径片段(第三方/生成物/外部资料)
|
||||
|
||||
Reference in New Issue
Block a user