File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
python/ql/lib/semmle/python/dataflow/new/internal Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -2369,6 +2369,19 @@ module Reachability {
23692369 )
23702370 }
23712371
2372+ /**
2373+ * Holds if `node` is unlikely to raise an exception. This includes entry nodes
2374+ * and simple name lookups.
2375+ */
2376+ private predicate unlikelyToRaise ( ControlFlowNode node ) {
2377+ exists ( node .getAnExceptionalSuccessor ( ) ) and
2378+ (
2379+ node .getNode ( ) instanceof Name
2380+ or
2381+ exists ( Scope s | s .getEntryNode ( ) = node )
2382+ )
2383+ }
2384+
23722385 /**
23732386 * Holds if it is highly unlikely for control to flow from `node` to `succ`.
23742387 */
@@ -2381,6 +2394,10 @@ module Reachability {
23812394 succ = node .getASuccessor ( ) and
23822395 not succ = node .getAnExceptionalSuccessor ( ) and
23832396 not succ .getNode ( ) instanceof Yield
2397+ or
2398+ // Exception edge from a node that is unlikely to raise
2399+ unlikelyToRaise ( node ) and
2400+ succ = node .getAnExceptionalSuccessor ( )
23842401 }
23852402
23862403 private predicate startBbLikelyReachable ( BasicBlock b ) {
You can’t perform that action at this time.
0 commit comments