[arch-commits] Commit in sagemath-doc/repos/community-any (11 files)

Antonio Rojas arojas at archlinux.org
Fri Jan 18 08:00:45 UTC 2019


    Date: Friday, January 18, 2019 @ 08:00:43
  Author: arojas
Revision: 423971

archrelease: copy trunk to community-any

Added:
  sagemath-doc/repos/community-any/PKGBUILD
    (from rev 423970, sagemath-doc/trunk/PKGBUILD)
  sagemath-doc/repos/community-any/docbuild_main.patch
    (from rev 423970, sagemath-doc/trunk/docbuild_main.patch)
  sagemath-doc/repos/community-any/sagemath-cypari2.patch
    (from rev 423970, sagemath-doc/trunk/sagemath-cypari2.patch)
  sagemath-doc/repos/community-any/sagemath-doc-segfault.patch
    (from rev 423970, sagemath-doc/trunk/sagemath-doc-segfault.patch)
  sagemath-doc/repos/community-any/sagemath-doc-sphinx-1.8.patch
    (from rev 423970, sagemath-doc/trunk/sagemath-doc-sphinx-1.8.patch)
  sagemath-doc/repos/community-any/sagemath-ecl-sigfpe.patch
    (from rev 423970, sagemath-doc/trunk/sagemath-ecl-sigfpe.patch)
Deleted:
  sagemath-doc/repos/community-any/PKGBUILD
  sagemath-doc/repos/community-any/docbuild_main.patch
  sagemath-doc/repos/community-any/sagemath-doc-segfault.patch
  sagemath-doc/repos/community-any/sagemath-doc-sphinx-1.8.patch
  sagemath-doc/repos/community-any/sagemath-ecl-sigfpe.patch

-------------------------------+
 PKGBUILD                      |  140 ++++---
 docbuild_main.patch           |   12 
 sagemath-cypari2.patch        |  711 ++++++++++++++++++++++++++++++++++++++++
 sagemath-doc-segfault.patch   |  126 +++----
 sagemath-doc-sphinx-1.8.patch |  348 ++++++++++++++++---
 sagemath-ecl-sigfpe.patch     |  294 ++++++++--------
 6 files changed, 1290 insertions(+), 341 deletions(-)

Deleted: PKGBUILD
===================================================================
--- PKGBUILD	2019-01-18 08:00:10 UTC (rev 423970)
+++ PKGBUILD	2019-01-18 08:00:43 UTC (rev 423971)
@@ -1,68 +0,0 @@
-# Maintainer: Antonio Rojas <arojas at archlinux.org>
-
-pkgname=sagemath-doc
-pkgver=8.6
-pkgrel=1
-pkgdesc="HTML documentation and inline help for SageMath"
-arch=(any)
-url="http://www.sagemath.org"
-license=(GPL)
-depends=(python2-sphinx gap-doc thebe)
-makedepends=(sagemath python2-pyzmq python2-docutils python2-jupyter_client python2-pkgconfig cython2 python2-ipywidgets)
-source=("$pkgname-$pkgver.tar.gz::https://github.com/sagemath/sage/archive/$pkgver.tar.gz"
-        docbuild_main.patch
-        sagemath-doc-sphinx-1.8.patch
-        sagemath-doc-segfault.patch
-        sagemath-ecl-sigfpe.patch)
-sha256sums=('dea613fc955cada76aaa7ab379bc5a219fe8b496064824f8c798b2b1651442fa'
-            'ea5e17bb7a7cb36a22e5e3872fcc2585852bc971c4b139b0b2cd69a36c1b009b'
-            '17aae8d9c76a4e14cf3a4f5c7c9470e5312b18976bdd60f970ee736ca03a8cb3'
-            '141ac064305526785fb6d9507896876cbf893cd41ec1e42d86fc836f766c200f'
-            'a42f3b152b1aedb8abf16bc70971419919d1fe30328574e7fef8305f9d07d938')
-
-prepare() {
-  cd sage-$pkgver
-
-# fix relative imports
-  patch -p0 -i ../docbuild_main.patch
-# use sage_setup imports from sagemath source, but use system sage ones (which include compiled modules)
-  mkdir -p local-python
-  ln -sr src/sage_setup local-python
-# fix build with sphinx 1.8
-  patch -p1 -i ../sagemath-doc-sphinx-1.8.patch
-# Partially revert https://trac.sagemath.org/ticket/24655 to workaround a segfault
-  patch -Rp1 -i ../sagemath-doc-segfault.patch
-# Fix SIGFPE crashes with ecl 16.1.3 https://trac.sagemath.org/ticket/22191
-  patch -p1 -i ../sagemath-ecl-sigfpe.patch
-}
-
-build() {
-  cd sage-$pkgver/src
-
-  export SAGE_LOCAL="/usr"
-  export SAGE_ROOT="/usr"
-  export SAGE_SRC="$PWD"
-  export SAGE_DOC_SRC="$SAGE_SRC"/doc
-  export SAGE_DOC="$SAGE_DOC_SRC"
-  export SAGE_DOC_MATHJAX=yes
-  export PYTHONPATH="$srcdir"/sage-$pkgver/local-python
-  python2 sage_setup/docbuild --no-pdf-links all html
-}
-
-package() {
-  cd sage-$pkgver/src/doc
- 
-  mkdir -p "$pkgdir"/usr/share/doc/sage/en
-  cp -r en/introspect "$pkgdir"/usr/share/doc/sage/en
-  cp -r common "$pkgdir"/usr/share/doc/sage
-  cp -r html "$pkgdir"/usr/share/doc/sage
-
-# Replace duplicated files by symlinks (Gentoo)
-  cd "$pkgdir"/usr/share/doc/sage
-  mv html/en/_static{,.tmp}
-  for _dir in `find -name _static` ; do
-        rm -r $_dir
-        ln -s /usr/share/doc/sage/html/en/_static $_dir
-  done
-  mv html/en/_static{.tmp,}
-}

Copied: sagemath-doc/repos/community-any/PKGBUILD (from rev 423970, sagemath-doc/trunk/PKGBUILD)
===================================================================
--- PKGBUILD	                        (rev 0)
+++ PKGBUILD	2019-01-18 08:00:43 UTC (rev 423971)
@@ -0,0 +1,72 @@
+# Maintainer: Antonio Rojas <arojas at archlinux.org>
+
+pkgname=sagemath-doc
+pkgver=8.6
+pkgrel=2
+pkgdesc="HTML documentation and inline help for SageMath"
+arch=(any)
+url="http://www.sagemath.org"
+license=(GPL)
+depends=(python2-sphinx gap-doc thebe)
+makedepends=(sagemath python2-pyzmq python2-docutils python2-jupyter_client python2-pkgconfig cython2 python2-ipywidgets)
+source=("$pkgname-$pkgver.tar.gz::https://github.com/sagemath/sage/archive/$pkgver.tar.gz"
+        docbuild_main.patch
+        sagemath-doc-sphinx-1.8.patch
+        sagemath-doc-segfault.patch
+        sagemath-ecl-sigfpe.patch
+        sagemath-cypari2.patch)
+sha256sums=('dea613fc955cada76aaa7ab379bc5a219fe8b496064824f8c798b2b1651442fa'
+            'ea5e17bb7a7cb36a22e5e3872fcc2585852bc971c4b139b0b2cd69a36c1b009b'
+            '8ed0b9151d392b9e1abbc2921e98f86000d0e8d3a78994e6fd3fd4610957e8b9'
+            '141ac064305526785fb6d9507896876cbf893cd41ec1e42d86fc836f766c200f'
+            'a42f3b152b1aedb8abf16bc70971419919d1fe30328574e7fef8305f9d07d938'
+            'ca47248d2ed5edfe663ea02e261ddbb26a7cb03bef67928dbec690d9b9a8f129')
+
+prepare() {
+  cd sage-$pkgver
+
+# fix relative imports
+  patch -p0 -i ../docbuild_main.patch
+# use sage_setup imports from sagemath source, but use system sage ones (which include compiled modules)
+  mkdir -p local-python
+  ln -sr src/sage_setup local-python
+# fix build with sphinx 1.8
+  patch -p1 -i ../sagemath-doc-sphinx-1.8.patch
+# Partially revert https://trac.sagemath.org/ticket/24655 to workaround a segfault
+  patch -Rp1 -i ../sagemath-doc-segfault.patch
+# Fix build with cypari 2.0 https://trac.sagemath.org/ticket/26442
+  patch -p1 -i ../sagemath-cypari2.patch
+# Fix SIGFPE crashes with ecl 16.1.3 https://trac.sagemath.org/ticket/22191
+  patch -p1 -i ../sagemath-ecl-sigfpe.patch
+}
+
+build() {
+  cd sage-$pkgver/src
+
+  export SAGE_LOCAL="/usr"
+  export SAGE_ROOT="/usr"
+  export SAGE_SRC="$PWD"
+  export SAGE_DOC_SRC="$SAGE_SRC"/doc
+  export SAGE_DOC="$SAGE_DOC_SRC"
+  export SAGE_DOC_MATHJAX=yes
+  export PYTHONPATH="$srcdir"/sage-$pkgver/local-python
+  python2 sage_setup/docbuild --no-pdf-links all html
+}
+
+package() {
+  cd sage-$pkgver/src/doc
+ 
+  mkdir -p "$pkgdir"/usr/share/doc/sage/en
+  cp -r en/introspect "$pkgdir"/usr/share/doc/sage/en
+  cp -r common "$pkgdir"/usr/share/doc/sage
+  cp -r html "$pkgdir"/usr/share/doc/sage
+
+# Replace duplicated files by symlinks (Gentoo)
+  cd "$pkgdir"/usr/share/doc/sage
+  mv html/en/_static{,.tmp}
+  for _dir in `find -name _static` ; do
+    rm -r $_dir
+    ln -s /usr/share/doc/sage/html/en/_static $_dir
+  done
+  mv html/en/_static{.tmp,}
+}

