Skip to content

Commit b9f6657

Browse files
Remove use of toString. This does also reduce reaults from cases where the exception is not a simple identifier.
1 parent b973806 commit b9f6657

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

python/ql/src/Functions/IncorrectRaiseInSpecialMethod.ql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ predicate correctRaise(string name, Expr exec) {
7171
}
7272

7373
predicate preferredRaise(string name, string execName, string message) {
74-
// TODO: execName should be an IPA type
7574
attributeMethod(name) and
7675
execName = "AttributeError" and
7776
message = "should raise an AttributeError instead."
@@ -94,6 +93,7 @@ predicate preferredRaise(string name, string execName, string message) {
9493
}
9594

9695
predicate execIsOfType(Expr exec, string execName) {
96+
// Might make sense to have execName be an IPA type here. Or part of a more general API modelling builtin/stdlib subclass relations.
9797
exists(string subclass |
9898
execName = "TypeError" and
9999
subclass = "TypeError"
@@ -149,6 +149,8 @@ predicate isNotImplementedError(Expr exec) {
149149
exec = API::builtin("NotImplementedError").getACall().asExpr()
150150
}
151151

152+
string getExecName(Expr exec) { result = exec.(Call).getFunc().(Name).getId() }
153+
152154
from Function f, Expr exec, string message
153155
where
154156
f.isSpecialMethod() and
@@ -170,4 +172,4 @@ where
170172
else message = "This method raises $@ - " + subMessage
171173
)
172174
)
173-
select f, message, exec, exec.toString() // TODO: remove tostring
175+
select f, message, exec, getExecName(exec)

0 commit comments

Comments
 (0)