Skip to content

Commit 5b1b2c4

Browse files
BHUVANSH855aisk
authored andcommitted
gh-158643: Document that Py_EnterRecursiveCall uses the C stack, not a counter (GH-158644)
(cherry picked from commit d6d1ebc) Co-authored-by: Bhuvansh <bhuvanshkataria@gmail.com> Co-authored-by: An Long <aisk@users.noreply.github.com>
1 parent 81c50e9 commit 5b1b2c4

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎Doc/c-api/exceptions.rst‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,10 @@ because the :ref:`call protocol <call>` takes care of recursion handling.
10341034
case, a :exc:`RecursionError` is set and a nonzero value is returned.
10351035
Otherwise, zero is returned.
10361036
1037+
The check is based on the remaining C stack space of the current thread,
1038+
not on a count of calls, so it is unaffected by
1039+
:c:func:`Py_SetRecursionLimit` and :func:`sys.setrecursionlimit`.
1040+
10371041
*where* should be a UTF-8 encoded string such as ``" in instance check"`` to
10381042
be concatenated to the :exc:`RecursionError` message caused by the recursion
10391043
depth limit.
@@ -1044,6 +1048,10 @@ because the :ref:`call protocol <call>` takes care of recursion handling.
10441048
.. versionchanged:: 3.9
10451049
This function is now also available in the :ref:`limited API <limited-c-api>`.
10461050
1051+
.. versionchanged:: 3.14
1052+
The check is based on the remaining C stack space. Previously, a
1053+
separate counter of C-level calls was used.
1054+
10471055
.. c:function:: void Py_LeaveRecursiveCall(void)
10481056
10491057
Ends a :c:func:`Py_EnterRecursiveCall`. Must be called once for each

0 commit comments

Comments
 (0)