This can be implemented by Python, so it can throw exceptions.
Fortunately, Python checks that the result is nonnegative, so we don't
have to worry about that.
if (!set) set = PyTuple_New(0);
else Py_INCREF(set);
if (!PySequence_Check(set)) TYERR("want a sequence");
- n = PySequence_Size(set);
- l = PyList_New(0);
- if (PyErr_Occurred()) goto end;
+ n = PySequence_Size(set); if (n < 0) goto end;
+ l = PyList_New(0); if (!l) goto end;
if (dfl < 0) VALERR("key size cannot be negative");
x = PyInt_FromLong(dfl);
PyList_Append(l, x);
arg = PyTuple_GetItem(arg, 0);
Py_INCREF(arg);
if (!PySequence_Check(arg)) TYERR("not a sequence");
- n = PySequence_Size(arg); if (!n) { z = id(me); goto end; }
+ n = PySequence_Size(arg); if (n < 0) goto end;
+ if (!n) { z = id(me); goto end; }
x = PySequence_GetItem(arg, 0);
if (PySequence_Check(x))
flat = 0;
if (!EC_FIND(c, p, xx)) VALERR("not on the curve");
} else if (PySequence_Check(x)) {
t = x; x = 0;
- n = PySequence_Size(t);
+ n = PySequence_Size(t); if (n < 0) goto end;
if (n != 2 && (n != 3 || !c))
TYERR("want sequence of two or three items");
if ((x = PySequence_GetItem(t, 0)) == 0 ||
goto end;
Py_INCREF(q);
if (!PySequence_Check(q)) TYERR("want a sequence of residues");
- if (PySequence_Size(q) != n) VALERR("residue count mismatch");
+ i = PySequence_Size(q); if (i < 0) goto end;
+ if (i != n) VALERR("residue count mismatch");
v = xmalloc(n * sizeof(*v));
for (i = 0; i < n; i++) {
if ((x = PySequence_GetItem(q, i)) == 0) goto end;
goto end;
Py_INCREF(q);
if (!PySequence_Check(q)) TYERR("want a sequence of moduli");
- n = PySequence_Size(q);
- if (PyErr_Occurred()) goto end;
+ n = PySequence_Size(q); if (n < 0) goto end;
if (!n) VALERR("want at least one modulus");
v = xmalloc(n * sizeof(*v));
for (i = 0; i < n; i++) {