mirror of https://github.com/python/cpython
gh-118379: Use PyTuple_Pack instead of Py_BuildValue if possible (GH-118381)
This commit is contained in:
parent
17a8af9508
commit
9a75d56d5d
|
@ -4287,7 +4287,7 @@ nm_mpd_qdivmod(PyObject *v, PyObject *w)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
ret = Py_BuildValue("(OO)", q, r);
|
||||
ret = PyTuple_Pack(2, q, r);
|
||||
Py_DECREF(r);
|
||||
Py_DECREF(q);
|
||||
return ret;
|
||||
|
@ -5312,7 +5312,7 @@ ctx_mpd_qdivmod(PyObject *context, PyObject *args)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
ret = Py_BuildValue("(OO)", q, r);
|
||||
ret = PyTuple_Pack(2, q, r);
|
||||
Py_DECREF(r);
|
||||
Py_DECREF(q);
|
||||
return ret;
|
||||
|
|
|
@ -1217,7 +1217,7 @@ init_ndbuf(PyObject *items, PyObject *shape, PyObject *strides,
|
|||
|
||||
/* convert scalar to list */
|
||||
if (ndim == 0) {
|
||||
items = Py_BuildValue("(O)", items);
|
||||
items = PyTuple_Pack(1, items);
|
||||
if (items == NULL)
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -2475,7 +2475,7 @@ get_basic_static_type(PyObject *self, PyObject *args)
|
|||
PyTypeObject *cls = &BasicStaticTypes[num_basic_static_types_used++];
|
||||
|
||||
if (base != NULL) {
|
||||
cls->tp_bases = Py_BuildValue("(O)", base);
|
||||
cls->tp_bases = PyTuple_Pack(1, base);
|
||||
if (cls->tp_bases == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -3474,7 +3474,7 @@ typedef struct {
|
|||
static PyObject *
|
||||
ipowType_ipow(PyObject *self, PyObject *other, PyObject *mod)
|
||||
{
|
||||
return Py_BuildValue("OO", other, mod);
|
||||
return PyTuple_Pack(2, other, mod);
|
||||
}
|
||||
|
||||
static PyNumberMethods ipowType_as_number = {
|
||||
|
|
|
@ -1243,7 +1243,7 @@ _testclinic_TestClass_get_defining_class_arg_impl(PyObject *self,
|
|||
PyObject *arg)
|
||||
/*[clinic end generated code: output=fe7e49d96cbb7718 input=d1b83d3b853af6d9]*/
|
||||
{
|
||||
return Py_BuildValue("(OO)", cls, arg);
|
||||
return PyTuple_Pack(2, cls, arg);
|
||||
}
|
||||
|
||||
static struct PyMethodDef test_class_methods[] = {
|
||||
|
|
|
@ -5500,7 +5500,7 @@ os__path_splitroot_ex_impl(PyObject *module, PyObject *path)
|
|||
if (tail == NULL) {
|
||||
goto exit;
|
||||
}
|
||||
result = Py_BuildValue("(OOO)", drv, root, tail);
|
||||
result = PyTuple_Pack(3, drv, root, tail);
|
||||
exit:
|
||||
PyMem_Free(buffer);
|
||||
Py_XDECREF(drv);
|
||||
|
|
|
@ -632,8 +632,8 @@ _PyErr_StackItemToExcInfoTuple(_PyErr_StackItem *err_info)
|
|||
PyObject *exc_type = get_exc_type(exc_value);
|
||||
PyObject *exc_traceback = get_exc_traceback(exc_value);
|
||||
|
||||
return Py_BuildValue(
|
||||
"(OOO)",
|
||||
return PyTuple_Pack(
|
||||
3,
|
||||
exc_type ? exc_type : Py_None,
|
||||
exc_value ? exc_value : Py_None,
|
||||
exc_traceback ? exc_traceback : Py_None);
|
||||
|
|
Loading…
Reference in New Issue