mirror of
https://github.com/github/codeql.git
synced 2025-12-21 19:26:31 +01:00
python: convenience methods for handler types
This commit is contained in:
@@ -392,6 +392,12 @@ class Try extends Try_ {
|
||||
/** Gets an exception handler of this try statement. */
|
||||
override Stmt getAHandler() { result = Try_.super.getAHandler() }
|
||||
|
||||
/** Gets a normal exception handler, `except`, of this try statement. */
|
||||
ExceptStmt getANormalHandler() { result = this.getAHandler() }
|
||||
|
||||
/** Gets a group exception handler, `except*`, of this try statement. */
|
||||
ExceptGroupStmt getAGroupHandler() { result = this.getAHandler() }
|
||||
|
||||
override Stmt getLastStatement() {
|
||||
result = this.getFinalbody().getLastItem().getLastStatement()
|
||||
or
|
||||
|
||||
@@ -52,7 +52,7 @@ predicate iter_not_exhausted(EssaVariable iterator) {
|
||||
predicate stop_iteration_handled(CallNode call) {
|
||||
exists(Try t |
|
||||
t.containsInScope(call.getNode()) and
|
||||
t.getAHandler().getType() = stopIteration().getAValueReachableFromSource().asExpr()
|
||||
t.getANormalHandler().getType() = stopIteration().getAValueReachableFromSource().asExpr()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user