diff --git a/mitogen/core.py b/mitogen/core.py index e796129d..f8c0b2db 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -1357,6 +1357,16 @@ class Importer(object): fp.close() def find_module(self, fullname, path=None): + """ + Return a loader (ourself) or None, for the module with fullname. + + Implements importlib.abc.MetaPathFinder.find_module(). + Deprecrated in Python 3.4+, replaced by find_spec(). + Raises ImportWarning in Python 3.10+. + + fullname A (fully qualified?) module name, e.g. "os.path". + path __path__ of parent packge. None for a top level module. + """ if hasattr(_tls, 'running'): return None @@ -1478,6 +1488,12 @@ class Importer(object): callback() def load_module(self, fullname): + """ + Return the loaded module specified by fullname. + + Implements importlib.abc.Loader.load_module(). + Deprecated in Python 3.4+, replaced by create_module() & exec_module(). + """ fullname = to_text(fullname) _v and self._log.debug('requesting %s', fullname) self._refuse_imports(fullname) diff --git a/mitogen/master.py b/mitogen/master.py index 806120d6..dbb4d2b9 100644 --- a/mitogen/master.py +++ b/mitogen/master.py @@ -122,6 +122,13 @@ def is_stdlib_name(modname): """ Return :data:`True` if `modname` appears to come from the standard library. """ + # `imp.is_builtin()` isn't a documented as part of Python's stdlib API. + # + # """ + # Main is a little special - imp.is_builtin("__main__") will return False, + # but BuiltinImporter is still the most appropriate initial setting for + # its __loader__ attribute. + # """ -- comment in CPython pylifecycle.c:add_main_module() if imp.is_builtin(modname) != 0: return True @@ -512,6 +519,8 @@ class PkgutilMethod(FinderMethod): Find `fullname` using :func:`pkgutil.find_loader`. """ try: + # If fullname refers to a submodule that's not already imported + # then the containing package is imported. # Pre-'import spec' this returned None, in Python3.6 it raises # ImportError. loader = pkgutil.find_loader(fullname)