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

Closed
opened 2026-11-07 15:33:16 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2542
Author: @qiuzan2001
Created: 10/15/2026
Status: ❌ Closed

Base: main ← Head: chief-serve/bench-utf8-version


📝 Commits (1)

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

📊 Changes

2 files changed (+12 additions, -1 deletions)

View changed files

📝 tools/strata_bench.py (+1 -1)
📝 tools/test_strata_bench.py (+11 -0)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/2542 **Author:** [@qiuzan2001](https://github.com/qiuzan2001) **Created:** 10/15/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `chief-serve/bench-utf8-version` --- ### 📝 Commits (1) - [`860b745`](https://github.com/Niko1221/Strata/commit/860b745314cb6ed2032d082372e1298ad456336d) bench: read the project version from CMakeLists.txt as UTF-8 on every locale (#2499) ### 📊 Changes **2 files changed** (+12 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `tools/strata_bench.py` (+1 -1) 📝 `tools/test_strata_bench.py` (+11 -0) </details> ### 📄 Description 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:33:16 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4107
No description provided.