Le 04/03/2015 23:55, Bill Allombert a écrit :
On Wed, Mar 04, 2015 at 10:47:28PM +0100, Julien Puydt wrote:
block that is put somewhere appropriate.
*They* won't do anything, but *I* am trying to wrap my head between
what they already have, and what they should have -- I must admit
I'm quite unfamiliar with setjmp/longjmp.
Let's see if I'm starting to get it ; in their code to setup error
handling, they should :
(1) have something like:
if (setjmp(&iferr_env)) {
GEN E = pari_err_last ();
/* the code of their cb_pari_err_handle implementation,
* whose argument is precisely a GEN, and E[1] has the error
* number, so it's possible to decide to raise a python exception
* or resize the stack */
pari_err(0, err); /* <- no infinite loop? */
You would need to set iferr_env=NULL for pari_err(0, err); to work.
But this is not what you want to do: instead just call
cb_pari_err_recover which does not return.
Cheers,
The following does give an infinite loop on error :
cdef void _pari_init_error_handling():
"""
Set up our code for handling PARI errors.
TESTS::
sage: try:
....: p = pari.polcyclo(-1)
....: except PariError as e:
....: print e.errtext()
domain error in polcyclo: index <= 0
Warnings still work just like in GP::
sage: pari('warning("test")')
*** user warning: test
"""
global cb_pari_err_recover
cb_pari_err_recover = _pari_err_recover
# FIXME: when PARI 2.8.0 comes out:
# 1. uncomment the two lines below
# 2. remove the rest of the function
#global cb_pari_err_handle
#cb_pari_err_handle = _pari_err_handle
cdef GEN E
cdef long errnum
cdef jmp_buf env
iferr_env = &env
if setjmp (iferr_env[0]) != 0:
E = pari_err_last()
errnum = E[1]
_pari_err_handle(E)
cb_pari_err_recover(errnum)
Did I miss something about pari (in which case you can probably help),
or something about sage (in which case sage-devel's mailing-list might
help) ?
Thanks,
Snark on #debian-science
--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org