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

Function _remove_dead_weakref

crates/vm/src/stdlib/_weakref.rs:51–64  ·  view source on GitHub ↗
(
        dict: PyDictRef,
        key: PyObjectRef,
        vm: &VirtualMachine,
    )

Source from the content-addressed store, hash-verified

49
50 #[pyfunction]
51 fn _remove_dead_weakref(
52 dict: PyDictRef,
53 key: PyObjectRef,
54 vm: &VirtualMachine,
55 ) -> PyResult<()> {
56 dict._as_dict_inner()
57 .delete_if(vm, &*key, |wr| {
58 let wr = wr
59 .downcast_ref::<PyWeak>()
60 .ok_or_else(|| vm.new_type_error("not a weakref"))?;
61 Ok(wr.is_dead())
62 })
63 .map(drop)
64 }
65}

Callers

nothing calls this directly

Calls 5

delete_ifMethod · 0.80
_as_dict_innerMethod · 0.80
ok_or_elseMethod · 0.80
is_deadMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected