Python: Adds preliminary modernization

This commit is contained in:
Rebecca Valentine
2020-03-10 08:51:20 -07:00
parent 4c1d76ee9a
commit 160f6cbc15
2 changed files with 24 additions and 4 deletions

View File

@@ -12,8 +12,8 @@
import python
Function iter_method(ClassObject t) {
result = ((FunctionObject)t.lookupAttribute("__iter__")).getFunction()
Function iter_method(ClassValue t) {
result = ((FunctionValue)t.lookup("__iter__")).getScope()
}
predicate is_self(Name value, Function f) {
@@ -28,6 +28,6 @@ predicate returns_non_self(Function f) {
exists(Return r | r.getScope() = f and not exists(r.getValue()))
}
from ClassObject t, Function iter
from ClassValue t, Function iter
where t.isIterator() and iter = iter_method(t) and returns_non_self(iter)
select t, "Class " + t.getName() + " is an iterator but its $@ method does not return 'self'.", iter, iter.getName()