From cccd1bdceb418c0ac94b133b18368deb40b2a75e Mon Sep 17 00:00:00 2001 From: ShaharNaveh <50263213+ShaharNaveh@users.noreply.github.com> Date: Sun, 14 Jun 2026 13:39:15 +0300 Subject: [PATCH 1/6] Reduce `to_owned` calls --- crates/capi/src/ceval.rs | 2 +- crates/vm/src/builtins/getset.rs | 7 +++-- crates/vm/src/eval.rs | 2 +- crates/vm/src/import.rs | 4 +-- crates/vm/src/stdlib/builtins.rs | 9 ++----- crates/vm/src/stdlib/sys.rs | 2 +- crates/vm/src/vm/compile.rs | 10 ++++--- crates/vm/src/vm/context.rs | 46 +++++++++++++++----------------- crates/vm/src/vm/python_run.rs | 10 +++---- crates/vm/src/vm/thread.rs | 7 +++-- src/lib.rs | 5 ++-- src/shell.rs | 2 +- 12 files changed, 51 insertions(+), 55 deletions(-) diff --git a/crates/capi/src/ceval.rs b/crates/capi/src/ceval.rs index be8d9c48b61..d28dad4d6df 100644 --- a/crates/capi/src/ceval.rs +++ b/crates/capi/src/ceval.rs @@ -38,7 +38,7 @@ pub unsafe extern "C" fn Py_CompileString( } }; - vm.compile(code, mode, filename.to_owned()) + vm.compile(code, mode, filename) .map_err(|err| vm.new_syntax_error(&err, Some(code))) }) } diff --git a/crates/vm/src/builtins/getset.rs b/crates/vm/src/builtins/getset.rs index ab538922a76..a2f6879940c 100644 --- a/crates/vm/src/builtins/getset.rs +++ b/crates/vm/src/builtins/getset.rs @@ -1,6 +1,5 @@ -/*! Python `attribute` descriptor class. (PyGetSet) +//! Python `attribute` descriptor class. (PyGetSet) -*/ use super::PyType; use crate::{ AsObject, Context, Py, PyObject, PyObjectRef, PyPayload, PyResult, VirtualMachine, @@ -71,9 +70,9 @@ impl GetDescriptor for PyGetSet { impl PyGetSet { #[must_use] - pub fn new(name: String, class: &'static Py) -> Self { + pub fn new(name: &str, class: &'static Py) -> Self { Self { - name, + name: name.into(), class: PointerSlot::from(class), getter: None, setter: None, diff --git a/crates/vm/src/eval.rs b/crates/vm/src/eval.rs index b69a4e05bfb..5f52799d0b9 100644 --- a/crates/vm/src/eval.rs +++ b/crates/vm/src/eval.rs @@ -1,7 +1,7 @@ use crate::{PyResult, VirtualMachine, compiler, scope::Scope}; pub fn eval(vm: &VirtualMachine, source: &str, scope: Scope, source_path: &str) -> PyResult { - match vm.compile(source, compiler::Mode::Eval, source_path.to_owned()) { + match vm.compile(source, compiler::Mode::Eval, source_path) { Ok(bytecode) => { debug!("Code object: {bytecode:?}"); vm.run_code_obj(bytecode, scope) diff --git a/crates/vm/src/import.rs b/crates/vm/src/import.rs index 798bc258b7f..d7e86422ec9 100644 --- a/crates/vm/src/import.rs +++ b/crates/vm/src/import.rs @@ -131,7 +131,7 @@ pub fn import_builtin(vm: &VirtualMachine, module_name: &str) -> PyResult { pub fn import_file( vm: &VirtualMachine, module_name: &str, - file_path: String, + file_path: &str, content: &str, ) -> PyResult { let code = vm @@ -151,7 +151,7 @@ pub fn import_source(vm: &VirtualMachine, module_name: &str, content: &str) -> P .compile_with_opts( content, crate::compiler::Mode::Exec, - "".to_owned(), + "", vm.compile_opts(), ) .map_err(|err| vm.new_syntax_error(&err, Some(content)))?; diff --git a/crates/vm/src/stdlib/builtins.rs b/crates/vm/src/stdlib/builtins.rs index 0bd04f332b5..d0ed32b22d6 100644 --- a/crates/vm/src/stdlib/builtins.rs +++ b/crates/vm/src/stdlib/builtins.rs @@ -424,12 +424,7 @@ mod builtins { opts.optimize = optimize; let code = vm - .compile_with_opts( - source, - mode, - filename.to_string_lossy().into_owned(), - opts, - ) + .compile_with_opts(source, mode, &filename.to_string_lossy(), opts) .map_err(|err| { (err, Some(source), allow_incomplete).to_pyexception(vm) })?; @@ -632,7 +627,7 @@ mod builtins { #[cfg(feature = "rustpython-compiler")] Either::A(string) => { let source = string.as_str(); - vm.compile(source, mode, "".to_owned()) + vm.compile(source, mode, "") .map_err(|err| vm.new_syntax_error(&err, Some(source)))? } #[cfg(not(feature = "rustpython-compiler"))] diff --git a/crates/vm/src/stdlib/sys.rs b/crates/vm/src/stdlib/sys.rs index ecc6ed170f5..58324a3c071 100644 --- a/crates/vm/src/stdlib/sys.rs +++ b/crates/vm/src/stdlib/sys.rs @@ -750,7 +750,7 @@ pub mod sys { handle .read_to_string(&mut source) .map_err(|e| vm.new_os_error(format!("Error reading from stdin: {e}")))?; - vm.compile(&source, crate::compiler::Mode::Single, "".to_owned()) + vm.compile(&source, crate::compiler::Mode::Single, "") .map_err(|e| vm.new_os_error(format!("Error running stdin: {e}")))?; Ok(()) } diff --git a/crates/vm/src/vm/compile.rs b/crates/vm/src/vm/compile.rs index 221df849f62..2dbdb17ff4a 100644 --- a/crates/vm/src/vm/compile.rs +++ b/crates/vm/src/vm/compile.rs @@ -13,7 +13,7 @@ impl VirtualMachine { &self, source: &str, mode: compiler::Mode, - source_path: String, + source_path: &str, ) -> Result, CompileError> { self.compile_with_opts(source, mode, source_path, self.compile_opts()) } @@ -22,15 +22,17 @@ impl VirtualMachine { &self, source: &str, mode: compiler::Mode, - source_path: String, + source_path: &str, opts: CompileOpts, ) -> Result, CompileError> { - let code = compiler::compile(source, mode, &source_path, opts) + let code = compiler::compile(source, mode, source_path, opts) .map(|code| PyCode::new_ref_from_bytecode(self, code)); + #[cfg(feature = "parser")] if code.is_ok() { - self.emit_string_escape_warnings(source, &source_path); + self.emit_string_escape_warnings(source, source_path); } + code } } diff --git a/crates/vm/src/vm/context.rs b/crates/vm/src/vm/context.rs index 4d16c5d8075..5bec58495b6 100644 --- a/crates/vm/src/vm/context.rs +++ b/crates/vm/src/vm/context.rs @@ -333,9 +333,11 @@ impl Context { ) }) .collect(); - let latin1_char_cache: Vec> = (0u8..=255) + + let latin1_char_cache = (u8::MIN..=u8::MAX) .map(|b| create_object(PyStr::from(char::from(b)), types.str_type)) - .collect(); + .collect::>>(); + let ascii_char_cache = latin1_char_cache[..128].to_vec(); let true_value = create_object(PyBool(PyInt::from(1)), types.bool_type); @@ -519,19 +521,20 @@ impl Context { fn latin1_singleton_index(s: &PyStr) -> Option { let mut cps = s.as_wtf8().code_points(); let cp = cps.next()?; - if cps.next().is_some() { - return None; - } - u8::try_from(cp.to_u32()).ok() + + cps.next() + .is_none() + .then(|| u8::try_from(cp.to_u32()).ok())? } #[inline] pub fn new_str(&self, s: impl Into) -> PyRef { let s = s.into(); if let Some(ch) = Self::latin1_singleton_index(&s) { - return self.latin1_char(ch); + self.latin1_char(ch) + } else { + s.into_ref(self) } - s.into_ref(self) } #[inline] @@ -544,9 +547,10 @@ impl Context { S: Into + AsRef, M: MaybeInternedString, { - match self.interned_str(s.as_ref()) { - Some(s) => s.to_owned(), - None => self.new_str(s), + if let Some(s) = self.interned_str(s.as_ref()) { + s.to_owned() + } else { + self.new_str(s) } } @@ -617,11 +621,7 @@ impl Context { name: &str, bases: Option>, ) -> PyTypeRef { - let bases = if let Some(bases) = bases { - bases - } else { - vec![self.exceptions.exception_type.to_owned()] - }; + let bases = bases.unwrap_or_else(|| vec![self.exceptions.exception_type.to_owned()]); let mut attrs = PyAttributes::default(); attrs.insert(identifier!(self, __module__), self.new_str(module).into()); @@ -692,21 +692,20 @@ impl Context { pub fn new_readonly_getset( &self, - name: impl Into, + name: &str, class: &'static Py, f: F, ) -> PyRef where F: IntoPyGetterFunc, { - let name = name.into(); - let getset = PyGetSet::new(name, class).with_get(f); + let getset = PyGetSet::new(&name, class).with_get(f); PyRef::new_ref(getset, self.types.getset_type.to_owned(), None) } pub fn new_static_getset( &self, - name: impl Into, + name: &str, class: &'static Py, g: G, s: S, @@ -715,19 +714,18 @@ impl Context { G: IntoPyGetterFunc, S: IntoPySetterFunc, { - let name = name.into(); - let getset = PyGetSet::new(name, class).with_get(g).with_set(s); + let getset = PyGetSet::new(&name, class).with_get(g).with_set(s); PyRef::new_ref(getset, self.types.getset_type.to_owned(), None) } - /// Creates a new `PyGetSet` with a heap type. + /// Creates a new [`PyGetSet`] with a heap type. /// /// # Safety /// In practice, this constructor is safe because a getset is always owned by its `class` type. /// However, it can be broken if used unconventionally. pub unsafe fn new_getset( &self, - name: impl Into, + name: &str, class: &Py, g: G, s: S, diff --git a/crates/vm/src/vm/python_run.rs b/crates/vm/src/vm/python_run.rs index ccb295465ec..c21b437b575 100644 --- a/crates/vm/src/vm/python_run.rs +++ b/crates/vm/src/vm/python_run.rs @@ -13,13 +13,13 @@ impl VirtualMachine { /// Execute a string of Python code in a new scope with builtins. pub fn run_simple_string(&self, source: &str) -> PyResult { let scope = self.new_scope_with_builtins(); - self.run_string(scope, source, "".to_owned()) + self.run_string(scope, source, "") } /// PyRun_String /// /// Execute a string of Python code with explicit scope and source path. - pub fn run_string(&self, scope: Scope, source: &str, source_path: String) -> PyResult { + pub fn run_string(&self, scope: Scope, source: &str, source_path: &str) -> PyResult { let code_obj = self .compile(source, compiler::Mode::Exec, source_path) .map_err(|err| self.new_syntax_error(&err, Some(source)))?; @@ -40,13 +40,13 @@ impl VirtualMachine { } #[deprecated(note = "use run_string instead")] - pub fn run_code_string(&self, scope: Scope, source: &str, source_path: String) -> PyResult { + pub fn run_code_string(&self, scope: Scope, source: &str, source_path: &str) -> PyResult { self.run_string(scope, source, source_path) } pub fn run_block_expr(&self, scope: Scope, source: &str) -> PyResult { let code_obj = self - .compile(source, compiler::Mode::BlockExpr, "".to_owned()) + .compile(source, compiler::Mode::BlockExpr, "") .map_err(|err| self.new_syntax_error(&err, Some(source)))?; self.run_code_obj(code_obj, scope) } @@ -108,7 +108,7 @@ mod file_run { match crate::host_env::fs::read_to_string(path) { Ok(source) => { let code_obj = self - .compile(&source, compiler::Mode::Exec, path.to_owned()) + .compile(&source, compiler::Mode::Exec, path) .map_err(|err| self.new_syntax_error(&err, Some(&source)))?; self.run_code_obj(code_obj, scope)?; } diff --git a/crates/vm/src/vm/thread.rs b/crates/vm/src/vm/thread.rs index f89cf818d2c..33fcec5e43e 100644 --- a/crates/vm/src/vm/thread.rs +++ b/crates/vm/src/vm/thread.rs @@ -2,10 +2,11 @@ use super::FramePtr; #[cfg(feature = "threading")] use crate::builtins::PyBaseExceptionRef; -use crate::frame::Frame; -use crate::{AsObject, PyObject, VirtualMachine}; #[cfg(feature = "threading")] use alloc::sync::Arc; + +use crate::frame::Frame; +use crate::{AsObject, PyObject, VirtualMachine}; use core::{ cell::{Cell, RefCell}, ptr::NonNull, @@ -129,6 +130,7 @@ pub fn enter_vm(vm: &VirtualMachine, f: impl FnOnce() -> R) -> R { detach_thread(); } } + set_current_vm(vm, f) } @@ -538,6 +540,7 @@ pub fn cleanup_current_thread_frames(vm: &VirtualMachine) { } else { None }; + #[cfg(all(unix, feature = "threading"))] if let Some(slot) = &_removed && vm.state.stop_the_world.requested.load(Ordering::Acquire) diff --git a/src/lib.rs b/src/lib.rs index d7dc6255e41..4204edc8850 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -146,7 +146,7 @@ __import__("io").TextIOWrapper( .downcast() .expect("TextIOWrapper.read() should return str"); eprintln!("running get-pip.py..."); - vm.run_string(scope, getpip_code.expect_str(), "get-pip.py".to_owned())?; + vm.run_string(scope, getpip_code.expect_str(), "get-pip.py")?; Ok(()) } @@ -294,8 +294,7 @@ fn run_rustpython(vm: &VirtualMachine, run_mode: RunMode) -> PyResult<()> { let res = match run_mode { RunMode::Command(command) => { debug!("Running command {command}"); - vm.run_string(scope.clone(), &command, "".to_owned()) - .map(drop) + vm.run_string(scope.clone(), &command, "").map(drop) } RunMode::Module(module) => { debug!("Running module {module}"); diff --git a/src/shell.rs b/src/shell.rs index 6c75e94572c..bc7ccec5c9d 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -32,7 +32,7 @@ fn shell_exec( // was actually compiled. #[cfg(windows)] let source = &source.replace("\r\n", "\n"); - match vm.compile(source, compiler::Mode::Single, "".to_owned()) { + match vm.compile(source, compiler::Mode::Single, "") { Ok(code) => { if empty_line_given || !continuing_block { // We want to execute the full code From 7ab95fdf90af9bbfa24985c81ca7e09311163b22 Mon Sep 17 00:00:00 2001 From: ShaharNaveh <50263213+ShaharNaveh@users.noreply.github.com> Date: Sun, 14 Jun 2026 14:33:23 +0300 Subject: [PATCH 2/6] fix more --- benches/execution.rs | 2 +- benches/microbenchmarks.rs | 4 ++-- crates/stdlib/src/_opcode.rs | 6 +++--- crates/vm/src/vm/context.rs | 4 ++-- crates/vm/src/vm/mod.rs | 2 +- examples/hello_embed.rs | 2 +- examples/mini_repl.rs | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/benches/execution.rs b/benches/execution.rs index 2816f0e8201..0eef88c8b99 100644 --- a/benches/execution.rs +++ b/benches/execution.rs @@ -30,7 +30,7 @@ fn bench_rustpython_code(b: &mut Bencher, name: &str, source: &str) { // Note: bench_cpython is both compiling and executing the code. // As such we compile the code in the benchmark loop as well. b.iter(|| { - let code = vm.compile(source, Mode::Exec, name.to_owned()).unwrap(); + let code = vm.compile(source, Mode::Exec, name).unwrap(); let scope = vm.new_scope_with_builtins(); let res: PyResult = vm.run_code_obj(code.clone(), scope); vm.unwrap_pyresult(res); diff --git a/benches/microbenchmarks.rs b/benches/microbenchmarks.rs index 3fef2f8dd7e..34e0b68468d 100644 --- a/benches/microbenchmarks.rs +++ b/benches/microbenchmarks.rs @@ -118,10 +118,10 @@ fn bench_rustpython_code(group: &mut BenchmarkGroup, bench: &MicroBenc let interp = builder.add_native_modules(&defs).build(); interp.enter(|vm| { let setup_code = vm - .compile(&bench.setup, Mode::Exec, bench.name.to_owned()) + .compile(&bench.setup, Mode::Exec, &bench.name) .expect("Error compiling setup code"); let bench_code = vm - .compile(&bench.code, Mode::Exec, bench.name.to_owned()) + .compile(&bench.code, Mode::Exec, &bench.name) .expect("Error compiling bench code"); let bench_func = |scope| { diff --git a/crates/stdlib/src/_opcode.rs b/crates/stdlib/src/_opcode.rs index bfdb06b305f..2b2a70b5572 100644 --- a/crates/stdlib/src/_opcode.rs +++ b/crates/stdlib/src/_opcode.rs @@ -192,7 +192,7 @@ mod tests { /// /// Memory addresses in the output are replaced with `0xdeadbeef` for consistency. fn dis(source: &str) -> String { - let fname = String::from(""); + const FNAME: &str = ""; let builder = vm::Interpreter::builder(Default::default()); let stdlib_defs = crate::stdlib_module_defs(&builder.ctx); @@ -204,7 +204,7 @@ mod tests { interp.enter(|vm| { let scope = vm.new_scope_with_builtins(); let code_obj = vm - .compile(source.trim(), Mode::Exec, fname.clone()) + .compile(source.trim(), Mode::Exec, FNAME) .map_err(|err| vm.new_syntax_error(&err, Some(source))) .unwrap(); scope.globals.set_item("code", code_obj.into(), vm).unwrap(); @@ -227,7 +227,7 @@ output = re.sub(r'(0xdeadbeef', tmp "#; let py_code_obj = vm - .compile(py_source, Mode::Exec, fname) + .compile(py_source, Mode::Exec, FNAME) .map_err(|err| vm.new_syntax_error(&err, Some(py_source))) .unwrap(); diff --git a/crates/vm/src/vm/context.rs b/crates/vm/src/vm/context.rs index 5bec58495b6..226d5f1a1a7 100644 --- a/crates/vm/src/vm/context.rs +++ b/crates/vm/src/vm/context.rs @@ -699,7 +699,7 @@ impl Context { where F: IntoPyGetterFunc, { - let getset = PyGetSet::new(&name, class).with_get(f); + let getset = PyGetSet::new(name, class).with_get(f); PyRef::new_ref(getset, self.types.getset_type.to_owned(), None) } @@ -714,7 +714,7 @@ impl Context { G: IntoPyGetterFunc, S: IntoPySetterFunc, { - let getset = PyGetSet::new(&name, class).with_get(g).with_set(s); + let getset = PyGetSet::new(name, class).with_get(g).with_set(s); PyRef::new_ref(getset, self.types.getset_type.to_owned(), None) } diff --git a/crates/vm/src/vm/mod.rs b/crates/vm/src/vm/mod.rs index 699c751fcba..eb6546c02fe 100644 --- a/crates/vm/src/vm/mod.rs +++ b/crates/vm/src/vm/mod.rs @@ -2285,7 +2285,7 @@ mod tests { let source = "from dir_module.dir_module_inner import value2"; let code_obj = vm - .compile(source, vm::compiler::Mode::Exec, "".to_owned()) + .compile(source, vm::compiler::Mode::Exec, "") .map_err(|err| vm.new_syntax_error(&err, Some(source))) .unwrap(); diff --git a/examples/hello_embed.rs b/examples/hello_embed.rs index 958fdaaf499..9e1cdb829d6 100644 --- a/examples/hello_embed.rs +++ b/examples/hello_embed.rs @@ -5,7 +5,7 @@ fn main() -> vm::PyResult<()> { let scope = vm.new_scope_with_builtins(); let source = r#"print("Hello World!")"#; let code_obj = vm - .compile(source, vm::compiler::Mode::Exec, "".to_owned()) + .compile(source, vm::compiler::Mode::Exec, "") .map_err(|err| vm.new_syntax_error(&err, Some(source)))?; vm.run_code_obj(code_obj, scope)?; diff --git a/examples/mini_repl.rs b/examples/mini_repl.rs index d7baa4692c2..40d111732ae 100644 --- a/examples/mini_repl.rs +++ b/examples/mini_repl.rs @@ -65,7 +65,7 @@ def fib(n): // this line also automatically prints the output // (note that this is only the case when compiler::Mode::Single is passed to vm.compile) match vm - .compile(&input, vm::compiler::Mode::Single, "".to_owned()) + .compile(&input, vm::compiler::Mode::Single, "") .map_err(|err| vm.new_syntax_error(&err, Some(&input))) .and_then(|code_obj| vm.run_code_obj(code_obj, scope.clone())) { From 30f2075161a83e8987606d6d358ea530d1010924 Mon Sep 17 00:00:00 2001 From: ShaharNaveh <50263213+ShaharNaveh@users.noreply.github.com> Date: Sun, 14 Jun 2026 15:21:41 +0300 Subject: [PATCH 3/6] Fix wasm --- crates/wasm/src/vm_class.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wasm/src/vm_class.rs b/crates/wasm/src/vm_class.rs index cface5b3868..08cb49ecfca 100644 --- a/crates/wasm/src/vm_class.rs +++ b/crates/wasm/src/vm_class.rs @@ -263,7 +263,7 @@ impl WASMVirtualMachine { ) -> Result<(), JsValue> { self.with_vm(|vm, _| { let code = vm - .compile(source, Mode::Exec, name.clone()) + .compile(source, Mode::Exec, &name) .map_err(convert::syntax_err)?; let attrs = vm.ctx.new_dict(); attrs @@ -327,7 +327,7 @@ impl WASMVirtualMachine { ) -> Result { self.with_vm(|vm, StoredVirtualMachine { scope, .. }| { let source_path = source_path.unwrap_or_else(|| "".to_owned()); - let code = vm.compile(source, mode, source_path); + let code = vm.compile(source, mode, &source_path); let code = code.map_err(convert::syntax_err)?; let result = vm.run_code_obj(code, scope.clone()); convert::pyresult_to_js_result(vm, result) From 0df603aa6a9de72d7b0a8b3365f1e4dfdfdde8b1 Mon Sep 17 00:00:00 2001 From: ShaharNaveh <50263213+ShaharNaveh@users.noreply.github.com> Date: Sun, 14 Jun 2026 15:41:10 +0300 Subject: [PATCH 4/6] doctest --- crates/vm/src/vm/interpreter.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/vm/src/vm/interpreter.rs b/crates/vm/src/vm/interpreter.rs index 770e493415e..79e3e190a2f 100644 --- a/crates/vm/src/vm/interpreter.rs +++ b/crates/vm/src/vm/interpreter.rs @@ -300,9 +300,7 @@ impl Default for InterpreterBuilder { /// let scope = vm.new_scope_with_builtins(); /// let source = r#"print("Hello World!")"#; /// let code_obj = vm.compile( -/// source, -/// Mode::Exec, -/// "".to_owned(), +/// source, Mode::Exec, "" /// ).map_err(|err| vm.new_syntax_error(&err, Some(source))).unwrap(); /// vm.run_code_obj(code_obj, scope).unwrap(); /// }); From f38b3048d62789c765df2cf8bf3241c96bd51e3c Mon Sep 17 00:00:00 2001 From: ShaharNaveh <50263213+ShaharNaveh@users.noreply.github.com> Date: Sun, 14 Jun 2026 17:05:13 +0300 Subject: [PATCH 5/6] Skip flaky test on windows --- Lib/test/test_thread.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/test/test_thread.py b/Lib/test/test_thread.py index 60f4d7c7df9..dc55174421a 100644 --- a/Lib/test/test_thread.py +++ b/Lib/test/test_thread.py @@ -115,7 +115,7 @@ def test_nt_and_posix_stack_size(self): thread.stack_size(0) - @unittest.skipIf(__import__("sys").platform == "linux", "TODO: RUSTPYTHON; Flakey on CI") + @unittest.skipIf(__import__("sys").platform in ("linux", "win32"), "TODO: RUSTPYTHON; Flakey on CI") def test__count(self): # Test the _count() function. orig = thread._count() From 215003a1c5f04cbcbff2e12d2eb670657bee0822 Mon Sep 17 00:00:00 2001 From: ShaharNaveh <50263213+ShaharNaveh@users.noreply.github.com> Date: Sun, 14 Jun 2026 17:07:18 +0300 Subject: [PATCH 6/6] fix when no hostenv --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 4204edc8850..9a5cede9bd4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -190,7 +190,7 @@ fn run_file(vm: &VirtualMachine, scope: Scope, path: &str) -> PyResult<()> { // The VM itself has no filesystem access. let path = if path.is_empty() { "???" } else { path }; match std::fs::read_to_string(path) { - Ok(source) => vm.run_string(scope, &source, path.to_owned()).map(drop), + Ok(source) => vm.run_string(scope, &source, path).map(drop), Err(err) => Err(vm.new_os_error(err.to_string())), } }