From: thexai <58434170+thexai@users.noreply.github.com> Date: Mon, 20 Jul 2026 11:28:06 +0000 (+0200) Subject: gh-152433: Alternate implementation of _winapi.GetVersion for modern API sets (GH... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85ab1125f47a05ae3c43bee917e086761784ad4d;p=thirdparty%2FPython%2Fcpython.git gh-152433: Alternate implementation of _winapi.GetVersion for modern API sets (GH-152694) --- 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 000000000000..00f89ffcbc1c --- /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 535784adedb2..a649d84a7925 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)