Skip to content

bpo-35348: Make parsing the output of the file command in platform.architecture() more reliable.#11160

Closed
serhiy-storchaka wants to merge 2 commits into
python:masterfrom
serhiy-storchaka:platform-syscmd-file
Closed

bpo-35348: Make parsing the output of the file command in platform.architecture() more reliable.#11160
serhiy-storchaka wants to merge 2 commits into
python:masterfrom
serhiy-storchaka:platform-syscmd-file

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Dec 14, 2018

Copy link
Copy Markdown
Member

Comment thread Lib/platform.py
output = subprocess.check_output(['file', target],
stderr=subprocess.DEVNULL,
encoding='latin-1')
env={'LC_ALL': 'C'})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LC_ALL=C is used because the output can be locale depending (as it is documented).

Comment thread Lib/platform.py
return (output or default)
prefix = os.fsencode(target) + b': '
if output.startswith(prefix):
output = output[len(prefix):]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use -b option, my PR #11159? It would prefer simpler to not display the filename than try to remove it, no?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@vstinner

Copy link
Copy Markdown
Member

I merged PR #11159 instead.

@vstinner vstinner closed this Dec 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants