Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PyErr_GetRaisedException(), PyErr_SetRaisedException() to FFI #3248

Merged
merged 1 commit into from
Jun 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/3248.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `PyErr_GetRaisedException()`, `PyErr_SetRaisedException()` to FFI definitions for Python 3.12 and later.
12 changes: 12 additions & 0 deletions pyo3-ffi/src/pyerrors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ extern "C" {
pub fn PyErr_Occurred() -> *mut PyObject;
#[cfg_attr(PyPy, link_name = "PyPyErr_Clear")]
pub fn PyErr_Clear();
#[cfg_attr(Py_3_12, deprecated(note = "Use PyErr_GetRaisedException() instead."))]
#[cfg_attr(PyPy, link_name = "PyPyErr_Fetch")]
pub fn PyErr_Fetch(
arg1: *mut *mut PyObject,
arg2: *mut *mut PyObject,
arg3: *mut *mut PyObject,
);
#[cfg_attr(Py_3_12, deprecated(note = "Use PyErr_SetRaisedException() instead."))]
#[cfg_attr(PyPy, link_name = "PyPyErr_Restore")]
pub fn PyErr_Restore(arg1: *mut PyObject, arg2: *mut PyObject, arg3: *mut PyObject);
#[cfg_attr(PyPy, link_name = "PyPyErr_GetExcInfo")]
Expand All @@ -35,12 +37,22 @@ extern "C" {
pub fn PyErr_GivenExceptionMatches(arg1: *mut PyObject, arg2: *mut PyObject) -> c_int;
#[cfg_attr(PyPy, link_name = "PyPyErr_ExceptionMatches")]
pub fn PyErr_ExceptionMatches(arg1: *mut PyObject) -> c_int;
#[cfg_attr(
Py_3_12,
deprecated(
note = "Use PyErr_GetRaisedException() instead, to avoid any possible de-normalization."
)
)]
#[cfg_attr(PyPy, link_name = "PyPyErr_NormalizeException")]
pub fn PyErr_NormalizeException(
arg1: *mut *mut PyObject,
arg2: *mut *mut PyObject,
arg3: *mut *mut PyObject,
);
#[cfg(Py_3_12)]
pub fn PyErr_GetRaisedException() -> *mut PyObject;
#[cfg(Py_3_12)]
pub fn PyErr_SetRaisedException(exc: *mut PyObject);
#[cfg_attr(PyPy, link_name = "PyPyException_SetTraceback")]
pub fn PyException_SetTraceback(arg1: *mut PyObject, arg2: *mut PyObject) -> c_int;
#[cfg_attr(PyPy, link_name = "PyPyException_GetTraceback")]
Expand Down