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

Method load_module

Lib/modulefinder.py:329–356  ·  view source on GitHub ↗
(self, fqname, fp, pathname, file_info)

Source from the content-addressed store, hash-verified

327 return m
328
329 def load_module(self, fqname, fp, pathname, file_info):
330 suffix, mode, type = file_info
331 self.msgin(2, "load_module", fqname, fp and "fp", pathname)
332 if type == _PKG_DIRECTORY:
333 m = self.load_package(fqname, pathname)
334 self.msgout(2, "load_module ->", m)
335 return m
336 if type == _PY_SOURCE:
337 co = compile(fp.read(), pathname, 'exec')
338 elif type == _PY_COMPILED:
339 try:
340 data = fp.read()
341 importlib._bootstrap_external._classify_pyc(data, fqname, {})
342 except ImportError as exc:
343 self.msgout(2, "raise ImportError: " + str(exc), pathname)
344 raise
345 co = marshal.loads(memoryview(data)[16:])
346 else:
347 co = None
348 m = self.add_module(fqname)
349 m.__file__ = pathname
350 if co:
351 if self.replace_paths:
352 co = self.replace_paths_in_code(co)
353 m.__code__ = co
354 self.scan_code(co, m)
355 self.msgout(2, "load_module ->", m)
356 return m
357
358 def _add_badmodule(self, name, caller):
359 if name not in self.badmodules:

Callers 4

run_scriptMethod · 0.95
load_fileMethod · 0.95
import_moduleMethod · 0.95
load_packageMethod · 0.95

Calls 10

msginMethod · 0.95
load_packageMethod · 0.95
msgoutMethod · 0.95
add_moduleMethod · 0.95
replace_paths_in_codeMethod · 0.95
scan_codeMethod · 0.95
strFunction · 0.85
compileFunction · 0.70
readMethod · 0.45
loadsMethod · 0.45

Tested by

no test coverage detected