Oops, here's the (broken) patch.

Index: Objects/typeobject.c
===================================================================
--- Objects/typeobject.c	(revision 54928)
+++ Objects/typeobject.c	(working copy)
@@ -5625,16 +5625,33 @@
 super_init(PyObject *self, PyObject *args, PyObject *kwds)
 {
 	superobject *su = (superobject *)self;
-	PyTypeObject *type;
-	PyObject *obj = NULL;
-	PyTypeObject *obj_type = NULL;
+	PyObject     *arg1 = NULL, *arg2 = NULL;
+	PyTypeObject *type = NULL, *obj_type = NULL;
+	PyObject     *obj  = NULL;
 
 	if (!_PyArg_NoKeywords("super", kwds))
 		return -1;
-	if (!PyArg_ParseTuple(args, "O!|O:super", &PyType_Type, &type, &obj))
+	if (!PyArg_ParseTuple(args, "O|O:super", &arg1, &arg2))
 		return -1;
-	if (obj == Py_None)
-		obj = NULL;
+	if (arg2 == Py_None)
+		arg2 = NULL;
+	/* super(MyClass, self) */
+	if (arg2 != NULL) {
+		type = (PyTypeObject *)arg1;
+		obj = arg2;
+	}
+	else {
+		/* super(MyClass) */
+		if (PyObject_IsInstance(arg1, (PyObject *)&PyType_Type)) {
+			type = (PyTypeObject *)arg1;
+		}
+		/* super(self) */
+		else {
+			obj = arg1;
+			/* XXX: we must perform some magic to determine __this_class__ ... */
+			/* type = obj->ob_type; */
+		}
+	}
 	if (obj != NULL) {
 		obj_type = supercheck(type, obj);
 		if (obj_type == NULL)
@@ -5643,7 +5660,7 @@
 	}
 	Py_INCREF(type);
 	su->type = type;
-	su->obj = obj;
+	su->obj  = obj;
 	su->obj_type = obj_type;
 	return 0;
 }
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to