@@ -64,15 +64,6 @@ predicate subscript(Stmt s) {
6464 s .( Delete ) .getATarget ( ) instanceof Subscript
6565}
6666
67- predicate encode_decode_objectapi ( Expr ex , ClassObject type ) {
68- exists ( string name |
69- ex .( Call ) .getFunc ( ) .( Attribute ) .getName ( ) = name |
70- name = "encode" and type = Object:: builtin ( "UnicodeEncodeError" )
71- or
72- name = "decode" and type = Object:: builtin ( "UnicodeDecodeError" )
73- )
74- }
75-
7667predicate encode_decode ( Expr ex , ClassValue type ) {
7768 exists ( string name |
7869 ex .( Call ) .getFunc ( ) .( Attribute ) .getName ( ) = name |
@@ -82,34 +73,12 @@ predicate encode_decode(Expr ex, ClassValue type) {
8273 )
8374}
8475
85- predicate small_handler_objectapi ( ExceptStmt ex , Stmt s , ClassObject type ) {
86- not exists ( ex .getTry ( ) .getStmt ( 1 ) ) and
87- s = ex .getTry ( ) .getStmt ( 0 ) and
88- ex .getType ( ) .refersTo ( type )
89- }
90-
9176predicate small_handler ( ExceptStmt ex , Stmt s , ClassValue type ) {
9277 not exists ( ex .getTry ( ) .getStmt ( 1 ) ) and
9378 s = ex .getTry ( ) .getStmt ( 0 ) and
9479 ex .getType ( ) .pointsTo ( type )
9580}
9681
97- /** Holds if this exception handler is sufficiently small in scope to not need a comment
98- * as to what it is doing.
99- */
100- predicate focussed_handler_objectapi ( ExceptStmt ex ) {
101- exists ( Stmt s , ClassObject type |
102- small_handler_objectapi ( ex , s , type ) |
103- subscript ( s ) and type .getAnImproperSuperType ( ) = theLookupErrorType ( )
104- or
105- attribute_access ( s ) and type = theAttributeErrorType ( )
106- or
107- s .( ExprStmt ) .getValue ( ) instanceof Name and type = theNameErrorType ( )
108- or
109- encode_decode_objectapi ( s .( ExprStmt ) .getValue ( ) , type )
110- )
111- }
112-
11382predicate focussed_handler ( ExceptStmt ex ) {
11483 exists ( Stmt s , ClassValue type |
11584 small_handler ( ex , s , type ) |
0 commit comments