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

Convert binary data returned by call() to use it as a string #21199

Merged
merged 1 commit into from Jan 16, 2020

Conversation

svillar
Copy link
Contributor

@svillar svillar commented Jan 15, 2020

subprocess.check_output() returns binary data as output. In python2, binary is basically an alias of str so it can be directly used as a normal string. However in python3 the binary data is different to a string. Inserting binary data into a string in python3 generates strings like '/some/path/with/b'binary'/data/inserted' which are not correct file paths. We must decode() the returned data in order to use it as a string.

subprocess.check_output() returns binary data as output. In python2,
binary is basically an alias of str so it can be directly used as a
normal string. However in python3 the binary data is different to a
string. Inserting binary data into a string in python3 generates
strings like '/some/path/with/b'binary'/data/inserted' which are not
correct file paths. We must decode() the returned data in order to use
it as a string.
Copy link
Contributor

@jgraham jgraham left a comment

Choose a reason for hiding this comment

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

Bleh. Paths aren't really unicode strings, but I guess this is going to be a good enough solution for now given that a lot of Python 3 methods that take paths assume that they are strings.

@jgraham jgraham merged commit 6ea4b6f into web-platform-tests:master Jan 16, 2020
@svillar svillar deleted the decodestr branch January 23, 2020 11:28
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.

None yet

4 participants