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.

12 files changed:
algorithms.c
catacomb-python.h
debian/.gitignore
debian/control
debian/rules
ec.c
field.c
group.c
key.c
pwsafe
rand.c
util.c

index be953b0..de7ab75 100644 (file)
@@ -462,16 +462,16 @@ PyObject *gccipher_pywrap(gccipher *cc)
 {
   gccipher_pyobj *g = newtype(gccipher_pytype, 0, cc->name);
   g->cc = cc;
-  g->ty.type.tp_basicsize = sizeof(gcipher_pyobj);
-  g->ty.type.tp_base = gcipher_pytype;
+  g->ty.ht_type.tp_basicsize = sizeof(gcipher_pyobj);
+  g->ty.ht_type.tp_base = gcipher_pytype;
   Py_INCREF(gcipher_pytype);
-  g->ty.type.tp_flags = (Py_TPFLAGS_DEFAULT |
-                        Py_TPFLAGS_BASETYPE |
-                        Py_TPFLAGS_HEAPTYPE);
-  g->ty.type.tp_alloc = PyType_GenericAlloc;
-  g->ty.type.tp_free = 0;
-  g->ty.type.tp_new = gcipher_pynew;
-  PyType_Ready(&g->ty.type);
+  g->ty.ht_type.tp_flags = (Py_TPFLAGS_DEFAULT |
+                           Py_TPFLAGS_BASETYPE |
+                           Py_TPFLAGS_HEAPTYPE);
+  g->ty.ht_type.tp_alloc = PyType_GenericAlloc;
+  g->ty.ht_type.tp_free = 0;
+  g->ty.ht_type.tp_new = gcipher_pynew;
+  PyType_Ready(&g->ty.ht_type);
   return ((PyObject *)g);
 }
 
@@ -706,16 +706,16 @@ PyObject *gchash_pywrap(gchash *ch)
 {
   gchash_pyobj *g = newtype(gchash_pytype, 0, ch->name);
   g->ch = ch;
-  g->ty.type.tp_basicsize = sizeof(ghash_pyobj);
-  g->ty.type.tp_base = ghash_pytype;
+  g->ty.ht_type.tp_basicsize = sizeof(ghash_pyobj);
+  g->ty.ht_type.tp_base = ghash_pytype;
   Py_INCREF(ghash_pytype);
-  g->ty.type.tp_flags = (Py_TPFLAGS_DEFAULT |
-                        Py_TPFLAGS_BASETYPE |
-                        Py_TPFLAGS_HEAPTYPE);
-  g->ty.type.tp_alloc = PyType_GenericAlloc;
-  g->ty.type.tp_free = 0;
-  g->ty.type.tp_new = ghash_pynew;
-  PyType_Ready(&g->ty.type);
+  g->ty.ht_type.tp_flags = (Py_TPFLAGS_DEFAULT |
+                           Py_TPFLAGS_BASETYPE |
+                           Py_TPFLAGS_HEAPTYPE);
+  g->ty.ht_type.tp_alloc = PyType_GenericAlloc;
+  g->ty.ht_type.tp_free = 0;
+  g->ty.ht_type.tp_new = ghash_pynew;
+  PyType_Ready(&g->ty.ht_type);
   return ((PyObject *)g);
 }
 
