Skip to content

Commit 5ba3e93

Browse files
committed
Document traceback object APIs.
1 parent a7bf27f commit 5ba3e93

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

Doc/c-api/exceptions.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,3 +1228,36 @@ Warning types
12281228
12291229
.. versionadded:: 3.10
12301230
:c:data:`PyExc_EncodingWarning`.
1231+
1232+
Tracebacks
1233+
==========
1234+
1235+
.. c:var:: PyTypeObject PyTraceBack_Type
1236+
1237+
Type object for traceback objects. This is available as
1238+
:class:`types.TracebackType` in the Python layer.
1239+
1240+
1241+
.. c:function:: int PyTraceBack_Check(PyObject *op)
1242+
1243+
Return true if *op* is a traceback object, false otherwise. This function
1244+
does not account for subtypes.
1245+
1246+
1247+
.. c:function:: int PyTraceBack_Here(PyFrameObject *f)
1248+
1249+
Replace the :attr:`~BaseException.__traceback__` attribute on the current
1250+
exception with a new traceback pointing to *f*.
1251+
1252+
Calling this function without an exception set is undefined behavior.
1253+
1254+
This function returns ``0`` on success, and returns ``-1`` with an
1255+
exception set on failure.
1256+
1257+
1258+
.. c:function:: int PyTraceBack_Print(PyObject *tb, PyObject *f)
1259+
1260+
Write the traceback *tb* into the file *f*.
1261+
1262+
This function returns ``0`` on success, and returns ``-1`` with an
1263+
exception set on failure.

0 commit comments

Comments
 (0)