Skip to content

Commit 505f454

Browse files
yoffRasmusWL
andauthored
Apply suggestions from code review
Co-authored-by: Rasmus Wriedt Larsen <[email protected]>
1 parent 4f15937 commit 505f454

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

python/downgrades/47e552c4357a04c5735355fad818630daee4a5ac/py_stmts.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class StmtList_ extends @py_stmt_list {
1414
*/
1515
bindingset[new_index]
1616
int old_index(int new_index) {
17+
not new_index = 7 and
1718
if new_index < 7 then result = new_index else result + (8 - 7) = new_index
1819
}
1920

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
category: breaking
33
---
4-
* `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.
4+
* `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.

python/ql/lib/semmle/python/Stmts.qll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ class Exec extends Exec_ {
145145

146146
/** An except group statement (part of a `try` statement), such as `except* IOError as err:` */
147147
class ExceptGroupStmt extends ExceptGroupStmt_ {
148-
/* syntax: except Expr [ as Expr ]: */
149148
/** Gets the immediately enclosing try statement */
150149
Try getTry() { result.getAHandler() = this }
151150

python/ql/lib/semmle/python/essa/Essa.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ class ExceptionCapture extends EssaNodeDefinition {
522522
* `ExceptionType` in `except ExceptionType as ex:`.
523523
*/
524524
ControlFlowNode getType() {
525-
exists(ExceptGroupFlowNode ex |
525+
exists(ExceptFlowNode ex |
526526
ex.getName() = this.getDefiningNode() and
527527
result = ex.getType()
528528
)

python/ql/lib/semmle/python/types/Exceptions.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ class ExceptGroupFlowNode extends ControlFlowNode {
453453

454454
/**
455455
* Gets the type handled by this exception handler.
456-
* `eg` in `except* eg as e:`
456+
* `ExceptionType` in `except* ExceptionType as e:`
457457
*/
458458
ControlFlowNode getType() {
459459
this.getBasicBlock().dominates(result.getBasicBlock()) and
@@ -462,7 +462,7 @@ class ExceptGroupFlowNode extends ControlFlowNode {
462462

463463
/**
464464
* Gets the name assigned to the handled exception, if any.
465-
* `e` in `except* eg as e:`
465+
* `e` in `except* ExceptionType as e:`
466466
*/
467467
ControlFlowNode getName() {
468468
this.getBasicBlock().dominates(result.getBasicBlock()) and

0 commit comments

Comments
 (0)