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

Method call_set_attr

crates/vm/src/protocol/object.rs:145–169  ·  view source on GitHub ↗
(
        &self,
        vm: &VirtualMachine,
        attr_name: &Py<PyStr>,
        attr_value: PySetterValue,
    )

Source from the content-addressed store, hash-verified

143 }
144
145 pub fn call_set_attr(
146 &self,
147 vm: &VirtualMachine,
148 attr_name: &Py<PyStr>,
149 attr_value: PySetterValue,
150 ) -> PyResult<()> {
151 let setattro = {
152 let cls = self.class();
153 cls.slots.setattro.load().ok_or_else(|| {
154 let has_getattr = cls.slots.getattro.load().is_some();
155 vm.new_type_error(format!(
156 "'{}' object has {} attributes ({} {})",
157 cls.name(),
158 if has_getattr { "only read-only" } else { "no" },
159 if attr_value.is_assign() {
160 "assign to"
161 } else {
162 "del"
163 },
164 attr_name
165 ))
166 })?
167 };
168 setattro(self, attr_name, attr_value, vm)
169 }
170
171 pub fn set_attr<'a>(
172 &self,

Callers 3

set_attrMethod · 0.80
del_attrMethod · 0.80
setattroMethod · 0.80

Calls 3

ok_or_elseMethod · 0.80
classMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected