From 80f7cd89bbb143dfa794e54be04994f55e851f7b Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Fri, 29 May 2015 09:34:09 +0100 Subject: [PATCH] Use ValueError instead of SyntaxError throughout. SyntaxError has a much more specific meaning, and some software, such as `ipython', expect it to carry lots of other detailed information. So abolish the `SYNERR' macro, and use `VALERR' instead consistently. I wish I had an excuse for this blunder, but I don't. --- catacomb-python.h | 1 - ec.c | 10 +++++----- field.c | 2 +- group.c | 8 ++++---- mp.c | 4 ++-- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/catacomb-python.h b/catacomb-python.h index bb84a74..b287450 100644 --- a/catacomb-python.h +++ b/catacomb-python.h @@ -128,7 +128,6 @@ #define VALERR(str) EXCERR(PyExc_ValueError, str) #define TYERR(str) EXCERR(PyExc_TypeError, str) #define ZDIVERR(str) EXCERR(PyExc_ZeroDivisionError, str) -#define SYNERR(str) EXCERR(PyExc_SyntaxError, str) #define SYSERR(str) EXCERR(PyExc_SystemError, str) #define NIERR(str) EXCERR(PyExc_NotImplementedError, str) #define INDEXERR(idx) do { \ diff --git a/ec.c b/ec.c index d27036e..13b7798 100644 --- a/ec.c +++ b/ec.c @@ -436,7 +436,7 @@ static int ecptxl_1(ec_curve *c, ec *p, PyObject *x) qd.p = q; qd.e = 0; if (!ec_ptparse(&qd, p)) - SYNERR(qd.e); + VALERR(qd.e); goto fix; } else if (c && (xx = tomp(x)) != 0) { xx = F_IN(c->f, xx, xx); @@ -817,7 +817,7 @@ static PyObject *meth__ECPtCurve_fromraw(PyObject *me, PyObject *arg) buf_init(&b, p, len); cc = ECCURVE_C(me); if (ec_getraw(cc, &b, &pp)) - SYNERR("bad point"); + VALERR("bad point"); EC_IN(cc, &pp, &pp); rc = Py_BuildValue("(NN)", ecpt_pywrap(me, &pp), bytestring_pywrapbuf(&b)); end: @@ -851,7 +851,7 @@ static PyObject *meth__ECPt_parse(PyObject *me, PyObject *arg) if (!PyArg_ParseTuple(arg, "Os:parse", &me, &p)) goto end; qd.p = p; qd.e = 0; - if (!ec_ptparse(&qd, &pp)) SYNERR(qd.e); + if (!ec_ptparse(&qd, &pp)) VALERR(qd.e); rc = Py_BuildValue("(Ns)", ecpt_pywrapout(me, &pp), qd.p); end: return (rc); @@ -975,7 +975,7 @@ static PyObject *meth__ECCurve_parse(PyObject *me, PyObject *arg) qd.p = p; qd.e = 0; if ((c = ec_curveparse(&qd)) == 0) - SYNERR(qd.e); + VALERR(qd.e); rc = eccurve_pywrap(0, c); end: return (rc); @@ -1355,7 +1355,7 @@ static PyObject *meth__ECInfo_parse(PyObject *me, PyObject *arg) qd.p = p; qd.e = 0; if (ec_infoparse(&qd, &ei)) - SYNERR(qd.e); + VALERR(qd.e); rc = Py_BuildValue("(Ns)", ecinfo_pywrap(&ei), qd.p); end: return (rc); diff --git a/field.c b/field.c index cce2e89..2807c1c 100644 --- a/field.c +++ b/field.c @@ -958,7 +958,7 @@ static PyObject *meth__Field_parse(PyObject *me, PyObject *arg) qd.p = p; qd.e = 0; if ((f = field_parse(&qd)) == 0) - SYNERR(qd.e); + VALERR(qd.e); rc = Py_BuildValue("(Ns)", field_pywrap(f), qd.p); end: return (rc); diff --git a/group.c b/group.c index 0fc8eb2..5cc40e5 100644 --- a/group.c +++ b/group.c @@ -264,7 +264,7 @@ static PyObject *meth__parse(PyObject *me, PyObject *arg, PyTypeObject *ty, if (!PyArg_ParseTuple(arg, "Os:parse", &me, &p)) goto end; qd.p = p; qd.e = 0; - if (parse(&qd, &gp)) SYNERR(qd.e); + if (parse(&qd, &gp)) VALERR(qd.e); rc = fginfo_pywrap(&gp, ty); end: return (rc); @@ -517,7 +517,7 @@ static PyObject *ge_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw) sc.buf = PyString_AS_STRING(x); sc.lim = sc.buf + PyString_GET_SIZE(x); if (G_READ(g, xx, &mptext_stringops, &sc) || sc.buf < sc.lim) - SYNERR("malformed group element string"); + VALERR("malformed group element string"); } else TYERR("can't convert to group element"); return (ge_pywrap((PyObject *)ty, xx)); @@ -868,7 +868,7 @@ static PyObject *meth__GE_fromstring(PyObject *me, PyObject *arg) g = GROUP_G(me); x = G_CREATE(g); if (G_READ(g, x, &mptext_stringops, &sc)) - SYNERR("bad group element string"); + VALERR("bad group element string"); return (Py_BuildValue("(Ns#)", ge_pywrap(me, x), sc.buf, (int)(sc.lim - sc.buf))); end: @@ -887,7 +887,7 @@ static PyObject *meth__Group_parse(PyObject *me, PyObject *arg) qd.p = p; qd.e = 0; if ((g = group_parse(&qd)) == 0) - SYNERR(qd.e); + VALERR(qd.e); return (group_pywrap(g)); end: return (0); diff --git a/mp.c b/mp.c index cb63a4f..2434eaf 100644 --- a/mp.c +++ b/mp.c @@ -921,7 +921,7 @@ static PyObject *meth__MP_fromstring(PyObject *me, if (!good_radix_p(r, 1)) VALERR("bad radix"); sc.buf = p; sc.lim = p + len; if ((zz = mp_read(MP_NEW, r, &mptext_stringops, &sc)) == 0) - SYNERR("bad integer"); + VALERR("bad integer"); z = Py_BuildValue("(Ns#)", mp_pywrap(zz), sc.buf, (int)(sc.lim - sc.buf)); end: return (z); @@ -2123,7 +2123,7 @@ static PyObject *meth__GF_fromstring(PyObject *me, if ((zz = mp_read(MP_NEW, r, &mptext_stringops, &sc)) == 0 || MP_NEGP(zz)) { if (zz) MP_DROP(zz); - SYNERR("bad binary polynomial"); + VALERR("bad binary polynomial"); } z = Py_BuildValue("(Ns#)", gf_pywrap(zz), sc.buf, (int)(sc.lim - sc.buf)); end: -- 2.11.0