Skip to content

Commit 9efda56

Browse files
committed
fix build on windows
1 parent d70ba69 commit 9efda56

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Modules/_ctypes/_ctypes.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,7 @@ 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")},
@@ -4426,6 +4427,7 @@ static PyTypeObject Struct_Type = {
44264427

44274428
static PyType_Slot union_type_slots[] = {
44284429
{Py_bf_getbuffer, PyCData_NewGetBuffer},
4430+
{Py_tp_doc, PyDoc_STR("Union base class")},
44294431
{Py_tp_traverse, PyCData_traverse},
44304432
{Py_tp_clear, PyCData_clear},
44314433
{Py_tp_init, Struct_init},
@@ -4436,7 +4438,8 @@ static PyType_Slot union_type_slots[] = {
44364438
static PyType_Spec union_type_spec = {
44374439
.name = "_ctypes.Union",
44384440
.basicsize = sizeof(CDataObject),
4439-
.flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
4441+
.flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
4442+
Py_TPFLAGS_IMMUTABLETYPE),
44404443
.slots = union_type_slots,
44414444
};
44424445

@@ -5603,6 +5606,7 @@ _ctypes_add_types(PyObject *mod)
56035606
TYPE_READY_BASE(&PyCSimpleType_Type, &PyType_Type);
56045607
TYPE_READY_BASE(&PyCFuncPtrType_Type, &PyType_Type);
56055608

5609+
union_type_type_slots[0].pfunc = &PyType_Type;
56065610
st->UnionType_Type = (PyTypeObject *)
56075611
PyType_FromModuleAndSpec(mod, &union_type_type_spec,
56085612
NULL);
@@ -5759,6 +5763,7 @@ _ctypes_traverse(PyObject *mod, visitproc visit, void *arg)
57595763
{
57605764
_ctypes_state *st = _PyModule_GetState(mod);
57615765
Py_VISIT(st->Union_Type);
5766+
Py_VISIT(st->UnionType_Type);
57625767
return 0;
57635768
}
57645769

@@ -5767,6 +5772,7 @@ _ctypes_clear(PyObject *mod)
57675772
{
57685773
_ctypes_state *st = _PyModule_GetState(mod);
57695774
Py_CLEAR(st->Union_Type);
5775+
Py_CLEAR(st->UnionType_Type);
57705776
return 0;
57715777
}
57725778

0 commit comments

Comments
 (0)