]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
Issue #18416: Have importlib.machinery.PathFinder treat '' as the cwd
authorBrett Cannon <brett@python.org>
Fri, 18 Oct 2013 15:39:04 +0000 (11:39 -0400)
committerBrett Cannon <brett@python.org>
Fri, 18 Oct 2013 15:39:04 +0000 (11:39 -0400)
commit27e27f7ee1f366e52cfd576b427e923190b6202e
tree895d1caeba83a4151556fdb06fcad6141bd49f12
parent40b22d0661c45ac350a7252a32ef665b81b1643c
Issue #18416: Have importlib.machinery.PathFinder treat '' as the cwd
and stop importlib.machinery.FileFinder treating '' as '.'.

Previous PathFinder transformed '' into '.' which led to __file__ for
modules imported from the cwd to always be relative paths. This meant
the values of the attribute were wrong as soon as the cwd changed.
This change now means that as long as the site module is run (which
makes all entries in sys.path absolute) then all values for __file__
will also be absolute unless it's for __main__ when specified by file
path in a relative way (modules imported by runpy will have an
absolute path).

Now that PathFinder is no longer treating '' as '.' it only makes
sense for FileFinder to stop doing so as well. Now no transformation
is performed for the directory given to the __init__ method.

Thanks to Madison May for the initial patch.
Doc/library/importlib.rst
Doc/whatsnew/3.4.rst
Lib/importlib/_bootstrap.py
Lib/test/test_importlib/import_/test_path.py
Misc/NEWS
Python/importlib.h