Skip to content

[3.7] bpo-33053: -m now adds *starting* directory to sys.path (GH-6231)#6236

Merged
ncoghlan merged 1 commit into
python:3.7from
ncoghlan:backport-d5d9e02-3.7
Mar 25, 2018
Merged

[3.7] bpo-33053: -m now adds *starting* directory to sys.path (GH-6231)#6236
ncoghlan merged 1 commit into
python:3.7from
ncoghlan:backport-d5d9e02-3.7

Conversation

@ncoghlan
Copy link
Copy Markdown
Contributor

@ncoghlan ncoghlan commented Mar 25, 2018

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 d5d9e02)

https://bugs.python.org/issue33053

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 d5d9e02)
@bedevere-bot
Copy link
Copy Markdown

@ncoghlan: Please replace # with GH- in the commit message next time. Thanks!

@ncoghlan ncoghlan deleted the backport-d5d9e02-3.7 branch March 30, 2018 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants