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

Method seek

crates/vm/src/stdlib/_io.rs:1651–1667  ·  view source on GitHub ↗
(
            &self,
            target: PyObjectRef,
            whence: OptionalArg<i32>,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

1649
1650 #[pymethod]
1651 fn seek(
1652 &self,
1653 target: PyObjectRef,
1654 whence: OptionalArg<i32>,
1655 vm: &VirtualMachine,
1656 ) -> PyResult<Offset> {
1657 let whence = whence.unwrap_or(0);
1658 if !validate_whence(whence) {
1659 return Err(vm.new_value_error(format!("whence value {whence} unsupported")));
1660 }
1661 let mut data = self.lock(vm)?;
1662 let raw = data.check_init(vm)?;
1663 ensure_unclosed(raw, "seek of closed file", vm)?;
1664 check_seekable(raw, vm)?;
1665 let target = get_offset(target, vm)?;
1666 data.seek(target, whence, vm)
1667 }
1668
1669 #[pymethod]
1670 fn tell(&self, vm: &VirtualMachine) -> PyResult<Offset> {

Callers

nothing calls this directly

Implementers 1

_io.rscrates/vm/src/stdlib/_io.rs

Calls 8

validate_whenceFunction · 0.85
ensure_unclosedFunction · 0.85
check_seekableFunction · 0.85
get_offsetFunction · 0.85
check_initMethod · 0.80
ErrClass · 0.50
lockMethod · 0.45
seekMethod · 0.45

Tested by

no test coverage detected