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

Method new_exception_msg_dict

crates/vm/src/vm/vm_new.rs:163–177  ·  view source on GitHub ↗

Instantiate an exception with `msg` as the only argument and `dict` for object This function should only be used with builtin exception types; if a user-defined exception type is passed in, it may not be fully initialized; try using [`vm.invoke_exception()`][Self::invoke_exception] or [`exceptions::ExceptionCtor`][crate::exceptions::ExceptionCtor] instead.

(
        &self,
        exc_type: PyTypeRef,
        msg: Wtf8Buf,
        dict: PyDictRef,
    )

Source from the content-addressed store, hash-verified

161 /// [`vm.invoke_exception()`][Self::invoke_exception] or
162 /// [`exceptions::ExceptionCtor`][crate::exceptions::ExceptionCtor] instead.
163 pub fn new_exception_msg_dict(
164 &self,
165 exc_type: PyTypeRef,
166 msg: Wtf8Buf,
167 dict: PyDictRef,
168 ) -> PyBaseExceptionRef {
169 PyRef::new_ref(
170 // TODO: this constructor might be invalid, because multiple
171 // exception (even builtin ones) are using custom constructors,
172 // see `OSError` as an example:
173 PyBaseException::new(vec![self.ctx.new_str(msg).into()], self),
174 exc_type,
175 Some(dict),
176 )
177 }
178
179 pub fn new_no_attribute_error(&self, obj: PyObjectRef, name: PyStrRef) -> PyBaseExceptionRef {
180 let msg = format!(

Callers 1

raise_exceptionFunction · 0.80

Calls 2

newFunction · 0.85
SomeClass · 0.50

Tested by

no test coverage detected