mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-83754: Use the Py_TYPE() macro (#120599)
Don't access directly PyObject.ob_type, but use the Py_TYPE() macro instead.
This commit is contained in:
parent
3df2022931
commit
c2d5df5787
6 changed files with 12 additions and 12 deletions
|
@ -261,8 +261,8 @@ PyAPI_DATA(PyTypeObject) PyBool_Type;
|
|||
|
||||
// bpo-39573: The Py_SET_SIZE() function must be used to set an object size.
|
||||
static inline Py_ssize_t Py_SIZE(PyObject *ob) {
|
||||
assert(ob->ob_type != &PyLong_Type);
|
||||
assert(ob->ob_type != &PyBool_Type);
|
||||
assert(Py_TYPE(ob) != &PyLong_Type);
|
||||
assert(Py_TYPE(ob) != &PyBool_Type);
|
||||
return _PyVarObject_CAST(ob)->ob_size;
|
||||
}
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
|
||||
|
@ -289,8 +289,8 @@ static inline void Py_SET_TYPE(PyObject *ob, PyTypeObject *type) {
|
|||
#endif
|
||||
|
||||
static inline void Py_SET_SIZE(PyVarObject *ob, Py_ssize_t size) {
|
||||
assert(ob->ob_base.ob_type != &PyLong_Type);
|
||||
assert(ob->ob_base.ob_type != &PyBool_Type);
|
||||
assert(Py_TYPE(_PyObject_CAST(ob)) != &PyLong_Type);
|
||||
assert(Py_TYPE(_PyObject_CAST(ob)) != &PyBool_Type);
|
||||
#ifdef Py_GIL_DISABLED
|
||||
_Py_atomic_store_ssize_relaxed(&ob->ob_size, size);
|
||||
#else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue