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

Method __qualname__

crates/vm/src/builtins/builtin_func.rs:146–164  ·  view source on GitHub ↗
(zelf: NativeFunctionOrMethod, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

144 // meth_get__qualname__ in CPython
145 #[pygetset]
146 fn __qualname__(zelf: NativeFunctionOrMethod, vm: &VirtualMachine) -> PyResult<PyStrRef> {
147 let zelf = zelf.0;
148 let qualname = if let Some(bound) = &zelf.zelf {
149 if bound.class().is(vm.ctx.types.module_type) {
150 return Ok(vm.ctx.intern_str(zelf.value.name).to_owned());
151 }
152 let prefix = if bound.class().is(vm.ctx.types.type_type) {
153 // m_self is a type: use PyType_GetQualName(m_self)
154 bound.get_attr("__qualname__", vm)?.str(vm)?.to_string()
155 } else {
156 // m_self is an instance: use Py_TYPE(m_self).__qualname__
157 bound.class().name().to_string()
158 };
159 vm.ctx.new_str(format!("{}.{}", prefix, &zelf.value.name))
160 } else {
161 vm.ctx.intern_str(zelf.value.name).to_owned()
162 };
163 Ok(qualname)
164 }
165
166 #[pygetset]
167 fn __doc__(zelf: NativeFunctionOrMethod) -> Option<&'static str> {

Callers

nothing calls this directly

Calls 9

isMethod · 0.80
intern_strMethod · 0.80
to_stringMethod · 0.80
classMethod · 0.45
to_ownedMethod · 0.45
strMethod · 0.45
get_attrMethod · 0.45
nameMethod · 0.45
new_strMethod · 0.45

Tested by

no test coverage detected