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

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

Merged
merged 5 commits into from
Jul 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/python/pants/fs/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from contextlib import contextmanager
from zipfile import ZIP_DEFLATED

from future.utils import PY2

from pants.util.contextutil import open_tar, open_zip, temporary_dir
from pants.util.dirutil import is_executable, safe_concurrent_rename, safe_walk
from pants.util.meta import AbstractClass
Expand Down Expand Up @@ -67,6 +69,8 @@ class TarArchiver(Archiver):

def _extract(self, path_or_file, outdir, **kwargs):
with open_tar(path_or_file, errorlevel=1, **kwargs) as tar:
if PY2:
outdir = outdir.encode('utf-8')
tar.extractall(outdir)

def __init__(self, mode, extension):
Expand Down
2 changes: 1 addition & 1 deletion src/python/pants/util/contextutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def signal_handler_as(sig, handler):


@contextmanager
def temporary_dir(root_dir=None, cleanup=True, suffix=b'', permissions=None, prefix=tempfile.template):
def temporary_dir(root_dir=None, cleanup=True, suffix='', permissions=None, prefix=tempfile.template):
"""
A with-context that creates a temporary directory.

Expand Down