General: Update for Python 2.5.
authorMark Wooding <mdw@ncipher.com>
Wed, 25 Oct 2006 18:36:19 +0000 (19:36 +0100)
committerMark Wooding <mdw@ncipher.com>
Wed, 25 Oct 2006 18:36:19 +0000 (19:36 +0100)
  * 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.

catacomb-python.h
util.c

index 722d7ad..79034af 100644 (file)
     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 (file)
--- 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);
 }