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

Function update_code_filenames

crates/vm/src/stdlib/_imp.rs:348–364  ·  view source on GitHub ↗
(
    code: &PyCode,
    old_name: &'static PyStrInterned,
    new_name: &'static PyStrInterned,
)

Source from the content-addressed store, hash-verified

346}
347
348fn update_code_filenames(
349 code: &PyCode,
350 old_name: &'static PyStrInterned,
351 new_name: &'static PyStrInterned,
352) {
353 let current = code.source_path();
354 if !core::ptr::eq(current, old_name) && current.as_str() != old_name.as_str() {
355 return;
356 }
357 code.set_source_path(new_name);
358 for constant in code.code.constants.iter() {
359 let obj: &crate::PyObject = constant.borrow();
360 if let Some(inner_code) = obj.downcast_ref::<PyCode>() {
361 update_code_filenames(inner_code, old_name, new_name);
362 }
363 }
364}

Callers 1

_fix_co_filenameFunction · 0.85

Calls 6

set_source_pathMethod · 0.80
eqFunction · 0.70
source_pathMethod · 0.45
as_strMethod · 0.45
iterMethod · 0.45
borrowMethod · 0.45

Tested by

no test coverage detected