mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-16 17:55:26 -04:00
fix(platform): read proc version with utf-8
Co-authored-by: Alexandre Teixeira <111787685+alteixeira20@users.noreply.github.com>
This commit is contained in:
@@ -300,7 +300,7 @@ def is_wsl() -> bool:
|
|||||||
import sys
|
import sys
|
||||||
if sys.platform.startswith("linux") or os.name == "posix":
|
if sys.platform.startswith("linux") or os.name == "posix":
|
||||||
try:
|
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():
|
if "microsoft" in f.read().lower():
|
||||||
return True
|
return True
|
||||||
except Exception:
|
except Exception:
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ def test_is_wsl_true_when_proc_version_mentions_microsoft(monkeypatch):
|
|||||||
def fake_open(path, mode="r", *args, **kwargs):
|
def fake_open(path, mode="r", *args, **kwargs):
|
||||||
assert path == "/proc/version"
|
assert path == "/proc/version"
|
||||||
assert mode == "r"
|
assert mode == "r"
|
||||||
|
assert kwargs == {"encoding": "utf-8", "errors": "ignore"}
|
||||||
return io.StringIO("Linux version 6.6.0 microsoft standard")
|
return io.StringIO("Linux version 6.6.0 microsoft standard")
|
||||||
|
|
||||||
monkeypatch.setattr("builtins.open", fake_open)
|
monkeypatch.setattr("builtins.open", fake_open)
|
||||||
|
|||||||
Reference in New Issue
Block a user