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

Function import_frozen

crates/vm/src/import.rs:78–90  ·  view source on GitHub ↗
(vm: &VirtualMachine, module_name: &str)

Source from the content-addressed store, hash-verified

76}
77
78pub fn import_frozen(vm: &VirtualMachine, module_name: &str) -> PyResult {
79 let frozen = vm.state.frozen.get(module_name).ok_or_else(|| {
80 vm.new_import_error(
81 format!("No such frozen object named {module_name}"),
82 vm.ctx.new_utf8_str(module_name),
83 )
84 })?;
85 let module = import_code_obj(vm, module_name, vm.ctx.new_code(frozen.code), false)?;
86 debug_assert!(module.get_attr(identifier!(vm, __name__), vm).is_ok());
87 let origname = resolve_frozen_alias(module_name);
88 module.set_attr("__origname__", vm.ctx.new_utf8_str(origname), vm)?;
89 Ok(module)
90}
91
92pub fn import_builtin(vm: &VirtualMachine, module_name: &str) -> PyResult {
93 let sys_modules = vm.sys_module.get_attr("modules", vm)?;

Callers 4

init_importlib_baseFunction · 0.85
init_frozenFunction · 0.85
initializeMethod · 0.85
frozen_origname_matchesFunction · 0.85

Calls 8

import_code_objFunction · 0.85
resolve_frozen_aliasFunction · 0.85
ok_or_elseMethod · 0.80
new_import_errorMethod · 0.80
new_utf8_strMethod · 0.80
getMethod · 0.45
new_codeMethod · 0.45
set_attrMethod · 0.45

Tested by 1

frozen_origname_matchesFunction · 0.68