diff options
author | Brett Cannon <brett@python.org> | 2012-04-26 00:54:04 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2012-04-26 00:54:04 (GMT) |
commit | e0d88a173c5ccc346b8d7c6e805f0e49b4ea92f7 (patch) | |
tree | 476528c79622c96645adf554536eeeba0c4ee0d8 /Lib/pkgutil.py | |
parent | 8f79dd5d7cc3eb19d568f8e95f04ee33f1177d92 (diff) | |
download | cpython-e0d88a173c5ccc346b8d7c6e805f0e49b4ea92f7.zip cpython-e0d88a173c5ccc346b8d7c6e805f0e49b4ea92f7.tar.gz cpython-e0d88a173c5ccc346b8d7c6e805f0e49b4ea92f7.tar.bz2 |
Issue #14605: Make explicit the entries on sys.path_hooks that used to
be implicit.
Added a warning for when sys.path_hooks is found to be empty. Also
changed the meaning of None in sys.path_importer_cache to represent
trying sys.path_hooks again (an interpretation of previous semantics).
Also added a warning for when None was found.
The long-term goal is for None in sys.path_importer_cache to represent
the same as imp.NullImporter: no finder found for that sys.path entry.
Diffstat (limited to 'Lib/pkgutil.py')
-rw-r--r-- | Lib/pkgutil.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/Lib/pkgutil.py b/Lib/pkgutil.py index ef027be..932abbc 100644 --- a/Lib/pkgutil.py +++ b/Lib/pkgutil.py @@ -379,18 +379,15 @@ def get_importer(path_item): for path_hook in sys.path_hooks: try: importer = path_hook(path_item) + sys.path_importer_cache.setdefault(path_item, importer) break except ImportError: pass else: - importer = None - sys.path_importer_cache.setdefault(path_item, importer) - - if importer is None: - try: - importer = ImpImporter(path_item) - except ImportError: - importer = None + try: + importer = ImpImporter(path_item) + except ImportError: + importer = None return importer |