summaryrefslogtreecommitdiffstats
path: root/Lib/test/support/script_helper.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-01-12 10:51:46 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2017-01-12 10:51:46 (GMT)
commit9b8dcc6b1c18d5539735b61004d2e84b3e26cc8f (patch)
tree1c9a3a4a006e21daab5cab672c7a754d6a33f83c /Lib/test/support/script_helper.py
parentde383289ea4b029028f2ca0bf7e2e27441b99025 (diff)
downloadcpython-9b8dcc6b1c18d5539735b61004d2e84b3e26cc8f.zip
cpython-9b8dcc6b1c18d5539735b61004d2e84b3e26cc8f.tar.gz
cpython-9b8dcc6b1c18d5539735b61004d2e84b3e26cc8f.tar.bz2
Fix script_helper.run_python_until_end(): copy SYSTEMROOT
Windows requires at least the SYSTEMROOT environment variable to start Python. If run_python_until_end() doesn't copy SYSTEMROOT, the function always fail on Windows.
Diffstat (limited to 'Lib/test/support/script_helper.py')
-rw-r--r--Lib/test/support/script_helper.py25
1 files changed, 18 insertions, 7 deletions
diff --git a/Lib/test/support/script_helper.py b/Lib/test/support/script_helper.py
index 80889b1..ca5f9c20 100644
--- a/Lib/test/support/script_helper.py
+++ b/Lib/test/support/script_helper.py
@@ -70,17 +70,28 @@ def run_python_until_end(*args, **env_vars):
elif not env_vars and not env_required:
# ignore Python environment variables
cmd_line.append('-E')
- # Need to preserve the original environment, for in-place testing of
- # shared library builds.
- env = os.environ.copy()
- # set TERM='' unless the TERM environment variable is passed explicitly
- # see issues #11390 and #18300
- if 'TERM' not in env_vars:
- env['TERM'] = ''
+
# But a special flag that can be set to override -- in this case, the
# caller is responsible to pass the full environment.
if env_vars.pop('__cleanenv', None):
env = {}
+ if sys.platform == 'win32':
+ # Windows requires at least the SYSTEMROOT environment variable to
+ # start Python.
+ env['SYSTEMROOT'] = os.environ['SYSTEMROOT']
+
+ # Other interesting environment variables, not copied currently:
+ # COMSPEC, HOME, PATH, TEMP, TMPDIR, TMP.
+ else:
+ # Need to preserve the original environment, for in-place testing of
+ # shared library builds.
+ env = os.environ.copy()
+
+ # set TERM='' unless the TERM environment variable is passed explicitly
+ # see issues #11390 and #18300
+ if 'TERM' not in env_vars:
+ env['TERM'] = ''
+
env.update(env_vars)
cmd_line.extend(args)
proc = subprocess.Popen(cmd_line, stdin=subprocess.PIPE,