def load_module(self, fullname, path=None):
imp_lock()
try:
# PEP302 If there is an existing module object named 'fullname'
# in sys.modules, the loader must use that existing module.
module = sys.modules.get(fullname)
if module is None:
module = imp.init_builtin(fullname)
except Exception:
# Remove 'fullname' from sys.modules if it was appended there.
if fullname in sys.modules:
sys.modules.pop(fullname)
raise # Raise the same exception again.
finally:
# Release the interpreter's import lock.
imp_unlock()
return module
### Optional Extensions to the PEP-302 Importer Protocol
评论列表
文章目录