Python: Only alert on Python 2 code

since
- Python 3 is ok from 3.7 onwards
- support for Python 3.6 was just dropped
- we do not actually know the minor version of the analysed code
  (only of the extractor)
This commit is contained in:
Rasmus Lerchedahl Petersen
2022-09-05 13:38:14 +02:00
parent afb50212a0
commit 5fc1bbc8c5
5 changed files with 4 additions and 8 deletions

View File

@@ -67,13 +67,10 @@ where
call.getNode().getScope().(Function).isGenerator() and
not exists(Comp comp | comp.contains(call.getNode())) and
not stop_iteration_handled(call) and
// PEP 479 removes this concern from 3.5 onwards
// PEP 479 removes this concern from 3.7 onwards
// see: https://peps.python.org/pep-0479/
//
// However, testing it out, the problem is not removed until 3.7.
(
major_version() = 2
or
major_version() = 3 and minor_version() < 7
)
// However, we do not know the minor version of the analysed code (only of the extractor),
// so we only alert on Python 2.
major_version() = 2
select call, "Call to next() in a generator"