gh-152433: Alternate implementation of _winapi.GetVersion for modern API sets (GH-152694)

zooba <[email protected]>
Newsgroups gmane.comp.python.cvs
Message-ID <[email protected]>
https://github.com/python/cpython/commit/85ab1125f47a05ae3c43bee917e086761784ad4d
commit: 85ab1125f47a05ae3c43bee917e086761784ad4d
branch: main
author: thexai <[email protected]>
committer: zooba <[email protected]>
date: 2026-07-20T12:28:06+01:00
summary:

gh-152433: Alternate implementation of _winapi.GetVersion for modern API sets (GH-152694)

files:
A Misc/NEWS.d/next/Windows/2026-06-30-16-40-00.gh-issue-152433.VaeEwR.rst
M 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
index 00000000000000..00f89ffcbc1c29
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2026-06-30-16-40-00.gh-issue-152433.VaeEwR.rst
@@ -0,0 +1 @@
+``_winapi``: implement ``GetVersion()`` UWP alternative.
diff --git a/Modules/_winapi.c b/Modules/_winapi.c
index 535784adedb24d..a649d84a7925a0 100644
--- a/Modules/_winapi.c
+++ b/Modules/_winapi.c
@@ -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)

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.