]> granicus.if.org Git - python/commitdiff
PyType_Ready(): initialize the base class a bit earlier, so that if we
authorGuido van Rossum <guido@python.org>
Wed, 14 Aug 2002 17:26:30 +0000 (17:26 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 14 Aug 2002 17:26:30 +0000 (17:26 +0000)
copy the metatype from the base, the base actually has one!

Objects/typeobject.c

index 62f2822a84910ad25078966a49782106f53192e2..145923a2ca64b48e3cb5a6ec8f93fb5e9b40c7af 100644 (file)
@@ -2294,6 +2294,12 @@ PyType_Ready(PyTypeObject *type)
        if (base == NULL && type != &PyBaseObject_Type)
                base = type->tp_base = &PyBaseObject_Type;
 
+       /* Initialize the base class */
+       if (base && base->tp_dict == NULL) {
+               if (PyType_Ready(base) < 0)
+                       goto error;
+       }
+
        /* Initialize ob_type if NULL.  This means extensions that want to be
           compilable separately on Windows can call PyType_Ready() instead of
           initializing the ob_type field of their type objects. */
@@ -2312,12 +2318,6 @@ PyType_Ready(PyTypeObject *type)
                type->tp_bases = bases;
        }
 
-       /* Initialize the base class */
-       if (base && base->tp_dict == NULL) {
-               if (PyType_Ready(base) < 0)
-                       goto error;
-       }
-
        /* Initialize tp_dict */
        dict = type->tp_dict;
        if (dict == NULL) {