[Python-checkins] r74005 - python/trunk/Lib/platform.py

marc-andre.lemburg python-checkins at python.org
Mon Jul 13 23:28:33 CEST 2009


Author: marc-andre.lemburg
Date: Mon Jul 13 23:28:33 2009
New Revision: 74005

Log:
Use a different VER command output parser to address the localization
issues mentioned in #3410.

Prepare for Windows 7 (still commented out).



Modified:
   python/trunk/Lib/platform.py

Modified: python/trunk/Lib/platform.py
==============================================================================
--- python/trunk/Lib/platform.py	(original)
+++ python/trunk/Lib/platform.py	Mon Jul 13 23:28:33 2009
@@ -464,7 +464,16 @@
 
 _ver_output = re.compile(r'(?:([\w ]+) ([\w.]+) '
                          '.*'
-                         'Version ([\d.]+))')
+                         '\[.* ([\d.]+)\])')
+
+# Examples of VER command output:
+#
+#   Windows 2000:  Microsoft Windows 2000 [Version 5.00.2195]
+#   Windows XP:    Microsoft Windows XP [Version 5.1.2600]
+#   Windows Vista: Microsoft Windows [Version 6.0.6002]
+#
+# Note that the "Version" string gets localized on different
+# Windows versions.
 
 def _syscmd_ver(system='', release='', version='',
 
@@ -596,6 +605,7 @@
     version = '%i.%i.%i' % (maj,min,buildno & 0xFFFF)
     if csd[:13] == 'Service Pack ':
         csd = 'SP' + csd[13:]
+
     if plat == VER_PLATFORM_WIN32_WINDOWS:
         regkey = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion'
         # Try to guess the release name
@@ -610,6 +620,7 @@
                 release = 'postMe'
         elif maj == 5:
             release = '2000'
+
     elif plat == VER_PLATFORM_WIN32_NT:
         regkey = 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion'
         if maj <= 4:
@@ -638,8 +649,12 @@
                         release = 'Vista'
                     else:
                         release = '2008Server'
+            #elif min == 1:
+            #    # Windows 7 release candidate uses version 6.1.7100
+            #    release = '7RC'
             else:
                 release = 'post2008Server'
+
     else:
         if not release:
             # E.g. Win3.1 with win32s
@@ -1114,7 +1129,7 @@
             node = _node()
             machine = ''
 
-        use_syscmd_ver = 01
+        use_syscmd_ver = 1
 
         # Try win32_ver() on win32 platforms
         if system == 'win32':


More information about the Python-checkins mailing list