From f169c24bb9769a5e2a8a3ea40d233b0c3092e813 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sun, 24 Nov 2019 22:42:10 +0000 Subject: [PATCH] ec.c: Dispatch to `ecptxl_3' whether or not we have a curve. 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 | 2 +- t/t-ec.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ec.c b/ec.c index 7a6ed95..6831552 100644 --- 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 || diff --git a/t/t-ec.py b/t/t-ec.py index 02ae4d1..f11da7d 100644 --- 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()) -- 2.11.0