Skip to content

Commit b8672c8

Browse files
vstinnerencukou
andauthored
Update Doc/c-api/init.rst
Co-authored-by: Petr Viktorin <[email protected]>
1 parent b0d1cf3 commit b8672c8

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Doc/c-api/init.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,8 +1360,16 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
13601360
On success, return ``0``.
13611361
On failure, set an exception and return ``-1``.
13621362
1363-
.. seealso::
1364-
The :c:func:`PyUnstable_ThreadState_ResetStack` function.
1363+
CPython implements :ref:`recursion control <recursion>` for C code by raising
1364+
:py:exc:`RecursionError` when it notices that the machine execution stack is close
1365+
to overflow.
1366+
For this, it needs to know the location of the current thread's stack, which it
1367+
normally gets from the operating system.
1368+
When the stack is changed, for example using context switching techniques like the
1369+
Boost library's ``boost::context``, you must call
1370+
:c:func:`~PyUnstable_ThreadState_SetStack` to inform CPython of the change.
1371+
1372+
See :c:func:`PyUnstable_ThreadState_ResetStack` for undoing this operation.
13651373
13661374
.. versionadded:: next
13671375

0 commit comments

Comments
 (0)