This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: platform.system() Windows inconsistency
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: lemburg Nosy List: gvanrossum, jlgijsbers, lemburg, paul.moore
Priority: normal Keywords:

Created on 2004-04-30 23:19 by gvanrossum, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (7)
msg20653 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2004-04-30 23:19
On Windows, platform.system() (and platform.uname()
[0]) return 'Windows' or 'Microsoft Windows' depending 
on whether win32api is available or not. This is 
confusing and can lead to hard-to-find bugs where 
testing in one environment doesn't reveal a bug that 
only occurs in another environment.

I believe this hasn't been fixed in Python 2.4 yet  (only 
the XP recognition has been fixed, it is also broken in 
2.3 when win32api was available).
msg20654 - (view) Author: Johannes Gijsbers (jlgijsbers) * (Python triager) Date: 2004-06-05 14:07
Logged In: YES 
user_id=469548

Yep, _syscmd_ver() returns 'Microsoft Windows' while the
default is 'Windows'. Setting the default to Microsoft
Windows seems the easiest way here (putting patch inline
because I can't attach it):

Index: platform.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/platform.py,v
retrieving revision 1.13
diff -u -r1.13 platform.py
--- platform.py	4 May 2004 18:18:59 -0000	1.13
+++ platform.py	5 Jun 2004 13:07:45 -0000
@@ -966,7 +966,7 @@
                     version = '32bit'
                 else:
                     version = '16bit'
-            system = 'Windows'
+            system = 'Microsoft Windows'
 
         elif system[:4] == 'java':
             release,vendor,vminfo,osinfo = java_ver()
msg20655 - (view) Author: Johannes Gijsbers (jlgijsbers) * (Python triager) Date: 2004-06-05 14:38
Logged In: YES 
user_id=469548

New patch, the docs say we should use 'Windows' instead of
'Microsoft Windows', so we do:

Index: platform.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/platform.py,v
retrieving revision 1.13
diff -u -r1.13 platform.py
--- platform.py	4 May 2004 18:18:59 -0000	1.13
+++ platform.py	5 Jun 2004 13:39:10 -0000
@@ -957,6 +957,8 @@
         # platforms
         if use_syscmd_ver:
             system,release,version = _syscmd_ver(system)
+            if string.find(system, 'Microsoft Windows') != -1:
+                system = 'Windows'
 
         # In case we still don't know anything useful,
we'll try to
         # help ourselves
msg20656 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2004-06-05 16:30
Logged In: YES 
user_id=113328

Looks OK to me. Not sure where you found docs which specify
the behaviour, but I'm OK with "Windows".

There's a very small risk of compatibility issues, but as
the module was new in 2.3, and the behaviour was
inconsistent before, I see no reason why this should be an
issue.

I'd recommend committing this.
msg20657 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2004-06-19 00:07
Logged In: YES 
user_id=6380

Note that the patch by jlgijsbers contains some ugly code.
s.find(...) != -1? Yuck!  I think it could just be

  if system == "Microsoft Windows": system = "Windows"

That should work even in Python 1.5.2.  And I don't think
the string would ever be "Microsoft Windows" plus some additive.

And yes, please, check it in. (Or do I have to do it myself? :-)
msg20658 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2004-06-19 17:20
Logged In: YES 
user_id=38388

Checked into CVS HEAD. 

I don't have a Python 2.3 branch checkout, so please check
it in there as well if you have a need. Thanks.
msg20659 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2004-06-22 02:46
Logged In: YES 
user_id=6380

Thanks, I'll leave 2.3 alone, it's just enough of an
incompatibility not to risk it.
History
Date User Action Args
2022-04-11 14:56:03adminsetgithub: 40204
2004-04-30 23:19:35gvanrossumcreate