summaryrefslogtreecommitdiffstats
path: root/Modules/_ctypes
diff options
context:
space:
mode:
authorDong-hee Na <donghee.na92@gmail.com>2020-02-17 10:09:15 (GMT)
committerGitHub <noreply@github.com>2020-02-17 10:09:15 (GMT)
commit1b55b65638254aa78b005fbf0b71fb02499f1852 (patch)
tree3c9a1a7b47443d75d73a57002ecb3a49ae88ce2c /Modules/_ctypes
parenta7847590f07655e794d7c62130aea245a110acef (diff)
downloadcpython-1b55b65638254aa78b005fbf0b71fb02499f1852.zip
cpython-1b55b65638254aa78b005fbf0b71fb02499f1852.tar.gz
cpython-1b55b65638254aa78b005fbf0b71fb02499f1852.tar.bz2
bpo-39573: Clean up modules and headers to use Py_IS_TYPE() function (GH-18521)
Diffstat (limited to 'Modules/_ctypes')
-rw-r--r--Modules/_ctypes/ctypes.h10
-rw-r--r--Modules/_ctypes/stgdict.c6
2 files changed, 8 insertions, 8 deletions
diff --git a/Modules/_ctypes/ctypes.h b/Modules/_ctypes/ctypes.h
index a93d573..1effccf 100644
--- a/Modules/_ctypes/ctypes.h
+++ b/Modules/_ctypes/ctypes.h
@@ -68,7 +68,7 @@ typedef struct {
ffi_type *atypes[1];
} CThunkObject;
extern PyTypeObject PyCThunk_Type;
-#define CThunk_CheckExact(v) (Py_TYPE(v) == &PyCThunk_Type)
+#define CThunk_CheckExact(v) Py_IS_TYPE(v, &PyCThunk_Type)
typedef struct {
/* First part identical to tagCDataObject */
@@ -102,7 +102,7 @@ typedef struct {
} PyCFuncPtrObject;
extern PyTypeObject PyCStgDict_Type;
-#define PyCStgDict_CheckExact(v) (Py_TYPE(v) == &PyCStgDict_Type)
+#define PyCStgDict_CheckExact(v) Py_IS_TYPE(v, &PyCStgDict_Type)
#define PyCStgDict_Check(v) PyObject_TypeCheck(v, &PyCStgDict_Type)
extern int PyCStructUnionType_update_stgdict(PyObject *fields, PyObject *type, int isStruct);
@@ -112,12 +112,12 @@ extern int PyObject_stginfo(PyObject *self, Py_ssize_t *psize, Py_ssize_t *palig
extern PyTypeObject PyCData_Type;
-#define CDataObject_CheckExact(v) (Py_TYPE(v) == &PyCData_Type)
+#define CDataObject_CheckExact(v) Py_IS_TYPE(v, &PyCData_Type)
#define CDataObject_Check(v) PyObject_TypeCheck(v, &PyCData_Type)
#define _CDataObject_HasExternalBuffer(v) ((v)->b_ptr != (char *)&(v)->b_value)
extern PyTypeObject PyCSimpleType_Type;
-#define PyCSimpleTypeObject_CheckExact(v) (Py_TYPE(v) == &PyCSimpleType_Type)
+#define PyCSimpleTypeObject_CheckExact(v) Py_IS_TYPE(v, &PyCSimpleType_Type)
#define PyCSimpleTypeObject_Check(v) PyObject_TypeCheck(v, &PyCSimpleType_Type)
extern PyTypeObject PyCField_Type;
@@ -314,7 +314,7 @@ struct tagPyCArgObject {
};
extern PyTypeObject PyCArg_Type;
-#define PyCArg_CheckExact(v) (Py_TYPE(v) == &PyCArg_Type)
+#define PyCArg_CheckExact(v) Py_IS_TYPE(v, &PyCArg_Type)
extern PyCArgObject *PyCArgObject_new(void);
extern PyObject *
diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c
index c8001a9..443951a 100644
--- a/Modules/_ctypes/stgdict.c
+++ b/Modules/_ctypes/stgdict.c
@@ -231,7 +231,7 @@ MakeFields(PyObject *type, CFieldObject *descr,
Py_DECREF(fieldlist);
return -1;
}
- if (Py_TYPE(fdescr) != &PyCField_Type) {
+ if (!Py_IS_TYPE(fdescr, &PyCField_Type)) {
PyErr_SetString(PyExc_TypeError, "unexpected type");
Py_DECREF(fdescr);
Py_DECREF(fieldlist);
@@ -254,7 +254,7 @@ MakeFields(PyObject *type, CFieldObject *descr,
Py_DECREF(fieldlist);
return -1;
}
- assert(Py_TYPE(new_descr) == &PyCField_Type);
+ assert(Py_IS_TYPE(new_descr, &PyCField_Type));
new_descr->size = fdescr->size;
new_descr->offset = fdescr->offset + offset;
new_descr->index = fdescr->index + index;
@@ -304,7 +304,7 @@ MakeAnonFields(PyObject *type)
Py_DECREF(anon_names);
return -1;
}
- if (Py_TYPE(descr) != &PyCField_Type) {
+ if (!Py_IS_TYPE(descr, &PyCField_Type)) {
PyErr_Format(PyExc_AttributeError,
"'%U' is specified in _anonymous_ but not in "
"_fields_",