Skip to content

Commit 2efa7d0

Browse files
authored
Merge 268edb6 into 69bfb94
2 parents 69bfb94 + 268edb6 commit 2efa7d0

3 files changed

Lines changed: 32 additions & 16 deletions

File tree

source/winVersion.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# A part of NonVisual Desktop Access (NVDA)
2-
# Copyright (C) 2006-2023 NV Access Limited, Bill Dengler, Joseph Lee
2+
# Copyright (C) 2006-2024 NV Access Limited, Bill Dengler, Joseph Lee
33
# This file is covered by the GNU General Public License.
44
# See the file COPYING for more details.
55

@@ -10,7 +10,7 @@
1010
When working on this file, consider moving to winAPI.
1111
"""
1212

13-
from typing import Optional, Dict, Any
13+
from typing import Any
1414
import sys
1515
import os
1616
import functools
@@ -23,7 +23,7 @@
2323
# Records a mapping between Windows builds and release names.
2424
# These include build 10240 for Windows 10 1507 and releases with multiple release builds.
2525
# These are applicable to Windows 10 and later as they report the same system version (10.0).
26-
_BUILDS_TO_RELEASE_NAMES: Dict[int, str] = {
26+
_BUILDS_TO_RELEASE_NAMES: dict[int, str] = {
2727
10240: "Windows 10 1507",
2828
10586: "Windows 10 1511",
2929
14393: "Windows 10 1607",
@@ -81,7 +81,7 @@ def __init__(
8181
major: int = 0,
8282
minor: int = 0,
8383
build: int = 0,
84-
releaseName: Optional[str] = None,
84+
releaseName: str | None = None,
8585
servicePack: str = "",
8686
productType: str = "",
8787
processorArchitecture: str = ""
@@ -105,18 +105,22 @@ def _getWindowsReleaseName(self) -> str:
105105
On server systems, unless noted otherwise, client release names will be returned.
106106
For example, 'Windows 10 1809' will be returned on Server 2019 systems.
107107
"""
108-
if (self.major, self.minor) == (6, 3):
109-
return "Windows 8.1"
110-
elif self.major == 10:
111-
# From Version 1511 (build 10586), release Id/display version comes from Windows Registry.
108+
match (self.major, self.minor):
109+
case (6, 3):
110+
return "Windows 8.1"
111+
# From Windows 10 1511 (build 10586), release Id/display version comes from Windows Registry.
112112
# However there are builds with no release name (Version 1507/10240)
113113
# or releases with different builds.
114114
# Look these up first before asking Windows Registry.
115-
if self.build in _BUILDS_TO_RELEASE_NAMES:
115+
case (10, 0) if self.build in _BUILDS_TO_RELEASE_NAMES:
116116
return _BUILDS_TO_RELEASE_NAMES[self.build]
117-
return "Windows 10 unknown"
118-
else:
119-
return "Windows release unknown"
117+
# #15992: 10.0.22000 or later is Windows 11.
118+
case (10, 0) if self.build >= 22000:
119+
return "Windows 11 unknown"
120+
case (10, 0):
121+
return "Windows 10 unknown"
122+
case _:
123+
return "Windows release unknown"
120124

121125
def __repr__(self):
122126
winVersionText = [self.releaseName]

tests/unit/test_winVersion.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# A part of NonVisual Desktop Access (NVDA)
22
# This file is covered by the GNU General Public License.
33
# See the file COPYING for more details.
4-
# Copyright (C) 2021-2022 NV Access Limited, Joseph Lee
4+
# Copyright (C) 2021-2024 NV Access Limited, Joseph Lee
55

66
"""Unit tests for the Windows version module."""
77

@@ -31,10 +31,10 @@ def test_getWinVerFromNonExistentRelease(self):
3131

3232
def test_moreRecentWinVer(self):
3333
# Specifically to test operators.
34-
minimumWinVer = winVersion.WIN7_SP1
35-
audioDuckingAvailable = winVersion.WIN8
34+
minimumWinVer = winVersion.WIN81
35+
emojiPanelIntroduced = winVersion.WIN10_1709
3636
self.assertGreaterEqual(
37-
audioDuckingAvailable, minimumWinVer
37+
emojiPanelIntroduced, minimumWinVer
3838
)
3939

4040
def test_winVerKnownReleaseNameForWinVersionConstant(self):
@@ -85,3 +85,12 @@ def test_winVerProcessorArchitecture(self):
8585
# Use os.environ to guard against platform.machine() giving odd results.
8686
actualArchitecture = os.environ.get("PROCESSOR_ARCHITEW6432", os.environ["PROCESSOR_ARCHITECTURE"])
8787
self.assertEqual(winVersion.getWinVer().processorArchitecture, actualArchitecture)
88+
89+
def test_winVerUnknownWin11BuildToReleaseName(self):
90+
# Despite system version being 10.0, build 22000 or later is Windows 11.
91+
# See if build 25398 (zinc milestone) is recognized as a Windows 11 "unknown" release.
92+
zincMajor, zincMinor, zincBuild = 10, 0, 25398
93+
win11ZincInfo = winVersion.WinVersion(
94+
major=zincMajor, minor=zincMinor, build=zincBuild
95+
)
96+
self.assertEqual(win11ZincInfo.releaseName, "Windows 11 unknown")

user_docs/en/changes.t2t

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ What's New in NVDA
2121
== Changes for Developers ==
2222
Please refer to [the developer guide https://www.nvaccess.org/files/nvda/documentation/developerGuide.html#API] for information on NVDA's API deprecation and removal process.
2323

24+
- Instantiating ``winVersion.WinVersion`` objects with unknown Windows versions above 10.0.22000 such as 10.0.25398 returns "Windows 11 unknown" instead of "Windows 10 unknown" for release name. (#15992, @josephsl)
25+
-
26+
2427
=== Deprecations ===
2528

2629

0 commit comments

Comments
 (0)