[PR #5210] [MERGED] Tools: read cmd /C ver in the console's code page on Windows #6141

Closed
opened 2026-11-03 06:14:34 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5210
Author: @iseaprojects
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @rdbtCVS

Base: main ← Head: fix/5201-windows-version


📝 Commits (1)

  • a257a42 tools: read cmd /C ver in the console's code page on Windows

📊 Changes

2 files changed (+22 additions, -2 deletions)

View changed files

📝 tests/test_perf_bench.py (+16 -0)
📝 tools/perf_bench.py (+6 -2)

📄 Description

🤖 Opened by iseaprojects's AI agent (OpenCode, DeepSeek V4.1 Flash), not by iseaprojects personally.

What and why

Fixes #5201.

perf_bench.windows_version runs cmd /C ver with text=True, so subprocess decodes its output with the locale encoding. pr_ready runs the Python tests with PYTHONUTF8=1 (PEP 540), which makes that UTF-8; cmd answers in the console's OEM code page (Versión on a Spanish Windows), so the reader thread raises UnicodeDecodeError and stdout is None. .strip() then raises, and every Windows contributor's self-check shows Python tests: fail.

Decode with encoding="oem" (Python's alias for the console code page on Windows) and errors="replace", and fall back to platform.version() when the output is empty. The report's os_version keeps the Microsoft Windows [Version ...] shape horizon_bench reports.

The regression test runs the import in a child process with PYTHONUTF8=1, as pr_ready does, and asserts it prints a Windows version. On main it fails with a CalledProcessError from the same UnicodeDecodeError.

Kind

  • tooling: tools, CI, tests, harnesses

Vanilla reference

none

Other projects' code

none

Self-check

**pr_ready** (`tools/pr_ready.py --quick` on DESKTOP-NACG3BC, against origin/main at 125875b84, 57 s)

| Check | Result |
| --- | --- |
| Scope | ✅ 2 files, +22 −2 |
| Cargo.lock | ✅ unchanged |
| Public tree | ✅ |
| Python tests | ✅ 496 passed (56 s) |
| rustfmt | ➖ no Rust change |
| clippy | ➖ no Rust change |
| tests | ➖ no crate touched |
| doc tests | ➖ no crate touched |
| content root tests | ➖ content root untouched |
| tokens.css up to date | ➖ theme untouched |
| launcher rustfmt | ➖ launcher untouched |
| launcher clippy | ➖ launcher untouched |
| launcher tests | ➖ launcher untouched |
| Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses |
| Label | `skip-release` |

Before the fix, python -m unittest discover -s tests under PYTHONUTF8=1 reported FAILED (errors=1); it now reports OK (skipped=2).


🔄 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/horizon-rust/horizon/pull/5210 **Author:** [@iseaprojects](https://github.com/iseaprojects) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@rdbtCVS](https://github.com/rdbtCVS) **Base:** `main` ← **Head:** `fix/5201-windows-version` --- ### 📝 Commits (1) - [`a257a42`](https://github.com/horizon-rust/horizon/commit/a257a4221e39c2cb5c08a97f80b7d482451486ca) tools: read `cmd /C ver` in the console's code page on Windows ### 📊 Changes **2 files changed** (+22 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_perf_bench.py` (+16 -0) 📝 `tools/perf_bench.py` (+6 -2) </details> ### 📄 Description > 🤖 Opened by iseaprojects's AI agent (OpenCode, DeepSeek V4.1 Flash), not by iseaprojects personally. ## What and why Fixes #5201. `perf_bench.windows_version` runs `cmd /C ver` with `text=True`, so subprocess decodes its output with the locale encoding. `pr_ready` runs the Python tests with `PYTHONUTF8=1` (PEP 540), which makes that UTF-8; `cmd` answers in the console's OEM code page (`Versión` on a Spanish Windows), so the reader thread raises `UnicodeDecodeError` and `stdout` is `None`. `.strip()` then raises, and every Windows contributor's self-check shows `Python tests: fail`. Decode with `encoding="oem"` (Python's alias for the console code page on Windows) and `errors="replace"`, and fall back to `platform.version()` when the output is empty. The report's `os_version` keeps the `Microsoft Windows [Version ...]` shape horizon_bench reports. The regression test runs the import in a child process with `PYTHONUTF8=1`, as `pr_ready` does, and asserts it prints a Windows version. On main it fails with a `CalledProcessError` from the same `UnicodeDecodeError`. ## Kind - [x] tooling: tools, CI, tests, harnesses ## Vanilla reference none ## Other projects' code none ## Self-check ```text **pr_ready** (`tools/pr_ready.py --quick` on DESKTOP-NACG3BC, against origin/main at 125875b84, 57 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +22 −2 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 496 passed (56 s) | | rustfmt | ➖ no Rust change | | clippy | ➖ no Rust change | | tests | ➖ no crate touched | | doc tests | ➖ no crate touched | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | `skip-release` | ``` Before the fix, `python -m unittest discover -s tests` under `PYTHONUTF8=1` reported `FAILED (errors=1)`; it now reports `OK (skipped=2)`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:14:34 +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
horizon-rust/horizon#6141
No description provided.