Thoufak
(Thoufak)
October 4, 2022, 2:05pm
1
I have two versions of my program. The older one is running python 3.7 and the newer one is running python 3.9.
This is what the value of platform.platfrom
is in both versions:
Old: Windows-10-10.0.19041-SP0
New: Windows-10-10.0.19044-SP0
The windows version didn’t change. I can reproduce this several times.
Why is there a difference?
The docs don’t give any clue.
Probably because you are using two different versions of Windows?
The one running in Python 3.7 could be Windows-10-10.0.19041-SP0, and the newer one running in Python 3.9 may be on a different machine running Windows-10-10.0.19044-SP0?
If that is not the case, you need to:
check the actual Windows version on both(?) machines – sorry I don’t know how to do that, I don’t use Windows very often;
on both(?) machines, run this minimal script:
import platform
import sys
print(platform.platform(), sys.version, sys.platform)
Copy and paste the exact output of that script into your response. Please do not use a screen shot, photo or other image.
petersuter
(Peter Suter)
October 5, 2022, 6:16am
3
It really is on the same version of Windows:
C:\> ver
Microsoft Windows [Version 10.0.19044.2006]
C:\> py -3.10
Python 3.10.5 (tags/v3.10.5:f377153, Jun 6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from platform import platform, win32_ver
>>> platform()
'Windows-10-10.0.19044-SP0'
>>> win32_ver()
('10', '10.0.19044', 'SP0', 'Multiprocessor Free')
>>> from sys import getwindowsversion
>>> getwindowsversion()
sys.getwindowsversion(major=10, minor=0, build=19044, platform=2, service_pack='')
>>> getwindowsversion().build
19044
>>> getwindowsversion().platform_version
(10, 0, 19041)
>>> exit()
C:\> py -3.9
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from platform import platform, win32_ver
>>> platform()
'Windows-10-10.0.19041-SP0'
>>> win32_ver()
('10', '10.0.19041', 'SP0', 'Multiprocessor Free')
>>> from sys import getwindowsversion
>>> getwindowsversion()
sys.getwindowsversion(major=10, minor=0, build=19044, platform=2, service_pack='')
>>> getwindowsversion().build
19044
>>> getwindowsversion().platform_version
(10, 0, 19041)
It was changed here I guess:
opened 10:42AM - 21 Feb 21 UTC
closed 04:47PM - 22 Apr 21 UTC
type-bug
OS-windows
3.10
3.9
3.8
BPO | [43284](https://bugs.python.org/issue43284)
--- | :---
Nosy | @pfmoore, @t… jguk, @zware, @eryksun, @zooba, @corona10, @miss-islington, @shreyanavigyan, @OrbitalHorizons
PRs | <li>python/cpython#25500</li><li>python/cpython#25523</li><li>python/cpython#25524</li>
<sup>*Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.*</sup>
<details><summary>Show more details</summary><p>
GitHub fields:
```python
assignee = None
closed_at = <Date 2021-04-22.16:47:28.307>
created_at = <Date 2021-02-21.10:42:26.691>
labels = ['3.10', 'type-bug', '3.8', '3.9', 'OS-windows']
title = 'sys.getwindowsversion().platform_version is incorrect'
updated_at = <Date 2021-04-23.18:09:24.687>
user = 'https://bugs.python.org/bugalebugale'
```
bugs.python.org fields:
```python
activity = <Date 2021-04-23.18:09:24.687>
actor = 'steve.dower'
assignee = 'none'
closed = True
closed_date = <Date 2021-04-22.16:47:28.307>
closer = 'steve.dower'
components = ['Windows']
creation = <Date 2021-02-21.10:42:26.691>
creator = 'bugale bugale'
dependencies = []
files = []
hgrepos = []
issue_num = 43284
keywords = ['patch']
message_count = 35.0
messages = ['387450', '387931', '387979', '387980', '387981', '387984', '388814', '388833', '388868', '388925', '388937', '388945', '391221', '391234', '391329', '391333', '391334', '391338', '391346', '391368', '391390', '391392', '391402', '391409', '391410', '391424', '391425', '391461', '391476', '391528', '391611', '391613', '391617', '391706', '391719']
nosy_count = 10.0
nosy_names = ['paul.moore', 'tim.golden', 'zach.ware', 'eryksun', 'steve.dower', 'corona10', 'bugale bugale', 'miss-islington', 'shreyanavigyan', 'Orbital']
pr_nums = ['25500', '25523', '25524']
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue43284'
versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']
```
</p></details>
It doesn’t mean anything except Windows versions are messy.
2 Likes
eryksun
(Eryk Sun)
October 5, 2022, 10:25am
4
The version tuple (major, minor, build) that’s returned by sys.getwindowsversion()
is subject to compatibility mode (e.g. Python is embedded in an application that has no manifest, which runs in Windows 8 compatibility mode). The value of the platform_version
attribute is the file version of “kernel32.dll”, which is not affected by compatibility mode. However, this is based on old advice from Microsoft that’s no longer reliable in practice, at least not for the build number.
In 3.8-3.11, platform.platform()
uses the version that’s reported by the CMD shell’s VER
command. In 3.12, it queries the version using a new _wmi
module (an undocumented, internal module; do not use the _wmi
module directly).
3 Likes
Thoufak
(Thoufak)
October 5, 2022, 10:54am
5
@petersuter , @eryksun
Thank you so much for the detailed information, it’s very helpful.
2 Likes