mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Merge pull request #1096 from kennethreitz/issue-1087
Fixes encoding issue with environment variables from .env files
This commit is contained in:
@@ -97,15 +97,7 @@ def dotenv_values(dotenv_path):
|
||||
|
||||
def parse_dotenv(dotenv_path):
|
||||
with open(dotenv_path) as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if not line or line.startswith('#') or '=' not in line:
|
||||
continue
|
||||
k, v = line.split('=', 1)
|
||||
|
||||
# Remove any leading and trailing spaces in key, value
|
||||
k, v = k.strip(), v.strip().encode('unicode-escape').decode('ascii')
|
||||
|
||||
for k, v in re.findall('^\s*(\w*)\s*=\s*("[^"]*"|[^\s]*)\s*$', f.read(), flags=re.MULTILINE):
|
||||
if len(v) > 0:
|
||||
quoted = v[0] == v[len(v) - 1] in ['"', "'"]
|
||||
|
||||
Reference in New Issue
Block a user