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 authored and nyalldawson committed Jun 2, 2021
1 parent 8682270 commit bf2b09f47aa41cbaa95a2be0d2165a230a55aae4
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 bf2b09f

Please sign in to comment.