Message331959
> 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) |
|
Date |
User |
Action |
Args |
2018-12-17 09:30:17 | ronaldoussoren | set | recipients:
+ ronaldoussoren, lemburg, vstinner, serhiy.storchaka, Windson Yang |
2018-12-17 09:30:17 | ronaldoussoren | set | messageid: <1545039017.44.0.788709270274.issue35348@psf.upfronthosting.co.za> |
2018-12-17 09:30:17 | ronaldoussoren | link | issue35348 messages |
2018-12-17 09:30:17 | ronaldoussoren | create | |
|