[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-09-26 Thread STINNER Victor
STINNER Victor added the comment: New changeset 43500a5907eb9ae2e470dcbffe73012cd456f5a1 by Victor Stinner in branch '3.6': bpo-28655: Fix test_import.test_missing_source_legacy() (GH-9589) https://github.com/python/cpython/commit/43500a5907eb9ae2e470dcbffe73012cd456f5a1 -- nosy:

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-09-26 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: +8987 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-04-07 Thread Nick Coghlan
Nick Coghlan added the comment: Some notes from my investigation of bpo-33185 that seem more appropriate here, rather than on that issue: * several of the developer-centric utilities in the standard library have a shared need to be friendly to imports from the current

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-04-06 Thread Ned Deily
Ned Deily added the comment: (See Issue33185 for regression.) -- ___ Python tracker ___

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-25 Thread Nick Coghlan
Nick Coghlan added the comment: New changeset ee3784594b33c72c3fdca6a71892d22f14045ab6 by Nick Coghlan in branch '3.7': bpo-33053: -m now adds *starting* directory to sys.path (GH-6231) (#6236)

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-25 Thread Nick Coghlan
Nick Coghlan added the comment: New changeset d5d9e02dd3c6df06a8dd9ce75ee9b52976420a8b by Nick Coghlan in branch 'master': bpo-33053: -m now adds *starting* directory to sys.path (GH-6231) https://github.com/python/cpython/commit/d5d9e02dd3c6df06a8dd9ce75ee9b52976420a8b

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-25 Thread Nick Coghlan
Nick Coghlan added the comment: Marking as fixed, since this is now the version likely to go out in 3.7.0b3 - if we find further problems with it (beyond the potential enhancement discussed above to make local directory usage opt-in), then those can go in a new issue.

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-25 Thread Nick Coghlan
Nick Coghlan added the comment: New changeset a9e5d0e9ef27b14e34631d415e727a07d0f63bef by Nick Coghlan in branch 'master': bpo-33053: Remove test_cmd_line_script debugging print (GH-6237) https://github.com/python/cpython/commit/a9e5d0e9ef27b14e34631d415e727a07d0f63bef

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-25 Thread Nick Coghlan
Nick Coghlan added the comment: 3.7 CI finished before I logged off for the night, so this is good to go for 3.7.0b3 now :) -- priority: release blocker -> normal ___ Python tracker

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-25 Thread Nick Coghlan
Change by Nick Coghlan : -- pull_requests: +5974 ___ Python tracker ___ ___

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-25 Thread Nick Coghlan
Nick Coghlan added the comment: Initial fix has been merged to master, CI runs pending for the backport to 3.7 and a follow-up master branch PR to remove a debugging print I noticed when resolving a test_import conflict in the backport. I won't get to merging those until

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-25 Thread Nick Coghlan
Change by Nick Coghlan : -- pull_requests: +5973 ___ Python tracker ___ ___

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-25 Thread Nick Coghlan
Nick Coghlan added the comment: It turned out some tests in CPython's own test suite were implicitly relying on the old behaviour where the current working directory automatically ended up on sys.path (see the changes to test_bdb and test_doctest in the updated PR).

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-25 Thread Nick Coghlan
Nick Coghlan added the comment: PR posted with the change to use an absolute path for the starting working directory in the "-m" case. That PR also includes a change to improve the fidelity of the test suite: back when I first wrote test_cmd_line_script, I was mainly

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-25 Thread Nick Coghlan
Change by Nick Coghlan : -- keywords: +patch pull_requests: +5970 stage: needs patch -> patch review ___ Python tracker ___

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-25 Thread Nick Coghlan
Change by Nick Coghlan : -- assignee: -> ncoghlan ___ Python tracker ___ ___

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-22 Thread Brett Cannon
Brett Cannon added the comment: I can't make any promises unfortunately. -- ___ Python tracker ___

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-22 Thread Ned Deily
Change by Ned Deily : -- Removed message: https://bugs.python.org/msg314252 ___ Python tracker ___

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-22 Thread Viv
Viv added the comment: Thanks, worked a treat https://www.allcarleasing.co.uk/special-offers/ -- nosy: +Viv ___ Python tracker

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-22 Thread Nick Coghlan
Nick Coghlan added the comment: Brett or Eric, any chance one of you could run with this for 3.7b3? I already have a startup refactoring related regression that I'm aiming to have fixed before then. Thanks to Victor's refactoring work, there's at least a clear

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-21 Thread Ned Deily
Ned Deily added the comment: I am OK with changing '' to the initial resolved working directory for 3.7 as long as we get that change in now, i.e. before the 3.7.0b3 ABI freeze next Monday. And I agree that we should not attempt to change this behavior for 3.6.x at this

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-21 Thread Brett Cannon
Brett Cannon added the comment: The proposed change for 3.8 and 3.7 seems reasonable to me. -- ___ Python tracker ___

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-21 Thread Nick Coghlan
Nick Coghlan added the comment: (Adding the other import system maintainers to the nosy list, along with Ned as the release manager for 3.6 and 3.7) Summarizing my current thoughts on this: I think the fact that "-m" currently adds the empty directory as sys.path[0]

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-19 Thread Eryk Sun
Eryk Sun added the comment: > the way `python -m pip` searches for the module to execute is much > closer to the way Windows searches for a command like `pip` (i.e. > current directory first) That's classic Windows behavior. However, search paths for CreateProcess and the

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-19 Thread Nick Coghlan
Nick Coghlan added the comment: It occurs to me that there may be some additional unshared context here: the way `python -m pip` searches for the module to execute is much closer to the way Windows searches for a command like `pip` (i.e. current directory first) than it

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-19 Thread Nathaniel Smith
Nathaniel Smith added the comment: Ah, yeah, I see: ~/t$ echo 'print("hi")' > re.py ~/t$ pip --version pip 9.0.1 from /home/njs/.user-python3.5-64bit/local/lib/python3.5/site-packages (python 3.5) ~/t$ python -m pip --version hi Traceback (most recent call last): [...] But if

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-19 Thread Antti Haapala
Antti Haapala added the comment: Took 2 seconds. % sudo python3 -mpip --version hello world Traceback (most recent call last): File "/usr/lib/python3.6/runpy.py", line 183, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-19 Thread Nathaniel Smith
Nathaniel Smith added the comment: @ncoghlan: The comparison I'm worried about is specifically this one: IIUC, right now it's safe to run 'pip --version' in an arbitrary directory, but it's not safe to run 'python -m pip --version' in an arbitrary directory. Am I wrong? (I

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-18 Thread Nick Coghlan
Nick Coghlan added the comment: https://bugs.python.org/issue13475 is the existing enhancement request to expose sys.path[0] management independently of the other execution isolation features. -- ___ Python tracker

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-18 Thread Jakub Wilk
Jakub Wilk added the comment: -I implies -s, which is not something I want. -- ___ Python tracker ___

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-18 Thread Nick Coghlan
Nick Coghlan added the comment: "python -m mypkg.myscript" does the right thing as far as local packages are concerned, whereas "python -m mypkg/myscript.py" will set you up for double-import bugs. Note that you can almost always trigger arbitrary non-obvious code

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-18 Thread Nathaniel Smith
Nathaniel Smith added the comment: Whoa, wait, what? I agree that the original post is not as diplomatic as it could be, but my reaction to learning about this just now is also shock and confusion, so I guess I can sympathize with the OP a bit... The reason I'm surprised is

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-17 Thread Nick Coghlan
Nick Coghlan added the comment: I've also separated out https://bugs.python.org/issue33095 (a docs issue about making isolated mode more discoverable) based on the jwilk's comment that it wasn't clear how to disable the default "add the current directory to sys.path"

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-17 Thread Nick Coghlan
Nick Coghlan added the comment: Also, a small upstream community interaction tip: if you want people to seriously consider your requests for changes in default behaviour (which inevitably risk backwards compatibility breaks), don't start out by insulting them. Python's

[issue33053] Avoid adding an empty directory to sys.path when running a module with `-m`

2018-03-17 Thread Nick Coghlan
Nick Coghlan added the comment: This isn't considered a security issue, as running "python3" interactively behaves in exactly the same way (i.e. tracking changes to the current working directory for the duration of the session), and running "python3 script.py" adds the