Skip to content

Commit c949417

Browse files
committed
Python: Fix bad join in missing_imported_module
This caused a ~30x blowup in intermediate tuples, now back to baseline.
1 parent 7eddf56 commit c949417

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

python/ql/lib/semmle/python/objects/TObject.qll

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,16 +397,22 @@ private predicate neither_class_nor_static_method(Function f) {
397397
)
398398
}
399399

400+
/** Join-order helper for `missing_imported_module`. */
401+
pragma[nomagic]
402+
private predicate module_has_syntaxerror(Module m) {
403+
exists(SyntaxError se | se.getFile() = m.getFile())
404+
}
405+
400406
predicate missing_imported_module(ControlFlowNode imp, Context ctx, string name) {
401407
ctx.isImport() and
402408
imp.(ImportExprNode).getNode().getAnImportedModuleName() = name and
403409
(
404410
not exists(Module m | m.getName() = name) and
405411
not exists(Builtin b | b.isModule() and b.getName() = name)
406412
or
407-
exists(Module m, SyntaxError se |
413+
exists(Module m |
408414
m.getName() = name and
409-
se.getFile() = m.getFile()
415+
module_has_syntaxerror(m)
410416
)
411417
)
412418
or

0 commit comments

Comments
 (0)