]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-141004: Document `Py_GetRecursionLimit` and `Py_SetRecursionLimit` (GH...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 6 Nov 2025 17:00:03 +0000 (18:00 +0100)
committerGitHub <noreply@github.com>
Thu, 6 Nov 2025 17:00:03 +0000 (17:00 +0000)
* gh-141004: Document `Py_GetRecursionLimit` and `Py_SetRecursionLimit` (GH-141151)
(cherry picked from commit 0b260305d302eace7d59931ca582a1953d894018)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
---------

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 10cb33990c55ca2a45904df8716d6daf2ac9d87b..cea03b24b4d61a712e8cc2401dc31812df9ac4a2 100644 (file)
@@ -967,6 +967,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 the
+   :term:`GIL`.
+
+   .. 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 the
+   :term:`GIL`.
+
+   .. seealso::
+      :py:func:`sys.setrecursionlimit`
 
 .. _standardexceptions: