]> granicus.if.org Git - python/commitdiff
The recent changes to super(), in particular supercheck(), broke when
authorGuido van Rossum <guido@python.org>
Tue, 18 Feb 2003 19:22:22 +0000 (19:22 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 18 Feb 2003 19:22:22 +0000 (19:22 +0000)
using super() for an instance in a metaclass situation.  Because the
class was a metaclass, the instance was a class, and hence the
PyType_Check() branch was taken.  But this branch didn't apply.  Make
it so that if this branch doesn't apply, the other branch is still
tried.  All tests pass.

Objects/typeobject.c

index eb2e08f40a03fac958929b664165c281dd84d0e8..52a98bcff9b5f2110ba68a972e0e904d06608e4f 100644 (file)
@@ -5170,16 +5170,14 @@ supercheck(PyTypeObject *type, PyObject *obj)
           This will allow using super() with a proxy for obj.
        */
 
-       if (PyType_Check(obj)) {
-               /* It's a new-style class */
-               if (PyType_IsSubtype((PyTypeObject *)obj, type)) {
-                       Py_INCREF(obj);
-                       return (PyTypeObject *)obj;
-               }
-               else
-                       goto fail;
+       /* Check for first bullet above (special case) */
+       if (PyType_Check(obj) && PyType_IsSubtype((PyTypeObject *)obj, type)) {
+               Py_INCREF(obj);
+               return (PyTypeObject *)obj;
        }
-       else if (PyType_IsSubtype(obj->ob_type, type)) {
+
+       /* Normal case */
+       if (PyType_IsSubtype(obj->ob_type, type)) {
                Py_INCREF(obj->ob_type);
                return obj->ob_type;
        }