mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
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'.
This commit is contained in:
parent
8ebe84dff5
commit
e753ef8d1b
1 changed files with 5 additions and 2 deletions
|
@ -2354,12 +2354,15 @@ com_import_stmt(struct compiling *c, node *n)
|
||||||
com_addopname(c, IMPORT_NAME, CHILD(subn, 0));
|
com_addopname(c, IMPORT_NAME, CHILD(subn, 0));
|
||||||
com_push(c, 1);
|
com_push(c, 1);
|
||||||
if (NCH(subn) > 1) {
|
if (NCH(subn) > 1) {
|
||||||
if (strcmp(STR(CHILD(subn, 1)), "as") != 0 ||
|
int j;
|
||||||
NCH(CHILD(subn, 0)) > 1) {
|
if (strcmp(STR(CHILD(subn, 1)), "as") != 0) {
|
||||||
com_error(c, PyExc_SyntaxError,
|
com_error(c, PyExc_SyntaxError,
|
||||||
"invalid syntax");
|
"invalid syntax");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
for (j=2 ; j < NCH(CHILD(subn, 0)); j += 2)
|
||||||
|
com_addopname(c, LOAD_ATTR,
|
||||||
|
CHILD(CHILD(subn, 0), j));
|
||||||
com_addopname(c, STORE_NAME, CHILD(subn, 2));
|
com_addopname(c, STORE_NAME, CHILD(subn, 2));
|
||||||
} else
|
} else
|
||||||
com_addopname(c, STORE_NAME,
|
com_addopname(c, STORE_NAME,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue