Issue215143
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2000-09-22 21:57 by skip.montanaro, last changed 2022-04-10 16:02 by admin. This issue is now closed.
Messages (4) | |||
---|---|---|---|
msg1579 - (view) | Author: Skip Montanaro (skip.montanaro) * | Date: 2000-09-22 21:57 | |
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 |
|||
msg1580 - (view) | Author: Guido van Rossum (gvanrossum) * | Date: 2000-10-03 18:06 | |
This really is a duplicate of #110830, which was "resolved" as a feature request (i.e. won't be fixed any time soon). A 'continue' inside a 'try' clause is invalid (because it's too complicated to generate code for it that cleans up the try block). Your continue is still inside a 'try' clause -- it is inside the *outer* 'try' clause! So it's the same bug. You don't need two inner try-except clauses with a continue stmt to reproduce this; one is enough (it complains about the last one due to the way the code generator signals errors). |
|||
msg1581 - (view) | Author: Skip Montanaro (skip.montanaro) * | Date: 2000-10-03 18:36 | |
I don't think I explained the problem properly. The compiler should either complain about both of the continue statements or neither of them, not just the second one. I believe that was what confused the person who originally described this problem on c.l.py. He couldn't figure out why the first one was okay but the second one wasn't. In any case, I added a reference to this bugid to the note in pep-0042, so whoever tackles the "continue inside a try block" problem will know to check this. |
|||
msg1582 - (view) | Author: Guido van Rossum (gvanrossum) * | Date: 2000-10-03 20:34 | |
OK. That's a very different issue. Normally the compiler complains about the *first* problem it finds. In this case it complained about the *last* problem. That's a separate ToTo, and I'll add it to PEP-42 momentarily. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-10 16:02:25 | admin | set | github: 33179 |
2000-09-22 21:57:34 | skip.montanaro | create |