File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
python/ql/src/semmle/python/types Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -269,6 +269,18 @@ class ExceptFlowNode extends ControlFlowNode {
269
269
)
270
270
}
271
271
272
+ private predicate handledObject ( Value val , ClassValue cls , ControlFlowNode origin ) {
273
+ val .getClass ( ) = cls and
274
+ (
275
+ this .getType ( ) .pointsTo ( val , origin )
276
+ or
277
+ exists ( TupleValue tup |
278
+ this .handledObject ( tup , ClassValue:: tuple ( ) , _) |
279
+ val = tup .getItem ( _) and origin .pointsTo ( val )
280
+ )
281
+ )
282
+ }
283
+
272
284
/** Gets the inferred type(s) that are handled by this node, splitting tuples if possible. */
273
285
pragma [ noinline]
274
286
predicate handledException_objectapi ( Object obj , ClassObject cls , ControlFlowNode origin ) {
@@ -278,6 +290,15 @@ class ExceptFlowNode extends ControlFlowNode {
278
290
origin = this
279
291
}
280
292
293
+ /** Gets the inferred type(s) that are handled by this node, splitting tuples if possible. */
294
+ pragma [ noinline]
295
+ predicate handledException ( Value val , ClassValue cls , ControlFlowNode origin ) {
296
+ this .handledObject ( val , cls , origin ) and not cls = ClassValue:: tuple ( )
297
+ or
298
+ not exists ( this .getNode ( ) .( ExceptStmt ) .getType ( ) ) and val = ClassValue:: baseException ( ) and cls = ClassValue:: type ( ) and
299
+ origin = this
300
+ }
301
+
281
302
/** Whether this `except` handles `cls` */
282
303
predicate handles ( ClassObject cls ) {
283
304
exists ( ClassObject handled |
You can’t perform that action at this time.
0 commit comments