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

Skip to content

Commit 697a006

Browse files
committed
Python: Modernise py/undefined-global-variable
1 parent 5faa7e7 commit 697a006

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

python/ql/src/Variables/UndefinedGlobal.ql

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ predicate guarded_against_name_error(Name u) {
3131

3232
predicate contains_unknown_import_star(Module m) {
3333
exists(ImportStar imp | imp.getScope() = m |
34-
not exists(ModuleObject imported | imported.importedAs(imp.getImportedModuleName()))
34+
exists(ModuleValue imported | imported.importedAs(imp.getImportedModuleName()) and imported.isAbsent())
3535
or
36-
exists(ModuleObject imported |
36+
exists(ModuleValue imported |
3737
imported.importedAs(imp.getImportedModuleName()) |
38-
not imported.exportsComplete()
38+
not imported.hasCompleteExportInfo()
3939
)
4040
)
4141
}
@@ -58,7 +58,7 @@ predicate undefined_use_in_function(Name u) {
5858
and
5959
not ((ImportTimeScope)u.getEnclosingModule()).definesName(u.getId())
6060
and
61-
not exists(ModuleObject m | m.getModule() = u.getEnclosingModule() | m.hasAttribute(u.getId()))
61+
not exists(ModuleValue m | m.getScope() = u.getEnclosingModule() | m.hasAttribute(u.getId()))
6262
and
6363
not globallyDefinedName(u.getId())
6464
and
@@ -78,7 +78,7 @@ predicate undefined_use_in_class_or_module(Name u) {
7878
and
7979
not guarded_against_name_error(u)
8080
and
81-
not exists(ModuleObject m | m.getModule() = u.getEnclosingModule() | m.hasAttribute(u.getId()))
81+
not exists(ModuleValue m | m.getScope() = u.getEnclosingModule() | m.hasAttribute(u.getId()))
8282
and
8383
not (u.getEnclosingModule().isPackageInit() and u.getId() = "__path__")
8484
and
@@ -88,10 +88,10 @@ predicate undefined_use_in_class_or_module(Name u) {
8888
predicate use_of_exec(Module m) {
8989
exists(Exec exec | exec.getScope() = m)
9090
or
91-
exists(CallNode call, FunctionObject exec |
91+
exists(CallNode call, FunctionValue exec |
9292
exec.getACall() = call and call.getScope() = m |
93-
exec = Object::builtin("exec") or
94-
exec = Object::builtin("execfile")
93+
exec = Value::named("exec") or
94+
exec = Value::named("execfile")
9595
)
9696
}
9797

@@ -105,7 +105,7 @@ predicate undefined_use(Name u) {
105105
not contains_unknown_import_star(u.getEnclosingModule()) and
106106
not use_of_exec(u.getEnclosingModule()) and
107107
not exists(u.getVariable().getAStore()) and
108-
not u.refersTo(_) and
108+
not u.pointsTo(_) and
109109
not probably_defined_in_loop(u)
110110
}
111111

0 commit comments

Comments
 (0)