diff --git a/pipenv/vendor/dotenv/main.py b/pipenv/vendor/dotenv/main.py index 3d1bd72f34..75f49c4acd 100644 --- a/pipenv/vendor/dotenv/main.py +++ b/pipenv/vendor/dotenv/main.py @@ -94,6 +94,13 @@ def set_as_environment_variables(self, override=False): for k, v in self.dict().items(): if k in os.environ and not override: continue + # With Python 2 on Windows, ensuree environment variables are + # system strings to avoid "TypeError: environment can only contain + # strings" in Python's subprocess module. + if sys.version_info.major < 3 and sys.platform == 'win32': + from pipenv.utils import fs_str + k = fs_str(k) + v = fs_str(v) os.environ[k] = v return True diff --git a/tasks/vendoring/patches/vendor/dotenv-windows-unicode.patch b/tasks/vendoring/patches/vendor/dotenv-windows-unicode.patch new file mode 100644 index 0000000000..c090e8853f --- /dev/null +++ b/tasks/vendoring/patches/vendor/dotenv-windows-unicode.patch @@ -0,0 +1,18 @@ +diff --git a/pipenv/vendor/dotenv/main.py b/pipenv/vendor/dotenv/main.py +index 3d1bd72f..75f49c4a 100644 +--- a/pipenv/vendor/dotenv/main.py ++++ b/pipenv/vendor/dotenv/main.py +@@ -94,6 +94,13 @@ class DotEnv(): + for k, v in self.dict().items(): + if k in os.environ and not override: + continue ++ # With Python 2 on Windows, ensuree environment variables are ++ # system strings to avoid "TypeError: environment can only contain ++ # strings" in Python's subprocess module. ++ if sys.version_info.major < 3 and sys.platform == 'win32': ++ from pipenv.utils import fs_str ++ k = fs_str(k) ++ v = fs_str(v) + os.environ[k] = v + + return True