@@ -961,16 +961,16 @@ PyObject *gcmac_pywrap(gcmac *cm)
 {
   gcmac_pyobj *g = newtype(gcmac_pytype, 0, cm->name);
   g->cm = cm;
-  g->ty.type.tp_basicsize = sizeof(gmac_pyobj);
-  g->ty.type.tp_base = gmac_pytype;
+  g->ty.ht_type.tp_basicsize = sizeof(gmac_pyobj);
+  g->ty.ht_type.tp_base = gmac_pytype;
   Py_INCREF(gmac_pytype);
-  g->ty.type.tp_flags = (Py_TPFLAGS_DEFAULT |
-                   Py_TPFLAGS_BASETYPE |
-                   Py_TPFLAGS_HEAPTYPE);
-  g->ty.type.tp_alloc = PyType_GenericAlloc;
-  g->ty.type.tp_free = 0;
-  g->ty.type.tp_new = gmac_pynew;
-  PyType_Ready(&g->ty.type);
+  g->ty.ht_type.tp_flags = (Py_TPFLAGS_DEFAULT |
+                           Py_TPFLAGS_BASETYPE |
+                           Py_TPFLAGS_HEAPTYPE);
+  g->ty.ht_type.tp_alloc = PyType_GenericAlloc;
+  g->ty.ht_type.tp_free = 0;
+  g->ty.ht_type.tp_new = gmac_pynew;
+  PyType_Ready(&g->ty.ht_type);
   return ((PyObject *)g);
 }
 
@@ -980,17 +980,17 @@ PyObject *gmac_pywrap(PyObject *cobj, gmac *m, unsigned f)
   if (!cobj) cobj = gcmac_pywrap((/*unconst*/ gcmac *)GM_CLASS(m));
   else Py_INCREF(cobj);
   g = newtype((PyTypeObject *)cobj, 0, 0);
-  g->ty.name = PyString_FromFormat("%s(keyed)", m->ops->c->name);
-  g->ty.type.tp_name = PyString_AS_STRING(g->ty.name);
-  g->ty.type.tp_base = gmhash_pytype;
+  g->ty.ht_name = PyString_FromFormat("%s(keyed)", m->ops->c->name);
+  g->ty.ht_type.tp_name = PyString_AS_STRING(g->ty.ht_name);
+  g->ty.ht_type.tp_base = gmhash_pytype;
   Py_INCREF(gmac_pytype);
-  g->ty.type.tp_flags = (Py_TPFLAGS_DEFAULT |
-                        Py_TPFLAGS_BASETYPE |
-                        Py_TPFLAGS_HEAPTYPE);
-  g->ty.type.tp_alloc = PyType_GenericAlloc;
-  g->ty.type.tp_free = 0;
-  g->ty.type.tp_new = gmhash_pynew;
-  PyType_Ready(&g->ty.type);
+  g->ty.ht_type.tp_flags = (Py_TPFLAGS_DEFAULT |
+                           Py_TPFLAGS_BASETYPE |
+                           Py_TPFLAGS_HEAPTYPE);
+  g->ty.ht_type.tp_alloc = PyType_GenericAlloc;
+  g->ty.ht_type.tp_free = 0;
+  g->ty.ht_type.tp_new = gmhash_pynew;
+  PyType_Ready(&g->ty.ht_type);
   g->m = m;
   g->f = f;
   return ((PyObject *)g);  
