Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Return NULL when no cause is set
  • Loading branch information
bschoenmaeckers committed May 19, 2026
commit 7bda56abacb718babb888d902b39377a70d9f6fc
7 changes: 5 additions & 2 deletions crates/capi/src/pyerrors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,11 @@ pub unsafe extern "C" fn PyException_GetTraceback(exc: *mut PyObject) -> *mut Py
pub unsafe extern "C" fn PyException_GetCause(exc: *mut PyObject) -> *mut PyObject {
with_vm(|vm| {
let exc = unsafe { &*exc }.try_downcast_ref::<PyBaseException>(vm)?;
let context = exc.__cause__().map(|context| context.into_object());
Ok(vm.unwrap_or_none(context))
let cause = exc
.__cause__()
.map(|cause| cause.into_object().into_raw().as_ptr())
.unwrap_or_default();
Ok(cause)
})
}

Expand Down
Loading