mirror of
https://github.com/python/cpython.git
synced 2025-10-06 15:11:58 +00:00
bpo-33053: -m now adds *starting* directory to sys.path (GH-6231) (#6236)
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.
(cherry picked from commit d5d9e02dd3
)
This commit is contained in:
parent
5666a55da8
commit
ee3784594b
9 changed files with 104 additions and 76 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue