-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinheritance_issue_2.c
48 lines (39 loc) · 1.19 KB
/
inheritance_issue_2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <Python.h>
#include <structmember.h>
static PyModuleDef my_module = {
PyModuleDef_HEAD_INIT,
.m_name = "inheritance_issue_2",
.m_doc = "Reproducer for an issue involving type inheritance",
.m_size = -1,
};
static struct PyMemberDef my_property_members[] = {
{ "__doc__", T_OBJECT, 0, 0, NULL },
{ NULL, 0, 0, 0, NULL }
};
static PyType_Slot my_property_slots[] = {
{ Py_tp_base, NULL },
{ Py_tp_members, my_property_members },
{ 0, NULL }
};
static PyType_Spec my_property_spec = {
.name = "inheritance_issue_2.my_property",
.flags = Py_TPFLAGS_DEFAULT,
.slots = my_property_slots
};
PyMODINIT_FUNC
PyInit_inheritance_issue_2(void)
{
PyObject *m = PyModule_Create(&my_module);
if (m == NULL)
return NULL;
my_property_slots[0].pfunc = &PyProperty_Type;
my_property_spec.basicsize = PyProperty_Type.tp_basicsize + sizeof(PyObject *);
my_property_members[0].offset = PyProperty_Type.tp_basicsize;
PyObject *my_property = PyType_FromSpec(&my_property_spec);
if (PyModule_AddObject(m, "my_property", my_property) < 0) {
Py_DECREF(my_property);
Py_DECREF(m);
return NULL;
}
return m;
}