Deleted: docbuild_main.patch
===================================================================
--- docbuild_main.patch	2019-01-18 08:00:10 UTC (rev 423970)
+++ docbuild_main.patch	2019-01-18 08:00:43 UTC (rev 423971)
@@ -1,6 +0,0 @@
---- src/sage_setup/docbuild/__main__.py.orig
-+++ src/sage_setup/docbuild/__main__.py
-@@ -1,2 +1,2 @@
--from . import main
-+from sage_setup.docbuild import main
- main()

Copied: sagemath-doc/repos/community-any/docbuild_main.patch (from rev 423970, sagemath-doc/trunk/docbuild_main.patch)
===================================================================
--- docbuild_main.patch	                        (rev 0)
+++ docbuild_main.patch	2019-01-18 08:00:43 UTC (rev 423971)
@@ -0,0 +1,6 @@
+--- src/sage_setup/docbuild/__main__.py.orig
++++ src/sage_setup/docbuild/__main__.py
+@@ -1,2 +1,2 @@
+-from . import main
++from sage_setup.docbuild import main
+ main()

Copied: sagemath-doc/repos/community-any/sagemath-cypari2.patch (from rev 423970, sagemath-doc/trunk/sagemath-cypari2.patch)
===================================================================
--- sagemath-cypari2.patch	                        (rev 0)
+++ sagemath-cypari2.patch	2019-01-18 08:00:43 UTC (rev 423971)
@@ -0,0 +1,711 @@
+diff --git a/src/sage/matrix/matrix_integer_dense.pxd b/src/sage/matrix/matrix_integer_dense.pxd
+index bc3af7c..5dd2a8e 100644
+--- a/src/sage/matrix/matrix_integer_dense.pxd
++++ b/src/sage/matrix/matrix_integer_dense.pxd
+@@ -30,6 +30,5 @@ cdef class Matrix_integer_dense(Matrix_dense):
+ 
+     cdef Matrix_integer_dense _new(self, Py_ssize_t nrows, Py_ssize_t ncols)
+ 
+-    cdef extract_hnf_from_pari_matrix(self, GEN H, int flag, bint include_zero_rows)
+ 
+ cpdef _lift_crt(Matrix_integer_dense M, residues, moduli=*)
+diff --git a/src/sage/matrix/matrix_integer_dense.pyx b/src/sage/matrix/matrix_integer_dense.pyx
+index 4f0b0e6..87e3391 100644
+--- a/src/sage/matrix/matrix_integer_dense.pyx
++++ b/src/sage/matrix/matrix_integer_dense.pyx
+@@ -87,11 +87,11 @@ from .args cimport SparseEntry, MatrixArgs_init
+ #########################################################
+ # PARI C library
+ from cypari2.gen cimport Gen
++from cypari2.stack cimport clear_stack, new_gen
++from cypari2.paridecl cimport *
+ from sage.libs.pari.convert_gmp cimport INT_to_mpz
+ from sage.libs.pari.convert_flint cimport (_new_GEN_from_fmpz_mat_t,
+            _new_GEN_from_fmpz_mat_t_rotate90, integer_matrix)
+-from cypari2.stack cimport clear_stack
+-from cypari2.paridecl cimport *
+ #########################################################
+ 
+ from sage.arith.multi_modular cimport MultiModularBasis
+@@ -2016,10 +2016,7 @@ cdef class Matrix_integer_dense(Matrix_dense):
+             raise ValueError("transformation matrix only available with p-adic algorithm")
+         elif algorithm in ["pari", "pari0", "pari1", "pari4"]:
+             flag = int(algorithm[-1]) if algorithm != "pari" else 1
+-            if self.height().ndigits() > 10000 or n >= 50:
+-                H_m = self._hnf_pari_big(flag, include_zero_rows=include_zero_rows)
+-            else:
+-                H_m = self._hnf_pari(flag, include_zero_rows=include_zero_rows)
++            H_m = self._hnf_pari(flag, include_zero_rows=include_zero_rows)
+         elif algorithm == 'ntl':
+             if nr != nc:
+                 raise ValueError("ntl only computes HNF for square matrices of full rank.")
+@@ -5664,6 +5661,7 @@ cdef class Matrix_integer_dense(Matrix_dense):
+         matrices.
+ 
+         EXAMPLES::
++
+             sage: matrix(ZZ,3,[1..9])._rank_pari()
+             2
+         """
+@@ -5674,16 +5672,12 @@ cdef class Matrix_integer_dense(Matrix_dense):
+ 
+     def _hnf_pari(self, int flag=0, bint include_zero_rows=True):
+         """
+-        Hermite form of this matrix, computed using PARI.  The
+-        computation is done entirely on the PARI stack, then the PARI
+-        stack is cleared.  This function is only useful for small
+-        matrices, and can crash on large matrices (e.g., if the PARI
+-        stack overflows).
++        Hermite normal form of this matrix, computed using PARI.
+ 
+         INPUT:
+ 
+         - ``flag`` -- 0 (default), 1, 3 or 4 (see docstring for
+-          gp.mathnf).
++          ``pari.mathnf``).
+ 
+         - ``include_zero_rows`` -- boolean. if False, do not include
+           any of the zero rows at the bottom of the matrix in the
+@@ -5733,98 +5727,13 @@ cdef class Matrix_integer_dense(Matrix_dense):
+             sage: pari('mathnf(Mat([0,1]), 4)')
+             [Mat(1), [1, 0; 0, 1]]
+         """
+-        cdef GEN A
+         sig_on()
+         A = _new_GEN_from_fmpz_mat_t_rotate90(self._matrix)
+-        cdef GEN H = mathnf0(A, flag)
+-        B = self.extract_hnf_from_pari_matrix(H, flag, include_zero_rows)
+-        clear_stack()  # This calls sig_off()
+-        return B
+-
+-
+-    def _hnf_pari_big(self, int flag=0, bint include_zero_rows=True):
+-        """
+-        Hermite form of this matrix, computed using PARI.
+-
+-        INPUT:
+-
+-        - ``flag`` -- 0 (default), 1, 3 or 4 (see docstring for
+-          gp.mathnf).
+-
+-        - ``include_zero_rows`` -- boolean. if False, do not include
+-          any of the zero rows at the bottom of the matrix in the
+-          output.
+-
+-        .. NOTE::
+-
+-            In no cases is the transformation matrix returned by this
+-            function.
+-
+-        EXAMPLES::
+-
+-            sage: a = matrix(ZZ,3,3,[1..9])
+-            sage: a._hnf_pari_big(flag=0, include_zero_rows=True)
+-            [1 2 3]
+-            [0 3 6]
+-            [0 0 0]
+-            sage: a._hnf_pari_big(flag=1, include_zero_rows=True)
+-            [1 2 3]
+-            [0 3 6]
+-            [0 0 0]
+-            sage: a._hnf_pari_big(flag=3, include_zero_rows=True)
+-            [1 2 3]
+-            [0 3 6]
+-            [0 0 0]
+-            sage: a._hnf_pari_big(flag=4, include_zero_rows=True)
+-            [1 2 3]
+-            [0 3 6]
+-            [0 0 0]
+-
+-        Check that ``include_zero_rows=False`` works correctly::
+-
+-            sage: matrix(ZZ,3,[1..9])._hnf_pari_big(0, include_zero_rows=False)
+-            [1 2 3]
+-            [0 3 6]
+-            sage: matrix(ZZ,3,[1..9])._hnf_pari_big(1, include_zero_rows=False)
+-            [1 2 3]
+-            [0 3 6]
+-            sage: matrix(ZZ,3,[1..9])._hnf_pari_big(3, include_zero_rows=False)
+-            [1 2 3]
+-            [0 3 6]
+-            sage: matrix(ZZ,3,[1..9])._hnf_pari_big(4, include_zero_rows=False)
+-            [1 2 3]
+-            [0 3 6]
+-        """
+-        cdef Gen H = integer_matrix(self._matrix, 1)
+-        H = H.mathnf(flag)
+-        sig_on()
+-        B = self.extract_hnf_from_pari_matrix(H.g, flag, include_zero_rows)
+-        clear_stack()  # This calls sig_off()
+-        return B
+-
+-    cdef extract_hnf_from_pari_matrix(self, GEN H, int flag, bint include_zero_rows):
+-        # Throw away the transformation matrix (yes, we should later
+-        # code this to keep track of it).
+-        cdef mpz_t tmp
+-        mpz_init(tmp)
+-        if flag > 0:
+-            H = gel(H,1)
+-
+-        # Figure out how many columns we got back.
+-        cdef Py_ssize_t H_nc = glength(H)  # number of columns
+-        # Now get the resulting Hermite form matrix back to Sage, suitably re-arranged.
+-        cdef Matrix_integer_dense B
+-        if include_zero_rows:
+-            B = self.new_matrix()
+-        else:
+-            B = self.new_matrix(nrows=H_nc)
+-        for i in range(self._ncols):
+-            for j in range(H_nc):
+-                INT_to_mpz(tmp, gcoeff(H, i+1, H_nc-j))
+-                fmpz_set_mpz(fmpz_mat_entry(B._matrix,j,self._ncols-i-1),tmp)
+-        mpz_clear(tmp)
+-        return B
+-
++        H = mathnf0(A, flag)
++        if typ(H) == t_VEC:
++            H = gel(H, 1)
++        GenH = new_gen(H)
++        return extract_hnf_from_pari_matrix(self, GenH, include_zero_rows)
+ 
+     def p_minimal_polynomials(self, p, s_max=None):
+         r"""
+@@ -5966,7 +5875,27 @@ cdef inline GEN pari_GEN(Matrix_integer_dense B):
+     return A
+ 
+ 
+-    #####################################################################################
++cdef extract_hnf_from_pari_matrix(Matrix_integer_dense self, Gen H, bint include_zero_rows):
++    cdef mpz_t tmp
++    mpz_init(tmp)
++
++    # Figure out how many columns we got back.
++    cdef long H_nc = glength(H.g)  # number of columns
++    # Now get the resulting Hermite form matrix back to Sage, suitably re-arranged.
++    cdef Matrix_integer_dense B
++    if include_zero_rows:
++        B = self.new_matrix()
++    else:
++        B = self.new_matrix(nrows=H_nc)
++    cdef long i, j
++    for i in range(self._ncols):
++        for j in range(H_nc):
++            sig_check()
++            INT_to_mpz(tmp, gcoeff(H.g, i+1, H_nc-j))
++            fmpz_set_mpz(fmpz_mat_entry(B._matrix,j,self._ncols-i-1),tmp)
++    mpz_clear(tmp)
++    return B
++
+ 
+ cdef _clear_columns(Matrix_integer_dense A, pivots, Py_ssize_t n):
+     # Clear all columns
+@@ -5990,11 +5919,6 @@ cdef _clear_columns(Matrix_integer_dense A, pivots, Py_ssize_t n):
+     fmpz_clear(t)
+     sig_off()
+ 
+-###############################################################
+-
+-
+-
+-
+ 
+ cpdef _lift_crt(Matrix_integer_dense M, residues, moduli=None):
+     """
+diff --git a/src/sage/modular/modform/eis_series_cython.pyx b/src/sage/modular/modform/eis_series_cython.pyx
+index f7e944c..3557c6b 100644
+--- a/src/sage/modular/modform/eis_series_cython.pyx
++++ b/src/sage/modular/modform/eis_series_cython.pyx
+@@ -3,7 +3,7 @@ Eisenstein Series (optimized compiled functions)
+ """
+ 
+ from cysignals.memory cimport check_allocarray, sig_free
+-from cysignals.signals cimport sig_on, sig_off
++from cysignals.signals cimport sig_check
+ 
+ from sage.rings.rational_field import QQ
+ from sage.rings.power_series_ring import PowerSeriesRing
+@@ -161,8 +161,7 @@ cpdef eisenstein_series_poly(int k, int prec = 10) :
+     """
+     cdef mpz_t *val = <mpz_t *>check_allocarray(prec, sizeof(mpz_t))
+     cdef mpz_t one, mult, term, last, term_m1, last_m1
+-    cdef unsigned long int expt
+-    cdef long ind, ppow, int_p
++    cdef long ind
+     cdef int i
+     cdef Fmpz_poly res = Fmpz_poly.__new__(Fmpz_poly)
+ 
+@@ -173,8 +172,6 @@ cpdef eisenstein_series_poly(int k, int prec = 10) :
+     if (prec == 0):
+         return Fmpz_poly.__new__(Fmpz_poly)
+ 
+-    sig_on()
+-
+     mpz_init(one)
+     mpz_init(term)
+     mpz_init(last)
+@@ -182,33 +179,33 @@ cpdef eisenstein_series_poly(int k, int prec = 10) :
+     mpz_init(term_m1)
+     mpz_init(last_m1)
+ 
+-    for i from 0 <= i < prec :
+-        mpz_init(val[i])
+-        mpz_set_si(val[i], 1)
++    for i in range(prec):
++        mpz_init_set_si(val[i], 1)
+ 
+     mpz_set_si(one, 1)
+ 
+-    expt = <unsigned long int>(k - 1)
+-    a0 = - bernoulli(k) / (2*k)
++    cdef unsigned long expt = k - 1
++    a0 = -bernoulli(k) / (2*k)
+ 
+-    for p in primes(1,prec) :
+-        int_p = int(p)
+-        ppow = <long int>int_p
++    cdef long p, ppow
++    for p in primes(1, prec) :
++        ppow = p
+ 
+-        mpz_set_si(mult, int_p)
++        mpz_set_si(mult, p)
+         mpz_pow_ui(mult, mult, expt)
+         mpz_mul(term, mult, mult)
+         mpz_set(last, mult)
+ 
+-        while (ppow < prec):
++        while ppow < prec:
++            sig_check()
+             ind = ppow
+             mpz_sub(term_m1, term, one)
+             mpz_sub(last_m1, last, one)
+-            while (ind < prec):
++            while ind < prec:
+                 mpz_mul(val[ind], val[ind], term_m1)
+                 mpz_fdiv_q(val[ind], val[ind], last_m1)
+                 ind += ppow
+-            ppow *= int_p
++            ppow *= p
+             mpz_set(last, term)
+             mpz_mul(term, term, mult)
+ 
+@@ -228,6 +225,4 @@ cpdef eisenstein_series_poly(int k, int prec = 10) :
+ 
+     sig_free(val)
+ 
+-    sig_off()
+-
+     return res
+diff --git a/src/sage/plot/complex_plot.pyx b/src/sage/plot/complex_plot.pyx
+index 758fb70..f499a3e 100644
+--- a/src/sage/plot/complex_plot.pyx
++++ b/src/sage/plot/complex_plot.pyx
+@@ -19,7 +19,7 @@ Complex Plots
+ from __future__ import absolute_import
+ 
+ # TODO: use NumPy buffers and complex fast_callable (when supported)
+-from cysignals.signals cimport sig_on, sig_off
++from cysignals.signals cimport sig_on, sig_off, sig_check
+ 
+ cimport numpy as cnumpy
+ 
+@@ -381,12 +381,18 @@ def complex_plot(f, xrange, yrange, **options):
+         pass
+ 
+     cdef double x, y
+-    ignore, ranges = setup_for_eval_on_grid([], [xrange, yrange], options['plot_points'])
+-    xrange,yrange=[r[:2] for r in ranges]
+-    sig_on()
+-    z_values = [[  f(new_CDF_element(x, y)) for x in srange(*ranges[0], include_endpoint=True)]
+-                                            for y in srange(*ranges[1], include_endpoint=True)]
+-    sig_off()
++    _, ranges = setup_for_eval_on_grid([], [xrange, yrange], options['plot_points'])
++    xrange = ranges[0]
++    yrange = ranges[1]
++    cdef list z_values = []
++    cdef list row
++    for y in srange(*yrange, include_endpoint=True):
++        row = []
++        for x in srange(*xrange, include_endpoint=True):
++            sig_check()
++            row.append(f(new_CDF_element(x, y)))
++        z_values.append(row)
++
+     g = Graphics()
+     g._set_extra_kwds(Graphics._extract_kwds_for_show(options, ignore=['xmin', 'xmax']))
+     g.add_primitive(ComplexPlot(complex_to_rgb(z_values), xrange, yrange, options))
+diff --git a/src/sage/rings/asymptotic/asymptotic_expansion_generators.py b/src/sage/rings/asymptotic/asymptotic_expansion_generators.py
+index 84fa0e4..18f8e90 100644
+--- a/src/sage/rings/asymptotic/asymptotic_expansion_generators.py
++++ b/src/sage/rings/asymptotic/asymptotic_expansion_generators.py
+@@ -1095,7 +1095,7 @@ class AsymptoticExpansionGenerators(SageObject):
+             sage: asymptotic_expansions.ImplicitExpansion('Z', phi=lambda u: 1 + 2*u + u^2, tau=2, precision=5)
+             Traceback (most recent call last):
+             ...
+-            ZeroDivisionError: Symbolic division by zero
++            ZeroDivisionError: symbolic division by zero
+             sage: asymptotic_expansions.ImplicitExpansion('Z', phi=lambda u: 1 + 2*u + u^2, tau=3, precision=5)
+             3 - 4*I*sqrt(3)*Z^(-1/2) + 6*I*sqrt(3)*Z^(-3/2) + O(Z^(-2))
+ 
+diff --git a/src/sage/rings/finite_rings/element_pari_ffelt.pyx b/src/sage/rings/finite_rings/element_pari_ffelt.pyx
+index ff73a1f..2fcd3a1 100644
+--- a/src/sage/rings/finite_rings/element_pari_ffelt.pyx
++++ b/src/sage/rings/finite_rings/element_pari_ffelt.pyx
+@@ -869,7 +869,8 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+             Univariate Polynomial Ring in beta over Finite Field of size 3
+         """
+         sig_on()
+-        return self._parent.polynomial_ring(name)(new_gen(FF_to_FpXQ_i(self.val)))
++        pol = new_gen(FF_to_FpXQ(self.val))
++        return self._parent.polynomial_ring(name)(pol)
+ 
+     def minpoly(self, var='x'):
+         """
+@@ -887,7 +888,8 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+             y^2 + 1
+         """
+         sig_on()
+-        return self._parent.polynomial_ring(var)(new_gen(FF_minpoly(self.val)))
++        pol = new_gen(FF_minpoly(self.val))
++        return self._parent.polynomial_ring(var)(pol)
+ 
+     def charpoly(self, var='x'):
+         """
+@@ -905,7 +907,8 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+             y^2 + 1
+         """
+         sig_on()
+-        return self._parent.polynomial_ring(var)(new_gen(FF_charpoly(self.val)))
++        pol = new_gen(FF_charpoly(self.val))
++        return self._parent.polynomial_ring(var)(pol)
+ 
+     def is_square(self):
+         """
+diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx
+index 17e62f3..9e99bde 100644
+--- a/src/sage/rings/integer.pyx
++++ b/src/sage/rings/integer.pyx
+@@ -6806,6 +6806,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
+             ....:         (2^100).binomial(2^22, algorithm='pari')
+             ....:     except AlarmInterrupt:
+             ....:         pass
++            doctest:...: RuntimeWarning: cypari2 leaked ... bytes on the PARI stack...
+         """
+         cdef Integer x
+         cdef Integer mm
+diff --git a/src/sage/rings/number_field/maps.py b/src/sage/rings/number_field/maps.py
+index 1727c13..5717227 100644
+--- a/src/sage/rings/number_field/maps.py
++++ b/src/sage/rings/number_field/maps.py
+@@ -358,7 +358,7 @@ class MapRelativeNumberFieldToRelativeVectorSpace(NumberFieldIsomorphism):
+             g = g(beta).lift()
+         # Convert the coefficients to elements of the base field.
+         B, from_B, _ = K.absolute_base_field()
+-        return self.codomain()([from_B(B(z.lift(), check=False)) for z in g.Vecrev(-K.relative_degree())])
++        return self.codomain()([from_B(B(z.lift(), check=False)) for z in g.Vecrev(K.relative_degree())])
+ 
+ 
+ class NameChangeMap(NumberFieldIsomorphism):
+diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx
+index a711e94..20895c0 100644
+--- a/src/sage/rings/polynomial/polynomial_element.pyx
++++ b/src/sage/rings/polynomial/polynomial_element.pyx
+@@ -4363,8 +4363,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
+             sage: G.prod() == g
+             True
+         """
+-        pols = G[0]
+-        exps = G[1]
++        pols, exps = G
+         R = self._parent
+         F = [(R(f), int(e)) for f, e in zip(pols, exps)]
+ 
+diff --git a/src/sage/rings/power_series_pari.pyx b/src/sage/rings/power_series_pari.pyx
+index e37e0a3..2e03ade 100644
+--- a/src/sage/rings/power_series_pari.pyx
++++ b/src/sage/rings/power_series_pari.pyx
+@@ -678,7 +678,8 @@ cdef class PowerSeries_pari(PowerSeries):
+             g = g.truncate()
+         if typ(g.g) == t_POL and varn(g.g) == vn:
+             # t_POL has 2 codewords.  Use new_ref instead of g[i] for speed.
+-            return [R(g.new_ref(gel(g.g, i))) for i in range(2, lg(g.g))]
++            G = g.fixGEN()
++            return [R(g.new_ref(gel(G, i))) for i in range(2, lg(G))]
+         else:
+             return [R(g)]
+ 
+@@ -729,6 +730,7 @@ cdef class PowerSeries_pari(PowerSeries):
+             return []
+ 
+         cdef pari_gen g = self.g
++        g.fixGEN()
+         cdef long l, m
+ 
+         R = self.base_ring()
+diff --git a/src/sage/rings/real_mpfr.pyx b/src/sage/rings/real_mpfr.pyx
+index e273190..3b89f4b 100644
+--- a/src/sage/rings/real_mpfr.pyx
++++ b/src/sage/rings/real_mpfr.pyx
+@@ -3212,7 +3212,6 @@ cdef class RealNumber(sage.structure.element.RingElement):
+         # by using internal interfaces of MPFR, which are documented
+         # as subject-to-change.
+ 
+-        sig_on()
+         if mpfr_nan_p(self.value) or mpfr_inf_p(self.value):
+             raise ValueError('Cannot convert NaN or infinity to Pari float')
+ 
+@@ -3234,6 +3233,7 @@ cdef class RealNumber(sage.structure.element.RingElement):
+         cdef mp_exp_t exponent
+         cdef GEN pari_float
+ 
++        sig_on()
+         if mpfr_zero_p(self.value):
+             pari_float = real_0_bit(-rounded_prec)
+         else:
+@@ -3245,7 +3245,7 @@ cdef class RealNumber(sage.structure.element.RingElement):
+             # Create a PARI REAL
+             pari_float = cgetr(2 + rounded_prec / wordsize)
+             pari_float[1] = evalexpo(exponent + rounded_prec - 1) + evalsigne(mpfr_sgn(self.value))
+-            mpz_export(&pari_float[2], NULL, 1, wordsize/8, 0, 0, mantissa)
++            mpz_export(&pari_float[2], NULL, 1, wordsize // 8, 0, 0, mantissa)
+             mpz_clear(mantissa)
+ 
+         return new_gen(pari_float)
+diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx
+index 586d4ab..c14b9a6 100644
+--- a/src/sage/symbolic/expression.pyx
++++ b/src/sage/symbolic/expression.pyx
+@@ -1273,12 +1273,7 @@ cdef class Expression(CommutativeRingElement):
+             sage: f._convert({'parent':int})
+             0
+         """
+-        cdef GEx res
+-        sig_on()
+-        try:
+-            res = self._gobj.evalf(0, kwds)
+-        finally:
+-            sig_off()
++        cdef GEx res = self._gobj.evalf(0, kwds)
+         return new_Expression_from_GEx(self._parent, res)
+ 
+     def _mpfr_(self, R):
+@@ -2839,11 +2834,7 @@ cdef class Expression(CommutativeRingElement):
+             # constants are wrappers around Sage objects, compare directly
+             if is_a_constant(self._gobj.lhs()) and is_a_constant(self._gobj.rhs()):
+                 return self.operator()(self.lhs().pyobject(), self.rhs().pyobject())
+-            sig_on()
+-            try:
+-                pynac_result = decide_relational(self._gobj)
+-            finally:
+-                sig_off()
++            pynac_result = decide_relational(self._gobj)
+             if pynac_result == relational_undecidable:
+                 raise ValueError('undecidable relation: ' + repr(self))
+ 
+@@ -3233,27 +3224,23 @@ cdef class Expression(CommutativeRingElement):
+         cdef GEx x
+         cdef Expression _right = <Expression>right
+         cdef operators op
+-        sig_on()
+-        try:
+-            if is_a_relational(left._gobj):
+-                if is_a_relational(_right._gobj):
+-                    op = compatible_relation(relational_operator(left._gobj),
+-                                             relational_operator(_right._gobj))
+-                    x = relational(left._gobj.lhs() + _right._gobj.lhs(),
+-                                   left._gobj.rhs() + _right._gobj.rhs(),
+-                                   op)
+-                else:
+-                    x = relational(left._gobj.lhs() + _right._gobj,
+-                                   left._gobj.rhs() + _right._gobj,
+-                                   relational_operator(left._gobj))
+-            elif is_a_relational(_right._gobj):
+-                x = relational(left._gobj + _right._gobj.lhs(),
+-                               left._gobj + _right._gobj.rhs(),
+-                               relational_operator(_right._gobj))
++        if is_a_relational(left._gobj):
++            if is_a_relational(_right._gobj):
++                op = compatible_relation(relational_operator(left._gobj),
++                                         relational_operator(_right._gobj))
++                x = relational(left._gobj.lhs() + _right._gobj.lhs(),
++                               left._gobj.rhs() + _right._gobj.rhs(),
++                               op)
+             else:
+-                x = left._gobj + _right._gobj
+-        finally:
+-            sig_off()
++                x = relational(left._gobj.lhs() + _right._gobj,
++                               left._gobj.rhs() + _right._gobj,
++                               relational_operator(left._gobj))
++        elif is_a_relational(_right._gobj):
++            x = relational(left._gobj + _right._gobj.lhs(),
++                           left._gobj + _right._gobj.rhs(),
++                           relational_operator(_right._gobj))
++        else:
++            x = left._gobj + _right._gobj
+         return new_Expression_from_GEx(left._parent, x)
+ 
+     cpdef _sub_(left, right):
+@@ -3289,27 +3276,23 @@ cdef class Expression(CommutativeRingElement):
+         """
+         cdef GEx x
+         cdef Expression _right = <Expression>right
+-        sig_on()
+-        try:
+-            if is_a_relational(left._gobj):
+-                if is_a_relational(_right._gobj):
+-                    op = compatible_relation(relational_operator(left._gobj),
+-                                             relational_operator(_right._gobj))
+-                    x = relational(left._gobj.lhs() - _right._gobj.lhs(),
+-                                   left._gobj.rhs() - _right._gobj.rhs(),
+-                                   op)
+-                else:
+-                    x = relational(left._gobj.lhs() - _right._gobj,
+-                                   left._gobj.rhs() - _right._gobj,
+-                                   relational_operator(left._gobj))
+-            elif is_a_relational(_right._gobj):
+-                x = relational(left._gobj - _right._gobj.lhs(),
+-                               left._gobj - _right._gobj.rhs(),
+-                               relational_operator(_right._gobj))
++        if is_a_relational(left._gobj):
++            if is_a_relational(_right._gobj):
++                op = compatible_relation(relational_operator(left._gobj),
++                                         relational_operator(_right._gobj))
++                x = relational(left._gobj.lhs() - _right._gobj.lhs(),
++                               left._gobj.rhs() - _right._gobj.rhs(),
++                               op)
+             else:
+-                x = left._gobj - _right._gobj
+-        finally:
+-            sig_off()
++                x = relational(left._gobj.lhs() - _right._gobj,
++                               left._gobj.rhs() - _right._gobj,
++                               relational_operator(left._gobj))
++        elif is_a_relational(_right._gobj):
++            x = relational(left._gobj - _right._gobj.lhs(),
++                           left._gobj - _right._gobj.rhs(),
++                           relational_operator(_right._gobj))
++        else:
++            x = left._gobj - _right._gobj
+         return new_Expression_from_GEx(left._parent, x)
+ 
+     cpdef _mul_(left, right):
+@@ -3457,29 +3440,25 @@ cdef class Expression(CommutativeRingElement):
+         cdef GEx x
+         cdef Expression _right = <Expression>right
+         cdef operators o
+-        sig_on()
+-        try:
+-            if is_a_relational(left._gobj):
+-                if is_a_relational(_right._gobj):
+-                    op = compatible_relation(relational_operator(left._gobj),
+-                                             relational_operator(_right._gobj))
+-                    x = relational(left._gobj.lhs() * _right._gobj.lhs(),
+-                                   left._gobj.rhs() * _right._gobj.rhs(),
+-                                   op)
+-                else:
+-                    o = relational_operator(left._gobj)
+-                    x = relational(left._gobj.lhs() * _right._gobj,
+-                                   left._gobj.rhs() * _right._gobj,
+-                                   o)
+-            elif is_a_relational(_right._gobj):
+-                o = relational_operator(_right._gobj)
+-                x = relational(left._gobj * _right._gobj.lhs(),
+-                               left._gobj * _right._gobj.rhs(),
+-                               o)
++        if is_a_relational(left._gobj):
++            if is_a_relational(_right._gobj):
++                op = compatible_relation(relational_operator(left._gobj),
++                                         relational_operator(_right._gobj))
++                x = relational(left._gobj.lhs() * _right._gobj.lhs(),
++                               left._gobj.rhs() * _right._gobj.rhs(),
++                               op)
+             else:
+-                x = left._gobj * _right._gobj
+-        finally:
+-            sig_off()
++                o = relational_operator(left._gobj)
++                x = relational(left._gobj.lhs() * _right._gobj,
++                               left._gobj.rhs() * _right._gobj,
++                               o)
++        elif is_a_relational(_right._gobj):
++            o = relational_operator(_right._gobj)
++            x = relational(left._gobj * _right._gobj.lhs(),
++                           left._gobj * _right._gobj.rhs(),
++                           o)
++        else:
++            x = left._gobj * _right._gobj
+         return new_Expression_from_GEx(left._parent, x)
+ 
+     cpdef _div_(left, right):
+@@ -3553,7 +3532,7 @@ cdef class Expression(CommutativeRingElement):
+             sage: x/0
+             Traceback (most recent call last):
+             ...
+-            ZeroDivisionError: Symbolic division by zero
++            ZeroDivisionError: symbolic division by zero
+ 
+         Check if Pynac can compute divisions of Python longs (:trac:`13107`)::
+ 
+@@ -3563,7 +3542,6 @@ cdef class Expression(CommutativeRingElement):
+         cdef GEx x
+         cdef Expression _right = <Expression>right
+         cdef operators o
+-        sig_on()
+         try:
+             if is_a_relational(left._gobj):
+                 if is_a_relational(_right._gobj):
+@@ -3589,11 +3567,9 @@ cdef class Expression(CommutativeRingElement):
+             # TODO: change this to maybe cleverly do something involving Cython C++ exception handling.
+             # See http://docs.cython.org/docs/wrapping_CPlusPlus.html
+             if 'division by zero' in str(msg):
+-                raise ZeroDivisionError("Symbolic division by zero")
++                raise ZeroDivisionError("symbolic division by zero")
+             else:
+                 raise
+-        finally:
+-            sig_off()
+ 
+     def __invert__(self):
+         """
+@@ -5314,11 +5290,7 @@ cdef class Expression(CommutativeRingElement):
+         for k, v in sdict.iteritems():
+             smap.insert(make_pair((<Expression>self.coerce_in(k))._gobj,
+                                   (<Expression>self.coerce_in(v))._gobj))
+-        sig_on()
+-        try:
+-            res = self._gobj.subs_map(smap, 0)
+-        finally:
+-            sig_off()
++        res = self._gobj.subs_map(smap, 0)
+         return new_Expression_from_GEx(self._parent, res)
+ 
+     subs = substitute
+@@ -7183,12 +7155,7 @@ cdef class Expression(CommutativeRingElement):
+             x^2 + 2*x + 2
+         """
+         cdef Expression r = self.coerce_in(b)
+-        cdef GEx x
+-        sig_on()
+-        try:
+-            x = g_gcd(self._gobj, r._gobj)
+-        finally:
+-            sig_off()
++        cdef GEx x = g_gcd(self._gobj, r._gobj)
+         return new_Expression_from_GEx(self._parent, x)
+ 
+     def gosper_sum(self, *args):
+@@ -8983,12 +8950,7 @@ cdef class Expression(CommutativeRingElement):
+             sage: t = SR(1).zeta(); t
+             Infinity
+         """
+-        cdef GEx x
+-        sig_on()
+-        try:
+-            x = g_hold_wrapper(g_zeta, self._gobj, hold)
+-        finally:
+-            sig_off()
++        cdef GEx x = g_hold_wrapper(g_zeta, self._gobj, hold)
+         return new_Expression_from_GEx(self._parent, x)
+ 
+     def factorial(self, hold=False):

Deleted: sagemath-doc-segfault.patch
===================================================================
--- sagemath-doc-segfault.patch	2019-01-18 08:00:10 UTC (rev 423970)
+++ sagemath-doc-segfault.patch	2019-01-18 08:00:43 UTC (rev 423971)
@@ -1,63 +0,0 @@
-diff --git a/src/sage_setup/docbuild/__init__.py b/src/sage_setup/docbuild/__init__.py
-index 5877b5b..7dc8ff7 100644
---- a/src/sage_setup/docbuild/__init__.py
-+++ b/src/sage_setup/docbuild/__init__.py
-@@ -265,35 +265,29 @@ class DocBuilder(object):
-     # import the customized builder for object.inv files
-     inventory = builder_helper('inventory')
- 
--if NUM_THREADS > 1:
--    def build_many(target, args):
--        from multiprocessing import Pool
--        pool = Pool(NUM_THREADS, maxtasksperchild=1)
--        # map_async handles KeyboardInterrupt correctly. Plain map and
--        # apply_async does not, so don't use it.
--        x = pool.map_async(target, args, 1)
--        try:
--            ret = x.get(99999)
--            pool.close()
--            pool.join()
--        except Exception:
--            pool.terminate()
--            if ABORT_ON_ERROR:
--                raise
--        return ret
--else:
--    def build_many(target, args):
--        results = []
--
--        for arg in args:
--            try:
--                results.append(target(arg))
--            except Exception:
--                if ABORT_ON_ERROR:
--                    raise
--
--        return results
--
-+def build_many(target, args):
-+    # Pool() uses an actual fork() to run each new instance. This is important
-+    # for performance reasons, i.e., don't use a forkserver when it becomes
-+    # available with Python 3: Here, sage is already initialized which is quite
-+    # costly, with a forkserver we would have to reinitialize it for every
-+    # document we build. At the same time, don't serialize this by taking the
-+    # pool (and thus the call to fork()) out completely: The call to Sphinx
-+    # leaks memory, so we need to build each document in its own process to
-+    # control the RAM usage.
-+    from multiprocessing import Pool
-+    pool = Pool(NUM_THREADS, maxtasksperchild=1)
-+    # map_async handles KeyboardInterrupt correctly. Plain map and
-+    # apply_async does not, so don't use it.
-+    x = pool.map_async(target, args, 1)
-+    try:
-+        ret = x.get(99999)
-+        pool.close()
-+        pool.join()
-+    except Exception:
-+        pool.terminate()
-+        if ABORT_ON_ERROR:
-+            raise
-+    return ret
- 
- ##########################################
- #      Parallel Building Ref Manual      #

Copied: sagemath-doc/repos/community-any/sagemath-doc-segfault.patch (from rev 423970, sagemath-doc/trunk/sagemath-doc-segfault.patch)
===================================================================
--- sagemath-doc-segfault.patch	                        (rev 0)
+++ sagemath-doc-segfault.patch	2019-01-18 08:00:43 UTC (rev 423971)
@@ -0,0 +1,63 @@
+diff --git a/src/sage_setup/docbuild/__init__.py b/src/sage_setup/docbuild/__init__.py
+index 5877b5b..7dc8ff7 100644
+--- a/src/sage_setup/docbuild/__init__.py
++++ b/src/sage_setup/docbuild/__init__.py
+@@ -265,35 +265,29 @@ class DocBuilder(object):
+     # import the customized builder for object.inv files
+     inventory = builder_helper('inventory')
+ 
+-if NUM_THREADS > 1:
+-    def build_many(target, args):
+-        from multiprocessing import Pool
+-        pool = Pool(NUM_THREADS, maxtasksperchild=1)
+-        # map_async handles KeyboardInterrupt correctly. Plain map and
+-        # apply_async does not, so don't use it.
+-        x = pool.map_async(target, args, 1)
+-        try:
+-            ret = x.get(99999)
+-            pool.close()
+-            pool.join()
+-        except Exception:
+-            pool.terminate()
+-            if ABORT_ON_ERROR:
+-                raise
+-        return ret
+-else:
+-    def build_many(target, args):
+-        results = []
+-
+-        for arg in args:
+-            try:
+-                results.append(target(arg))
+-            except Exception:
+-                if ABORT_ON_ERROR:
+-                    raise
+-
+-        return results
+-
++def build_many(target, args):
++    # Pool() uses an actual fork() to run each new instance. This is important
++    # for performance reasons, i.e., don't use a forkserver when it becomes
++    # available with Python 3: Here, sage is already initialized which is quite
++    # costly, with a forkserver we would have to reinitialize it for every
++    # document we build. At the same time, don't serialize this by taking the
++    # pool (and thus the call to fork()) out completely: The call to Sphinx
++    # leaks memory, so we need to build each document in its own process to
++    # control the RAM usage.
++    from multiprocessing import Pool
++    pool = Pool(NUM_THREADS, maxtasksperchild=1)
++    # map_async handles KeyboardInterrupt correctly. Plain map and
++    # apply_async does not, so don't use it.
++    x = pool.map_async(target, args, 1)
++    try:
++        ret = x.get(99999)
++        pool.close()
++        pool.join()
++    except Exception:
++        pool.terminate()
++        if ABORT_ON_ERROR:
++            raise
++    return ret
+ 
+ ##########################################
+ #      Parallel Building Ref Manual      #

