diff options
author | Guido van Rossum <guido@python.org> | 2001-08-12 03:43:35 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-08-12 03:43:35 (GMT) |
commit | 8de8680d071df3bddcb5d56a06d11697a32a922e (patch) | |
tree | 3031808e4a4c939b423871b8d0b6c38b786b3525 | |
parent | 9d4fe4298ece1acf3401c6b4849d2cb56238d710 (diff) | |
download | cpython-8de8680d071df3bddcb5d56a06d11697a32a922e.zip cpython-8de8680d071df3bddcb5d56a06d11697a32a922e.tar.gz cpython-8de8680d071df3bddcb5d56a06d11697a32a922e.tar.bz2 |
Temporary stop-gap fix for dynamic classes, so they pass the test.
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.
-rw-r--r-- | Objects/typeobject.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 37d9491..098d591 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -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); |