Apply suggestions from code review

Co-authored-by: Rasmus Wriedt Larsen <rasmuswl@github.com>
This commit is contained in:
yoff
2022-11-16 22:20:19 +01:00
committed by GitHub
parent 4f159371f9
commit 505f454878
5 changed files with 5 additions and 5 deletions

View File

@@ -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
}

View File

@@ -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.

View File

@@ -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 }

View File

@@ -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()
)

View File

@@ -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