Index: Parser/Python.asdl =================================================================== --- Parser/Python.asdl (Revision 62039) +++ Parser/Python.asdl (Arbeitskopie) @@ -98,11 +98,8 @@ comprehension = (expr target, expr iter, expr* ifs) -- not sure what to call the first argument for raise and except - -- TODO(jhylton): Figure out if there is a better way to handle - -- lineno and col_offset fields, particularly when - -- ast is exposed to Python. - excepthandler = (expr? type, expr? name, stmt* body, int lineno, - int col_offset) + excepthandler = ExceptHandler(expr? type, expr? name, stmt* body) + attributes (int lineno, int col_offset) arguments = (expr* args, identifier? vararg, identifier? kwarg, expr* defaults) Index: Python/compile.c =================================================================== --- Python/compile.c (Revision 62039) +++ Python/compile.c (Arbeitskopie) @@ -1855,32 +1855,32 @@ for (i = 0; i < n; i++) { excepthandler_ty handler = (excepthandler_ty)asdl_seq_GET( s->v.TryExcept.handlers, i); - if (!handler->type && i < n-1) + if (!handler->v.ExceptHandler.type && i < n-1) return compiler_error(c, "default 'except:' must be last"); c->u->u_lineno_set = false; c->u->u_lineno = handler->lineno; except = compiler_new_block(c); if (except == NULL) return 0; - if (handler->type) { + if (handler->v.ExceptHandler.type) { ADDOP(c, DUP_TOP); - VISIT(c, expr, handler->type); + VISIT(c, expr, handler->v.ExceptHandler.type); ADDOP_I(c, COMPARE_OP, PyCmp_EXC_MATCH); ADDOP_JREL(c, JUMP_IF_FALSE, except); ADDOP(c, POP_TOP); } ADDOP(c, POP_TOP); - if (handler->name) { - VISIT(c, expr, handler->name); + if (handler->v.ExceptHandler.name) { + VISIT(c, expr, handler->v.ExceptHandler.name); } else { ADDOP(c, POP_TOP); } ADDOP(c, POP_TOP); - VISIT_SEQ(c, stmt, handler->body); + VISIT_SEQ(c, stmt, handler->v.ExceptHandler.body); ADDOP_JREL(c, JUMP_FORWARD, end); compiler_use_next_block(c, except); - if (handler->type) + if (handler->v.ExceptHandler.type) ADDOP(c, POP_TOP); } ADDOP(c, END_FINALLY); Index: Python/symtable.c =================================================================== --- Python/symtable.c (Revision 62039) +++ Python/symtable.c (Arbeitskopie) @@ -1308,11 +1308,11 @@ static int symtable_visit_excepthandler(struct symtable *st, excepthandler_ty eh) { - if (eh->type) - VISIT(st, expr, eh->type); - if (eh->name) - VISIT(st, expr, eh->name); - VISIT_SEQ(st, stmt, eh->body); + if (eh->v.ExceptHandler.type) + VISIT(st, expr, eh->v.ExceptHandler.type); + if (eh->v.ExceptHandler.name) + VISIT(st, expr, eh->v.ExceptHandler.name); + VISIT_SEQ(st, stmt, eh->v.ExceptHandler.body); return 1; } Index: Python/ast.c =================================================================== --- Python/ast.c (Revision 62039) +++ Python/ast.c (Arbeitskopie) @@ -2830,7 +2830,7 @@ if (!suite_seq) return NULL; - return excepthandler(NULL, NULL, suite_seq, LINENO(exc), + return ExceptHandler(NULL, NULL, suite_seq, LINENO(exc), exc->n_col_offset, c->c_arena); } else if (NCH(exc) == 2) { @@ -2844,7 +2844,7 @@ if (!suite_seq) return NULL; - return excepthandler(expression, NULL, suite_seq, LINENO(exc), + return ExceptHandler(expression, NULL, suite_seq, LINENO(exc), exc->n_col_offset, c->c_arena); } else if (NCH(exc) == 4) { @@ -2862,7 +2862,7 @@ if (!suite_seq) return NULL; - return excepthandler(expression, e, suite_seq, LINENO(exc), + return ExceptHandler(expression, e, suite_seq, LINENO(exc), exc->n_col_offset, c->c_arena); }