mirror of
https://github.com/python/cpython.git
synced 2025-07-19 01:05:26 +00:00
gh-64490: Fix bugs in argument clinic varargs processing (#32092)
This commit is contained in:
parent
351842b46a
commit
0da728387c
11 changed files with 612 additions and 11 deletions
|
@ -2598,7 +2598,25 @@ _PyArg_UnpackKeywordsWithVararg(PyObject *const *args, Py_ssize_t nargs,
|
|||
current_arg = NULL;
|
||||
}
|
||||
|
||||
buf[i + vararg + 1] = current_arg;
|
||||
/* If an arguments is passed in as a keyword argument,
|
||||
* it should be placed before `buf[vararg]`.
|
||||
*
|
||||
* For example:
|
||||
* def f(a, /, b, *args):
|
||||
* pass
|
||||
* f(1, b=2)
|
||||
*
|
||||
* This `buf` array should be: [1, 2, NULL].
|
||||
* In this case, nargs < vararg.
|
||||
*
|
||||
* Otherwise, we leave a place at `buf[vararg]` for vararg tuple
|
||||
* so the index is `i + 1`. */
|
||||
if (nargs < vararg) {
|
||||
buf[i] = current_arg;
|
||||
}
|
||||
else {
|
||||
buf[i + 1] = current_arg;
|
||||
}
|
||||
|
||||
if (current_arg) {
|
||||
--nkwargs;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue