From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Thu, 6 Nov 2025 16:45:31 +0000 (+0100) Subject: [3.14] gh-141004: Document `Py_GetRecursionLimit` and `Py_SetRecursionLimit` (GH... X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5c2476a4c9b6879745543bf5c4513997ba2a65e1;p=thirdparty%2FPython%2Fcpython.git [3.14] gh-141004: Document `Py_GetRecursionLimit` and `Py_SetRecursionLimit` (GH-141151) (GH-141156) gh-141004: Document `Py_GetRecursionLimit` and `Py_SetRecursionLimit` (GH-141151) (cherry picked from commit 0b260305d302eace7d59931ca582a1953d894018) Co-authored-by: Peter Bierma Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> --- diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst index 3ff4631a8e53..9c75f66f6831 100644 --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -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: