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

Skip to content

Commit 8a6f295

Browse files
committed
Fix SF bug [ #445474 ] warn about import * inside functions
Reported by the Man himself.
1 parent 5dd064a commit 8a6f295

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Python/compile.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5294,6 +5294,11 @@ symtable_import(struct symtable *st, node *n)
52945294
}
52955295
}
52965296
if (TYPE(CHILD(n, 3)) == STAR) {
5297+
if (st->st_cur->ste_type != TYPE_MODULE) {
5298+
symtable_warn(st,
5299+
"import * not allowed inside function");
5300+
return;
5301+
}
52975302
st->st_cur->ste_optimized |= OPT_IMPORT_STAR;
52985303
st->st_cur->ste_opt_lineno = n->n_lineno;
52995304
} else {

0 commit comments

Comments
 (0)