mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
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:
parent
15d4c9fabc
commit
b0edf3b98e
17 changed files with 67 additions and 39 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue