[Python-bugs-list] [Bug #115143] Python sometimes complains about continue in an except
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 29 Sep 2000 17:08:25 -0700
Bug #115143, was updated on 2000-Sep-22 14:57
Here is a current snapshot of the bug.
Project: Python
Category: Parser/Compiler
Status: Open
Resolution: None
Bug Group: None
Priority: 4
Summary: Python sometimes complains about continue in an except
Details: If a continue statement occurs in the second try/except
statement nested within another try statement, it complains
about the second continue. For example, this code generates a SyntaxError:
for i in range(10):
try:
try:
pass
except:
continue
try:
pass
except:
continue
except:
pass
while this is fine:
for i in range(10):
try:
pass
except:
continue
try:
pass
except:
continue
This problem exists in both 1.5.2 and 2.0b1.
A workaround is to raise "continue" from the inner
try/except statements and catch it in the outer try/except:
for i in range(10):
try:
try:
pass
except:
raise "continue"
try:
pass
except:
raise "continue"
except "continue":
continue
except:
pass
For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=115143&group_id=5470