diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-02-01 22:48:12 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-02-01 22:48:12 (GMT) |
commit | 3faa52ecc4aeb30f8913b4dd105184f6f7bc733d (patch) | |
tree | d4c6c78e934c98ef15aaf79fae249063b5a41a1b /Lib | |
parent | 1bbc04831071891c5bbeb53a2c1defbbf83245d9 (diff) | |
download | cpython-3faa52ecc4aeb30f8913b4dd105184f6f7bc733d.zip cpython-3faa52ecc4aeb30f8913b4dd105184f6f7bc733d.tar.gz cpython-3faa52ecc4aeb30f8913b4dd105184f6f7bc733d.tar.bz2 |
Allow 'continue' inside 'try' clause
SF patch 102989 by Thomas Wouters
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/dis.py | 1 | ||||
-rw-r--r-- | Lib/test/output/test_exceptions | 6 | ||||
-rw-r--r-- | Lib/test/output/test_grammar | 2 | ||||
-rw-r--r-- | Lib/test/test_exceptions.py | 21 | ||||
-rw-r--r-- | Lib/test/test_grammar.py | 19 |
5 files changed, 25 insertions, 24 deletions
@@ -259,6 +259,7 @@ jrel_op('FOR_LOOP', 114) # Number of bytes to skip name_op('LOAD_GLOBAL', 116) # Index in name list +jabs_op('CONTINUE_LOOP', 119) # Target address jrel_op('SETUP_LOOP', 120) # Distance to target address jrel_op('SETUP_EXCEPT', 121) # "" jrel_op('SETUP_FINALLY', 122) # "" diff --git a/Lib/test/output/test_exceptions b/Lib/test/output/test_exceptions index 8ce0154..e1e146a 100644 --- a/Lib/test/output/test_exceptions +++ b/Lib/test/output/test_exceptions @@ -27,11 +27,7 @@ RuntimeError (not used any more?) spam SyntaxError -'continue' not supported inside 'try' clause -ok -'continue' not supported inside 'try' clause -ok -'continue' not supported inside 'try' clause +'continue' not supported inside 'finally' clause ok 'continue' not properly in loop ok diff --git a/Lib/test/output/test_grammar b/Lib/test/output/test_grammar index 172a597..319177c 100644 --- a/Lib/test/output/test_grammar +++ b/Lib/test/output/test_grammar @@ -33,6 +33,8 @@ pass_stmt flow_stmt break_stmt continue_stmt +continue + try/except ok +continue + try/finally ok return_stmt raise_stmt import_stmt diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py index 73c2489..9f42659 100644 --- a/Lib/test/test_exceptions.py +++ b/Lib/test/test_exceptions.py @@ -104,28 +104,11 @@ def ckmsg(src, msg): s = '''\ while 1: try: - continue - except: - pass -''' -ckmsg(s, "'continue' not supported inside 'try' clause") -s = '''\ -while 1: - try: - continue - finally: pass -''' -ckmsg(s, "'continue' not supported inside 'try' clause") -s = '''\ -while 1: - try: - if 1: - continue finally: - pass + continue ''' -ckmsg(s, "'continue' not supported inside 'try' clause") +ckmsg(s, "'continue' not supported inside 'finally' clause") s = '''\ try: continue diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index 6e0fe91..b7af64a 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -349,6 +349,25 @@ print 'continue_stmt' # 'continue' i = 1 while i: i = 0; continue +msg = "" +while not msg: + msg = "continue + try/except ok" + try: + continue + msg = "continue failed to continue inside try" + except: + msg = "continue inside try called except block" +print msg + +msg = "" +while not msg: + msg = "finally block not called" + try: + continue + finally: + msg = "continue + try/finally ok" +print msg + print 'return_stmt' # 'return' [testlist] def g1(): return def g2(): return 1 |