mirror of
https://github.com/github/codeql.git
synced 2026-05-02 04:05:14 +02:00
Merge pull request #6283 from tausbn/python-fix-exceptstmt-gettype
Python: Fix `ExceptStmt::getType`
This commit is contained in:
@@ -153,6 +153,12 @@ class ExceptStmt extends ExceptStmt_ {
|
||||
override Stmt getASubStatement() { result = this.getAStmt() }
|
||||
|
||||
override Stmt getLastStatement() { result = this.getBody().getLastItem().getLastStatement() }
|
||||
|
||||
override Expr getType() {
|
||||
result = super.getType() and not result instanceof Tuple
|
||||
or
|
||||
result = super.getType().(Tuple).getAnElt()
|
||||
}
|
||||
}
|
||||
|
||||
/** An assert statement, such as `assert a == b, "A is not equal to b"` */
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user