summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-07-04 16:59:04 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-07-04 16:59:04 (GMT)
commit1a7f3020a7abd7b1904f60ebb520180b3a124b5e (patch)
treea5bdbbcc815e1b54407fe96a79ca767e333c2e4d /Modules
parent644bef795b2a87ae41cdb308a526d562d77ff116 (diff)
downloadcpython-1a7f3020a7abd7b1904f60ebb520180b3a124b5e.zip
cpython-1a7f3020a7abd7b1904f60ebb520180b3a124b5e.tar.gz
cpython-1a7f3020a7abd7b1904f60ebb520180b3a124b5e.tar.bz2
Issue #9130: Fix validation of relative imports in parser module.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/parsermodule.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c
index 097c450..e1b7a2b 100644
--- a/Modules/parsermodule.c
+++ b/Modules/parsermodule.c
@@ -1886,8 +1886,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)
@@ -1897,7 +1897,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");