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

Function _get_module_code

Lib/zipimport.py:790–822  ·  view source on GitHub ↗
(self, fullname)

Source from the content-addressed store, hash-verified

788# Get the code object associated with the module specified by
789# 'fullname'.
790def _get_module_code(self, fullname):
791 path = _get_module_path(self, fullname)
792 import_error = None
793 for suffix, isbytecode, ispackage in _zip_searchorder:
794 fullpath = path + suffix
795 _bootstrap._verbose_message('trying {}{}{}', self.archive, path_sep, fullpath, verbosity=2)
796 try:
797 toc_entry = self._get_files()[fullpath]
798 except KeyError:
799 pass
800 else:
801 modpath = toc_entry[0]
802 data = _get_data(self.archive, toc_entry)
803 code = None
804 if isbytecode:
805 try:
806 code = _unmarshal_code(self, modpath, fullpath, fullname, data)
807 except ImportError as exc:
808 import_error = exc
809 else:
810 code = _compile_source(modpath, data)
811 if code is None:
812 # bad magic number or non-matching mtime
813 # in byte code, try next
814 continue
815 modpath = toc_entry[0]
816 return code, ispackage, modpath
817 else:
818 if import_error:
819 msg = f"module load failed: {import_error}"
820 raise ZipImportError(msg, name=fullname) from import_error
821 else:
822 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 6

_get_module_pathFunction · 0.85
_get_dataFunction · 0.85
_unmarshal_codeFunction · 0.85
_compile_sourceFunction · 0.85
ZipImportErrorClass · 0.85
_get_filesMethod · 0.80

Tested by

no test coverage detected