diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2014-01-07 03:42:59 (GMT) |
---|---|---|
committer | Eric Snow <ericsnowcurrently@gmail.com> | 2014-01-07 03:42:59 (GMT) |
commit | 3a62d14b24843de4884ea8d0167bc1285b285a97 (patch) | |
tree | fcaa670459f27aa6fc4e4902cdc7b4d53a207e2b /Lib/pydoc.py | |
parent | 3192eac6cfa658cb66e42bea4c7c59cef85fd6fc (diff) | |
download | cpython-3a62d14b24843de4884ea8d0167bc1285b285a97.zip cpython-3a62d14b24843de4884ea8d0167bc1285b285a97.tar.gz cpython-3a62d14b24843de4884ea8d0167bc1285b285a97.tar.bz2 |
Issue #19703: Update pydoc to use the new importer APIs.
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-x | Lib/pydoc.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 1369e8a..9f62692 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -246,8 +246,12 @@ def synopsis(filename, cache={}): else: # Must be a binary module, which has to be imported. loader = loader_cls('__temp__', filename) + # XXX We probably don't need to pass in the loader here. + spec = importlib.util.spec_from_file_location('__temp__', filename, + loader=loader) + _spec = importlib._bootstrap._SpecMethods(spec) try: - module = loader.load_module('__temp__') + module = _spec.load() except: return None del sys.modules['__temp__'] @@ -277,8 +281,11 @@ def importfile(path): loader = importlib._bootstrap.SourcelessFileLoader(name, path) else: loader = importlib._bootstrap.SourceFileLoader(name, path) + # XXX We probably don't need to pass in the loader here. + spec = importlib.util.spec_from_file_location(name, path, loader=loader) + _spec = importlib._bootstrap._SpecMethods(spec) try: - return loader.load_module(name) + return _spec.load() except: raise ErrorDuringImport(path, sys.exc_info()) @@ -2008,10 +2015,11 @@ class ModuleScanner: callback(None, modname, '') else: try: - loader = importer.find_module(modname) + spec = pkgutil._get_spec(importer, modname) except SyntaxError: # raised by tests for bad coding cookies or BOM continue + loader = spec.loader if hasattr(loader, 'get_source'): try: source = loader.get_source(modname) @@ -2025,8 +2033,9 @@ class ModuleScanner: else: path = None else: + _spec = importlib._bootstrap._SpecMethods(spec) try: - module = loader.load_module(modname) + module = _spec.load() except ImportError: if onerror: onerror(modname) |