10000 Fix bug · python/cpython@a48971d · GitHub
[go: up one dir, main page]

Skip to content

Commit a48971d

Browse files
committed
Fix bug
1 parent 87314ff commit a48971d
10000

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Python/getargs.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2598,7 +2598,25 @@ _PyArg_UnpackKeywordsWithVararg(PyObject *const *args, Py_ssize_t nargs,
25982598
current_arg = NULL;
25992599
}
26002600

2601-
buf[i + 1] = current_arg;
2601+
/* If an arguments is passed in as a keyword argument,
2602+
* it should be placed before `buf[vararg]`.
2603+
*
2604+
* For example:
2605+
* def f(a, /, b, *args):
2606+
* pass
2607+
* f(1, b=2)
2608+
*
2609+
* This `buf` array should be: [1, 2, NULL].
2610+
* In this case, nargs < vararg.
2611+
*
2612+
* Otherwise, we leave a place at `buf[vararg]` for vararg tuple
2613+
* so the index is `i + 1`. */
2614+
if (nargs < vararg) {
2615+
buf[i] = current_arg;
2616+
}
2617+
else {
2618+
buf[i + 1] = current_arg;
2619+
}
26022620

26032621
if (current_arg) {
26042622
--nkwargs;

0 commit comments

Comments
 (0)
0