Skip to content

Commit 4296ac1

Browse files
committed
Python: Allow CallNode.getArgByName for keyword args after **kwargs
1 parent 3384521 commit 4296ac1

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: minorAnalysis
3+
---
4+
* Changed `CallNode.getArgByName` such that it has results for keyword arguments given after a dictionary unpacking argument, as the `bar=2` argument in `func(foo=1, **kwargs, bar=2)`.

python/ql/lib/semmle/python/Flow.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ class CallNode extends ControlFlowNode {
376376
ControlFlowNode getArgByName(string name) {
377377
exists(Call c, Keyword k |
378378
this.getNode() = c and
379-
k = c.getAKeyword() and
379+
k = c.getANamedArg() and
380380
k.getValue() = result.getNode() and
381381
k.getArg() = name and
382382
result.getBasicBlock().dominates(this.getBasicBlock())

python/ql/test/experimental/dataflow/coverage/argumentPassing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def with_multiple_kw_args(a, b, c):
9494
def test_multiple_kw_args():
9595
with_multiple_kw_args(b=arg2, c=arg3, a=arg1) #$ arg1 arg2 arg3
9696
with_multiple_kw_args(arg1, *(arg2,), arg3) #$ arg1 MISSING: arg2 arg3
97-
with_multiple_kw_args(arg1, **{"c": arg3}, b=arg2) #$ arg1 arg3 func=with_multiple_kw_args MISSING: arg2
97+
with_multiple_kw_args(arg1, **{"c": arg3}, b=arg2) #$ arg1 arg2 arg3 func=with_multiple_kw_args MISSING:
9898
with_multiple_kw_args(**{"b": arg2}, **{"c": arg3}, **{"a": arg1}) #$ arg1 arg2 arg3 func=with_multiple_kw_args
9999

100100

0 commit comments

Comments
 (0)