summaryrefslogtreecommitdiff
path: root/Include/cpython/tupleobject.h
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-05-12 00:49:03 +0200
committerGitHub <noreply@github.com>2022-05-12 00:49:03 +0200
commit6de78ef96afbaa127472bb9dc0a4e41e44555d00 (patch)
treef858a9a2dd32a8511f4d5ad41c9be4fed7afa712 /Include/cpython/tupleobject.h
parentd492f0ab2add26d89474b002a9a5a2da306222c5 (diff)
downloadcpython-git-6de78ef96afbaa127472bb9dc0a4e41e44555d00.tar.gz
gh-89653: PEP 670: Use PyObject* type for parameters (#92694)
Use the PyObject* type for parameters of static inline functions: * Py_SIZE(): same parameter type than PyObject_Size() * PyList_GET_SIZE(), PyList_SET_ITEM(): same parameter type than PyList_Size() and PyList_SetItem() * PyTuple_GET_SIZE(), PyTuple_SET_ITEM(): same parameter type than PyTuple_Size() and PyTuple_SetItem().
Diffstat (limited to 'Include/cpython/tupleobject.h')
-rw-r--r--Include/cpython/tupleobject.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/Include/cpython/tupleobject.h b/Include/cpython/tupleobject.h
index a41cee1759..3d9c1aff58 100644
--- a/Include/cpython/tupleobject.h
+++ b/Include/cpython/tupleobject.h
@@ -19,23 +19,25 @@ PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *);
// Macros and static inline functions, trading safety for speed
-static inline Py_ssize_t PyTuple_GET_SIZE(PyTupleObject *op) {
- return Py_SIZE(op);
+static inline Py_ssize_t PyTuple_GET_SIZE(PyObject *op) {
+ PyTupleObject *tuple = _PyTuple_CAST(op);
+ return Py_SIZE(tuple);
}
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
-# define PyTuple_GET_SIZE(op) PyTuple_GET_SIZE(_PyTuple_CAST(op))
+# define PyTuple_GET_SIZE(op) PyTuple_GET_SIZE(_PyObject_CAST(op))
#endif
#define PyTuple_GET_ITEM(op, index) (_PyTuple_CAST(op)->ob_item[index])
/* Function *only* to be used to fill in brand new tuples */
static inline void
-PyTuple_SET_ITEM(PyTupleObject *op, Py_ssize_t index, PyObject *value) {
- op->ob_item[index] = value;
+PyTuple_SET_ITEM(PyObject *op, Py_ssize_t index, PyObject *value) {
+ PyTupleObject *tuple = _PyTuple_CAST(op);
+ tuple->ob_item[index] = value;
}
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
#define PyTuple_SET_ITEM(op, index, value) \
- PyTuple_SET_ITEM(_PyTuple_CAST(op), index, _PyObject_CAST(value))
+ PyTuple_SET_ITEM(_PyObject_CAST(op), index, _PyObject_CAST(value))
#endif
PyAPI_FUNC(void) _PyTuple_DebugMallocStats(FILE *out);