[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-18 Thread STINNER Victor
STINNER Victor added the comment: The initial issue has been fixed, I close the issue. Thanks for the review and feedback! -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-18 Thread STINNER Victor
STINNER Victor added the comment: Ok, I closed my PR 11186 which modified architecture() to only return struct.calcsize('P') if the executable argument is equal to sys.executable. > please read the doc-string of the platform.architecture() function (or ask > the person who wrote most of the

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-18 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: +10445 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-17 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: Guys, please read the doc-string of the platform.architecture() function (or ask the person who wrote most of the module). It clearly refers to inspecting a specific executable and only uses the Python interpreter as default. The running process can

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-17 Thread STINNER Victor
STINNER Victor added the comment: New changeset 0af9c33262fb43f39a6558e3f155689e83e10706 by Victor Stinner in branch 'master': bpo-35348: Fix platform.architecture() (GH-11159) https://github.com/python/cpython/commit/0af9c33262fb43f39a6558e3f155689e83e10706 --

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-17 Thread STINNER Victor
STINNER Victor added the comment: > 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. architecture() looks at running Python executable by

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-17 Thread STINNER Victor
STINNER Victor added the comment: See also bpo-35516: "platform.system_alias(): add macOS support". -- ___ Python tracker ___ ___

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-17 Thread Ronald Oussoren
Ronald Oussoren added the comment: > 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

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-17 Thread STINNER Victor
STINNER Victor added the comment: Ronald Oussoren gave more info on my previous PR 10780 ("platform.platform() uses mac_ver() on macOS"): https://github.com/python/cpython/pull/10780#issuecomment-444529371 """ The information does not include data about fat binaries, resulting amongst

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-17 Thread Ronald Oussoren
Ronald Oussoren added the comment: > What result of platform.architecture() do you expect for an universal binary? I honestly don't know. What is the purpose of this functionality in the first place? I have never had a problem where using this function was the right solution. To be honest

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-17 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: +10424 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-14 Thread STINNER Victor
STINNER Victor added the comment: I don't understand the purpose of the 'linkage' information of platform.architecture(). Does anyone care if Python is an ELF program or a WindowsPE program? Maybe it was useful 20 years ago when there were COFF on Unix, but right now ELF is the defacto

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: What result of platform.architecture() do you expect for an universal binary? -- ___ Python tracker ___

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-14 Thread Ronald Oussoren
Ronald Oussoren added the comment: BTW. A related problem with platform.architecture() is that it doesn't know how to deal with fat binaries (such as those found on macOS). As an example: $ file /usr/bin/python /usr/bin/python: Mach-O universal binary with 2 architectures: [i386:Mach-O

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: PR 11160 is an alternate solution which strips the filename in the output. It does not matter if the filename contains ":", because the format of the output in the POSIX locale is strictly specified. -- ___

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-14 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- pull_requests: +10396 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-14 Thread STINNER Victor
STINNER Victor added the comment: A convervative approach would be to leave stable branches unchanged and use -b in the master branch. -- ___ Python tracker ___

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-14 Thread STINNER Victor
STINNER Victor added the comment: > We can also check that the output starts with executable+': ' and strip this > prefix. Technically, on UNIX, ':' is valid in a filename. Filename examples which contain ':' on my Fedora 29: /usr/share/man/man3/List::Util.3pm.gz

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-14 Thread STINNER Victor
STINNER Victor added the comment: In 2.7 branch, _syscmd_file() only used -b option during one day (no Python 2.7.x release used -b): * Oct 4, 2012: commit 95038fa526c8b93e42c59b0735edf1c80b7b6449 added -b: "Closes #16112: platform.architecture does not correctly escape argument to

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I tested that the "-b" option is supported on Linux, *BSD and OpenIndiana. But it is not a part of POSIX. So perhaps we should fall back to "file" without "-b" if "file -b" failed. We can also check that the output starts with executable+': ' and strip

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-14 Thread STINNER Victor
STINNER Victor added the comment: > -b option added by: > https://hg.python.org/cpython/rev/c73b90b6dadd Oh wait, this change is for the 2.7 branch. The change in master (old "default" branch) didn't add -b, but replaced "-b" with "-b --": https://hg.python.org/cpython/rev/cd026866b333

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-14 Thread STINNER Victor
STINNER Victor added the comment: -b option added by: https://hg.python.org/cpython/rev/c73b90b6dadd and removed the day after by: https://hg.python.org/cpython/rev/b94a9ff13199 -- ___ Python tracker

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-14 Thread STINNER Victor
Change by STINNER Victor : -- keywords: +patch pull_requests: +10395 stage: -> patch review ___ Python tracker ___ ___

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-14 Thread STINNER Victor
STINNER Victor added the comment: > I agreed with Serhiy. I also found the function decode the output with > latin-1, I think it will be better to use utf-8 instead. Decoding from UTF-8 can fail with UnicodeDecodeError, whereas decoding from latin-1 never fails. file output is ASCII, so I

[issue35348] Problems with handling the file command output in platform.architecture()

2018-12-14 Thread STINNER Victor
STINNER Victor added the comment: I removed the dependency between bpo-35346 and this issue. I don't see how they are related. -- ___ Python tracker ___

[issue35348] Problems with handling the file command output in platform.architecture()

2018-11-29 Thread Windson Yang
Windson Yang added the comment: I agreed with Serhiy. I also found the function decode the output with latin-1, I think it will be better to use utf-8 instead. -- nosy: +Windson Yang ___ Python tracker

[issue35348] Problems with handling the file command output in platform.architecture()

2018-11-29 Thread STINNER Victor
STINNER Victor added the comment: Why does platform has to analyze sys.executable binary to check if it's 32 or 64 bits? Can't we use sizeof(void*) for example? Is it something related to FAT binary on macOS? (single binary for 32 and 64 bits, or single binary for PPC and x86) --

[issue35348] Problems with handling the file command output in platform.architecture()

2018-11-29 Thread Serhiy Storchaka
New submission from Serhiy Storchaka : The code of _syscmd_file() in the platform module does not match the docstring. The "-b" option was removed in 685fffa (issue16112), and this leads to inclusion the executable path in the file command output. If the executable path contains some key