mirror of
https://github.com/github/codeql.git
synced 2025-12-19 18:33:16 +01:00
Merge pull request #2965 from BekaValentine/python-objectapi-to-valueapi-raising
Python: ObjectAPI to ValueAPI: Raising
This commit is contained in:
@@ -15,7 +15,7 @@ import python
|
||||
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(r, _)
|
||||
from Raise r, ClassValue t
|
||||
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."
|
||||
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import python
|
||||
|
||||
/** Whether the raise statement 'r' raises 'type' from origin 'orig' */
|
||||
predicate type_or_typeof(Raise r, ClassObject type, AstNode orig) {
|
||||
predicate type_or_typeof(Raise r, ClassValue type, AstNode orig) {
|
||||
exists(Expr exception |
|
||||
exception = r.getRaised() |
|
||||
exception.refersTo(type, _, orig)
|
||||
exception.pointsTo(type, orig)
|
||||
or
|
||||
not exists(ClassObject exc_type | exception.refersTo(exc_type)) and
|
||||
not type = theTypeType() and // First value is an unknown exception type
|
||||
exception.refersTo(_, type, orig)
|
||||
not exists(ClassValue exc_type | exception.pointsTo(exc_type)) and
|
||||
not type = ClassValue::type() and // First value is an unknown exception type
|
||||
exists(Value val | exception.pointsTo(val, orig) |
|
||||
val.getClass() = type
|
||||
)
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user