#11868: PARI library interface broken by design
---------------------------------------+------------------------------
       Reporter:  jdemeyer             |        Owner:  was
           Type:  defect               |       Status:  needs_review
       Priority:  major                |    Milestone:  sage-5.13
      Component:  interfaces           |   Resolution:
       Keywords:  t0GEN t1GEN gen      |    Merged in:
        Authors:  Peter Bruin          |    Reviewers:  Jeroen Demeyer
Report Upstream:  N/A                  |  Work issues:
         Branch:                       |       Commit:
   Dependencies:  #864, #9640, #10018  |     Stopgaps:
---------------------------------------+------------------------------

Comment (by jdemeyer):

 Added patch
 {{{
 #!diff
 diff --git a/sage/libs/pari/gen.pyx b/sage/libs/pari/gen.pyx
 --- a/sage/libs/pari/gen.pyx
 +++ b/sage/libs/pari/gen.pyx
 @@ -1871,7 +1871,7 @@
          pari_catch_sig_on()
          cdef int ret = gequal(a.g, t0.g)
          pari_catch_sig_off()
 -        return bool(ret)
 +        return ret != 0

      def gequal0(gen a):
          r"""
 @@ -1893,7 +1893,7 @@
          pari_catch_sig_on()
          cdef int ret = gequal0(a.g)
          pari_catch_sig_off()
 -        return bool(ret)
 +        return ret != 0

      def gequal_long(gen a, long b):
          r"""
 @@ -1920,7 +1920,7 @@
          pari_catch_sig_on()
          cdef int ret = gequalsg(b, a.g)
          pari_catch_sig_off()
 -        return bool(ret)
 +        return ret != 0


      ###########################################
 @@ -1962,7 +1962,7 @@
          pari_catch_sig_on()
          cdef long t = signe(gisprime(self.g, flag))
          P.clear_stack()
 -        return bool(t)
 +        return t != 0

      def qfbhclassno(gen n):
          r"""
 @@ -2041,7 +2041,7 @@
          pari_catch_sig_on()
          cdef long t = ispseudoprime(self.g, flag)
          pari_catch_sig_off()
 -        return bool(t)
 +        return t != 0

      def ispower(gen self, k=None):
          r"""
 @@ -3209,9 +3209,9 @@
              [True, False, True, True, True, True, True, True, True, True]
          """
          pari_catch_sig_on()
 -        b = bool(bittest(x.g, n))
 +        cdef long b = bittest(x.g, n)
          pari_catch_sig_off()
 -        return b
 +        return b != 0

      def bitxor(gen x, y):
          """
 @@ -5541,24 +5541,24 @@

      def issquare(gen x, find_root=False):
          """
 -        issquare(x,n): true(1) if x is a square, false(0) if not. If
 -        find_root is given, also returns the exact square root if it was
 -        computed.
 -        """
 -        cdef GEN G, t
 +        issquare(x,n): ``True`` if x is a square, ``False`` if not. If
 +        ``find_root`` is given, also returns the exact square root.
 +        """
 +        cdef GEN G
 +        cdef long t
          cdef gen g
          pari_catch_sig_on()
          if find_root:
 -            t = gissquareall(x.g, &G)
 -            v = bool(P.new_gen_noclear(t))
 -            if v:
 -                return v, P.new_gen(G)
 +            t = itos(gissquareall(x.g, &G))
 +            if t:
 +                return True, P.new_gen(G)
              else:
 -                pari_catch_sig_off()
 -                return v, None
 +                P.clear_stack()
 +                return False, None
          else:
 -            return P.new_gen(gissquare(x.g))
 -
 +            t = itos(gissquare(x.g))
 +            pari_catch_sig_off()
 +            return t != 0

      def issquarefree(gen self):
          """
 @@ -5570,9 +5570,9 @@
              False
          """
          pari_catch_sig_on()
 -        t = bool(issquarefree(self.g))
 +        cdef long t = issquarefree(self.g)
          pari_catch_sig_off()
 -        return t
 +        return t != 0

      def lcm(gen x, y):
          """
 @@ -6203,9 +6203,9 @@
          """
          cdef gen t0 = objtogen(x)
          pari_catch_sig_on()
 -        t = bool(oncurve(self.g, t0.g) == 1)
 +        cdef int t = oncurve(self.g, t0.g)
          pari_catch_sig_off()
 -        return t
 +        return t != 0

      def elllocalred(self, p):
          r"""
 @@ -8034,9 +8034,10 @@
          non-constant polynomial, or False if f is reducible or constant.
          """
          pari_catch_sig_on()
 -        return bool(self.new_gen(gisirreducible(self.g)))
 -
 -
 +        cdef long t = itos(gisirreducible(self.g))
 +        P.clear_stack()
 +        return t != 0
 +
      def pollead(self, v=-1):
          """
          self.pollead(v): leading coefficient of polynomial or series
 self,
 }}}

--
Ticket URL: <http://trac.sagemath.org/ticket/11868#comment:38>
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.

Reply via email to