From 3bb0f370c4ca0fbd7e73b2d1fb391de4ea37813e Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sun, 15 May 2022 12:03:08 +0200 Subject: [PATCH] gh-87347: Add parenthesis around PyXXX_Check() arguments --- Include/boolobject.h | 2 +- Include/bytearrayobject.h | 4 ++-- Include/bytesobject.h | 2 +- Include/complexobject.h | 4 ++-- Include/cpython/cellobject.h | 2 +- Include/cpython/classobject.h | 4 ++-- Include/cpython/code.h | 2 +- Include/cpython/context.h | 6 +++--- Include/cpython/frameobject.h | 2 +- Include/cpython/funcobject.h | 2 +- Include/cpython/genobject.h | 8 ++++---- Include/cpython/methodobject.h | 4 ++-- Include/cpython/odictobject.h | 4 ++-- Include/cpython/picklebufobject.h | 2 +- Include/dictobject.h | 8 ++++---- Include/floatobject.h | 2 +- Include/internal/pycore_hamt.h | 2 +- Include/internal/pycore_symtable.h | 2 +- Include/internal/pycore_unionobject.h | 4 ++-- Include/iterobject.h | 4 ++-- Include/listobject.h | 2 +- Include/longobject.h | 2 +- Include/memoryobject.h | 2 +- Include/methodobject.h | 4 ++-- Include/moduleobject.h | 4 ++-- Include/py_curses.h | 2 +- Include/pycapsule.h | 2 +- Include/rangeobject.h | 2 +- Include/setobject.h | 10 +++++----- Include/sliceobject.h | 2 +- Include/traceback.h | 2 +- Include/tupleobject.h | 2 +- Include/unicodeobject.h | 2 +- Include/weakrefobject.h | 8 ++++---- 34 files changed, 58 insertions(+), 58 deletions(-) diff --git a/Include/boolobject.h b/Include/boolobject.h index 28068d1cbe5939..7dc8e0c266cea6 100644 --- a/Include/boolobject.h +++ b/Include/boolobject.h @@ -9,7 +9,7 @@ extern "C" { PyAPI_DATA(PyTypeObject) PyBool_Type; -#define PyBool_Check(x) Py_IS_TYPE(x, &PyBool_Type) +#define PyBool_Check(x) Py_IS_TYPE((x), &PyBool_Type) /* Py_False and Py_True are the only two bools in existence. Don't forget to apply Py_INCREF() when returning either!!! */ diff --git a/Include/bytearrayobject.h b/Include/bytearrayobject.h index ae2bde1c303565..3d53fdba643267 100644 --- a/Include/bytearrayobject.h +++ b/Include/bytearrayobject.h @@ -21,8 +21,8 @@ PyAPI_DATA(PyTypeObject) PyByteArray_Type; PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type; /* Type check macros */ -#define PyByteArray_Check(self) PyObject_TypeCheck(self, &PyByteArray_Type) -#define PyByteArray_CheckExact(self) Py_IS_TYPE(self, &PyByteArray_Type) +#define PyByteArray_Check(self) PyObject_TypeCheck((self), &PyByteArray_Type) +#define PyByteArray_CheckExact(self) Py_IS_TYPE((self), &PyByteArray_Type) /* Direct API functions */ PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *); diff --git a/Include/bytesobject.h b/Include/bytesobject.h index 4c4dc40d705d71..ee448cd02bdab3 100644 --- a/Include/bytesobject.h +++ b/Include/bytesobject.h @@ -29,7 +29,7 @@ PyAPI_DATA(PyTypeObject) PyBytesIter_Type; #define PyBytes_Check(op) \ PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_BYTES_SUBCLASS) -#define PyBytes_CheckExact(op) Py_IS_TYPE(op, &PyBytes_Type) +#define PyBytes_CheckExact(op) Py_IS_TYPE((op), &PyBytes_Type) PyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t); PyAPI_FUNC(PyObject *) PyBytes_FromString(const char *); diff --git a/Include/complexobject.h b/Include/complexobject.h index c7764e43803d65..ebe49a832f7414 100644 --- a/Include/complexobject.h +++ b/Include/complexobject.h @@ -10,8 +10,8 @@ extern "C" { PyAPI_DATA(PyTypeObject) PyComplex_Type; -#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type) -#define PyComplex_CheckExact(op) Py_IS_TYPE(op, &PyComplex_Type) +#define PyComplex_Check(op) PyObject_TypeCheck((op), &PyComplex_Type) +#define PyComplex_CheckExact(op) Py_IS_TYPE((op), &PyComplex_Type) PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag); diff --git a/Include/cpython/cellobject.h b/Include/cpython/cellobject.h index 344238a533563d..e2660b2a80480e 100644 --- a/Include/cpython/cellobject.h +++ b/Include/cpython/cellobject.h @@ -15,7 +15,7 @@ typedef struct { PyAPI_DATA(PyTypeObject) PyCell_Type; -#define PyCell_Check(op) Py_IS_TYPE(op, &PyCell_Type) +#define PyCell_Check(op) Py_IS_TYPE((op), &PyCell_Type) PyAPI_FUNC(PyObject *) PyCell_New(PyObject *); PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *); diff --git a/Include/cpython/classobject.h b/Include/cpython/classobject.h index 80df8842eb4f78..d748e2cab18b82 100644 --- a/Include/cpython/classobject.h +++ b/Include/cpython/classobject.h @@ -19,7 +19,7 @@ typedef struct { PyAPI_DATA(PyTypeObject) PyMethod_Type; -#define PyMethod_Check(op) Py_IS_TYPE(op, &PyMethod_Type) +#define PyMethod_Check(op) Py_IS_TYPE((op), &PyMethod_Type) PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *); @@ -40,7 +40,7 @@ typedef struct { PyAPI_DATA(PyTypeObject) PyInstanceMethod_Type; -#define PyInstanceMethod_Check(op) Py_IS_TYPE(op, &PyInstanceMethod_Type) +#define PyInstanceMethod_Check(op) Py_IS_TYPE((op), &PyInstanceMethod_Type) PyAPI_FUNC(PyObject *) PyInstanceMethod_New(PyObject *); PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *); diff --git a/Include/cpython/code.h b/Include/cpython/code.h index ba7324b48d8675..18e2e56739f75f 100644 --- a/Include/cpython/code.h +++ b/Include/cpython/code.h @@ -135,7 +135,7 @@ struct PyCodeObject _PyCode_DEF(1); PyAPI_DATA(PyTypeObject) PyCode_Type; -#define PyCode_Check(op) Py_IS_TYPE(op, &PyCode_Type) +#define PyCode_Check(op) Py_IS_TYPE((op), &PyCode_Type) #define PyCode_GetNumFree(op) ((op)->co_nfreevars) #define _PyCode_CODE(CO) ((_Py_CODEUNIT *)(CO)->co_code_adaptive) #define _PyCode_NBYTES(CO) (Py_SIZE(CO) * (Py_ssize_t)sizeof(_Py_CODEUNIT)) diff --git a/Include/cpython/context.h b/Include/cpython/context.h index 4db079f7633f48..9879fc7192ebb8 100644 --- a/Include/cpython/context.h +++ b/Include/cpython/context.h @@ -15,9 +15,9 @@ PyAPI_DATA(PyTypeObject) PyContextToken_Type; typedef struct _pycontexttokenobject PyContextToken; -#define PyContext_CheckExact(o) Py_IS_TYPE(o, &PyContext_Type) -#define PyContextVar_CheckExact(o) Py_IS_TYPE(o, &PyContextVar_Type) -#define PyContextToken_CheckExact(o) Py_IS_TYPE(o, &PyContextToken_Type) +#define PyContext_CheckExact(o) Py_IS_TYPE((o), &PyContext_Type) +#define PyContextVar_CheckExact(o) Py_IS_TYPE((o), &PyContextVar_Type) +#define PyContextToken_CheckExact(o) Py_IS_TYPE((o), &PyContextToken_Type) PyAPI_FUNC(PyObject *) PyContext_New(void); diff --git a/Include/cpython/frameobject.h b/Include/cpython/frameobject.h index 9cd711e43559a6..a509e2c5805687 100644 --- a/Include/cpython/frameobject.h +++ b/Include/cpython/frameobject.h @@ -8,7 +8,7 @@ PyAPI_DATA(PyTypeObject) PyFrame_Type; -#define PyFrame_Check(op) Py_IS_TYPE(op, &PyFrame_Type) +#define PyFrame_Check(op) Py_IS_TYPE((op), &PyFrame_Type) PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *, PyObject *, PyObject *); diff --git a/Include/cpython/funcobject.h b/Include/cpython/funcobject.h index 99ac6008f8b611..8776bf0ac528ea 100644 --- a/Include/cpython/funcobject.h +++ b/Include/cpython/funcobject.h @@ -60,7 +60,7 @@ typedef struct { PyAPI_DATA(PyTypeObject) PyFunction_Type; -#define PyFunction_Check(op) Py_IS_TYPE(op, &PyFunction_Type) +#define PyFunction_Check(op) Py_IS_TYPE((op), &PyFunction_Type) PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *); PyAPI_FUNC(PyObject *) PyFunction_NewWithQualName(PyObject *, PyObject *, PyObject *); diff --git a/Include/cpython/genobject.h b/Include/cpython/genobject.h index 40eaa19d3fad94..6127ba7babb80f 100644 --- a/Include/cpython/genobject.h +++ b/Include/cpython/genobject.h @@ -37,8 +37,8 @@ typedef struct { PyAPI_DATA(PyTypeObject) PyGen_Type; -#define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type) -#define PyGen_CheckExact(op) Py_IS_TYPE(op, &PyGen_Type) +#define PyGen_Check(op) PyObject_TypeCheck((op), &PyGen_Type) +#define PyGen_CheckExact(op) Py_IS_TYPE((op), &PyGen_Type) PyAPI_FUNC(PyObject *) PyGen_New(PyFrameObject *); PyAPI_FUNC(PyObject *) PyGen_NewWithQualName(PyFrameObject *, @@ -57,7 +57,7 @@ typedef struct { PyAPI_DATA(PyTypeObject) PyCoro_Type; PyAPI_DATA(PyTypeObject) _PyCoroWrapper_Type; -#define PyCoro_CheckExact(op) Py_IS_TYPE(op, &PyCoro_Type) +#define PyCoro_CheckExact(op) Py_IS_TYPE((op), &PyCoro_Type) PyAPI_FUNC(PyObject *) PyCoro_New(PyFrameObject *, PyObject *name, PyObject *qualname); @@ -76,7 +76,7 @@ PyAPI_DATA(PyTypeObject) _PyAsyncGenAThrow_Type; PyAPI_FUNC(PyObject *) PyAsyncGen_New(PyFrameObject *, PyObject *name, PyObject *qualname); -#define PyAsyncGen_CheckExact(op) Py_IS_TYPE(op, &PyAsyncGen_Type) +#define PyAsyncGen_CheckExact(op) Py_IS_TYPE((op), &PyAsyncGen_Type) #undef _PyGenObject_HEAD diff --git a/Include/cpython/methodobject.h b/Include/cpython/methodobject.h index 54a61cfd077be9..83f54dc54eadb9 100644 --- a/Include/cpython/methodobject.h +++ b/Include/cpython/methodobject.h @@ -31,8 +31,8 @@ typedef struct { PyAPI_DATA(PyTypeObject) PyCMethod_Type; -#define PyCMethod_CheckExact(op) Py_IS_TYPE(op, &PyCMethod_Type) -#define PyCMethod_Check(op) PyObject_TypeCheck(op, &PyCMethod_Type) +#define PyCMethod_CheckExact(op) Py_IS_TYPE((op), &PyCMethod_Type) +#define PyCMethod_Check(op) PyObject_TypeCheck((op), &PyCMethod_Type) /* Static inline functions for direct access to these values. diff --git a/Include/cpython/odictobject.h b/Include/cpython/odictobject.h index e070413017d801..ce54d4836c3d2e 100644 --- a/Include/cpython/odictobject.h +++ b/Include/cpython/odictobject.h @@ -18,8 +18,8 @@ PyAPI_DATA(PyTypeObject) PyODictKeys_Type; PyAPI_DATA(PyTypeObject) PyODictItems_Type; PyAPI_DATA(PyTypeObject) PyODictValues_Type; -#define PyODict_Check(op) PyObject_TypeCheck(op, &PyODict_Type) -#define PyODict_CheckExact(op) Py_IS_TYPE(op, &PyODict_Type) +#define PyODict_Check(op) PyObject_TypeCheck((op), &PyODict_Type) +#define PyODict_CheckExact(op) Py_IS_TYPE((op), &PyODict_Type) #define PyODict_SIZE(op) PyDict_GET_SIZE((op)) PyAPI_FUNC(PyObject *) PyODict_New(void); diff --git a/Include/cpython/picklebufobject.h b/Include/cpython/picklebufobject.h index 0df2561dceaea0..f3cbaeef919518 100644 --- a/Include/cpython/picklebufobject.h +++ b/Include/cpython/picklebufobject.h @@ -12,7 +12,7 @@ extern "C" { PyAPI_DATA(PyTypeObject) PyPickleBuffer_Type; -#define PyPickleBuffer_Check(op) Py_IS_TYPE(op, &PyPickleBuffer_Type) +#define PyPickleBuffer_Check(op) Py_IS_TYPE((op), &PyPickleBuffer_Type) /* Create a PickleBuffer redirecting to the given buffer-enabled object */ PyAPI_FUNC(PyObject *) PyPickleBuffer_FromObject(PyObject *); diff --git a/Include/dictobject.h b/Include/dictobject.h index a6233d8ae2512a..e7fcb44d0cf9a9 100644 --- a/Include/dictobject.h +++ b/Include/dictobject.h @@ -16,7 +16,7 @@ PyAPI_DATA(PyTypeObject) PyDict_Type; #define PyDict_Check(op) \ PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS) -#define PyDict_CheckExact(op) Py_IS_TYPE(op, &PyDict_Type) +#define PyDict_CheckExact(op) Py_IS_TYPE((op), &PyDict_Type) PyAPI_FUNC(PyObject *) PyDict_New(void); PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key); @@ -67,9 +67,9 @@ PyAPI_DATA(PyTypeObject) PyDictKeys_Type; PyAPI_DATA(PyTypeObject) PyDictValues_Type; PyAPI_DATA(PyTypeObject) PyDictItems_Type; -#define PyDictKeys_Check(op) PyObject_TypeCheck(op, &PyDictKeys_Type) -#define PyDictValues_Check(op) PyObject_TypeCheck(op, &PyDictValues_Type) -#define PyDictItems_Check(op) PyObject_TypeCheck(op, &PyDictItems_Type) +#define PyDictKeys_Check(op) PyObject_TypeCheck((op), &PyDictKeys_Type) +#define PyDictValues_Check(op) PyObject_TypeCheck((op), &PyDictValues_Type) +#define PyDictItems_Check(op) PyObject_TypeCheck((op), &PyDictItems_Type) /* This excludes Values, since they are not sets. */ # define PyDictViewSet_Check(op) \ (PyDictKeys_Check(op) || PyDictItems_Check(op)) diff --git a/Include/floatobject.h b/Include/floatobject.h index 9d2fff3097e8ec..999441ac536e1d 100644 --- a/Include/floatobject.h +++ b/Include/floatobject.h @@ -14,7 +14,7 @@ extern "C" { PyAPI_DATA(PyTypeObject) PyFloat_Type; #define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type) -#define PyFloat_CheckExact(op) Py_IS_TYPE(op, &PyFloat_Type) +#define PyFloat_CheckExact(op) Py_IS_TYPE((op), &PyFloat_Type) #define Py_RETURN_NAN return PyFloat_FromDouble(Py_NAN) diff --git a/Include/internal/pycore_hamt.h b/Include/internal/pycore_hamt.h index 85e35c5afc90cf..f07497783a7ddd 100644 --- a/Include/internal/pycore_hamt.h +++ b/Include/internal/pycore_hamt.h @@ -23,7 +23,7 @@ void _PyHamt_Fini(PyInterpreterState *); /* other API */ -#define PyHamt_Check(o) Py_IS_TYPE(o, &_PyHamt_Type) +#define PyHamt_Check(o) Py_IS_TYPE((o), &_PyHamt_Type) /* Abstract tree node. */ diff --git a/Include/internal/pycore_symtable.h b/Include/internal/pycore_symtable.h index 28935f4ed55012..2d64aba22ff905 100644 --- a/Include/internal/pycore_symtable.h +++ b/Include/internal/pycore_symtable.h @@ -77,7 +77,7 @@ typedef struct _symtable_entry { extern PyTypeObject PySTEntry_Type; -#define PySTEntry_Check(op) Py_IS_TYPE(op, &PySTEntry_Type) +#define PySTEntry_Check(op) Py_IS_TYPE((op), &PySTEntry_Type) extern long _PyST_GetSymbol(PySTEntryObject *, PyObject *); extern int _PyST_GetScope(PySTEntryObject *, PyObject *); diff --git a/Include/internal/pycore_unionobject.h b/Include/internal/pycore_unionobject.h index a9ed5651a410e8..87264635b6e1cf 100644 --- a/Include/internal/pycore_unionobject.h +++ b/Include/internal/pycore_unionobject.h @@ -9,10 +9,10 @@ extern "C" { #endif extern PyTypeObject _PyUnion_Type; -#define _PyUnion_Check(op) Py_IS_TYPE(op, &_PyUnion_Type) +#define _PyUnion_Check(op) Py_IS_TYPE((op), &_PyUnion_Type) extern PyObject *_Py_union_type_or(PyObject *, PyObject *); -#define _PyGenericAlias_Check(op) PyObject_TypeCheck(op, &Py_GenericAliasType) +#define _PyGenericAlias_Check(op) PyObject_TypeCheck((op), &Py_GenericAliasType) extern PyObject *_Py_subs_parameters(PyObject *, PyObject *, PyObject *, PyObject *); extern PyObject *_Py_make_parameters(PyObject *); extern PyObject *_Py_union_args(PyObject *self); diff --git a/Include/iterobject.h b/Include/iterobject.h index 6454611aebef8a..fff30f7176fdeb 100644 --- a/Include/iterobject.h +++ b/Include/iterobject.h @@ -11,12 +11,12 @@ PyAPI_DATA(PyTypeObject) PyCallIter_Type; extern PyTypeObject _PyAnextAwaitable_Type; #endif -#define PySeqIter_Check(op) Py_IS_TYPE(op, &PySeqIter_Type) +#define PySeqIter_Check(op) Py_IS_TYPE((op), &PySeqIter_Type) PyAPI_FUNC(PyObject *) PySeqIter_New(PyObject *); -#define PyCallIter_Check(op) Py_IS_TYPE(op, &PyCallIter_Type) +#define PyCallIter_Check(op) Py_IS_TYPE((op), &PyCallIter_Type) PyAPI_FUNC(PyObject *) PyCallIter_New(PyObject *, PyObject *); diff --git a/Include/listobject.h b/Include/listobject.h index eff42c188f1ff1..6b7041ba0b05d5 100644 --- a/Include/listobject.h +++ b/Include/listobject.h @@ -23,7 +23,7 @@ PyAPI_DATA(PyTypeObject) PyListRevIter_Type; #define PyList_Check(op) \ PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LIST_SUBCLASS) -#define PyList_CheckExact(op) Py_IS_TYPE(op, &PyList_Type) +#define PyList_CheckExact(op) Py_IS_TYPE((op), &PyList_Type) PyAPI_FUNC(PyObject *) PyList_New(Py_ssize_t size); PyAPI_FUNC(Py_ssize_t) PyList_Size(PyObject *); diff --git a/Include/longobject.h b/Include/longobject.h index 81ba1239a69ecf..e559e238ae5a35 100644 --- a/Include/longobject.h +++ b/Include/longobject.h @@ -11,7 +11,7 @@ PyAPI_DATA(PyTypeObject) PyLong_Type; #define PyLong_Check(op) \ PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS) -#define PyLong_CheckExact(op) Py_IS_TYPE(op, &PyLong_Type) +#define PyLong_CheckExact(op) Py_IS_TYPE((op), &PyLong_Type) PyAPI_FUNC(PyObject *) PyLong_FromLong(long); PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long); diff --git a/Include/memoryobject.h b/Include/memoryobject.h index 154397ce1e56d2..19aec679a5fad1 100644 --- a/Include/memoryobject.h +++ b/Include/memoryobject.h @@ -11,7 +11,7 @@ PyAPI_DATA(PyTypeObject) _PyManagedBuffer_Type; #endif PyAPI_DATA(PyTypeObject) PyMemoryView_Type; -#define PyMemoryView_Check(op) Py_IS_TYPE(op, &PyMemoryView_Type) +#define PyMemoryView_Check(op) Py_IS_TYPE((op), &PyMemoryView_Type) #ifndef Py_LIMITED_API /* Get a pointer to the memoryview's private copy of the exporter's buffer. */ diff --git a/Include/methodobject.h b/Include/methodobject.h index c971d78a640a68..72af5ad933df7f 100644 --- a/Include/methodobject.h +++ b/Include/methodobject.h @@ -13,8 +13,8 @@ extern "C" { PyAPI_DATA(PyTypeObject) PyCFunction_Type; -#define PyCFunction_CheckExact(op) Py_IS_TYPE(op, &PyCFunction_Type) -#define PyCFunction_Check(op) PyObject_TypeCheck(op, &PyCFunction_Type) +#define PyCFunction_CheckExact(op) Py_IS_TYPE((op), &PyCFunction_Type) +#define PyCFunction_Check(op) PyObject_TypeCheck((op), &PyCFunction_Type) typedef PyObject *(*PyCFunction)(PyObject *, PyObject *); typedef PyObject *(*_PyCFunctionFast) (PyObject *, PyObject *const *, Py_ssize_t); diff --git a/Include/moduleobject.h b/Include/moduleobject.h index 75abd2cf2b9050..fbb2c5ae79444b 100644 --- a/Include/moduleobject.h +++ b/Include/moduleobject.h @@ -9,8 +9,8 @@ extern "C" { PyAPI_DATA(PyTypeObject) PyModule_Type; -#define PyModule_Check(op) PyObject_TypeCheck(op, &PyModule_Type) -#define PyModule_CheckExact(op) Py_IS_TYPE(op, &PyModule_Type) +#define PyModule_Check(op) PyObject_TypeCheck((op), &PyModule_Type) +#define PyModule_CheckExact(op) Py_IS_TYPE((op), &PyModule_Type) #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 PyAPI_FUNC(PyObject *) PyModule_NewObject( diff --git a/Include/py_curses.h b/Include/py_curses.h index b2c7f1bb4309c6..e46b08e9cc414e 100644 --- a/Include/py_curses.h +++ b/Include/py_curses.h @@ -64,7 +64,7 @@ typedef struct { char *encoding; } PyCursesWindowObject; -#define PyCursesWindow_Check(v) Py_IS_TYPE(v, &PyCursesWindow_Type) +#define PyCursesWindow_Check(v) Py_IS_TYPE((v), &PyCursesWindow_Type) #define PyCurses_CAPSULE_NAME "_curses._C_API" diff --git a/Include/pycapsule.h b/Include/pycapsule.h index fb5d503fea73f1..929a9a685259fb 100644 --- a/Include/pycapsule.h +++ b/Include/pycapsule.h @@ -22,7 +22,7 @@ PyAPI_DATA(PyTypeObject) PyCapsule_Type; typedef void (*PyCapsule_Destructor)(PyObject *); -#define PyCapsule_CheckExact(op) Py_IS_TYPE(op, &PyCapsule_Type) +#define PyCapsule_CheckExact(op) Py_IS_TYPE((op), &PyCapsule_Type) PyAPI_FUNC(PyObject *) PyCapsule_New( diff --git a/Include/rangeobject.h b/Include/rangeobject.h index d6af8473f9e8d3..d46ce7cd41b741 100644 --- a/Include/rangeobject.h +++ b/Include/rangeobject.h @@ -19,7 +19,7 @@ PyAPI_DATA(PyTypeObject) PyRange_Type; PyAPI_DATA(PyTypeObject) PyRangeIter_Type; PyAPI_DATA(PyTypeObject) PyLongRangeIter_Type; -#define PyRange_Check(op) Py_IS_TYPE(op, &PyRange_Type) +#define PyRange_Check(op) Py_IS_TYPE((op), &PyRange_Type) #ifdef __cplusplus } diff --git a/Include/setobject.h b/Include/setobject.h index fdad70644c545c..62c9e6b13f8901 100644 --- a/Include/setobject.h +++ b/Include/setobject.h @@ -20,21 +20,21 @@ PyAPI_FUNC(int) PySet_Discard(PyObject *set, PyObject *key); PyAPI_FUNC(PyObject *) PySet_Pop(PyObject *set); PyAPI_FUNC(Py_ssize_t) PySet_Size(PyObject *anyset); -#define PyFrozenSet_CheckExact(ob) Py_IS_TYPE(ob, &PyFrozenSet_Type) +#define PyFrozenSet_CheckExact(ob) Py_IS_TYPE((ob), &PyFrozenSet_Type) #define PyFrozenSet_Check(ob) \ - (Py_IS_TYPE(ob, &PyFrozenSet_Type) || \ + (Py_IS_TYPE((ob), &PyFrozenSet_Type) || \ PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type)) #define PyAnySet_CheckExact(ob) \ - (Py_IS_TYPE(ob, &PySet_Type) || Py_IS_TYPE(ob, &PyFrozenSet_Type)) + (Py_IS_TYPE((ob), &PySet_Type) || Py_IS_TYPE((ob), &PyFrozenSet_Type)) #define PyAnySet_Check(ob) \ - (Py_IS_TYPE(ob, &PySet_Type) || Py_IS_TYPE(ob, &PyFrozenSet_Type) || \ + (Py_IS_TYPE((ob), &PySet_Type) || Py_IS_TYPE((ob), &PyFrozenSet_Type) || \ PyType_IsSubtype(Py_TYPE(ob), &PySet_Type) || \ PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type)) #define PySet_CheckExact(op) Py_IS_TYPE(op, &PySet_Type) #define PySet_Check(ob) \ - (Py_IS_TYPE(ob, &PySet_Type) || \ + (Py_IS_TYPE((ob), &PySet_Type) || \ PyType_IsSubtype(Py_TYPE(ob), &PySet_Type)) #ifndef Py_LIMITED_API diff --git a/Include/sliceobject.h b/Include/sliceobject.h index 2c889508b4b495..c13863f27c2e63 100644 --- a/Include/sliceobject.h +++ b/Include/sliceobject.h @@ -28,7 +28,7 @@ typedef struct { PyAPI_DATA(PyTypeObject) PySlice_Type; PyAPI_DATA(PyTypeObject) PyEllipsis_Type; -#define PySlice_Check(op) Py_IS_TYPE(op, &PySlice_Type) +#define PySlice_Check(op) Py_IS_TYPE((op), &PySlice_Type) PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop, PyObject* step); diff --git a/Include/traceback.h b/Include/traceback.h index 2dfa2ada4f2c37..2b40cc9fc32617 100644 --- a/Include/traceback.h +++ b/Include/traceback.h @@ -11,7 +11,7 @@ PyAPI_FUNC(int) PyTraceBack_Print(PyObject *, PyObject *); /* Reveal traceback type so we can typecheck traceback objects */ PyAPI_DATA(PyTypeObject) PyTraceBack_Type; -#define PyTraceBack_Check(v) Py_IS_TYPE(v, &PyTraceBack_Type) +#define PyTraceBack_Check(v) Py_IS_TYPE((v), &PyTraceBack_Type) #ifndef Py_LIMITED_API diff --git a/Include/tupleobject.h b/Include/tupleobject.h index dc68e3fc5c6d88..1f9ab54be65f87 100644 --- a/Include/tupleobject.h +++ b/Include/tupleobject.h @@ -25,7 +25,7 @@ PyAPI_DATA(PyTypeObject) PyTupleIter_Type; #define PyTuple_Check(op) \ PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TUPLE_SUBCLASS) -#define PyTuple_CheckExact(op) Py_IS_TYPE(op, &PyTuple_Type) +#define PyTuple_CheckExact(op) Py_IS_TYPE((op), &PyTuple_Type) PyAPI_FUNC(PyObject *) PyTuple_New(Py_ssize_t size); PyAPI_FUNC(Py_ssize_t) PyTuple_Size(PyObject *); diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h index ed3e8d2c6cc99d..99b81eda2ef3ad 100644 --- a/Include/unicodeobject.h +++ b/Include/unicodeobject.h @@ -113,7 +113,7 @@ PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type; #define PyUnicode_Check(op) \ PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS) -#define PyUnicode_CheckExact(op) Py_IS_TYPE(op, &PyUnicode_Type) +#define PyUnicode_CheckExact(op) Py_IS_TYPE((op), &PyUnicode_Type) /* --- Constants ---------------------------------------------------------- */ diff --git a/Include/weakrefobject.h b/Include/weakrefobject.h index f071e9c759a641..8e1fa1b9286a77 100644 --- a/Include/weakrefobject.h +++ b/Include/weakrefobject.h @@ -12,12 +12,12 @@ PyAPI_DATA(PyTypeObject) _PyWeakref_RefType; PyAPI_DATA(PyTypeObject) _PyWeakref_ProxyType; PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType; -#define PyWeakref_CheckRef(op) PyObject_TypeCheck(op, &_PyWeakref_RefType) +#define PyWeakref_CheckRef(op) PyObject_TypeCheck((op), &_PyWeakref_RefType) #define PyWeakref_CheckRefExact(op) \ - Py_IS_TYPE(op, &_PyWeakref_RefType) + Py_IS_TYPE((op), &_PyWeakref_RefType) #define PyWeakref_CheckProxy(op) \ - (Py_IS_TYPE(op, &_PyWeakref_ProxyType) || \ - Py_IS_TYPE(op, &_PyWeakref_CallableProxyType)) + (Py_IS_TYPE((op), &_PyWeakref_ProxyType) \ + || Py_IS_TYPE((op), &_PyWeakref_CallableProxyType)) #define PyWeakref_Check(op) \ (PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op))