Skip to content

Commit 9a0b2b1

Browse files
authored
Merge pull request github#2989 from BekaValentine/python-objectapi-to-valueapi-incorrectexceptorder
Python: ObjectAPI to ValueAPI: IncorrectExceptOrder
2 parents 290e33a + 68c455c commit 9a0b2b1

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

python/ql/src/Exceptions/IncorrectExceptOrder.ql

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@
1414

1515
import python
1616

17-
predicate incorrect_except_order(ExceptStmt ex1, ClassObject cls1, ExceptStmt ex2, ClassObject cls2) {
18-
exists(int i, int j, Try t |
19-
ex1 = t.getHandler(i) and
20-
ex2 = t.getHandler(j) and i < j and
21-
cls1 = except_class(ex1) and
22-
cls2 = except_class(ex2) and
23-
cls1 = cls2.getASuperType()
24-
)
17+
predicate incorrect_except_order(ExceptStmt ex1, ClassValue cls1, ExceptStmt ex2, ClassValue cls2) {
18+
exists(int i, int j, Try t |
19+
ex1 = t.getHandler(i) and
20+
ex2 = t.getHandler(j) and
21+
i < j and
22+
cls1 = except_class(ex1) and
23+
cls2 = except_class(ex2) and
24+
cls1 = cls2.getASuperType()
25+
)
2526
}
2627

27-
ClassObject except_class(ExceptStmt ex) {
28-
ex.getType().refersTo(result)
29-
}
28+
ClassValue except_class(ExceptStmt ex) { ex.getType().pointsTo(result) }
3029

31-
from ExceptStmt ex1, ClassObject cls1, ExceptStmt ex2, ClassObject cls2
30+
from ExceptStmt ex1, ClassValue cls1, ExceptStmt ex2, ClassValue cls2
3231
where incorrect_except_order(ex1, cls1, ex2, cls2)
33-
select ex2, "Except block for $@ is unreachable; the more general $@ for $@ will always be executed in preference.",
34-
cls2, cls2.getName(), ex1, "except block", cls1, cls1.getName()
32+
select ex2,
33+
"Except block for $@ is unreachable; the more general $@ for $@ will always be executed in preference.",
34+
cls2, cls2.getName(), ex1, "except block", cls1, cls1.getName()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| exceptions_test.py:64:1:64:22 | ExceptStmt | Except block for $@ is unreachable; the more general $@ for $@ will always be executed in preference. | file://:Compiled Code:0:0:0:0 | builtin-class AttributeError | AttributeError | exceptions_test.py:62:1:62:17 | ExceptStmt | except block | file://:Compiled Code:0:0:0:0 | builtin-class Exception | Exception |
1+
| exceptions_test.py:64:1:64:22 | ExceptStmt | Except block for $@ is unreachable; the more general $@ for $@ will always be executed in preference. | file://:0:0:0:0 | builtin-class AttributeError | AttributeError | exceptions_test.py:62:1:62:17 | ExceptStmt | except block | file://:0:0:0:0 | builtin-class Exception | Exception |

0 commit comments

Comments
 (0)