Skip to content

Commit 0d65db1

Browse files
committed
Python: ObjectAPI to ValueAPI: IterReturnsNonIterator: Adds preliminary modernization
1 parent a0992aa commit 0d65db1

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

python/ql/src/Functions/IterReturnsNonIterator.ql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212

1313
import python
1414

15-
ClassObject return_type(FunctionObject f) {
15+
ClassValue return_type(FunctionValue f) {
1616
exists(ControlFlowNode n, Return ret |
17-
ret.getScope() = f.getFunction() and
17+
ret.getScope() = f.getScope() and
1818
ret.getValue() = n.getNode() and
19-
n.refersTo(_, result, _)
19+
result = n.pointsTo().getClass()
2020
)
2121
}
2222

23-
from ClassObject iterable, FunctionObject iter, ClassObject iterator
23+
from ClassValue iterable, FunctionValue iter, ClassValue iterator
2424
where
25-
iter = iterable.lookupAttribute("__iter__") and
25+
iter = iterable.lookup("__iter__") and
2626
iterator = return_type(iter) and
2727
not iterator.isIterator()
2828
select iterator,
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
| file://:Compiled Code:0:0:0:0 | builtin-class object | Class object is returned as an iterator (by $@) but does not fully implement the iterator interface. | protocols.py:16:5:16:23 | Function __iter__ | __iter__ |
2-
| protocols.py:20:1:20:26 | class IteratorMissingNext | Class IteratorMissingNext is returned as an iterator (by $@) but does not fully implement the iterator interface. | protocols.py:22:5:22:23 | Function __iter__ | __iter__ |
3-
| protocols.py:20:1:20:26 | class IteratorMissingNext | Class IteratorMissingNext is returned as an iterator (by $@) but does not fully implement the iterator interface. | protocols.py:27:5:27:23 | Function __iter__ | __iter__ |
4-
| protocols.py:30:1:30:26 | class IteratorMissingIter | Class IteratorMissingIter is returned as an iterator (by $@) but does not fully implement the iterator interface. | protocols.py:40:5:40:23 | Function __iter__ | __iter__ |
1+
| file://:0:0:0:0 | builtin-class object | Class object is returned as an iterator (by $@) but does not fully implement the iterator interface. | protocols.py:16:5:16:23 | Function X.__iter__ | __iter__ |
2+
| protocols.py:20:1:20:26 | class IteratorMissingNext | Class IteratorMissingNext is returned as an iterator (by $@) but does not fully implement the iterator interface. | protocols.py:22:5:22:23 | Function IteratorMissingNext.__iter__ | __iter__ |
3+
| protocols.py:20:1:20:26 | class IteratorMissingNext | Class IteratorMissingNext is returned as an iterator (by $@) but does not fully implement the iterator interface. | protocols.py:27:5:27:23 | Function IterableMissingNext.__iter__ | __iter__ |
4+
| protocols.py:30:1:30:26 | class IteratorMissingIter | Class IteratorMissingIter is returned as an iterator (by $@) but does not fully implement the iterator interface. | protocols.py:40:5:40:23 | Function IterableMissingIter.__iter__ | __iter__ |

0 commit comments

Comments
 (0)