Skip to content

Commit 4575b6c

Browse files
committed
minor fixes and improvements
1 parent 00ebb4b commit 4575b6c

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

Modules/_functoolsmodule.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,7 @@ partial_vectorcall(PyObject *self, PyObject *const *args,
433433
/* NOTE, in theory size * elsize could overflow */
434434
stack = PyMem_Malloc(init_stack_size * sizeof(PyObject *));
435435
if (stack == NULL) {
436-
PyErr_NoMemory();
437-
return NULL;
436+
return PyErr_NoMemory();
438437
}
439438
}
440439

@@ -467,7 +466,7 @@ partial_vectorcall(PyObject *self, PyObject *const *args,
467466
}
468467
}
469468
if (PyDict_SetItem(pto_kw_merged, key, val) < 0) {
470-
Py_XDECREF(pto_kw_merged);
469+
Py_DECREF(pto_kw_merged);
471470
if (stack != small_stack) {
472471
PyMem_Free(stack);
473472
}
@@ -486,16 +485,14 @@ partial_vectorcall(PyObject *self, PyObject *const *args,
486485
/* Create tot_kwnames */
487486
tot_kwnames = PyTuple_New(pto_nkwds + n_tail);
488487
for (Py_ssize_t i = 0; i < n_tail; ++i) {
489-
key = stack[tot_nargskw + i];
488+
key = Py_NewRef(stack[tot_nargskw + i]);
490489
PyTuple_SET_ITEM(tot_kwnames, pto_nkwds + i, key);
491-
Py_INCREF(key);
492490
}
493491

494492
/* Copy pto_kw_merged to stack */
495493
Py_ssize_t pos = 0, i = 0;
496494
while (PyDict_Next(n_merges ? pto_kw_merged : pto->kw, &pos, &key, &val)) {
497-
PyTuple_SET_ITEM(tot_kwnames, i, key);
498-
Py_INCREF(key);
495+
PyTuple_SET_ITEM(tot_kwnames, i, Py_NewRef(key));
499496
stack[tot_nargs + i] = val;
500497
i++;
501498
}
@@ -509,8 +506,7 @@ partial_vectorcall(PyObject *self, PyObject *const *args,
509506
if (stack != small_stack) {
510507
PyMem_Free(stack);
511508
}
512-
PyErr_NoMemory();
513-
return NULL;
509+
return PyErr_NoMemory();
514510
}
515511
stack = tmp_stack;
516512
}

0 commit comments

Comments
 (0)