diff Objects/typeobject.c @ 23541:f6ded6efabcf legacy-trunk

Add a safeguard against setting the class to something with a different free or alloc slot.
author Guido van Rossum <guido@python.org>
date Fri, 24 May 2002 18:47:47 +0000
parents 70650ae1a2cf
children 1bf34f4394c5
line wrap: on
line diff
--- a/Objects/typeobject.c	Fri May 24 17:58:05 2002 +0000
+++ b/Objects/typeobject.c	Fri May 24 18:47:47 2002 +0000
@@ -1622,6 +1622,16 @@
 		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))