Skip to content

Commit

Permalink
Merge #2788
Browse files Browse the repository at this point in the history
2788: Define _PyErr_ChainExceptions() FFI for CPython r=messense a=ijl

This appears to be the only way to chain exceptions via the FFI. It was introduced prior to CPython 3.7. It has some description of usage in PEP 490. There was a discussion of whether it should be made stable in BPO 44938.

Co-authored-by: ijl <ijl@mailbox.org>
  • Loading branch information
bors[bot] and ijl authored Dec 1, 2022
2 parents a67c578 + 5b3894f commit 23c15f2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions newsfragments/2788.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Define `_PyErr_ChainExceptions()` FFI for CPython.
6 changes: 4 additions & 2 deletions pyo3-ffi/src/cpython/pyerrors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ pub struct PyStopIterationObject {
pub value: *mut PyObject,
}

extern "C" {
pub fn _PyErr_ChainExceptions(typ: *mut PyObject, val: *mut PyObject, tb: *mut PyObject);
}

// skipped PyNameErrorObject
// skipped PyAttributeErrorObject

Expand All @@ -160,8 +164,6 @@ pub struct PyStopIterationObject {
// skipped _PyErr_GetTopmostException
// skipped _PyErr_GetExcInfo

// skipped _PyErr_ChainExceptions

// skipped PyErr_SetFromErrnoWithUnicodeFilename

// skipped _PyErr_FormatFromCause
Expand Down

0 comments on commit 23c15f2

Please sign in to comment.