diff options
author | Victor Stinner <vstinner@python.org> | 2020-02-07 09:17:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-07 09:17:07 +0100 |
commit | d2ec81a8c99796b51fb8c49b77a7fe369863226f (patch) | |
tree | d88e7cbe89f65366d5591338fbe59a71192950db /Modules/_ctypes | |
parent | daa9756cb6395323d6f291efe5c7d7fdc6b2e9d8 (diff) | |
download | cpython-git-d2ec81a8c99796b51fb8c49b77a7fe369863226f.tar.gz |
bpo-39573: Add Py_SET_TYPE() function (GH-18394)
Add Py_SET_TYPE() function to set the type of an object.
Diffstat (limited to 'Modules/_ctypes')
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 12 | ||||
-rw-r--r-- | Modules/_ctypes/ctypes.h | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index cb6e03f2ca..4747195c2e 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -5758,42 +5758,42 @@ PyInit__ctypes(void) if (PyType_Ready(&PyCData_Type) < 0) return NULL; - Py_TYPE(&Struct_Type) = &PyCStructType_Type; + Py_SET_TYPE(&Struct_Type, &PyCStructType_Type); Struct_Type.tp_base = &PyCData_Type; if (PyType_Ready(&Struct_Type) < 0) return NULL; Py_INCREF(&Struct_Type); PyModule_AddObject(m, "Structure", (PyObject *)&Struct_Type); - Py_TYPE(&Union_Type) = &UnionType_Type; + Py_SET_TYPE(&Union_Type, &UnionType_Type); Union_Type.tp_base = &PyCData_Type; if (PyType_Ready(&Union_Type) < 0) return NULL; Py_INCREF(&Union_Type); PyModule_AddObject(m, "Union", (PyObject *)&Union_Type); - Py_TYPE(&PyCPointer_Type) = &PyCPointerType_Type; + Py_SET_TYPE(&PyCPointer_Type, &PyCPointerType_Type); PyCPointer_Type.tp_base = &PyCData_Type; if (PyType_Ready(&PyCPointer_Type) < 0) return NULL; Py_INCREF(&PyCPointer_Type); PyModule_AddObject(m, "_Pointer", (PyObject *)&PyCPointer_Type); - Py_TYPE(&PyCArray_Type) = &PyCArrayType_Type; + Py_SET_TYPE(&PyCArray_Type, &PyCArrayType_Type); PyCArray_Type.tp_base = &PyCData_Type; if (PyType_Ready(&PyCArray_Type) < 0) return NULL; Py_INCREF(&PyCArray_Type); PyModule_AddObject(m, "Array", (PyObject *)&PyCArray_Type); - Py_TYPE(&Simple_Type) = &PyCSimpleType_Type; + Py_SET_TYPE(&Simple_Type, &PyCSimpleType_Type); Simple_Type.tp_base = &PyCData_Type; if (PyType_Ready(&Simple_Type) < 0) return NULL; Py_INCREF(&Simple_Type); PyModule_AddObject(m, "_SimpleCData", (PyObject *)&Simple_Type); - Py_TYPE(&PyCFuncPtr_Type) = &PyCFuncPtrType_Type; + Py_SET_TYPE(&PyCFuncPtr_Type, &PyCFuncPtrType_Type); PyCFuncPtr_Type.tp_base = &PyCData_Type; if (PyType_Ready(&PyCFuncPtr_Type) < 0) return NULL; diff --git a/Modules/_ctypes/ctypes.h b/Modules/_ctypes/ctypes.h index 351f996be0..a232a4bc83 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) ((v)->ob_type == &PyCThunk_Type) +#define CThunk_CheckExact(v) (Py_TYPE(v) == &PyCThunk_Type) typedef struct { /* First part identical to tagCDataObject */ |