mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +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. */
|
/** Gets an exception handler of this try statement. */
|
||||||
override Stmt getAHandler() { result = Try_.super.getAHandler() }
|
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() {
|
override Stmt getLastStatement() {
|
||||||
result = this.getFinalbody().getLastItem().getLastStatement()
|
result = this.getFinalbody().getLastItem().getLastStatement()
|
||||||
or
|
or
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ predicate iter_not_exhausted(EssaVariable iterator) {
|
|||||||
predicate stop_iteration_handled(CallNode call) {
|
predicate stop_iteration_handled(CallNode call) {
|
||||||
exists(Try t |
|
exists(Try t |
|
||||||
t.containsInScope(call.getNode()) and
|
t.containsInScope(call.getNode()) and
|
||||||
t.getAHandler().getType() = stopIteration().getAValueReachableFromSource().asExpr()
|
t.getANormalHandler().getType() = stopIteration().getAValueReachableFromSource().asExpr()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user