diff options
author | Guido van Rossum <guido@python.org> | 2007-01-10 18:51:35 +0000 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-01-10 18:51:35 +0000 |
commit | 16be03e4a206c24b00dc1d2d3c740dffbbfc4ac9 (patch) | |
tree | 459a125a265abb16399baeea398ab116b7bf4f9b /Python | |
parent | b940e113bf90ff71b0ef57414ea2beea9d2a4bc0 (diff) | |
download | cpython-git-16be03e4a206c24b00dc1d2d3c740dffbbfc4ac9.tar.gz |
Some more changes related to the new except syntax and semantics,
by Collin Winter.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/Python-ast.c | 4 | ||||
-rw-r--r-- | Python/ast.c | 4 | ||||
-rw-r--r-- | Python/compile.c | 17 | ||||
-rw-r--r-- | Python/graminit.c | 2 | ||||
-rw-r--r-- | Python/symtable.c | 3 |
5 files changed, 11 insertions, 19 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c index a210c7f20f..e1a5bcef8b 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -1836,7 +1836,7 @@ comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs, PyArena *arena) } excepthandler_ty -excepthandler(expr_ty type, expr_ty name, asdl_seq * body, int lineno, int +excepthandler(expr_ty type, identifier name, asdl_seq * body, int lineno, int col_offset, PyArena *arena) { excepthandler_ty p; @@ -2928,7 +2928,7 @@ ast2obj_excepthandler(void* _o) if (PyObject_SetAttrString(result, "type", value) == -1) goto failed; Py_DECREF(value); - value = ast2obj_expr(o->name); + value = ast2obj_identifier(o->name); if (!value) goto failed; if (PyObject_SetAttrString(result, "name", value) == -1) goto failed; diff --git a/Python/ast.c b/Python/ast.c index 5ccd6f530d..41fb50e410 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -2899,11 +2899,9 @@ ast_for_except_clause(struct compiling *c, const node *exc, node *body) else if (NCH(exc) == 4) { asdl_seq *suite_seq; expr_ty expression; - expr_ty e = ast_for_expr(c, CHILD(exc, 3)); + identifier e = NEW_IDENTIFIER(CHILD(exc, 3)); if (!e) return NULL; - if (!set_context(e, Store, CHILD(exc, 3))) - return NULL; expression = ast_for_expr(c, CHILD(exc, 1)); if (!expression) return NULL; diff --git a/Python/compile.c b/Python/compile.c index 481cc85886..e3bdaf5a1e 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1956,16 +1956,13 @@ compiler_try_except(struct compiler *c, stmt_ty s) ADDOP(c, POP_TOP); if (handler->name) { basicblock *cleanup_end, *cleanup_body; - expr_context_ty orig_ctx; - - assert(handler->name->kind == Name_kind); cleanup_end = compiler_new_block(c); cleanup_body = compiler_new_block(c); if(!(cleanup_end || cleanup_body)) return 0; - VISIT(c, expr, handler->name); + compiler_nameop(c, handler->name, Store); ADDOP(c, POP_TOP); /* @@ -1998,14 +1995,10 @@ compiler_try_except(struct compiler *c, stmt_ty s) /* name = None */ ADDOP_O(c, LOAD_CONST, Py_None, consts); - orig_ctx = handler->name->v.Name.ctx; - handler->name->v.Name.ctx = Store; - VISIT(c, expr, handler->name); - - /* del name */ - handler->name->v.Name.ctx = Del; - VISIT(c, expr, handler->name); - handler->name->v.Name.ctx = orig_ctx; + compiler_nameop(c, handler->name, Store); + + /* del name */ + compiler_nameop(c, handler->name, Del); ADDOP(c, END_FINALLY); compiler_pop_fblock(c, FINALLY_END, cleanup_end); diff --git a/Python/graminit.c b/Python/graminit.c index 3f0224045e..0c4bfb5739 100644 --- a/Python/graminit.c +++ b/Python/graminit.c @@ -1053,7 +1053,7 @@ static arc arcs_46_2[2] = { {0, 2}, }; static arc arcs_46_3[1] = { - {22, 4}, + {19, 4}, }; static arc arcs_46_4[1] = { {0, 4}, diff --git a/Python/symtable.c b/Python/symtable.c index 708e18cafd..d275cb9034 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -1335,7 +1335,8 @@ 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); + if (!symtable_add_def(st, eh->name, DEF_LOCAL)) + return 0; VISIT_SEQ(st, stmt, eh->body); return 1; } |