Author ronaldoussoren
Recipients Windson Yang, lemburg, ronaldoussoren, serhiy.storchaka, vstinner
Date 2018-12-17.09:30:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1545039017.44.0.788709270274.issue35348@psf.upfronthosting.co.za>
In-reply-to
Content
> IMHO platform.architecture() should return 32bit when running "arch -i386 /usr/local/bin/python3" to be consistent with struct.calcsize("P") == 4 and sys.maxsize == 2147483647. Otherwise, how would you notice that you are using the 32-bit flavor of Python?

I don't agree. Platform.architecture() is defined to look at a specified binary, not the currently running process. That can lead to inconsistencies like this and is not something you can avoid. 


> Ronald Oussoren:
> > Using sizeof(void*) or sys.maxsize suffers from the a simular problem:  this will only detect the pointer-size of the current proces and not that the binary is capable of running with a different pointer-size as well.

> Right, but I don't think that it's possible to report that Python executable is FAT binary in platform.architecture() result. If you want to provide such information, IMHO you should write a new function or at least add a new parameter to platform.architecture().

> IMHO it's more consistent to report "32bit" for "arch -i386 python3" and "64bit" for "arch -x86_64 python3".

This doesn't necessarily need a new function, platform.architecture could also return something like "32bit,64bit". 

But as I mentioned in my previous message I don't know why anyone would want to use this function in the first place. There are better ways to determine information about the current process (struct.calcsize, sys.maxsize, sys.byteorder), and I have never had a need to determine information about executable files that I couldn't get in a better way using other libraries (like macholib and pyelftools)
History
Date User Action Args
2018-12-17 09:30:17ronaldoussorensetrecipients: + ronaldoussoren, lemburg, vstinner, serhiy.storchaka, Windson Yang
2018-12-17 09:30:17ronaldoussorensetmessageid: <1545039017.44.0.788709270274.issue35348@psf.upfronthosting.co.za>
2018-12-17 09:30:17ronaldoussorenlinkissue35348 messages
2018-12-17 09:30:17ronaldoussorencreate