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

Method descr_get

crates/vm/src/builtins/super.rs:201–229  ·  view source on GitHub ↗
(
        zelf_obj: PyObjectRef,
        obj: Option<PyObjectRef>,
        _cls: Option<PyObjectRef>,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

199
200impl GetDescriptor for PySuper {
201 fn descr_get(
202 zelf_obj: PyObjectRef,
203 obj: Option<PyObjectRef>,
204 _cls: Option<PyObjectRef>,
205 vm: &VirtualMachine,
206 ) -> PyResult {
207 let (zelf, obj) = Self::_unwrap(&zelf_obj, obj, vm)?;
208 if vm.is_none(&obj) || zelf.inner.read().obj.is_some() {
209 return Ok(zelf_obj);
210 }
211 let zelf_class = zelf.as_object().class();
212 if zelf_class.is(vm.ctx.types.super_type) {
213 let typ = zelf.inner.read().typ.clone();
214 Ok(Self {
215 inner: PyRwLock::new(PySuperInner::new(typ, obj, vm)?),
216 }
217 .into_ref(&vm.ctx)
218 .into())
219 } else {
220 let (obj, typ) = {
221 let lock = zelf.inner.read();
222 let obj = lock.obj.as_ref().map(|(o, _)| o.to_owned());
223 let typ = lock.typ.clone();
224 (obj, typ)
225 };
226 let obj = vm.unwrap_or_none(obj);
227 PyType::call(zelf.class(), (typ, obj).into_args(vm), vm)
228 }
229 }
230}
231
232impl Representable for PySuper {

Callers

nothing calls this directly

Calls 14

newFunction · 0.85
isMethod · 0.80
callFunction · 0.50
is_noneMethod · 0.45
readMethod · 0.45
classMethod · 0.45
as_objectMethod · 0.45
cloneMethod · 0.45
into_refMethod · 0.45
mapMethod · 0.45
as_refMethod · 0.45
to_ownedMethod · 0.45

Tested by

no test coverage detected