Python: Fix modernisation of py/iteration-string-and-sequence

Introduced a regression, since the old code was:

```
predicate is_a_string_type(ClassObject seqtype) {
    seqtype = theBytesType() and major_version() = 2
    or
    seqtype = theUnicodeType()
}
```

but *now* we're good!
This commit is contained in:
Rasmus Wriedt Larsen
2020-02-14 17:51:31 +01:00
parent 0509228296
commit d7b803a859

View File

@@ -13,6 +13,11 @@
import python
predicate has_string_type(Value v) {
v.getClass() = ClassValue::bytes() and major_version() = 2
or
v.getClass() = ClassValue::unicode()
}
from
For loop, ControlFlowNode iter, Value str, Value seq, ControlFlowNode seq_origin, ControlFlowNode str_origin
@@ -20,8 +25,8 @@ where
loop.getIter().getAFlowNode() = iter and
iter.pointsTo(str, str_origin) and
iter.pointsTo(seq, seq_origin) and
str.getClass() = ClassValue::str() and
has_string_type(str) and
seq.getClass().isIterable() and
not seq.getClass() = ClassValue::str()
not has_string_type(seq)
select loop, "Iteration over $@, of class " + seq.getClass().getName() + ", may also iterate over $@.",
seq_origin, "sequence", str_origin, "string"