bpo-45382: test.pythoninfo logs more Windows versions (GH-30817) · python/cpython@b0898f4

GitHub

@@ -729,6 +729,45 @@ def collect_windows(info_add):

729729except (ImportError, AttributeError):

730730pass

731731732+importsubprocess

733+try:

734+proc=subprocess.Popen(["wmic", "os", "get", "Caption,Version", "/value"],

735+stdout=subprocess.PIPE,

736+stderr=subprocess.PIPE,

737+text=True)

738+output, stderr=proc.communicate()

739+ifproc.returncode:

740+output=""

741+exceptOSError:

742+pass

743+else:

744+forlineinoutput.splitlines():

745+line=line.strip()

746+ifline.startswith('Caption='):

747+line=line.removeprefix('Caption=').strip()

748+ifline:

749+info_add('windows.version_caption', line)

750+elifline.startswith('Version='):

751+line=line.removeprefix('Version=').strip()

752+ifline:

753+info_add('windows.version', line)

754+755+try:

756+proc=subprocess.Popen(["ver"], shell=True,

757+stdout=subprocess.PIPE,

758+stderr=subprocess.PIPE,

759+text=True)

760+output=proc.communicate()[0]

761+ifproc.returncode:

762+output=""

763+exceptOSError:

764+return

765+else:

766+output=output.strip()

767+line=output.splitlines()[0]

768+ifline:

769+info_add('windows.ver', line)

770+732771733772defcollect_fips(info_add):

734773try: