Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

tools/strata_bench.py: read CMakeLists.txt as UTF-8, not with the locale's code page (#4011, #2792)

SuperDistanced2c69e6d4b19
diff --git a/tools/strata_bench.py b/tools/strata_bench.py
index 93d92ee1d..0bb0711d7 100644
--- a/tools/strata_bench.py
+++ b/tools/strata_bench.py
@@ -563,7 +563,8 @@ def detect_quant(view: dict) -> str | None:
def project_version() -> str | None:
try:
- m = re.search(r"project\(strata VERSION ([\d.]+)", (ROOT / "CMakeLists.txt").read_text())
+ # UTF-8 as setup.py reads it, whatever the locale's code page (#2792)
+ m = re.search(r"project\(strata VERSION ([\d.]+)", (ROOT / "CMakeLists.txt").read_text(encoding="utf-8"))
return m.group(1) if m else None
except OSError:
return None
diff --git a/tools/test_strata_bench.py b/tools/test_strata_bench.py
index 30d3978b0..986ab1a3a 100644
--- a/tools/test_strata_bench.py
+++ b/tools/test_strata_bench.py
@@ -339,6 +339,24 @@ class ReportTests(unittest.TestCase):
def test_no_server_is_an_error_not_a_crash(self):
self.assertEqual(B.main(["--url", "http://127.0.0.1:9", "--quiet"]), 2)
+ def test_project_version_does_not_use_the_locale_code_page(self):
+ # #2792: on Windows a text file read without an encoding is decoded with the locale's code page, and CMakeLists.txt
+ # is UTF-8 with non-ASCII text. Path.read_text here defaults to each Windows ANSI code page in turn.
+ original = Path.read_text
+ with tempfile.TemporaryDirectory() as d:
+ root = Path(d)
+ (root / "CMakeLists.txt").write_bytes(
+ "cmake_minimum_required(VERSION 3.24)\n# notes — § €\nproject(strata VERSION 9.8.7 LANGUAGES CXX)\n"
+ .encode("utf-8"))
+ for code_page in ("cp874", "cp932", "cp936", "cp949", "cp950", "cp1250", "cp1251", "cp1252", "cp1253",
+ "cp1254", "cp1255", "cp1256", "cp1257", "cp1258"):
+ def locale_default(self, encoding=None, errors=None, **kw):
+ return original(self, encoding=encoding or code_page, errors=errors, **kw)
+
+ with self.subTest(code_page=code_page), mock.patch.object(B, "ROOT", root), \
+ mock.patch.object(Path, "read_text", locale_default):
+ self.assertEqual(B.project_version(), "9.8.7")
+
if __name__ == "__main__":
unittest.main()