Python: Adds modernized predicate and moves queries over to it

This commit is contained in:
Rebecca Valentine
2020-03-02 18:52:45 -08:00
parent c058e17089
commit e481ddf99e
4 changed files with 12 additions and 3 deletions

View File

@@ -16,6 +16,6 @@ import Raising
import Exceptions.NotImplemented
from Raise r, ClassObject t
where type_or_typeof(r, t, _) and not t.isLegalExceptionType() and not t.failedInference() and not use_of_not_implemented_in_raise_objectapi(r, _)
where type_or_typeof(r, t, _) and not t.isLegalExceptionType() and not t.failedInference() and not use_of_not_implemented_in_raise(r, _)
select r, "Illegal class '" + t.getName() + "' raised; will result in a TypeError being raised instead."

View File

@@ -9,3 +9,12 @@ predicate use_of_not_implemented_in_raise_objectapi(Raise raise, Expr notimpl) {
notimpl = raise.getException().(Call).getFunc()
)
}
/** Holds if `notimpl` refers to `NotImplemented` or `NotImplemented()` in the `raise` statement */
predicate use_of_not_implemented_in_raise(Raise raise, Expr notimpl) {
notimpl.pointsTo(Value::named("NotImplemented")) and
(
notimpl = raise.getException() or
notimpl = raise.getException().(Call).getFunc()
)
}

View File

@@ -14,6 +14,6 @@ import python
import Exceptions.NotImplemented
from Expr notimpl
where use_of_not_implemented_in_raise_objectapi(_, notimpl)
where use_of_not_implemented_in_raise(_, notimpl)
select notimpl, "NotImplemented is not an Exception. Did you mean NotImplementedError?"