bpo-35348: Make parsing the output of the file command in platform.architecture() more reliable.#11160
bpo-35348: Make parsing the output of the file command in platform.architecture() more reliable.#11160serhiy-storchaka wants to merge 2 commits into
Conversation
…chitecture() more reliable.
| output = subprocess.check_output(['file', target], | ||
| stderr=subprocess.DEVNULL, | ||
| encoding='latin-1') | ||
| env={'LC_ALL': 'C'}) |
There was a problem hiding this comment.
Do you use LC_ALL=C to change the encoding? If yes, I'm not sure that it's a good idea.
If it's to get the output in english: I would be surprised since I'm not aware of a translated output of file?
There was a problem hiding this comment.
LC_ALL=C is used because the output can be locale depending (as it is documented).
| return (output or default) | ||
| prefix = os.fsencode(target) + b': ' | ||
| if output.startswith(prefix): | ||
| output = output[len(prefix):] |
There was a problem hiding this comment.
Why not use -b option, my PR #11159? It would prefer simpler to not display the filename than try to remove it, no?
There was a problem hiding this comment.
The only reason is that this option is non-standard. It may introduce a regression on some exotic platform if add the -b option.
"--" is non-standard too. Since the target should be an absolute name, I think it is not needed.
|
I merged PR #11159 instead. |
https://bugs.python.org/issue35348