#14894: Fix PARI error handling (needed for future upgrade to PARI 2.6)
--------------------------------------+-------------------------------
Reporter: vbraun | Owner: jdemeyer
Type: defect | Status: needs_review
Priority: major | Milestone: sage-5.12
Component: packages: standard | Resolution:
Keywords: pari error signal | Merged in:
Authors: Peter Bruin | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Dependencies: #12142, #14873
Stopgaps: |
--------------------------------------+-------------------------------
Old description:
> Pari GIT has made significant changes to the error handling code, which
> will require us to make some changes to Sage.
>
> This ticket reimplements PARI error handling inside Cython code using
> macros provided by `pari/paricom.h` instead of undocumented functions
> that no longer exist in PARI 2.6. The new syntax is
> {{{
> sage_pari_catch()
> ... code ...
> sage_pari_catch_end()
> }}}
> Inside such a block one can put conditions like
> {{{
> if [some condition]:
> sage_pari_catch_reset()
> [return or raise exception]
> }}}
>
> The new functions catch PARI errors and also call `sig_on()` and
> `sig_off()` to enable interrupt handling. This replaces the current hack
> of overriding `sig_on()` and `sig_off()`.
>
> Since `sage_pari_catch()` and `sage_pari_catch_end()` are C macros
> containing complementary braces, they ''must'' be on the same level in
> Cython code. This means that several functions in
> `sage/libs/pari/gen.pyx`, most importantly `new_gen()`, no longer call
> `sig_off()` or its replacement `sage_pari_catch_end()`. Instead of
> {{{
> sig_on()
> return new_gen(something returning GEN)
> }}}
> one therefore has to write
> {{{
> cdef gen result
> sage_pari_catch()
> result = new_gen(something returning GEN)
> sage_pari_catch_end()
> return result
> }}}
>
> This new approach fixes several (potential) problems with the existing
> one; see http://trac.sagemath.org/sage_trac/ticket/14873#comment:9.
>
> When upgrading to PARI 2.6, the only remaining change to be made
> (hopefully) is to replace the macros `CATCH`, `ENDCATCH`, `RETRY` and
> `CATCH_RELEASE` by `pari_CATCH`, `pari_ENDCATCH`, `pari_RETRY` and
> `pari_CATCH_reset`.
>
> Apply: [attachment:trac_14894-pari_catch.patch],
> [attachment:trac_14894-pari_catch_gen.patch],
> [attachment:trac_14894-pari_catch_FiniteFieldElement_pari_ffelt.patch],
> [attachment:trac_14894-pari_catch_misc.patch],
> [attachment:trac_14894-pari_catch_delete_old.patch]
New description:
Pari GIT has made significant changes to the error handling code, which
will require us to make some changes to Sage.
This ticket reimplements PARI error handling inside Cython code using
macros provided by `pari/paricom.h` instead of undocumented functions that
no longer exist in PARI 2.6. The new syntax is
{{{
sage_pari_catch()
... code ...
sage_pari_catch_end()
}}}
Inside such a block one can put conditions like
{{{
if [some condition]:
sage_pari_catch_reset()
[return or raise exception]
}}}
The new functions catch PARI errors and also call `sig_on()` and
`sig_off()` to enable interrupt handling. This replaces the current hack
of overriding `sig_on()` and `sig_off()`.
Since `sage_pari_catch()` and `sage_pari_catch_end()` are C macros
containing complementary braces, they ''must'' be on the same level in
Cython code. This means that several functions in
`sage/libs/pari/gen.pyx`, most importantly `new_gen()`, no longer call
`sig_off()` or its replacement `sage_pari_catch_end()`. Instead of
{{{
sig_on()
return new_gen(something returning GEN)
}}}
one therefore has to write
{{{
cdef gen result
sage_pari_catch()
result = new_gen(something returning GEN)
sage_pari_catch_end()
return result
}}}
This new approach fixes several (potential) problems with the existing
one; see http://trac.sagemath.org/sage_trac/ticket/14873#comment:9.
When upgrading to PARI 2.6, the only remaining change to be made
(hopefully) is to replace the macros `CATCH`, `ENDCATCH`, `RETRY` and
`CATCH_RELEASE` by `pari_CATCH`, `pari_ENDCATCH`, `pari_RETRY` and
`pari_CATCH_reset`.
Apply: [attachment:trac_14894-pari_catch.patch],
[attachment:trac_14894-pari_catch_gen.patch],
[attachment:trac_14894-pari_catch_FiniteFieldElement_pari_ffelt.patch],
[attachment:trac_14894-pari_catch_misc.patch],
[attachment:trac_14894-pari_catch_delete_old.patch],
[attachment:trac_14894-pari_catch_simplify.patch]
--
Comment (by pbruin):
I'm attaching one more patch, which I hope will be the last one for this
ticket. It makes the C macros as simple as possible and moves the
handling of `pari_errno` to a single Cython function `pari_handle_error`.
--
Ticket URL: <http://trac.sagemath.org/ticket/14894#comment:9>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.