]> granicus.if.org Git - python/commitdiff
Add a safeguard against setting the class to something with a
authorGuido van Rossum <guido@python.org>
Fri, 24 May 2002 18:47:47 +0000 (18:47 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 24 May 2002 18:47:47 +0000 (18:47 +0000)
different free or alloc slot.

Objects/typeobject.c

index 9a20fa4e049c590628ad11cd3804f2aae0711d72..61cbeae377782d9e96ba07149891658c45b36f9c 100644 (file)
@@ -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))