]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-89653: PEP 670: Limited API doesn't cast arguments (#92654)
authorVictor Stinner <vstinner@python.org>
Wed, 11 May 2022 22:01:42 +0000 (00:01 +0200)
committerGitHub <noreply@github.com>
Wed, 11 May 2022 22:01:42 +0000 (00:01 +0200)
The limited API version 3.11 no longer casts arguments to expected
types of functions of functions:

* PyList_GET_SIZE(), PyList_SET_ITEM()
* PyTuple_GET_SIZE(), PyTuple_SET_ITEM()
* PyWeakref_GET_OBJECT()

Include/cpython/listobject.h
Include/cpython/tupleobject.h
Include/cpython/weakrefobject.h

index ebbea5ebf1ebcb309a9205acc17a7fdb0db8e675..4989cccef9f8045cb1c15388f297f03ccd9e3cac 100644 (file)
@@ -33,7 +33,9 @@ PyAPI_FUNC(void) _PyList_DebugMallocStats(FILE *out);
 static inline Py_ssize_t PyList_GET_SIZE(PyListObject *op) {
     return Py_SIZE(op);
 }
-#define PyList_GET_SIZE(op) PyList_GET_SIZE(_PyList_CAST(op))
+#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
+#  define PyList_GET_SIZE(op) PyList_GET_SIZE(_PyList_CAST(op))
+#endif
 
 #define PyList_GET_ITEM(op, index) (_PyList_CAST(op)->ob_item[index])
 
@@ -41,5 +43,7 @@ static inline void
 PyList_SET_ITEM(PyListObject *op, Py_ssize_t index, PyObject *value) {
     op->ob_item[index] = value;
 }
+#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
 #define PyList_SET_ITEM(op, index, value) \
     PyList_SET_ITEM(_PyList_CAST(op), index, _PyObject_CAST(value))
+#endif
index d5b810e5f4277eace33b298da9162b1d307bda2c..a41cee1759d484362e1e7558dff406b70f2e90fb 100644 (file)
@@ -22,7 +22,9 @@ PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *);
 static inline Py_ssize_t PyTuple_GET_SIZE(PyTupleObject *op) {
     return Py_SIZE(op);
 }
-#define PyTuple_GET_SIZE(op) PyTuple_GET_SIZE(_PyTuple_CAST(op))
+#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
+#  define PyTuple_GET_SIZE(op) PyTuple_GET_SIZE(_PyTuple_CAST(op))
+#endif
 
 #define PyTuple_GET_ITEM(op, index) (_PyTuple_CAST(op)->ob_item[index])
 
@@ -31,7 +33,9 @@ static inline void
 PyTuple_SET_ITEM(PyTupleObject *op, Py_ssize_t index, PyObject *value) {
     op->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))
+#endif
 
 PyAPI_FUNC(void) _PyTuple_DebugMallocStats(FILE *out);
index bec69ba90d6b986cf32262d05d8d19def7eb4321..2dbef2cea37658ec36f53d919ed1b640fa00890b 100644 (file)
@@ -51,4 +51,6 @@ static inline PyObject* PyWeakref_GET_OBJECT(PyObject *ref_obj) {
     }
     return Py_None;
 }
-#define PyWeakref_GET_OBJECT(ref) PyWeakref_GET_OBJECT(_PyObject_CAST(ref))
+#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
+#  define PyWeakref_GET_OBJECT(ref) PyWeakref_GET_OBJECT(_PyObject_CAST(ref))
+#endif