From 20cf94f53dfcb1eb3fbc2659c95afdf4301a3186 Mon Sep 17 00:00:00 2001 From: Rolly Calma <115199279+Ghraven@users.noreply.github.com> Date: Fri, 12 Jun 2026 04:58:22 +0800 Subject: [PATCH] fix(platform): read proc version with utf-8 Co-authored-by: Alexandre Teixeira <111787685+alteixeira20@users.noreply.github.com> --- core/platform_compat.py | 2 +- tests/test_platform_compat.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/core/platform_compat.py b/core/platform_compat.py index 1a927702b..efa496ac6 100644 --- a/core/platform_compat.py +++ b/core/platform_compat.py @@ -300,7 +300,7 @@ def is_wsl() -> bool: import sys if sys.platform.startswith("linux") or os.name == "posix": try: - with open("/proc/version", "r") as f: + with open("/proc/version", "r", encoding="utf-8", errors="ignore") as f: if "microsoft" in f.read().lower(): return True except Exception: diff --git a/tests/test_platform_compat.py b/tests/test_platform_compat.py index 2d8c211c0..d3e42b5ae 100644 --- a/tests/test_platform_compat.py +++ b/tests/test_platform_compat.py @@ -83,6 +83,7 @@ def test_is_wsl_true_when_proc_version_mentions_microsoft(monkeypatch): def fake_open(path, mode="r", *args, **kwargs): assert path == "/proc/version" assert mode == "r" + assert kwargs == {"encoding": "utf-8", "errors": "ignore"} return io.StringIO("Linux version 6.6.0 microsoft standard") monkeypatch.setattr("builtins.open", fake_open)