MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / setattr

Method setattr

src/objectprotocol.rs:61–71  ·  view source on GitHub ↗
(&self, py: Python, attr_name: N, value: V)

Source from the content-addressed store, hash-verified

59 /// This is equivalent to the Python expression 'self.attr_name = value'.
60 #[inline]
61 fn setattr<N, V>(&self, py: Python, attr_name: N, value: V) -> PyResult<()>
62 where
63 N: ToPyObject,
64 V: ToPyObject,
65 {
66 attr_name.with_borrowed_ptr(py, move |attr_name| {
67 value.with_borrowed_ptr(py, |value| unsafe {
68 err::error_on_minusone(py, ffi::PyObject_SetAttr(self.as_ptr(), attr_name, value))
69 })
70 })
71 }
72
73 /// Deletes an attribute.
74 /// This is equivalent to the Python expression 'del self.attr_name'.

Callers 1

addMethod · 0.80

Implementers 1

objectprotocol.rssrc/objectprotocol.rs

Calls 3

error_on_minusoneFunction · 0.85
with_borrowed_ptrMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected