4 ms·
I think this would break the fundamental workflow of python where you can run a script and it can import from your CWD.
by AlphaSite 6y ago
I think this would break the fundamental workflow of python where you can run a script and it can import from your CWD.
- masklinn 6y agoScripts being run (`python foo.py`) are not imported. What it would break is running a script and trying to import from a utility module next to it.
- jwilk 6y agoNo, that's unrelated to PYTHONPATH; it wouldn't break either.
- masklinn 6y agoIt's not. That sys.path includes "." when running a script lets you import files next to the script. This is trivial to confirm: > cat "import bar" > foo.py > touch bar.py > python foo.py > python -I foo.py Traceback (most recent call last): File "foo.py", line 1, in <module> import bar ModuleNotFoundError: No module named 'bar' and this is exactly the feature which makes it risky to run `python` from an untrusted location.
- jwilk 6y agoBut there's no PYTHONPATH involved here. If you changed semantics of PYTONPATH as dwheeler suggested, everything would continue to work as you shown.