]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-141004: Document `PyTraceBack*` APIs (GH-141192) (GH-141210) 3.14
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 7 Nov 2025 18:52:45 +0000 (19:52 +0100)
committerGitHub <noreply@github.com>
Fri, 7 Nov 2025 18:52:45 +0000 (18:52 +0000)
gh-141004: Document `PyTraceBack*` APIs (GH-141192)
(cherry picked from commit d13ee0ae186f4704f3b6016dd52f7727b81f9194)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Doc/c-api/exceptions.rst

index b6f9399337eb86c9f9b8ab5958cb969dfde3eb89..f525ee7a0461fe91117a131a6fa26fa9491b95e7 100644 (file)
@@ -1237,3 +1237,37 @@ Warning types
 
 .. versionadded:: 3.10
    :c:data:`PyExc_EncodingWarning`.
+
+
+Tracebacks
+==========
+
+.. c:var:: PyTypeObject PyTraceBack_Type
+
+   Type object for traceback objects. This is available as
+   :class:`types.TracebackType` in the Python layer.
+
+
+.. c:function:: int PyTraceBack_Check(PyObject *op)
+
+   Return true if *op* is a traceback object, false otherwise. This function
+   does not account for subtypes.
+
+
+.. c:function:: int PyTraceBack_Here(PyFrameObject *f)
+
+   Replace the :attr:`~BaseException.__traceback__` attribute on the current
+   exception with a new traceback prepending *f* to the existing chain.
+
+   Calling this function without an exception set is undefined behavior.
+
+   This function returns ``0`` on success, and returns ``-1`` with an
+   exception set on failure.
+
+
+.. c:function:: int PyTraceBack_Print(PyObject *tb, PyObject *f)
+
+   Write the traceback *tb* into the file *f*.
+
+   This function returns ``0`` on success, and returns ``-1`` with an
+   exception set on failure.