From bf276bc25d266ebfbff9f50dc9884a8d5e111069 Mon Sep 17 00:00:00 2001 From: "Molecule AI Dev Engineer A (Kimi)" Date: Tue, 26 May 2026 17:09:06 +0000 Subject: [PATCH] fix(ci): add explicit utf-8 encoding to Python open() calls Python 3's open() default encoding is platform-dependent (PEP 597). On CI runners it happens to be UTF-8, but being explicit avoids surprises on Windows dev boxes or custom runner images. Files touched: - sop-checklist.py: config loading (YAML + minimal parser) - tests/_review_check_fixture.py: test fixture scenario loader - tests/_refire_fixture.py: test fixture scenario loader Co-Authored-By: Claude Opus 4.7 --- .gitea/scripts/sop-checklist.py | 4 ++-- .gitea/scripts/tests/_refire_fixture.py | 2 +- .gitea/scripts/tests/_review_check_fixture.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitea/scripts/sop-checklist.py b/.gitea/scripts/sop-checklist.py index 40e3b81f6..28573cf4a 100644 --- a/.gitea/scripts/sop-checklist.py +++ b/.gitea/scripts/sop-checklist.py @@ -642,7 +642,7 @@ def load_config(path: str) -> dict[str, Any]: # requiring the dep, so the ignore is safe: if yaml loads, we use it; # otherwise we fall back silently. import yaml # type: ignore[import-not-found] - with open(path) as f: + with open(path, encoding="utf-8") as f: return yaml.safe_load(f) except ImportError: return _load_config_minimal(path) @@ -656,7 +656,7 @@ def _load_config_minimal(path: str) -> dict[str, Any]: item map: scalars + lists of scalars. Does NOT support nested lists, YAML anchors, multi-doc, or flow style. """ - with open(path) as f: + with open(path, encoding="utf-8") as f: lines = f.readlines() return _parse_minimal_yaml(lines) diff --git a/.gitea/scripts/tests/_refire_fixture.py b/.gitea/scripts/tests/_refire_fixture.py index 3844ba5c1..a64b2036d 100755 --- a/.gitea/scripts/tests/_refire_fixture.py +++ b/.gitea/scripts/tests/_refire_fixture.py @@ -33,7 +33,7 @@ def scenario() -> str: p = os.path.join(STATE_DIR, "scenario") if not os.path.isfile(p): return "T1_success" - with open(p) as f: + with open(p, encoding="utf-8") as f: return f.read().strip() diff --git a/.gitea/scripts/tests/_review_check_fixture.py b/.gitea/scripts/tests/_review_check_fixture.py index 265098265..bb0a52f8d 100644 --- a/.gitea/scripts/tests/_review_check_fixture.py +++ b/.gitea/scripts/tests/_review_check_fixture.py @@ -40,7 +40,7 @@ def scenario() -> str: p = os.path.join(STATE_DIR, "scenario") if not os.path.isfile(p): return "T1_pr_open" - with open(p) as f: + with open(p, encoding="utf-8") as f: return f.read().strip() -- 2.52.0