summaryrefslogtreecommitdiffstats
path: root/Modules/parsermodule.c
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-07-04 18:16:43 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-07-04 18:16:43 (GMT)
commit1b9b5727cc85c4aec17c2fa79f9491d986dbb00e (patch)
treeb3477eca8792ea14563fb6167e962820e34b7f59 /Modules/parsermodule.c
parent31a0f86e368c980b751bdc0b377e42322cf2566d (diff)
downloadcpython-1b9b5727cc85c4aec17c2fa79f9491d986dbb00e.zip
cpython-1b9b5727cc85c4aec17c2fa79f9491d986dbb00e.tar.gz
cpython-1b9b5727cc85c4aec17c2fa79f9491d986dbb00e.tar.bz2
Merged revisions 82552-82553 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r82552 | mark.dickinson | 2010-07-04 19:11:51 +0100 (Sun, 04 Jul 2010) | 2 lines Issue #9130: Fix validation of relative imports in parser module. ........ r82553 | mark.dickinson | 2010-07-04 19:15:26 +0100 (Sun, 04 Jul 2010) | 1 line Fix symbol numbers in test_parser test. ........
Diffstat (limited to 'Modules/parsermodule.c')
-rw-r--r--Modules/parsermodule.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c
index b00037d..c9150d9 100644
--- a/Modules/parsermodule.c
+++ b/Modules/parsermodule.c
@@ -1763,8 +1763,8 @@ count_from_dots(node *tree)
return i-1;
}
-/* 'from' ('.'* dotted_name | '.') 'import' ('*' | '(' import_as_names ')' |
- * import_as_names
+/* import_from: ('from' ('.'* dotted_name | '.'+)
+ * 'import' ('*' | '(' import_as_names ')' | import_as_names))
*/
static int
validate_import_from(node *tree)
@@ -1774,7 +1774,8 @@ validate_import_from(node *tree)
int havename = (TYPE(CHILD(tree, ndots + 1)) == dotted_name);
int offset = ndots + havename;
int res = validate_ntype(tree, import_from)
- && (nch >= 4 + ndots)
+ && (offset >= 1)
+ && (nch >= 3 + offset)
&& validate_name(CHILD(tree, 0), "from")
&& (!havename || validate_dotted_name(CHILD(tree, ndots + 1)))
&& validate_name(CHILD(tree, offset + 1), "import");