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