Skip to content

Commit

Permalink
* if env keyword passed to subprocess, make sure that windows subproc…
Browse files Browse the repository at this point in the history
…ess gets SYSTEMROOT env variable
  • Loading branch information
Ryan Clary committed Jun 25, 2020
1 parent 615b2aa commit 56a53b5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions spyder/utils/programs.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,19 @@ def alter_subprocess_kwargs_by_platform(**kwargs):
# We "or" them together
CONSOLE_CREATION_FLAGS |= CREATE_NO_WINDOW
kwargs.setdefault('creationflags', CONSOLE_CREATION_FLAGS)

# ensure Windows subprocess environment has SYSTEMROOT, but variable
# is case insensitive
if ((kwargs.get('env') is not None) and
('SYSTEMROOT' not in map(str.upper, kwargs['env'].keys()))):
sys_root_key = None
for k, v in os.environ.items():
if 'SYSTEMROOT' == k.upper():
sys_root_key = k
break # don't risk multiple values
if sys_root_key is not None:
kwargs['env'].update({sys_root_key: os.environ[sys_root_key]})

return kwargs


Expand Down

0 comments on commit 56a53b5

Please sign in to comment.