MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / load_module

Method load_module

tools/python-3.11.9-amd64/Lib/zipimport.py:271–311  ·  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_

(self, fullname)

Source from the content-addressed store, hash-verified

269
270 # Load and return the module named by 'fullname'.
271 def load_module(self, fullname):
272 """load_module(fullname) -> module.
273
274 Load the module specified by 'fullname'. 'fullname' must be the
275 fully qualified (dotted) module name. It returns the imported
276 module, or raises ZipImportError if it could not be imported.
277
278 Deprecated since Python 3.10. Use exec_module() instead.
279 """
280 msg = ("zipimport.zipimporter.load_module() is deprecated and slated for "
281 "removal in Python 3.12; use exec_module() instead")
282 _warnings.warn(msg, DeprecationWarning)
283 code, ispackage, modpath = _get_module_code(self, fullname)
284 mod = sys.modules.get(fullname)
285 if mod is None or not isinstance(mod, _module_type):
286 mod = _module_type(fullname)
287 sys.modules[fullname] = mod
288 mod.__loader__ = self
289
290 try:
291 if ispackage:
292 # add __path__ to the module *before* the code gets
293 # executed
294 path = _get_module_path(self, fullname)
295 fullpath = _bootstrap_external._path_join(self.archive, path)
296 mod.__path__ = [fullpath]
297
298 if not hasattr(mod, '__builtins__'):
299 mod.__builtins__ = __builtins__
300 _bootstrap_external._fix_up_module(mod.__dict__, fullname, modpath)
301 exec(code, mod.__dict__)
302 except:
303 del sys.modules[fullname]
304 raise
305
306 try:
307 mod = sys.modules[fullname]
308 except KeyError:
309 raise ImportError(f'Loaded module {fullname!r} not found in sys.modules')
310 _bootstrap._verbose_message('import {} # loaded from Zip {}', fullname, modpath)
311 return mod
312
313
314 def get_resource_reader(self, fullname):

Callers

nothing calls this directly

Calls 5

_get_module_codeFunction · 0.85
_get_module_pathFunction · 0.85
_fix_up_moduleMethod · 0.80
warnMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected