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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 63 additions and 74 deletions

View file

@ -23,9 +23,6 @@ extern PyStatus _PyTuple_InitGlobalObjects(PyInterpreterState *);
#define _PyTuple_ITEMS(op) _Py_RVALUE(_PyTuple_CAST(op)->ob_item) #define _PyTuple_ITEMS(op) _Py_RVALUE(_PyTuple_CAST(op)->ob_item)
// Alias for backward compatibility
#define _PyTuple_FromArray PyTuple_FromArray
PyAPI_FUNC(PyObject *)_PyTuple_FromStackRefStealOnSuccess(const union _PyStackRef *, Py_ssize_t); PyAPI_FUNC(PyObject *)_PyTuple_FromStackRefStealOnSuccess(const union _PyStackRef *, Py_ssize_t);
PyAPI_FUNC(PyObject *)_PyTuple_FromArraySteal(PyObject *const *, Py_ssize_t); PyAPI_FUNC(PyObject *)_PyTuple_FromArraySteal(PyObject *const *, Py_ssize_t);

View file

@ -4341,7 +4341,7 @@ test_vararg_and_posonly(PyObject *module, PyObject *const *args, Py_ssize_t narg
goto exit; goto exit;
} }
a = args[0]; a = args[0];
__clinic_args = _PyTuple_FromArray(args + 1, nargs - 1); __clinic_args = PyTuple_FromArray(args + 1, nargs - 1);
if (__clinic_args == NULL) { if (__clinic_args == NULL) {
goto exit; goto exit;
} }
@ -4356,7 +4356,7 @@ test_vararg_and_posonly(PyObject *module, PyObject *const *args, Py_ssize_t narg
static PyObject * static PyObject *
test_vararg_and_posonly_impl(PyObject *module, PyObject *a, PyObject *args) test_vararg_and_posonly_impl(PyObject *module, PyObject *a, PyObject *args)
/*[clinic end generated code: output=0c11c475e240869e input=2c49a482f68545c0]*/ /*[clinic end generated code: output=83cbe9554d04add2 input=2c49a482f68545c0]*/
/*[clinic input] /*[clinic input]
test_vararg test_vararg
@ -4421,7 +4421,7 @@ test_vararg(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject
} }
a = fastargs[0]; a = fastargs[0];
__clinic_args = nargs > 1 __clinic_args = nargs > 1
? _PyTuple_FromArray(args + 1, nargs - 1) ? PyTuple_FromArray(args + 1, nargs - 1)
: PyTuple_New(0); : PyTuple_New(0);
if (__clinic_args == NULL) { if (__clinic_args == NULL) {
goto exit; goto exit;
@ -4437,7 +4437,7 @@ test_vararg(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject
static PyObject * static PyObject *
test_vararg_impl(PyObject *module, PyObject *a, PyObject *args) test_vararg_impl(PyObject *module, PyObject *a, PyObject *args)
/*[clinic end generated code: output=17ba625cdd0369c1 input=7448995636d9186a]*/ /*[clinic end generated code: output=d773f7b54e61f73a input=7448995636d9186a]*/
/*[clinic input] /*[clinic input]
test_vararg_with_default test_vararg_with_default
@ -4514,7 +4514,7 @@ test_vararg_with_default(PyObject *module, PyObject *const *args, Py_ssize_t nar
} }
skip_optional_kwonly: skip_optional_kwonly:
__clinic_args = nargs > 1 __clinic_args = nargs > 1
? _PyTuple_FromArray(args + 1, nargs - 1) ? PyTuple_FromArray(args + 1, nargs - 1)
: PyTuple_New(0); : PyTuple_New(0);
if (__clinic_args == NULL) { if (__clinic_args == NULL) {
goto exit; goto exit;
@ -4531,7 +4531,7 @@ test_vararg_with_default(PyObject *module, PyObject *const *args, Py_ssize_t nar
static PyObject * static PyObject *
test_vararg_with_default_impl(PyObject *module, PyObject *a, PyObject *args, test_vararg_with_default_impl(PyObject *module, PyObject *a, PyObject *args,
int b) int b)
/*[clinic end generated code: output=3f2b06ab08d5d0be input=3a0f9f557ce1f712]*/ /*[clinic end generated code: output=d25e56802c197344 input=3a0f9f557ce1f712]*/
/*[clinic input] /*[clinic input]
test_vararg_with_only_defaults test_vararg_with_only_defaults
@ -4612,7 +4612,7 @@ test_vararg_with_only_defaults(PyObject *module, PyObject *const *args, Py_ssize
} }
c = fastargs[1]; c = fastargs[1];
skip_optional_kwonly: skip_optional_kwonly:
__clinic_args = _PyTuple_FromArray(args, nargs); __clinic_args = PyTuple_FromArray(args, nargs);
if (__clinic_args == NULL) { if (__clinic_args == NULL) {
goto exit; goto exit;
} }
@ -4628,7 +4628,7 @@ test_vararg_with_only_defaults(PyObject *module, PyObject *const *args, Py_ssize
static PyObject * static PyObject *
test_vararg_with_only_defaults_impl(PyObject *module, PyObject *args, int b, test_vararg_with_only_defaults_impl(PyObject *module, PyObject *args, int b,
PyObject *c) PyObject *c)
/*[clinic end generated code: output=f46666f0b1bf86b9 input=6983e66817f82924]*/ /*[clinic end generated code: output=7366943a7df42e05 input=6983e66817f82924]*/
/*[clinic input] /*[clinic input]
test_paramname_module test_paramname_module

View file

@ -63,7 +63,7 @@ pack_arguments_2pos_varpos(PyObject *a, PyObject *b,
PyObject * const *args, Py_ssize_t args_length) PyObject * const *args, Py_ssize_t args_length)
/*[clinic end generated code: output=267032f41bd039cc input=86ee3064b7853e86]*/ /*[clinic end generated code: output=267032f41bd039cc input=86ee3064b7853e86]*/
{ {
PyObject *tuple = _PyTuple_FromArray(args, args_length); PyObject *tuple = PyTuple_FromArray(args, args_length);
if (tuple == NULL) { if (tuple == NULL) {
return NULL; return NULL;
} }
@ -1174,7 +1174,7 @@ varpos_array_impl(PyObject *module, PyObject * const *args,
Py_ssize_t args_length) Py_ssize_t args_length)
/*[clinic end generated code: output=a25f42f39c9b13ad input=97b8bdcf87e019c7]*/ /*[clinic end generated code: output=a25f42f39c9b13ad input=97b8bdcf87e019c7]*/
{ {
return _PyTuple_FromArray(args, args_length); return PyTuple_FromArray(args, args_length);
} }
@ -1610,7 +1610,7 @@ _testclinic_TestClass_varpos_array_no_fastcall_impl(PyTypeObject *type,
Py_ssize_t args_length) Py_ssize_t args_length)
/*[clinic end generated code: output=27c9da663e942617 input=9ba5ae1f1eb58777]*/ /*[clinic end generated code: output=27c9da663e942617 input=9ba5ae1f1eb58777]*/
{ {
return _PyTuple_FromArray(args, args_length); return PyTuple_FromArray(args, args_length);
} }

View file

@ -9,7 +9,7 @@ preserve
#include "pycore_long.h" // _PyLong_UnsignedShort_Converter() #include "pycore_long.h" // _PyLong_UnsignedShort_Converter()
#include "pycore_modsupport.h" // _PyArg_CheckPositional() #include "pycore_modsupport.h" // _PyArg_CheckPositional()
#include "pycore_runtime.h" // _Py_ID() #include "pycore_runtime.h" // _Py_ID()
#include "pycore_tuple.h" // _PyTuple_FromArray() #include "pycore_tuple.h" // _PyTuple_ITEMS()
PyDoc_STRVAR(test_empty_function__doc__, PyDoc_STRVAR(test_empty_function__doc__,
"test_empty_function($module, /)\n" "test_empty_function($module, /)\n"
@ -2764,7 +2764,7 @@ varpos(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL; PyObject *return_value = NULL;
PyObject *__clinic_args = NULL; PyObject *__clinic_args = NULL;
__clinic_args = _PyTuple_FromArray(args, nargs); __clinic_args = PyTuple_FromArray(args, nargs);
if (__clinic_args == NULL) { if (__clinic_args == NULL) {
goto exit; goto exit;
} }
@ -2802,7 +2802,7 @@ posonly_varpos(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
} }
a = args[0]; a = args[0];
b = args[1]; b = args[1];
__clinic_args = _PyTuple_FromArray(args + 2, nargs - 2); __clinic_args = PyTuple_FromArray(args + 2, nargs - 2);
if (__clinic_args == NULL) { if (__clinic_args == NULL) {
goto exit; goto exit;
} }
@ -2845,7 +2845,7 @@ posonly_req_opt_varpos(PyObject *module, PyObject *const *args, Py_ssize_t nargs
b = args[1]; b = args[1];
skip_optional: skip_optional:
__clinic_args = nargs > 2 __clinic_args = nargs > 2
? _PyTuple_FromArray(args + 2, nargs - 2) ? PyTuple_FromArray(args + 2, nargs - 2)
: PyTuple_New(0); : PyTuple_New(0);
if (__clinic_args == NULL) { if (__clinic_args == NULL) {
goto exit; goto exit;
@ -2916,7 +2916,7 @@ posonly_poskw_varpos(PyObject *module, PyObject *const *args, Py_ssize_t nargs,
a = fastargs[0]; a = fastargs[0];
b = fastargs[1]; b = fastargs[1];
__clinic_args = nargs > 2 __clinic_args = nargs > 2
? _PyTuple_FromArray(args + 2, nargs - 2) ? PyTuple_FromArray(args + 2, nargs - 2)
: PyTuple_New(0); : PyTuple_New(0);
if (__clinic_args == NULL) { if (__clinic_args == NULL) {
goto exit; goto exit;
@ -2984,7 +2984,7 @@ poskw_varpos(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject
} }
a = fastargs[0]; a = fastargs[0];
__clinic_args = nargs > 1 __clinic_args = nargs > 1
? _PyTuple_FromArray(args + 1, nargs - 1) ? PyTuple_FromArray(args + 1, nargs - 1)
: PyTuple_New(0); : PyTuple_New(0);
if (__clinic_args == NULL) { if (__clinic_args == NULL) {
goto exit; goto exit;
@ -3063,7 +3063,7 @@ poskw_varpos_kwonly_opt(PyObject *module, PyObject *const *args, Py_ssize_t narg
} }
skip_optional_kwonly: skip_optional_kwonly:
__clinic_args = nargs > 1 __clinic_args = nargs > 1
? _PyTuple_FromArray(args + 1, nargs - 1) ? PyTuple_FromArray(args + 1, nargs - 1)
: PyTuple_New(0); : PyTuple_New(0);
if (__clinic_args == NULL) { if (__clinic_args == NULL) {
goto exit; goto exit;
@ -3146,7 +3146,7 @@ poskw_varpos_kwonly_opt2(PyObject *module, PyObject *const *args, Py_ssize_t nar
c = fastargs[2]; c = fastargs[2];
skip_optional_kwonly: skip_optional_kwonly:
__clinic_args = nargs > 1 __clinic_args = nargs > 1
? _PyTuple_FromArray(args + 1, nargs - 1) ? PyTuple_FromArray(args + 1, nargs - 1)
: PyTuple_New(0); : PyTuple_New(0);
if (__clinic_args == NULL) { if (__clinic_args == NULL) {
goto exit; goto exit;
@ -3218,7 +3218,7 @@ varpos_kwonly_opt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyO
} }
b = fastargs[0]; b = fastargs[0];
skip_optional_kwonly: skip_optional_kwonly:
__clinic_args = _PyTuple_FromArray(args, nargs); __clinic_args = PyTuple_FromArray(args, nargs);
if (__clinic_args == NULL) { if (__clinic_args == NULL) {
goto exit; goto exit;
} }
@ -3299,7 +3299,7 @@ varpos_kwonly_req_opt(PyObject *module, PyObject *const *args, Py_ssize_t nargs,
} }
c = fastargs[2]; c = fastargs[2];
skip_optional_kwonly: skip_optional_kwonly:
__clinic_args = _PyTuple_FromArray(args, nargs); __clinic_args = PyTuple_FromArray(args, nargs);
if (__clinic_args == NULL) { if (__clinic_args == NULL) {
goto exit; goto exit;
} }
@ -3549,7 +3549,7 @@ gh_32092_oob(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject
kw2 = fastargs[3]; kw2 = fastargs[3];
skip_optional_kwonly: skip_optional_kwonly:
varargs = nargs > 2 varargs = nargs > 2
? _PyTuple_FromArray(args + 2, nargs - 2) ? PyTuple_FromArray(args + 2, nargs - 2)
: PyTuple_New(0); : PyTuple_New(0);
if (varargs == NULL) { if (varargs == NULL) {
goto exit; goto exit;
@ -3626,7 +3626,7 @@ gh_32092_kw_pass(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyOb
kw = fastargs[1]; kw = fastargs[1];
skip_optional_kwonly: skip_optional_kwonly:
__clinic_args = nargs > 1 __clinic_args = nargs > 1
? _PyTuple_FromArray(args + 1, nargs - 1) ? PyTuple_FromArray(args + 1, nargs - 1)
: PyTuple_New(0); : PyTuple_New(0);
if (__clinic_args == NULL) { if (__clinic_args == NULL) {
goto exit; goto exit;
@ -3658,7 +3658,7 @@ gh_99233_refcount(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL; PyObject *return_value = NULL;
PyObject *__clinic_args = NULL; PyObject *__clinic_args = NULL;
__clinic_args = _PyTuple_FromArray(args, nargs); __clinic_args = PyTuple_FromArray(args, nargs);
if (__clinic_args == NULL) { if (__clinic_args == NULL) {
goto exit; goto exit;
} }
@ -3771,7 +3771,7 @@ null_or_tuple_for_varargs(PyObject *module, PyObject *const *args, Py_ssize_t na
} }
skip_optional_kwonly: skip_optional_kwonly:
constraints = nargs > 1 constraints = nargs > 1
? _PyTuple_FromArray(args + 1, nargs - 1) ? PyTuple_FromArray(args + 1, nargs - 1)
: PyTuple_New(0); : PyTuple_New(0);
if (constraints == NULL) { if (constraints == NULL) {
goto exit; goto exit;
@ -4174,7 +4174,7 @@ _testclinic_TestClass_defclass_varpos(PyObject *self, PyTypeObject *cls, PyObjec
if (!fastargs) { if (!fastargs) {
goto exit; goto exit;
} }
__clinic_args = _PyTuple_FromArray(args, nargs); __clinic_args = PyTuple_FromArray(args, nargs);
if (__clinic_args == NULL) { if (__clinic_args == NULL) {
goto exit; goto exit;
} }
@ -4231,7 +4231,7 @@ _testclinic_TestClass_defclass_posonly_varpos(PyObject *self, PyTypeObject *cls,
} }
a = fastargs[0]; a = fastargs[0];
b = fastargs[1]; b = fastargs[1];
__clinic_args = _PyTuple_FromArray(args + 2, nargs - 2); __clinic_args = PyTuple_FromArray(args + 2, nargs - 2);
if (__clinic_args == NULL) { if (__clinic_args == NULL) {
goto exit; goto exit;
} }
@ -4600,4 +4600,4 @@ _testclinic_TestClass_posonly_poskw_varpos_array_no_fastcall(PyObject *type, PyO
exit: exit:
return return_value; return return_value;
} }
/*[clinic end generated code: output=0764e6f8c9d94057 input=a9049054013a1b77]*/ /*[clinic end generated code: output=290d2e346ea7bfa1 input=a9049054013a1b77]*/

View file

@ -9,7 +9,7 @@ preserve
#include "pycore_long.h" // _PyLong_UnsignedShort_Converter() #include "pycore_long.h" // _PyLong_UnsignedShort_Converter()
#include "pycore_modsupport.h" // _PyArg_CheckPositional() #include "pycore_modsupport.h" // _PyArg_CheckPositional()
#include "pycore_runtime.h" // _Py_ID() #include "pycore_runtime.h" // _Py_ID()
#include "pycore_tuple.h" // _PyTuple_FromArray() #include "pycore_tuple.h" // _PyTuple_ITEMS()
PyDoc_STRVAR(depr_star_new__doc__, PyDoc_STRVAR(depr_star_new__doc__,
"DeprStarNew(a=None)\n" "DeprStarNew(a=None)\n"
@ -2474,4 +2474,4 @@ depr_multi(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *
exit: exit:
return return_value; return return_value;
} }
/*[clinic end generated code: output=4e60af44fd6b7b94 input=a9049054013a1b77]*/ /*[clinic end generated code: output=2231bec0ed196830 input=a9049054013a1b77]*/

View file

@ -9,7 +9,7 @@ preserve
#include "pycore_long.h" // _PyLong_UnsignedShort_Converter() #include "pycore_long.h" // _PyLong_UnsignedShort_Converter()
#include "pycore_modsupport.h" // _PyArg_CheckPositional() #include "pycore_modsupport.h" // _PyArg_CheckPositional()
#include "pycore_runtime.h" // _Py_ID() #include "pycore_runtime.h" // _Py_ID()
#include "pycore_tuple.h" // _PyTuple_FromArray() #include "pycore_tuple.h" // _PyTuple_ITEMS()
PyDoc_STRVAR(lone_kwds__doc__, PyDoc_STRVAR(lone_kwds__doc__,
"lone_kwds($module, /, **kwds)\n" "lone_kwds($module, /, **kwds)\n"
@ -181,4 +181,4 @@ exit:
return return_value; return return_value;
} }
/*[clinic end generated code: output=e4dea1070e003f5d input=a9049054013a1b77]*/ /*[clinic end generated code: output=3e5251b10aa44382 input=a9049054013a1b77]*/

View file

@ -8,7 +8,6 @@ preserve
#endif #endif
#include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t() #include "pycore_abstract.h" // _Py_convert_optional_to_ssize_t()
#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
#include "pycore_tuple.h" // _PyTuple_FromArray()
PyDoc_STRVAR(gc_enable__doc__, PyDoc_STRVAR(gc_enable__doc__,
"enable($module, /)\n" "enable($module, /)\n"
@ -324,7 +323,7 @@ gc_get_referrers(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL; PyObject *return_value = NULL;
PyObject *objs = NULL; PyObject *objs = NULL;
objs = _PyTuple_FromArray(args, nargs); objs = PyTuple_FromArray(args, nargs);
if (objs == NULL) { if (objs == NULL) {
goto exit; goto exit;
} }
@ -355,7 +354,7 @@ gc_get_referents(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyObject *return_value = NULL; PyObject *return_value = NULL;
PyObject *objs = NULL; PyObject *objs = NULL;
objs = _PyTuple_FromArray(args, nargs); objs = PyTuple_FromArray(args, nargs);
if (objs == NULL) { if (objs == NULL) {
goto exit; goto exit;
} }
@ -584,4 +583,4 @@ gc_get_freeze_count(PyObject *module, PyObject *Py_UNUSED(ignored))
exit: exit:
return return_value; return return_value;
} }
/*[clinic end generated code: output=96d057eac558e6ca input=a9049054013a1b77]*/ /*[clinic end generated code: output=19738854607938db input=a9049054013a1b77]*/

View file

@ -8,7 +8,6 @@
#include "pycore_gc.h" #include "pycore_gc.h"
#include "pycore_object.h" // _PyObject_IS_GC() #include "pycore_object.h" // _PyObject_IS_GC()
#include "pycore_pystate.h" // _PyInterpreterState_GET() #include "pycore_pystate.h" // _PyInterpreterState_GET()
#include "pycore_tuple.h" // _PyTuple_FromArray()
typedef struct _gc_runtime_state GCState; typedef struct _gc_runtime_state GCState;

View file

@ -2131,7 +2131,7 @@ product_next_lock_held(PyObject *op)
/* Copy the previous result tuple or re-use it if available */ /* Copy the previous result tuple or re-use it if available */
if (Py_REFCNT(result) > 1) { if (Py_REFCNT(result) > 1) {
PyObject *old_result = result; PyObject *old_result = result;
result = _PyTuple_FromArray(_PyTuple_ITEMS(old_result), npools); result = PyTuple_FromArray(_PyTuple_ITEMS(old_result), npools);
if (result == NULL) if (result == NULL)
goto empty; goto empty;
lz->result = result; lz->result = result;
@ -2366,7 +2366,7 @@ combinations_next_lock_held(PyObject *op)
/* Copy the previous result tuple or re-use it if available */ /* Copy the previous result tuple or re-use it if available */
if (Py_REFCNT(result) > 1) { if (Py_REFCNT(result) > 1) {
PyObject *old_result = result; PyObject *old_result = result;
result = _PyTuple_FromArray(_PyTuple_ITEMS(old_result), r); result = PyTuple_FromArray(_PyTuple_ITEMS(old_result), r);
if (result == NULL) if (result == NULL)
goto empty; goto empty;
co->result = result; co->result = result;
@ -2620,7 +2620,7 @@ cwr_next(PyObject *op)
/* Copy the previous result tuple or re-use it if available */ /* Copy the previous result tuple or re-use it if available */
if (Py_REFCNT(result) > 1) { if (Py_REFCNT(result) > 1) {
PyObject *old_result = result; PyObject *old_result = result;
result = _PyTuple_FromArray(_PyTuple_ITEMS(old_result), r); result = PyTuple_FromArray(_PyTuple_ITEMS(old_result), r);
if (result == NULL) if (result == NULL)
goto empty; goto empty;
co->result = result; co->result = result;
@ -2881,7 +2881,7 @@ permutations_next(PyObject *op)
/* Copy the previous result tuple or re-use it if available */ /* Copy the previous result tuple or re-use it if available */
if (Py_REFCNT(result) > 1) { if (Py_REFCNT(result) > 1) {
PyObject *old_result = result; PyObject *old_result = result;
result = _PyTuple_FromArray(_PyTuple_ITEMS(old_result), r); result = PyTuple_FromArray(_PyTuple_ITEMS(old_result), r);
if (result == NULL) if (result == NULL)
goto empty; goto empty;
po->result = result; po->result = result;

View file

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

View file

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

View file

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

View file

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

View file

@ -12,7 +12,7 @@
#include "pycore_modsupport.h" // _PyArg_NoPositional() #include "pycore_modsupport.h" // _PyArg_NoPositional()
#include "pycore_object.h" // _PyObject_GC_TRACK() #include "pycore_object.h" // _PyObject_GC_TRACK()
#include "pycore_structseq.h" // PyStructSequence_InitType() #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() #include "pycore_typeobject.h" // _PyStaticType_FiniBuiltin()
static const char visible_length_key[] = "n_sequence_fields"; 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) { if (n_unnamed_fields < 0) {
return NULL; return NULL;
} }
tup = _PyTuple_FromArray(self->ob_item, n_visible_fields); tup = PyTuple_FromArray(self->ob_item, n_visible_fields);
if (!tup) if (!tup)
goto error; 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)) { if (ilow == 0 && ihigh == Py_SIZE(a) && PyTuple_CheckExact(a)) {
return Py_NewRef(a); return Py_NewRef(a);
} }
return _PyTuple_FromArray(a->ob_item + ilow, ihigh - ilow); return PyTuple_FromArray(a->ob_item + ilow, ihigh - ilow);
} }
PyObject * 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_pyhash.h" // _Py_HashSecret_t
#include "pycore_pylifecycle.h" // _Py_SetFileSystemEncoding() #include "pycore_pylifecycle.h" // _Py_SetFileSystemEncoding()
#include "pycore_pystate.h" // _PyInterpreterState_GET() #include "pycore_pystate.h" // _PyInterpreterState_GET()
#include "pycore_tuple.h" // _PyTuple_FromArray()
#include "pycore_ucnhash.h" // _PyUnicode_Name_CAPI #include "pycore_ucnhash.h" // _PyUnicode_Name_CAPI
#include "pycore_unicodeobject.h" // struct _Py_unicode_state #include "pycore_unicodeobject.h" // struct _Py_unicode_state
#include "pycore_unicodeobject_generated.h" // _PyUnicode_InitStaticStrings() #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); Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
if (kwnames != NULL && PyTuple_GET_SIZE(kwnames) != 0) { if (kwnames != NULL && PyTuple_GET_SIZE(kwnames) != 0) {
// Fallback to unicode_new() // Fallback to unicode_new()
PyObject *tuple = _PyTuple_FromArray(args, nargs); PyObject *tuple = PyTuple_FromArray(args, nargs);
if (tuple == NULL) { if (tuple == NULL) {
return NULL; return NULL;
} }

View file

@ -3,6 +3,7 @@
#include "Python.h" #include "Python.h"
#include "pycore_ast.h" // _PyAST_Validate() #include "pycore_ast.h" // _PyAST_Validate()
#include "pycore_call.h" // _PyObject_CallNoArgs() #include "pycore_call.h" // _PyObject_CallNoArgs()
#include "pycore_cell.h" // PyCell_GetRef()
#include "pycore_ceval.h" // _PyEval_Vector() #include "pycore_ceval.h" // _PyEval_Vector()
#include "pycore_compile.h" // _PyAST_Compile() #include "pycore_compile.h" // _PyAST_Compile()
#include "pycore_fileutils.h" // _PyFile_Flush #include "pycore_fileutils.h" // _PyFile_Flush
@ -14,8 +15,7 @@
#include "pycore_pyerrors.h" // _PyErr_NoMemory() #include "pycore_pyerrors.h" // _PyErr_NoMemory()
#include "pycore_pystate.h" // _PyThreadState_GET() #include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_pythonrun.h" // _Py_SourceAsString() #include "pycore_pythonrun.h" // _Py_SourceAsString()
#include "pycore_tuple.h" // _PyTuple_FromArray() #include "pycore_tuple.h" // _PyTuple_Recycle()
#include "pycore_cell.h" // PyCell_GetRef()
#include "clinic/bltinmodule.c.h" #include "clinic/bltinmodule.c.h"
@ -123,7 +123,7 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs,
"__build_class__: name is not a string"); "__build_class__: name is not a string");
return NULL; return NULL;
} }
orig_bases = _PyTuple_FromArray(args + 2, nargs - 2); orig_bases = PyTuple_FromArray(args + 2, nargs - 2);
if (orig_bases == NULL) if (orig_bases == NULL)
return NULL; return NULL;

View file

@ -2011,7 +2011,7 @@ PyEval_EvalCodeEx(PyObject *_co, PyObject *globals, PyObject *locals,
{ {
PyThreadState *tstate = _PyThreadState_GET(); PyThreadState *tstate = _PyThreadState_GET();
PyObject *res = NULL; PyObject *res = NULL;
PyObject *defaults = _PyTuple_FromArray(defs, defcount); PyObject *defaults = PyTuple_FromArray(defs, defcount);
if (defaults == NULL) { if (defaults == NULL) {
return NULL; return NULL;
} }

View file

@ -7,7 +7,6 @@ preserve
# include "pycore_runtime.h" // _Py_ID() # include "pycore_runtime.h" // _Py_ID()
#endif #endif
#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
#include "pycore_tuple.h" // _PyTuple_FromArray()
PyDoc_STRVAR(sys_addaudithook__doc__, PyDoc_STRVAR(sys_addaudithook__doc__,
"addaudithook($module, /, hook)\n" "addaudithook($module, /, hook)\n"
@ -102,7 +101,7 @@ sys_audit(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
PyErr_SetString(PyExc_ValueError, "embedded null character"); PyErr_SetString(PyExc_ValueError, "embedded null character");
goto exit; goto exit;
} }
__clinic_args = _PyTuple_FromArray(args + 1, nargs - 1); __clinic_args = PyTuple_FromArray(args + 1, nargs - 1);
if (__clinic_args == NULL) { if (__clinic_args == NULL) {
goto exit; goto exit;
} }
@ -1948,4 +1947,4 @@ exit:
#ifndef SYS_GETANDROIDAPILEVEL_METHODDEF #ifndef SYS_GETANDROIDAPILEVEL_METHODDEF
#define SYS_GETANDROIDAPILEVEL_METHODDEF #define SYS_GETANDROIDAPILEVEL_METHODDEF
#endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */ #endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */
/*[clinic end generated code: output=449d16326e69dcf6 input=a9049054013a1b77]*/ /*[clinic end generated code: output=5f7d84c5bf00d557 input=a9049054013a1b77]*/

View file

@ -9,7 +9,6 @@
#include "pycore_intrinsics.h" // INTRINSIC_PRINT #include "pycore_intrinsics.h" // INTRINSIC_PRINT
#include "pycore_pyerrors.h" // _PyErr_SetString() #include "pycore_pyerrors.h" // _PyErr_SetString()
#include "pycore_runtime.h" // _Py_ID() #include "pycore_runtime.h" // _Py_ID()
#include "pycore_tuple.h" // _PyTuple_FromArray()
#include "pycore_typevarobject.h" // _Py_make_typevar() #include "pycore_typevarobject.h" // _Py_make_typevar()
#include "pycore_unicodeobject.h" // _PyUnicode_FromASCII() #include "pycore_unicodeobject.h" // _PyUnicode_FromASCII()
@ -192,7 +191,7 @@ static PyObject *
list_to_tuple(PyThreadState* unused, PyObject *v) list_to_tuple(PyThreadState* unused, PyObject *v)
{ {
assert(PyList_Check(v)); assert(PyList_Check(v));
return _PyTuple_FromArray(((PyListObject *)v)->ob_item, Py_SIZE(v)); return PyTuple_FromArray(((PyListObject *)v)->ob_item, Py_SIZE(v));
} }
static PyObject * static PyObject *

View file

@ -7,7 +7,6 @@
#include "pycore_long.h" #include "pycore_long.h"
#include "pycore_optimizer.h" #include "pycore_optimizer.h"
#include "pycore_stats.h" #include "pycore_stats.h"
#include "pycore_tuple.h" // _PyTuple_FromArray()
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
@ -1044,7 +1043,7 @@ _Py_uop_symbols_test(PyObject *Py_UNUSED(self), PyObject *Py_UNUSED(ignored))
"tuple item does not match value used to create tuple" "tuple item does not match value used to create tuple"
); );
PyObject *pair[2] = { val_42, val_43 }; PyObject *pair[2] = { val_42, val_43 };
tuple = _PyTuple_FromArray(pair, 2); tuple = PyTuple_FromArray(pair, 2);
ref = _Py_uop_sym_new_const(ctx, tuple); ref = _Py_uop_sym_new_const(ctx, tuple);
TEST_PREDICATE( TEST_PREDICATE(
_Py_uop_sym_get_const(ctx, _Py_uop_sym_tuple_getitem(ctx, ref, 1)) == val_43, _Py_uop_sym_get_const(ctx, _Py_uop_sym_tuple_getitem(ctx, ref, 1)) == val_43,

View file

@ -1266,13 +1266,12 @@ def parse_vararg(self, *, pos_only: int, min_pos: int, max_pos: int,
}}}} }}}}
""" """
else: else:
self.add_include('pycore_tuple.h', '_PyTuple_FromArray()')
start = f'args + {max_pos}' if max_pos else 'args' start = f'args + {max_pos}' if max_pos else 'args'
size = f'nargs - {max_pos}' if max_pos else 'nargs' size = f'nargs - {max_pos}' if max_pos else 'nargs'
if min(pos_only, min_pos) < max_pos: if min(pos_only, min_pos) < max_pos:
return f""" return f"""
{paramname} = nargs > {max_pos} {paramname} = nargs > {max_pos}
? _PyTuple_FromArray({start}, {size}) ? PyTuple_FromArray({start}, {size})
: PyTuple_New(0); : PyTuple_New(0);
if ({paramname} == NULL) {{{{ if ({paramname} == NULL) {{{{
goto exit; goto exit;
@ -1280,7 +1279,7 @@ def parse_vararg(self, *, pos_only: int, min_pos: int, max_pos: int,
""" """
else: else:
return f""" return f"""
{paramname} = _PyTuple_FromArray({start}, {size}); {paramname} = PyTuple_FromArray({start}, {size});
if ({paramname} == NULL) {{{{ if ({paramname} == NULL) {{{{
goto exit; goto exit;
}}}} }}}}