Issues / #2648

#2648 BENCH.bat crashes on Japanese-locale Windows: UnicodeDecodeError (cp932) reading CMakeLists.txt

open · @qramo · 0 comments · View on GitHub

BenchmarksSetup & installWindowsLinux

Description

**What happens**

On Windows with a Japanese system locale (ANSI code page 932), `BENCH.bat` stops before measuring anything:

```text
Using the Strata server already running at http://127.0.0.1:8080.
Traceback (most recent call last):
  File "D:\Strata\tools\strata_bench.py", line 1028, in <module>
    sys.exit(main())
  File "D:\Strata\tools\strata_bench.py", line 989, in main
    pre = collect_machine(base, key, cfg, a.gpu)
  File "D:\Strata\tools\strata_bench.py", line 639, in collect_machine
    "strata_version": project_version(), "strata_commit": git_commit(),
  File "D:\Strata\tools\strata_bench.py", line 564, in project_version
    m = re.search(r"project\(strata VERSION ([\d.]+)", (ROOT / "CMakeLists.txt").read_text())
  ...
UnicodeDecodeError: 'cp932' codec can't decode byte 0xef in position 0: illegal multibyte sequence
```

**Cause**

`CMakeLists.txt` starts with a UTF-8 BOM (`EF BB BF`). `Path.read_text()` without `encoding=` uses the locale's code page on Windows, which is cp932 here. On English-locale Windows (cp1252) the BOM decodes without error, which is probably why this hasn't come up.

**Fix**

```python
# tools/strata_bench.py:564
(ROOT / "CMakeLists.txt").read_text(encoding="utf-8-sig")
```

Other `read_text()` calls without an encoding in `tools/` could fail the same way on CJK-locale Windows if they read files containing non-ASCII bytes. The ones in `strata_bench.py` at lines 448 and 471 read `/proc` and are Linux-only, so they're fine.

**Workaround**

`set PYTHONUTF8=1` before running `BENCH.bat`. With that, the benchmark completes normally.

**Environment**

Windows 11 Home 10.0.26200 (Japanese), Strata 0.1.44.1 (commit 296b59d2), Python 3.13 venv created by setup.

Related on this site

Quick links to related pages.