From 44649e69f4f5ab52f17b72993925f51ecaa8a010 Mon Sep 17 00:00:00 2001 From: kael-odin <445481611@qq.com> Date: Wed, 15 Jul 2026 18:25:38 +0800 Subject: [PATCH] test(install): add UTF-8 regression guard for skills_sync child path Addresses hermes-sweeper review on PR #54866: the installer runs tools/skills_sync.py as a child python.exe whose PYTHONIOENCODING / PYTHONUTF8 the scoped install.ps1 block sets, but there was no regression test for this child-Python UTF-8 path. The existing test_child_process_inherits_utf8_mode covers a different (bootstrap entry-point) flow. Add TestSkillsSyncUtf8Guard: three subprocess tests that import skills_sync (triggering its import-time stdout/stderr reconfigure) and assert the checkmark/up-arrow glyphs the script prints at tools/skills_sync.py:596,675 emit valid UTF-8 and exit 0 even when the child env is left unset or explicitly hostile (gbk). A third test proves the guard is load-bearing by reproducing the crash without it. Also keep the new install.ps1 comment ASCII-only (the checkmark spelled out as U+2713) per the file's PS 5.1 parser-compatibility contract at scripts/install.ps1:79-80; the literal glyph in the comment violated that contract. --- scripts/install.ps1 | 7 ++++--- tests/test_hermes_bootstrap.py | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/install.ps1 b/scripts/install.ps1 index 3d4b7b504b53..e02acfff8816 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -2438,9 +2438,10 @@ You are Hermes Agent, an intelligent AI assistant created by Nous Research. You # Force the child python.exe to emit UTF-8 on its stdout/stderr. # On non-UTF-8 Windows locales (CP936/GBK zh-CN) Python defaults # its stream encoding to the active codepage and crashes on glyphs - # like ✓ (U+2713) that the codepage can't encode; the resulting - # non-UTF-8 bytes break this script's JSON result frame on stdout - # and abort the config-templates stage. Scope to this call only. + # like the checkmark (U+2713) that the codepage can't encode; the + # resulting non-UTF-8 bytes break this script's JSON result frame on + # stdout and abort the config-templates stage. Scope to this call + # only. (Comment kept ASCII per this file's PS 5.1 contract above.) $prevPythonioencoding = $env:PYTHONIOENCODING $prevPythonutf8 = $env:PYTHONUTF8 $env:PYTHONIOENCODING = "utf-8" diff --git a/tests/test_hermes_bootstrap.py b/tests/test_hermes_bootstrap.py index 6c2ecaf425ee..a95bff9127ad 100644 --- a/tests/test_hermes_bootstrap.py +++ b/tests/test_hermes_bootstrap.py @@ -24,6 +24,7 @@ import os import subprocess import sys import textwrap +from pathlib import Path import pytest