Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ca2edce

Browse files
committed
Merged revisions 79294 via svnmerge from
svn+ssh://[email protected]/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. ........
1 parent 37c1f18 commit ca2edce

3 files changed

Lines changed: 29 additions & 1 deletion

File tree

Lib/platform.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1103,7 +1103,11 @@ def uname():
11031103
# http://support.microsoft.com/kb/888731 and
11041104
# http://www.geocities.com/rick_lively/MANUALS/ENV/MSWIN/PROCESSI.HTM
11051105
if not machine:
1106-
machine = os.environ.get('PROCESSOR_ARCHITECTURE', '')
1106+
# WOW64 processes mask the native architecture
1107+
if "PROCESSOR_ARCHITEW6432" in os.environ:
1108+
machine = os.environ.get("PROCESSOR_ARCHITEW6432", '')
1109+
else:
1110+
machine = os.environ.get('PROCESSOR_ARCHITECTURE', '')
11071111
if not processor:
11081112
processor = os.environ.get('PROCESSOR_IDENTIFIER', machine)
11091113

Lib/test/test_platform.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,27 @@ def test_uname(self):
127127
res = platform.uname()
128128
self.assertTrue(any(res))
129129

130+
@unittest.skipUnless(sys.platform.startswith('win'), "windows only test")
131+
def test_uname_win32_ARCHITEW6432(self):
132+
# Issue 7860: make sure we get architecture from the correct variable
133+
# on 64 bit Windows: if PROCESSOR_ARCHITEW6432 exists we should be
134+
# using it, per
135+
# http://blogs.msdn.com/david.wang/archive/2006/03/26/HOWTO-Detect-Process-Bitness.aspx
136+
try:
137+
with test_support.EnvironmentVarGuard() as environ:
138+
if 'PROCESSOR_ARCHITEW6432' in environ:
139+
del environ['PROCESSOR_ARCHITEW6432']
140+
environ['PROCESSOR_ARCHITECTURE'] = 'foo'
141+
platform._uname_cache = None
142+
system, node, release, version, machine, processor = platform.uname()
143+
self.assertEqual(machine, 'foo')
144+
environ['PROCESSOR_ARCHITEW6432'] = 'bar'
145+
platform._uname_cache = None
146+
system, node, release, version, machine, processor = platform.uname()
147+
self.assertEqual(machine, 'bar')
148+
finally:
149+
platform._uname_cache = None
150+
130151
def test_java_ver(self):
131152
res = platform.java_ver()
132153
if sys.platform == 'java':

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ C-API
287287
Library
288288
-------
289289

290+
- Issue #7860: platform.uname now reports the correct 'machine' type
291+
when Python is running in WOW64 mode on 64 bit Windows.
292+
290293
- Issue #3890: Fix recv() and recv_into() on non-blocking SSL sockets.
291294

292295
- Issue #4282: Fix the main function of the profile module for a non-ASCII

0 commit comments

Comments
 (0)