From f997f9a19456e323b73786a911078873901a40eb Mon Sep 17 00:00:00 2001 From: Samuel Colvin Date: Mon, 15 Jan 2024 10:33:21 +0000 Subject: [PATCH] use PyErr_Clear --- Cargo.toml | 1 - src/tools.rs | 17 +---------------- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f391daa69..66a8667e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,7 +57,6 @@ extension-module = ["pyo3/extension-module"] lto = "fat" codegen-units = 1 strip = true -#debug = true [profile.bench] debug = true diff --git a/src/tools.rs b/src/tools.rs index 2ee24c063..bdc41583c 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -105,7 +105,7 @@ pub fn safe_repr(v: &PyAny) -> Cow { pub fn extract_i64(obj: &PyAny) -> Option { let val = unsafe { ffi::PyLong_AsLong(obj.as_ptr()) }; if val == -1 && PyErr::occurred(obj.py()) { - _take_err(obj.py()); + unsafe { ffi::PyErr_Clear() }; None } else { Some(val) @@ -120,18 +120,3 @@ pub fn extract_i64(v: &PyAny) -> Option { None } } - -#[cfg(not(Py_3_12))] -fn _take_err(_: Python) { - let mut ptype: *mut ffi::PyObject = std::ptr::null_mut(); - let mut pvalue: *mut ffi::PyObject = std::ptr::null_mut(); - let mut ptraceback: *mut ffi::PyObject = std::ptr::null_mut(); - unsafe { ffi::PyErr_Fetch(&mut ptype, &mut pvalue, &mut ptraceback) }; -} - -#[cfg(Py_3_12)] -fn _take_err(_: Python) { - unsafe { - ffi::PyErr_GetRaisedException(); - } -}