Skip to content

gh-118379: Use PyTuple_Pack #118381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Modules/_decimal/_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Modules/_testbuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions Modules/_testcapimodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion Modules/_testclinic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand Down
2 changes: 1 addition & 1 deletion Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions Python/errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading