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

Function setattr

crates/vm/src/stdlib/builtins.rs:1071–1085  ·  view source on GitHub ↗
(
        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

Callers 15

update_wrapperFunction · 0.85
total_orderingFunction · 0.85
copy_locationFunction · 0.85
generic_visitMethod · 0.85
import_moduleMethod · 0.85
_make_class_unpicklableFunction · 0.85
__setitem__Method · 0.85
__new__Method · 0.85
_add_member_Method · 0.85
convert_classFunction · 0.85
_reconstructFunction · 0.85
_colorize.pyFile · 0.85

Calls 1

set_attrMethod · 0.45

Tested by 15

test_patma_249Method · 0.68
stderr_to_parser_errorFunction · 0.68
__init__Method · 0.68
__call__Method · 0.68
__call__Method · 0.68
__call__Method · 0.68
__init__Method · 0.68
test_printMethod · 0.68
get_itemsMethod · 0.68
decoratorMethod · 0.68
__new__Method · 0.68
create_invalidMethod · 0.68