Skip to content

Commit

Permalink
Fix Python module enviroment setup on Windows
Browse files Browse the repository at this point in the history
- Trim trailing newline when reading .env lines
- Skip empty, commented and non "key=value" lines
- Allow = chars in values using maxsplit=1
- No special quote handling, use values as is

Fixes #43308
  • Loading branch information
komima authored and nyalldawson committed Jun 21, 2021
1 parent 7f91c00 commit e3f9f7b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions python/__init__.py
Expand Up @@ -55,10 +55,14 @@ def setupenv():

with open(envfile) as f:
for line in f:
linedata = line.split("=")
name = linedata[0]
data = linedata[1]
os.environ[name] = data
line = line.rstrip("\n")
if line.startswith("#") or not line:
continue
try:
env_key, env_value = line.split("=", maxsplit=1)
os.environ[env_key] = env_value
except ValueError:
pass


if os.name == 'nt':
Expand Down

0 comments on commit e3f9f7b

Please sign in to comment.