2

In Python 3.8.10 i cannot get the correct Windows release, i'm running Windows 11 Insider Preview, but the output says it Windows 10

Bug

Any WorkAround?

Edit: for now the only way i found to detect W11 is with

wmic os get name
Pedro
  • 360
  • 3
  • 13

2 Answers2

4

the solution i ended up following:

def IsWin11():
    if sys.getwindowsversion().build >= 22000:
        return True
    else:
        return False
Martí Climent
  • 407
  • 4
  • 9
Pedro
  • 360
  • 3
  • 13
  • According to MS, Windows 11 build numbers start at `22000`, not `20000`. https://learn.microsoft.com/en-us/windows/release-health/windows11-release-information?source=recommendations – Dustin Wyatt Apr 04 '23 at 20:33
1

The platform.release() call traces to win32_ver() which then calls the C function sys_getwindowsversion_impl().

That C call simply pulls the version of kernel32.dll file i.e. not of the Windows itself by utilizing the GetFileVersionInfoW() + VerQueryValueW() Win32 API functions.

So until kernel32.dll file's version changes it'll remain Windows 10. Check manually if the result matches on that system and if it does not, open a bug for CPython.

Regarding whether this is the correct implementation or not I'd say is debatable. Apparently it was in the past but now it's not, so I guess just use ctypes for GetProductInfo() or pull it from the registry.

However, you are using a preview version, which is one of the reasons the version might be "incorrect" because perhaps the Windows developers intend it to still be 10 instead of 11 and somewhere in the system there's a flag saying it's a "10" + "preview".

Peter Badida
  • 11,310
  • 10
  • 44
  • 90
  • I tested the C Functions but gives the same value, the problem is really with kernel32 version, the only way i found to detect Win11 is with: wmic os get name – Pedro Aug 24 '21 at 01:07