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

Method __setstate__

crates/vm/src/exceptions.rs:719–734  ·  view source on GitHub ↗
(self, state: PyObjectRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

717
718 #[pymethod]
719 fn __setstate__(self, state: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyObjectRef> {
720 if !vm.is_none(&state) {
721 let dict = state
722 .downcast::<crate::builtins::PyDict>()
723 .map_err(|_| vm.new_type_error("state is not a dictionary"))?;
724
725 for (key, value) in &dict {
726 let key_str = key.str(vm)?;
727 if key_str.as_bytes().starts_with(b"__") {
728 continue;
729 }
730 self.as_object().set_attr(&key_str, value.clone(), vm)?;
731 }
732 }
733 Ok(vm.ctx.none())
734 }
735}
736
737impl Constructor for PyBaseException {

Callers

nothing calls this directly

Calls 8

starts_withMethod · 0.80
noneMethod · 0.80
is_noneMethod · 0.45
strMethod · 0.45
as_bytesMethod · 0.45
set_attrMethod · 0.45
as_objectMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected