Skip to content

Commit 0599e8a

Browse files
committed
python: add version check
and attempt to set version for tests
1 parent 163bfc4 commit 0599e8a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

python/ql/src/Exceptions/UnguardedNextInGenerator.ql

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,12 @@ where
6666
) and
6767
call.getNode().getScope().(Function).isGenerator() and
6868
not exists(Comp comp | comp.contains(call.getNode())) and
69-
not stop_iteration_handled(call)
69+
not stop_iteration_handled(call) and
70+
// PEP 479 removes this concern from 3.5 onwards
71+
// see: https://peps.python.org/pep-0479/
72+
(
73+
major_version() = 2
74+
or
75+
major_version() = 3 and minor_version() < 5
76+
)
7077
select call, "Call to next() in a generator"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
semmle-extractor-options: --lang=3 --version=3.2

0 commit comments

Comments
 (0)