MCPcopy Index your code
hub / github.com/RustPython/RustPython / load_module

Method load_module

Lib/zipimport.py:214–256  ·  view source on GitHub ↗

load_module(fullname) -> module. Load the module specified by 'fullname'. 'fullname' must be the fully qualified (dotted) module name. It returns the imported module, or raises ZipImportError if it could not be imported. Deprecated since Python 3.10. Use exec_module

(self, fullname)

Source from the content-addressed store, hash-verified

212
213 # Load and return the module named by 'fullname'.
214 def load_module(self, fullname):
215 """load_module(fullname) -> module.
216
217 Load the module specified by 'fullname'. 'fullname' must be the
218 fully qualified (dotted) module name. It returns the imported
219 module, or raises ZipImportError if it could not be imported.
220
221 Deprecated since Python 3.10. Use exec_module() instead.
222 """
223 import warnings
224 warnings._deprecated("zipimport.zipimporter.load_module",
225 f"{warnings._DEPRECATED_MSG}; "
226 "use zipimport.zipimporter.exec_module() instead",
227 remove=(3, 15))
228 code, ispackage, modpath = _get_module_code(self, fullname)
229 mod = sys.modules.get(fullname)
230 if mod is None or not isinstance(mod, _module_type):
231 mod = _module_type(fullname)
232 sys.modules[fullname] = mod
233 mod.__loader__ = self
234
235 try:
236 if ispackage:
237 # add __path__ to the module *before* the code gets
238 # executed
239 path = _get_module_path(self, fullname)
240 fullpath = _bootstrap_external._path_join(self.archive, path)
241 mod.__path__ = [fullpath]
242
243 if not hasattr(mod, '__builtins__'):
244 mod.__builtins__ = __builtins__
245 _bootstrap_external._fix_up_module(mod.__dict__, fullname, modpath)
246 exec(code, mod.__dict__)
247 except:
248 del sys.modules[fullname]
249 raise
250
251 try:
252 mod = sys.modules[fullname]
253 except KeyError:
254 raise ImportError(f'Loaded module {fullname!r} not found in sys.modules')
255 _bootstrap._verbose_message('import {} # loaded from Zip {}', fullname, modpath)
256 return mod
257
258
259 def get_resource_reader(self, fullname):

Callers

nothing calls this directly

Calls 7

_get_module_codeFunction · 0.85
isinstanceFunction · 0.85
_get_module_pathFunction · 0.85
hasattrFunction · 0.85
execFunction · 0.50
getMethod · 0.45
_fix_up_moduleMethod · 0.45

Tested by

no test coverage detected