From 84a792b287b583b24d210050ec7da35994d94924 Mon Sep 17 00:00:00 2001 From: Philippe Ombredanne Date: Fri, 28 Jun 2019 12:39:10 +0200 Subject: [PATCH] Add proof of concept fix for Unicode bug With these minimal changes the exmaple.zip from #5972 installs correctly on Windows. Link: https://github.com/pypa/pip/issues/5972 Signed-off-by: Philippe Ombredanne --- src/pip/_internal/req/constructors.py | 1 + src/pip/_internal/utils/misc.py | 1 + src/pip/_internal/utils/temp_dir.py | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pip/_internal/req/constructors.py b/src/pip/_internal/req/constructors.py index 0f18b6a727d..7fe49c1fec0 100644 --- a/src/pip/_internal/req/constructors.py +++ b/src/pip/_internal/req/constructors.py @@ -213,6 +213,7 @@ def install_req_from_line( """Creates an InstallRequirement from a name, which might be a requirement, directory containing 'setup.py', filename, or URL. """ + name = unicode(name) if is_url(name): marker_sep = '; ' else: diff --git a/src/pip/_internal/utils/misc.py b/src/pip/_internal/utils/misc.py index ca7a529387c..4b5001d27c0 100644 --- a/src/pip/_internal/utils/misc.py +++ b/src/pip/_internal/utils/misc.py @@ -724,6 +724,7 @@ def call_subprocess( env.update(extra_environ) for name in unset_environ: env.pop(name, None) + env = {k: str(v) if isinstance(v, unicode) else v for k, v in env.items()} try: proc = subprocess.Popen( cmd, stderr=subprocess.STDOUT, stdin=subprocess.PIPE, diff --git a/src/pip/_internal/utils/temp_dir.py b/src/pip/_internal/utils/temp_dir.py index 2c81ad554c8..656f80771ee 100644 --- a/src/pip/_internal/utils/temp_dir.py +++ b/src/pip/_internal/utils/temp_dir.py @@ -72,7 +72,7 @@ def create(self): # scripts, so we canonicalize the path by traversing potential # symlinks here. self.path = os.path.realpath( - tempfile.mkdtemp(prefix="pip-{}-".format(self.kind)) + tempfile.mkdtemp(prefix=u"pip-{}-".format(self.kind)) ) logger.debug("Created temporary directory: {}".format(self.path)) @@ -150,6 +150,6 @@ def create(self): if not self.path: # Final fallback on the default behavior. self.path = os.path.realpath( - tempfile.mkdtemp(prefix="pip-{}-".format(self.kind)) + tempfile.mkdtemp(prefix=u"pip-{}-".format(self.kind)) ) logger.debug("Created temporary directory: {}".format(self.path))