From: Guido van Rossum Date: Fri, 26 Apr 2002 00:53:34 +0000 (+0000) Subject: Make sure that tp_free frees the int the same way as tp_dealloc would. X-Git-Tag: v2.3c1~5790 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=93646981011b0795329888bf7d2d10097e899432;p=thirdparty%2FPython%2Fcpython.git Make sure that tp_free frees the int the same way as tp_dealloc would. This fixes the problem that Barry reported on python-dev: >>> 23000 .__class__ = bool crashes in the deallocator. This was because int inherited tp_free from object, which uses the default allocator. 2.2. Bugfix candidate. --- diff --git a/Objects/intobject.c b/Objects/intobject.c index 588620924060..58a6beb46ee5 100644 --- a/Objects/intobject.c +++ b/Objects/intobject.c @@ -130,6 +130,13 @@ int_dealloc(PyIntObject *v) v->ob_type->tp_free((PyObject *)v); } +static void +int_free(PyIntObject *v) +{ + v->ob_type = (struct _typeobject *)free_list; + free_list = v; +} + long PyInt_AsLong(register PyObject *op) { @@ -905,6 +912,7 @@ PyTypeObject PyInt_Type = { 0, /* tp_init */ 0, /* tp_alloc */ int_new, /* tp_new */ + (freefunc)int_free, /* tp_free */ }; void