[issue10735] platform.architecture() gives misleading results for OS X multi-architecture executables

Ned Deily report at bugs.python.org
Sun Dec 19 08:10:39 CET 2010


Ned Deily <nad at acm.org> added the comment:

The attached patches for py3k (3.2+) and 2.7 correct platform.architecture() to return the bit architecture ('32bit' or '64bit') of the running interpreter in the default case where executable = sys.executable.  The linkage string will also contain information about the Mach-O executable including available bit- and processor-architectures as returned by the MacOS X file command.

An example of the most general results, using a 4-way build:

# ./configure --enable-universalsdk=/Developer/SDKs/MacOSX10.5.sdk --with-universal-archs=all MACOSX_DEPLOYMENT_TARGET=10.5
$ file ./python
./python: Mach-O universal binary with 4 architectures
./python (for architecture i386):	Mach-O executable i386
./python (for architecture ppc7400):	Mach-O executable ppc
./python (for architecture ppc64):	Mach-O 64-bit executable ppc64
./python (for architecture x86_64):	Mach-O 64-bit executable x86_64
$ arch -i386 ./python -c 'import platform;print(platform.architecture())'
('32bit', 'MachO 32bit 64bit i386 ppc ppc64 x86_64')
$ arch -x86_64 ./python -c 'import platform;print(platform.architecture())'
('64bit', 'MachO 32bit 64bit i386 ppc ppc64 x86_64')
$ arch -ppc ./python -c 'import platform;print(platform.architecture())'
('32bit', 'MachO 32bit 64bit i386 ppc ppc64 x86_64')
$ arch -i386 ./python -m platform
Darwin-10.5.0-i386-32bit-MachO_32bit_64bit_i386_ppc_ppc64_x86_64
$ arch -x86_64 ./python -m platform
Darwin-10.5.0-i386-64bit-MachO_32bit_64bit_i386_ppc_ppc64_x86_64
$ ./python -m platform --terse
Darwin-10.5.0

----------
stage:  -> patch review

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10735>
_______________________________________


More information about the Python-bugs-list mailing list