From d5d9e02dd3c6df06a8dd9ce75ee9b52976420a8b Mon Sep 17 00:00:00 2001 From: Nick Coghlan Date: Sun, 25 Mar 2018 23:03:10 +1000 Subject: 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. --- Lib/test/support/script_helper.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'Lib/test/support/script_helper.py') diff --git a/Lib/test/support/script_helper.py b/Lib/test/support/script_helper.py index 5a81697708..64b25aab80 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() -- cgit v1.2.1