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

Function import_source

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

Source from the content-addressed store, hash-verified

142
143#[cfg(feature = "rustpython-compiler")]
144pub fn import_source(vm: &VirtualMachine, module_name: &str, content: &str) -> PyResult {
145 let code = vm
146 .compile_with_opts(
147 content,
148 crate::compiler::Mode::Exec,
149 "<source>".to_owned(),
150 vm.compile_opts(),
151 )
152 .map_err(|err| vm.new_syntax_error(&err, Some(content)))?;
153 import_code_obj(vm, module_name, code, false)
154}
155
156/// If `__spec__._initializing` is true, wait for the module to finish
157/// initializing by calling `_lock_unlock_module`.

Callers 1

load_moduleFunction · 0.85

Calls 6

import_code_objFunction · 0.85
compile_with_optsMethod · 0.80
compile_optsMethod · 0.80
new_syntax_errorMethod · 0.80
SomeClass · 0.50
to_ownedMethod · 0.45

Tested by

no test coverage detected