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

Method run_string

crates/vm/src/vm/python_run.rs:22–29  ·  view source on GitHub ↗

PyRun_String Execute a string of Python code with explicit scope and source path.

(&self, scope: Scope, source: &str, source_path: String)

Source from the content-addressed store, hash-verified

20 ///
21 /// Execute a string of Python code with explicit scope and source path.
22 pub fn run_string(&self, scope: Scope, source: &str, source_path: String) -> PyResult {
23 let code_obj = self
24 .compile(source, compiler::Mode::Exec, source_path)
25 .map_err(|err| self.new_syntax_error(&err, Some(source)))?;
26 // linecache._register_code(code, source, filename)
27 let _ = self.register_code_in_linecache(&code_obj, source);
28 self.run_code_obj(code_obj, scope)
29 }
30
31 /// Register a code object's source in linecache._interactive_cache
32 /// so that traceback can display source lines and caret indicators.

Callers 7

_from_subinterpMethod · 0.80
get_pipFunction · 0.80
run_fileFunction · 0.80
run_rustpythonFunction · 0.80
run_simple_stringMethod · 0.80
run_code_stringMethod · 0.80

Calls 5

new_syntax_errorMethod · 0.80
run_code_objMethod · 0.80
SomeClass · 0.50
compileMethod · 0.45

Tested by 1