[Python-checkins] r64233 - in python/trunk: Lib/platform.py Misc/ACKS Misc/NEWS

benjamin.peterson python-checkins at python.org
Fri Jun 13 17:11:50 CEST 2008


Author: benjamin.peterson
Date: Fri Jun 13 17:11:50 2008
New Revision: 64233

Log:
platform.uname now tries to fill empty values even when os.uname is present


Modified:
   python/trunk/Lib/platform.py
   python/trunk/Misc/ACKS
   python/trunk/Misc/NEWS

Modified: python/trunk/Lib/platform.py
==============================================================================
--- python/trunk/Lib/platform.py	(original)
+++ python/trunk/Lib/platform.py	Fri Jun 13 17:11:50 2008
@@ -1090,23 +1090,30 @@
 
     """
     global _uname_cache
+    no_os_uname = 0
 
     if _uname_cache is not None:
         return _uname_cache
 
+    processor = ''
+
     # Get some infos from the builtin os.uname API...
     try:
         system,node,release,version,machine = os.uname()
-
     except AttributeError:
-        # Hmm, no uname... we'll have to poke around the system then.
-        system = sys.platform
-        release = ''
-        version = ''
-        node = _node()
-        machine = ''
-        processor = ''
-        use_syscmd_ver = 1
+        no_os_uname = 1
+
+    if no_os_uname or not filter(None, (system, node, release, version, machine)):
+        # Hmm, no there is either no uname or uname has returned
+        #'unknowns'... we'll have to poke around the system then.
+        if no_os_uname:
+            system = sys.platform
+            release = ''
+            version = ''
+            node = _node()
+            machine = ''
+
+        use_syscmd_ver = 01
 
         # Try win32_ver() on win32 platforms
         if system == 'win32':
@@ -1117,8 +1124,10 @@
             # available on Win XP and later; see
             # http://support.microsoft.com/kb/888731 and
             # http://www.geocities.com/rick_lively/MANUALS/ENV/MSWIN/PROCESSI.HTM
-            machine = os.environ.get('PROCESSOR_ARCHITECTURE', '')
-            processor = os.environ.get('PROCESSOR_IDENTIFIER', machine)
+            if not machine:
+                machine = os.environ.get('PROCESSOR_ARCHITECTURE', '')
+            if not processor:
+                processor = os.environ.get('PROCESSOR_IDENTIFIER', machine)
 
         # Try the 'ver' system command available on some
         # platforms
@@ -1160,30 +1169,28 @@
             release,(version,stage,nonrel),machine = mac_ver()
             system = 'MacOS'
 
-    else:
-        # System specific extensions
-        if system == 'OpenVMS':
-            # OpenVMS seems to have release and version mixed up
-            if not release or release == '0':
-                release = version
-                version = ''
-            # Get processor information
-            try:
-                import vms_lib
-            except ImportError:
-                pass
-            else:
-                csid, cpu_number = vms_lib.getsyi('SYI$_CPU',0)
-                if (cpu_number >= 128):
-                    processor = 'Alpha'
-                else:
-                    processor = 'VAX'
+    # System specific extensions
+    if system == 'OpenVMS':
+        # OpenVMS seems to have release and version mixed up
+        if not release or release == '0':
+            release = version
+            version = ''
+        # Get processor information
+        try:
+            import vms_lib
+        except ImportError:
+            pass
         else:
-            # Get processor information from the uname system command
-            processor = _syscmd_uname('-p','')
+            csid, cpu_number = vms_lib.getsyi('SYI$_CPU',0)
+            if (cpu_number >= 128):
+                processor = 'Alpha'
+            else:
+                processor = 'VAX'
+    if not processor:
+        # Get processor information from the uname system command
+        processor = _syscmd_uname('-p','')
 
-    # 'unknown' is not really any useful as information; we'll convert
-    # it to '' which is more portable
+    #If any unknowns still exist, replace them with ''s, which are more portable
     if system == 'unknown':
         system = ''
     if node == 'unknown':

Modified: python/trunk/Misc/ACKS
==============================================================================
--- python/trunk/Misc/ACKS	(original)
+++ python/trunk/Misc/ACKS	Fri Jun 13 17:11:50 2008
@@ -675,6 +675,7 @@
 Monty Taylor
 Amy Taylor
 Tobias Thelen
+James Thomas
 Robin Thomas
 Eric Tiedemann
 Tracy Tims

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Fri Jun 13 17:11:50 2008
@@ -84,6 +84,9 @@
 Library
 -------
 
+- Issue #2912: platform.uname now tries to determine unknown information even if
+  os.uname exists.
+
 - The rfc822 module has been deprecated for removal in 3.0.
 
 - The mimetools module has been deprecated for removal in 3.0.


More information about the Python-checkins mailing list