summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-07-08 05:31:37 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-07-08 05:31:37 (GMT)
commitfb48afa708d2b5de9d59e6c91e2c063889c41e45 (patch)
treef1620629f1f2b47ec730d8ea86de9ca9f7776dc1 /Python
parentb6b175229bb8e9c94b104c3037b14e41b7549907 (diff)
downloadcpython-fb48afa708d2b5de9d59e6c91e2c063889c41e45.zip
cpython-fb48afa708d2b5de9d59e6c91e2c063889c41e45.tar.gz
cpython-fb48afa708d2b5de9d59e6c91e2c063889c41e45.tar.bz2
Fix SF bug #1519018: 'as' is now validated properly in import statements
Diffstat (limited to 'Python')
-rw-r--r--Python/ast.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/Python/ast.c b/Python/ast.c
index f3e611b..4c78b00 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -2142,7 +2142,14 @@ alias_for_import_name(struct compiling *c, const node *n)
loop:
switch (TYPE(n)) {
case import_as_name:
- str = (NCH(n) == 3) ? NEW_IDENTIFIER(CHILD(n, 2)) : NULL;
+ str = NULL;
+ if (NCH(n) == 3) {
+ if (strcmp(STR(CHILD(n, 1)), "as") != 0) {
+ ast_error(n, "must use 'as' in import");
+ return NULL;
+ }
+ str = NEW_IDENTIFIER(CHILD(n, 2));
+ }
return alias(NEW_IDENTIFIER(CHILD(n, 0)), str, c->c_arena);
case dotted_as_name:
if (NCH(n) == 1) {
@@ -2151,6 +2158,10 @@ alias_for_import_name(struct compiling *c, const node *n)
}
else {
alias_ty a = alias_for_import_name(c, CHILD(n, 0));
+ if (strcmp(STR(CHILD(n, 1)), "as") != 0) {
+ ast_error(n, "must use 'as' in import");
+ return NULL;
+ }
assert(!a->asname);
a->asname = NEW_IDENTIFIER(CHILD(n, 2));
return a;