mirror of https://github.com/python/cpython.git
gh-135028: Increase parser MAXSTACK for nested parenthesis (#135031)
This commit is contained in:
parent
b525e31b7f
commit
6e80f11eb5
|
@ -1,7 +1,7 @@
|
||||||
# Python test set -- part 1, grammar.
|
# Python test set -- part 1, grammar.
|
||||||
# This just tests whether the parser accepts them all.
|
# This just tests whether the parser accepts them all.
|
||||||
|
|
||||||
from test.support import check_syntax_error
|
from test.support import check_syntax_error, skip_wasi_stack_overflow
|
||||||
from test.support import import_helper
|
from test.support import import_helper
|
||||||
import annotationlib
|
import annotationlib
|
||||||
import inspect
|
import inspect
|
||||||
|
@ -249,6 +249,18 @@ def test_eof_error(self):
|
||||||
compile(s, "<test>", "exec")
|
compile(s, "<test>", "exec")
|
||||||
self.assertIn("was never closed", str(cm.exception))
|
self.assertIn("was never closed", str(cm.exception))
|
||||||
|
|
||||||
|
@skip_wasi_stack_overflow()
|
||||||
|
def test_max_level(self):
|
||||||
|
# Macro defined in Parser/lexer/state.h
|
||||||
|
MAXLEVEL = 200
|
||||||
|
|
||||||
|
result = eval("(" * MAXLEVEL + ")" * MAXLEVEL)
|
||||||
|
self.assertEqual(result, ())
|
||||||
|
|
||||||
|
with self.assertRaises(SyntaxError) as cm:
|
||||||
|
eval("(" * (MAXLEVEL + 1) + ")" * (MAXLEVEL + 1))
|
||||||
|
self.assertStartsWith(str(cm.exception), 'too many nested parentheses')
|
||||||
|
|
||||||
var_annot_global: int # a global annotated is necessary for test_var_annot
|
var_annot_global: int # a global annotated is necessary for test_var_annot
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
# define MAXSTACK 4000
|
# define MAXSTACK 4000
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
# define MAXSTACK 4000
|
# define MAXSTACK 6000
|
||||||
#endif
|
#endif
|
||||||
static const int n_keyword_lists = 9;
|
static const int n_keyword_lists = 9;
|
||||||
static KeywordToken *reserved_keywords[] = {
|
static KeywordToken *reserved_keywords[] = {
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
# define MAXSTACK 4000
|
# define MAXSTACK 4000
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
# define MAXSTACK 4000
|
# define MAXSTACK 6000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue