chiark / gitweb /
ec.c: Dispatch to `ecptxl_3' whether or not we have a curve.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 24 Nov 2019 22:42:10 +0000 (22:42 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 11 Apr 2020 11:49:31 +0000 (12:49 +0100)
The `ecptxl_3' function has a better error message in the case where
there is no curve.  Indeed, `want sequence of two or three items' is
downright unfair in the case where you did in fact supply a sequence of
three items, and the real problem is that you're trying to construct a
curveless point.

ec.c
t/t-ec.py

diff --git a/ec.c b/ec.c
index 47445c17d14836089c9c835ef5698f9ec76b39dd..1e3eb994dfb946d86b89e1c8724beaf9ad306f77 100644 (file)
--- a/ec.c
+++ b/ec.c
@@ -533,7 +533,7 @@ static int ecptxl_1(ec_curve *c, ec *p, PyObject *x)
   } else if (PySequence_Check(x)) {
     t = x; x = 0;
     n = PySequence_Size(t); if (n < 0) goto end;
-    if (n != 2 && (n != 3 || !c))
+    if (n != 2 && n != 3)
       TYERR("want sequence of two or three items");
     if ((x = PySequence_GetItem(t, 0)) == 0 ||
        (y = PySequence_GetItem(t, 1)) == 0 ||
index 02ae4d1d590aeb21090626dd02bfda472fbd30fe..f11da7d211ed633db7fcc6100a89acbf8db57f81 100644 (file)
--- a/t/t-ec.py
+++ b/t/t-ec.py
@@ -60,7 +60,7 @@ class TestCurvelessPoints (U.TestCase):
     me.assertRaises(ValueError, C.ECPt, "12345,")
     me.assertRaises(ValueError, C.ECPt, "12345, xyzzy")
     me.assertRaises(ValueError, C.ECPt, "12345, 67890!??")
-    me.assertRaises(TypeError, C.ECPt, (1, 2, 3))
+    me.assertRaises(ValueError, C.ECPt, (1, 2, 3))
     me.assertRaises(TypeError, C.ECPt, 1, 2, 3)
     me.assertRaises(TypeError, C.ECPt, 1234)
     me.assertRaises(TypeError, C.ECPt, object())