gh-89653: PEP 670: Macros always cast arguments in cpython/ (#93766)

Header files in the Include/cpython/ are only included if
the Py_LIMITED_API macro is not defined.
This commit is contained in:
Victor Stinner 2022-06-13 20:09:40 +02:00 committed by GitHub
parent c2007573dd
commit df22eec421
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 28 additions and 92 deletions

View file

@ -40,9 +40,7 @@ PyAPI_DATA(PyTypeObject) PyCMethod_Type;
static inline PyCFunction PyCFunction_GET_FUNCTION(PyObject *func) {
return _PyCFunctionObject_CAST(func)->m_ml->ml_meth;
}
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
# define PyCFunction_GET_FUNCTION(func) PyCFunction_GET_FUNCTION(_PyObject_CAST(func))
#endif
#define PyCFunction_GET_FUNCTION(func) PyCFunction_GET_FUNCTION(_PyObject_CAST(func))
static inline PyObject* PyCFunction_GET_SELF(PyObject *func_obj) {
PyCFunctionObject *func = _PyCFunctionObject_CAST(func_obj);
@ -51,16 +49,12 @@ static inline PyObject* PyCFunction_GET_SELF(PyObject *func_obj) {
}
return func->m_self;
}
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
# define PyCFunction_GET_SELF(func) PyCFunction_GET_SELF(_PyObject_CAST(func))
#endif
#define PyCFunction_GET_SELF(func) PyCFunction_GET_SELF(_PyObject_CAST(func))
static inline int PyCFunction_GET_FLAGS(PyObject *func) {
return _PyCFunctionObject_CAST(func)->m_ml->ml_flags;
}
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
# define PyCFunction_GET_FLAGS(func) PyCFunction_GET_FLAGS(_PyObject_CAST(func))
#endif
#define PyCFunction_GET_FLAGS(func) PyCFunction_GET_FLAGS(_PyObject_CAST(func))
static inline PyTypeObject* PyCFunction_GET_CLASS(PyObject *func_obj) {
PyCFunctionObject *func = _PyCFunctionObject_CAST(func_obj);
@ -69,6 +63,4 @@ static inline PyTypeObject* PyCFunction_GET_CLASS(PyObject *func_obj) {
}
return _Py_NULL;
}
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
# define PyCFunction_GET_CLASS(func) PyCFunction_GET_CLASS(_PyObject_CAST(func))
#endif
#define PyCFunction_GET_CLASS(func) PyCFunction_GET_CLASS(_PyObject_CAST(func))