[issue18416] Move to absolute file paths for module.__file__

Madison May report at bugs.python.org
Sat Aug 10 01:59:55 CEST 2013


Madison May added the comment:

I quickly ran the tests with each of the above edits to see what bits of the test suite would break.

With option 1 (edits to PathFinder only):

``1 test failed:
    test_importlib``
 

With option 2 (edits to FileFinder only):

``3 tests failed:
    test_import test_importlib test_support``


With option 3 (edits to PathFinder and FileFinder):

``3 tests failed:
    test_import test_importlib test_support``

So using the cwd as a key in sys.path_importer_cache seems to break fewer tests than using '' as a key does.  Perhaps that counts for something.

In test_importlib, the only test to fail was `test_path_importer_cache_empty_string()`, for rather obvious reasons. 
I haven't spent much time looking at failing tests in test_import and test_support yet, though.


In regard to sys.path_importer_cache behavior -- at first glance, I'd lean toward either:

1) Creating a new entry in sys.path_importer_cache after changing directories and importing a new module (as is the case in option 1).

Key: os.getcwd() => Value: FileFinder(os.getcwd())

2) Keeping the current behavior in sys.path_importer_cache and somehow changing the __file__ attribute a bit further down the line (perhaps in `FileFinder._init_file_attr()` or `FileLoader.get_filename()`).

Key: '.' => Value: FileFinder('.') 

or with a minor tweak for consistency with sys.path:

Key: ''  => Value: FileFinder('.')

Have you given the issue any more thought, Brett?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18416>
_______________________________________


More information about the Python-bugs-list mailing list