From: <ti...@co...> - 2009-07-24 19:04:42
|
Author: tismer Date: Fri Jul 24 21:07:54 2009 New Revision: 66610 Modified: psyco/v2/dist/c/Objects/compactobject.c Log: backward compatibility for heaptypes prior to 2.5 Modified: psyco/v2/dist/c/Objects/compactobject.c ============================================================================== --- psyco/v2/dist/c/Objects/compactobject.c (original) +++ psyco/v2/dist/c/Objects/compactobject.c Fri Jul 24 21:07:54 2009 @@ -540,7 +540,7 @@ /* For a heaptype, the instances count as references to the type. Traverse the type so the collector can find cycles involving this link. */ - Py_VISIT(type); + Py_VISIT((PyObject *) type); if (basetraverse) return basetraverse(self, visit, arg); @@ -720,10 +720,18 @@ return k_extend_impl(base, last->attrname, v); } +#if PY_VERSION_HEX < 0x02050000 /* before 2.5 */ +# define HEAPTYPE_SLOTS(et) ((et)->slots) +# define HEAPTYPE_TYPE(et) ((et)->type) +#else +# define HEAPTYPE_SLOTS(et) ((et)->ht_slots) +# define HEAPTYPE_TYPE(et) ((et)->ht_type) +#endif + #ifdef STACKLESS -# define HEAPTYPE_FLAGS(et) (et->tp_flags) +# define HEAPTYPE_FLAGS(et) ((et)->tp_flags) #else -# define HEAPTYPE_FLAGS(et) (et->ht_type.tp_flags) +# define HEAPTYPE_FLAGS(et) (HEAPTYPE_TYPE(et).tp_flags) #endif bool @@ -738,7 +746,7 @@ et = (PyHeapTypeObject *) PyTuple_GET_ITEM(mro, idx); if (!(HEAPTYPE_FLAGS(et) & Py_TPFLAGS_HEAPTYPE)) continue; - slotnames = et->ht_slots; + slotnames = HEAPTYPE_SLOTS(et); if (slotnames == NULL) continue; for (i = 0; i < PyTuple_GET_SIZE(slotnames); i++) { @@ -839,7 +847,7 @@ store_data: /* if we have defined __slots__, check for the attribute name */ if (ko->ob_type->tp_flags & Py_TPFLAGS_HEAPTYPE && - ((PyHeapTypeObject *) ko->ob_type)->ht_slots != NULL) { + (HEAPTYPE_SLOTS((PyHeapTypeObject *) ko->ob_type)) != NULL) { if (!k_find_slotname(ko->ob_type, attr)) { nobody: PyErr_Format(pyerr_notfound, @@ -1211,7 +1219,7 @@ /* save the slots, if any */ if (tp->tp_flags & Py_TPFLAGS_HEAPTYPE) - slots = ((PyHeapTypeObject *) tp)->ht_slots; + slots = HEAPTYPE_SLOTS((PyHeapTypeObject *) tp); /* now start over if there were slots */ if (slots != NULL) { @@ -1232,7 +1240,7 @@ if (tp != NULL) { PyHeapTypeObject *et = (PyHeapTypeObject *) tp; - et->ht_slots = slots; + HEAPTYPE_SLOTS(et) = slots; Py_INCREF(slots); } } @@ -1348,7 +1356,7 @@ return NULL; } /* save the slots, if any */ - slots = ((PyHeapTypeObject *) result)->ht_slots; + slots = HEAPTYPE_SLOTS((PyHeapTypeObject *) result); /* now start over if there were slots */ if (slots != NULL) { @@ -1367,7 +1375,7 @@ if (result != NULL) { PyHeapTypeObject *et = (PyHeapTypeObject *) result; - et->ht_slots = slots; + HEAPTYPE_SLOTS(et) = slots; Py_INCREF(slots); } } |