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

Method slot_new

crates/vm/src/builtins/staticmethod.rs:46–61  ·  view source on GitHub ↗
(cls: PyTypeRef, args: FuncArgs, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

44 type Args = PyObjectRef;
45
46 fn slot_new(cls: PyTypeRef, args: FuncArgs, vm: &VirtualMachine) -> PyResult {
47 let callable: Self::Args = args.bind(vm)?;
48 let doc = callable.get_attr("__doc__", vm);
49
50 let result = Self {
51 callable: PyMutex::new(callable),
52 }
53 .into_ref_with_type(vm, cls)?;
54 let obj = PyObjectRef::from(result);
55
56 if let Ok(doc) = doc {
57 obj.set_attr("__doc__", doc, vm)?;
58 }
59
60 Ok(obj)
61 }
62
63 fn py_new(_cls: &Py<PyType>, _args: Self::Args, _vm: &VirtualMachine) -> PyResult<Self> {
64 unimplemented!("use slot_new")

Callers

nothing calls this directly

Calls 5

newFunction · 0.85
into_ref_with_typeMethod · 0.80
bindMethod · 0.45
get_attrMethod · 0.45
set_attrMethod · 0.45

Tested by

no test coverage detected