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

Method __init_methods

crates/vm/src/builtins/module.rs:137–147  ·  view source on GitHub ↗
(&self, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

135
136impl Py<PyModule> {
137 pub fn __init_methods(&self, vm: &VirtualMachine) -> PyResult<()> {
138 debug_assert!(self.def.is_some());
139 for method in self.def.unwrap().methods {
140 let func = method
141 .to_function()
142 .with_module(self.name.unwrap())
143 .into_ref(&vm.ctx);
144 vm.__module_set_attr(self, vm.ctx.intern_str(method.name), func)?;
145 }
146 Ok(())
147 }
148
149 fn getattr_inner(&self, name: &Py<PyStr>, vm: &VirtualMachine) -> PyResult {
150 if let Some(attr) = self.as_object().generic_getattr_opt(name, None, vm)? {

Callers 4

init_moduleFunction · 0.80
create_builtinFunction · 0.80
init_moduleFunction · 0.80
create_moduleMethod · 0.80

Calls 6

with_moduleMethod · 0.80
to_functionMethod · 0.80
__module_set_attrMethod · 0.80
intern_strMethod · 0.80
unwrapMethod · 0.45
into_refMethod · 0.45

Tested by

no test coverage detected