[issue34444] Module's __file__ should be absolute always ("." in sys.path)

Brett Cannon report at bugs.python.org
Tue Dec 24 12:59:52 EST 2019


Brett Cannon <brett at python.org> added the comment:

So if you were to insert '.' via PYTHONPATH it would be made absolute as the site module makes all entries in sys.path absolute during startup.

And changing this to have to check every time import runs if an entry in sys.path is absolute would be costly (that's not a insignificant number of stat calls which we always try to avoid during import when possible). Your best option is to insert an absolute path to begin with. Also realize that manipulating sys.path is an advanced thing to do and so I don't think asking people to be "consenting adults" and be careful about adding relative paths on sys.path is an unreasonable thing to ask.

So while I appreciate the report, Daniel, and the motivation, I'm closing this as "won't fix" as the overhead of implementing this is too high.

----------
resolution:  -> rejected
stage:  -> resolved
status: open -> closed
type:  -> enhancement

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34444>
_______________________________________


More information about the Python-bugs-list mailing list