Module Exceptions
Analysis of exception raising and handling.
In order to make this useful we make a number of assumptions. These are:
- Typing errors (TypeError, NameError, AttributeError) are assumed to occur only if:
a) Explicitly raised, e.g.
raise TypeError()
or b) Explicitly caught, e.g.except TypeError:
- Asynchronous exceptions, MemoryError, KeyboardInterrupt are ignored.
- Calls to unidentified objects can raise anything, unless it is an attribute named ‘read’ or ‘write’ in which case it can raise IOError.
Import path
import semmle.python.types.Exceptions
Imports
Predicates
scope_raises | INTERNAL – Use FunctionObject.getARaisedType() instead |
scope_raises_objectapi | INTERNAL – Use FunctionObject.getARaisedType() instead |
scope_raises_unknown | INTERNAL – Use FunctionObject.raisesUnknownType() instead |
Classes
ExceptFlowNode | The ControlFlowNode for an ‘except’ statement. |
ExceptGroupFlowNode | The ControlFlowNode for an ‘except*’ statement. |
RaisingNode | The subset of ControlFlowNodes which might raise an exception |
ReraisingNode | A Reraising node is the node at the end of a finally block (on the exceptional branch) that reraises the current exception. |