]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-141004: Document `Py_GetRecursionLimit` and `Py_SetRecursionLimit` (GH-141151)
authorPeter Bierma <zintensitydev@gmail.com>
Thu, 6 Nov 2025 16:37:52 +0000 (11:37 -0500)
committerGitHub <noreply@github.com>
Thu, 6 Nov 2025 16:37:52 +0000 (16:37 +0000)
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Doc/c-api/exceptions.rst

index 3ff4631a8e53c4a04739858be85207ec93b6f6d1..9c75f66f6831958e0897dbc9cd9e684bfa809ef1 100644 (file)
@@ -979,6 +979,27 @@ these are the C equivalent to :func:`reprlib.recursive_repr`.
    Ends a :c:func:`Py_ReprEnter`.  Must be called once for each
    invocation of :c:func:`Py_ReprEnter` that returns zero.
 
+.. c:function:: int Py_GetRecursionLimit(void)
+
+   Get the recursion limit for the current interpreter. It can be set with
+   :c:func:`Py_SetRecursionLimit`. The recursion limit prevents the
+   Python interpreter stack from growing infinitely.
+
+   This function cannot fail, and the caller must hold an
+   :term:`attached thread state`.
+
+   .. seealso::
+      :py:func:`sys.getrecursionlimit`
+
+.. c:function:: void Py_SetRecursionLimit(int new_limit)
+
+   Set the recursion limit for the current interpreter.
+
+   This function cannot fail, and the caller must hold an
+   :term:`attached thread state`.
+
+   .. seealso::
+      :py:func:`sys.setrecursionlimit`
 
 .. _standardexceptions: