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

Function rename

crates/vm/src/stdlib/os.rs:1536–1552  ·  view source on GitHub ↗
(src: PyObjectRef, dst: PyObjectRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

1534 #[pyfunction]
1535 #[pyfunction(name = "replace")]
1536 fn rename(src: PyObjectRef, dst: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> {
1537 let src = PathConverter::new()
1538 .function("rename")
1539 .argument("src")
1540 .try_path(src, vm)?;
1541 let dst = PathConverter::new()
1542 .function("rename")
1543 .argument("dst")
1544 .try_path(dst, vm)?;
1545
1546 fs::rename(&src.path, &dst.path).map_err(|err| {
1547 let builder = err.to_os_error_builder(vm);
1548 let builder = builder.filename(src.filename(vm));
1549 let builder = builder.filename2(dst.filename(vm));
1550 builder.build(vm).upcast()
1551 })
1552 }
1553
1554 #[pyfunction]
1555 fn getpid(vm: &VirtualMachine) -> PyObjectRef {

Callers 1

renamesFunction · 0.85

Calls 9

newFunction · 0.85
try_pathMethod · 0.80
argumentMethod · 0.80
to_os_error_builderMethod · 0.80
filename2Method · 0.80
upcastMethod · 0.80
functionMethod · 0.45
filenameMethod · 0.45
buildMethod · 0.45

Tested by

no test coverage detected