@@ -1250,16 +1250,16 @@ static PyObject *gcprp_pywrap(const prpinfo *prp)
 {
   gcprp_pyobj *g = newtype(gcprp_pytype, 0, prp->name);
   g->prp = prp;
-  g->ty.type.tp_basicsize = sizeof(gprp_pyobj) + prp->ctxsz;
-  g->ty.type.tp_base = gprp_pytype;
+  g->ty.ht_type.tp_basicsize = sizeof(gprp_pyobj) + prp->ctxsz;
+  g->ty.ht_type.tp_base = gprp_pytype;
   Py_INCREF(gprp_pytype);
-  g->ty.type.tp_flags = (Py_TPFLAGS_DEFAULT |
-                        Py_TPFLAGS_BASETYPE |
-                        Py_TPFLAGS_HEAPTYPE);
-  g->ty.type.tp_alloc = PyType_GenericAlloc;
-  g->ty.type.tp_free = 0;
-  g->ty.type.tp_new = gprp_pynew;
-  PyType_Ready(&g->ty.type);
+  g->ty.ht_type.tp_flags = (Py_TPFLAGS_DEFAULT |
+                           Py_TPFLAGS_BASETYPE |
+                           Py_TPFLAGS_HEAPTYPE);
+  g->ty.ht_type.tp_alloc = PyType_GenericAlloc;
+  g->ty.ht_type.tp_free = 0;
+  g->ty.ht_type.tp_new = gprp_pynew;
+  PyType_Ready(&g->ty.ht_type);
   return ((PyObject *)g);
 }
 
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 {                                                \
index 2a13289..e7fd938 100644 (file)
@@ -8,3 +8,4 @@ python-catacomb
 python2.3-catacomb
 python2.4-catacomb
 
+python2.5-catacomb
index d1ff042..a823632 100644 (file)
@@ -2,7 +2,7 @@ Source: python-catacomb
 Section: python
 Priority: extra
 Maintainer: Mark Wooding <mdw@distorted.org.uk>
-Build-Depends: catacomb-dev, python, python2.3-dev, python2.4-dev
+Build-Depends: catacomb-dev, python, python2.3-dev, python2.4-dev, python2.5-dev
 Standards-Version: 3.1.1
 
 Package: python-catacomb
@@ -24,7 +24,7 @@ Description: Python bindings for the Catacomb cryptographic library.
 
 Package: python2.3-catacomb
 Architecture: any
-Depends: ${shlibs:Depends}, ${python:Depends}
+Depends: ${shlibs:Depends}
 Description: Python bindings for the Catacomb cryptographic library.
  Catacomb is a cryptographic library.  It implements a large number of
  encryption algorithms, hash functions, message authentication codes
@@ -41,7 +41,7 @@ Description: Python bindings for the Catacomb cryptographic library.
 
 Package: python2.4-catacomb
 Architecture: any
-Depends: ${shlibs:Depends}, ${python:Depends}
+Depends: ${shlibs:Depends}
 Description: Python bindings for the Catacomb cryptographic library.
  Catacomb is a cryptographic library.  It implements a large number of
  encryption algorithms, hash functions, message authentication codes
@@ -56,6 +56,23 @@ Description: Python bindings for the Catacomb cryptographic library.
  This package contains the Python bindings for Catacomb, for version 2.4 of
  Python.
 
+Package: python2.5-catacomb
+Architecture: any
+Depends: ${shlibs:Depends}
+Description: Python bindings for the Catacomb cryptographic library.
+ Catacomb is a cryptographic library.  It implements a large number of
+ encryption algorithms, hash functions, message authentication codes
+ and random number generators.  It has a multi-precision maths library,
+ for implementing public key schemes such as RSA, DSA and Diffie-Hellman.
+ It contains rudimentary key-management tools.
+ .
+ The objective of Catacomb is to make a crypto library which is
+ relatively straightforward to audit for security.  Its focus is on
+ clarity of source code and portability more than performance.
+ .
+ This package contains the Python bindings for Catacomb, for version 2.5 of
+ Python.
+
 Package: python-catacomb-bin
 Architecture: all
 Depends: python, python-catacomb
index fa923a9..35c429b 100755 (executable)
@@ -2,8 +2,8 @@
 
 export DH_COMPAT = 4
 
-DEFVERSION = 2.3
-VERSIONS = $(DEFVERSION) 2.4
+DEFVERSION = 2.4
+VERSIONS = $(DEFVERSION) 2.3 2.5
 
 build: build-stamp
 
diff --git a/ec.c b/ec.c
index dab6dfe..5173356 100644 (file)
--- a/ec.c
+++ b/ec.c
@@ -903,17 +903,17 @@ static PyObject *eccurve_dopywrap(PyTypeObject *ty,
   eccurve_pyobj *cobj = newtype(ty, 0, c->ops->name);
   cobj->c = c;
   cobj->fobj = fobj;
-  cobj->ty.type.tp_basicsize = sizeof(ecpt_pyobj);
-  cobj->ty.type.tp_base = ecptcurve_pytype;
+  cobj->ty.ht_type.tp_basicsize = sizeof(ecpt_pyobj);
+  cobj->ty.ht_type.tp_base = ecptcurve_pytype;
   Py_INCREF(ecptcurve_pytype);
-  cobj->ty.type.tp_flags = (Py_TPFLAGS_DEFAULT |
-                           Py_TPFLAGS_BASETYPE |
-                           Py_TPFLAGS_CHECKTYPES |
-                           Py_TPFLAGS_HEAPTYPE);
-  cobj->ty.type.tp_alloc = PyType_GenericAlloc;
-  cobj->ty.type.tp_free = 0;
-  cobj->ty.type.tp_new = ecpt_pynew;
-  PyType_Ready(&cobj->ty.type);
+  cobj->ty.ht_type.tp_flags = (Py_TPFLAGS_DEFAULT |
+                              Py_TPFLAGS_BASETYPE |
+                              Py_TPFLAGS_CHECKTYPES |
+                              Py_TPFLAGS_HEAPTYPE);
+  cobj->ty.ht_type.tp_alloc = PyType_GenericAlloc;
+  cobj->ty.ht_type.tp_free = 0;
+  cobj->ty.ht_type.tp_new = ecpt_pynew;
+  PyType_Ready(&cobj->ty.ht_type);
   return ((PyObject *)cobj);
 }
 
diff --git a/field.c b/field.c
index d0ab05d..9f51f5f 100644 (file)
--- a/field.c
+++ b/field.c
@@ -58,17 +58,17 @@ static PyObject *field_dopywrap(PyTypeObject *ty, field *f)
 {
   field_pyobj *fobj = newtype(ty, 0, f->ops->name);
   fobj->f = f;
-  fobj->ty.type.tp_basicsize = sizeof(fe_pyobj);
-  fobj->ty.type.tp_base = fe_pytype;
+  fobj->ty.ht_type.tp_basicsize = sizeof(fe_pyobj);
+  fobj->ty.ht_type.tp_base = fe_pytype;
   Py_INCREF(fe_pytype);
-  fobj->ty.type.tp_flags = (Py_TPFLAGS_DEFAULT |
-                           Py_TPFLAGS_BASETYPE |
-                           Py_TPFLAGS_CHECKTYPES |
-                           Py_TPFLAGS_HEAPTYPE);
-  fobj->ty.type.tp_alloc = PyType_GenericAlloc;
-  fobj->ty.type.tp_free = 0;
-  fobj->ty.type.tp_new = fe_pynew;
-  PyType_Ready(&fobj->ty.type);
+  fobj->ty.ht_type.tp_flags = (Py_TPFLAGS_DEFAULT |
+                              Py_TPFLAGS_BASETYPE |
+                              Py_TPFLAGS_CHECKTYPES |
+                              Py_TPFLAGS_HEAPTYPE);
+  fobj->ty.ht_type.tp_alloc = PyType_GenericAlloc;
+  fobj->ty.ht_type.tp_free = 0;
+  fobj->ty.ht_type.tp_new = fe_pynew;
+  PyType_Ready(&fobj->ty.ht_type);
   return ((PyObject *)fobj);
 }
 
diff --git a/group.c b/group.c
index 1c869a4..fe05f15 100644 (file)
--- a/group.c
+++ b/group.c
@@ -534,17 +534,17 @@ static PyObject *group_dopywrap(PyTypeObject *ty, group *g)
 {
   group_pyobj *gobj = newtype(ty, 0, g->ops->name);
   gobj->g = g;
-  gobj->ty.type.tp_basicsize = sizeof(ge_pyobj);
-  gobj->ty.type.tp_base = ge_pytype;
+  gobj->ty.ht_type.tp_basicsize = sizeof(ge_pyobj);
+  gobj->ty.ht_type.tp_base = ge_pytype;
   Py_INCREF(group_pytype);
-  gobj->ty.type.tp_flags = (Py_TPFLAGS_DEFAULT |
-                           Py_TPFLAGS_BASETYPE |
-                           Py_TPFLAGS_CHECKTYPES |
-                           Py_TPFLAGS_HEAPTYPE);
-  gobj->ty.type.tp_alloc = PyType_GenericAlloc;
-  gobj->ty.type.tp_free = 0;
-  gobj->ty.type.tp_new = ge_pynew;
-  PyType_Ready(&gobj->ty.type);
+  gobj->ty.ht_type.tp_flags = (Py_TPFLAGS_DEFAULT |
+                              Py_TPFLAGS_BASETYPE |
+                              Py_TPFLAGS_CHECKTYPES |
+                              Py_TPFLAGS_HEAPTYPE);
+  gobj->ty.ht_type.tp_alloc = PyType_GenericAlloc;
+  gobj->ty.ht_type.tp_free = 0;
+  gobj->ty.ht_type.tp_new = ge_pynew;
+  PyType_Ready(&gobj->ty.ht_type);
   return ((PyObject *)gobj);
 }
 
diff --git a/key.c b/key.c
index c0b9eb4..54054bf 100644 (file)
--- a/key.c
+++ b/key.c
@@ -1920,10 +1920,10 @@ static PyObject *kfmeth_newkey(PyObject *me, PyObject *arg, PyObject *kw)
   key *k;
   int err;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&sl:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&s|l:newkey", kwlist,
                                   convu32, &id, &type, &exptime))
     goto end;
