Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e753ef8

Browse files
committed
Re-allow 'import mod.submod as s', and change its meaning to what it should
mean; the same as 'from mod import submod as s'.
1 parent 8ebe84d commit e753ef8

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Python/compile.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2354,12 +2354,15 @@ com_import_stmt(struct compiling *c, node *n)
23542354
com_addopname(c, IMPORT_NAME, CHILD(subn, 0));
23552355
com_push(c, 1);
23562356
if (NCH(subn) > 1) {
2357-
if (strcmp(STR(CHILD(subn, 1)), "as") != 0 ||
2358-
NCH(CHILD(subn, 0)) > 1) {
2357+
int j;
2358+
if (strcmp(STR(CHILD(subn, 1)), "as") != 0) {
23592359
com_error(c, PyExc_SyntaxError,
23602360
"invalid syntax");
23612361
return;
23622362
}
2363+
for (j=2 ; j < NCH(CHILD(subn, 0)); j += 2)
2364+
com_addopname(c, LOAD_ATTR,
2365+
CHILD(CHILD(subn, 0), j));
23632366
com_addopname(c, STORE_NAME, CHILD(subn, 2));
23642367
} else
23652368
com_addopname(c, STORE_NAME,

0 commit comments

Comments
 (0)