]> granicus.if.org Git - python/commitdiff
verify that Python raises SyntaxError for long and deeply-nested expressions
authorJeremy Hylton <jeremy@alum.mit.edu>
Tue, 20 Jun 2000 19:13:27 +0000 (19:13 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Tue, 20 Jun 2000 19:13:27 +0000 (19:13 +0000)
Lib/test/output/test_longexp [new file with mode: 0644]
Lib/test/test_longexp.py [new file with mode: 0644]

diff --git a/Lib/test/output/test_longexp b/Lib/test/output/test_longexp
new file mode 100644 (file)
index 0000000..73a101d
--- /dev/null
@@ -0,0 +1,2 @@
+test_longexp
+Caught SyntaxError for long expression: expression too long
diff --git a/Lib/test/test_longexp.py b/Lib/test/test_longexp.py
new file mode 100644 (file)
index 0000000..38eb79b
--- /dev/null
@@ -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"
+