Merge branch '1.1.x'
authorMark Wooding <mdw@distorted.org.uk>
Sun, 14 May 2017 03:28:02 +0000 (04:28 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 14 May 2017 03:28:02 +0000 (04:28 +0100)
* 1.1.x:
  Release 1.1.2.
  catacomb/__init__.py: Fix up cipher etc. names better.
  algorithms.c: Support the new 16-bit key-size descriptors.
  group.c: Track Catacomb group internals change.
  utils.c: Raise exceptions from `convTHING' with null arguments.
  Return `long' objects when `int' is requested but the value won't fit.
  bytestring.c: Check for cached hash more carefully.
  rand.c: Careful range checking on `block' and `mp'.
  *.c: Fix docstrings for methods.
  Further fixing to use `Py_ssize_t' in place of int.

Conflicts:
debian/control (already wanted later catacomb-dev)
group.c (no need for compatibility with older Catacombs)

1  2 
util.c

diff --combined util.c
--- 1/util.c
--- 2/util.c
+++ b/util.c
@@@ -42,29 -42,6 +42,29 @@@ PyObject *getulong(unsigned long w
      return (PyLong_FromUnsignedLong(w));
  }
  
 +static PyObject *i32 = 0;
 +static int init_i32(void)
 +  { if (!i32 && (i32 = PyInt_FromLong(32)) == 0) return (-1); return (0); }
 +
 +PyObject *getk64(kludge64 u)
 +{
 +  PyObject *i = 0, *j = 0, *t;
 +  PyObject *rc = 0;
 +
 +  if (init_i32()) goto end;
 +  if ((i = PyLong_FromUnsignedLong(HI64(u))) == 0) goto end;
 +  if ((t = PyNumber_InPlaceLshift(i, i32)) == 0) goto end;
 +  Py_DECREF(i); i = t;
 +  if ((j = PyLong_FromUnsignedLong(LO64(u))) == 0) goto end;
 +  if ((t = PyNumber_InPlaceOr(i, j)) == 0) goto end;
 +  Py_DECREF(i); i = t;
 +  if ((rc = PyNumber_Int(i)) == 0) goto end;
 +end:
 +  if (i) Py_DECREF(i);
 +  if (j) Py_DECREF(j);
 +  return (rc);
 +}
 +
  PyObject *getbool(int b)
  {
    if (b) RETURN_TRUE;
@@@ -83,6 -60,7 +83,7 @@@ int convulong(PyObject *o, void *pp
    unsigned long *p = pp;
    PyObject *t;
  
+   if (!o) VALERR("can't delete");
    if (PyInt_Check(o)) {
      i = PyInt_AS_LONG(o);
      if (i < 0) VALERR("must be nonnegative");
@@@ -126,28 -104,6 +127,28 @@@ end
    return (0);
  }
  
 +int convk64(PyObject *o, void *pp)
 +{
 +  PyObject *i = 0, *t;
 +  int rc = 0;
 +  uint32 lo, hi;
 +
 +  if (init_i32()) goto end;
 +  if ((i = PyNumber_Int(o)) == 0) goto end;
 +  lo = PyInt_AsUnsignedLongMask(i);
 +  if ((t = PyNumber_InPlaceRshift(i, i32)) == 0) goto end;
 +  Py_DECREF(i); i = t;
 +  hi = PyInt_AsUnsignedLongMask(i);
 +  if ((t = PyNumber_InPlaceRshift(i, i32)) == 0) goto end;
 +  Py_DECREF(i); i = t;
 +  if (PyObject_IsTrue(i)) VALERR("out of range");
 +  SET64(*(kludge64 *)pp, hi, lo);
 +  rc = 1;
 +end:
 +  if (i) Py_DECREF(i);
 +  return (rc);
 +}
 +
  int convmpw(PyObject *o, void *pp)
  {
    unsigned long u;
@@@ -176,8 -132,11 +177,11 @@@ end
  
  int convbool(PyObject *o, void *pp)
  {
+   if (!o) VALERR("can't delete");
    *(int *)pp = PyObject_IsTrue(o);
    return (1);
+ end:
+   return (0);
  }
  
  /*----- Type messing ------------------------------------------------------*/
@@@ -223,9 -182,9 +227,9 @@@ void typeready(PyTypeObject *ty
    PyDict_SetItemString(ty->tp_dict, "__module__", modname);
  }
  
 -PyTypeObject *inittype(PyTypeObject *tyskel)
 +PyTypeObject *inittype(PyTypeObject *tyskel, PyTypeObject *meta)
  {
 -  PyTypeObject *ty = newtype(&PyType_Type, tyskel, 0);
 +  PyTypeObject *ty = newtype(meta, tyskel, 0);
    ty->tp_flags |= Py_TPFLAGS_HEAPTYPE;
    typeready(ty);
    return (ty);
@@@ -271,8 -230,8 +275,8 @@@ PyMethodDef *donemethods(void
  
  /*----- Exceptions --------------------------------------------------------*/
  
 -PyObject * mkexc(PyObject *mod, PyObject *base,
 -               const char *name, PyMethodDef *mm)
 +PyObject *mkexc(PyObject *mod, PyObject *base,
 +              const char *name, PyMethodDef *mm)
  {
    PyObject *nameobj = 0;
    PyObject *dict = 0;