Skip to content

Commit afd071c

Browse files
committed
Fix windows-11 detection for non-float platform.release() values (fixes #639)
1 parent 29f355b commit afd071c

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

meshtastic/tests/test_util.py

+7
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,13 @@ def test_is_windows11_false_win8_1(patched_platform, patched_release):
442442
patched_platform.assert_called()
443443
patched_release.assert_called()
444444

445+
@patch("platform.release", return_value="2022Server")
446+
@patch("platform.system", return_value="Windows")
447+
def test_is_windows11_false_winserver(patched_platform, patched_release):
448+
"""Test is_windows11()"""
449+
assert is_windows11() is False
450+
patched_platform.assert_called()
451+
patched_release.assert_called()
445452

446453
@pytest.mark.unit
447454
@patch("platform.system", return_value="Linux")

meshtastic/util.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -521,15 +521,15 @@ def is_windows11() -> bool:
521521
"""Detect if Windows 11"""
522522
is_win11: bool = False
523523
if platform.system() == "Windows":
524-
if float(platform.release()) >= 10.0:
525-
patch = platform.version().split(".")[2]
526-
# in case they add some number suffix later, just get first 5 chars of patch
527-
patch = patch[:5]
528-
try:
524+
try:
525+
if float(platform.release()) >= 10.0:
526+
patch = platform.version().split(".")[2]
527+
# in case they add some number suffix later, just get first 5 chars of patch
528+
patch = patch[:5]
529529
if int(patch) >= 22000:
530530
is_win11 = True
531-
except Exception as e:
532-
print(f"problem detecting win11 e:{e}")
531+
except Exception as e:
532+
print(f"problem detecting win11 e:{e}")
533533
return is_win11
534534

535535

0 commit comments

Comments
 (0)