Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.11] gh-100750: pass encoding kwarg in lib/platform.py (GH-100751) #101207

Merged
merged 1 commit into from
Jan 21, 2023

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Jan 20, 2023

(cherry picked from commit 6b3993c)

Co-authored-by: Thomas Grainger tagrain@gmail.com
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Shantanu 12621235+hauntsaninja@users.noreply.github.com

)

(cherry picked from commit 6b3993c)

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
@miss-islington miss-islington merged commit c6cfde6 into python:3.11 Jan 21, 2023
@miss-islington miss-islington deleted the backport-6b3993c-3.11 branch January 21, 2023 05:08
@malemburg
Copy link
Member

Shouldn't this instance of calling .check_output() also receive an encoding argument ?

https://github.com/python/cpython/blob/main/Lib/platform.py#L667

(in _syscmd_file())

@graingert
Copy link
Contributor

graingert commented Feb 1, 2023

Shouldn't this instance of calling .check_output() also receive an encoding argument ?

main/Lib/platform.py#L667

(in _syscmd_file())

@malemburg no, that uses the default text=False and then decodes the bytes object returned with latin-1:

cpython/Lib/platform.py

Lines 667 to 676 in 62251c3

output = subprocess.check_output(['file', '-b', target],
stderr=subprocess.DEVNULL,
env=env)
except (OSError, subprocess.CalledProcessError):
return default
if not output:
return default
# With the C locale, the output should be mostly ASCII-compatible.
# Decode from Latin-1 to prevent Unicode decode error.
return output.decode('latin-1')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants