Update of /cvsroot/python/python/dist/src/Modules In directory usw-pr-cvs1:/tmp/cvs-serv13436/Modules Modified Files: parsermodule.c Log Message: Fix problems with validation of import statement parse trees. This closes SF bug #127271. Index: parsermodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/parsermodule.c,v retrieving revision 2.59 retrieving revision 2.60 diff -C2 -r2.59 -r2.60 *** parsermodule.c 2000/12/11 22:08:27 2.59 --- parsermodule.c 2001/01/07 05:59:59 2.60 *************** *** 1559,1562 **** --- 1559,1581 ---- + /* dotted_name: NAME ("." NAME)* + */ + static int + validate_dotted_name(node *tree) + { + int nch = NCH(tree); + int res = (validate_ntype(tree, dotted_name) + && is_odd(nch) + && validate_name(CHILD(tree, 0), NULL)); + int i; + + for (i = 1; res && (i < nch); i += 2) { + res = (validate_dot(CHILD(tree, i)) + && validate_name(CHILD(tree, i+1), NULL)); + } + return res; + } + + /* dotted_as_name: dotted_name [NAME NAME] */ *************** *** 1569,1575 **** if (res) { if (nch == 1) ! res = validate_ntype(CHILD(tree, 0), dotted_name); else if (nch == 3) ! res = (validate_ntype(CHILD(tree, 0), dotted_name) && validate_name(CHILD(tree, 1), "as") && validate_name(CHILD(tree, 2), NULL)); --- 1588,1594 ---- if (res) { if (nch == 1) ! res = validate_dotted_name(CHILD(tree, 0)); else if (nch == 3) ! res = (validate_dotted_name(CHILD(tree, 0)) && validate_name(CHILD(tree, 1), "as") && validate_name(CHILD(tree, 2), NULL)); *************** *** 1602,1611 **** for (j = 2; res && (j < nch); j += 2) res = (validate_comma(CHILD(tree, j)) ! && validate_ntype(CHILD(tree, j + 1), dotted_name)); } else if (res && (res = validate_name(CHILD(tree, 0), "from"))) { res = ((nch >= 4) && is_even(nch) ! && validate_name(CHILD(tree, 2), "import") ! && validate_dotted_as_name(CHILD(tree, 1))); if (nch == 4) { if (TYPE(CHILD(tree, 3)) == import_as_name) --- 1621,1630 ---- for (j = 2; res && (j < nch); j += 2) res = (validate_comma(CHILD(tree, j)) ! && validate_dotted_as_name(CHILD(tree, j + 1))); } else if (res && (res = validate_name(CHILD(tree, 0), "from"))) { res = ((nch >= 4) && is_even(nch) ! && validate_dotted_name(CHILD(tree, 1)) ! && validate_name(CHILD(tree, 2), "import")); if (nch == 4) { if (TYPE(CHILD(tree, 3)) == import_as_name)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4