From 234531b4462b20d668762bd78406fd2ebab129c9 Mon Sep 17 00:00:00 2001 From: Sergey Fedoseev Date: Mon, 25 Feb 2019 21:59:12 +0500 Subject: bpo-36030: Add _PyTuple_FromArray() function (GH-11954) --- Objects/call.c | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) (limited to 'Objects/call.c') diff --git a/Objects/call.c b/Objects/call.c index be8e90d03d..3250f8a10d 100644 --- a/Objects/call.c +++ b/Objects/call.c @@ -1276,20 +1276,7 @@ PyObject_CallFunctionObjArgs(PyObject *callable, ...) _Py_NO_INLINE PyObject * _PyStack_AsTuple(PyObject *const *stack, Py_ssize_t nargs) { - PyObject *args; - Py_ssize_t i; - - args = PyTuple_New(nargs); - if (args == NULL) { - return NULL; - } - - for (i=0; i < nargs; i++) { - PyObject *item = stack[i]; - Py_INCREF(item); - PyTuple_SET_ITEM(args, i, item); - } - return args; + return _PyTuple_FromArray(stack, nargs); } @@ -1297,24 +1284,11 @@ PyObject* _PyStack_AsTupleSlice(PyObject *const *stack, Py_ssize_t nargs, Py_ssize_t start, Py_ssize_t end) { - PyObject *args; - Py_ssize_t i; - assert(0 <= start); assert(end <= nargs); assert(start <= end); - args = PyTuple_New(end - start); - if (args == NULL) { - return NULL; - } - - for (i=start; i < end; i++) { - PyObject *item = stack[i]; - Py_INCREF(item); - PyTuple_SET_ITEM(args, i - start, item); - } - return args; + return _PyTuple_FromArray(stack + start, end - start); } -- cgit v1.2.1