Skip to content

Commit 7d3b469

Browse files
authoredMay 11, 2022
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()
1 parent eb88f21 commit 7d3b469

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed
 

‎Include/cpython/listobject.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,17 @@ PyAPI_FUNC(void) _PyList_DebugMallocStats(FILE *out);
3333
static inline Py_ssize_t PyList_GET_SIZE(PyListObject *op) {
3434
return Py_SIZE(op);
3535
}
36-
#define PyList_GET_SIZE(op) PyList_GET_SIZE(_PyList_CAST(op))
36+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
37+
# define PyList_GET_SIZE(op) PyList_GET_SIZE(_PyList_CAST(op))
38+
#endif
3739

3840
#define PyList_GET_ITEM(op, index) (_PyList_CAST(op)->ob_item[index])
3941

4042
static inline void
4143
PyList_SET_ITEM(PyListObject *op, Py_ssize_t index, PyObject *value) {
4244
op->ob_item[index] = value;
4345
}
46+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
4447
#define PyList_SET_ITEM(op, index, value) \
4548
PyList_SET_ITEM(_PyList_CAST(op), index, _PyObject_CAST(value))
49+
#endif

‎Include/cpython/tupleobject.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *);
2222
static inline Py_ssize_t PyTuple_GET_SIZE(PyTupleObject *op) {
2323
return Py_SIZE(op);
2424
}
25-
#define PyTuple_GET_SIZE(op) PyTuple_GET_SIZE(_PyTuple_CAST(op))
25+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
26+
# define PyTuple_GET_SIZE(op) PyTuple_GET_SIZE(_PyTuple_CAST(op))
27+
#endif
2628

2729
#define PyTuple_GET_ITEM(op, index) (_PyTuple_CAST(op)->ob_item[index])
2830

@@ -31,7 +33,9 @@ static inline void
3133
PyTuple_SET_ITEM(PyTupleObject *op, Py_ssize_t index, PyObject *value) {
3234
op->ob_item[index] = value;
3335
}
36+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
3437
#define PyTuple_SET_ITEM(op, index, value) \
3538
PyTuple_SET_ITEM(_PyTuple_CAST(op), index, _PyObject_CAST(value))
39+
#endif
3640

3741
PyAPI_FUNC(void) _PyTuple_DebugMallocStats(FILE *out);

‎Include/cpython/weakrefobject.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,6 @@ static inline PyObject* PyWeakref_GET_OBJECT(PyObject *ref_obj) {
5151
}
5252
return Py_None;
5353
}
54-
#define PyWeakref_GET_OBJECT(ref) PyWeakref_GET_OBJECT(_PyObject_CAST(ref))
54+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
55+
# define PyWeakref_GET_OBJECT(ref) PyWeakref_GET_OBJECT(_PyObject_CAST(ref))
56+
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.