-  if ((err = key_new(KEYFILE_KF(me), id, type, exptime, &k)) == 0)
+  if ((err = key_new(KEYFILE_KF(me), id, type, exptime, &k)) != 0)
     KEYERR(err);
   return (key_pywrap(me, k));
 end:
diff --git a/pwsafe b/pwsafe
index 3485b08..208ccdc 100755 (executable)
--- a/pwsafe
+++ b/pwsafe
@@ -1,4 +1,4 @@
-#! /usr/bin/python2.2
+#! /usr/bin/python
 # -*-python-*-
 
 import catacomb as C
diff --git a/rand.c b/rand.c
index 7f33e13..7a3ad53 100644 (file)
--- a/rand.c
+++ b/rand.c
@@ -645,19 +645,19 @@ static PyObject *gccrand_pywrap(const gccrand_info *info)
 {
   gccrand_pyobj *g = newtype(gccrand_pytype, 0, info->name);
   g->info = info;
-  g->ty.type.tp_basicsize = sizeof(grand_pyobj);
-  g->ty.type.tp_base = gcrand_pytype;
+  g->ty.ht_type.tp_basicsize = sizeof(grand_pyobj);
+  g->ty.ht_type.tp_base = gcrand_pytype;
   Py_INCREF(gcrand_pytype);
-  g->ty.type.tp_flags = (Py_TPFLAGS_DEFAULT |
-                        Py_TPFLAGS_BASETYPE |
-                        Py_TPFLAGS_HEAPTYPE);
-  g->ty.type.tp_alloc = PyType_GenericAlloc;
-  g->ty.type.tp_free = 0;
+  g->ty.ht_type.tp_flags = (Py_TPFLAGS_DEFAULT |
+                           Py_TPFLAGS_BASETYPE |
+                           Py_TPFLAGS_HEAPTYPE);
+  g->ty.ht_type.tp_alloc = PyType_GenericAlloc;
+  g->ty.ht_type.tp_free = 0;
   if (info->f & RNGF_INT)
-    g->ty.type.tp_new = gcirand_pynew;
+    g->ty.ht_type.tp_new = gcirand_pynew;
   else
-    g->ty.type.tp_new = gcrand_pynew;
-  PyType_Ready(&g->ty.type);
+    g->ty.ht_type.tp_new = gcrand_pynew;
+  PyType_Ready(&g->ty.ht_type);
   return ((PyObject *)g);
 }
 
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);
 }