Skip to content

Commit ec9063b

Browse files
authored
Python: Add test case for #6227
1 parent 48ec223 commit ec9063b

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
| test.py:5:15:5:22 | ControlFlowNode for next() | Call to next() in a generator |
22
| test.py:10:20:10:27 | ControlFlowNode for next() | Call to next() in a generator |
3+
| test.py:62:19:62:28 | ControlFlowNode for next() | Call to next() in a generator |

python/ql/test/query-tests/Exceptions/generators/test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,12 @@ def ok5(seq):
5353

5454
def ok6(seq):
5555
yield next(iter([]), default='foo')
56+
57+
# Handling for multiple exception types, one of which is `StopIteration`
58+
# Reported as a false positive in github/codeql#6227
59+
def ok7(seq, ctx):
60+
try:
61+
with ctx:
62+
yield next(iter)
63+
except (StopIteration, MemoryError):
64+
return

0 commit comments

Comments
 (0)