Skip to content

Commit b31905e

Browse files
committed
bpo-39573: Update PyXXX_CheckExact() APIs
Co-Author: Neil Schemenauer <[email protected]>
1 parent 42f1b0e commit b31905e

30 files changed

+46
-46
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_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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type;
3535

3636
/* Type check macros */
3737
#define PyByteArray_Check(self) PyObject_TypeCheck(self, &PyByteArray_Type)
38-
#define PyByteArray_CheckExact(self) (Py_TYPE(self) == &PyByteArray_Type)
38+
#define PyByteArray_CheckExact(self) Py_IS_TYPE(self, &PyByteArray_Type)
3939

4040
/* Direct API functions */
4141
PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *);

Include/bytesobject.h

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

4747
#define PyBytes_Check(op) \
4848
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_BYTES_SUBCLASS)
49-
#define PyBytes_CheckExact(op) (Py_TYPE(op) == &PyBytes_Type)
49+
#define PyBytes_CheckExact(op) Py_IS_TYPE(op, &PyBytes_Type)
5050

5151
PyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t);
5252
PyAPI_FUNC(PyObject *) PyBytes_FromString(const char *);

Include/cellobject.h

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

1414
PyAPI_DATA(PyTypeObject) PyCell_Type;
1515

16-
#define PyCell_Check(op) (Py_TYPE(op) == &PyCell_Type)
16+
#define PyCell_Check(op) Py_IS_TYPE(op, &PyCell_Type)
1717

1818
PyAPI_FUNC(PyObject *) PyCell_New(PyObject *);
1919
PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *);

Include/code.h

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

116116
PyAPI_DATA(PyTypeObject) PyCode_Type;
117117

118-
#define PyCode_Check(op) (Py_TYPE(op) == &PyCode_Type)
118+
#define PyCode_Check(op) Py_IS_TYPE(op, &PyCode_Type)
119119
#define PyCode_GetNumFree(op) (PyTuple_GET_SIZE((op)->co_freevars))
120120

121121
/* Public interface */

Include/complexobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ typedef struct {
3939
PyAPI_DATA(PyTypeObject) PyComplex_Type;
4040

4141
#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
42-
#define PyComplex_CheckExact(op) (Py_TYPE(op) == &PyComplex_Type)
42+
#define PyComplex_CheckExact(op) Py_IS_TYPE(op, &PyComplex_Type)
4343

4444
#ifndef Py_LIMITED_API
4545
PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);

Include/context.h

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

1919

20-
#define PyContext_CheckExact(o) (Py_TYPE(o) == &PyContext_Type)
21-
#define PyContextVar_CheckExact(o) (Py_TYPE(o) == &PyContextVar_Type)
22-
#define PyContextToken_CheckExact(o) (Py_TYPE(o) == &PyContextToken_Type)
20+
#define PyContext_CheckExact(o) Py_IS_TYPE(o, &PyContext_Type)
21+
#define PyContextVar_CheckExact(o) Py_IS_TYPE(o, &PyContextVar_Type)
22+
#define PyContextToken_CheckExact(o) Py_IS_TYPE(o, &PyContextToken_Type)
2323

2424

2525
PyAPI_FUNC(PyObject *) PyContext_New(void);

Include/datetime.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,19 +196,19 @@ static PyDateTime_CAPI *PyDateTimeAPI = NULL;
196196

197197
/* Macros for type checking when not building the Python core. */
198198
#define PyDate_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateType)
199-
#define PyDate_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateType)
199+
#define PyDate_CheckExact(op) Py_IS_TYPE(op, PyDateTimeAPI->DateType)
200200

201201
#define PyDateTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateTimeType)
202-
#define PyDateTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateTimeType)
202+
#define PyDateTime_CheckExact(op) Py_IS_TYPE(op, PyDateTimeAPI->DateTimeType)
203203

204204
#define PyTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TimeType)
205-
#define PyTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TimeType)
205+
#define PyTime_CheckExact(op) Py_IS_TYPE(op, PyDateTimeAPI->TimeType)
206206

207207
#define PyDelta_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DeltaType)
208-
#define PyDelta_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DeltaType)
208+
#define PyDelta_CheckExact(op) Py_IS_TYPE(op, PyDateTimeAPI->DeltaType)
209209

210210
#define PyTZInfo_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TZInfoType)
211-
#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TZInfoType)
211+
#define PyTZInfo_CheckExact(op) Py_IS_TYPE(op, PyDateTimeAPI->TZInfoType)
212212

213213

214214
/* Macros for accessing constructors in a simplified fashion. */

Include/dictobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ PyAPI_DATA(PyTypeObject) PyDict_Type;
1616

1717
#define PyDict_Check(op) \
1818
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS)
19-
#define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
19+
#define PyDict_CheckExact(op) Py_IS_TYPE(op, &PyDict_Type)
2020

2121
PyAPI_FUNC(PyObject *) PyDict_New(void);
2222
PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key);

Include/floatobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ typedef struct {
2121
PyAPI_DATA(PyTypeObject) PyFloat_Type;
2222

2323
#define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type)
24-
#define PyFloat_CheckExact(op) (Py_TYPE(op) == &PyFloat_Type)
24+
#define PyFloat_CheckExact(op) Py_IS_TYPE(op, &PyFloat_Type)
2525

2626
#ifdef Py_NAN
2727
#define Py_RETURN_NAN return PyFloat_FromDouble(Py_NAN)

Include/funcobject.h

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

4444
PyAPI_DATA(PyTypeObject) PyFunction_Type;
4545

46-
#define PyFunction_Check(op) (Py_TYPE(op) == &PyFunction_Type)
46+
#define PyFunction_Check(op) Py_IS_TYPE(op, &PyFunction_Type)
4747

4848
PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *);
4949
PyAPI_FUNC(PyObject *) PyFunction_NewWithQualName(PyObject *, PyObject *, PyObject *);

