Skip to content

Commit f23021c

Browse files
committed
small fixes
1 parent 9a21b55 commit f23021c

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

Modules/_functoolsmodule.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -482,31 +482,33 @@ partial_vectorcall(partialobject *pto, PyObject *const *args,
482482
return NULL;
483483
}
484484
if (nkwds) {
485-
/* Merge kwds */
486-
PyObject *new_kw = PyDict_Copy(pto->kw);
487-
if (new_kw == NULL) {
485+
/* Merge keywords with pto->kw */
486+
PyObject *tot_kw = PyDict_Copy(pto->kw);
487+
if (tot_kw == NULL) {
488+
Py_DECREF(tot_kwnames);
488489
return NULL;
489490
}
490-
491491
for (Py_ssize_t i=0; i < nkwds; i++) {
492492
key = PyTuple_GET_ITEM(kwnames, i);
493-
if (PyDict_SetItem(new_kw, key, args[nargs + i])) {
494-
Py_DECREF(new_kw);
493+
val = args[nargs + i];
494+
if (PyDict_SetItem(tot_kw, key, val)) {
495+
Py_DECREF(tot_kwnames);
496+
Py_DECREF(tot_kw);
495497
return NULL;
496498
}
497499
}
498500

499501
Py_ssize_t pos = 0, i = 0;
500-
while (PyDict_Next(new_kw, &pos, &key, &val)) {
502+
while (PyDict_Next(tot_kw, &pos, &key, &val)) {
501503
PyTuple_SET_ITEM(tot_kwnames, i, key);
502504
Py_INCREF(key);
503505
stack[tot_nargs + i] = val;
504506
i += 1;
505507
}
506-
Py_DECREF(new_kw);
508+
Py_DECREF(tot_kw);
507509
}
508510
else {
509-
/* Set pto->kw only */
511+
/* Call with pto->kw only */
510512
Py_ssize_t pos = 0, i = 0;
511513
while (PyDict_Next(pto->kw, &pos, &key, &val)) {
512514
PyTuple_SET_ITEM(tot_kwnames, i, key);

0 commit comments

Comments
 (0)