diff options
author | Senthil Kumaran <senthil@uthcode.com> | 2016-09-07 07:52:20 (GMT) |
---|---|---|
committer | Senthil Kumaran <senthil@uthcode.com> | 2016-09-07 07:52:20 (GMT) |
commit | 32d374215a514915eca892e5c58a61e9494f37af (patch) | |
tree | a5eb60bfa6e5a1f28bedd4042460a22fce720fca /Lib | |
parent | e848cd7605a7891378ef1463e933939aa253df71 (diff) | |
download | cpython-32d374215a514915eca892e5c58a61e9494f37af.zip cpython-32d374215a514915eca892e5c58a61e9494f37af.tar.gz cpython-32d374215a514915eca892e5c58a61e9494f37af.tar.bz2 |
[backport to 3.5] - issue26896 - Disambiguate uses of "importer" with "finder".
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/pkgutil.py | 18 | ||||
-rw-r--r-- | Lib/runpy.py | 4 | ||||
-rw-r--r-- | Lib/test/test_importlib/import_/test_meta_path.py | 1 | ||||
-rw-r--r-- | Lib/test/test_importlib/util.py | 1 | ||||
-rw-r--r-- | Lib/test/test_pkgutil.py | 2 |
5 files changed, 12 insertions, 14 deletions
diff --git a/Lib/pkgutil.py b/Lib/pkgutil.py index 0685378..81d418d 100644 --- a/Lib/pkgutil.py +++ b/Lib/pkgutil.py @@ -45,7 +45,7 @@ def read_code(stream): def walk_packages(path=None, prefix='', onerror=None): - """Yields (module_loader, name, ispkg) for all modules recursively + """Yields (module_finder, name, ispkg) for all modules recursively on path, or, if path is None, all accessible modules. 'path' should be either None or a list of paths to look for @@ -102,7 +102,7 @@ def walk_packages(path=None, prefix='', onerror=None): def iter_modules(path=None, prefix=''): - """Yields (module_loader, name, ispkg) for all submodules on path, + """Yields (module_finder, name, ispkg) for all submodules on path, or, if path is None, all top-level modules on sys.path. 'path' should be either None or a list of paths to look for @@ -184,10 +184,10 @@ def _import_imp(): imp = importlib.import_module('imp') class ImpImporter: - """PEP 302 Importer that wraps Python's "classic" import algorithm + """PEP 302 Finder that wraps Python's "classic" import algorithm - ImpImporter(dirname) produces a PEP 302 importer that searches that - directory. ImpImporter(None) produces a PEP 302 importer that searches + ImpImporter(dirname) produces a PEP 302 finder that searches that + directory. ImpImporter(None) produces a PEP 302 finder that searches the current sys.path, plus any modules that are frozen or built-in. Note that ImpImporter does not currently support being used by placement @@ -397,7 +397,7 @@ except ImportError: def get_importer(path_item): """Retrieve a finder for the given path item - The returned importer is cached in sys.path_importer_cache + The returned finder is cached in sys.path_importer_cache if it was newly created by a path hook. The cache (or part of it) can be cleared manually if a @@ -421,14 +421,14 @@ def get_importer(path_item): def iter_importers(fullname=""): """Yield finders for the given module name - If fullname contains a '.', the importers will be for the package + If fullname contains a '.', the finders will be for the package containing fullname, otherwise they will be all registered top level - importers (i.e. those on both sys.meta_path and sys.path_hooks). + finders (i.e. those on both sys.meta_path and sys.path_hooks). If the named module is in a package, that package is imported as a side effect of invoking this function. - If no module name is specified, all top level importers are produced. + If no module name is specified, all top level finders are produced. """ if fullname.startswith('.'): msg = "Relative module name {!r} not supported".format(fullname) diff --git a/Lib/runpy.py b/Lib/runpy.py index e290c21..d86f0e4 100644 --- a/Lib/runpy.py +++ b/Lib/runpy.py @@ -98,7 +98,7 @@ def _run_module_code(code, init_globals=None, # may be cleared when the temporary module goes away return mod_globals.copy() -# Helper to get the loader, code and filename for a module +# Helper to get the full name, spec and code for a module def _get_module_details(mod_name, error=ImportError): if mod_name.startswith("."): raise error("Relative module names not supported") @@ -262,7 +262,7 @@ def run_path(path_name, init_globals=None, run_name=None): return _run_module_code(code, init_globals, run_name, pkg_name=pkg_name, script_name=fname) else: - # Importer is defined for path, so add it to + # Finder is defined for path, so add it to # the start of sys.path sys.path.insert(0, path_name) try: diff --git a/Lib/test/test_importlib/import_/test_meta_path.py b/Lib/test/test_importlib/import_/test_meta_path.py index c452cdd..5a41e89 100644 --- a/Lib/test/test_importlib/import_/test_meta_path.py +++ b/Lib/test/test_importlib/import_/test_meta_path.py @@ -76,7 +76,6 @@ class CallSignature: self.__import__(mod_name) assert len(log) == 1 args = log[0][0] - kwargs = log[0][1] # Assuming all arguments are positional. self.assertEqual(args[0], mod_name) self.assertIsNone(args[1]) diff --git a/Lib/test/test_importlib/util.py b/Lib/test/test_importlib/util.py index 43896c5..64e039e 100644 --- a/Lib/test/test_importlib/util.py +++ b/Lib/test/test_importlib/util.py @@ -266,7 +266,6 @@ class mock_spec(_ImporterMock): module = self.modules[fullname] except KeyError: return None - is_package = hasattr(module, '__path__') spec = util.spec_from_file_location( fullname, module.__file__, loader=self, submodule_search_locations=getattr(module, '__path__', None)) diff --git a/Lib/test/test_pkgutil.py b/Lib/test/test_pkgutil.py index 9d20354..a820587 100644 --- a/Lib/test/test_pkgutil.py +++ b/Lib/test/test_pkgutil.py @@ -205,7 +205,7 @@ class PkgutilPEP302Tests(unittest.TestCase): del sys.meta_path[0] def test_getdata_pep302(self): - # Use a dummy importer/loader + # Use a dummy finder/loader self.assertEqual(pkgutil.get_data('foo', 'dummy'), "Hello, world!") del sys.modules['foo'] |