mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Python: Remove unnecessary restriction from getNamedArgumentForCall
As agreed in https://github.com/github/codeql/pull/3407
This commit is contained in:
@@ -397,7 +397,6 @@ class CallableValue extends Value {
|
||||
|
||||
/**
|
||||
* Gets the argument in `call` corresponding to the `name`d keyword parameter of this callable.
|
||||
* ONLY WORKS FOR NON-BUILTINS.
|
||||
*
|
||||
* This method also gives results when the argument is passed as a positional argument in `call`, as long
|
||||
* as `this` is not a builtin function or a builtin method.
|
||||
@@ -420,8 +419,7 @@ class CallableValue extends Value {
|
||||
PointsToInternal::pointsTo(call.getFunction(), _, called, _) and
|
||||
called.functionAndOffset(this, offset)
|
||||
|
|
||||
call.getArgByName(name) = result and
|
||||
exists(this.getParameterByName(name))
|
||||
call.getArgByName(name) = result
|
||||
or
|
||||
exists(int n |
|
||||
call.getArg(n) = result and
|
||||
|
||||
@@ -23,5 +23,9 @@
|
||||
| 42 | ControlFlowNode for Attribute() | Function C.n | arg1 | ControlFlowNode for IntegerLiteral |
|
||||
| 42 | ControlFlowNode for Attribute() | Function C.n | self | ControlFlowNode for c |
|
||||
| 42 | ControlFlowNode for Attribute() | Method(Function C.n, C()) | arg1 | ControlFlowNode for IntegerLiteral |
|
||||
| 46 | ControlFlowNode for open() | Builtin-function open | file | ControlFlowNode for Str |
|
||||
| 46 | ControlFlowNode for open() | Builtin-function open | mode | ControlFlowNode for Str |
|
||||
| 51 | ControlFlowNode for foo() | Function foo | a | ControlFlowNode for IntegerLiteral |
|
||||
| 55 | ControlFlowNode for bar() | Function bar | a | ControlFlowNode for IntegerLiteral |
|
||||
| 55 | ControlFlowNode for bar() | Function bar | b | ControlFlowNode for IntegerLiteral |
|
||||
| 55 | ControlFlowNode for bar() | Function bar | c | ControlFlowNode for IntegerLiteral |
|
||||
|
||||
@@ -43,7 +43,7 @@ c.n(arg1=1)
|
||||
|
||||
# positional/keyword arguments for a builtin function
|
||||
open("foo.txt", "rb") # TODO: Not handled by getNamedArgumentForCall
|
||||
open(file="foo.txt", mode="rb") # TODO: Not handled by either getNamedArgumentForCall or getArgumentForCall
|
||||
open(file="foo.txt", mode="rb")
|
||||
|
||||
# Testing how arguments to *args and **kwargs are handled
|
||||
def foo(a, *args):
|
||||
@@ -52,4 +52,4 @@ foo(1, 2, 3)
|
||||
|
||||
def bar(a, **kwargs):
|
||||
pass
|
||||
bar(a=1, b=2, c=3) # TODO: no result for `b` or `c` with getNamedArgumentForCall
|
||||
bar(a=1, b=2, c=3)
|
||||
|
||||
Reference in New Issue
Block a user