New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
platform system may be Windows or Microsoft since Vista #45423
Comments
SUMMARY: 'Microsoft' is the platform.system() of Vista Windows, whereas 'Windows' STEPS TO REPRODUCE & ACTUAL RESULTS: Run 2.5.1 Python in a Vista and see: >>> import platform
>>> platform.system()
>>>
'Microsoft'
>>> EXPECTED RESULTS: >>> import platform
>>> platform.system()
'Windows'
>>> WORKAROUND: Write new Python source code like: if platform.system() in ('Windows', 'Microsoft'):
if not (platform.system() in ('Windows', 'Microsoft')): in place of obsolete Python source code like: if platform.system() == 'Windows': # Microsoft
if platform.system() != 'Windows': # Microsoft REGRESSION/ ISOLATION: Seen by me in an Enterprise Vista. Indexed by Google as reported by http://mail.python.org/pipermail/patches/2007-June/022947.html Patches item bpo-1726668, was opened at 2007-05-28 03:23 On Microsoft Vista platform.system() returns 'Microsoft' and Under Microsoft Windows XP SP2 platform.system() returns 'Windows' and This is problem was caused by a change in the output of the "ver" NOTES: There is no fixing all of this? Cross-platform scripts actually will misbehave across the large Question: Is it better to leave this feature as is, so that everyone Question: Why are we screen-scraping the Ver command, instead of calling |
Wow. I think that platform.system() should return "Windows" for both XP |
Attached a patch which I *THINK* fixes this, but I don't run Windows. |
Supplied patch passes "make test", BTW. |
I recommend we reject this first draft of the python-trunk- I reason as follows ... ACTUAL RESULTS OF 2.5.1 PLUS PATCH IN VISTA WINDOWS: >>> import platform
>>> ...
>>> platform.uname()
('Microsoft', '[redacted]', 'Windows', '6.0.6000', '', '')
>>> platform.system()
'Windows'
>>> platform.release()
'Windows'
>>> EXPECTED RESULTS OF 2.5.1 PLUS PATCH IN VISTA WINDOWS: >>> import platform
>>> ...
>>> platform.uname()
('Windows', '[redacted]', 'Vista', '6.0.6000', '', '')
>>> platform.system()
'Windows'
>>> platform.release()
'Vista'
>>> ACTUAL RESULTS OF 2.5 IN SP2 XP WINDOWS: >>> import platform
>>> ...
>>> platform.uname()
('Windows', '[redacted]', 'XP', '5.1.2600', '', '')
>>> platform.system()
'Windows'
>>> platform.release()
'XP'
>>> DISCUSSION: Four thoughts: I think we meant to write { unameInfo[2] == 'Windows' } where we wrote To run the patch I created a copy of platform.py in the same folder and I think we should substitute a different kind of patch, a patch to I'd like us to hold to such cross-platform invariants as: ( platform.system() == platform.uname()[0] ) ( platform.system() == platform.uname()[2] ) Out on the web I see that we have documented these invariants. I quote: """ 14.12.1 Cross Platform uname() ... Returns a tuple of strings (system, node, release, version, """ 2007-09-17 fetch of http://docs.python.org/lib/node442.html I don't think we can totally fix this trouble in code: we have Specifically, I think we should also fix the doc to admit the hereafter if not (platform.system() in ('Microsoft', 'Windows')): |
Attached is a patch that fixes uname() instead of the individual What about adding a "isWindows()" sort of method that does the right |
A couple of notes:
Any other changes to accommodate for differences between used marketing |
Shall I commit my "v2" patch then, to 2.5.2 and trunk? It has the code |
Yes, please. Thanks. |
Commited in trunk revision 58183 and 25-maint revision 58184. |
Works for me. I tried python-trunk-vistaplatform-v2.patch in one sample of 2006-11 >>> import platform
>>> platform.uname()
('Windows', '[redacted]', 'Vista', '6.0.6000', '', '')
>>> platform.system()
'Windows'
>>> platform.version()
'6.0.6000'
>>> |
--- USAGE: I agree we should let people in future write: if not platform.system('Windows'): rather than: if not (platform.system() in ('Microsoft', 'Windows')): now that our people can no longer rely on Python in Vista correctly if platform.system() != 'Windows': --- DRAFT SPEC: platform.system(name = None) returns the system name if name is None, The string 'Mac OS X' is a well-known alias for the system 'Darwin'. The string 'Windows' is a well-known alias for the system 'Microsoft' The system name is itself a well-known alias of the system name. For Etc. |
Pat, we already have system_alias() for exactly the purpose you suggested. Software relying on platform.system() reporting "Vista" will have to use |
Thanks for the cultural education of 2.5.1 isn't supposed to work, I Also I'm glad to hear this is fixed for 2.5.2 already. Sorry I'm too new & ignorant to understand why you believe this is if not platform.system('Linux'): Do we have a way to say things like that? My first Googles, tried here now at Mac OS X, give me useless >>> platform.platform(aliased=True)
'Darwin-9.0.0b5-i386-32bit'
>>> platform.system_alias(platform.system(), platform.release(),
platform.version())
('Darwin', '9.0.0b5', 'Darwin Kernel Version 9.0.0b5: Fri Aug 17
17:24:24 PDT 2007; root:xnu-1182~1/RELEASE_I386')
>>> Practically speaking, I was getting by ok with: if platform.system() != 'Windows': Until that broke in Vista plus 2.5.1. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: