bpo-38644: Add Py_EnterRecursiveCall() to the limited API (GH-17046)
Provide Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() as
regular functions for the limited API. Previously, there were defined
as macros, but these macros didn't work with the limited API which
cannot access PyThreadState.recursion_depth field.
Remove _Py_CheckRecursionLimit from the stable ABI.
Add Include/cpython/ceval.h header file.
diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst
index c7ba74c..a042c6e 100644
--- a/Doc/c-api/exceptions.rst
+++ b/Doc/c-api/exceptions.rst
@@ -715,15 +715,21 @@
case, a :exc:`RecursionError` is set and a nonzero value is returned.
Otherwise, zero is returned.
- *where* should be a string such as ``" in instance check"`` to be
- concatenated to the :exc:`RecursionError` message caused by the recursion
+ *where* should be a UTF-8 encoded string such as ``" in instance check"`` to
+ be concatenated to the :exc:`RecursionError` message caused by the recursion
depth limit.
-.. c:function:: void Py_LeaveRecursiveCall()
+ .. versionchanged:: 3.9
+ This function is now also available in the limited API.
+
+.. c:function:: void Py_LeaveRecursiveCall(void)
Ends a :c:func:`Py_EnterRecursiveCall`. Must be called once for each
*successful* invocation of :c:func:`Py_EnterRecursiveCall`.
+ .. versionchanged:: 3.9
+ This function is now also available in the limited API.
+
Properly implementing :c:member:`~PyTypeObject.tp_repr` for container types requires
special recursion handling. In addition to protecting the stack,
:c:member:`~PyTypeObject.tp_repr` also needs to track objects to prevent cycles. The