Function
setattr
(
obj: PyObjectRef,
attr: PyObjectRef,
value: PyObjectRef,
vm: &VirtualMachine,
)
Source from the content-addressed store, hash-verified
| 1069 | |
| 1070 | #[pyfunction] |
| 1071 | fn setattr( |
| 1072 | obj: PyObjectRef, |
| 1073 | attr: PyObjectRef, |
| 1074 | value: PyObjectRef, |
| 1075 | vm: &VirtualMachine, |
| 1076 | ) -> PyResult<()> { |
| 1077 | let attr = attr.try_to_ref::<PyStr>(vm).map_err(|_e| { |
| 1078 | vm.new_type_error(format!( |
| 1079 | "attribute name must be string, not '{}'", |
| 1080 | attr.class().name() |
| 1081 | )) |
| 1082 | })?; |
| 1083 | obj.set_attr(attr, value, vm)?; |
| 1084 | Ok(()) |
| 1085 | } |
| 1086 | |
| 1087 | // builtin_slice |
| 1088 | |