@@ -1633,6 +1633,7 @@ static PyStructSequence_Field windows_version_fields[] = {
16331633 {"suite_mask" , "Bit mask identifying available product suites" },
16341634 {"product_type" , "System product type" },
16351635 {"platform_version" , "Diagnostic version number" },
1636+ {"device_family" , "'Desktop', 'Xbox' or 'UWP'" },
16361637 {0 }
16371638};
16381639
@@ -1645,13 +1646,10 @@ static PyStructSequence_Desc windows_version_desc = {
16451646 via indexing, the rest are name only */
16461647};
16471648
1649+ #ifdef MS_WINDOWS_DESKTOP
16481650static PyObject *
16491651_sys_getwindowsversion_from_kernel32 (void )
16501652{
1651- #ifndef MS_WINDOWS_DESKTOP
1652- PyErr_SetString (PyExc_OSError , "cannot read version info on this platform" );
1653- return NULL ;
1654- #else
16551653 HANDLE hKernel32 ;
16561654 wchar_t kernel32_path [MAX_PATH ];
16571655 LPVOID verblock ;
@@ -1688,8 +1686,8 @@ _sys_getwindowsversion_from_kernel32(void)
16881686 realBuild = HIWORD (ffi -> dwProductVersionLS );
16891687 PyMem_RawFree (verblock );
16901688 return Py_BuildValue ("(kkk)" , realMajor , realMinor , realBuild );
1691- #endif /* !MS_WINDOWS_DESKTOP */
16921689}
1690+ #endif /* MS_WINDOWS_DESKTOP */
16931691
16941692/* Disable deprecation warnings about GetVersionEx as the result is
16951693 being passed straight through to the caller, who is responsible for
@@ -1719,7 +1717,6 @@ sys_getwindowsversion_impl(PyObject *module)
17191717{
17201718 PyObject * version ;
17211719 int pos = 0 ;
1722- OSVERSIONINFOEXW ver ;
17231720
17241721 if (PyObject_GetOptionalAttrString (module , "_cached_windows_version" , & version ) < 0 ) {
17251722 return NULL ;
@@ -1729,6 +1726,8 @@ sys_getwindowsversion_impl(PyObject *module)
17291726 }
17301727 Py_XDECREF (version );
17311728
1729+ OSVERSIONINFOEXW ver ;
1730+ ZeroMemory (& ver , sizeof (ver ));
17321731 ver .dwOSVersionInfoSize = sizeof (ver );
17331732 if (!GetVersionExW ((OSVERSIONINFOW * ) & ver ))
17341733 return PyErr_SetFromWindowsErr (0 );
@@ -1756,6 +1755,7 @@ sys_getwindowsversion_impl(PyObject *module)
17561755 SET_VERSION_INFO (PyLong_FromLong (ver .wSuiteMask ));
17571756 SET_VERSION_INFO (PyLong_FromLong (ver .wProductType ));
17581757
1758+ #if defined(MS_WINDOWS_DESKTOP )
17591759 // GetVersion will lie if we are running in a compatibility mode.
17601760 // We need to read the version info from a system file resource
17611761 // to accurately identify the OS version. If we fail for any reason,
@@ -1775,6 +1775,14 @@ sys_getwindowsversion_impl(PyObject *module)
17751775 }
17761776
17771777 SET_VERSION_INFO (realVersion );
1778+ SET_VERSION_INFO (PyUnicode_FromString ("Desktop" ));
1779+ #elif defined(MS_WINDOWS_GAMES )
1780+ SET_VERSION_INFO (Py_BuildValue ("(kkk)" , ver .dwMajorVersion , ver .dwMinorVersion , ver .dwBuildNumber ));
1781+ SET_VERSION_INFO (PyUnicode_FromString ("Xbox" ));
1782+ #else
1783+ SET_VERSION_INFO (Py_BuildValue ("(kkk)" , ver .dwMajorVersion , ver .dwMinorVersion , ver .dwBuildNumber ));
1784+ SET_VERSION_INFO (PyUnicode_FromString ("UWP" ));
1785+ #endif
17781786
17791787#undef SET_VERSION_INFO
17801788
0 commit comments