Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Take &Py<PyCode> in register_code_in_linecache
Assisted-by: Grok:4.6
  • Loading branch information
youknowone committed Sep 21, 2026
commit 80990bfb0f76e199f05049795dffacb230292ed4
6 changes: 3 additions & 3 deletions crates/vm/src/vm/python_run.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Python code execution functions.

use crate::{
AsObject, PyRef, PyResult, VirtualMachine,
Py, PyRef, PyResult, VirtualMachine,
builtins::PyCode,
compiler::{self},
scope::Scope,
Expand Down Expand Up @@ -30,12 +30,12 @@ impl VirtualMachine {

/// Register a code object's source in linecache._interactive_cache
/// so that traceback can display source lines and caret indicators.
pub fn register_code_in_linecache(&self, code: &PyRef<PyCode>, source: &str) -> PyResult<()> {
pub fn register_code_in_linecache(&self, code: &Py<PyCode>, source: &str) -> PyResult<()> {
let linecache = self.import("linecache", 0)?;
let register = linecache.get_attr("_register_code", self)?;
let source_str = self.ctx.new_str(source);
let filename = self.ctx.new_str(code.source_path().as_str());
register.call((code.as_object().to_owned(), source_str, filename), self)?;
register.call((code.to_owned().into(), source_str, filename), self)?;
Ok(())
}

Expand Down
Loading