Skip to content

Commit b488087

Browse files
authored
Merge pull request #10264 from yoff/python/port-RaisesTuple
Approved by tausbn
2 parents ed4b64b + d31d763 commit b488087

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

python/ql/src/Exceptions/RaisingTuple.ql

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@
1010
*/
1111

1212
import python
13+
import semmle.python.dataflow.new.DataFlow
1314

14-
from Raise r, Value v, AstNode origin
15+
from Raise r, DataFlow::LocalSourceNode origin
1516
where
16-
r.getException().pointsTo(v, origin) and
17-
v.getClass() = ClassValue::tuple() and
17+
exists(DataFlow::Node exception | exception.asExpr() = r.getException() |
18+
origin.flowsTo(exception)
19+
) and
20+
origin.asExpr() instanceof Tuple and
1821
major_version() = 2
1922
/* Raising a tuple is a type error in Python 3, so is handled by the IllegalRaise query. */
2023
select r,
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
| test.py:8:5:8:12 | Raise | Raising $@ will result in the first element (recursively) being raised and all other elements being discarded. | test.py:7:10:7:29 | Tuple | a tuple |
2-
| test.py:11:5:11:32 | Raise | Raising $@ will result in the first element (recursively) being raised and all other elements being discarded. | test.py:11:12:11:31 | Tuple | a tuple |
3-
| test.py:15:5:15:23 | Raise | Raising $@ will result in the first element (recursively) being raised and all other elements being discarded. | test.py:14:10:14:19 | Tuple | a tuple |
1+
| test.py:8:5:8:12 | Raise | Raising $@ will result in the first element (recursively) being raised and all other elements being discarded. | test.py:7:10:7:29 | ControlFlowNode for Tuple | a tuple |
2+
| test.py:11:5:11:32 | Raise | Raising $@ will result in the first element (recursively) being raised and all other elements being discarded. | test.py:11:12:11:31 | ControlFlowNode for Tuple | a tuple |
3+
| test.py:15:5:15:23 | Raise | Raising $@ will result in the first element (recursively) being raised and all other elements being discarded. | test.py:14:10:14:19 | ControlFlowNode for Tuple | a tuple |

0 commit comments

Comments
 (0)