diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-05-11 23:23:29 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-11 23:23:29 (GMT) |
commit | a1bef8c2e305178fae2ff90b5772e785a97d2201 (patch) | |
tree | 3abd613bf2e358df877f2cd07650bdab5cfe1799 /Include/object.h | |
parent | c7b9da5204b44fd3e9960a2326d431e3ff5c8667 (diff) | |
download | cpython-a1bef8c2e305178fae2ff90b5772e785a97d2201.zip cpython-a1bef8c2e305178fae2ff90b5772e785a97d2201.tar.gz cpython-a1bef8c2e305178fae2ff90b5772e785a97d2201.tar.bz2 |
gh-89653: PEP 670: Use PyObject* type for parameters (GH-92694)
Use the PyObject* type for parameters of static inline functions:
* Py_SIZE(): same parameter type than PyObject_Size()
* PyList_GET_SIZE(), PyList_SET_ITEM(): same parameter type than
PyList_Size() and PyList_SetItem()
* PyTuple_GET_SIZE(), PyTuple_SET_ITEM(): same parameter type than
PyTuple_Size() and PyTuple_SetItem().
(cherry picked from commit 6de78ef96afbaa127472bb9dc0a4e41e44555d00)
Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Include/object.h')
-rw-r--r-- | Include/object.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Include/object.h b/Include/object.h index fac8892..f2af428 100644 --- a/Include/object.h +++ b/Include/object.h @@ -137,11 +137,12 @@ static inline PyTypeObject* Py_TYPE(PyObject *ob) { #endif // bpo-39573: The Py_SET_SIZE() function must be used to set an object size. -static inline Py_ssize_t Py_SIZE(PyVarObject *ob) { - return ob->ob_size; +static inline Py_ssize_t Py_SIZE(PyObject *ob) { + PyVarObject *var_ob = _PyVarObject_CAST(ob); + return var_ob->ob_size; } #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000 -# define Py_SIZE(ob) Py_SIZE(_PyVarObject_CAST(ob)) +# define Py_SIZE(ob) Py_SIZE(_PyObject_CAST(ob)) #endif |