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

Method add_note

crates/vm/src/exceptions.rs:687–707  ·  view source on GitHub ↗
(self, note: PyStrRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

685
686 #[pymethod]
687 fn add_note(self, note: PyStrRef, vm: &VirtualMachine) -> PyResult<()> {
688 let dict = self
689 .as_object()
690 .dict()
691 .ok_or_else(|| vm.new_attribute_error("Exception object has no __dict__"))?;
692
693 let notes = if let Ok(notes) = dict.get_item("__notes__", vm) {
694 notes
695 } else {
696 let new_notes = vm.ctx.new_list(vec![]);
697 dict.set_item("__notes__", new_notes.clone().into(), vm)?;
698 new_notes.into()
699 };
700
701 let notes = notes
702 .downcast::<PyList>()
703 .map_err(|_| vm.new_type_error("__notes__ must be a list"))?;
704
705 notes.borrow_vec_mut().push(note.into());
706 Ok(())
707 }
708
709 #[pymethod]
710 fn __reduce__(self, vm: &VirtualMachine) -> PyTupleRef {

Callers 15

_generic_class_getitemFunction · 0.80
__new__Method · 0.80
saveMethod · 0.80
save_reduceMethod · 0.80
save_tupleMethod · 0.80
_batch_appendsMethod · 0.80
_batch_setitemsMethod · 0.80
save_setMethod · 0.80
save_frozensetMethod · 0.80
test_split_by_typeMethod · 0.80

Calls 9

ok_or_elseMethod · 0.80
new_listMethod · 0.80
borrow_vec_mutMethod · 0.80
dictMethod · 0.45
as_objectMethod · 0.45
get_itemMethod · 0.45
set_itemMethod · 0.45
cloneMethod · 0.45
pushMethod · 0.45