Skip to content

Commit 7546914

Browse files
authored
gh-87347: Add parenthesis around PyXXX_Check() arguments (#92815)
1 parent 484b40b commit 7546914

34 files changed

+58
-58
lines changed

Include/boolobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extern "C" {
99

1010
PyAPI_DATA(PyTypeObject) PyBool_Type;
1111

12-
#define PyBool_Check(x) Py_IS_TYPE(x, &PyBool_Type)
12+
#define PyBool_Check(x) Py_IS_TYPE((x), &PyBool_Type)
1313

1414
/* Py_False and Py_True are the only two bools in existence.
1515
Don't forget to apply Py_INCREF() when returning either!!! */

Include/bytearrayobject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ PyAPI_DATA(PyTypeObject) PyByteArray_Type;
2121
PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type;
2222

2323
/* Type check macros */
24-
#define PyByteArray_Check(self) PyObject_TypeCheck(self, &PyByteArray_Type)
25-
#define PyByteArray_CheckExact(self) Py_IS_TYPE(self, &PyByteArray_Type)
24+
#define PyByteArray_Check(self) PyObject_TypeCheck((self), &PyByteArray_Type)
25+
#define PyByteArray_CheckExact(self) Py_IS_TYPE((self), &PyByteArray_Type)
2626

2727
/* Direct API functions */
2828
PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *);

Include/bytesobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ PyAPI_DATA(PyTypeObject) PyBytesIter_Type;
2929

3030
#define PyBytes_Check(op) \
3131
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_BYTES_SUBCLASS)
32-
#define PyBytes_CheckExact(op) Py_IS_TYPE(op, &PyBytes_Type)
32+
#define PyBytes_CheckExact(op) Py_IS_TYPE((op), &PyBytes_Type)
3333

3434
PyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t);
3535
PyAPI_FUNC(PyObject *) PyBytes_FromString(const char *);

Include/complexobject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ extern "C" {
1010

1111
PyAPI_DATA(PyTypeObject) PyComplex_Type;
1212

13-
#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
14-
#define PyComplex_CheckExact(op) Py_IS_TYPE(op, &PyComplex_Type)
13+
#define PyComplex_Check(op) PyObject_TypeCheck((op), &PyComplex_Type)
14+
#define PyComplex_CheckExact(op) Py_IS_TYPE((op), &PyComplex_Type)
1515

1616
PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag);
1717

Include/cpython/cellobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ typedef struct {
1515

1616
PyAPI_DATA(PyTypeObject) PyCell_Type;
1717

18-
#define PyCell_Check(op) Py_IS_TYPE(op, &PyCell_Type)
18+
#define PyCell_Check(op) Py_IS_TYPE((op), &PyCell_Type)
1919

2020
PyAPI_FUNC(PyObject *) PyCell_New(PyObject *);
2121
PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *);

Include/cpython/classobject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ typedef struct {
1919

2020
PyAPI_DATA(PyTypeObject) PyMethod_Type;
2121

22-
#define PyMethod_Check(op) Py_IS_TYPE(op, &PyMethod_Type)
22+
#define PyMethod_Check(op) Py_IS_TYPE((op), &PyMethod_Type)
2323

2424
PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *);
2525

@@ -40,7 +40,7 @@ typedef struct {
4040

4141
PyAPI_DATA(PyTypeObject) PyInstanceMethod_Type;
4242

43-
#define PyInstanceMethod_Check(op) Py_IS_TYPE(op, &PyInstanceMethod_Type)
43+
#define PyInstanceMethod_Check(op) Py_IS_TYPE((op), &PyInstanceMethod_Type)
4444

4545
PyAPI_FUNC(PyObject *) PyInstanceMethod_New(PyObject *);
4646
PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *);

Include/cpython/code.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ struct PyCodeObject _PyCode_DEF(1);
137137

138138
PyAPI_DATA(PyTypeObject) PyCode_Type;
139139

140-
#define PyCode_Check(op) Py_IS_TYPE(op, &PyCode_Type)
140+
#define PyCode_Check(op) Py_IS_TYPE((op), &PyCode_Type)
141141
#define PyCode_GetNumFree(op) ((op)->co_nfreevars)
142142
#define _PyCode_CODE(CO) ((_Py_CODEUNIT *)(CO)->co_code_adaptive)
143143
#define _PyCode_NBYTES(CO) (Py_SIZE(CO) * (Py_ssize_t)sizeof(_Py_CODEUNIT))

Include/cpython/context.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ PyAPI_DATA(PyTypeObject) PyContextToken_Type;
1515
typedef struct _pycontexttokenobject PyContextToken;
1616

1717

18-
#define PyContext_CheckExact(o) Py_IS_TYPE(o, &PyContext_Type)
19-
#define PyContextVar_CheckExact(o) Py_IS_TYPE(o, &PyContextVar_Type)
20-
#define PyContextToken_CheckExact(o) Py_IS_TYPE(o, &PyContextToken_Type)
18+
#define PyContext_CheckExact(o) Py_IS_TYPE((o), &PyContext_Type)
19+
#define PyContextVar_CheckExact(o) Py_IS_TYPE((o), &PyContextVar_Type)
20+
#define PyContextToken_CheckExact(o) Py_IS_TYPE((o), &PyContextToken_Type)
2121

2222

2323
PyAPI_FUNC(PyObject *) PyContext_New(void);

Include/cpython/frameobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
PyAPI_DATA(PyTypeObject) PyFrame_Type;
1010

11-
#define PyFrame_Check(op) Py_IS_TYPE(op, &PyFrame_Type)
11+
#define PyFrame_Check(op) Py_IS_TYPE((op), &PyFrame_Type)
1212

1313
PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *,
1414
PyObject *, PyObject *);

Include/cpython/funcobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ typedef struct {
6060

6161
PyAPI_DATA(PyTypeObject) PyFunction_Type;
6262

63-
#define PyFunction_Check(op) Py_IS_TYPE(op, &PyFunction_Type)
63+
#define PyFunction_Check(op) Py_IS_TYPE((op), &PyFunction_Type)
6464

6565
PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *);
6666
PyAPI_FUNC(PyObject *) PyFunction_NewWithQualName(PyObject *, PyObject *, PyObject *);

0 commit comments

Comments
 (0)