Skip to content

Commit 28b32ac

Browse files
committed
Simplify logic for handling import *
1 parent b15ec09 commit 28b32ac

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

Python/compile.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2440,7 +2440,6 @@ static int
24402440
compiler_from_import(struct compiler *c, stmt_ty s)
24412441
{
24422442
int i, n = asdl_seq_LEN(s->v.ImportFrom.names);
2443-
int star = 0;
24442443

24452444
PyObject *names = PyTuple_New(n);
24462445
if (!names)
@@ -2474,8 +2473,7 @@ compiler_from_import(struct compiler *c, stmt_ty s)
24742473
if (i == 0 && *PyString_AS_STRING(alias->name) == '*') {
24752474
assert(n == 1);
24762475
ADDOP(c, IMPORT_STAR);
2477-
star = 1;
2478-
break;
2476+
return 1;
24792477
}
24802478

24812479
ADDOP_NAME(c, IMPORT_FROM, alias->name, names);
@@ -2488,9 +2486,8 @@ compiler_from_import(struct compiler *c, stmt_ty s)
24882486
return 0;
24892487
}
24902488
}
2491-
if (!star)
2492-
/* remove imported module */
2493-
ADDOP(c, POP_TOP);
2489+
/* remove imported module */
2490+
ADDOP(c, POP_TOP);
24942491
return 1;
24952492
}
24962493

0 commit comments

Comments
 (0)