[PR #1965] [CLOSED] fix(bench): prevent UnicodeDecodeError on Windows #3779

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1965
Author: @saruiwa
Created: 10/11/2026
Status: ❌ Closed

Base: main ← Head: fix/bench-windows-encoding


📝 Commits (1)

  • 9075c23 fix(bench): prevent UnicodeDecodeError on Windows

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 tools/strata_bench.py (+1 -1)

📄 Description

Summary

Fix a UnicodeDecodeError in BENCH.bat on Windows systems using non-UTF-8 default encodings, such as CP932 (Japanese Windows).

Problem

On Japanese Windows with Python 3.11, running BENCH.bat fails during machine information collection because project_version() reads CMakeLists.txt without specifying an encoding.

Python defaults to CP932, which cannot decode the UTF-8 BOM at the beginning of the file.

UnicodeDecodeError: 'cp932' codec can't decode byte 0xef in position 0: illegal multibyte sequence

Fix

Explicitly use encoding="utf-8-sig" when reading CMakeLists.txt.

This handles UTF-8 files with or without a BOM, regardless of the system's default encoding.

Testing

  • Reproduced the issue on Japanese Windows with Python 3.11.
  • Confirmed that setting PYTHONUTF8=1 works around the issue.
  • Verify that BENCH.bat completes without PYTHONUTF8 after applying the fix.

🔄 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/1965 **Author:** [@saruiwa](https://github.com/saruiwa) **Created:** 10/11/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/bench-windows-encoding` --- ### 📝 Commits (1) - [`9075c23`](https://github.com/Niko1221/Strata/commit/9075c23febce3b6ae6686e0fc4cce46d73db89c6) fix(bench): prevent UnicodeDecodeError on Windows ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `tools/strata_bench.py` (+1 -1) </details> ### 📄 Description ## Summary Fix a `UnicodeDecodeError` in `BENCH.bat` on Windows systems using non-UTF-8 default encodings, such as CP932 (Japanese Windows). ## Problem On Japanese Windows with Python 3.11, running `BENCH.bat` fails during machine information collection because `project_version()` reads `CMakeLists.txt` without specifying an encoding. Python defaults to CP932, which cannot decode the UTF-8 BOM at the beginning of the file. ```text UnicodeDecodeError: 'cp932' codec can't decode byte 0xef in position 0: illegal multibyte sequence ``` ## Fix Explicitly use `encoding="utf-8-sig"` when reading `CMakeLists.txt`. This handles UTF-8 files with or without a BOM, regardless of the system's default encoding. ## Testing - Reproduced the issue on Japanese Windows with Python 3.11. - Confirmed that setting `PYTHONUTF8=1` works around the issue. - [x] Verify that `BENCH.bat` completes without `PYTHONUTF8` after applying the fix. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:30:41 +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#3779
No description provided.