Exception Objects

PyObject* PyException_GetTraceback(PyObject *ex)

Return value: New reference.

Return the traceback associated with the exception as a new reference, as accessible from Python through __traceback__. If there is no traceback associated, this returns NULL.

int PyException_SetTraceback(PyObject ex*, PyObject tb*)

Set the traceback associated with the exception to tb. Use Py_None to clear it.

PyObject* PyException_GetContext(PyObject *ex)

Return value: New reference.

Return the context (another exception instance during whose handling ex was raised) associated with the exception as a new reference, as accessible from Python through __context__. If there is no context associated, this returns NULL.

void PyException_SetContext(PyObject ex*, PyObject ctx*)

Set the context associated with the exception to ctx. Use NULL to clear it. There is no type check to make sure that ctx is an exception instance. This steals a reference to ctx.

PyObject* PyException_GetCause(PyObject *ex)

Return value: New reference.

Return the cause (either an exception instance, or None, set by raise ... from ...) associated with the exception as a new reference, as accessible from Python through __cause__.

void PyException_SetCause(PyObject ex*, PyObject cause*)

Set the cause associated with the exception to cause. Use NULL to clear it. There is no type check to make sure that cause is either an exception instance or None. This steals a reference to cause.

__suppress_context__ is implicitly set to True by this function.