This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients vstinner
Date 2020-09-22.12:39:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1600778367.51.0.464121227135.issue41834@roundup.psfhosted.org>
In-reply-to
Content
_Py_CheckRecursionLimit variable is no longer needed and can be removed.

In Python 3.9, I added a recursion limit per interpreter.

In Python 3.8 and older, it was used by _Py_MakeRecCheck() macro to check for recursion error. 

Previously, the _Py_CheckRecursionLimit variable was kept for backward compatibility with the stable ABI, but in Python 3.8 and older, Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() could not be used with the limited C API since these macros accessed PyThreadState structure member, whereas the structure is opaque in the limited C API.

Attached PR removed the variable.

---

(3) bpo-40513: Limit made per interpreter.

commit 4e30ed3af06ae655f4cb8aad8cba21f341384250
Author: Victor Stinner <vstinner@python.org>
Date:   Tue May 5 16:52:52 2020 +0200

    bpo-40513: Per-interpreter recursion_limit (GH-19929)
    
    Move recursion_limit member from _PyRuntimeState.ceval to
    PyInterpreterState.ceval.
    
    * Py_SetRecursionLimit() now only sets _Py_CheckRecursionLimit
      of ceval.c if the current Python thread is part of the main
      interpreter.
    * Inline _Py_MakeEndRecCheck() into _Py_LeaveRecursiveCall().
    * Convert _Py_RecursionLimitLowerWaterMark() macro into a static
      inline function.

---

(2) bpo-38644: The _Py_CheckRecursionLimit variable was used by Py_EnterRecursiveCall() and Py_LeaveRecursiveCall() macros. I converted these macros into function calls in Python 3.9:

commit f4b1e3d7c64985f5d5b00f6cc9a1c146bbbfd613
Author: Victor Stinner <vstinner@python.org>
Date:   Mon Nov 4 19:48:34 2019 +0100

    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.

In pycore_ceval.h, the function is overriden by a macro which points to an inline function which uses:

* tstate->recursion_depth
* tstate->interp->ceval.recursion_limit
* tstate->stackcheck_counter (if USE_STACKCHECK macro is defined)

---

(1) bpo-31857: Original change adding the FIXME.

commit 1896793520a49a6f97ae360c0b288967e56b005e
Author: pdox <pdox@alum.mit.edu>
Date:   Wed Oct 25 23:03:01 2017 -0700

    bpo-31857: Make the behavior of USE_STACKCHECK deterministic (#4098)

This change added the FIXME comment:

/* Due to the macros in which it's used, _Py_CheckRecursionLimit is in
   the stable ABI.  It should be removed therefrom when possible.
*/
History
Date User Action Args
2020-09-22 12:39:27vstinnersetrecipients: + vstinner
2020-09-22 12:39:27vstinnersetmessageid: <1600778367.51.0.464121227135.issue41834@roundup.psfhosted.org>
2020-09-22 12:39:27vstinnerlinkissue41834 messages
2020-09-22 12:39:26vstinnercreate