Skip to content

Commit 8c7ed01

Browse files
Issue #16991: Use PyObject_TypeCheck instead of PyObject_IsInstance.
1 parent 7aa5341 commit 8c7ed01

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Include/dictobject.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ PyAPI_DATA(PyTypeObject) PyDictValues_Type;
4545
#define PyDict_Check(op) \
4646
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS)
4747
#define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
48-
#define PyDictKeys_Check(op) (PyObject_IsInstance(op, (PyObject *)&PyDictKeys_Type))
49-
#define PyDictItems_Check(op) (PyObject_IsInstance(op, (PyObject *)&PyDictItems_Type))
50-
#define PyDictValues_Check(op) (PyObject_IsInstance(op, (PyObject *)&PyDictValues_Type))
48+
#define PyDictKeys_Check(op) PyObject_TypeCheck(op, &PyDictKeys_Type)
49+
#define PyDictItems_Check(op) PyObject_TypeCheck(op, &PyDictItems_Type)
50+
#define PyDictValues_Check(op) PyObject_TypeCheck(op, &PyDictValues_Type)
5151
/* This excludes Values, since they are not sets. */
5252
# define PyDictViewSet_Check(op) \
5353
(PyDictKeys_Check(op) || PyDictItems_Check(op))

Include/odictobject.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ PyAPI_DATA(PyTypeObject) PyODictValues_Type;
1919

2020
#endif /* Py_LIMITED_API */
2121

22-
#define PyODict_Check(op) PyObject_IsInstance(op, (PyObject *)&PyODict_Type)
22+
#define PyODict_Check(op) PyObject_TypeCheck(op, &PyODict_Type)
2323
#define PyODict_CheckExact(op) (Py_TYPE(op) == &PyODict_Type)
2424
#define PyODict_SIZE(op) ((PyDictObject *)op)->ma_used
2525
#define PyODict_HasKey(od, key) (PyMapping_HasKey(PyObject *)od, key)

0 commit comments

Comments
 (0)