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

Method register_code_in_linecache

crates/vm/src/vm/python_run.rs:33–40  ·  view source on GitHub ↗

Register a code object's source in linecache._interactive_cache so that traceback can display source lines and caret indicators.

(&self, code: &PyRef<PyCode>, source: &str)

Source from the content-addressed store, hash-verified

31 /// Register a code object's source in linecache._interactive_cache
32 /// so that traceback can display source lines and caret indicators.
33 fn register_code_in_linecache(&self, code: &PyRef<PyCode>, source: &str) -> PyResult<()> {
34 let linecache = self.import("linecache", 0)?;
35 let register = linecache.get_attr("_register_code", self)?;
36 let source_str = self.ctx.new_str(source);
37 let filename = self.ctx.new_str(code.source_path().as_str());
38 register.call((code.as_object().to_owned(), source_str, filename), self)?;
39 Ok(())
40 }
41
42 #[deprecated(note = "use run_string instead")]
43 pub fn run_code_string(&self, scope: Scope, source: &str, source_path: String) -> PyResult {

Callers 1

run_stringMethod · 0.80

Calls 8

importMethod · 0.45
get_attrMethod · 0.45
new_strMethod · 0.45
as_strMethod · 0.45
source_pathMethod · 0.45
callMethod · 0.45
to_ownedMethod · 0.45
as_objectMethod · 0.45

Tested by

no test coverage detected