Skip to content
Permalink
Browse files
Fix Python module enviroment setup on Windows
- 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 committed May 25, 2021
1 parent dfaafa6 commit 8cea1789af5e6dfe14ebe37582791c6a528a4c50
Showing with 8 additions and 4 deletions.
  1. +8 −4 python/__init__.py
@@ -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':

0 comments on commit 8cea178

Please sign in to comment.