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

Method delete

crates/stdlib/src/contextvars.rs:327–341  ·  view source on GitHub ↗
(zelf: &Py<Self>, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

325
326 impl ContextVar {
327 fn delete(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<()> {
328 zelf.cached.store(None);
329
330 let ctx = PyContext::current(vm);
331
332 let mut vars = ctx.borrow_vars_mut();
333 if vars.swap_remove(zelf).is_none() {
334 // TODO:
335 // PyErr_SetObject(PyExc_LookupError, (PyObject *)var);
336 let msg = zelf.as_object().repr(vm)?.as_wtf8().to_owned();
337 return Err(vm.new_lookup_error(msg));
338 }
339
340 Ok(())
341 }
342
343 // contextvar_set in CPython
344 fn set_inner(zelf: &Py<Self>, value: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> {

Callers

nothing calls this directly

Calls 9

borrow_vars_mutMethod · 0.80
swap_removeMethod · 0.80
ErrClass · 0.50
storeMethod · 0.45
is_noneMethod · 0.45
to_ownedMethod · 0.45
as_wtf8Method · 0.45
reprMethod · 0.45
as_objectMethod · 0.45

Tested by

no test coverage detected