[Python-checkins] python/dist/src/Python ast.c,1.1.2.62,1.1.2.63
nascheme@users.sourceforge.net
nascheme at users.sourceforge.net
Thu Jun 2 07:34:38 CEST 2005
Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23165/Python
Modified Files:
Tag: ast-branch
ast.c
Log Message:
Add invalid trailing comma syntax check for import statements. Closes
SF patch #1194895.
Index: ast.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/ast.c,v
retrieving revision 1.1.2.62
retrieving revision 1.1.2.63
diff -u -d -r1.1.2.62 -r1.1.2.63
--- ast.c 28 Apr 2005 03:32:39 -0000 1.1.2.62
+++ ast.c 2 Jun 2005 05:34:35 -0000 1.1.2.63
@@ -2079,8 +2079,18 @@
/* XXX this needs to be cleaned up */
from_modules = STR(CHILD(n, 3));
- if (!from_modules || from_modules[0] == '*')
+ if (!from_modules) {
n = CHILD(n, 3); /* from ... import x, y, z */
+ if (NCH(n) % 2 == 0) {
+ /* it ends with a comma, not valid but the parser allows it */
+ ast_error(n, "trailing comma not allowed without"
+ " surrounding parentheses");
+ return NULL;
+ }
+ }
+ else if (from_modules[0] == '*') {
+ n = CHILD(n,3); /* from ... import * */
+ }
else if (from_modules[0] == '(')
n = CHILD(n, 4); /* from ... import (x, y, z) */
else
More information about the Python-checkins
mailing list