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

Python 3 fixes - use unicode with temporary_directory() file path #6233

Merged
merged 5 commits into from Jul 26, 2018

Conversation

Projects
None yet
2 participants
@Eric-Arellano
Copy link
Contributor

Eric-Arellano commented Jul 25, 2018

For temporary_directory(), we were using a mix of bytes and unicode in the arguments, which fails in Py3 because it does not allow mixing the two.

The arguments could be either, but unicode makes more sense and requires less changes in our codebase. This changes the return type to be a str, not bytes, which impacted the TarFile logic.

for m in tar.getmembers():
m.name = m.name.decode('utf-8')
decoded_members.append(m)
tar.extractall(outdir, members=decoded_members)

This comment has been minimized.

@stuhood

stuhood Jul 25, 2018

Member

So, it looks like there are a bunch of usages of with open_tar(..) in the codebase... would it be worth auditing them all and seeing whether there is a helper worth extracting?

This comment has been minimized.

@Eric-Arellano

Eric-Arellano Jul 25, 2018

Contributor

I don't think the issue is with open_tar.

It seems to be with _extract() and in particular it's outdir argument, which is a path to the desired directory.

@stuhood stuhood merged commit 84dfb2e into pantsbuild:master Jul 26, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Eric-Arellano Eric-Arellano deleted the Eric-Arellano:py3-fixes_temp-dir branch Jul 26, 2018

CMLivingston pushed a commit to CMLivingston/pants that referenced this pull request Aug 27, 2018

Python 3 fixes - use unicode with temporary_directory() file path (pa…
…ntsbuild#6233)

For `temporary_directory()`, we were using a mix of bytes and unicode in the arguments, which fails in Py3 because it does not allow mixing the two.

The arguments could be either, but unicode makes more sense and requires less changes in our codebase. This changes the return type to be a `str`, not `bytes`, which impacted the TarFile logic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment