summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-05-11 22:01:42 (GMT)
committerGitHub <noreply@github.com>2022-05-11 22:01:42 (GMT)
commit7d3b469e475e6e52ce4f0bad7198bb05ead77b1d (patch)
tree879c8bda5f64cfd2f301e07a50a3003e15123b38
parenteb88f21301931449718cd4d105018d167a02788b (diff)
downloadcpython-7d3b469e475e6e52ce4f0bad7198bb05ead77b1d.zip
cpython-7d3b469e475e6e52ce4f0bad7198bb05ead77b1d.tar.gz
cpython-7d3b469e475e6e52ce4f0bad7198bb05ead77b1d.tar.bz2
gh-89653: PEP 670: Limited API doesn't cast arguments (#92654)
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()
-rw-r--r--Include/cpython/listobject.h6
-rw-r--r--Include/cpython/tupleobject.h6
-rw-r--r--Include/cpython/weakrefobject.h4
3 files changed, 13 insertions, 3 deletions
diff --git a/Include/cpython/listobject.h b/Include/cpython/listobject.h
index ebbea5e..4989ccc 100644
--- a/Include/cpython/listobject.h
+++ b/Include/cpython/listobject.h
@@ -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
diff --git a/Include/cpython/tupleobject.h b/Include/cpython/tupleobject.h
index d5b810e..a41cee1 100644
--- a/Include/cpython/tupleobject.h
+++ b/Include/cpython/tupleobject.h
@@ -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);
diff --git a/Include/cpython/weakrefobject.h b/Include/cpython/weakrefobject.h
index bec69ba..2dbef2c 100644
--- a/Include/cpython/weakrefobject.h
+++ b/Include/cpython/weakrefobject.h
@@ -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