File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
test/query-tests/Exceptions/generators Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -153,6 +153,12 @@ class ExceptStmt extends ExceptStmt_ {
153
153
override Stmt getASubStatement ( ) { result = this .getAStmt ( ) }
154
154
155
155
override Stmt getLastStatement ( ) { result = this .getBody ( ) .getLastItem ( ) .getLastStatement ( ) }
156
+
157
+ override Expr getType ( ) {
158
+ result = super .getType ( ) and not result instanceof Tuple
159
+ or
160
+ result = super .getType ( ) .( Tuple ) .getAnElt ( )
161
+ }
156
162
}
157
163
158
164
/** An assert statement, such as `assert a == b, "A is not equal to b"` */
Original file line number Diff line number Diff line change @@ -53,3 +53,12 @@ def ok5(seq):
53
53
54
54
def ok6 (seq ):
55
55
yield next (iter ([]), default = 'foo' )
56
+
57
+ # Handling for multiple exception types, one of which is `StopIteration`
58
+ # Reported as a false positive in github/codeql#6227
59
+ def ok7 (seq , ctx ):
60
+ try :
61
+ with ctx :
62
+ yield next (iter )
63
+ except (StopIteration , MemoryError ):
64
+ return
You can’t perform that action at this time.
0 commit comments