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

Function import_file

crates/vm/src/import.rs:126–141  ·  view source on GitHub ↗
(
    vm: &VirtualMachine,
    module_name: &str,
    file_path: String,
    content: &str,
)

Source from the content-addressed store, hash-verified

124
125#[cfg(feature = "rustpython-compiler")]
126pub fn import_file(
127 vm: &VirtualMachine,
128 module_name: &str,
129 file_path: String,
130 content: &str,
131) -> PyResult {
132 let code = vm
133 .compile_with_opts(
134 content,
135 crate::compiler::Mode::Exec,
136 file_path,
137 vm.compile_opts(),
138 )
139 .map_err(|err| vm.new_syntax_error(&err, Some(content)))?;
140 import_code_obj(vm, module_name, code, true)
141}
142
143#[cfg(feature = "rustpython-compiler")]
144pub fn import_source(vm: &VirtualMachine, module_name: &str, content: &str) -> PyResult {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected