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

Method setattro

crates/vm/src/stdlib/_thread.rs:999–1019  ·  view source on GitHub ↗
(
            zelf: &Py<Self>,
            attr: &Py<PyStr>,
            value: PySetterValue,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

997
998 impl SetAttr for Local {
999 fn setattro(
1000 zelf: &Py<Self>,
1001 attr: &Py<PyStr>,
1002 value: PySetterValue,
1003 vm: &VirtualMachine,
1004 ) -> PyResult<()> {
1005 if attr.as_bytes() == b"__dict__" {
1006 Err(vm.new_attribute_error(format!(
1007 "{} attribute '__dict__' is read-only",
1008 zelf.class().name()
1009 )))
1010 } else {
1011 let dict = zelf.l_dict(vm);
1012 if let PySetterValue::Assign(value) = value {
1013 dict.set_item(attr, value, vm)?;
1014 } else {
1015 dict.del_item(attr, vm)?;
1016 }
1017 Ok(())
1018 }
1019 }
1020 }
1021
1022 // Registry of all ThreadHandles for fork cleanup

Callers

nothing calls this directly

Calls 5

l_dictMethod · 0.80
ErrClass · 0.50
as_bytesMethod · 0.45
set_itemMethod · 0.45
del_itemMethod · 0.45

Tested by

no test coverage detected