Pull requests / #2542

#2542 bench: read the project version from CMakeLists.txt as UTF-8 on every locale (#2499)

open · @qiuzan2001 · 0 comentarios · En GitHub

BenchmarksWindowsLinux

Descripción

Fixes #2499.

**What it changes.** `tools/strata_bench.py`'s `project_version()` reads `CMakeLists.txt` as `utf-8-sig` instead of
with the locale's code page. `CMakeLists.txt` starts with a UTF-8 BOM (`ef bb bf`), so on a Windows with a non-UTF-8
code page (cp932 in the report) the read raised `UnicodeDecodeError`, which the `except OSError` around it does not
catch, and `BENCH.bat` stopped right after it found the server. The bench already reads the run config as
`utf-8-sig` (the same file, lines 657, 688, 961).

**What it leaves alone.** Everything else in the report. On a UTF-8 locale the version read is the same (the regex
is not anchored, so the BOM never mattered there). The `except OSError` is unchanged: with the file read as UTF-8,
only a corrupt `CMakeLists.txt` could still raise, and I kept this to the one line the issue names. The other file
reads on the bench's main path already name an encoding; the two `/proc` reads are Linux-only.

**How it was checked.**
- New test `ReportTests.test_the_version_is_read_on_a_non_utf8_locale` in `tools/test_strata_bench.py`: it gives
  `Path.read_text` a cp932 default (as a Japanese Windows does) and reads the real `CMakeLists.txt`. Without the fix
  it fails with the issue's error (`'cp932' codec can't decode byte 0xef in position 0`); with it, it passes.
- `python3 tools/test_strata_bench.py`: 18 tests OK. `python3 tools/test_setup_bench_tips.py`: 9 tests OK.
- Python 3.14 on Ubuntu (Linux 7.0), no GPU needed. Not run on a Japanese Windows itself.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

En el sitio

Enlaces a install, modelos, releases.