GH-91079: Rename C_RECURSION_LIMIT to Py_C_RECURSION_LIMIT (#108507)

Symbols of the C API should be prefixed by "Py_" to avoid conflict
with existing names in 3rd party C extensions on "#include <Python.h>".

test.pythoninfo now logs Py_C_RECURSION_LIMIT constant and other
_testcapi and _testinternalcapi constants.
This commit is contained in:
Victor Stinner 2023-09-08 11:48:28 +02:00 committed by GitHub
parent 15d4c9fabc
commit b0edf3b98e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 67 additions and 39 deletions

View file

@ -11,7 +11,7 @@ import textwrap
import warnings
from test import support
from test.support import (script_helper, requires_debug_ranges,
requires_specialization, C_RECURSION_LIMIT)
requires_specialization, Py_C_RECURSION_LIMIT)
from test.support.os_helper import FakePath
class TestSpecifics(unittest.TestCase):
@ -111,7 +111,7 @@ class TestSpecifics(unittest.TestCase):
@unittest.skipIf(support.is_wasi, "exhausts limited stack on WASI")
def test_extended_arg(self):
repeat = int(C_RECURSION_LIMIT * 0.9)
repeat = int(Py_C_RECURSION_LIMIT * 0.9)
longexpr = 'x = x or ' + '-x' * repeat
g = {}
code = textwrap.dedent('''
@ -557,12 +557,12 @@ class TestSpecifics(unittest.TestCase):
@support.cpython_only
@unittest.skipIf(support.is_wasi, "exhausts limited stack on WASI")
def test_compiler_recursion_limit(self):
# Expected limit is C_RECURSION_LIMIT * 2
# Expected limit is Py_C_RECURSION_LIMIT * 2
# Duplicating the limit here is a little ugly.
# Perhaps it should be exposed somewhere...
fail_depth = C_RECURSION_LIMIT * 2 + 1
crash_depth = C_RECURSION_LIMIT * 100
success_depth = int(C_RECURSION_LIMIT * 1.8)
fail_depth = Py_C_RECURSION_LIMIT * 2 + 1
crash_depth = Py_C_RECURSION_LIMIT * 100
success_depth = int(Py_C_RECURSION_LIMIT * 1.8)
def check_limit(prefix, repeated, mode="single"):
expect_ok = prefix + repeated * success_depth