summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_syntax.py
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2006-10-04 02:24:52 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2006-10-04 02:24:52 (GMT)
commit82271f13e7eab69b909d538556e4781e971f7584 (patch)
tree1e6933364df5194411899d9b6535a525667d1948 /Lib/test/test_syntax.py
parent1e3c3b15df64a8ca083f63af7884ce60bf4e9c16 (diff)
downloadcpython-82271f13e7eab69b909d538556e4781e971f7584.zip
cpython-82271f13e7eab69b909d538556e4781e971f7584.tar.gz
cpython-82271f13e7eab69b909d538556e4781e971f7584.tar.bz2
Fix for SF bug 1569998: break permitted inside try.
The compiler was checking that there was something on the fblock stack, but not that there was a loop on the stack. Fixed that and added a test for the specific syntax error. Bug fix candidate.
Diffstat (limited to 'Lib/test/test_syntax.py')
-rw-r--r--Lib/test/test_syntax.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 692ba57..8143032 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -322,6 +322,20 @@ This is essentially a continue in a finally which should not be allowed.
...
SyntaxError: 'continue' not supported inside 'finally' clause (<doctest test.test_syntax[41]>, line 8)
+There is one test for a break that is not in a loop. The compiler
+uses a single data structure to keep track of try-finally and loops,
+so we need to be sure that a break is actually inside a loop. If it
+isn't, there should be a syntax error.
+
+ >>> try:
+ ... print 1
+ ... break
+ ... print 2
+ ... finally:
+ ... print 3
+ Traceback (most recent call last):
+ ...
+ SyntaxError: 'break' outside loop (<doctest test.test_syntax[42]>, line 3)
"""
import re