diff options
author | Collin Winter <collinw@gmail.com> | 2007-08-31 00:04:24 (GMT) |
---|---|---|
committer | Collin Winter <collinw@gmail.com> | 2007-08-31 00:04:24 (GMT) |
commit | 828f04ac3f0dd3b68b4dbf42a79ebb846d1de568 (patch) | |
tree | 21e25d3d969ce636c32539e4d4b5255dc4c85702 /Python/ast.c | |
parent | 150b7d7d02eca6970d792f3e6887f957a36b6ca2 (diff) | |
download | cpython-828f04ac3f0dd3b68b4dbf42a79ebb846d1de568.zip cpython-828f04ac3f0dd3b68b4dbf42a79ebb846d1de568.tar.gz cpython-828f04ac3f0dd3b68b4dbf42a79ebb846d1de568.tar.bz2 |
Issue #1066: implement PEP 3109, 2/3 of PEP 3134.
Diffstat (limited to 'Python/ast.c')
-rw-r--r-- | Python/ast.c | 39 |
1 files changed, 9 insertions, 30 deletions
diff --git a/Python/ast.c b/Python/ast.c index c13d093..8dd3c4ab 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -2199,39 +2199,18 @@ ast_for_flow_stmt(struct compiling *c, const node *n) } case raise_stmt: if (NCH(ch) == 1) - return Raise(NULL, NULL, NULL, LINENO(n), n->n_col_offset, c->c_arena); - else if (NCH(ch) == 2) { + return Raise(NULL, NULL, LINENO(n), n->n_col_offset, c->c_arena); + else if (NCH(ch) >= 2) { + expr_ty cause = NULL; expr_ty expression = ast_for_expr(c, CHILD(ch, 1)); if (!expression) return NULL; - return Raise(expression, NULL, NULL, LINENO(n), n->n_col_offset, c->c_arena); - } - else if (NCH(ch) == 4) { - expr_ty expr1, expr2; - - expr1 = ast_for_expr(c, CHILD(ch, 1)); - if (!expr1) - return NULL; - expr2 = ast_for_expr(c, CHILD(ch, 3)); - if (!expr2) - return NULL; - - return Raise(expr1, expr2, NULL, LINENO(n), n->n_col_offset, c->c_arena); - } - else if (NCH(ch) == 6) { - expr_ty expr1, expr2, expr3; - - expr1 = ast_for_expr(c, CHILD(ch, 1)); - if (!expr1) - return NULL; - expr2 = ast_for_expr(c, CHILD(ch, 3)); - if (!expr2) - return NULL; - expr3 = ast_for_expr(c, CHILD(ch, 5)); - if (!expr3) - return NULL; - - return Raise(expr1, expr2, expr3, LINENO(n), n->n_col_offset, c->c_arena); + if (NCH(ch) == 4) { + cause = ast_for_expr(c, CHILD(ch, 3)); + if (!cause) + return NULL; + } + return Raise(expression, cause, LINENO(n), n->n_col_offset, c->c_arena); } default: PyErr_Format(PyExc_SystemError, |