Skip to content

Commit d13ee0a

Browse files
gh-141004: Document PyTraceBack* APIs (GH-141192)
Co-authored-by: Stan Ulbrych <[email protected]>
1 parent 3989e12 commit d13ee0a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

Doc/c-api/exceptions.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,3 +1237,37 @@ Warning types
12371237
12381238
.. versionadded:: 3.10
12391239
:c:data:`PyExc_EncodingWarning`.
1240+
1241+
1242+
Tracebacks
1243+
==========
1244+
1245+
.. c:var:: PyTypeObject PyTraceBack_Type
1246+
1247+
Type object for traceback objects. This is available as
1248+
:class:`types.TracebackType` in the Python layer.
1249+
1250+
1251+
.. c:function:: int PyTraceBack_Check(PyObject *op)
1252+
1253+
Return true if *op* is a traceback object, false otherwise. This function
1254+
does not account for subtypes.
1255+
1256+
1257+
.. c:function:: int PyTraceBack_Here(PyFrameObject *f)
1258+
1259+
Replace the :attr:`~BaseException.__traceback__` attribute on the current
1260+
exception with a new traceback prepending *f* to the existing chain.
1261+
1262+
Calling this function without an exception set is undefined behavior.
1263+
1264+
This function returns ``0`` on success, and returns ``-1`` with an
1265+
exception set on failure.
1266+
1267+
1268+
.. c:function:: int PyTraceBack_Print(PyObject *tb, PyObject *f)
1269+
1270+
Write the traceback *tb* into the file *f*.
1271+
1272+
This function returns ``0`` on success, and returns ``-1`` with an
1273+
exception set on failure.

0 commit comments

Comments
 (0)