Skip to content

Use the _wmi module in test.pythoninfo#152824

Draft
vstinner wants to merge 8 commits into
python:mainfrom
vstinner:pythoninfo_wmi
Draft

Use the _wmi module in test.pythoninfo#152824
vstinner wants to merge 8 commits into
python:mainfrom
vstinner:pythoninfo_wmi

Conversation

@vstinner

@vstinner vstinner commented Jul 1, 2026

Copy link
Copy Markdown
Member

On Windows, replace wmic command with _wmi module to get the operating system caption and version.

The wmic tool is deprecated since January 2024:
https://techcommunity.microsoft.com/blog/windows-itpro-blog/wmi-command-line-wmic-utility-deprecation-next-steps/4039242

For example, it's no longer installed in Windows images on GitHub Action.

Fix also run_command(): no longer try to spawn a subprocess if the platform doesn't support subprocess. It avoids logging run_command() errors.

On Windows, replace wmic command with _wmi module to get the
operating system caption and version.

The wmic tool is deprecated since January 2024:
https://techcommunity.microsoft.com/blog/windows-itpro-blog/wmi-command-line-wmic-utility-deprecation-next-steps/4039242

For example, it's no longer installed in Windows images on GitHub
Action.

Fix also run_command(): no longer try to spawn a subprocess if the
platform doesn't support subprocess. It avoids logging run_command()
errors.
@vstinner

vstinner commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

I checked test.pythoninfo output of the GitHub Action "Windows / Build and test (x64, tail-call)" job.

Before:

windows.ver: Microsoft Windows [Version 10.0.26100.32995]

With this PR:

windows.ver: Microsoft Windows [Version 10.0.26100.32995]
windows.version: 10.0.26100
windows.version_caption: Microsoft Windows Server 2025 Datacenter

With this change, test.pythoninfo is able to get the operating system caption and version even if wmic is not installed.

@vstinner vstinner marked this pull request as draft July 1, 2026 22:01
@vstinner

vstinner commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

!buildbot Windows

@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @vstinner for commit bb6099d 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F152824%2Fmerge

The command will test the builders whose names match following regular expression: Windows

The builders matched are:

  • ARM64 Windows Non-Debug PR
  • ARM64 Windows PR
  • AMD64 Windows PGO NoGIL PR
  • AMD64 Windows11 Non-Debug PR
  • AMD64 Windows11 Refleaks PR
  • AMD64 Windows10 PR
  • AMD64 Windows PGO PR
  • AMD64 Windows PGO NoGIL Tailcall PR
  • AMD64 Windows Server 2022 NoGIL PR
  • AMD64 Windows PGO Tailcall PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants