Thanks Dino. The attached patch should fix the problem. Once RC1 is cut, I'll check this in unless someone beats me to it. Since the compiler changed, I can't backport this. If someone wants to make a similar fix for 2.4 go for it.
n -- On 8/16/06, Dino Viehland <[EMAIL PROTECTED]> wrote:
We've been working on fixing some exception handling bugs in IronPython where we differ from CPython. Along the way we ran into this issue which causes CPython to crash when the code below is run. It crashes on both 2.4 and 2.5 beta 3. The code's technically illegal, but it probably shouldn't crash either :) def test(): for abc in range(10): try: pass finally: try: continue except: pass test() _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/nnorwitz%40gmail.com
Index: Python/compile.c =================================================================== --- Python/compile.c (revision 51334) +++ Python/compile.c (working copy) @@ -143,7 +143,8 @@ PyFutureFeatures *c_future; /* pointer to module's __future__ */ PyCompilerFlags *c_flags; - int c_interactive; /* true if in interactive mode */ + unsigned int c_in_finally : 1; /* true if in finally clause */ + unsigned int c_interactive : 1; /* true if in interactive mode */ int c_nestlevel; struct compiler_unit *u; /* compiler state for current block */ @@ -2288,10 +2289,16 @@ compiler_continue(struct compiler *c) { static const char LOOP_ERROR_MSG[] = "'continue' not properly in loop"; + static const char IN_FINALLY_ERROR_MSG[] = + "'continue' not supported inside 'finally' clause"; int i; if (!c->u->u_nfblocks) return compiler_error(c, LOOP_ERROR_MSG); + + if (c->c_in_finally) + return compiler_error(c, IN_FINALLY_ERROR_MSG); + i = c->u->u_nfblocks - 1; switch (c->u->u_fblock[i].fb_type) { case LOOP: @@ -2306,8 +2313,8 @@ ADDOP_JABS(c, CONTINUE_LOOP, c->u->u_fblock[i].fb_block); break; case FINALLY_END: - return compiler_error(c, - "'continue' not supported inside 'finally' clause"); + /* XXX(nnorwitz): should have already been handled above. */ + return compiler_error(c, IN_FINALLY_ERROR_MSG); } return 1; @@ -2367,7 +2374,9 @@ compiler_use_next_block(c, end); if (!compiler_push_fblock(c, FINALLY_END, end)) return 0; + c->c_in_finally = 1; VISIT_SEQ(c, stmt, s->v.TryFinally.finalbody); + c->c_in_finally = 0; ADDOP(c, END_FINALLY); compiler_pop_fblock(c, FINALLY_END, end);
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com