bpo-35199: Add an internal _PyTuple_ITEMS() macro (GH-10434)
* _PyTuple_ITEMS() gives access to the tuple->ob_item field and cast the
first argument to PyTupleObject*. This internal macro is only usable if
Py_BUILD_CORE is defined.
* Replace &PyTuple_GET_ITEM(ob, 0) with _PyTuple_ITEMS(ob).
* Replace PyTuple_GET_ITEM(op, 1) with &_PyTuple_ITEMS(ob)[1].
diff --git a/Include/tupleobject.h b/Include/tupleobject.h
index 72a7d8d..257e05a 100644
--- a/Include/tupleobject.h
+++ b/Include/tupleobject.h
@@ -58,6 +58,10 @@
#define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i])
#define PyTuple_GET_SIZE(op) (assert(PyTuple_Check(op)),Py_SIZE(op))
+#ifdef Py_BUILD_CORE
+# define _PyTuple_ITEMS(op) ((((PyTupleObject *)(op))->ob_item))
+#endif
+
/* Macro, *only* to be used to fill in brand new tuples */
#define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v)
#endif