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

Function _get_module_code

tools/python-3.11.9-amd64/Lib/zipimport.py:746–778  ·  view source on GitHub ↗
(self, fullname)

Source from the content-addressed store, hash-verified

744# Get the code object associated with the module specified by
745# 'fullname'.
746def _get_module_code(self, fullname):
747 path = _get_module_path(self, fullname)
748 import_error = None
749 for suffix, isbytecode, ispackage in _zip_searchorder:
750 fullpath = path + suffix
751 _bootstrap._verbose_message('trying {}{}{}', self.archive, path_sep, fullpath, verbosity=2)
752 try:
753 toc_entry = self._files[fullpath]
754 except KeyError:
755 pass
756 else:
757 modpath = toc_entry[0]
758 data = _get_data(self.archive, toc_entry)
759 code = None
760 if isbytecode:
761 try:
762 code = _unmarshal_code(self, modpath, fullpath, fullname, data)
763 except ImportError as exc:
764 import_error = exc
765 else:
766 code = _compile_source(modpath, data)
767 if code is None:
768 # bad magic number or non-matching mtime
769 # in byte code, try next
770 continue
771 modpath = toc_entry[0]
772 return code, ispackage, modpath
773 else:
774 if import_error:
775 msg = f"module load failed: {import_error}"
776 raise ZipImportError(msg, name=fullname) from import_error
777 else:
778 raise ZipImportError(f"can't find module {fullname!r}", name=fullname)

Callers 3

get_codeMethod · 0.85
get_filenameMethod · 0.85
load_moduleMethod · 0.85

Calls 5

_get_module_pathFunction · 0.85
_get_dataFunction · 0.85
_unmarshal_codeFunction · 0.85
_compile_sourceFunction · 0.85
ZipImportErrorClass · 0.85

Tested by

no test coverage detected