From d7d3981b8261d18601b6d8673ed34ae918614d35 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 10 Aug 2025 17:01:49 +0300 Subject: [PATCH 1/2] gh-137609: Change names of some positional-only parameters in builtins This is to pair with GH-137610. --- Python/bltinmodule.c | 48 +++++++++++++++++------------------ Python/clinic/bltinmodule.c.h | 28 ++++++++++---------- 2 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 51d7297ec243cc..5887efcaf795ec 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -289,17 +289,17 @@ builtin___import___impl(PyObject *module, PyObject *name, PyObject *globals, /*[clinic input] abs as builtin_abs - x: object + number: object / Return the absolute value of the argument. [clinic start generated code]*/ static PyObject * -builtin_abs(PyObject *module, PyObject *x) -/*[clinic end generated code: output=b1b433b9e51356f5 input=bed4ca14e29c20d1]*/ +builtin_abs(PyObject *module, PyObject *number) +/*[clinic end generated code: output=861a9db97dee0595 input=a356196903543505]*/ { - return PyNumber_Absolute(x); + return PyNumber_Absolute(number); } /*[clinic input] @@ -425,7 +425,7 @@ builtin_ascii(PyObject *module, PyObject *obj) /*[clinic input] bin as builtin_bin - number: object + integer: object / Return the binary representation of an integer. @@ -435,10 +435,10 @@ Return the binary representation of an integer. [clinic start generated code]*/ static PyObject * -builtin_bin(PyObject *module, PyObject *number) -/*[clinic end generated code: output=b6fc4ad5e649f4f7 input=53f8a0264bacaf90]*/ +builtin_bin(PyObject *module, PyObject *integer) +/*[clinic end generated code: output=533f9388441805cc input=d16518f148341e70]*/ { - return PyNumber_ToBase(number, 2); + return PyNumber_ToBase(integer, 2); } @@ -1779,7 +1779,7 @@ builtin_hash(PyObject *module, PyObject *obj) /*[clinic input] hex as builtin_hex - number: object + integer: object / Return the hexadecimal representation of an integer. @@ -1789,10 +1789,10 @@ Return the hexadecimal representation of an integer. [clinic start generated code]*/ static PyObject * -builtin_hex(PyObject *module, PyObject *number) -/*[clinic end generated code: output=e46b612169099408 input=e645aff5fc7d540e]*/ +builtin_hex(PyObject *module, PyObject *integer) +/*[clinic end generated code: output=e5de857ba61aae08 input=3bef4746efc62fac]*/ { - return PyNumber_ToBase(number, 16); + return PyNumber_ToBase(integer, 16); } @@ -1846,7 +1846,7 @@ PyObject *PyAnextAwaitable_New(PyObject *, PyObject *); /*[clinic input] anext as builtin_anext - aiterator: object + async_iterator as aiterator: object default: object = NULL / @@ -1859,7 +1859,7 @@ it is returned instead of raising StopAsyncIteration. static PyObject * builtin_anext_impl(PyObject *module, PyObject *aiterator, PyObject *default_value) -/*[clinic end generated code: output=f02c060c163a81fa input=2900e4a370d39550]*/ +/*[clinic end generated code: output=f02c060c163a81fa input=f3dc5a93f073e5ac]*/ { PyTypeObject *t; PyObject *awaitable; @@ -2098,7 +2098,7 @@ With two or more positional arguments, return the largest argument."); /*[clinic input] oct as builtin_oct - number: object + integer: object / Return the octal representation of an integer. @@ -2108,10 +2108,10 @@ Return the octal representation of an integer. [clinic start generated code]*/ static PyObject * -builtin_oct(PyObject *module, PyObject *number) -/*[clinic end generated code: output=40a34656b6875352 input=ad6b274af4016c72]*/ +builtin_oct(PyObject *module, PyObject *integer) +/*[clinic end generated code: output=8c15f2145a74c390 input=b97c377b15fedf8d]*/ { - return PyNumber_ToBase(number, 8); + return PyNumber_ToBase(integer, 8); } @@ -2192,7 +2192,7 @@ builtin_pow_impl(PyObject *module, PyObject *base, PyObject *exp, /*[clinic input] print as builtin_print - *args: array + *objects: array sep: object(c_default="Py_None") = ' ' string inserted between values, default a space. end: object(c_default="Py_None") = '\n' @@ -2207,10 +2207,10 @@ Prints the values to a stream, or to sys.stdout by default. [clinic start generated code]*/ static PyObject * -builtin_print_impl(PyObject *module, PyObject * const *args, - Py_ssize_t args_length, PyObject *sep, PyObject *end, +builtin_print_impl(PyObject *module, PyObject * const *objects, + Py_ssize_t objects_length, PyObject *sep, PyObject *end, PyObject *file, int flush) -/*[clinic end generated code: output=3cb7e5b66f1a8547 input=66ea4de1605a2437]*/ +/*[clinic end generated code: output=38d8def56c837bcc input=ff35cb3d59ee8115]*/ { int i, err; @@ -2251,7 +2251,7 @@ builtin_print_impl(PyObject *module, PyObject * const *args, return NULL; } - for (i = 0; i < args_length; i++) { + for (i = 0; i < objects_length; i++) { if (i > 0) { if (sep == NULL) { err = PyFile_WriteString(" ", file); @@ -2264,7 +2264,7 @@ builtin_print_impl(PyObject *module, PyObject * const *args, return NULL; } } - err = PyFile_WriteObject(args[i], file, Py_PRINT_RAW); + err = PyFile_WriteObject(objects[i], file, Py_PRINT_RAW); if (err) { Py_DECREF(file); return NULL; diff --git a/Python/clinic/bltinmodule.c.h b/Python/clinic/bltinmodule.c.h index c826a5724f769c..f8a7aaf629e7ba 100644 --- a/Python/clinic/bltinmodule.c.h +++ b/Python/clinic/bltinmodule.c.h @@ -114,7 +114,7 @@ builtin___import__(PyObject *module, PyObject *const *args, Py_ssize_t nargs, Py } PyDoc_STRVAR(builtin_abs__doc__, -"abs($module, x, /)\n" +"abs($module, number, /)\n" "--\n" "\n" "Return the absolute value of the argument."); @@ -159,7 +159,7 @@ PyDoc_STRVAR(builtin_ascii__doc__, {"ascii", (PyCFunction)builtin_ascii, METH_O, builtin_ascii__doc__}, PyDoc_STRVAR(builtin_bin__doc__, -"bin($module, number, /)\n" +"bin($module, integer, /)\n" "--\n" "\n" "Return the binary representation of an integer.\n" @@ -729,7 +729,7 @@ PyDoc_STRVAR(builtin_hash__doc__, {"hash", (PyCFunction)builtin_hash, METH_O, builtin_hash__doc__}, PyDoc_STRVAR(builtin_hex__doc__, -"hex($module, number, /)\n" +"hex($module, integer, /)\n" "--\n" "\n" "Return the hexadecimal representation of an integer.\n" @@ -750,7 +750,7 @@ PyDoc_STRVAR(builtin_aiter__doc__, {"aiter", (PyCFunction)builtin_aiter, METH_O, builtin_aiter__doc__}, PyDoc_STRVAR(builtin_anext__doc__, -"anext($module, aiterator, default=, /)\n" +"anext($module, async_iterator, default=, /)\n" "--\n" "\n" "Return the next item from the async iterator.\n" @@ -819,7 +819,7 @@ builtin_locals(PyObject *module, PyObject *Py_UNUSED(ignored)) } PyDoc_STRVAR(builtin_oct__doc__, -"oct($module, number, /)\n" +"oct($module, integer, /)\n" "--\n" "\n" "Return the octal representation of an integer.\n" @@ -911,7 +911,7 @@ builtin_pow(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject } PyDoc_STRVAR(builtin_print__doc__, -"print($module, /, *args, sep=\' \', end=\'\\n\', file=None, flush=False)\n" +"print($module, /, *objects, sep=\' \', end=\'\\n\', file=None, flush=False)\n" "--\n" "\n" "Prints the values to a stream, or to sys.stdout by default.\n" @@ -929,8 +929,8 @@ PyDoc_STRVAR(builtin_print__doc__, {"print", _PyCFunction_CAST(builtin_print), METH_FASTCALL|METH_KEYWORDS, builtin_print__doc__}, static PyObject * -builtin_print_impl(PyObject *module, PyObject * const *args, - Py_ssize_t args_length, PyObject *sep, PyObject *end, +builtin_print_impl(PyObject *module, PyObject * const *objects, + Py_ssize_t objects_length, PyObject *sep, PyObject *end, PyObject *file, int flush); static PyObject * @@ -967,8 +967,8 @@ builtin_print(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec PyObject *argsbuf[4]; PyObject * const *fastargs; Py_ssize_t noptargs = 0 + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; - PyObject * const *__clinic_args; - Py_ssize_t args_length; + PyObject * const *objects; + Py_ssize_t objects_length; PyObject *sep = Py_None; PyObject *end = Py_None; PyObject *file = Py_None; @@ -1005,9 +1005,9 @@ builtin_print(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec goto exit; } skip_optional_kwonly: - __clinic_args = args; - args_length = nargs; - return_value = builtin_print_impl(module, __clinic_args, args_length, sep, end, file, flush); + objects = args; + objects_length = nargs; + return_value = builtin_print_impl(module, objects, objects_length, sep, end, file, flush); exit: return return_value; @@ -1268,4 +1268,4 @@ builtin_issubclass(PyObject *module, PyObject *const *args, Py_ssize_t nargs) exit: return return_value; } -/*[clinic end generated code: output=e7a5d0851d7f2cfb input=a9049054013a1b77]*/ +/*[clinic end generated code: output=3edd98f9caa60782 input=a9049054013a1b77]*/ From a4e0f21f1b03e43bfbdd8a857a6cf1360ebc8966 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 10 Aug 2025 22:18:49 +0300 Subject: [PATCH 2/2] Change the parameter name in reversed(). --- Objects/clinic/enumobject.c.h | 4 ++-- Objects/enumobject.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Objects/clinic/enumobject.c.h b/Objects/clinic/enumobject.c.h index 29ff11e89b9d1d..1bda482f4955ae 100644 --- a/Objects/clinic/enumobject.c.h +++ b/Objects/clinic/enumobject.c.h @@ -82,7 +82,7 @@ enum_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) } PyDoc_STRVAR(reversed_new__doc__, -"reversed(sequence, /)\n" +"reversed(object, /)\n" "--\n" "\n" "Return a reverse iterator over the values of the given sequence."); @@ -110,4 +110,4 @@ reversed_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) exit: return return_value; } -/*[clinic end generated code: output=3300305b351674d3 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=155cc9483d5f9eab input=a9049054013a1b77]*/ diff --git a/Objects/enumobject.c b/Objects/enumobject.c index 1123b140c7fda8..814ce4f919514b 100644 --- a/Objects/enumobject.c +++ b/Objects/enumobject.c @@ -367,7 +367,7 @@ typedef struct { @classmethod reversed.__new__ as reversed_new - sequence as seq: object + object as seq: object / Return a reverse iterator over the values of the given sequence. @@ -375,7 +375,7 @@ Return a reverse iterator over the values of the given sequence. static PyObject * reversed_new_impl(PyTypeObject *type, PyObject *seq) -/*[clinic end generated code: output=f7854cc1df26f570 input=aeb720361e5e3f1d]*/ +/*[clinic end generated code: output=f7854cc1df26f570 input=4781869729e3ba50]*/ { Py_ssize_t n; PyObject *reversed_meth;