Deleted: sagemath-doc-sphinx-1.8.patch
===================================================================
--- sagemath-doc-sphinx-1.8.patch	2019-01-18 08:00:10 UTC (rev 423970)
+++ sagemath-doc-sphinx-1.8.patch	2019-01-18 08:00:43 UTC (rev 423971)
@@ -1,57 +0,0 @@
-diff --git a/src/sage_setup/docbuild/__init__.py b/src/sage_setup/docbuild/__init__.py
-index ff67979..83b49e1 100644
---- a/src/sage_setup/docbuild/__init__.py
-+++ b/src/sage_setup/docbuild/__init__.py
-@@ -332,6 +331,18 @@ class AllBuilder(object):
-         for document in refs:
-             getattr(get_builder(document), 'inventory')(*args, **kwds)
- 
-+        # In the inventory build, the directory
-+        # SAGE_DOC/inventory/en/reference/_static might be created,
-+        # but it is unnecessary in the inventory build -- this
-+        # directory should contain javascript and style files
-+        # specifically for the html build -- and it can confuse
-+        # intersphinx and the html builder when they look for
-+        # inventory files. So delete this directory.
-+        staticdir = os.path.join(SAGE_DOC, 'inventory', 'en', 'reference', '_static')
-+        if os.path.isdir(staticdir):
-+            logger.info("Deleting _static directory in the inventory build")
-+            shutil.rmtree(staticdir)
-+
-         logger.warning("Building reference manual, second pass.\n")
-         for document in refs:
-             getattr(get_builder(document), name)(*args, **kwds)
-@@ -526,6 +537,17 @@ class ReferenceBuilder(AllBuilder):
-             output_dir = self._output_dir(format, lang)
-             L = [(doc, lang, format, kwds) + args for doc in self.get_all_documents(refdir)]
-             build_many(build_ref_doc, L)
-+            # In the html build, a file -- not a directory --
-+            # SAGE_DOC/html/en/reference/_static might be created,
-+            # with the contents of Sphinx's graphviz.css file.  This
-+            # is supposed to be a directory, and the presence of this
-+            # file prevents copying of any css files, etc., to
-+            # reference/_static. So delete this file.
-+            staticfile = os.path.join(SAGE_DOC, 'html', 'en', 'reference', '_static')
-+            if os.path.isfile(staticfile):
-+                logger.info("Deleting _static file in the html build")
-+                os.unlink(staticfile)
-+
-             # The html refman must be build at the end to ensure correct
-             # merging of indexes and inventories.
-             # Sphinx is run here in the current process (not in a
-diff --git a/src/sage_setup/docbuild/ext/sage_autodoc.py b/src/sage_setup/docbuild/ext/sage_autodoc.py
-index 2c399bad51..96abec3382 100644
---- a/src/sage_setup/docbuild/ext/sage_autodoc.py
-+++ b/src/sage_setup/docbuild/ext/sage_autodoc.py
-@@ -39,8 +39,9 @@ from docutils.statemachine import ViewList
- import sphinx
- from sphinx.util import rpartition, force_decode
- from sphinx.locale import _
--from sphinx.pycode import ModuleAnalyzer, PycodeError
--from sphinx.application import ExtensionError
-+from sphinx.pycode import ModuleAnalyzer
-+from sphinx.errors import ExtensionError, PycodeError
-+from sphinx.util.logging import getLogger
- from sphinx.util.nodes import nested_parse_with_titles
- from docutils.parsers.rst import Directive
- from sphinx.util.inspect import getargspec, isdescriptor, safe_getmembers, \

Copied: sagemath-doc/repos/community-any/sagemath-doc-sphinx-1.8.patch (from rev 423970, sagemath-doc/trunk/sagemath-doc-sphinx-1.8.patch)
===================================================================
--- sagemath-doc-sphinx-1.8.patch	                        (rev 0)
+++ sagemath-doc-sphinx-1.8.patch	2019-01-18 08:00:43 UTC (rev 423971)
@@ -0,0 +1,291 @@
+diff --git a/src/sage_setup/docbuild/__init__.py b/src/sage_setup/docbuild/__init__.py
+index ff67979..83b49e1 100644
+--- a/src/sage_setup/docbuild/__init__.py
++++ b/src/sage_setup/docbuild/__init__.py
+@@ -332,6 +331,18 @@ class AllBuilder(object):
+         for document in refs:
+             getattr(get_builder(document), 'inventory')(*args, **kwds)
+ 
++        # In the inventory build, the directory
++        # SAGE_DOC/inventory/en/reference/_static might be created,
++        # but it is unnecessary in the inventory build -- this
++        # directory should contain javascript and style files
++        # specifically for the html build -- and it can confuse
++        # intersphinx and the html builder when they look for
++        # inventory files. So delete this directory.
++        staticdir = os.path.join(SAGE_DOC, 'inventory', 'en', 'reference', '_static')
++        if os.path.isdir(staticdir):
++            logger.info("Deleting _static directory in the inventory build")
++            shutil.rmtree(staticdir)
++
+         logger.warning("Building reference manual, second pass.\n")
+         for document in refs:
+             getattr(get_builder(document), name)(*args, **kwds)
+diff --git a/src/sage_setup/docbuild/ext/sage_autodoc.py b/src/sage_setup/docbuild/ext/sage_autodoc.py
+index 2c399bad51..96abec3382 100644
+--- a/src/sage_setup/docbuild/ext/sage_autodoc.py
++++ b/src/sage_setup/docbuild/ext/sage_autodoc.py
+@@ -39,8 +39,9 @@ from docutils.statemachine import ViewList
+ import sphinx
+ from sphinx.util import rpartition, force_decode
+ from sphinx.locale import _
+-from sphinx.pycode import ModuleAnalyzer, PycodeError
+-from sphinx.application import ExtensionError
++from sphinx.pycode import ModuleAnalyzer
++from sphinx.errors import ExtensionError, PycodeError
++from sphinx.util.logging import getLogger
+ from sphinx.util.nodes import nested_parse_with_titles
+ from docutils.parsers.rst import Directive
+ from sphinx.util.inspect import getargspec, isdescriptor, safe_getmembers, \
+diff --git a/src/sage_setup/docbuild/ext/multidocs.py b/src/sage_setup/docbuild/ext/multidocs.py
+index dc2e065e7e..ddd28c1a46 100644
+--- a/src/sage_setup/docbuild/ext/multidocs.py
++++ b/src/sage_setup/docbuild/ext/multidocs.py
+@@ -302,7 +302,6 @@ def init_subdoc(app):
+                     os.unlink(static_dir)
+             os.symlink(master_static_dir, static_dir)
+
+-        app.builder.copy_static_files = link_static_files
+
+     if app.config.multidoc_first_pass == 1:
+         app.config.intersphinx_mapping = {}
+diff --git a/src/sage_setup/docbuild/__init__.py b/src/sage_setup/docbuild/__init__.py
+index 0b24b1a..ff67979 100644
+--- a/src/sage_setup/docbuild/__init__.py
++++ b/src/sage_setup/docbuild/__init__.py
+@@ -47,7 +47,6 @@ import logging, warnings
+ 
+ logger = logging.getLogger(__name__)
+ 
+-import sphinx.cmdline
+ import sphinx.util.console
+ import sphinx.ext.intersphinx
+ 
+diff --git a/src/sage_setup/docbuild/ext/multidocs.py b/src/sage_setup/docbuild/ext/multidocs.py
+index 62d3946..262cb3c 100644
+--- a/src/sage_setup/docbuild/ext/multidocs.py
++++ b/src/sage_setup/docbuild/ext/multidocs.py
+@@ -32,6 +32,7 @@ from sphinx.util.console import bold
+ from sage.env import SAGE_DOC
+ from sage.misc.misc import sage_makedirs
+ 
++logger = sphinx.util.logging.getLogger(__name__)
+ 
+ CITE_FILENAME = 'citations.pickle'
+ 
+@@ -48,13 +49,13 @@ def merge_environment(app, env):
+ 
+     - domaindata['py']['modules'] # list of python modules
+     """
+-    app.info(bold('Merging environment/index files...'))
++    logger.info(bold('Merging environment/index files...'))
+     for curdoc in app.env.config.multidocs_subdoc_list:
+-        app.info("    %s:"%curdoc, nonl=1)
++        logger.info("    %s:"%curdoc, nonl=1)
+         docenv = get_env(app, curdoc)
+         if docenv is not None:
+             fixpath = lambda path: os.path.join(curdoc, path)
+-            app.info(" %s todos, %s index, %s citations"%(
++            logger.info(" %s todos, %s index, %s citations"%(
+                     len(docenv.todo_all_todos),
+                     len(docenv.indexentries),
+                     len(docenv.domaindata["std"]["citations"])
+@@ -99,8 +100,8 @@ def merge_environment(app, env):
+                 six.iteritems(docenv.domaindata['py']['modules'])):
+                 newmodules[ind] = (fixpath(modpath),v1,v2,v3)
+             env.domaindata['py']['modules'].update(newmodules)
+-            app.info(", %s modules"%(len(newmodules)))
+-    app.info('... done (%s todos, %s index, %s citations, %s modules)'%(
++            logger.info(", %s modules"%(len(newmodules)))
++    logger.info('... done (%s todos, %s index, %s citations, %s modules)'%(
+             len(env.todo_all_todos),
+             len(env.indexentries),
+             len(env.domaindata["std"]["citations"]),
+@@ -118,8 +119,8 @@ def get_env(app, curdoc):
+     try:
+         f = open(filename, 'rb')
+     except IOError:
+-        app.info("")
+-        app.warn("Unable to fetch %s " % filename)
++        logger.info("")
++        logger.warn("Unable to fetch %s " % filename)
+         return None
+     docenv = cPickle.load(f)
+     f.close()
+@@ -130,16 +131,16 @@ def merge_js_index(app):
+     """
+     Merge the JS indexes of the sub-docs into the main JS index
+     """
+-    app.info('')
+-    app.info(bold('Merging js index files...'))
++    logger.info('')
++    logger.info(bold('Merging js index files...'))
+     mapping = app.builder.indexer._mapping
+     for curdoc in app.env.config.multidocs_subdoc_list:
+-        app.info("    %s:"%curdoc, nonl=1)
++        logger.info("    %s:"%curdoc, nonl=1)
+         fixpath = lambda path: os.path.join(curdoc, path)
+         index = get_js_index(app, curdoc)
+         if index is not None:
+             # merge the mappings
+-            app.info(" %s js index entries"%(len(index._mapping)))
++            logger.info(" %s js index entries"%(len(index._mapping)))
+             for (ref, locs) in six.iteritems(index._mapping):
+                 newmapping = set(map(fixpath, locs))
+                 if ref in mapping:
+@@ -159,8 +160,8 @@ def merge_js_index(app):
+             dest = os.path.join(app.outdir, "_sources", curdoc)
+             if not os.path.exists(dest):
+                 os.symlink(os.path.join("..", curdoc, "_sources"), dest)
+-    app.info('... done (%s js index entries)'%(len(mapping)))
+-    app.info(bold('Writing js search indexes...'), nonl=1)
++    logger.info('... done (%s js index entries)'%(len(mapping)))
++    logger.info(bold('Writing js search indexes...'), nonl=1)
+     return [] # no extra page to setup
+ 
+ 
+@@ -181,8 +182,8 @@ def get_js_index(app, curdoc):
+     try:
+         f = open(indexfile, 'rb')
+     except IOError:
+-        app.info("")
+-        app.warn("Unable to fetch %s " % indexfile)
++        logger.info("")
++        logger.warn("Unable to fetch %s " % indexfile)
+         return None
+     indexer.load(f, sphinx.search.js_index)
+     f.close()
+@@ -238,7 +239,7 @@ def write_citations(app, citations):
+     outdir = citation_dir(app)
+     with atomic_write(os.path.join(outdir, CITE_FILENAME), binary=True) as f:
+         cPickle.dump(citations, f)
+-    app.info("Saved pickle file: %s" % CITE_FILENAME)
++    logger.info("Saved pickle file: %s" % CITE_FILENAME)
+ 
+ 
+ def fetch_citation(app, env):
+@@ -246,13 +247,13 @@ def fetch_citation(app, env):
+     Fetch the global citation index from the refman to allow for cross
+     references.
+     """
+-    app.builder.info(bold('loading cross citations... '), nonl=1)
++    logger.info(bold('loading cross citations... '), nonl=1)
+     filename = os.path.join(citation_dir(app), '..', CITE_FILENAME)
+     if not os.path.isfile(filename):
+         return
+     with open(filename, 'rb') as f:
+         cache = cPickle.load(f)
+-    app.builder.info("done (%s citations)."%len(cache))
++    logger.info("done (%s citations)."%len(cache))
+     cite = env.domaindata["std"]["citations"]
+     for ind, (path, tag, lineno) in six.iteritems(cache):
+         if ind not in cite: # don't override local citation
+@@ -265,18 +266,17 @@ def init_subdoc(app):
+     doc itself.
+     """
+     if app.config.multidocs_is_master:
+-        app.info(bold("Compiling the master document"))
++        logger.info(bold("Compiling the master document"))
+         app.connect('env-updated', merge_environment)
+         app.connect('html-collect-pages', merge_js_index)
+         if app.config.multidocs_subdoc_list:
+             # Master file with indexes computed by merging indexes:
+             # Monkey patch index fetching to silence warning about broken index
+             def load_indexer(docnames):
+-                app.builder.info(bold('skipping loading of indexes... '), nonl=1)
++                logger.info(bold('skipping loading of indexes... '), nonl=1)
+             app.builder.load_indexer = load_indexer
+-
+     else:
+-        app.info(bold("Compiling a sub-document"))
++        logger.info(bold("Compiling a sub-document"))
+         app.connect('html-page-context', fix_path_html)
+         if not app.config.multidoc_first_pass:
+             app.connect('env-updated', fetch_citation)
+@@ -292,7 +292,7 @@ def init_subdoc(app):
+                     def copy_static_files(self):
+                     [...]
+             """
+-            app.builder.info(bold('linking _static directory.'))
++            logger.info(bold('linking _static directory.'))
+             static_dir = os.path.join(app.builder.outdir, '_static')
+             master_static_dir = os.path.join('..', '_static')
+             if os.path.lexists(static_dir):
+diff --git a/src/sage_setup/docbuild/ext/sage_autodoc.py b/src/sage_setup/docbuild/ext/sage_autodoc.py
+index ecad739..587f592 100644
+--- a/src/sage_setup/docbuild/ext/sage_autodoc.py
++++ b/src/sage_setup/docbuild/ext/sage_autodoc.py
+@@ -49,6 +49,8 @@ from sphinx.util.inspect import getargspec, isdescriptor, safe_getmembers, \
+     isenumclass, isenumattribute
+ from sphinx.util.docstrings import prepare_docstring
+ 
++logger = getLogger(__name__)
++
+ try:
+     if sys.version_info >= (3,):
+         import typing
+@@ -554,7 +556,7 @@ class Documenter(object):
+ 
+         Returns True if successful, False if an error occurred.
+         """
+-        dbg = self.env.app.debug
++        dbg = logger.debug
+         if self.objpath:
+             dbg('[autodoc] from %s import %s',
+                 self.modname, '.'.join(self.objpath))
+@@ -988,7 +990,7 @@ class Documenter(object):
+             # be cached anyway)
+             self.analyzer.find_attr_docs()
+         except PycodeError as err:
+-            self.env.app.debug('[autodoc] module analyzer failed: %s', err)
++            logger.debug('[autodoc] module analyzer failed: %s', err)
+             # A few things could have happened here:
+             # * there is no source file -- e.g. for builtin and C modules
+             # * the source file contains syntax that Sphinx can not parse,
+@@ -1732,8 +1734,8 @@ class AutoDirective(Directive):
+             source, lineno = self.reporter.get_source_and_line(self.lineno)
+         except AttributeError:
+             source = lineno = None
+-        self.env.app.debug('[autodoc] %s:%s: input:\n%s',
+-                           source, lineno, self.block_text)
++        logger.debug('[autodoc] %s:%s: input:\n%s',
++                     source, lineno, self.block_text)
+ 
+         # find out what documenter to call
+         objtype = self.name[4:]
+@@ -1762,7 +1764,7 @@ class AutoDirective(Directive):
+         if not self.result:
+             return self.warnings
+ 
+-        self.env.app.debug2('[autodoc] output:\n%s', '\n'.join(self.result))
++        logger.debug('[autodoc] output:\n%s', '\n'.join(self.result))
+ 
+         # record all filenames as dependencies -- this will at least
+         # partially make automatic invalidation possible
+diff --git a/src/sage_setup/docbuild/sphinxbuild.py b/src/sage_setup/docbuild/sphinxbuild.py
+index 8f7034f..87c29b7 100644
+--- a/src/sage_setup/docbuild/sphinxbuild.py
++++ b/src/sage_setup/docbuild/sphinxbuild.py
+@@ -22,6 +22,7 @@ We redirect stdout and stderr to our own logger, and remove some unwanted chatte
+ # ****************************************************************************
+ 
+ import os, sys, re, sphinx
++import sphinx.cmd.build
+ 
+ # override the fancy multi-line formatting
+ def term_width_line(text):
+@@ -310,12 +311,12 @@ def runsphinx():
+     try:
+         sys.stdout = SageSphinxLogger(sys.stdout, os.path.basename(output_dir))
+         sys.stderr = SageSphinxLogger(sys.stderr, os.path.basename(output_dir))
+-        # Note that this call as of eraly 2018 leaks memory. So make sure that
++        # Note that this call as of early 2018 leaks memory. So make sure that
+         # you don't call runsphinx() several times in a row. (i.e., you want to
+         # fork() somewhere before this call.)
+         # We don't use subprocess here, as we don't want to re-initialize Sage
+         # for every docbuild as this takes a while.
+-        sphinx.cmdline.main(sys.argv[1:])
++        sphinx.cmd.build.main(sys.argv[1:])
+         sys.stderr.raise_errors()
+         sys.stdout.raise_errors()
+     finally:

Deleted: sagemath-ecl-sigfpe.patch
===================================================================
--- sagemath-ecl-sigfpe.patch	2019-01-18 08:00:10 UTC (rev 423970)
+++ sagemath-ecl-sigfpe.patch	2019-01-18 08:00:43 UTC (rev 423971)
@@ -1,147 +0,0 @@
-diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx
-index e408866..fa24ac0 100644
---- a/src/sage/libs/ecl.pyx
-+++ b/src/sage/libs/ecl.pyx
-@@ -16,7 +16,7 @@ from __future__ import print_function, absolute_import
- #adapted to work with pure Python types.
- 
- from libc.stdlib cimport abort
--from libc.signal cimport SIGINT, SIGBUS, SIGSEGV, SIGCHLD
-+from libc.signal cimport SIGINT, SIGBUS, SIGSEGV, SIGCHLD, SIGFPE
- from libc.signal cimport raise_ as signal_raise
- from posix.signal cimport sigaction, sigaction_t
- cimport cysignals.signals
-@@ -48,9 +48,14 @@ cdef extern from "eclsig.h":
-     void ecl_sig_off()
-     cdef sigaction_t ecl_sigint_handler
-     cdef sigaction_t ecl_sigbus_handler
-+    cdef sigaction_t ecl_sigfpe_handler
-     cdef sigaction_t ecl_sigsegv_handler
-     cdef mpz_t ecl_mpz_from_bignum(cl_object obj)
-     cdef cl_object ecl_bignum_from_mpz(mpz_t num)
-+    cdef int fegetexcept()
-+    cdef int feenableexcept(int)
-+    cdef int fedisableexcept(int)
-+    cdef int ecl_feflags
- 
- cdef cl_object string_to_object(char * s):
-     return ecl_read_from_cstring(s)
-@@ -239,6 +244,7 @@ def init_ecl():
-     global ecl_has_booted
-     cdef char *argv[1]
-     cdef sigaction_t sage_action[32]
-+    cdef int sage_fpes
-     cdef int i
- 
-     if ecl_has_booted:
-@@ -258,6 +264,8 @@ def init_ecl():
-     for i in range(1,32):
-         sigaction(i, NULL, &sage_action[i])
- 
-+    sage_fpes = fegetexcept()
-+
-     #initialize ECL
-     ecl_set_option(ECL_OPT_SIGNAL_HANDLING_THREAD, 0)
-     cl_boot(1, argv)
-@@ -265,8 +273,12 @@ def init_ecl():
-     #save signal handler from ECL
-     sigaction(SIGINT, NULL, &ecl_sigint_handler)
-     sigaction(SIGBUS, NULL, &ecl_sigbus_handler)
-+    sigaction(SIGFPE, NULL, &ecl_sigfpe_handler)
-     sigaction(SIGSEGV, NULL, &ecl_sigsegv_handler)
- 
-+    #save ECL's floating point exception flags
-+    ecl_feflags = fegetexcept()
-+
-     #verify that no SIGCHLD handler was installed
-     cdef sigaction_t sig_test
-     sigaction(SIGCHLD, NULL, &sig_test)
-@@ -277,6 +289,9 @@ def init_ecl():
-     for i in range(1,32):
-         sigaction(i, &sage_action[i], NULL)
- 
-+    fedisableexcept(ecl_feflags)
-+    feenableexcept(sage_fpes)
-+
-     #initialise list of objects and bind to global variable
-     # *SAGE-LIST-OF-OBJECTS* to make it rooted in the reachable tree for the GC
-     list_of_objects=cl_cons(Cnil,cl_cons(Cnil,Cnil))
-@@ -320,7 +335,6 @@ def init_ecl():
-                     (values nil (princ-to-string cnd)))))
-         """))
-     safe_funcall_clobj=cl_eval(string_to_object(b"(symbol-function 'sage-safe-funcall)"))
--
-     ecl_has_booted = 1
- 
- cdef cl_object ecl_safe_eval(cl_object form) except NULL:
-diff --git a/src/sage/libs/eclsig.h b/src/sage/libs/eclsig.h
-index f9f2690..a7e1f40 100644
---- a/src/sage/libs/eclsig.h
-+++ b/src/sage/libs/eclsig.h
-@@ -9,24 +9,66 @@
- 
- 
- #include <signal.h>
-+
-+/* Rummage around to determine how ECL was configured */
-+#define ECL_AVOID_FPE_H  /* Prevent some local includes */
-+#include <ecl/config-internal.h>
-+
-+#ifdef HAVE_FENV_H
-+#include <fenv.h>
-+#ifndef FE_ALL_EXCEPT
-+#define FE_ALL_EXCEPT FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INVALID
-+#endif
-+#else
-+#ifndef FE_ALL_EXCEPT
-+#define FE_ALL_EXCEPT 0
-+#endif
-+#define feclearexcept(flags) do {} while (0)
-+#endif
-+
-+#ifndef HAVE_FEENABLEEXCEPT
-+/* These are GNU extensions */
-+#define fegetexcept() 0
-+#define feenablexcept(flags) do {} while (0)
-+#define fdisableexcept(flags) do {} while (0)
-+#endif
-+
- static struct sigaction ecl_sigint_handler;
- static struct sigaction ecl_sigbus_handler;
-+static struct sigaction ecl_sigfpe_handler;
- static struct sigaction ecl_sigsegv_handler;
- static struct sigaction sage_sigint_handler;
- static struct sigaction sage_sigbus_handler;
-+static struct sigaction sage_sigfpe_handler;
- static struct sigaction sage_sigsegv_handler;
-+static int ecl_feflags;
-+static int sage_feflags;
- 
- static inline void set_ecl_signal_handler(void)
- {
-     sigaction(SIGINT, &ecl_sigint_handler, &sage_sigint_handler);
-     sigaction(SIGBUS, &ecl_sigbus_handler, &sage_sigbus_handler);
-+    sigaction(SIGFPE, &ecl_sigfpe_handler, &sage_sigfpe_handler);
-     sigaction(SIGSEGV, &ecl_sigsegv_handler, &sage_sigsegv_handler);
-+
-+    /* first clear pending floating point exceptions, if any */
-+    feclearexcept(FE_ALL_EXCEPT);
-+
-+    /* sage_feflags should be 0; we don't set them otherwise */
-+    sage_feflags = fedisableexcept(FE_ALL_EXCEPT);
-+    feenableexcept(ecl_feflags);
- }
- 
- static inline void unset_ecl_signal_handler(void)
- {
-+    /* clear pending exceptions and restore previous exception mask */
-+    feclearexcept(FE_ALL_EXCEPT);
-+    ecl_feflags = fedisableexcept(FE_ALL_EXCEPT);
-+    feenableexcept(sage_feflags);
-+
-     sigaction(SIGINT, &sage_sigint_handler, NULL);
-     sigaction(SIGBUS, &sage_sigbus_handler, NULL);
-+    sigaction(SIGFPE, &sage_sigfpe_handler, NULL);
-     sigaction(SIGSEGV, &sage_sigsegv_handler, NULL);
- }
- 

