summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-05-24 18:47:47 (GMT)
committerGuido van Rossum <guido@python.org>2002-05-24 18:47:47 (GMT)
commit9ee4b94f51d19a37db3b93222b5e15c8379db78d (patch)
tree7ecb855f821fea6737c2dae7abf3f8992ca15d0b /Objects
parent4b46c0a15f1bdb8987ce78c0ded40dbc92b6e03e (diff)
downloadcpython-9ee4b94f51d19a37db3b93222b5e15c8379db78d.zip
cpython-9ee4b94f51d19a37db3b93222b5e15c8379db78d.tar.gz
cpython-9ee4b94f51d19a37db3b93222b5e15c8379db78d.tar.bz2
Add a safeguard against setting the class to something with a
different free or alloc slot.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 9a20fa4..61cbeae 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -1622,6 +1622,16 @@ object_set_class(PyObject *self, PyObject *value, void *closure)
return -1;
}
new = (PyTypeObject *)value;
+ if (new->tp_dealloc != old->tp_dealloc ||
+ new->tp_free != old->tp_free)
+ {
+ PyErr_Format(PyExc_TypeError,
+ "__class__ assignment: "
+ "'%s' deallocator differs from '%s'",
+ new->tp_name,
+ old->tp_name);
+ return -1;
+ }
newbase = new;
oldbase = old;
while (equiv_structs(newbase, newbase->tp_base))