]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
I had the inheritance cycle stuff backwards. Oops!
authorMichael W. Hudson <mwh@python.net>
Wed, 27 Nov 2002 10:24:44 +0000 (10:24 +0000)
committerMichael W. Hudson <mwh@python.net>
Wed, 27 Nov 2002 10:24:44 +0000 (10:24 +0000)
Lib/test/test_descr.py
Objects/typeobject.c

index f77d6a478c87f7ae5957cbd5dff37f290552f0e8..dde165d251d4bb4576614753a503a619950526c3 100644 (file)
@@ -3452,6 +3452,7 @@ def mutable_bases():
         pass
     d = D()
     e = E()
+    D.__bases__ = (C,)
     D.__bases__ = (C2,)
     vereq(d.meth(), 1)
     vereq(e.meth(), 1)
@@ -3492,6 +3493,13 @@ def mutable_bases():
         # actually, we'll have crashed by here...
         raise TestFailed, "shouldn't be able to create inheritance cycles"
 
+    try:
+        D.__bases__ = (E,)
+    except TypeError:
+        pass
+    else:
+        raise TestFailed, "shouldn't be able to create inheritance cycles"
+
     # let's throw a classic class into the mix:
     class Classic:
         def meth2(self):
index a5779ef3fe2d4c2b7d2cf19f56e16d1c9329b98e..82237c870cd6d4f27f2b398166c7e837d4508199 100644 (file)
@@ -208,10 +208,12 @@ type_set_bases(PyTypeObject *type, PyObject *value, void *context)
                                type->tp_name, ob->ob_type->tp_name);
                        return -1;
                }
-               if (PyType_IsSubtype(type, (PyTypeObject*)ob)) {
-                       PyErr_SetString(PyExc_TypeError,
-               "a __bases__ item causes an inheritance cycle");
-                       return -1;
+               if (PyType_Check(ob)) {
+                       if (PyType_IsSubtype((PyTypeObject*)ob, type)) {
+                               PyErr_SetString(PyExc_TypeError,
+                       "a __bases__ item causes an inheritance cycle");
+                               return -1;
+                       }
                }
        }