Include/genobject.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ typedef struct {
3838
PyAPI_DATA(PyTypeObject) PyGen_Type;
3939

4040
#define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type)
41-
#define PyGen_CheckExact(op) (Py_TYPE(op) == &PyGen_Type)
41+
#define PyGen_CheckExact(op) Py_IS_TYPE(op, &PyGen_Type)
4242

4343
PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *);
4444
PyAPI_FUNC(PyObject *) PyGen_NewWithQualName(struct _frame *,
@@ -58,7 +58,7 @@ typedef struct {
5858
PyAPI_DATA(PyTypeObject) PyCoro_Type;
5959
PyAPI_DATA(PyTypeObject) _PyCoroWrapper_Type;
6060

61-
#define PyCoro_CheckExact(op) (Py_TYPE(op) == &PyCoro_Type)
61+
#define PyCoro_CheckExact(op) Py_IS_TYPE(op, &PyCoro_Type)
6262
PyObject *_PyCoro_GetAwaitableIter(PyObject *o);
6363
PyAPI_FUNC(PyObject *) PyCoro_New(struct _frame *,
6464
PyObject *name, PyObject *qualname);
@@ -89,7 +89,7 @@ PyAPI_DATA(PyTypeObject) _PyAsyncGenAThrow_Type;
8989
PyAPI_FUNC(PyObject *) PyAsyncGen_New(struct _frame *,
9090
PyObject *name, PyObject *qualname);
9191

92-
#define PyAsyncGen_CheckExact(op) (Py_TYPE(op) == &PyAsyncGen_Type)
92+
#define PyAsyncGen_CheckExact(op) Py_IS_TYPE(op, &PyAsyncGen_Type)
9393

9494
PyObject *_PyAsyncGenValueWrapperNew(PyObject *);
9595

Include/internal/pycore_hamt.h

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

1010

11-
#define PyHamt_Check(o) (Py_TYPE(o) == &_PyHamt_Type)
11+
#define PyHamt_Check(o) Py_IS_TYPE(o, &_PyHamt_Type)
1212

1313

1414
/* Abstract tree node. */

Include/iterobject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ extern "C" {
88
PyAPI_DATA(PyTypeObject) PySeqIter_Type;
99
PyAPI_DATA(PyTypeObject) PyCallIter_Type;
1010

11-
#define PySeqIter_Check(op) (Py_TYPE(op) == &PySeqIter_Type)
11+
#define PySeqIter_Check(op) Py_IS_TYPE(op, &PySeqIter_Type)
1212

1313
PyAPI_FUNC(PyObject *) PySeqIter_New(PyObject *);
1414

1515

16-
#define PyCallIter_Check(op) (Py_TYPE(op) == &PyCallIter_Type)
16+
#define PyCallIter_Check(op) Py_IS_TYPE(op, &PyCallIter_Type)
1717

1818
PyAPI_FUNC(PyObject *) PyCallIter_New(PyObject *, PyObject *);
1919

Include/listobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ PyAPI_DATA(PyTypeObject) PyListRevIter_Type;
2323

2424
#define PyList_Check(op) \
2525
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LIST_SUBCLASS)
26-
#define PyList_CheckExact(op) (Py_TYPE(op) == &PyList_Type)
26+
#define PyList_CheckExact(op) Py_IS_TYPE(op, &PyList_Type)
2727

2828
PyAPI_FUNC(PyObject *) PyList_New(Py_ssize_t size);
2929
PyAPI_FUNC(Py_ssize_t) PyList_Size(PyObject *);

Include/memoryobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ PyAPI_DATA(PyTypeObject) _PyManagedBuffer_Type;
1111
#endif
1212
PyAPI_DATA(PyTypeObject) PyMemoryView_Type;
1313

14-
#define PyMemoryView_Check(op) (Py_TYPE(op) == &PyMemoryView_Type)
14+
#define PyMemoryView_Check(op) Py_IS_TYPE(op, &PyMemoryView_Type)
1515

1616
#ifndef Py_LIMITED_API
1717
/* Get a pointer to the memoryview's private copy of the exporter's buffer. */

Include/methodobject.h

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

1414
PyAPI_DATA(PyTypeObject) PyCFunction_Type;
1515

16-
#define PyCFunction_Check(op) (Py_TYPE(op) == &PyCFunction_Type)
16+
#define PyCFunction_Check(op) Py_IS_TYPE(op, &PyCFunction_Type)
1717

1818
typedef PyObject *(*PyCFunction)(PyObject *, PyObject *);
1919
typedef PyObject *(*_PyCFunctionFast) (PyObject *, PyObject *const *, Py_ssize_t);

Include/moduleobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ extern "C" {
1010
PyAPI_DATA(PyTypeObject) PyModule_Type;
1111

1212
#define PyModule_Check(op) PyObject_TypeCheck(op, &PyModule_Type)
13-
#define PyModule_CheckExact(op) (Py_TYPE(op) == &PyModule_Type)
13+
#define PyModule_CheckExact(op) Py_IS_TYPE(op, &PyModule_Type)
1414

1515
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
1616
PyAPI_FUNC(PyObject *) PyModule_NewObject(

Include/object.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ PyAPI_FUNC(void*) PyType_GetSlot(PyTypeObject*, int);
216216
/* Generic type check */
217217
PyAPI_FUNC(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *);
218218
#define PyObject_TypeCheck(ob, tp) \
219-
(Py_TYPE(ob) == (tp) || PyType_IsSubtype(Py_TYPE(ob), (tp)))
219+
(Py_IS_TYPE(ob, tp) || PyType_IsSubtype(Py_TYPE(ob), (tp)))
220220

221221
PyAPI_DATA(PyTypeObject) PyType_Type; /* built-in 'type' */
222222
PyAPI_DATA(PyTypeObject) PyBaseObject_Type; /* built-in 'object' */
@@ -628,7 +628,7 @@ static inline int _PyType_Check(PyObject *op) {
628628
#define PyType_Check(op) _PyType_Check(_PyObject_CAST(op))
629629

630630
static inline int _PyType_CheckExact(PyObject *op) {
631-
return (Py_TYPE(op) == &PyType_Type);
631+
return Py_IS_TYPE(op, &PyType_Type);
632632
}
633633
#define PyType_CheckExact(op) _PyType_CheckExact(_PyObject_CAST(op))
634634

Include/odictobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ PyAPI_DATA(PyTypeObject) PyODictItems_Type;
1919
PyAPI_DATA(PyTypeObject) PyODictValues_Type;
2020

2121
#define PyODict_Check(op) PyObject_TypeCheck(op, &PyODict_Type)
22-
#define PyODict_CheckExact(op) (Py_TYPE(op) == &PyODict_Type)
22+
#define PyODict_CheckExact(op) Py_IS_TYPE(op, &PyODict_Type)
2323
#define PyODict_SIZE(op) PyDict_GET_SIZE((op))
2424

2525
PyAPI_FUNC(PyObject *) PyODict_New(void);

Include/pycapsule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ PyAPI_DATA(PyTypeObject) PyCapsule_Type;
2222

2323
typedef void (*PyCapsule_Destructor)(PyObject *);
2424

25-
#define PyCapsule_CheckExact(op) (Py_TYPE(op) == &PyCapsule_Type)
25+
#define PyCapsule_CheckExact(op) Py_IS_TYPE(op, &PyCapsule_Type)
2626

2727

2828
PyAPI_FUNC(PyObject *) PyCapsule_New(

Include/rangeobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ PyAPI_DATA(PyTypeObject) PyRange_Type;
1919
PyAPI_DATA(PyTypeObject) PyRangeIter_Type;
2020
PyAPI_DATA(PyTypeObject) PyLongRangeIter_Type;
2121

22-
#define PyRange_Check(op) (Py_TYPE(op) == &PyRange_Type)
22+
#define PyRange_Check(op) Py_IS_TYPE(op, &PyRange_Type)
2323

2424
#ifdef __cplusplus
2525
}

Include/setobject.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,18 @@ PyAPI_FUNC(int) PySet_Discard(PyObject *set, PyObject *key);
8888
PyAPI_FUNC(PyObject *) PySet_Pop(PyObject *set);
8989
PyAPI_FUNC(Py_ssize_t) PySet_Size(PyObject *anyset);
9090

91-
#define PyFrozenSet_CheckExact(ob) (Py_TYPE(ob) == &PyFrozenSet_Type)
91+
#define PyFrozenSet_CheckExact(ob) Py_IS_TYPE(ob, &PyFrozenSet_Type)
9292
#define PyAnySet_CheckExact(ob) \
93-
(Py_TYPE(ob) == &PySet_Type || Py_TYPE(ob) == &PyFrozenSet_Type)
93+
(Py_IS_TYPE(ob, &PySet_Type) || Py_IS_TYPE(ob, &PyFrozenSet_Type))
9494
#define PyAnySet_Check(ob) \
95-
(Py_TYPE(ob) == &PySet_Type || Py_TYPE(ob) == &PyFrozenSet_Type || \
95+
(Py_IS_TYPE(ob, &PySet_Type) || Py_IS_TYPE(ob, &PyFrozenSet_Type) || \
9696
PyType_IsSubtype(Py_TYPE(ob), &PySet_Type) || \
9797
PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type))
9898
#define PySet_Check(ob) \
99-
(Py_TYPE(ob) == &PySet_Type || \
99+
(Py_IS_TYPE(ob, &PySet_Type) || \
100100
PyType_IsSubtype(Py_TYPE(ob), &PySet_Type))
101101
#define PyFrozenSet_Check(ob) \
102-
(Py_TYPE(ob) == &PyFrozenSet_Type || \
102+
(Py_IS_TYPE(ob, &PyFrozenSet_Type) || \
103103
PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type))
104104

105105
#ifdef __cplusplus

Include/sliceobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ typedef struct {
2828
PyAPI_DATA(PyTypeObject) PySlice_Type;
2929
PyAPI_DATA(PyTypeObject) PyEllipsis_Type;
3030

31-
#define PySlice_Check(op) (Py_TYPE(op) == &PySlice_Type)
31+
#define PySlice_Check(op) Py_IS_TYPE(op, &PySlice_Type)
3232

3333
PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop,
3434
PyObject* step);

Include/symtable.h

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

7070
PyAPI_DATA(PyTypeObject) PySTEntry_Type;
7171

72-
#define PySTEntry_Check(op) (Py_TYPE(op) == &PySTEntry_Type)
72+
#define PySTEntry_Check(op) Py_IS_TYPE(op, &PySTEntry_Type)
7373

7474
PyAPI_FUNC(int) PyST_GetScope(PySTEntryObject *, PyObject *);
7575

Include/traceback.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ PyAPI_FUNC(int) PyTraceBack_Print(PyObject *, PyObject *);
1313

1414
/* Reveal traceback type so we can typecheck traceback objects */
1515
PyAPI_DATA(PyTypeObject) PyTraceBack_Type;
16-
#define PyTraceBack_Check(v) (Py_TYPE(v) == &PyTraceBack_Type)
16+
#define PyTraceBack_Check(v) Py_IS_TYPE(v, &PyTraceBack_Type)
1717

1818

1919
#ifndef Py_LIMITED_API

Include/tupleobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ PyAPI_DATA(PyTypeObject) PyTupleIter_Type;
2525

2626
#define PyTuple_Check(op) \
2727
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TUPLE_SUBCLASS)
28-
#define PyTuple_CheckExact(op) (Py_TYPE(op) == &PyTuple_Type)
28+
#define PyTuple_CheckExact(op) Py_IS_TYPE(op, &PyTuple_Type)
2929

3030
PyAPI_FUNC(PyObject *) PyTuple_New(Py_ssize_t size);
3131
PyAPI_FUNC(Py_ssize_t) PyTuple_Size(PyObject *);

Include/unicodeobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type;
113113

114114
#define PyUnicode_Check(op) \
115115
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS)
116-
#define PyUnicode_CheckExact(op) (Py_TYPE(op) == &PyUnicode_Type)
116+
#define PyUnicode_CheckExact(op) Py_IS_TYPE(op, &PyUnicode_Type)
117117

118118
/* --- Constants ---------------------------------------------------------- */
119119

Include/weakrefobject.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType;
4646

4747
#define PyWeakref_CheckRef(op) PyObject_TypeCheck(op, &_PyWeakref_RefType)
4848
#define PyWeakref_CheckRefExact(op) \
49-
(Py_TYPE(op) == &_PyWeakref_RefType)
49+
Py_IS_TYPE(op, &_PyWeakref_RefType)
5050
#define PyWeakref_CheckProxy(op) \
51-
((Py_TYPE(op) == &_PyWeakref_ProxyType) || \
52-
(Py_TYPE(op) == &_PyWeakref_CallableProxyType))
51+
(Py_IS_TYPE(op, &_PyWeakref_ProxyType) || \
52+
Py_IS_TYPE(op, &_PyWeakref_CallableProxyType))
5353

5454
#define PyWeakref_Check(op) \
5555
(PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op))

Objects/genobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ gen_send_ex(PyGenObject *gen, PyObject *arg, int exc, int closing)
255255
if (PyCoro_CheckExact(gen)) {
256256
msg = "coroutine raised StopIteration";
257257
}
258-
else if PyAsyncGen_CheckExact(gen) {
258+
else if (PyAsyncGen_CheckExact(gen)) {
259259
msg = "async generator raised StopIteration";
260260
}
261261
_PyErr_FormatFromCause(PyExc_RuntimeError, "%s", msg);

0 commit comments

Comments
 (0)