From: Mark Wooding Date: Tue, 21 Mar 2006 01:20:29 +0000 (+0000) Subject: key: Use convulong instead of PyLong_AsUnsignedLong. X-Git-Tag: 1.0.1~21 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/catacomb-python/commitdiff_plain/61e45e9b848e9116203243251c44514050f02790?ds=sidebyside key: Use convulong instead of PyLong_AsUnsignedLong. Python 2.4's implementation of PyLong_AsUnsignedLong handles integers correctly; but 2.3 insists on having a real `long' object. Our `convulong' function handles these, and also stranger things like MPs. Use it. --- diff --git a/key.c b/key.c index 57d01f9..c0b9eb4 100644 --- a/key.c +++ b/key.c @@ -1482,7 +1482,7 @@ static int kset_exptime(PyObject *me, PyObject *x, void *hunoz) key *k = KEY_K(me); unsigned long et; - if ((et = PyLong_AsUnsignedLong(x)) == (unsigned long)-1 && PyErr_Occurred()) + if (!convulong(x, &et)) goto end; if (!(KEY_KF(me)->f & KF_WRITE)) KEYERR(KERR_READONLY); @@ -1498,7 +1498,7 @@ static int kset_deltime(PyObject *me, PyObject *x, void *hunoz) key *k = KEY_K(me); unsigned long dt; - if ((dt = PyLong_AsUnsignedLong(x)) == (unsigned long)-1 && PyErr_Occurred()) + if (!convulong(x, &dt)) goto end; if (dt == KEXP_FOREVER && k->exp != KEXP_FOREVER) VALERR("key will eventually expire");