[Python-checkins] python/nondist/sandbox/twister _random.c,1.5,1.6
rhettinger@users.sourceforge.net
rhettinger@users.sourceforge.net
Wed, 25 Dec 2002 21:14:36 -0800
Update of /cvsroot/python/python/nondist/sandbox/twister
In directory sc8-pr-cvs1:/tmp/cvs-serv6772
Modified Files:
_random.c
Log Message:
Types that are subclassable need a customer destructor.
Also, they have to be INCREFed when being added to the module dictionary.
So, now it all works in both the DEBUG and regular compilations, oh yeah!
Index: _random.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/twister/_random.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** _random.c 25 Dec 2002 23:48:04 -0000 1.5
--- _random.c 26 Dec 2002 05:14:33 -0000 1.6
***************
*** 419,422 ****
--- 419,428 ----
}
+ static void
+ random_dealloc(RandomObject *self)
+ {
+ self->ob_type->tp_free(self);
+ }
+
static PyMethodDef random_methods[] = {
{"random", (PyCFunction)random_random, METH_NOARGS,
***************
*** 444,448 ****
0, /*tp_itemsize*/
/* methods */
! (destructor)PyObject_Del, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
--- 450,454 ----
0, /*tp_itemsize*/
/* methods */
! (destructor)random_dealloc, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
***************
*** 496,499 ****
--- 502,506 ----
Random_Type.ob_type = &PyType_Type;
m = Py_InitModule3("_random", module_functions, module_doc);
+ Py_INCREF((PyObject *)&Random_Type);
PyModule_AddObject(m, "Random", (PyObject *)&Random_Type);
}