MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / new

Method new

src/err.rs:172–178  ·  view source on GitHub ↗

Creates a new PyErr of type `T`. `value` can be: `NoArgs`: the exception instance will be created using python `T()` a tuple: the exception instance will be created using python `T(*tuple)` any other value: the exception instance will be created using python `T(value)` Panics if `T` is not a python class derived from `BaseException`. Example: `return Err(PyErr::new:: (py, "Err

(py: Python, value: V)

Source from the content-addressed store, hash-verified

170 /// Example:
171 /// `return Err(PyErr::new::<exc::TypeError, _>(py, "Error message"));`
172 pub fn new<T, V>(py: Python, value: V) -> PyErr
173 where
174 T: PythonObjectWithTypeObject,
175 V: ToPyObject,
176 {
177 PyErr::new_helper(py, py.get_type::<T>(), value.to_py_object(py).into_object())
178 }
179
180 /// Gets whether an error is present in the Python interpreter's global state.
181 #[inline]

Callers

nothing calls this directly

Calls 2

into_objectMethod · 0.45
to_py_objectMethod · 0.45

Tested by

no test coverage detected