]> granicus.if.org Git - python/commitdiff
Temporary stop-gap fix for dynamic classes, so they pass the test.
authorGuido van Rossum <guido@python.org>
Sun, 12 Aug 2001 03:43:35 +0000 (03:43 +0000)
committerGuido van Rossum <guido@python.org>
Sun, 12 Aug 2001 03:43:35 +0000 (03:43 +0000)
XXX This is not sufficient: if a dynamic class has no __repr__ method
(for instance), but later one is added, that doesn't add a tp_repr
slot, so repr() doesn't call the __repr__ method.  To make this work,
I'll have to add default implementations of several slots to 'object'.

XXX Also, dynamic types currently only inherit slots from their
dominant base.

Objects/typeobject.c

index 37d94918dce3209719d28e132566681466d80cec..098d591975e26fb9e5ada757038ce0a4a214b1f9 100644 (file)
@@ -1244,7 +1244,12 @@ PyType_Ready(PyTypeObject *type)
                inherit_special(type, type->tp_base);
 
        /* Initialize tp_dict properly */
-       if (!PyType_HasFeature(type, Py_TPFLAGS_DYNAMICTYPE)) {
+       if (PyType_HasFeature(type, Py_TPFLAGS_DYNAMICTYPE)) {
+               /* XXX This is not enough -- see checkin msg 2.30. */
+               if (type->tp_base != NULL)
+                       inherit_slots(type, type->tp_base);
+       }
+       else {
                /* For a static type, tp_dict is the consolidation
                   of the tp_defined of its bases in MRO. */
                Py_DECREF(type->tp_dict);