]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-152433: Alternate implementation of _winapi.GetVersion for modern API sets (GH...
authorthexai <58434170+thexai@users.noreply.github.com>
Mon, 20 Jul 2026 11:28:06 +0000 (13:28 +0200)
committerGitHub <noreply@github.com>
Mon, 20 Jul 2026 11:28:06 +0000 (12:28 +0100)
Misc/NEWS.d/next/Windows/2026-06-30-16-40-00.gh-issue-152433.VaeEwR.rst [new file with mode: 0644]
Modules/_winapi.c

diff --git a/Misc/NEWS.d/next/Windows/2026-06-30-16-40-00.gh-issue-152433.VaeEwR.rst b/Misc/NEWS.d/next/Windows/2026-06-30-16-40-00.gh-issue-152433.VaeEwR.rst
new file mode 100644 (file)
index 0000000..00f89ff
--- /dev/null
@@ -0,0 +1 @@
+``_winapi``: implement ``GetVersion()`` UWP alternative.
index 535784adedb24d8f3afc5556d74a2c21517ca453..a649d84a7925a04bf4c5108b6d28e60104ad73aa 100644 (file)
@@ -1739,7 +1739,19 @@ _winapi_GetVersion_impl(PyObject *module)
 #pragma warning(disable:4996)
 
 {
+#ifdef MS_WINDOWS_DESKTOP
     return GetVersion();
+#else
+    OSVERSIONINFOW version_info;
+    ZeroMemory(&version_info, sizeof(version_info));
+    version_info.dwOSVersionInfoSize = sizeof(version_info);
+    if (GetVersionExW(&version_info)) {
+        return version_info.dwMinorVersion |
+            (version_info.dwMajorVersion << 8) |
+            (version_info.dwBuildNumber << 16);
+    }
+    return 0;
+#endif
 }
 
 #pragma warning(pop)