Skip to content

Commit e7c6c04

Browse files
authored
Merge pull request #9858 from tausbn/python-fix-bad-getOuterVariable-join
Python: Fix bad join in `getOuterVariable`
2 parents 3006fa6 + 1f5176d commit e7c6c04

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

python/ql/lib/semmle/python/types/ImportTime.qll

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,21 @@ class ImportTimeScope extends Scope {
2626

2727
/** Gets the global variable that is used during lookup, should `var` be undefined. */
2828
GlobalVariable getOuterVariable(LocalVariable var) {
29-
this instanceof Class and
30-
var.getScope() = this and
31-
result.getScope() = this.getEnclosingModule() and
32-
var.getId() = result.getId()
29+
exists(string name |
30+
class_var_scope(this, name, var) and
31+
global_var_scope(name, this.getEnclosingModule(), result)
32+
)
3333
}
3434
}
35+
36+
pragma[nomagic]
37+
private predicate global_var_scope(string name, Scope scope, GlobalVariable var) {
38+
var.getScope() = scope and
39+
var.getId() = name
40+
}
41+
42+
pragma[nomagic]
43+
private predicate class_var_scope(Class cls, string name, LocalVariable var) {
44+
var.getScope() = cls and
45+
var.getId() = name
46+
}

0 commit comments

Comments
 (0)