chiark / gitweb /
Use ValueError instead of SyntaxError throughout.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 29 May 2015 08:34:09 +0000 (09:34 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 29 May 2015 08:34:09 +0000 (09:34 +0100)
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
ec.c
field.c
group.c
mp.c

index bb84a74dec4297ac2afb7c87dff38c5051fa4354..b287450280a5318114e098e62708a5b49ae09b28 100644 (file)
 #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 d27036eed9c478136bf0fd35d0a9b82490edf07b..13b7798592601d2c174e42d1c7a56a2adc4200c7 100644 (file)
--- 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 cce2e89124d10d22ef83d6a613826df65c4c9fef..2807c1ccbfb6cb491fb5902868548af47f6b203a 100644 (file)
--- 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 0fc8eb2b228886e7d65278d0a7829a443bc618cb..5cc40e54a364cecb0028ca35329e9afc5fb0c792 100644 (file)
--- 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 cb63a4f653dfa98a8f337735e90b15fd820359d3..2434eaf75f1147e54cfb25be55ac5a05066075d7 100644 (file)
--- 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: