Merge pull request #2147 from tausbn/python-cyclic-import-package-fp

Python: Fix cyclic import FP relating to packages.
This commit is contained in:
Rasmus Wriedt Larsen
2019-10-25 11:57:55 +02:00
committed by GitHub
22 changed files with 29 additions and 1 deletions

View File

@@ -21,7 +21,8 @@ predicate circular_import(ModuleValue m1, ModuleValue m2) {
ModuleValue stmt_imports(ImportingStmt s) {
exists(string name | result.importedAs(name) and not name = "__main__" |
name = s.getAnImportedModuleName() and
s.getASubExpression().pointsTo(result)
s.getASubExpression().pointsTo(result) and
not result.isPackage()
)
}

View File

@@ -139,6 +139,11 @@ class ModuleValue extends Value {
PointsToInternal::module_imported_as(this, name)
}
/** Whether this module is a package. */
predicate isPackage() {
this instanceof PackageObjectInternal
}
}
module Module {