chiark / gitweb /
key.c (key_pynew): Make `exptime' arg (a) optional, and (b) unsigned.
authorMark Wooding <mdw@distorted.org.uk>
Wed, 1 Jan 2014 17:32:08 +0000 (17:32 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 4 Jan 2014 01:40:12 +0000 (01:40 +0000)
Otherwise (a) it was pointless trying to set a default, and (b) you get
an error when you try to set KEXP_FOREVER explicitly.  Effectively it
was impossible to make keys which never expire.

key.c

diff --git a/key.c b/key.c
index 7820f1d4db62a3f4252c8306a85d3de39aba73ae..c4ccfa9dcf20f11d526270c5653c708ad98e7c4f 100644 (file)
--- a/key.c
+++ b/key.c
@@ -1385,14 +1385,14 @@ static PyObject *key_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
   PyObject *kfobj;
   uint32 id;
   char *type;
-  long exptime = KEXP_FOREVER;
+  unsigned long exptime = KEXP_FOREVER;
   static char *kwlist[] = { "keyfile", "id", "type", "exptime", 0 };
   key *k;
   int err;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O&sl:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O&s|O&:new", kwlist,
                                   keyfile_pytype, &kfobj, convu32, &id,
-                                  &type, &exptime))
+                                  &type, convulong, &exptime))
     goto end;
   if ((err = key_new(KEYFILE_KF(kfobj), id, type, exptime, &k)) != 0)
     KEYERR(err);