From: Mark Wooding Date: Wed, 25 Oct 2006 18:36:19 +0000 (+0100) Subject: General: Update for Python 2.5. X-Git-Url: https://git.distorted.org.uk/~mdw/pyke/commitdiff_plain/d4a9e7e71495a1180062371cbac5353795d1fe47 General: Update for Python 2.5. * This renamed the members of heap types. so there's a compatibility macro now. * Debian has moved on to Python 2.4 as its standard version, so track that. * Also provide Python 2.5 packages now that we can. --- diff --git a/catacomb-python.h b/catacomb-python.h index 722d7ad..79034af 100644 --- a/catacomb-python.h +++ b/catacomb-python.h @@ -152,6 +152,11 @@ return (0); \ } +#if PY_VERSION_HEX < 0x02050000 /* Compatibility hack */ +# define ht_name name +# define ht_type type +#endif + #define root_pytype 0 #define type_pytype &PyType_Type #define INITTYPE(ty, base) do { \ diff --git a/util.c b/util.c index 1739ebe..7201401 100644 --- a/util.c +++ b/util.c @@ -145,13 +145,13 @@ void *newtype(PyTypeObject *metaty, (PyHeapTypeObject *)_PyObject_GC_Malloc(_PyObject_VAR_SIZE(metaty, 0)); if (!skel) skel = &emptytype; memcpy(ty, skel, sizeof(*skel)); - if (ty->type.tp_base) Py_INCREF(ty->type.tp_base); + if (ty->ht_type.tp_base) Py_INCREF(ty->ht_type.tp_base); #define COPY(blah) do { \ - if (ty->type.tp_as_##blah) { \ + if (ty->ht_type.tp_as_##blah) { \ memcpy(&ty->as_##blah, \ - ty->type.tp_as_##blah, \ + ty->ht_type.tp_as_##blah, \ sizeof(ty->as_##blah)); \ - ty->type.tp_as_##blah = &ty->as_##blah; \ + ty->ht_type.tp_as_##blah = &ty->as_##blah; \ } \ } while (0) COPY(number); @@ -160,12 +160,12 @@ void *newtype(PyTypeObject *metaty, COPY(buffer); #undef COPY if (name) - ty->name = PyString_FromString(name); - else if (ty->type.tp_name) - ty->name = PyString_FromString(ty->type.tp_name); - if (ty->name) - ty->type.tp_name = PyString_AS_STRING(ty->name); - PyObject_INIT(&ty->type, metaty); + ty->ht_name = PyString_FromString(name); + else if (ty->ht_type.tp_name) + ty->ht_name = PyString_FromString(ty->ht_type.tp_name); + if (ty->ht_name) + ty->ht_type.tp_name = PyString_AS_STRING(ty->ht_name); + PyObject_INIT(&ty->ht_type, metaty); Py_INCREF(metaty); return (ty); }