Copied: sagemath-doc/repos/community-any/sagemath-ecl-sigfpe.patch (from rev 423970, sagemath-doc/trunk/sagemath-ecl-sigfpe.patch)
===================================================================
--- sagemath-ecl-sigfpe.patch	                        (rev 0)
+++ sagemath-ecl-sigfpe.patch	2019-01-18 08:00:43 UTC (rev 423971)
@@ -0,0 +1,147 @@
+diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx
+index e408866..fa24ac0 100644
+--- a/src/sage/libs/ecl.pyx
++++ b/src/sage/libs/ecl.pyx
+@@ -16,7 +16,7 @@ from __future__ import print_function, absolute_import
+ #adapted to work with pure Python types.
+ 
+ from libc.stdlib cimport abort
+-from libc.signal cimport SIGINT, SIGBUS, SIGSEGV, SIGCHLD
++from libc.signal cimport SIGINT, SIGBUS, SIGSEGV, SIGCHLD, SIGFPE
+ from libc.signal cimport raise_ as signal_raise
+ from posix.signal cimport sigaction, sigaction_t
+ cimport cysignals.signals
+@@ -48,9 +48,14 @@ cdef extern from "eclsig.h":
+     void ecl_sig_off()
+     cdef sigaction_t ecl_sigint_handler
+     cdef sigaction_t ecl_sigbus_handler
++    cdef sigaction_t ecl_sigfpe_handler
+     cdef sigaction_t ecl_sigsegv_handler
+     cdef mpz_t ecl_mpz_from_bignum(cl_object obj)
+     cdef cl_object ecl_bignum_from_mpz(mpz_t num)
++    cdef int fegetexcept()
++    cdef int feenableexcept(int)
++    cdef int fedisableexcept(int)
++    cdef int ecl_feflags
+ 
+ cdef cl_object string_to_object(char * s):
+     return ecl_read_from_cstring(s)
+@@ -239,6 +244,7 @@ def init_ecl():
+     global ecl_has_booted
+     cdef char *argv[1]
+     cdef sigaction_t sage_action[32]
++    cdef int sage_fpes
+     cdef int i
+ 
+     if ecl_has_booted:
+@@ -258,6 +264,8 @@ def init_ecl():
+     for i in range(1,32):
+         sigaction(i, NULL, &sage_action[i])
+ 
++    sage_fpes = fegetexcept()
++
+     #initialize ECL
+     ecl_set_option(ECL_OPT_SIGNAL_HANDLING_THREAD, 0)
+     cl_boot(1, argv)
+@@ -265,8 +273,12 @@ def init_ecl():
+     #save signal handler from ECL
+     sigaction(SIGINT, NULL, &ecl_sigint_handler)
+     sigaction(SIGBUS, NULL, &ecl_sigbus_handler)
++    sigaction(SIGFPE, NULL, &ecl_sigfpe_handler)
+     sigaction(SIGSEGV, NULL, &ecl_sigsegv_handler)
+ 
++    #save ECL's floating point exception flags
++    ecl_feflags = fegetexcept()
++
+     #verify that no SIGCHLD handler was installed
+     cdef sigaction_t sig_test
+     sigaction(SIGCHLD, NULL, &sig_test)
+@@ -277,6 +289,9 @@ def init_ecl():
+     for i in range(1,32):
+         sigaction(i, &sage_action[i], NULL)
+ 
++    fedisableexcept(ecl_feflags)
++    feenableexcept(sage_fpes)
++
+     #initialise list of objects and bind to global variable
+     # *SAGE-LIST-OF-OBJECTS* to make it rooted in the reachable tree for the GC
+     list_of_objects=cl_cons(Cnil,cl_cons(Cnil,Cnil))
+@@ -320,7 +335,6 @@ def init_ecl():
+                     (values nil (princ-to-string cnd)))))
+         """))
+     safe_funcall_clobj=cl_eval(string_to_object(b"(symbol-function 'sage-safe-funcall)"))
+-
+     ecl_has_booted = 1
+ 
+ cdef cl_object ecl_safe_eval(cl_object form) except NULL:
+diff --git a/src/sage/libs/eclsig.h b/src/sage/libs/eclsig.h
+index f9f2690..a7e1f40 100644
+--- a/src/sage/libs/eclsig.h
++++ b/src/sage/libs/eclsig.h
+@@ -9,24 +9,66 @@
+ 
+ 
+ #include <signal.h>
++
++/* Rummage around to determine how ECL was configured */
++#define ECL_AVOID_FPE_H  /* Prevent some local includes */
++#include <ecl/config-internal.h>
++
++#ifdef HAVE_FENV_H
++#include <fenv.h>
++#ifndef FE_ALL_EXCEPT
++#define FE_ALL_EXCEPT FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INVALID
++#endif
++#else
++#ifndef FE_ALL_EXCEPT
++#define FE_ALL_EXCEPT 0
++#endif
++#define feclearexcept(flags) do {} while (0)
++#endif
++
++#ifndef HAVE_FEENABLEEXCEPT
++/* These are GNU extensions */
++#define fegetexcept() 0
++#define feenablexcept(flags) do {} while (0)
++#define fdisableexcept(flags) do {} while (0)
++#endif
++
+ static struct sigaction ecl_sigint_handler;
+ static struct sigaction ecl_sigbus_handler;
++static struct sigaction ecl_sigfpe_handler;
+ static struct sigaction ecl_sigsegv_handler;
+ static struct sigaction sage_sigint_handler;
+ static struct sigaction sage_sigbus_handler;
++static struct sigaction sage_sigfpe_handler;
+ static struct sigaction sage_sigsegv_handler;
++static int ecl_feflags;
++static int sage_feflags;
+ 
+ static inline void set_ecl_signal_handler(void)
+ {
+     sigaction(SIGINT, &ecl_sigint_handler, &sage_sigint_handler);
+     sigaction(SIGBUS, &ecl_sigbus_handler, &sage_sigbus_handler);
++    sigaction(SIGFPE, &ecl_sigfpe_handler, &sage_sigfpe_handler);
+     sigaction(SIGSEGV, &ecl_sigsegv_handler, &sage_sigsegv_handler);
++
++    /* first clear pending floating point exceptions, if any */
++    feclearexcept(FE_ALL_EXCEPT);
++
++    /* sage_feflags should be 0; we don't set them otherwise */
++    sage_feflags = fedisableexcept(FE_ALL_EXCEPT);
++    feenableexcept(ecl_feflags);
+ }
+ 
+ static inline void unset_ecl_signal_handler(void)
+ {
++    /* clear pending exceptions and restore previous exception mask */
++    feclearexcept(FE_ALL_EXCEPT);
++    ecl_feflags = fedisableexcept(FE_ALL_EXCEPT);
++    feenableexcept(sage_feflags);
++
+     sigaction(SIGINT, &sage_sigint_handler, NULL);
+     sigaction(SIGBUS, &sage_sigbus_handler, NULL);
++    sigaction(SIGFPE, &sage_sigfpe_handler, NULL);
+     sigaction(SIGSEGV, &sage_sigsegv_handler, NULL);
+ }
+ 



More information about the arch-commits mailing list