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

Method set_characters_written

crates/vm/src/exceptions.rs:2181–2207  ·  view source on GitHub ↗
(
            &self,
            value: Option<PyObjectRef>,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

2179
2180 #[pygetset(setter)]
2181 fn set_characters_written(
2182 &self,
2183 value: Option<PyObjectRef>,
2184 vm: &VirtualMachine,
2185 ) -> PyResult<()> {
2186 match value {
2187 None => {
2188 // Deleting the attribute
2189 if self.written.load() == -1 {
2190 Err(vm.new_attribute_error("characters_written"))
2191 } else {
2192 self.written.store(-1);
2193 Ok(())
2194 }
2195 }
2196 Some(v) => {
2197 let n = v
2198 .try_index(vm)?
2199 .try_to_primitive::<isize>(vm)
2200 .map_err(|_| {
2201 vm.new_value_error("cannot convert characters_written value to isize")
2202 })?;
2203 self.written.store(n);
2204 Ok(())
2205 }
2206 }
2207 }
2208 }
2209
2210 #[pyexception(name, base = PyOSError, ctx = "blocking_io_error", impl)]

Callers

nothing calls this directly

Calls 4

try_indexMethod · 0.80
ErrClass · 0.50
loadMethod · 0.45
storeMethod · 0.45

Tested by

no test coverage detected