-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure environs are strings on Python2 + Windows
Patch based on theskumar/python-dotenv#101 by @greyli.
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
tasks/vendoring/patches/vendor/dotenv-windows-unicode.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
diff --git a/pipenv/vendor/dotenv/main.py b/pipenv/vendor/dotenv/main.py | ||
index 3d1bd72f..4e1b4b46 100644 | ||
--- a/pipenv/vendor/dotenv/main.py | ||
+++ b/pipenv/vendor/dotenv/main.py | ||
@@ -94,6 +94,14 @@ class DotEnv(): | ||
for k, v in self.dict().items(): | ||
if k in os.environ and not override: | ||
continue | ||
+ # With Python2 on Windows, force environment variables to str to | ||
+ # avoid "TypeError: environment can only contain strings" in | ||
+ # Python's subprocess module. | ||
+ if sys.version_info.major < 3 and sys.platform == 'win32': | ||
+ if not isinstance(k, str): | ||
+ k = k.encode(sys.getdefaultencoding()) | ||
+ if not isinstance(v, str): | ||
+ v = v.encode(sys.getdefaultencoding()) | ||
os.environ[k] = v | ||
|
||
return True |