From e0d88a173c5ccc346b8d7c6e805f0e49b4ea92f7 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Wed, 25 Apr 2012 20:54:04 -0400 Subject: 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. --- Lib/pkgutil.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'Lib/pkgutil.py') diff --git a/Lib/pkgutil.py b/Lib/pkgutil.py index ef027be898..932abbc181 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 -- cgit v1.2.1