diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2018-03-25 23:03:10 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-25 23:03:10 +1000 |
commit | d5d9e02dd3c6df06a8dd9ce75ee9b52976420a8b (patch) | |
tree | c3c02b573a85d3a5caa61e1dd5188ba6bec36392 /Lib/test/support/script_helper.py | |
parent | bc77eff8b96be4f035e665ab35c1d06e22f46491 (diff) | |
download | cpython-d5d9e02dd3c6df06a8dd9ce75ee9b52976420a8b.tar.gz cpython-d5d9e02dd3c6df06a8dd9ce75ee9b52976420a8b.zip |
bpo-33053: -m now adds *starting* directory to sys.path (GH-6231)
Historically, -m added the empty string as sys.path
zero, meaning it resolved imports against the current
working directory, the same way -c and the interactive
prompt do.
This changes the sys.path initialisation to add the
*starting* working directory as sys.path[0] instead,
such that changes to the working directory while the
program is running will have no effect on imports
when using the -m switch.
Diffstat (limited to 'Lib/test/support/script_helper.py')
-rw-r--r-- | Lib/test/support/script_helper.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/test/support/script_helper.py b/Lib/test/support/script_helper.py index 5a81697708f..64b25aab800 100644 --- a/Lib/test/support/script_helper.py +++ b/Lib/test/support/script_helper.py @@ -87,6 +87,7 @@ class _PythonRunResult(collections.namedtuple("_PythonRunResult", # Executing the interpreter in a subprocess def run_python_until_end(*args, **env_vars): env_required = interpreter_requires_environment() + cwd = env_vars.pop('__cwd', None) if '__isolated' in env_vars: isolated = env_vars.pop('__isolated') else: @@ -125,7 +126,7 @@ def run_python_until_end(*args, **env_vars): cmd_line.extend(args) proc = subprocess.Popen(cmd_line, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, - env=env) + env=env, cwd=cwd) with proc: try: out, err = proc.communicate() |