Skip to content

Commit d8c5f6c

Browse files
committed
fix build on windows
1 parent d70ba69 commit d8c5f6c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Modules/_ctypes/_ctypes.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -966,14 +966,14 @@ PyTypeObject PyCStructType_Type = {
966966
};
967967

968968
static PyType_Slot union_type_type_slots[] = {
969+
{Py_tp_base, NULL}, // filled out in module exec function
969970
{Py_sq_repeat, CDataType_repeat},
970971
{Py_tp_setattro, UnionType_setattro},
971972
{Py_tp_doc, PyDoc_STR("metatype for the CData Objects")},
972973
{Py_tp_traverse, CDataType_traverse},
973974
{Py_tp_clear, CDataType_clear},
974975
{Py_tp_methods, CDataType_methods},
975976
{Py_tp_new, UnionType_new},
976-
{Py_tp_base, &PyType_Type},
977977
{0, NULL},
978978
};
979979

@@ -4426,6 +4426,7 @@ static PyTypeObject Struct_Type = {
44264426

44274427
static PyType_Slot union_type_slots[] = {
44284428
{Py_bf_getbuffer, PyCData_NewGetBuffer},
4429+
{Py_tp_doc, PyDoc_STR("Union base class")},
44294430
{Py_tp_traverse, PyCData_traverse},
44304431
{Py_tp_clear, PyCData_clear},
44314432
{Py_tp_init, Struct_init},
@@ -4436,7 +4437,8 @@ static PyType_Slot union_type_slots[] = {
44364437
static PyType_Spec union_type_spec = {
44374438
.name = "_ctypes.Union",
44384439
.basicsize = sizeof(CDataObject),
4439-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
4440+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
4441+
Py_TPFLAGS_IMMUTABLETYPE),
44404442
.slots = union_type_slots,
44414443
};
44424444

@@ -5603,6 +5605,7 @@ _ctypes_add_types(PyObject *mod)
56035605
TYPE_READY_BASE(&PyCSimpleType_Type, &PyType_Type);
56045606
TYPE_READY_BASE(&PyCFuncPtrType_Type, &PyType_Type);
56055607

5608+
union_type_type_slots[0].pfunc = &PyType_Type;
56065609
st->UnionType_Type = (PyTypeObject *)
56075610
PyType_FromModuleAndSpec(mod, &union_type_type_spec,
56085611
NULL);
@@ -5759,6 +5762,7 @@ _ctypes_traverse(PyObject *mod, visitproc visit, void *arg)
57595762
{
57605763
_ctypes_state *st = _PyModule_GetState(mod);
57615764
Py_VISIT(st->Union_Type);
5765+
Py_VISIT(st->UnionType_Type);
57625766
return 0;
57635767
}
57645768

@@ -5767,6 +5771,7 @@ _ctypes_clear(PyObject *mod)
57675771
{
57685772
_ctypes_state *st = _PyModule_GetState(mod);
57695773
Py_CLEAR(st->Union_Type);
5774+
Py_CLEAR(st->UnionType_Type);
57705775
return 0;
57715776
}
57725777

0 commit comments

Comments
 (0)