diff options
author | Georg Brandl <georg@python.org> | 2006-10-08 07:12:23 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-10-08 07:12:23 (GMT) |
commit | a5fe3ef8d835d8dffe42b58398d101eb42b897af (patch) | |
tree | 943f16877663a74e8c2dd623460ebeb6ee9d9fc4 /Lib | |
parent | 74284b9606b4c2743ef82119b41eb3a74dd5b2d2 (diff) | |
download | cpython-a5fe3ef8d835d8dffe42b58398d101eb42b897af.zip cpython-a5fe3ef8d835d8dffe42b58398d101eb42b897af.tar.gz cpython-a5fe3ef8d835d8dffe42b58398d101eb42b897af.tar.bz2 |
Fix #1569998: no break inside try statement (outside loop) allowed.
(backport from rev. 52129)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_syntax.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index bc9cb12..521789f 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -319,6 +319,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 |