diff --git a/src/ieee1284module.c b/src/ieee1284module.c index 30972f8..265ab4b 100644 --- a/src/ieee1284module.c +++ b/src/ieee1284module.c @@ -28,6 +28,17 @@ typedef struct { struct parport *port; } ParportObject; +static PyObject * +Parport_new (PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + ParportObject *self; + self = (ParportObject *) type->tp_alloc (type, 0); + if (self != NULL) + self->port = NULL; + + return (PyObject *) self; +} + static int Parport_init (ParportObject *self, PyObject *args, PyObject *kwds) { @@ -562,6 +573,23 @@ static PyTypeObject ParportType = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT, /* tp_flags */ "parallel port object", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + Parport_methods, /* tp_methods */ + 0, /* tp_members */ + Parport_getseters, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + (initproc)Parport_init, /* tp_init */ + 0, /* tp_alloc */ + Parport_new, /* tp_new */ }; static PyObject * @@ -625,14 +653,9 @@ initieee1284 (void) PyObject *d = PyModule_GetDict (m); PyObject *c; - ParportType.tp_new = PyType_GenericNew; - ParportType.tp_init = (initproc) Parport_init; - ParportType.tp_getset = Parport_getseters; - ParportType.tp_methods = Parport_methods; if (PyType_Ready (&ParportType) < 0) return; - Py_INCREF (&ParportType); PyModule_AddObject (m, "Parport", (PyObject *) &ParportType); pyieee1284_error = PyErr_NewException("ieee1284.error", NULL, NULL);