]> granicus.if.org Git - python/commitdiff
Merged revisions 79294 via svnmerge from
authorR. David Murray <rdmurray@bitdance.com>
Mon, 22 Mar 2010 17:48:48 +0000 (17:48 +0000)
committerR. David Murray <rdmurray@bitdance.com>
Mon, 22 Mar 2010 17:48:48 +0000 (17:48 +0000)
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r79294 | r.david.murray | 2010-03-22 11:55:09 -0400 (Mon, 22 Mar 2010) | 4 lines

  Issue #7860: platform.uname now reports the correct 'machine' type
  when Python is running in WOW64 mode on 64 bit Windows.  Patch by
  Brian Curtin.
........

Lib/platform.py
Lib/test/test_platform.py
Misc/NEWS

index 7d392502a123e2aca63a6548a27d2c0243adc18e..aa256dca92f51bdbe25c0563fa600d213ab21e36 100755 (executable)
@@ -1103,7 +1103,11 @@ def uname():
             # http://support.microsoft.com/kb/888731 and
             # http://www.geocities.com/rick_lively/MANUALS/ENV/MSWIN/PROCESSI.HTM
             if not machine:
-                machine = os.environ.get('PROCESSOR_ARCHITECTURE', '')
+                # WOW64 processes mask the native architecture
+                if "PROCESSOR_ARCHITEW6432" in os.environ:
+                    machine = os.environ.get("PROCESSOR_ARCHITEW6432", '')
+                else:
+                    machine = os.environ.get('PROCESSOR_ARCHITECTURE', '')
             if not processor:
                 processor = os.environ.get('PROCESSOR_IDENTIFIER', machine)
 
index 98751624db32743e303e431deb8191dc45380581..710877955113581c0f1e3b78e2fb05d7e78f23f4 100644 (file)
@@ -127,6 +127,27 @@ class PlatformTest(unittest.TestCase):
         res = platform.uname()
         self.assertTrue(any(res))
 
+    @unittest.skipUnless(sys.platform.startswith('win'), "windows only test")
+    def test_uname_win32_ARCHITEW6432(self):
+        # Issue 7860: make sure we get architecture from the correct variable
+        # on 64 bit Windows: if PROCESSOR_ARCHITEW6432 exists we should be
+        # using it, per
+        # http://blogs.msdn.com/david.wang/archive/2006/03/26/HOWTO-Detect-Process-Bitness.aspx
+        try:
+            with test_support.EnvironmentVarGuard() as environ:
+                if 'PROCESSOR_ARCHITEW6432' in environ:
+                    del environ['PROCESSOR_ARCHITEW6432']
+                environ['PROCESSOR_ARCHITECTURE'] = 'foo'
+                platform._uname_cache = None
+                system, node, release, version, machine, processor = platform.uname()
+                self.assertEqual(machine, 'foo')
+                environ['PROCESSOR_ARCHITEW6432'] = 'bar'
+                platform._uname_cache = None
+                system, node, release, version, machine, processor = platform.uname()
+                self.assertEqual(machine, 'bar')
+        finally:
+            platform._uname_cache = None
+
     def test_java_ver(self):
         res = platform.java_ver()
         if sys.platform == 'java':
index a27dd11f92b6742391257bf436c1e63f607173b6..8d4706da15313d17d8f938efa20f5e35b9b504c3 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -287,6 +287,9 @@ C-API
 Library
 -------
 
+- Issue #7860: platform.uname now reports the correct 'machine' type
+  when Python is running in WOW64 mode on 64 bit Windows.
+
 - Issue #3890: Fix recv() and recv_into() on non-blocking SSL sockets.
 
 - Issue #4282: Fix the main function of the profile module for a non-ASCII