mirror of
https://github.com/python/cpython.git
synced 2025-11-01 02:38:53 +00:00
gh-87347: Add parenthesis around macro arguments (#93915)
Add unit test on Py_MEMBER_SIZE() and some other macros.
This commit is contained in:
parent
61f24e7885
commit
7ad6f74fcf
30 changed files with 171 additions and 143 deletions
|
|
@ -80,10 +80,10 @@ whose size is determined when the object is allocated.
|
|||
|
||||
#define PyObject_HEAD_INIT(type) \
|
||||
{ _PyObject_EXTRA_INIT \
|
||||
1, type },
|
||||
1, (type) },
|
||||
|
||||
#define PyVarObject_HEAD_INIT(type, size) \
|
||||
{ PyObject_HEAD_INIT(type) size },
|
||||
{ PyObject_HEAD_INIT(type) (size) },
|
||||
|
||||
/* PyObject_VAR_HEAD defines the initial segment of all variable-size
|
||||
* container objects. These end with a declaration of an array with 1
|
||||
|
|
@ -152,7 +152,7 @@ static inline int Py_IS_TYPE(PyObject *ob, PyTypeObject *type) {
|
|||
return Py_TYPE(ob) == type;
|
||||
}
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
|
||||
# define Py_IS_TYPE(ob, type) Py_IS_TYPE(_PyObject_CAST(ob), type)
|
||||
# define Py_IS_TYPE(ob, type) Py_IS_TYPE(_PyObject_CAST(ob), (type))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -160,7 +160,7 @@ static inline void Py_SET_REFCNT(PyObject *ob, Py_ssize_t refcnt) {
|
|||
ob->ob_refcnt = refcnt;
|
||||
}
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
|
||||
# define Py_SET_REFCNT(ob, refcnt) Py_SET_REFCNT(_PyObject_CAST(ob), refcnt)
|
||||
# define Py_SET_REFCNT(ob, refcnt) Py_SET_REFCNT(_PyObject_CAST(ob), (refcnt))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ static inline void Py_SET_SIZE(PyVarObject *ob, Py_ssize_t size) {
|
|||
ob->ob_size = size;
|
||||
}
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
|
||||
# define Py_SET_SIZE(ob, size) Py_SET_SIZE(_PyVarObject_CAST(ob), size)
|
||||
# define Py_SET_SIZE(ob, size) Py_SET_SIZE(_PyVarObject_CAST(ob), (size))
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -268,7 +268,7 @@ static inline int PyObject_TypeCheck(PyObject *ob, PyTypeObject *type) {
|
|||
return Py_IS_TYPE(ob, type) || PyType_IsSubtype(Py_TYPE(ob), type);
|
||||
}
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
|
||||
# define PyObject_TypeCheck(ob, type) PyObject_TypeCheck(_PyObject_CAST(ob), type)
|
||||
# define PyObject_TypeCheck(ob, type) PyObject_TypeCheck(_PyObject_CAST(ob), (type))
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyType_Type; /* built-in 'type' */
|
||||
|
|
@ -779,7 +779,7 @@ PyType_HasFeature(PyTypeObject *type, unsigned long feature)
|
|||
return ((flags & feature) != 0);
|
||||
}
|
||||
|
||||
#define PyType_FastSubclass(type, flag) PyType_HasFeature(type, flag)
|
||||
#define PyType_FastSubclass(type, flag) PyType_HasFeature((type), (flag))
|
||||
|
||||
static inline int PyType_Check(PyObject *op) {
|
||||
return PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TYPE_SUBCLASS);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue