mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
gh-93678: Address stack exhaustion on WASI (GH-95296)
This commit is contained in:
parent
9af7f87d76
commit
51c56f8d72
2 changed files with 9 additions and 4 deletions
|
@ -108,6 +108,7 @@ class TestSpecifics(unittest.TestCase):
|
||||||
exec('z = a', g, d)
|
exec('z = a', g, d)
|
||||||
self.assertEqual(d['z'], 12)
|
self.assertEqual(d['z'], 12)
|
||||||
|
|
||||||
|
@unittest.skipIf(support.is_wasi, "exhausts limited stack on WASI")
|
||||||
def test_extended_arg(self):
|
def test_extended_arg(self):
|
||||||
# default: 1000 * 2.5 = 2500 repetitions
|
# default: 1000 * 2.5 = 2500 repetitions
|
||||||
repeat = int(sys.getrecursionlimit() * 2.5)
|
repeat = int(sys.getrecursionlimit() * 2.5)
|
||||||
|
@ -542,6 +543,7 @@ if 1:
|
||||||
self.assertIn(b"Non-UTF-8", res.err)
|
self.assertIn(b"Non-UTF-8", res.err)
|
||||||
|
|
||||||
@support.cpython_only
|
@support.cpython_only
|
||||||
|
@unittest.skipIf(support.is_wasi, "exhausts limited stack on WASI")
|
||||||
def test_compiler_recursion_limit(self):
|
def test_compiler_recursion_limit(self):
|
||||||
# Expected limit is sys.getrecursionlimit() * the scaling factor
|
# Expected limit is sys.getrecursionlimit() * the scaling factor
|
||||||
# in symtable.c (currently 3)
|
# in symtable.c (currently 3)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# Test the most dynamic corner cases of Python's runtime semantics.
|
# Test the most dynamic corner cases of Python's runtime semantics.
|
||||||
|
|
||||||
import builtins
|
import builtins
|
||||||
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from test.support import swap_item, swap_attr
|
from test.support import swap_item, swap_attr
|
||||||
|
@ -139,12 +140,14 @@ class RebindBuiltinsTests(unittest.TestCase):
|
||||||
def __missing__(self, key):
|
def __missing__(self, key):
|
||||||
return int(key.removeprefix("_number_"))
|
return int(key.removeprefix("_number_"))
|
||||||
|
|
||||||
code = "lambda: " + "+".join(f"_number_{i}" for i in range(1000))
|
# 1,000 on most systems
|
||||||
sum_1000 = eval(code, MyGlobals())
|
limit = sys.getrecursionlimit()
|
||||||
expected = sum(range(1000))
|
code = "lambda: " + "+".join(f"_number_{i}" for i in range(limit))
|
||||||
|
sum_func = eval(code, MyGlobals())
|
||||||
|
expected = sum(range(limit))
|
||||||
# Warm up the the function for quickening (PEP 659)
|
# Warm up the the function for quickening (PEP 659)
|
||||||
for _ in range(30):
|
for _ in range(30):
|
||||||
self.assertEqual(sum_1000(), expected)
|
self.assertEqual(sum_func(), expected)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue