Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-89653: PEP 670: Limited API doesn't cast arguments #92654

Merged
merged 1 commit into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Include/cpython/listobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ 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])

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
6 changes: 5 additions & 1 deletion Include/cpython/tupleobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand All @@ -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);
4 changes: 3 additions & 1 deletion Include/cpython/weakrefobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -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