Skip to content

Commit

Permalink
use concrete inner for PyErr:matches
Browse files Browse the repository at this point in the history
  • Loading branch information
davidhewitt committed Jul 4, 2023
1 parent 76f3a39 commit 81c0328
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/err/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,14 +438,16 @@ impl PyErr {
where
T: ToPyObject,
{
let exc = exc.to_object(py);
unsafe { ffi::PyErr_GivenExceptionMatches(self.type_ptr(py), exc.as_ptr()) != 0 }
fn inner(err: &PyErr, py: Python<'_>, exc: PyObject) -> bool {
(unsafe { ffi::PyErr_GivenExceptionMatches(err.type_ptr(py), exc.as_ptr()) }) != 0
}
inner(self, py, exc.to_object(py))
}

/// Returns true if the current exception is instance of `T`.
#[inline]
pub fn is_instance(&self, py: Python<'_>, ty: &PyAny) -> bool {
unsafe { ffi::PyErr_GivenExceptionMatches(self.type_ptr(py), ty.as_ptr()) != 0 }
(unsafe { ffi::PyErr_GivenExceptionMatches(self.type_ptr(py), ty.as_ptr()) }) != 0
}

/// Returns true if the current exception is instance of `T`.
Expand Down

0 comments on commit 81c0328

Please sign in to comment.