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

Method import_inner

crates/vm/src/vm/mod.rs:1800–1823  ·  view source on GitHub ↗
(
        &self,
        module: &Py<PyStr>,
        from_list: &Py<PyTuple<PyStrRef>>,
        level: usize,
    )

Source from the content-addressed store, hash-verified

1798 }
1799
1800 fn import_inner(
1801 &self,
1802 module: &Py<PyStr>,
1803 from_list: &Py<PyTuple<PyStrRef>>,
1804 level: usize,
1805 ) -> PyResult {
1806 let import_func = self
1807 .builtins
1808 .get_attr(identifier!(self, __import__), self)
1809 .map_err(|_| self.new_import_error("__import__ not found", module.to_owned()))?;
1810
1811 let (locals, globals) = if let Some(frame) = self.current_frame() {
1812 (
1813 Some(frame.locals.clone_mapping(self)),
1814 Some(frame.globals.clone()),
1815 )
1816 } else {
1817 (None, None)
1818 };
1819 let from_list: PyObjectRef = from_list.to_owned().into();
1820 import_func
1821 .call((module.to_owned(), globals, locals, from_list, level), self)
1822 .inspect_err(|exc| import::remove_importlib_frames(self, exc))
1823 }
1824
1825 pub fn extract_elements_with<T, F>(&self, value: &PyObject, func: F) -> PyResult<Vec<T>>
1826 where

Callers 2

importMethod · 0.80
import_fromMethod · 0.80

Calls 9

remove_importlib_framesFunction · 0.85
new_import_errorMethod · 0.80
current_frameMethod · 0.80
clone_mappingMethod · 0.80
SomeClass · 0.50
get_attrMethod · 0.45
to_ownedMethod · 0.45
cloneMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected