|
11 | 11 | import warnings |
12 | 12 | from test import support |
13 | 13 | from test.support import (script_helper, requires_debug_ranges, |
14 | | - requires_specialization) |
| 14 | + requires_specialization, C_RECURSION_LIMIT) |
15 | 15 | from test.support.os_helper import FakePath |
16 | 16 |
|
17 | | - |
18 | 17 | class TestSpecifics(unittest.TestCase): |
19 | 18 |
|
20 | 19 | def compile_single(self, source): |
@@ -112,7 +111,7 @@ def __getitem__(self, key): |
112 | 111 |
|
113 | 112 | @unittest.skipIf(support.is_wasi, "exhausts limited stack on WASI") |
114 | 113 | def test_extended_arg(self): |
115 | | - repeat = 2000 |
| 114 | + repeat = int(C_RECURSION_LIMIT * 0.9) |
116 | 115 | longexpr = 'x = x or ' + '-x' * repeat |
117 | 116 | g = {} |
118 | 117 | code = textwrap.dedent(''' |
@@ -558,16 +557,12 @@ def test_yet_more_evil_still_undecodable(self): |
558 | 557 | @support.cpython_only |
559 | 558 | @unittest.skipIf(support.is_wasi, "exhausts limited stack on WASI") |
560 | 559 | def test_compiler_recursion_limit(self): |
561 | | - # Expected limit is sys.getrecursionlimit() * the scaling factor |
562 | | - # in symtable.c (currently 3) |
563 | | - # We expect to fail *at* that limit, because we use up some of |
564 | | - # the stack depth limit in the test suite code |
565 | | - # So we check the expected limit and 75% of that |
566 | | - # XXX (ncoghlan): duplicating the scaling factor here is a little |
567 | | - # ugly. Perhaps it should be exposed somewhere... |
568 | | - fail_depth = sys.getrecursionlimit() * 3 |
569 | | - crash_depth = sys.getrecursionlimit() * 300 |
570 | | - success_depth = int(fail_depth * 0.75) |
| 560 | + # Expected limit is C_RECURSION_LIMIT * 2 |
| 561 | + # Duplicating the limit here is a little ugly. |
| 562 | + # Perhaps it should be exposed somewhere... |
| 563 | + fail_depth = C_RECURSION_LIMIT * 2 + 1 |
| 564 | + crash_depth = C_RECURSION_LIMIT * 100 |
| 565 | + success_depth = int(C_RECURSION_LIMIT * 1.8) |
571 | 566 |
|
572 | 567 | def check_limit(prefix, repeated, mode="single"): |
573 | 568 | expect_ok = prefix + repeated * success_depth |
|
0 commit comments