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

2020-01-02 Thread Brett Cannon
Brett Cannon added the comment: RE: "This could be done when inserting something into `sys.path` maybe then only?" That would require a custom object instead of a standard list for sys.path which could detect insertion and then do the automatic absolute path resolution which as you pointed

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

2019-12-24 Thread daniel hahler
daniel hahler added the comment: > 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). This could be done when inserting

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

2019-12-24 Thread Brett Cannon
Brett Cannon 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

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

2019-12-21 Thread Batuhan
Batuhan added the comment: I am not sure about computing absolute path every time when `__file__` called. I guess it is a static thing, that get setted on the import time and never changes. What you are proposing is to compute it dynamically which IMHO isn't the best way. -- nosy:

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

2018-08-20 Thread daniel hahler
New submission from daniel hahler : With "." in sys.path the "__file__" attribute will be a relative path, and therefore cannot be used after "chdir". This likely affects relative paths in general, but have not tested it. ``` import os import sys sys.path.insert(0, '.') # Importing it