X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/catacomb-python/blobdiff_plain/a42955d587b9ed267aa9a22d5b68f89b4d88beb5..930d78e3e2045f6f810c73edd81f44321b039ea5:/rand.c diff --git a/rand.c b/rand.c index 7e091b0..ddec6ff 100644 --- a/rand.c +++ b/rand.c @@ -1364,18 +1364,20 @@ static PyObject *meth__BBSPriv_generate(PyObject *me, { bbs_priv bp = { 0 }; mp *x = MP_TWO; - pgev evt = { 0 }; + struct excinfo exc = EXCINFO_INIT; + pypgev evt = { { 0 } }; unsigned nbits, n = 0; grand *r = &rand_global; char *kwlist[] = { "class", "nbits", "event", "rng", "nsteps", "seed", 0 }; bbspriv_pyobj *rc = 0; + evt.exc = &exc; if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO&|O&O&O&O&:generate", kwlist, &me, convuint, &nbits, convpgev, &evt, convgrand, &r, convuint, &n, convmp, &x)) goto end; - if (bbs_gen(&bp, nbits, r, n, evt.proc, evt.ctx)) - VALERR("prime genration failed"); + if (bbs_gen(&bp, nbits, r, n, evt.ev.proc, evt.ev.ctx)) + PGENERR(&exc); rc = PyObject_New(bbspriv_pyobj, bbspriv_pytype); rc->gr.r = bbs_rand(bp.n, x); rc->gr.f = f_freeme; @@ -1384,7 +1386,6 @@ static PyObject *meth__BBSPriv_generate(PyObject *me, rc->bp.n = MP_COPY(bp.n); end: mp_drop(bp.p); mp_drop(bp.q); mp_drop(bp.n); mp_drop(x); - droppgev(&evt); return ((PyObject *)rc); }