PyRun_String Execute a string of Python code with explicit scope and source path.
(&self, scope: Scope, source: &str, source_path: String)
| 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. |