python: add version check

and attempt to set version for tests
This commit is contained in:
Rasmus Lerchedahl Petersen
2022-09-01 23:47:07 +02:00
parent 163bfc4f71
commit 0599e8ac35
2 changed files with 9 additions and 1 deletions

View File

@@ -66,5 +66,12 @@ where
) and
call.getNode().getScope().(Function).isGenerator() and
not exists(Comp comp | comp.contains(call.getNode())) and
not stop_iteration_handled(call)
not stop_iteration_handled(call) and
// PEP 479 removes this concern from 3.5 onwards
// see: https://peps.python.org/pep-0479/
(
major_version() = 2
or
major_version() = 3 and minor_version() < 5
)
select call, "Call to next() in a generator"

View File

@@ -0,0 +1 @@
semmle-extractor-options: --lang=3 --version=3.2