Mercurial > cpython-lru_cache-weakref
diff Modules/parsermodule.c @ 76818:fc17f70292f6 3.2
Issue #14701: Add missing support for 'raise ... from' in parser module.
| author | Mark Dickinson <mdickinson@enthought.com> |
|---|---|
| date | Mon, 07 May 2012 12:01:27 +0100 |
| parents | b7e491b9094f |
| children | 129289144dfb 0dd0d56bdcc1 |
line wrap: on
line diff
--- a/Modules/parsermodule.c Mon May 07 10:24:02 2012 +0100 +++ b/Modules/parsermodule.c Mon May 07 12:01:27 2012 +0100 @@ -1608,31 +1608,30 @@ } +/* + * raise_stmt: + * + * 'raise' [test ['from' test]] + */ static int validate_raise_stmt(node *tree) { int nch = NCH(tree); int res = (validate_ntype(tree, raise_stmt) - && ((nch == 1) || (nch == 2) || (nch == 4) || (nch == 6))); + && ((nch == 1) || (nch == 2) || (nch == 4))); + + if (!res && !PyErr_Occurred()) + (void) validate_numnodes(tree, 2, "raise"); if (res) { res = validate_name(CHILD(tree, 0), "raise"); if (res && (nch >= 2)) res = validate_test(CHILD(tree, 1)); - if (res && nch > 2) { - res = (validate_comma(CHILD(tree, 2)) + if (res && (nch == 4)) { + res = (validate_name(CHILD(tree, 2), "from") && validate_test(CHILD(tree, 3))); - if (res && (nch > 4)) - res = (validate_comma(CHILD(tree, 4)) - && validate_test(CHILD(tree, 5))); } } - else - (void) validate_numnodes(tree, 2, "raise"); - if (res && (nch == 4)) - res = (validate_comma(CHILD(tree, 2)) - && validate_test(CHILD(tree, 3))); - return (res); }
