#7794: PolynomialRing_integral_domain ignores Ctrl-C and segfaults
-------------------------------------+--------------------------------------
Reporter: SimonKing | Owner: AlexGhitza
Type: defect | Status: needs_work
Priority: critical | Milestone: sage-4.7.1
Component: algebra | Keywords: Polynomial Ring
KeyboardInterrupt
Work_issues: catch attribute error | Upstream: N/A
Reviewer: Simon King | Author: Jeroen Demeyer
Merged: | Dependencies:
-------------------------------------+--------------------------------------
Changes (by SimonKing):
* status: positive_review => needs_work
* work_issues: => catch attribute error
Comment:
Replying to [comment:17 jdemeyer]:
> you are probably right about {{{except AttributeError}}}. How about
> {{{
> cdef inline cparent get_cparent(parent) except? 0:
> try:
> return <unsigned long>(parent.modulus())
> except AttributeError:
> return 0
> }}}
> This will also catch the case `parent == None`.
Yes, that looks a bit better.
Concerning modulus 1:
It is possible to explicitly construct an instance of
`sage.rings.polynomial.polynomial_zmod_flint.Polynomial_zmod_flint` whose
parent has modulus 1:
{{{
sage: from sage.rings.polynomial.polynomial_ring import
PolynomialRing_dense_mod_n
sage: P = PolynomialRing_dense_mod_n(Zmod(1),'x')
sage: type(P.0)
<type 'sage.rings.polynomial.polynomial_zmod_flint.Polynomial_zmod_flint'>
}}}
So, in order to be on the safe side, one should not have
`get_cparent(parent) except 1:`.
One may argue, however, that it can not occur if one constructs a ring as
one is supposed to, namely by calling the polynomial ring constructor:
{{{
sage: P.<x> = Zmod(1)[]
sage: type(x)
<type 'sage.rings.polynomial.polynomial_element.Polynomial_generic_dense'>
}}}
But better safe than sorry, in particular since your safe solution (`...
except? 0:`) should have no serious time penalty.
Namely, as much as I understand, `cdef get_cparent(parent) except? 0:`
will slow things down only if the return value is 0, because then it will
be tested whether an error has actually occured.
But, to the best of my knowledge, it is ''impossible'' to have a parent
with modulus zero, even if one works around the polynomial ring
constructor:
{{{
sage: P = PolynomialRing_dense_mod_n(ZZ,'x')
Traceback (most recent call last):
...
ValueError: invalid integer: +Infinity
}}}
So, if one has return value zero then something exceptional must be
happening: Either it is a real error, or it is during pickling, when
`parent` is None. So, we can certainly afford to test for an error in that
situation.
Can you update your patch, so that the attribute error is caught? Then
I'll run the tests again, and will hoppefully be able to renew my positive
review.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7794#comment:18>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.