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

Method from_instance

src/err.rs:261–266  ·  view source on GitHub ↗

Creates a new PyErr. `obj` must be an Python exception instance, the PyErr will use that instance. If `obj` is a Python exception type object, the PyErr will (lazily) create a new instance of that type. Otherwise, a `TypeError` is created instead.

(py: Python, obj: O)

Source from the content-addressed store, hash-verified

259 /// If `obj` is a Python exception type object, the PyErr will (lazily) create a new instance of that type.
260 /// Otherwise, a `TypeError` is created instead.
261 pub fn from_instance<O>(py: Python, obj: O) -> PyErr
262 where
263 O: PythonObject,
264 {
265 PyErr::from_instance_helper(py, obj.into_object())
266 }
267
268 fn from_instance_helper(py: Python, obj: PyObject) -> PyErr {
269 if unsafe { ffi::PyExceptionInstance_Check(obj.as_ptr()) } != 0 {

Callers

nothing calls this directly

Calls 1

into_objectMethod · 0.45

Tested by

no test coverage detected