chiark / gitweb /
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 be953b0757893906cb3aa01c4f2864b4d41a6c5e..de7ab75a86332feafe72895ed7df288f38476d9b 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 722d7adb9faacee622c236b0b3a7b3f514e2e379..79034af56ab07183ee63782befe7339d1617372d 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 2a132897d53e155a3d7153394e787341d46fbda0..e7fd938b5bbd5e032b81cc5892f02ee91f537cb5 100644 (file)
@@ -8,3 +8,4 @@ python-catacomb
 python2.3-catacomb
 python2.4-catacomb
 
+python2.5-catacomb
index d1ff042e99297689fcb51c0a201231aa7e0c5933..a82363274e6d002627c036e54769fc065516ec33 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 fa923a9236f2fcff21bc71e08e88ab14ad6af6f7..35c429b6ce0f78273ff18f4ca8c79de9c3f1b0a1 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 dab6dfe600666fcb3c2833b43a1cae747ca710f1..51733568dfb89ddf4ba025d62bbd5314d84153db 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 d0ab05d605f236e50a5c7186f40a080d4b131d70..9f51f5f6f4f01852178a737f0bdea309a198cd05 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 1c869a42c57691ea88c1530f4700d2d6fbd8f800..fe05f151c3785fd2342648d54acfb0bd5b812df4 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 c0b9eb49dceba2e2422033f3f47d93b5eb8251bd..54054bfcabe680f2f0f5dbf17530e369a8b2cab2 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 3485b08cf37f62d6d16818851c2568702fd3372e..208ccdcd7a0d0a938a5b5c1b031cdd66d4a1cdab 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 7f33e1366bc461ee931fec009c80c7d4a65353cc..7a3ad532d85af309f284205505f5334cb2685b41 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 1739ebe9b4a2d4a78685b25b9d563a3227cfa0e5..72014015b9878232b10493d608b51219f4098233 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);
 }