forked from QubesOS/qubes-vmm-xen
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpatch-0004-python-initialize-specific-fields-of-PyTypeObject.patch
139 lines (131 loc) · 6.27 KB
/
patch-0004-python-initialize-specific-fields-of-PyTypeObject.patch
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
From 38ceb1e28c1d2f794fd616fb8b33a3b303eba68a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?=
Date: Fri, 17 Feb 2017 03:31:13 +0100
Subject: [PATCH 4/7] python: initialize specific fields of PyTypeObject
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Organization: Invisible Things Lab
Cc: Marek Marczykowski-Górecki <[email protected]>
Fields not named here will be zero-initialized anyway, but using this
way will be much easier to support both Python2 and Python3.
Signed-off-by: Marek Marczykowski-Górecki <[email protected]>
---
tools/python/xen/lowlevel/xc/xc.c | 47 ++++++++-------------------------------
tools/python/xen/lowlevel/xs/xs.c | 47 ++++++++-------------------------------
2 files changed, 18 insertions(+), 76 deletions(-)
diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c
index 75842ef..bcbb7b0 100644
--- a/tools/python/xen/lowlevel/xc/xc.c
+++ b/tools/python/xen/lowlevel/xc/xc.c
@@ -2675,44 +2675,15 @@ static void PyXc_dealloc(XcObject *self)
static PyTypeObject PyXcType = {
PyObject_HEAD_INIT(NULL)
- 0,
- PKG "." CLS,
- sizeof(XcObject),
- 0,
- (destructor)PyXc_dealloc, /* tp_dealloc */
- NULL, /* tp_print */
- NULL, /* tp_getattr */
- NULL, /* tp_setattr */
- NULL, /* tp_compare */
- NULL, /* tp_repr */
- NULL, /* tp_as_number */
- NULL, /* tp_as_sequence */
- NULL, /* tp_as_mapping */
- NULL, /* tp_hash */
- NULL, /* tp_call */
- NULL, /* tp_str */
- NULL, /* tp_getattro */
- NULL, /* tp_setattro */
- NULL, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- "Xen client connections", /* tp_doc */
- NULL, /* tp_traverse */
- NULL, /* tp_clear */
- NULL, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- NULL, /* tp_iter */
- NULL, /* tp_iternext */
- pyxc_methods, /* tp_methods */
- NULL, /* tp_members */
- NULL, /* tp_getset */
- NULL, /* tp_base */
- NULL, /* tp_dict */
- NULL, /* tp_descr_get */
- NULL, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)PyXc_init, /* tp_init */
- NULL, /* tp_alloc */
- PyXc_new, /* tp_new */
+ .tp_name = PKG "." CLS,
+ .tp_basicsize = sizeof(XcObject),
+ .tp_itemsize = 0,
+ .tp_dealloc = (destructor)PyXc_dealloc,
+ .tp_flags = Py_TPFLAGS_DEFAULT,
+ .tp_doc = "Xen client connections",
+ .tp_methods = pyxc_methods,
+ .tp_init = (initproc)PyXc_init,
+ .tp_new = PyXc_new,
};
static PyMethodDef xc_methods[] = { { NULL } };
diff --git a/tools/python/xen/lowlevel/xs/xs.c b/tools/python/xen/lowlevel/xs/xs.c
index 74a80ca..66ab08d 100644
--- a/tools/python/xen/lowlevel/xs/xs.c
+++ b/tools/python/xen/lowlevel/xs/xs.c
@@ -927,44 +927,15 @@ static void xshandle_dealloc(XsHandle *self)
static PyTypeObject xshandle_type = {
PyObject_HEAD_INIT(NULL)
- 0,
- PKG "." CLS,
- sizeof(XsHandle),
- 0,
- (destructor)xshandle_dealloc, /* tp_dealloc */
- NULL, /* tp_print */
- NULL, /* tp_getattr */
- NULL, /* tp_setattr */
- NULL, /* tp_compare */
- NULL, /* tp_repr */
- NULL, /* tp_as_number */
- NULL, /* tp_as_sequence */
- NULL, /* tp_as_mapping */
- NULL, /* tp_hash */
- NULL, /* tp_call */
- NULL, /* tp_str */
- NULL, /* tp_getattro */
- NULL, /* tp_setattro */
- NULL, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
- "Xenstore connections", /* tp_doc */
- NULL, /* tp_traverse */
- NULL, /* tp_clear */
- NULL, /* tp_richcompare */
- 0, /* tp_weaklistoffset */
- NULL, /* tp_iter */
- NULL, /* tp_iternext */
- xshandle_methods, /* tp_methods */
- NULL, /* tp_members */
- NULL, /* tp_getset */
- NULL, /* tp_base */
- NULL, /* tp_dict */
- NULL, /* tp_descr_get */
- NULL, /* tp_descr_set */
- 0, /* tp_dictoffset */
- (initproc)xshandle_init, /* tp_init */
- NULL, /* tp_alloc */
- xshandle_new, /* tp_new */
+ .tp_name = PKG "." CLS,
+ .tp_basicsize = sizeof(XsHandle),
+ .tp_itemsize = 0,
+ .tp_dealloc = (destructor)xshandle_dealloc,
+ .tp_flags = Py_TPFLAGS_DEFAULT,
+ .tp_doc = "Xenstore connections",
+ .tp_methods = xshandle_methods,
+ .tp_init = (initproc)xshandle_init,
+ .tp_new = xshandle_new,
};
static PyMethodDef xs_methods[] = { { NULL } };
--
2.7.4