Eryk Sun <eryk...@gmail.com> added the comment:

> sys.getwindowsversion() which exposes GetVersionEx() looks fine to me.

In Windows 8+, sys.getwindowsversion() returns a version that can vary from 
6.2.9200 (Windows 8) up to the actual OS version. It depends on the OS versions 
supported by the application manifest -- with 6.2.9200 used when there's no 
application manifest. The platform module uses the shell's VER command because 
it returns the real OS version.

The version number for Windows 11 is 10.0.22000+. The platform module 
misreports this as Windows 10. In msg403452, I suggested a modification to use 
build numbers. In msg404451 Steve said we may as well use the WMI result to 
identify Windows 11 based on the OS caption. If we use WMI, we can choose to 
rely on wmic.exe (deprecated), PowerShell, or implement our own code in C/C++.

> I don't understand why we have to handle XML or JSON and encoding... 

Using JSON or XML (ElementTree) isn't required, if you'd rather parse 
human-readable output. AFAIK, the Win32_OperatingSystem caption is always 
ASCII. 

In general, wmic.exe writes output text to a pipe that's encoded with the 
system OEM code page. pwsh.exe, powershell.exe, and cmd.exe write output text 
to a pipe (from their internal commands/cmdlets) that's encoded using the 
console's output code page. cmd.exe also supports a /U option to use UTF-16.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue45382>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to