SF bug #541883 (Vincent Fiack).
A stupid bug in object_set_class(): didn't check for value==NULL
before checking its type.
Bugfix candidate.
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index d290278..deb7320 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -1605,6 +1605,11 @@
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",