Python: Add test case for github/codeql#6227

This commit is contained in:
Taus
2021-07-14 13:52:32 +00:00
committed by GitHub
parent 48ec223727
commit ec9063b4a5
2 changed files with 10 additions and 0 deletions

View File

@@ -1,2 +1,3 @@
| test.py:5:15:5:22 | ControlFlowNode for next() | Call to next() in a generator |
| test.py:10:20:10:27 | ControlFlowNode for next() | Call to next() in a generator |
| test.py:62:19:62:28 | ControlFlowNode for next() | Call to next() in a generator |

View File

@@ -53,3 +53,12 @@ def ok5(seq):
def ok6(seq):
yield next(iter([]), default='foo')
# Handling for multiple exception types, one of which is `StopIteration`
# Reported as a false positive in github/codeql#6227
def ok7(seq, ctx):
try:
with ctx:
yield next(iter)
except (StopIteration, MemoryError):
return