mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Some more changes related to the new except syntax and semantics,
by Collin Winter.
This commit is contained in:
parent
b940e113bf
commit
16be03e4a2
10 changed files with 46 additions and 32 deletions
|
@ -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);
|
||||
compiler_nameop(c, handler->name, Store);
|
||||
|
||||
/* del name */
|
||||
handler->name->v.Name.ctx = Del;
|
||||
VISIT(c, expr, handler->name);
|
||||
handler->name->v.Name.ctx = orig_ctx;
|
||||
/* del name */
|
||||
compiler_nameop(c, handler->name, Del);
|
||||
|
||||
ADDOP(c, END_FINALLY);
|
||||
compiler_pop_fblock(c, FINALLY_END, cleanup_end);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue