mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Python: Fix import * from __init__.py files
This commit is contained in:
@@ -167,8 +167,9 @@ module ImportResolution {
|
||||
)
|
||||
}
|
||||
|
||||
/** Gets the module from which attributes are imported by `i`. */
|
||||
Module getModuleImportedByImportStar(ImportStar i) {
|
||||
isPreferredModuleForName(result.getFile(), i.getImportedModuleName())
|
||||
isPreferredModuleForName(result.getFile(), i.getImportedModuleName() + ["", ".__init__"])
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -87,7 +87,7 @@ check("non_clashing_submodule", non_clashing_submodule, "<module attr_clash.non_
|
||||
|
||||
# check that import * from an __init__ file works
|
||||
from package.subpackage2 import *
|
||||
check("subpackage2_attr", subpackage2_attr, "subpackage2_attr", globals()) #$ MISSING: prints=subpackage2_attr
|
||||
check("subpackage2_attr", subpackage2_attr, "subpackage2_attr", globals()) #$ prints=subpackage2_attr
|
||||
|
||||
|
||||
exit(__file__)
|
||||
|
||||
Reference in New Issue
Block a user