1 diff --git a/src/ieee1284module.c b/src/ieee1284module.c
2 index 23c1f29..c6d6928 100644
3 --- a/src/ieee1284module.c
4 +++ b/src/ieee1284module.c
5 @@ -52,33 +52,32 @@ Parport_dealloc (ParportObject *self)
8 ieee1284_unref (self->port);
10 - self->ob_type->tp_free ((PyObject *) self);
11 + Py_TYPE(self)->tp_free((PyObject *) self);
15 Parport_getname (ParportObject *self, void *closure)
17 - return PyString_FromString (self->port->name);
18 + return PyBytes_FromString (self->port->name);
22 Parport_getbase_addr (ParportObject *self, void *closure)
24 - return PyInt_FromLong (self->port->base_addr);
25 + return PyLong_FromLong (self->port->base_addr);
29 Parport_gethibase_addr (ParportObject *self, void *closure)
31 - return PyInt_FromLong (self->port->hibase_addr);
32 + return PyLong_FromLong (self->port->hibase_addr);
36 Parport_getfilename (ParportObject *self, void *closure)
38 if (self->port->filename)
39 - return PyString_FromString (self->port->filename);
40 + return PyBytes_FromString (self->port->filename);
44 @@ -168,7 +167,7 @@ Parport_get_deviceid (ParportObject *self, PyObject *args)
48 - return PyString_FromStringAndSize (buffer, r);
49 + return PyBytes_FromStringAndSize (buffer, r);
53 @@ -186,7 +185,7 @@ Parport_open (ParportObject *self, PyObject *args)
57 - return PyInt_FromLong (capabilities);
58 + return PyLong_FromLong (capabilities);
62 @@ -198,7 +197,7 @@ Parport_get_irq_fd (ParportObject *self)
66 - return PyInt_FromLong (fd);
67 + return PyLong_FromLong (fd);
71 @@ -213,7 +212,7 @@ Parport_clear_irq (ParportObject *self)
75 - return PyInt_FromLong (portcount);
76 + return PyLong_FromLong (portcount);
80 @@ -259,7 +258,7 @@ Parport_read_data (ParportObject *self)
84 - return PyInt_FromLong (r);
85 + return PyLong_FromLong (r);
89 @@ -301,7 +300,7 @@ Parport_read_status (ParportObject *self)
93 - return PyInt_FromLong (r);
94 + return PyLong_FromLong (r);
98 @@ -335,7 +334,7 @@ Parport_read_control (ParportObject *self)
102 - return PyInt_FromLong (r);
103 + return PyLong_FromLong (r);
107 @@ -452,7 +451,7 @@ Parport_##x (ParportObject *self, PyObject *args) \
111 - ret = PyString_FromStringAndSize (buffer, got); \
112 + ret = PyBytes_FromStringAndSize (buffer, got); \
116 @@ -480,7 +479,7 @@ Parport_##x (ParportObject *self, PyObject *args) \
120 - return PyInt_FromLong (wrote); \
121 + return PyLong_FromLong (wrote); \
124 #define WRITE_METHOD(x) \
125 @@ -581,44 +580,53 @@ WRITE_METHOD(ecp_write_addr)
127 static PyTypeObject ParportType = {
128 PyObject_HEAD_INIT(NULL)
130 - "ieee1284.Parport", /* tp_name */
131 - sizeof (ParportObject), /* tp_basicsize */
132 - 0, /* tp_itemsize */
133 - (destructor)Parport_dealloc, /* tp_dealloc */
135 - 0, /* tp_getattr */
136 - 0, /* tp_setattr */
137 - 0, /* tp_compare */
139 - 0, /* tp_as_number */
140 - 0, /* tp_as_sequence */
141 - 0, /* tp_as_mapping */
145 - 0, /* tp_getattro */
146 - 0, /* tp_setattro */
147 - 0, /* tp_as_buffer */
148 - Py_TPFLAGS_DEFAULT, /* tp_flags */
149 - "parallel port object", /* tp_doc */
150 - 0, /* tp_traverse */
152 - 0, /* tp_richcompare */
153 - 0, /* tp_weaklistoffset */
155 - 0, /* tp_iternext */
156 - Parport_methods, /* tp_methods */
157 - 0, /* tp_members */
158 - Parport_getseters, /* tp_getset */
161 - 0, /* tp_descr_get */
162 - 0, /* tp_descr_set */
163 - 0, /* tp_dictoffset */
164 - (initproc)Parport_init, /* tp_init */
166 - Parport_new, /* tp_new */
167 + "ieee1284.Parport", /* const char *tp_name; */
168 + sizeof (ParportObject), /* Py_ssize_t tp_basicsize */
169 + 0, /* Py_ssize_t tp_itemsize; */
170 + (destructor)Parport_dealloc, /* destructor tp_dealloc; */
171 + 0, /* printfunc tp_print; */
172 + 0, /* getattrfunc tp_getattr; */
173 + 0, /* setattrfunc tp_setattr; */
174 + 0, /* PyAsyncMethods *tp_as_async; */
175 + 0, /* reprfunc tp_repr; */
176 + 0, /* PyNumberMethods *tp_as_number; */
177 + 0, /* PySequenceMethods *tp_as_sequence; */
178 + 0, /* PyMappingMethods *tp_as_mapping; */
179 + 0, /* hashfunc tp_hash; */
180 + 0, /* ternaryfunc tp_call; */
181 + 0, /* reprfunc tp_str; */
182 + 0, /* getattrofunc tp_getattro; */
183 + 0, /* setattrofunc tp_setattro; */
184 + 0, /* PyBufferProcs *tp_as_buffer; */
185 + Py_TPFLAGS_DEFAULT, /* unsigned long tp_flags; */
186 + "parallel port object", /* const char *tp_doc; */
187 + 0, /* traverseproc tp_traverse; */
188 + 0, /* inquiry tp_clear; */
189 + 0, /* richcmpfunc tp_richcompare; */
190 + 0, /* Py_ssize_t tp_weaklistoffset; */
191 + 0, /* getiterfunc tp_iter; */
192 + 0, /* iternextfunc tp_iternext; */
193 + Parport_methods, /* struct PyMethodDef *tp_methods; */
194 + 0, /* struct PyMemberDef *tp_members; */
195 + Parport_getseters, /* struct PyGetSetDef *tp_getset; */
196 + 0, /* struct _typeobject *tp_base; */
197 + 0, /* PyObject *tp_dict; */
198 + 0, /* descrgetfunc tp_descr_get; */
199 + 0, /* descrsetfunc tp_descr_set; */
200 + 0, /* Py_ssize_t tp_dictoffset; */
201 + (initproc)Parport_init, /* initproc tp_init; */
202 + 0, /* allocfunc tp_alloc; */
203 + Parport_new, /* newfunc tp_new; */
204 + 0, /* freefunc tp_free; */
205 + 0, /* inquiry tp_is_gc; */
206 + 0, /* PyObject *tp_bases; */
207 + 0, /* PyObject *tp_mro; */
208 + 0, /* PyObject *tp_cache; */
209 + 0, /* PyObject *tp_subclasses; */
210 + 0, /* PyObject *tp_weaklist; */
211 + 0, /* destructor tp_del; */
212 + 0, /* unsigned int tp_version_tag; */
213 + 0 /* destructor tp_finalize; */
217 @@ -672,18 +680,30 @@ static PyMethodDef Ieee1284Methods[] = {
218 {NULL, NULL, 0, NULL}
221 +static struct PyModuleDef Ieee1284Module = {
222 + PyModuleDef_HEAD_INIT,
224 + NULL, /* documentation */
233 #ifndef PyMODINIT_FUNC
234 #define PyMODINIT_FUNC void
238 +PyInit_ieee1284module (void)
240 - PyObject *m = Py_InitModule ("ieee1284", Ieee1284Methods);
241 + PyObject *m = PyModule_Create (&Ieee1284Module);
242 PyObject *d = PyModule_GetDict (m);
245 if (PyType_Ready (&ParportType) < 0)
249 PyModule_AddObject (m, "Parport", (PyObject *) &ParportType);
251 @@ -693,7 +713,7 @@ initieee1284 (void)
253 #define CONSTANT(x) \
255 - c = PyInt_FromLong (x); \
256 + c = PyLong_FromLong (x); \
257 PyDict_SetItemString (d, #x, c); \
260 @@ -740,4 +760,6 @@ initieee1284 (void)
261 CONSTANT (F1284_SWE);
262 CONSTANT (F1284_RLE);
263 CONSTANT (F1284_FASTEPP);