[ python-Bugs-945665 ] platform.system() Windows inconsistency

SourceForge.net noreply at sourceforge.net
Sat Jun 19 13:20:49 EDT 2004


Bugs item #945665, was opened at 2004-05-01 01:19
Message generated for change (Comment added) made by lemburg
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=945665&group_id=5470

Category: Python Library
Group: Python 2.3
>Status: Closed
Resolution: None
Priority: 5
Submitted By: Guido van Rossum (gvanrossum)
Assigned to: M.-A. Lemburg (lemburg)
Summary: platform.system() Windows inconsistency

Initial Comment:
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).

----------------------------------------------------------------------

>Comment By: M.-A. Lemburg (lemburg)
Date: 2004-06-19 19:20

Message:
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.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2004-06-19 02:07

Message:
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? :-)

----------------------------------------------------------------------

Comment By: Paul Moore (pmoore)
Date: 2004-06-05 18:30

Message:
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.

----------------------------------------------------------------------

Comment By: Johannes Gijsbers (jlgijsbers)
Date: 2004-06-05 16:38

Message:
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

----------------------------------------------------------------------

Comment By: Johannes Gijsbers (jlgijsbers)
Date: 2004-06-05 16:07

Message:
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()

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=945665&group_id=5470



More information about the Python-bugs-list mailing list