Title: Try to avoid invoking a new process to determine the Windows version in the platform module · Issue #129294 · python/cpython · GitHub
Open Graph Title: Try to avoid invoking a new process to determine the Windows version in the platform module · Issue #129294 · python/cpython
X Title: Try to avoid invoking a new process to determine the Windows version in the platform module · Issue #129294 · python/cpython
Description: Feature or enhancement Proposal: In Lib/platform.py, there's a code aimed to determine the Windows version python runs in. for cmd in ('ver', 'command /c ver', 'cmd /c ver'): try: info = subprocess.check_output(cmd, stdin=subprocess.DEVN...
Open Graph Description: Feature or enhancement Proposal: In Lib/platform.py, there's a code aimed to determine the Windows version python runs in. for cmd in ('ver', 'command /c ver', 'cmd /c ver'): try: info = subprocess...
X Description: Feature or enhancement Proposal: In Lib/platform.py, there's a code aimed to determine the Windows version python runs in. for cmd in ('ver', 'command /c ver', 'cmd /c ver...
Opengraph URL: https://github.com/python/cpython/issues/129294
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Try to avoid invoking a new process to determine the Windows version in the platform module","articleBody":"# Feature or enhancement\n\n### Proposal:\n\nIn Lib/platform.py, there's a code aimed to determine the Windows version python runs in.\n\n```python\n for cmd in ('ver', 'command /c ver', 'cmd /c ver'):\n try:\n info = subprocess.check_output(cmd,\n stdin=subprocess.DEVNULL,\n stderr=subprocess.DEVNULL,\n text=True,\n encoding=\"locale\",\n shell=True)\n```\n\nAs much as I understand, one shouldn't invoke whole new process just to question what OS version he runs at.\n\nso just before invoking cmd.exe, we will try to question winapi directly.\n```python\n# Load ntdll.dll and call RtlGetVersion\n ntdll = ctypes.WinDLL(\"ntdll\")\n rtl_get_version = ntdll.RtlGetVersion\n rtl_get_version(ctypes.byref(os_version))\n```\n\n### Has this already been discussed elsewhere?\n\nNo response given\n\n### Links to previous discussion of this feature:\n\n_No response_\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-129295\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/tomergert","@type":"Person","name":"tomergert"},"datePublished":"2025-01-25T12:03:59.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/129294/cpython/issues/129294"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5916ec06-aa05-d43d-958d-c49004bfed4e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 860C:2677B0:60B776:810432:6A529F02 |
| html-safe-nonce | cb1b1a9bcb16586792d609b9e44691d1e8f84da7502d3a2e6ecb443e8e7f64f7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NjBDOjI2NzdCMDo2MEI3NzY6ODEwNDMyOjZBNTI5RjAyIiwidmlzaXRvcl9pZCI6IjIyMjkxOTUxNDA1OTcxOTQ0OTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5384e740c8761d24167e7a5ee142657434e5bb688563b24c3f45a4656937d4f9 |
| hovercard-subject-tag | issue:2810947536 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/129294/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ff8db5bdfb401f57c37011dd7adad0d1f26fe7c66bb56e07e4af57ab82abb3bc/python/cpython/issues/129294 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ff8db5bdfb401f57c37011dd7adad0d1f26fe7c66bb56e07e4af57ab82abb3bc/python/cpython/issues/129294 |
| og:image:alt | Feature or enhancement Proposal: In Lib/platform.py, there's a code aimed to determine the Windows version python runs in. for cmd in ('ver', 'command /c ver', 'cmd /c ver'): try: info = subprocess... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tomergert |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width