summaryrefslogtreecommitdiffstats
path: root/Include/structseq.h
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-06-28 01:45:57 (GMT)
committerGitHub <noreply@github.com>2023-06-28 01:45:57 (GMT)
commit3f8483cad2f3b94600c3ecf3f0bb220bb1e61d7d (patch)
treed2a68be122484d443ab9260b2b542a9c509defe1 /Include/structseq.h
parent161012fc25910a47423bae8012398bf519a88140 (diff)
downloadcpython-3f8483cad2f3b94600c3ecf3f0bb220bb1e61d7d.zip
cpython-3f8483cad2f3b94600c3ecf3f0bb220bb1e61d7d.tar.gz
cpython-3f8483cad2f3b94600c3ecf3f0bb220bb1e61d7d.tar.bz2
gh-106168: PyTuple_SET_ITEM() now checks the index (#106164)
PyTuple_SET_ITEM() and PyList_SET_ITEM() now check the index argument with an assertion if Python is built in debug mode or is built with assertions. * list_extend() and _PyList_AppendTakeRef() now set the list size before calling PyList_SET_ITEM(). * PyStructSequence_GetItem() and PyStructSequence_SetItem() now check the index argument: must be lesser than REAL_SIZE(op). * PyStructSequence_GET_ITEM() and PyStructSequence_SET_ITEM() are now aliases to PyStructSequence_GetItem() and PyStructSequence_SetItem().
Diffstat (limited to 'Include/structseq.h')
-rw-r--r--Include/structseq.h13
1 files changed, 5 insertions, 8 deletions
diff --git a/Include/structseq.h b/Include/structseq.h
index 9687115..29e24fe 100644
--- a/Include/structseq.h
+++ b/Include/structseq.h
@@ -31,18 +31,15 @@ PyAPI_FUNC(PyTypeObject*) PyStructSequence_NewType(PyStructSequence_Desc *desc);
PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type);
+PyAPI_FUNC(void) PyStructSequence_SetItem(PyObject*, Py_ssize_t, PyObject*);
+PyAPI_FUNC(PyObject*) PyStructSequence_GetItem(PyObject*, Py_ssize_t);
+
#ifndef Py_LIMITED_API
typedef PyTupleObject PyStructSequence;
-
-/* Macro, *only* to be used to fill in brand new objects */
-#define PyStructSequence_SET_ITEM(op, i, v) PyTuple_SET_ITEM((op), (i), (v))
-
-#define PyStructSequence_GET_ITEM(op, i) PyTuple_GET_ITEM((op), (i))
+#define PyStructSequence_SET_ITEM PyStructSequence_SetItem
+#define PyStructSequence_GET_ITEM PyStructSequence_GetItem
#endif
-PyAPI_FUNC(void) PyStructSequence_SetItem(PyObject*, Py_ssize_t, PyObject*);
-PyAPI_FUNC(PyObject*) PyStructSequence_GetItem(PyObject*, Py_ssize_t);
-
#ifdef __cplusplus
}
#endif