mirror of
https://github.com/python/cpython.git
synced 2024-11-28 12:31:14 +08:00
verify that Python raises SyntaxError for long and deeply-nested expressions
This commit is contained in:
parent
94988067b9
commit
3c0d013db4
2
Lib/test/output/test_longexp
Normal file
2
Lib/test/output/test_longexp
Normal file
@ -0,0 +1,2 @@
|
||||
test_longexp
|
||||
Caught SyntaxError for long expression: expression too long
|
18
Lib/test/test_longexp.py
Normal file
18
Lib/test/test_longexp.py
Normal file
@ -0,0 +1,18 @@
|
||||
REPS = 8192
|
||||
|
||||
try:
|
||||
eval("2+2+" * REPS + "+3.14159265")
|
||||
except SyntaxError, msg:
|
||||
print "Caught SyntaxError for long expression:", msg
|
||||
else:
|
||||
print "Long expression did not raise SyntaxError"
|
||||
|
||||
## This test prints "s_push: parser stack overflow" on stderr,
|
||||
## which seems to confuse the test harness
|
||||
##try:
|
||||
## eval("(2+" * REPS + "0" + ")" * REPS)
|
||||
##except SyntaxError:
|
||||
## pass
|
||||
##else:
|
||||
## print "Deeply nested expression did not raised SyntaxError"
|
||||
|
Loading…
Reference in New Issue
Block a user