mirror of
https://github.com/github/codeql.git
synced 2025-12-16 08:43:11 +01:00
Apply suggestions from code review
Co-authored-by: Rasmus Wriedt Larsen <rasmuswl@github.com>
This commit is contained in:
@@ -14,6 +14,7 @@ class StmtList_ extends @py_stmt_list {
|
||||
*/
|
||||
bindingset[new_index]
|
||||
int old_index(int new_index) {
|
||||
not new_index = 7 and
|
||||
if new_index < 7 then result = new_index else result + (8 - 7) = new_index
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
---
|
||||
category: breaking
|
||||
---
|
||||
* `Try::getAHandler` no longer returns an `ExceptStmt`, as handlers may also be `ExceptGroupStmt`s. Instead, it returns a plain `Stmt`. This means that code of the form `try.getAHandler().getType()` will no longer work. Instead, use `try.getANormalHandler().getType()` or `try.getAGroupHandler().getType()`, depending on your use case.
|
||||
* `Try.getAHandler()` and `Try.getHandler(<index>)` have results of type `Stmt` instead of `ExceptStmt`, as handlers may also be `ExceptGroupStmt`s (After Python 3.11 introduced PEP 654). This means that code of the form `try.getAHandler().getType()` will no longer work. Instead, use `try.getANormalHandler().getType()` or `try.getAGroupHandler().getType()`, depending on your use case.
|
||||
|
||||
@@ -145,7 +145,6 @@ class Exec extends Exec_ {
|
||||
|
||||
/** An except group statement (part of a `try` statement), such as `except* IOError as err:` */
|
||||
class ExceptGroupStmt extends ExceptGroupStmt_ {
|
||||
/* syntax: except Expr [ as Expr ]: */
|
||||
/** Gets the immediately enclosing try statement */
|
||||
Try getTry() { result.getAHandler() = this }
|
||||
|
||||
|
||||
@@ -522,7 +522,7 @@ class ExceptionCapture extends EssaNodeDefinition {
|
||||
* `ExceptionType` in `except ExceptionType as ex:`.
|
||||
*/
|
||||
ControlFlowNode getType() {
|
||||
exists(ExceptGroupFlowNode ex |
|
||||
exists(ExceptFlowNode ex |
|
||||
ex.getName() = this.getDefiningNode() and
|
||||
result = ex.getType()
|
||||
)
|
||||
|
||||
@@ -453,7 +453,7 @@ class ExceptGroupFlowNode extends ControlFlowNode {
|
||||
|
||||
/**
|
||||
* Gets the type handled by this exception handler.
|
||||
* `eg` in `except* eg as e:`
|
||||
* `ExceptionType` in `except* ExceptionType as e:`
|
||||
*/
|
||||
ControlFlowNode getType() {
|
||||
this.getBasicBlock().dominates(result.getBasicBlock()) and
|
||||
@@ -462,7 +462,7 @@ class ExceptGroupFlowNode extends ControlFlowNode {
|
||||
|
||||
/**
|
||||
* Gets the name assigned to the handled exception, if any.
|
||||
* `e` in `except* eg as e:`
|
||||
* `e` in `except* ExceptionType as e:`
|
||||
*/
|
||||
ControlFlowNode getName() {
|
||||
this.getBasicBlock().dominates(result.getBasicBlock()) and
|
||||
|
||||
Reference in New Issue
Block a user