gh-111489: Remove _PyTuple_FromArray() alias (#139973)

Replace _PyTuple_FromArray() with PyTuple_FromArray().
Remove pycore_tuple.h includes.
This commit is contained in:
Victor Stinner
2025-10-11 22:58:14 +02:00
committed by GitHub
parent 447c7a89fb
commit 166cdaa6fb
23 changed files with 63 additions and 74 deletions

View File

@@ -213,7 +213,7 @@ _PyObject_MakeTpCall(PyThreadState *tstate, PyObject *callable,
return NULL;
}
PyObject *argstuple = _PyTuple_FromArray(args, nargs);
PyObject *argstuple = PyTuple_FromArray(args, nargs);
if (argstuple == NULL) {
return NULL;
}

View File

@@ -313,7 +313,7 @@ method_vectorcall_VARARGS(
if (method_check_args(func, args, nargs, kwnames)) {
return NULL;
}
PyObject *argstuple = _PyTuple_FromArray(args+1, nargs-1);
PyObject *argstuple = PyTuple_FromArray(args+1, nargs-1);
if (argstuple == NULL) {
return NULL;
}
@@ -338,7 +338,7 @@ method_vectorcall_VARARGS_KEYWORDS(
if (method_check_args(func, args, nargs, NULL)) {
return NULL;
}
PyObject *argstuple = _PyTuple_FromArray(args+1, nargs-1);
PyObject *argstuple = PyTuple_FromArray(args+1, nargs-1);
if (argstuple == NULL) {
return NULL;
}

View File

@@ -13,7 +13,6 @@
#include "pycore_modsupport.h" // _PyArg_NoKeywords()
#include "pycore_object.h"
#include "pycore_pyerrors.h" // struct _PyErr_SetRaisedException
#include "pycore_tuple.h" // _PyTuple_FromArray()
#include "osdefs.h" // SEP
#include "clinic/exceptions.c.h"
@@ -119,7 +118,7 @@ BaseException_vectorcall(PyObject *type_obj, PyObject * const*args,
self->context = NULL;
self->suppress_context = 0;
self->args = _PyTuple_FromArray(args, PyVectorcall_NARGS(nargsf));
self->args = PyTuple_FromArray(args, PyVectorcall_NARGS(nargsf));
if (!self->args) {
Py_DECREF(self);
return NULL;

View File

@@ -6,16 +6,16 @@
#include "pycore_critical_section.h" // _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED()
#include "pycore_dict.h" // _PyDictViewObject
#include "pycore_freelist.h" // _Py_FREELIST_FREE(), _Py_FREELIST_POP()
#include "pycore_pyatomic_ft_wrappers.h"
#include "pycore_interp.h" // PyInterpreterState.list
#include "pycore_list.h" // struct _Py_list_freelist, _PyListIterObject
#include "pycore_long.h" // _PyLong_DigitCount
#include "pycore_modsupport.h" // _PyArg_NoKwnames()
#include "pycore_object.h" // _PyObject_GC_TRACK(), _PyDebugAllocatorStats()
#include "pycore_stackref.h" // _Py_TryIncrefCompareStackRef()
#include "pycore_tuple.h" // _PyTuple_FromArray()
#include "pycore_typeobject.h" // _Py_TYPE_VERSION_LIST
#include "pycore_pyatomic_ft_wrappers.h"
#include "pycore_setobject.h" // _PySet_NextEntry()
#include "pycore_stackref.h" // _Py_TryIncrefCompareStackRef()
#include "pycore_tuple.h" // _PyTuple_FromArraySteal()
#include "pycore_typeobject.h" // _Py_TYPE_VERSION_LIST
#include <stddef.h>
/*[clinic input]
@@ -3221,7 +3221,7 @@ PyList_AsTuple(PyObject *v)
PyObject *ret;
PyListObject *self = (PyListObject *)v;
Py_BEGIN_CRITICAL_SECTION(self);
ret = _PyTuple_FromArray(self->ob_item, Py_SIZE(v));
ret = PyTuple_FromArray(self->ob_item, Py_SIZE(v));
Py_END_CRITICAL_SECTION();
return ret;
}

View File

@@ -12,7 +12,7 @@
#include "pycore_modsupport.h" // _PyArg_NoPositional()
#include "pycore_object.h" // _PyObject_GC_TRACK()
#include "pycore_structseq.h" // PyStructSequence_InitType()
#include "pycore_tuple.h" // _PyTuple_FromArray()
#include "pycore_tuple.h" // _PyTuple_RESET_HASH_CACHE()
#include "pycore_typeobject.h" // _PyStaticType_FiniBuiltin()
static const char visible_length_key[] = "n_sequence_fields";
@@ -353,7 +353,7 @@ structseq_reduce(PyObject *op, PyObject *Py_UNUSED(ignored))
if (n_unnamed_fields < 0) {
return NULL;
}
tup = _PyTuple_FromArray(self->ob_item, n_visible_fields);
tup = PyTuple_FromArray(self->ob_item, n_visible_fields);
if (!tup)
goto error;

View File

@@ -438,7 +438,7 @@ tuple_slice(PyTupleObject *a, Py_ssize_t ilow,
if (ilow == 0 && ihigh == Py_SIZE(a) && PyTuple_CheckExact(a)) {
return Py_NewRef(a);
}
return _PyTuple_FromArray(a->ob_item + ilow, ihigh - ilow);
return PyTuple_FromArray(a->ob_item + ilow, ihigh - ilow);
}
PyObject *

View File

@@ -56,7 +56,6 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "pycore_pyhash.h" // _Py_HashSecret_t
#include "pycore_pylifecycle.h" // _Py_SetFileSystemEncoding()
#include "pycore_pystate.h" // _PyInterpreterState_GET()
#include "pycore_tuple.h" // _PyTuple_FromArray()
#include "pycore_ucnhash.h" // _PyUnicode_Name_CAPI
#include "pycore_unicodeobject.h" // struct _Py_unicode_state
#include "pycore_unicodeobject_generated.h" // _PyUnicode_InitStaticStrings()
@@ -14494,7 +14493,7 @@ unicode_vectorcall(PyObject *type, PyObject *const *args,
Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
if (kwnames != NULL && PyTuple_GET_SIZE(kwnames) != 0) {
// Fallback to unicode_new()
PyObject *tuple = _PyTuple_FromArray(args, nargs);
PyObject *tuple = PyTuple_FromArray(args, nargs);
if (tuple == NULL) {
return NULL;
}