]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
backport gvanrossum's patch:
authorAnthony Baxter <anthonybaxter@gmail.com>
Thu, 18 Apr 2002 05:11:50 +0000 (05:11 +0000)
committerAnthony Baxter <anthonybaxter@gmail.com>
Thu, 18 Apr 2002 05:11:50 +0000 (05:11 +0000)
SF bug #541883 (Vincent Fiack).

A stupid bug in object_set_class(): didn't check for value==NULL
before checking its type.

Bugfix candidate.

Original patches were:
python/dist/src/Objects/typeobject.c:2.142

Objects/typeobject.c

index 848e0a6137cc5982b30fffca9ac05fc3aae0ab67..74dfff94e8ffe98c51a12727b0f17f8c1d9593d0 100644 (file)
@@ -1589,6 +1589,11 @@ object_set_class(PyObject *self, PyObject *value, void *closure)
        PyTypeObject *old = self->ob_type;
        PyTypeObject *new, *newbase, *oldbase;
 
+       if (value == NULL) {
+               PyErr_SetString(PyExc_TypeError,
+                               "can't delete __class__ attribute");
+               return -1;
+       }
        if (!PyType_Check(value)) {
                PyErr_Format(PyExc_TypeError,
                  "__class__ must be set to new-style class, not '%s' object",