From 4e4646348c580488c97d0ba2fb432be0d2f3f866 Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Wed, 15 Oct 2025 01:27:42 +0500 Subject: [PATCH 01/16] Add PyTuple_Make[Single,Pair] --- Doc/c-api/tuple.rst | 28 ++++++++++++++++++++++++++++ Doc/data/refcounts.dat | 7 +++++++ Include/tupleobject.h | 3 +++ Lib/test/test_capi/test_tuple.py | 29 +++++++++++++++++++++++++++++ Modules/_testcapi/tuple.c | 25 +++++++++++++++++++++++++ Objects/tupleobject.c | 29 +++++++++++++++++++++++++++++ 6 files changed, 121 insertions(+) diff --git a/Doc/c-api/tuple.rst b/Doc/c-api/tuple.rst index 14a7c05efeac87..feb209607d3ad5 100644 --- a/Doc/c-api/tuple.rst +++ b/Doc/c-api/tuple.rst @@ -58,6 +58,34 @@ Tuple Objects ``PyTuple_Pack(2, a, b)`` is equivalent to ``Py_BuildValue("(OO)", a, b)``. +.. c:function:: PyObject* PyTuple_MakeSingle(PyObject *one) + + Return a new tuple object of size 1, + or ``NULL`` with an exception set on failure. The tuple value + is initialized with the new reference to the *one* object. + ``PyTuple_MakeSingle(a)`` is equivalent to ``PyTuple_Pack(1, a)``. + + .. warning:: + + This function expects non ``NULL`` object *one*. + Checking is performed as an assertion if Python is built in + :ref:`debug mode ` or :option:`with assertions <--with-assertions>`. + + +.. c:function:: PyObject* PyTuple_MakePair(PyObject *one, PyObject *two) + + Return a new tuple object of size 2, + or ``NULL`` with an exception set on failure. The tuple values + are initialized with the new references to the *one* and *two* objects. + ``PyTuple_MakePair(a, b)`` is equivalent to ``PyTuple_Pack(2, a, b)``. + + .. warning:: + + This function expects non ``NULL`` objects *one* and *two*. + Checking is performed as an assertion if Python is built in + :ref:`debug mode ` or :option:`with assertions <--with-assertions>`. + + .. c:function:: Py_ssize_t PyTuple_Size(PyObject *p) Take a pointer to a tuple object, and return the size of that tuple. diff --git a/Doc/data/refcounts.dat b/Doc/data/refcounts.dat index 48f4f4919e8966..25f922d94ff622 100644 --- a/Doc/data/refcounts.dat +++ b/Doc/data/refcounts.dat @@ -2359,6 +2359,13 @@ PyTuple_GetSlice:PyObject*:p:0: PyTuple_GetSlice:Py_ssize_t:low:: PyTuple_GetSlice:Py_ssize_t:high:: +PyTuple_MakePair:PyObject*::+1 +PyTuple_MakePair:PyObject*:one:+1 +PyTuple_MakePair:PyObject*:two:+1 + +PyTuple_MakeSingle:PyObject*::+1 +PyTuple_MakeSingle:PyObject*:one:+1 + PyTuple_New:PyObject*::+1: PyTuple_New:Py_ssize_t:len:: diff --git a/Include/tupleobject.h b/Include/tupleobject.h index 1f9ab54be65f87..d91ea13e307031 100644 --- a/Include/tupleobject.h +++ b/Include/tupleobject.h @@ -34,6 +34,9 @@ PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *); PyAPI_FUNC(PyObject *) PyTuple_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t); PyAPI_FUNC(PyObject *) PyTuple_Pack(Py_ssize_t, ...); +PyAPI_FUNC(PyObject *) PyTuple_MakeSingle(PyObject *one); +PyAPI_FUNC(PyObject *) PyTuple_MakePair(PyObject *one, PyObject *two); + #ifndef Py_LIMITED_API # define Py_CPYTHON_TUPLEOBJECT_H # include "cpython/tupleobject.h" diff --git a/Lib/test/test_capi/test_tuple.py b/Lib/test/test_capi/test_tuple.py index b6d6da008d0b7b..ce70f19c932d3e 100644 --- a/Lib/test/test_capi/test_tuple.py +++ b/Lib/test/test_capi/test_tuple.py @@ -99,6 +99,35 @@ def test_tuple_pack(self): # CRASHES pack(1, NULL) # CRASHES pack(2, [1]) + def test_tuple_make_single(self): + # Test PyTuple_MakeSingle() + make_single = _testcapi.tuple_make_single + + self.assertEqual(make_single(1), (1,)) + self.assertEqual(make_single(None), (None,)) + self.assertEqual(make_single(True), (True,)) + + temp = object() + self.assertEqual(make_single(temp), (temp,)) + + self.assertRaises(TypeError, make_single, 1, 2) + self.assertRaises(TypeError, make_single) + + def test_tuple_make_pair(self): + # Test PyTuple_MakePair() + make_pair = _testcapi.tuple_make_pair + + self.assertEqual(make_pair(1, 2), (1, 2)) + self.assertEqual(make_pair(None, None), (None, None)) + self.assertEqual(make_pair(True, False), (True, False)) + + temp = object() + self.assertEqual(make_pair(temp, temp), (temp, temp)) + + self.assertRaises(TypeError, make_pair, 1, 2, 3) + self.assertRaises(TypeError, make_pair, 1) + self.assertRaises(TypeError, make_pair) + def test_tuple_size(self): # Test PyTuple_Size() size = _testlimitedcapi.tuple_size diff --git a/Modules/_testcapi/tuple.c b/Modules/_testcapi/tuple.c index 5de1c494c0a8c0..da2aac12ec2eb8 100644 --- a/Modules/_testcapi/tuple.c +++ b/Modules/_testcapi/tuple.c @@ -130,6 +130,29 @@ tuple_fromarray(PyObject* Py_UNUSED(module), PyObject *args) return PyTuple_FromArray(items, size); } +static PyObject * +tuple_make_single(PyObject *Py_UNUSED(module), PyObject *args) +{ + PyObject *one; + if (!PyArg_ParseTuple(args, "O", &one)) { + return NULL; + } + + return PyTuple_MakeSingle(one); +} + +static PyObject * +tuple_make_pair(PyObject *Py_UNUSED(module), PyObject *args) +{ + PyObject *one; + PyObject *two; + if (!PyArg_ParseTuple(args, "OO", &one, &two)) { + return NULL; + } + + return PyTuple_MakePair(one, two); +} + static PyMethodDef test_methods[] = { {"tuple_get_size", tuple_get_size, METH_O}, @@ -138,6 +161,8 @@ static PyMethodDef test_methods[] = { {"_tuple_resize", _tuple_resize, METH_VARARGS}, {"_check_tuple_item_is_NULL", _check_tuple_item_is_NULL, METH_VARARGS}, {"tuple_fromarray", tuple_fromarray, METH_VARARGS}, + {"tuple_make_single", tuple_make_single, METH_VARARGS}, + {"tuple_make_pair", tuple_make_pair, METH_VARARGS}, {NULL}, }; diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index 94b7ae7e642283..6e235cfeb21db7 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -184,6 +184,35 @@ PyTuple_Pack(Py_ssize_t n, ...) return (PyObject *)result; } +PyObject * +PyTuple_MakeSingle(PyObject *one) +{ + assert (one != NULL); + + PyTupleObject *op = tuple_alloc(1); + if (op == NULL) { + return NULL; + } + op->ob_item[0] = Py_NewRef(one); + _PyObject_GC_TRACK(op); + return (PyObject *) op; +} + +PyObject * +PyTuple_MakePair(PyObject *one, PyObject *two) +{ + assert (one != NULL); + assert (two != NULL); + + PyTupleObject *op = tuple_alloc(2); + if (op == NULL) { + return NULL; + } + op->ob_item[0] = Py_NewRef(one); + op->ob_item[1] = Py_NewRef(two); + _PyObject_GC_TRACK(op); + return (PyObject *) op; +} /* Methods */ From aacb9f277a684cdc82fea45c6d19c2fbc2b75703 Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Wed, 15 Oct 2025 01:30:37 +0500 Subject: [PATCH 02/16] Add news entry --- .../2025-10-15-01-30-28.gh-issue-140052.08spgX.rst | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Misc/NEWS.d/next/Core_and_Builtins/2025-10-15-01-30-28.gh-issue-140052.08spgX.rst diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-10-15-01-30-28.gh-issue-140052.08spgX.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-10-15-01-30-28.gh-issue-140052.08spgX.rst new file mode 100644 index 00000000000000..04ef75c8886a64 --- /dev/null +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-10-15-01-30-28.gh-issue-140052.08spgX.rst @@ -0,0 +1,2 @@ +Add :c:func:`PyTuple_MakeSingle` and :c:func:`PyTuple_MakePair` functions to +create short-sized tuples. (Contributed by Sergey Miryanov in :gh:`140052`.) From ef7d139b4c8926eea709a4a7ea8f0051f361e3a0 Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Wed, 15 Oct 2025 01:32:18 +0500 Subject: [PATCH 03/16] Fix news entry --- .../2025-10-15-01-30-28.gh-issue-140052.08spgX.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-10-15-01-30-28.gh-issue-140052.08spgX.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-10-15-01-30-28.gh-issue-140052.08spgX.rst index 04ef75c8886a64..afe2c8b9d1b0bc 100644 --- a/Misc/NEWS.d/next/Core_and_Builtins/2025-10-15-01-30-28.gh-issue-140052.08spgX.rst +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-10-15-01-30-28.gh-issue-140052.08spgX.rst @@ -1,2 +1,4 @@ Add :c:func:`PyTuple_MakeSingle` and :c:func:`PyTuple_MakePair` functions to -create short-sized tuples. (Contributed by Sergey Miryanov in :gh:`140052`.) +create short-sized tuples. + +Patch by Sergey Miryanov. From ebb70c96fb92429651468962967692733f925e3a Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Wed, 15 Oct 2025 01:38:46 +0500 Subject: [PATCH 04/16] Revert refcounts.dat changes --- Doc/data/refcounts.dat | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Doc/data/refcounts.dat b/Doc/data/refcounts.dat index 25f922d94ff622..48f4f4919e8966 100644 --- a/Doc/data/refcounts.dat +++ b/Doc/data/refcounts.dat @@ -2359,13 +2359,6 @@ PyTuple_GetSlice:PyObject*:p:0: PyTuple_GetSlice:Py_ssize_t:low:: PyTuple_GetSlice:Py_ssize_t:high:: -PyTuple_MakePair:PyObject*::+1 -PyTuple_MakePair:PyObject*:one:+1 -PyTuple_MakePair:PyObject*:two:+1 - -PyTuple_MakeSingle:PyObject*::+1 -PyTuple_MakeSingle:PyObject*:one:+1 - PyTuple_New:PyObject*::+1: PyTuple_New:Py_ssize_t:len:: From bb9d532cd277da0015fdd5af167fbb291fdb2062 Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Wed, 15 Oct 2025 01:47:51 +0500 Subject: [PATCH 05/16] Revert "Revert refcounts.dat changes" This reverts commit ebb70c96fb92429651468962967692733f925e3a. --- Doc/data/refcounts.dat | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Doc/data/refcounts.dat b/Doc/data/refcounts.dat index 48f4f4919e8966..25f922d94ff622 100644 --- a/Doc/data/refcounts.dat +++ b/Doc/data/refcounts.dat @@ -2359,6 +2359,13 @@ PyTuple_GetSlice:PyObject*:p:0: PyTuple_GetSlice:Py_ssize_t:low:: PyTuple_GetSlice:Py_ssize_t:high:: +PyTuple_MakePair:PyObject*::+1 +PyTuple_MakePair:PyObject*:one:+1 +PyTuple_MakePair:PyObject*:two:+1 + +PyTuple_MakeSingle:PyObject*::+1 +PyTuple_MakeSingle:PyObject*:one:+1 + PyTuple_New:PyObject*::+1: PyTuple_New:Py_ssize_t:len:: From ee4056e9c74c23c96f5c3aed4a69099730ade400 Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Wed, 15 Oct 2025 01:49:13 +0500 Subject: [PATCH 06/16] Fix refcounts.dat --- Doc/data/refcounts.dat | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/data/refcounts.dat b/Doc/data/refcounts.dat index 25f922d94ff622..625e8e63ec9d7e 100644 --- a/Doc/data/refcounts.dat +++ b/Doc/data/refcounts.dat @@ -2359,12 +2359,12 @@ PyTuple_GetSlice:PyObject*:p:0: PyTuple_GetSlice:Py_ssize_t:low:: PyTuple_GetSlice:Py_ssize_t:high:: -PyTuple_MakePair:PyObject*::+1 -PyTuple_MakePair:PyObject*:one:+1 -PyTuple_MakePair:PyObject*:two:+1 +PyTuple_MakePair:PyObject*::+1: +PyTuple_MakePair:PyObject*:one:+1: +PyTuple_MakePair:PyObject*:two:+1: -PyTuple_MakeSingle:PyObject*::+1 -PyTuple_MakeSingle:PyObject*:one:+1 +PyTuple_MakeSingle:PyObject*::+1: +PyTuple_MakeSingle:PyObject*:one:+1: PyTuple_New:PyObject*::+1: PyTuple_New:Py_ssize_t:len:: From bda2374d4c7bc3d12b850a80d687d75faa50e8a7 Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Wed, 15 Oct 2025 01:49:27 +0500 Subject: [PATCH 07/16] Fix news entry --- .../2025-10-15-01-30-28.gh-issue-140052.08spgX.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2025-10-15-01-30-28.gh-issue-140052.08spgX.rst b/Misc/NEWS.d/next/Core_and_Builtins/2025-10-15-01-30-28.gh-issue-140052.08spgX.rst index afe2c8b9d1b0bc..c0c93598d0df49 100644 --- a/Misc/NEWS.d/next/Core_and_Builtins/2025-10-15-01-30-28.gh-issue-140052.08spgX.rst +++ b/Misc/NEWS.d/next/Core_and_Builtins/2025-10-15-01-30-28.gh-issue-140052.08spgX.rst @@ -1,4 +1,2 @@ Add :c:func:`PyTuple_MakeSingle` and :c:func:`PyTuple_MakePair` functions to -create short-sized tuples. - -Patch by Sergey Miryanov. +create short-sized tuples. Patch by Sergey Miryanov. From 2076783741439a710141285a49db4d327b89af9c Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Wed, 15 Oct 2025 01:52:33 +0500 Subject: [PATCH 08/16] Apply suggestions from code review Co-authored-by: Victor Stinner --- Modules/_testcapi/tuple.c | 3 +-- Objects/tupleobject.c | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Modules/_testcapi/tuple.c b/Modules/_testcapi/tuple.c index da2aac12ec2eb8..4ac2b52d4a0f76 100644 --- a/Modules/_testcapi/tuple.c +++ b/Modules/_testcapi/tuple.c @@ -144,8 +144,7 @@ tuple_make_single(PyObject *Py_UNUSED(module), PyObject *args) static PyObject * tuple_make_pair(PyObject *Py_UNUSED(module), PyObject *args) { - PyObject *one; - PyObject *two; + PyObject *one, *two; if (!PyArg_ParseTuple(args, "OO", &one, &two)) { return NULL; } diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index 6e235cfeb21db7..19443a52a79f20 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -195,7 +195,7 @@ PyTuple_MakeSingle(PyObject *one) } op->ob_item[0] = Py_NewRef(one); _PyObject_GC_TRACK(op); - return (PyObject *) op; + return (PyObject *)op; } PyObject * @@ -211,7 +211,7 @@ PyTuple_MakePair(PyObject *one, PyObject *two) op->ob_item[0] = Py_NewRef(one); op->ob_item[1] = Py_NewRef(two); _PyObject_GC_TRACK(op); - return (PyObject *) op; + return (PyObject *)op; } /* Methods */ From d45bd2ae1bec3e1b506263dc5f9b93053475771e Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Wed, 15 Oct 2025 01:55:30 +0500 Subject: [PATCH 09/16] Fix docs --- Doc/c-api/tuple.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Doc/c-api/tuple.rst b/Doc/c-api/tuple.rst index feb209607d3ad5..094b914cb87bf3 100644 --- a/Doc/c-api/tuple.rst +++ b/Doc/c-api/tuple.rst @@ -67,9 +67,9 @@ Tuple Objects .. warning:: - This function expects non ``NULL`` object *one*. - Checking is performed as an assertion if Python is built in - :ref:`debug mode ` or :option:`with assertions <--with-assertions>`. + *one* must not be ``NULL``. Checking is performed as an assertion + if Python is built in :ref:`debug mode ` or + :option:`with assertions <--with-assertions>`. .. c:function:: PyObject* PyTuple_MakePair(PyObject *one, PyObject *two) @@ -81,9 +81,9 @@ Tuple Objects .. warning:: - This function expects non ``NULL`` objects *one* and *two*. - Checking is performed as an assertion if Python is built in - :ref:`debug mode ` or :option:`with assertions <--with-assertions>`. + *one* and *two* must not be ``NULL``. Checking is performed as an assertion + if Python is built in :ref:`debug mode ` or + :option:`with assertions <--with-assertions>`. .. c:function:: Py_ssize_t PyTuple_Size(PyObject *p) From bd7bc3e94cc3fafe8ae2b1d1fefcb21f6c667fa7 Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Wed, 15 Oct 2025 01:59:50 +0500 Subject: [PATCH 10/16] Fix tuple_make_single --- Modules/_testcapi/tuple.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Modules/_testcapi/tuple.c b/Modules/_testcapi/tuple.c index 4ac2b52d4a0f76..32574f13d0d937 100644 --- a/Modules/_testcapi/tuple.c +++ b/Modules/_testcapi/tuple.c @@ -131,13 +131,8 @@ tuple_fromarray(PyObject* Py_UNUSED(module), PyObject *args) } static PyObject * -tuple_make_single(PyObject *Py_UNUSED(module), PyObject *args) +tuple_make_single(PyObject *Py_UNUSED(module), PyObject *one) { - PyObject *one; - if (!PyArg_ParseTuple(args, "O", &one)) { - return NULL; - } - return PyTuple_MakeSingle(one); } @@ -160,7 +155,7 @@ static PyMethodDef test_methods[] = { {"_tuple_resize", _tuple_resize, METH_VARARGS}, {"_check_tuple_item_is_NULL", _check_tuple_item_is_NULL, METH_VARARGS}, {"tuple_fromarray", tuple_fromarray, METH_VARARGS}, - {"tuple_make_single", tuple_make_single, METH_VARARGS}, + {"tuple_make_single", tuple_make_single, METH_O}, {"tuple_make_pair", tuple_make_pair, METH_VARARGS}, {NULL}, }; From f5bab3c57d59065d0a27472faec8bf34bc90ced7 Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Wed, 15 Oct 2025 02:24:08 +0500 Subject: [PATCH 11/16] Fix docs --- Doc/c-api/tuple.rst | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Doc/c-api/tuple.rst b/Doc/c-api/tuple.rst index 094b914cb87bf3..8b6a9509b150ac 100644 --- a/Doc/c-api/tuple.rst +++ b/Doc/c-api/tuple.rst @@ -67,9 +67,7 @@ Tuple Objects .. warning:: - *one* must not be ``NULL``. Checking is performed as an assertion - if Python is built in :ref:`debug mode ` or - :option:`with assertions <--with-assertions>`. + *one* must not be ``NULL``. .. c:function:: PyObject* PyTuple_MakePair(PyObject *one, PyObject *two) @@ -81,9 +79,7 @@ Tuple Objects .. warning:: - *one* and *two* must not be ``NULL``. Checking is performed as an assertion - if Python is built in :ref:`debug mode ` or - :option:`with assertions <--with-assertions>`. + *one* and *two* must not be ``NULL``. .. c:function:: Py_ssize_t PyTuple_Size(PyObject *p) From 616153514bc929af0f9a3af8bd639547bd8e85ed Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Wed, 15 Oct 2025 02:26:54 +0500 Subject: [PATCH 12/16] Move declarations to Include/cpython/tupleobject.h --- Include/cpython/tupleobject.h | 3 +++ Include/tupleobject.h | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Include/cpython/tupleobject.h b/Include/cpython/tupleobject.h index 888baaf3358267..3a3653ebba3584 100644 --- a/Include/cpython/tupleobject.h +++ b/Include/cpython/tupleobject.h @@ -42,3 +42,6 @@ PyTuple_SET_ITEM(PyObject *op, Py_ssize_t index, PyObject *value) { PyAPI_FUNC(PyObject*) PyTuple_FromArray( PyObject *const *array, Py_ssize_t size); + +PyAPI_FUNC(PyObject *) PyTuple_MakeSingle(PyObject *one); +PyAPI_FUNC(PyObject *) PyTuple_MakePair(PyObject *one, PyObject *two); diff --git a/Include/tupleobject.h b/Include/tupleobject.h index d91ea13e307031..1f9ab54be65f87 100644 --- a/Include/tupleobject.h +++ b/Include/tupleobject.h @@ -34,9 +34,6 @@ PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *); PyAPI_FUNC(PyObject *) PyTuple_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t); PyAPI_FUNC(PyObject *) PyTuple_Pack(Py_ssize_t, ...); -PyAPI_FUNC(PyObject *) PyTuple_MakeSingle(PyObject *one); -PyAPI_FUNC(PyObject *) PyTuple_MakePair(PyObject *one, PyObject *two); - #ifndef Py_LIMITED_API # define Py_CPYTHON_TUPLEOBJECT_H # include "cpython/tupleobject.h" From e6d2e0e6119bc0fb7d1925363d5a6609f3106c3c Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Wed, 15 Oct 2025 02:35:49 +0500 Subject: [PATCH 13/16] Update Doc/c-api/tuple.rst Co-authored-by: Victor Stinner --- Doc/c-api/tuple.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Doc/c-api/tuple.rst b/Doc/c-api/tuple.rst index 8b6a9509b150ac..f97df5a2bb31e4 100644 --- a/Doc/c-api/tuple.rst +++ b/Doc/c-api/tuple.rst @@ -65,9 +65,7 @@ Tuple Objects is initialized with the new reference to the *one* object. ``PyTuple_MakeSingle(a)`` is equivalent to ``PyTuple_Pack(1, a)``. - .. warning:: - - *one* must not be ``NULL``. + *one* must not be ``NULL``. .. c:function:: PyObject* PyTuple_MakePair(PyObject *one, PyObject *two) From 3c0ef7c37c7ff5c48d5e68a0b56536606da43fb1 Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Wed, 15 Oct 2025 02:36:27 +0500 Subject: [PATCH 14/16] Remove warning from PyTuple_MakePair docs --- Doc/c-api/tuple.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/Doc/c-api/tuple.rst b/Doc/c-api/tuple.rst index f97df5a2bb31e4..87db92117ff904 100644 --- a/Doc/c-api/tuple.rst +++ b/Doc/c-api/tuple.rst @@ -75,8 +75,6 @@ Tuple Objects are initialized with the new references to the *one* and *two* objects. ``PyTuple_MakePair(a, b)`` is equivalent to ``PyTuple_Pack(2, a, b)``. - .. warning:: - *one* and *two* must not be ``NULL``. From 270141b98607919078b80d5538ceaa05cfc4f067 Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Wed, 15 Oct 2025 02:51:03 +0500 Subject: [PATCH 15/16] Apply suggestions from code review Co-authored-by: Pieter Eendebak --- Doc/c-api/tuple.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/tuple.rst b/Doc/c-api/tuple.rst index 87db92117ff904..f52a71be5c2453 100644 --- a/Doc/c-api/tuple.rst +++ b/Doc/c-api/tuple.rst @@ -62,7 +62,7 @@ Tuple Objects Return a new tuple object of size 1, or ``NULL`` with an exception set on failure. The tuple value - is initialized with the new reference to the *one* object. + is initialized with a new reference to the *one* object. ``PyTuple_MakeSingle(a)`` is equivalent to ``PyTuple_Pack(1, a)``. *one* must not be ``NULL``. @@ -72,7 +72,7 @@ Tuple Objects Return a new tuple object of size 2, or ``NULL`` with an exception set on failure. The tuple values - are initialized with the new references to the *one* and *two* objects. + are initialized with new references to the *one* and *two* objects. ``PyTuple_MakePair(a, b)`` is equivalent to ``PyTuple_Pack(2, a, b)``. *one* and *two* must not be ``NULL``. From 7c0eaa4c06508723cd1c2da840f76e59e03654ef Mon Sep 17 00:00:00 2001 From: Sergey Miryanov Date: Wed, 15 Oct 2025 10:27:19 +0500 Subject: [PATCH 16/16] Fix indentation for PyTuple_MakePair docs --- Doc/c-api/tuple.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/c-api/tuple.rst b/Doc/c-api/tuple.rst index f52a71be5c2453..8e73b053107416 100644 --- a/Doc/c-api/tuple.rst +++ b/Doc/c-api/tuple.rst @@ -75,7 +75,7 @@ Tuple Objects are initialized with new references to the *one* and *two* objects. ``PyTuple_MakePair(a, b)`` is equivalent to ``PyTuple_Pack(2, a, b)``. - *one* and *two* must not be ``NULL``. + *one* and *two* must not be ``NULL``. .. c:function:: Py_ssize_t PyTuple_Size(PyObject *p)