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

Antonio Rojas arojas at archlinux.org
Tue Nov 10 07:32:08 UTC 2020


    Date: Tuesday, November 10, 2020 @ 07:32:08
  Author: arojas
Revision: 749410

archrelease: copy trunk to community-testing-x86_64

Added:
  sagemath/repos/community-testing-x86_64/
  sagemath/repos/community-testing-x86_64/PKGBUILD
    (from rev 749409, sagemath/trunk/PKGBUILD)
  sagemath/repos/community-testing-x86_64/latte-count.patch
    (from rev 749409, sagemath/trunk/latte-count.patch)
  sagemath/repos/community-testing-x86_64/sagemath-cremona.patch
    (from rev 749409, sagemath/trunk/sagemath-cremona.patch)
  sagemath/repos/community-testing-x86_64/sagemath-cypari-2.1.2.patch
    (from rev 749409, sagemath/trunk/sagemath-cypari-2.1.2.patch)
  sagemath/repos/community-testing-x86_64/sagemath-flint-2.6.patch
    (from rev 749409, sagemath/trunk/sagemath-flint-2.6.patch)
  sagemath/repos/community-testing-x86_64/sagemath-gap-4.11.patch
    (from rev 749409, sagemath/trunk/sagemath-gap-4.11.patch)
  sagemath/repos/community-testing-x86_64/sagemath-optional-packages.patch
    (from rev 749409, sagemath/trunk/sagemath-optional-packages.patch)
  sagemath/repos/community-testing-x86_64/sagemath-pari-2.13.patch
    (from rev 749409, sagemath/trunk/sagemath-pari-2.13.patch)
  sagemath/repos/community-testing-x86_64/sagemath-singular-4.1.2.patch
    (from rev 749409, sagemath/trunk/sagemath-singular-4.1.2.patch)
  sagemath/repos/community-testing-x86_64/test-optional.patch
    (from rev 749409, sagemath/trunk/test-optional.patch)

----------------------------------+
 PKGBUILD                         |  133 ++
 latte-count.patch                |   89 +
 sagemath-cremona.patch           |   31 
 sagemath-cypari-2.1.2.patch      |  155 ++
 sagemath-flint-2.6.patch         |  110 +
 sagemath-gap-4.11.patch          |  260 ++++
 sagemath-optional-packages.patch |   22 
 sagemath-pari-2.13.patch         | 2202 +++++++++++++++++++++++++++++++++++++
 sagemath-singular-4.1.2.patch    |  759 ++++++++++++
 test-optional.patch              |   25 
 10 files changed, 3786 insertions(+)

Copied: sagemath/repos/community-testing-x86_64/PKGBUILD (from rev 749409, sagemath/trunk/PKGBUILD)
===================================================================
--- community-testing-x86_64/PKGBUILD	                        (rev 0)
+++ community-testing-x86_64/PKGBUILD	2020-11-10 07:32:08 UTC (rev 749410)
@@ -0,0 +1,133 @@
+# Maintainer: Antonio Rojas <arojas at archlinux.org>
+# Contributor: Evgeniy Alekseev <arcanis.arch at gmail dot com>
+# Contributor: Daniel Wallace <danielwallace at gtmanfred dot com>
+# Contributor: Thomas Dziedzic <gostrc at gmail dot com>
+# Contributor: Osman Ugus <ugus11 at yahoo dot com>
+# Contributor: Stefan Husmann <stefan-husmann at t-online dot de>
+
+pkgbase=sagemath
+pkgname=(sagemath sagemath-jupyter)
+pkgver=9.2
+pkgrel=5
+pkgdesc="Open Source Mathematics Software, free alternative to Magma, Maple, Mathematica, and Matlab"
+arch=(x86_64)
+url="http://www.sagemath.org"
+license=(GPL)
+depends=(ipython palp brial cliquer maxima-ecl gfan sympow nauty python-rpy2 python-fpylll python-psutil python-cypari2
+  python-matplotlib python-scipy python-sympy python-networkx python-pillow python-pplpy python-sphinx
+  gap flintqs lcalc lrcalc arb eclib zn_poly gd python-cvxopt pynac linbox m4rie pari-galdata pari-seadata-small planarity rankwidth tachyon
+  sage-data-combinatorial_designs sage-data-elliptic_curves sage-data-graphs sage-data-polytopes_db sage-data-conway_polynomials
+  iml libgiac libhomfly libbraiding symmetrica three.js)
+optdepends=('cython: to compile cython code' 'python-pkgconfig: to compile cython code'
+  'jmol: alternative 3D plot engine' 'sagemath-doc: HTML documentation' 'python-igraph: igraph backend for graph theory'
+  'sage-numerical-backends-coin: COIN mixed integer linear programming backend'
+  'coin-or-csdp: for computing Lovász theta-function of graphs'
+  'buckygen: for generating fullerene graphs' 'plantri: for generating some classes of graphs' 'benzene: for generating fusenes and benzenoids'
+  'ffmpeg: to export animations to video' 'imagemagick: to show animations'
+  'coxeter: Coxeter groups implementation'
+  'rubiks: Rubiks cube algorithms'
+  'lrs: Algorithms for linear reverse search used in game theory and for computing volume of polytopes'
+  'python-pynormaliz: Normaliz backend for polyhedral computations'
+  'latte-integrale: integral point count in polyhedra' 'python-jupymake: polymake backend for polyhedral computations'
+  'shared_meataxe: faster matrix arithmetic over finite fields' 'openblas: faster linear algebra'
+  'sirocco: for computing the fundamental group of the complement of a plane curve' 'primecount: faster prime_pi implementation'
+  'dot2tex: for displaying some diagrams' 'cryptominisat5: SAT solver' 'python-pycosat: picosat SAT solver'
+  'python-pip: to install optional packages with sage -pip')
+makedepends=(cython boost ratpoints python-jinja sirocco mcqd coxeter bliss tdlib python-pkgconfig shared_meataxe primecount git)
+source=("$pkgname-$pkgver.tar.gz::https://github.com/sagemath/sage/archive/$pkgver.tar.gz"
+        sagemath-optional-packages.patch
+        latte-count.patch
+        test-optional.patch
+        sagemath-cremona.patch
+        sagemath-singular-4.1.2.patch
+        sagemath-gap-4.11.patch
+        sagemath-flint-2.6.patch
+        sagemath-cypari-2.1.2.patch
+        sagemath-pari-2.13.patch)
+sha256sums=('edc89776461247cf74a16473851378e70a2de867309978ca2346ef6f93af0f90'
+            '00cf73534c10bb8694c77639670aa041b4b8c897babb01751a5f65648bcfdcf6'
+            'af922e1f978821a9a1f6c9a56130d71e5011c84a7aee7bf66a591bee658af30b'
+            '7da0dbcda15a327c21dc33853cb8f98cb86a283139f8735e3b20a71d49458a88'
+            '937074fa7a8a4e2aba9ea77ec622fe937985a1a9176c48460d51325ee877a4f5'
+            '881186d016a6eb47b919765b9d4e6abc4560fce54e08cf42bd948ba77e16aa85'
+            '34f06f9776f84f6998b1350555316e0ffea76ed16e149916970f19ef750a467f'
+            '5d00b24c1d36b41b8ea3f07b93fc0e00b42dd84d9bc4e9b3d26e5f2cfeba6405'
+            'dc507eeb75eae1109273879771b4eb56172b7417e87a0693381106afd7554e04'
+            '84875c90268436cb6a740a4e1bffd70b4895458ef9e1ee268a3c4aa0564e893f')
+
+prepare(){
+  cd sage-$pkgver
+
+  sed -e '/sage-env/d' -i src/setup.py # Don't try to install sage-env
+
+# Upstream patches
+# use Features to detect Cremona databases https://trac.sagemath.org/ticket/25825
+  patch -p1 -i ../sagemath-cremona.patch
+# Fixes for singular 4.1.2 https://trac.sagemath.org/ticket/25993
+  patch -p1 -i ../sagemath-singular-4.1.2.patch
+# Fix segfault and tests with flint 2.6 https://trac.sagemath.org/ticket/29719
+  patch -p1 -i ../sagemath-flint-2.6.patch
+# Fix gap.version() and doctests with GAP 4.11 https://trac.sagemath.org/ticket/29314
+  patch -p1 -i ../sagemath-gap-4.11.patch
+# Fix gcd/lcm between pari and sage objects https://trac.sagemath.org/ticket/30849
+  patch -p1 -i ../sagemath-cypari-2.1.2.patch
+# Port to PARI 2.13 https://trac.sagemath.org/ticket/30801
+  patch -p1 -i ../sagemath-pari-2.13.patch
+
+# Arch-specific patches
+# assume all optional packages are installed
+  patch -p1 -i ../sagemath-optional-packages.patch
+# don't list optional packages when running tests
+  patch -p1 -i ../test-optional.patch
+# use correct latte-count binary name
+  patch -p1 -i ../latte-count.patch
+# Fix mathjax path
+  sed -e 's|mathjax|mathjax2|g' -i src/sage/env.py
+
+  sed -e 's|sage-python23|python|' -i src/bin/*
+  sed -e 's|$SAGE_PYTHON3|yes|' -i src/bin/sage
+}
+
+build() {
+  cd sage-$pkgver/src
+
+  export SAGE_NUM_THREADS=10
+  python setup.py build
+}
+
+package_sagemath() {
+  optdepends+=('sagemath-jupyter: Jupyter kernel')
+
+  cd sage-$pkgver/src
+
+  python setup.py install --root="$pkgdir" --optimize=1
+
+  _pythonpath=`python -c "from sysconfig import get_path; print(get_path('platlib'))"`
+# Remove sage_setup
+  rm -r "$pkgdir"/$_pythonpath/sage_setup
+# Install tests
+  cp -r sage/doctest/tests "$pkgdir"/$_pythonpath/sage/doctest
+  cp -r sage/tests/books "$pkgdir"/$_pythonpath/sage/tests
+
+# Split jupyter kernel
+  rm -r "$pkgdir"/usr/share
+}
+
+package_sagemath-jupyter() {
+  pkgdesc='Jupyter kernel for SageMath'
+  depends=(sagemath python-jupyter_client python-ipywidgets)
+  optdepends=('sage-notebook-exporter: convert flask notebooks to Jupyter' 'jsmol: alternative 3D plot engine')
+
+  cd sage-$pkgver/src
+
+  export SAGE_ROOT="$PWD" \
+         SAGE_LOCAL="/usr" \
+         MATHJAX_DIR="/usr/share/mathjax2"
+  python -c "from sage.repl.ipython_kernel.install import SageKernelSpec; SageKernelSpec.update(prefix='$pkgdir/usr')"
+# fix symlinks to assets
+  _pythonpath=`python -c "from sysconfig import get_path; print(get_path('platlib'))"`
+  for _i in $(ls sage/ext_data/notebook-ipython); do
+    rm "$pkgdir"/usr/share/jupyter/kernels/sagemath/$_i
+    ln -s $_pythonpath/sage/ext_data/notebook-ipython/$_i "$pkgdir"/usr/share/jupyter/kernels/sagemath/
+  done
+}

Copied: sagemath/repos/community-testing-x86_64/latte-count.patch (from rev 749409, sagemath/trunk/latte-count.patch)
===================================================================
--- community-testing-x86_64/latte-count.patch	                        (rev 0)
+++ community-testing-x86_64/latte-count.patch	2020-11-10 07:32:08 UTC (rev 749410)
@@ -0,0 +1,89 @@
+diff --git a/src/sage/geometry/polyhedron/base_ZZ.py b/src/sage/geometry/polyhedron/base_ZZ.py
+index 268af9db0d..70d41dfa30 100644
+--- a/src/sage/geometry/polyhedron/base_ZZ.py
++++ b/src/sage/geometry/polyhedron/base_ZZ.py
+@@ -194,7 +194,7 @@ class Polyhedron_ZZ(Polyhedron_base):
+             sage: p = P._ehrhart_polynomial_latte(maxdet=5, verbose=True)  # optional - latte_int
+             This is LattE integrale ...
+             ...
+-            Invocation: count --ehrhart-polynomial '--redundancy-check=none' --cdd '--maxdet=5' /dev/stdin
++            Invocation: latte-count --ehrhart-polynomial '--redundancy-check=none' --cdd '--maxdet=5' /dev/stdin
+             ...
+             sage: p    # optional - latte_int
+             1/2*t^2 + 3/2*t + 1
+@@ -202,7 +202,7 @@ class Polyhedron_ZZ(Polyhedron_base):
+             sage: p = P._ehrhart_polynomial_latte(dual=True, verbose=True)  # optional - latte_int
+             This is LattE integrale ...
+             ...
+-            Invocation: count --ehrhart-polynomial '--redundancy-check=none' --cdd --dual /dev/stdin
++            Invocation: latte-count --ehrhart-polynomial '--redundancy-check=none' --cdd --dual /dev/stdin
+             ...
+             sage: p   # optional - latte_int
+             1/2*t^2 + 3/2*t + 1
+@@ -210,7 +210,7 @@ class Polyhedron_ZZ(Polyhedron_base):
+             sage: p = P._ehrhart_polynomial_latte(irrational_primal=True, verbose=True)   # optional - latte_int
+             This is LattE integrale ...
+             ...
+-            Invocation: count --ehrhart-polynomial '--redundancy-check=none' --cdd --irrational-primal /dev/stdin
++            Invocation: latte-count --ehrhart-polynomial '--redundancy-check=none' --cdd --irrational-primal /dev/stdin
+             ...
+             sage: p   # optional - latte_int
+             1/2*t^2 + 3/2*t + 1
+@@ -218,7 +218,7 @@ class Polyhedron_ZZ(Polyhedron_base):
+             sage: p = P._ehrhart_polynomial_latte(irrational_all_primal=True, verbose=True)  # optional - latte_int
+             This is LattE integrale ...
+             ...
+-            Invocation: count --ehrhart-polynomial '--redundancy-check=none' --cdd --irrational-all-primal /dev/stdin
++            Invocation: latte-count --ehrhart-polynomial '--redundancy-check=none' --cdd --irrational-all-primal /dev/stdin
+             ...
+             sage: p   # optional - latte_int
+             1/2*t^2 + 3/2*t + 1
+@@ -230,7 +230,7 @@ class Polyhedron_ZZ(Polyhedron_base):
+             ...
+             RuntimeError: LattE integrale program failed (exit code 1):
+             ...
+-            Invocation: count --ehrhart-polynomial '--redundancy-check=none' --cdd '--bim-bam-boum=19' /dev/stdin
++            Invocation: latte-count --ehrhart-polynomial '--redundancy-check=none' --cdd '--bim-bam-boum=19' /dev/stdin
+             Unknown command/option --bim-bam-boum=19
+         """
+         # note: the options below are explicitly written in the function
+diff --git a/src/sage/interfaces/latte.py b/src/sage/interfaces/latte.py
+index 066cedd401..302b39910d 100644
+--- a/src/sage/interfaces/latte.py
++++ b/src/sage/interfaces/latte.py
+@@ -96,7 +96,7 @@ def count(arg, ehrhart_polynomial=False, multivariate_generating_function=False,
+         sage: n = count(cddin, cdd=True, verbose=True, raw_output=True)  # optional - latte_int
+         This is LattE integrale ...
+         ...
+-        Invocation: count '--redundancy-check=none' --cdd /dev/stdin
++        Invocation: latte-count '--redundancy-check=none' --cdd /dev/stdin
+         ...
+         Total Unimodular Cones: ...
+         Maximum number of simplicial cones in memory at once: ...
+@@ -117,7 +117,7 @@ def count(arg, ehrhart_polynomial=False, multivariate_generating_function=False,
+ 
+     arg = str_to_bytes(arg)
+ 
+-    args = ['count']
++    args = ['latte-count']
+     if ehrhart_polynomial and multivariate_generating_function:
+         raise ValueError
+     if ehrhart_polynomial:
+diff --git a/src/sage/features/latte.py b/src/sage/features/latte.py
+index 63d227fd35..040a5cf1f9 100644
+--- a/src/sage/features/latte.py
++++ b/src/sage/features/latte.py
+@@ -9,10 +9,10 @@ from . import Executable, Feature, FeatureTestResult
+ 
+ class Latte_count(Executable):
+     r"""
+-    Feature for the executable ``count`` from the LattE suite.
++    Feature for the executable ``latte-count`` from the LattE suite.
+     """
+     def __init__(self):
+-        Executable.__init__(self, "count", executable="count",
++        Executable.__init__(self, "latte-count", executable="latte-count",
+                             spkg="latte_int",
+                             url=LATTE_URL)
+ 
+

Copied: sagemath/repos/community-testing-x86_64/sagemath-cremona.patch (from rev 749409, sagemath/trunk/sagemath-cremona.patch)
===================================================================
--- community-testing-x86_64/sagemath-cremona.patch	                        (rev 0)
+++ community-testing-x86_64/sagemath-cremona.patch	2020-11-10 07:32:08 UTC (rev 749410)
@@ -0,0 +1,31 @@
+diff --git a/src/sage/databases/cremona.py b/src/sage/databases/cremona.py
+index 3f8dd62..ed5726a 100644
+--- a/src/sage/databases/cremona.py
++++ b/src/sage/databases/cremona.py
+@@ -51,7 +51,7 @@ from sage.misc.prandom import randint
+ 
+ import sage.schemes.elliptic_curves.constructor as elliptic
+ from .sql_db import SQLDatabase, verify_column
+-from sage.misc.package import is_package_installed
++from sage.features.databases import DatabaseCremona
+ from sage.env import CREMONA_MINI_DATA_DIR, CREMONA_LARGE_DATA_DIR, SAGE_SHARE
+ from sage.misc.all import walltime
+ 
+@@ -847,7 +847,7 @@ class MiniCremonaDatabase(SQLDatabase):
+             if N < self.largest_conductor():
+                 message = "There is no elliptic curve with label " + label \
+                     + " in the database"
+-            elif is_package_installed('database_cremona_ellcurve'):
++            elif DatabaseCremona().is_present():
+                 message = "There is no elliptic curve with label " + label \
+                     + " in the currently available databases"
+             else:
+@@ -1705,7 +1705,7 @@ def CremonaDatabase(name=None,mini=None,set_global=None):
+     if name is None and not set_global:
+         return _db
+     if set_global and name is None:
+-        if is_package_installed('database_cremona_ellcurve'):
++        if DatabaseCremona().is_present():
+             name = 'cremona'
+         else:
+             name = 'cremona mini'

Copied: sagemath/repos/community-testing-x86_64/sagemath-cypari-2.1.2.patch (from rev 749409, sagemath/trunk/sagemath-cypari-2.1.2.patch)
===================================================================
--- community-testing-x86_64/sagemath-cypari-2.1.2.patch	                        (rev 0)
+++ community-testing-x86_64/sagemath-cypari-2.1.2.patch	2020-11-10 07:32:08 UTC (rev 749410)
@@ -0,0 +1,155 @@
+diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx
+index 4c835d0..77a3a18 100644
+--- a/src/sage/rings/integer.pyx
++++ b/src/sage/rings/integer.pyx
+@@ -4414,6 +4414,29 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
+         sig_off()
+         return z
+ 
++    def _gcd(self, Integer n):
++        """
++        Return the greatest common divisor of self and `n`.
++
++        EXAMPLES::
++
++            sage: 1._gcd(-1)
++            1
++            sage: 0._gcd(1)
++            1
++            sage: 0._gcd(0)
++            0
++            sage: 2._gcd(2^6)
++            2
++            sage: 21._gcd(2^6)
++            1
++        """
++        cdef Integer z = PY_NEW(Integer)
++        sig_on()
++        mpz_gcd(z.value, self.value, n.value)
++        sig_off()
++        return z
++
+     def denominator(self):
+         """
+         Return the denominator of this integer, which of course is
+@@ -6736,33 +6759,6 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
+             raise ZeroDivisionError(f"inverse of Mod({self}, {m}) does not exist")
+         return ans
+ 
+-    def gcd(self, n):
+-        """
+-        Return the greatest common divisor of self and `n`.
+-
+-        EXAMPLES::
+-
+-            sage: gcd(-1,1)
+-            1
+-            sage: gcd(0,1)
+-            1
+-            sage: gcd(0,0)
+-            0
+-            sage: gcd(2,2^6)
+-            2
+-            sage: gcd(21,2^6)
+-            1
+-        """
+-        if not isinstance(n, Integer) and not isinstance(n, int):
+-            left, right = coercion_model.canonical_coercion(self, n)
+-            return left.gcd(right)
+-        cdef Integer m = as_Integer(n)
+-        cdef Integer g = PY_NEW(Integer)
+-        sig_on()
+-        mpz_gcd(g.value, self.value, m.value)
+-        sig_off()
+-        return g
+-
+     def crt(self, y, m, n):
+         """
+         Return the unique integer between `0` and `mn` that is congruent to
+diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx
+index f145e66..1cf634e 100644
+--- a/src/sage/structure/element.pyx
++++ b/src/sage/structure/element.pyx
+@@ -3908,16 +3908,79 @@ def is_PrincipalIdealDomainElement(x):
+     return isinstance(x, PrincipalIdealDomainElement)
+ 
+ cdef class PrincipalIdealDomainElement(DedekindDomainElement):
++    def gcd(self, right):
++        r"""
++        Return the greatest common divisor of ``self`` and ``other``.
++
++        TESTS:
++
++        :trac:`30849`::
++
++            sage: 2.gcd(pari(3))
++            1
++            sage: type(2.gcd(pari(3)))
++            <class 'sage.rings.integer.Integer'>
++
++            sage: 2.gcd(pari('1/3'))
++            1/3
++            sage: type(2.gcd(pari('1/3')))
++            <class 'sage.rings.rational.Rational'>
++
++            sage: import gmpy2
++            sage: 2.gcd(gmpy2.mpz(3))
++            1
++            sage: type(2.gcd(gmpy2.mpz(3)))
++            <class 'sage.rings.integer.Integer'>
++
++            sage: 2.gcd(gmpy2.mpq(1,3))
++            1/3
++            sage: type(2.gcd(pari('1/3')))
++            <class 'sage.rings.rational.Rational'>
++        """
++        # NOTE: in order to handle nicely pari or gmpy2 integers we do not rely only on coercion
++        if not isinstance(right, Element):
++            right = py_scalar_to_element(right)
++            if not isinstance(right, Element):
++                right = right.sage()
++        if not ((<Element>right)._parent is self._parent):
++            from sage.arith.all import gcd
++            return coercion_model.bin_op(self, right, gcd)
++        return self._gcd(right)
++
+     def lcm(self, right):
+         """
+         Return the least common multiple of ``self`` and ``right``.
+-        """
+-        if not isinstance(right, Element) or not ((<Element>right)._parent is self._parent):
++
++        TESTS:
++
++        :trac:`30849`::
++
++            sage: 2.lcm(pari(3))
++            6
++            sage: type(2.lcm(pari(3)))
++            <class 'sage.rings.integer.Integer'>
++
++            sage: 2.lcm(pari('1/3'))
++            2
++            sage: type(2.lcm(pari('1/3')))
++            <class 'sage.rings.rational.Rational'>
++
++            sage: import gmpy2
++            sage: 2.lcm(gmpy2.mpz(3))
++            6
++            sage: type(2.lcm(gmpy2.mpz(3)))
++            <class 'sage.rings.integer.Integer'>
++        """
++        # NOTE: in order to handle nicely pari or gmpy2 integers we do not rely only on coercion
++        if not isinstance(right, Element):
++            right = py_scalar_to_element(right)
++            if not isinstance(right, Element):
++                right = right.sage()
++        if not ((<Element>right)._parent is self._parent):
+             from sage.arith.all import lcm
+             return coercion_model.bin_op(self, right, lcm)
+         return self._lcm(right)
+ 
+-
+ # This is pretty nasty low level stuff. The idea is to speed up construction
+ # of EuclideanDomainElements (in particular Integers) by skipping some tp_new
+ # calls up the inheritance tree.

Copied: sagemath/repos/community-testing-x86_64/sagemath-flint-2.6.patch (from rev 749409, sagemath/trunk/sagemath-flint-2.6.patch)
===================================================================
--- community-testing-x86_64/sagemath-flint-2.6.patch	                        (rev 0)
+++ community-testing-x86_64/sagemath-flint-2.6.patch	2020-11-10 07:32:08 UTC (rev 749410)
@@ -0,0 +1,110 @@
+diff --git a/src/doc/en/constructions/algebraic_geometry.rst b/src/doc/en/constructions/algebraic_geometry.rst
+index a312548..3933bf0 100644
+--- a/src/doc/en/constructions/algebraic_geometry.rst
++++ b/src/doc/en/constructions/algebraic_geometry.rst
+@@ -142,13 +142,17 @@ Other methods
+        sage: I = singular.ideal('x^4+x', 'y^4+y')
+        sage: L = singular.closed_points(I)
+        sage: # Here you have all the points :
+-       sage: print(L)
++       sage: L       # random
+        [1]:
+-          _[1]=y+1  # 32-bit
+-          _[2]=x+1  # 32-bit
+-          _[1]=y    # 64-bit
+-          _[2]=x    # 64-bit
++          _[1]=y+1
++          _[2]=x+1
+        ...
++       sage: l=[L[k].sage() for k in [1..10]]; len(l) # there are 10 points
++       10
++       sage: r=sorted(l[0].ring().gens()); r
++       [y, x]
++       sage: r in [t.gens() for t in l] #  one of them is given by [y,x]
++       True
+ 
+ -  Another way to compute rational points is to use Singular's
+    ``NSplaces`` command. Here's the Klein quartic over :math:`GF(8)`
+diff --git a/src/doc/en/developer/coding_in_other.rst b/src/doc/en/developer/coding_in_other.rst
+index ee71373..6693aed 100644
+--- a/src/doc/en/developer/coding_in_other.rst
++++ b/src/doc/en/developer/coding_in_other.rst
+@@ -439,7 +439,7 @@ interface to Singular::
+     ''
+     sage: L = singular.eval("POINTS;")
+ 
+-    sage: print(L)
++    sage: print(L) # random
+     [1]:
+        [1]:
+           0
+@@ -447,13 +447,6 @@ interface to Singular::
+           1
+        [3]:
+           0
+-    [2]:
+-       [1]:
+-          -2
+-       [2]:
+-          -1
+-       [3]:
+-          1
+     ...
+ 
+ From looking at the output, notice that our wrapper function will need
+diff --git a/src/sage/modules/fg_pid/fgp_module.py b/src/sage/modules/fg_pid/fgp_module.py
+index 1208768..8cb68d0 100644
+--- a/src/sage/modules/fg_pid/fgp_module.py
++++ b/src/sage/modules/fg_pid/fgp_module.py
+@@ -127,7 +127,8 @@ which is coerced into M0. ::
+ Here we illustrate lifting an element of the image of f, i.e., finding
+ an element of M0 that maps to a given element of M1::
+ 
+-    sage: y = f.lift(3*M1.0); y
++    sage: y = f.lift(3*M1.0)
++    sage: y # random
+     (0, 13)
+     sage: f(y)
+     (3)
+@@ -1285,7 +1286,7 @@ class FGP_Module_class(Module):
+             (0, 4)
+             sage: Q.coordinate_vector(x, reduce=True)
+             (0, 4)
+-            sage: Q.coordinate_vector(-x, reduce=False)
++            sage: Q.coordinate_vector(-x, reduce=False) # random
+             (0, -4)
+             sage: x == 4*Q.1
+             True
+@@ -1414,7 +1415,7 @@ class FGP_Module_class(Module):
+             Echelon basis matrix:
+             [ 0 12  0]
+             [ 0  0  4]
+-            sage: X
++            sage: X         # random
+             [0 4 0]
+             [0 1 0]
+             [0 0 1]
+diff --git a/src/sage/modules/free_module_morphism.py b/src/sage/modules/free_module_morphism.py
+index 62379d2..2c163f5 100644
+--- a/src/sage/modules/free_module_morphism.py
++++ b/src/sage/modules/free_module_morphism.py
+@@ -350,12 +350,14 @@ class FreeModuleMorphism(matrix_morphism.MatrixMorphism):
+             sage: V = X.span([[2, 0], [0, 8]], ZZ)
+             sage: W = (QQ**1).span([[1/12]], ZZ)
+             sage: f = V.hom([W([1/3]), W([1/2])], W)
+-            sage: f.lift([1/3])
++            sage: l=f.lift([1/3]); l # random
+             (8, -16)
+-            sage: f.lift([1/2])
+-            (12, -24)
+-            sage: f.lift([1/6])
+-            (4, -8)
++            sage: f(l)
++            (1/3)
++            sage: f(f.lift([1/2]))
++            (1/2)
++            sage: f(f.lift([1/6]))
++            (1/6)
+             sage: f.lift([1/12])
+             Traceback (most recent call last):
+             ...

Copied: sagemath/repos/community-testing-x86_64/sagemath-gap-4.11.patch (from rev 749409, sagemath/trunk/sagemath-gap-4.11.patch)
===================================================================
--- community-testing-x86_64/sagemath-gap-4.11.patch	                        (rev 0)
+++ community-testing-x86_64/sagemath-gap-4.11.patch	2020-11-10 07:32:08 UTC (rev 749410)
@@ -0,0 +1,260 @@
+diff --git a/src/sage/coding/linear_code.py b/src/sage/coding/linear_code.py
+index 8c330c7..b3901f8 100644
+--- a/src/sage/coding/linear_code.py
++++ b/src/sage/coding/linear_code.py
+@@ -479,17 +479,17 @@ class AbstractLinearCode(AbstractLinearCodeNoMetric):
+             0
+             sage: C = codes.HammingCode(GF(4, 'z'), 3)
+             sage: C.automorphism_group_gens()
+-            ([((1, z, z + 1, z, z, 1, 1, z, z + 1, z, z, 1, z, z + 1, z, z, 1, z, z + 1, z, z); (1,5,18,7,11,8)(2,12,21)(3,20,14,10,19,15)(4,9)(13,17,16), Ring endomorphism of Finite Field in z of size 2^2
+-                Defn: z |--> z + 1),
+-              ((1, 1, z, z + 1, z, z, z + 1, z + 1, z, 1, 1, z, z, z + 1, z + 1, 1, z, z, 1, z, z + 1); (2,11)(3,13)(4,14)(5,20)(6,17)(8,15)(16,19), Ring endomorphism of Finite Field in z of size 2^2
++            ([((1, 1, 1, 1, 1, z + 1, z, z + 1, z, z, z, 1, 1, z + 1, z + 1, z, z + 1, z, z + 1, z + 1, z + 1); (1,14,6,7,4,10,11,19)(2,8,16,13,3,17,21,15)(9,12,18,20), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z + 1),
++              ((z + 1, 1, 1, z, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z + 1, 1, z, z + 1, z + 1, z); (1,18,6,19,2,9,17,10,13,14,21,11,4,5,12)(3,20,7,16,8), Ring endomorphism of Finite Field in z of size 2^2
++                Defn: z |--> z),
+               ((z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z); (), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z)],
+              362880)
+             sage: C.automorphism_group_gens(equivalence="linear")
+-            ([((z, 1, 1, z, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, 1, 1, z, z, z + 1, z); (1,6)(2,20,9,16)(3,10,8,11)(4,15,21,5)(12,17)(13,14,19,18), Ring endomorphism of Finite Field in z of size 2^2
++            ([((z + 1, 1, z + 1, z + 1, z + 1, z, 1, z, 1, 1, 1, 1, z + 1, z + 1, z + 1, z, z, 1, z, z, z); (1,15,2,8,16,18,3)(4,9,12,13,20,10,11)(5,21,14,6,7,19,17), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+-              ((1, z, z + 1, z, z, z, z + 1, z + 1, 1, z, z, z, 1, z, 1, z + 1, z, z + 1, z, z + 1, 1); (1,15,20,5,8,6,12,14,13,7,16,11,19,3,21,4,9,10,18,17,2), Ring endomorphism of Finite Field in z of size 2^2
++              ((z + 1, z + 1, z + 1, z + 1, z + 1, 1, z, 1, z, z, z, 1, z, 1, 1, 1, z + 1, z + 1, z + 1, 1, z); (1,15,21,8,9)(2,18,5,3,11,16,7,10,19,13,12,4,17,6,20), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+               ((z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1); (), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z)],
+@@ -705,10 +705,10 @@ class AbstractLinearCode(AbstractLinearCodeNoMetric):
+             sage: C_iso == aut_group_can_label.get_canonical_form()
+             True
+             sage: aut_group_can_label.get_autom_gens()
+-            [((1, z, z + 1, z, z, 1, 1, z, z + 1, z, z, 1, z, z + 1, z, z, 1, z, z + 1, z, z); (1,5,18,7,11,8)(2,12,21)(3,20,14,10,19,15)(4,9)(13,17,16), Ring endomorphism of Finite Field in z of size 2^2
+-               Defn: z |--> z + 1),
+-             ((1, 1, z, z + 1, z, z, z + 1, z + 1, z, 1, 1, z, z, z + 1, z + 1, 1, z, z, 1, z, z + 1); (2,11)(3,13)(4,14)(5,20)(6,17)(8,15)(16,19), Ring endomorphism of Finite Field in z of size 2^2
++            [((1, 1, 1, 1, 1, z + 1, z, z + 1, z, z, z, 1, 1, z + 1, z + 1, z, z + 1, z, z + 1, z + 1, z + 1); (1,14,6,7,4,10,11,19)(2,8,16,13,3,17,21,15)(9,12,18,20), Ring endomorphism of Finite Field in z of size 2^2
+                Defn: z |--> z + 1),
++             ((z + 1, 1, 1, z, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z + 1, 1, z, z + 1, z + 1, z); (1,18,6,19,2,9,17,10,13,14,21,11,4,5,12)(3,20,7,16,8), Ring endomorphism of Finite Field in z of size 2^2
++               Defn: z |--> z),
+              ((z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z); (), Ring endomorphism of Finite Field in z of size 2^2
+                Defn: z |--> z)]
+         """
+diff --git a/src/sage/combinat/tiling.py b/src/sage/combinat/tiling.py
+index 3a70f13..e03fdd8 100644
+--- a/src/sage/combinat/tiling.py
++++ b/src/sage/combinat/tiling.py
+@@ -320,21 +320,21 @@ def ncube_isometry_group(n, orientation_preserving=True):
+ 
+         sage: ncube_isometry_group(3)
+         [
+-        [1 0 0]  [ 1  0  0]  [ 0  1  0]  [ 0  0 -1]  [ 1  0  0]  [ 0  1  0]
+-        [0 1 0]  [ 0  0  1]  [ 0  0 -1]  [ 0 -1  0]  [ 0  0 -1]  [-1  0  0]
+-        [0 0 1], [ 0 -1  0], [-1  0  0], [-1  0  0], [ 0  1  0], [ 0  0  1],
++        [1 0 0]  [ 1  0  0]  [ 1  0  0]  [ 0  1  0]  [0 1 0]  [ 0  0  1]
++        [0 1 0]  [ 0  0  1]  [ 0  0 -1]  [-1  0  0]  [0 0 1]  [ 0 -1  0]
++        [0 0 1], [ 0 -1  0], [ 0  1  0], [ 0  0  1], [1 0 0], [ 1  0  0],
+         <BLANKLINE>
+-        [ 1  0  0]  [ 0  0  1]  [0 1 0]  [ 0  0  1]  [ 0  0 -1]  [ 0 -1  0]
+-        [ 0 -1  0]  [-1  0  0]  [0 0 1]  [ 0 -1  0]  [-1  0  0]  [-1  0  0]
+-        [ 0  0 -1], [ 0 -1  0], [1 0 0], [ 1  0  0], [ 0  1  0], [ 0  0 -1],
++        [-1  0  0]  [ 0 -1  0]  [-1  0  0]  [-1  0  0]  [ 0 -1  0]  [ 0  0 -1]
++        [ 0 -1  0]  [ 0  0 -1]  [ 0  0 -1]  [ 0  1  0]  [ 0  0  1]  [ 1  0  0]
++        [ 0  0  1], [ 1  0  0], [ 0 -1  0], [ 0  0 -1], [-1  0  0], [ 0 -1  0],
+         <BLANKLINE>
+-        [ 0  1  0]  [ 0  0  1]  [ 0  0 -1]  [ 0 -1  0]  [0 0 1]  [ 0 -1  0]
+-        [ 1  0  0]  [ 0  1  0]  [ 1  0  0]  [ 0  0  1]  [1 0 0]  [ 1  0  0]
+-        [ 0  0 -1], [-1  0  0], [ 0 -1  0], [-1  0  0], [0 1 0], [ 0  0  1],
++        [ 0  1  0]  [ 0  0  1]  [0 0 1]  [ 0 -1  0]  [ 0  0 -1]  [-1  0  0]
++        [ 1  0  0]  [ 0  1  0]  [1 0 0]  [ 1  0  0]  [ 0  1  0]  [ 0  0  1]
++        [ 0  0 -1], [-1  0  0], [0 1 0], [ 0  0  1], [ 1  0  0], [ 0  1  0],
+         <BLANKLINE>
+-        [-1  0  0]  [-1  0  0]  [ 0  0 -1]  [-1  0  0]  [ 0 -1  0]  [-1  0  0]
+-        [ 0  1  0]  [ 0  0 -1]  [ 0  1  0]  [ 0  0  1]  [ 0  0 -1]  [ 0 -1  0]
+-        [ 0  0 -1], [ 0 -1  0], [ 1  0  0], [ 0  1  0], [ 1  0  0], [ 0  0  1]
++        [ 0 -1  0]  [ 0  0 -1]  [ 0  0  1]  [ 1  0  0]  [ 0  0 -1]  [ 0  1  0]
++        [-1  0  0]  [-1  0  0]  [-1  0  0]  [ 0 -1  0]  [ 0 -1  0]  [ 0  0 -1]
++        [ 0  0 -1], [ 0  1  0], [ 0 -1  0], [ 0  0 -1], [-1  0  0], [-1  0  0]
+         ]
+ 
+     TESTS::
+diff --git a/src/sage/groups/finitely_presented.py b/src/sage/groups/finitely_presented.py
+index 1642d48..4d1dd4c 100644
+--- a/src/sage/groups/finitely_presented.py
++++ b/src/sage/groups/finitely_presented.py
+@@ -1201,7 +1201,7 @@ class FinitelyPresentedGroup(GroupMixinLibGAP, UniqueRepresentation,
+             sage: D = C2.semidirect_product(C8, hom); D
+             Finitely presented group < a, b | a^2, b^8, a^-1*b*a*b >
+             sage: D = C2.semidirect_product(C8, hom, reduced=True); D
+-            Finitely presented group < a, b | a^2, (a*b)^2, b^8 >
++            Finitely presented group < a, b | a^2, a*b*a*b, b^8 >
+ 
+             sage: C3 = groups.presentation.Cyclic(3)
+             sage: C4 = groups.presentation.Cyclic(4)
+@@ -1442,22 +1442,25 @@ class FinitelyPresentedGroup(GroupMixinLibGAP, UniqueRepresentation,
+             sage: H = AlternatingGroup(3)
+             sage: G.epimorphisms(H)
+             [Generic morphism:
+-               From: Finitely presented group < x0, x1, x2 | (x0*x1*x2)^2, x0^3 >
++               From: Finitely presented group < x0, x1, x2 | x0*x1*x2*x0*x1*x2, x0^3 >
+                To:   Alternating group of order 3!/2 as a permutation group
+                Defn: x0 |--> ()
+                      x1 |--> (1,3,2)
+-                     x2 |--> (1,2,3), Generic morphism:
+-               From: Finitely presented group < x0, x1, x2 | (x0*x1*x2)^2, x0^3 >
++                     x2 |--> (1,2,3),
++             Generic morphism:
++               From: Finitely presented group < x0, x1, x2 | x0*x1*x2*x0*x1*x2, x0^3 >
+                To:   Alternating group of order 3!/2 as a permutation group
+                Defn: x0 |--> (1,3,2)
+                      x1 |--> ()
+-                     x2 |--> (1,2,3), Generic morphism:
+-               From: Finitely presented group < x0, x1, x2 | (x0*x1*x2)^2, x0^3 >
++                     x2 |--> (1,2,3),
++             Generic morphism:
++               From: Finitely presented group < x0, x1, x2 | x0*x1*x2*x0*x1*x2, x0^3 >
+                To:   Alternating group of order 3!/2 as a permutation group
+                Defn: x0 |--> (1,3,2)
+                      x1 |--> (1,2,3)
+-                     x2 |--> (), Generic morphism:
+-               From: Finitely presented group < x0, x1, x2 | (x0*x1*x2)^2, x0^3 >
++                     x2 |--> (),
++             Generic morphism:
++               From: Finitely presented group < x0, x1, x2 | x0*x1*x2*x0*x1*x2, x0^3 >
+                To:   Alternating group of order 3!/2 as a permutation group
+                Defn: x0 |--> (1,2,3)
+                      x1 |--> (1,2,3)
+@@ -1548,11 +1551,11 @@ class FinitelyPresentedGroup(GroupMixinLibGAP, UniqueRepresentation,
+             sage: G = F / [a^2,b^3,(a*b/a)^3,b*a*b*a]
+             sage: k = G.rewriting_system()
+             sage: k
+-            Rewriting system of Finitely presented group < a, b | a^2, b^3, a*b^3*a^-1, (b*a)^2 >
++            Rewriting system of Finitely presented group < a, b | a^2, b^3, a*b^3*a^-1, b*a*b*a >
+             with rules:
+                 a^2    --->    1
+                 b^3    --->    1
+-                (b*a)^2    --->    1
++                b*a*b*a    --->    1
+                 a*b^3*a^-1    --->    1
+ 
+             sage: G([1,1,2,2,2])
+diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
+index 2467582..ac0b7a3 100644
+--- a/src/sage/groups/matrix_gps/finitely_generated.py
++++ b/src/sage/groups/matrix_gps/finitely_generated.py
+@@ -549,8 +549,8 @@ class FinitelyGeneratedMatrixGroup_gap(MatrixGroup_gap):
+             sage: MS = MatrixSpace(GF(2), 5, 5)
+             sage: A = MS([[0,0,0,0,1],[0,0,0,1,0],[0,0,1,0,0],[0,1,0,0,0],[1,0,0,0,0]])
+             sage: G = MatrixGroup([A])
+-            sage: G.as_permutation_group()
+-            Permutation Group with generators [(1,2)]
++            sage: G.as_permutation_group().order()
++            2
+ 
+         A finite subgroup of  GL(12,Z) as a permutation group::
+ 
+@@ -624,8 +624,8 @@ class FinitelyGeneratedMatrixGroup_gap(MatrixGroup_gap):
+             sage: MG = GU(3,2).as_matrix_group()
+             sage: PG = MG.as_permutation_group()
+             sage: mg = MG.an_element()
+-            sage: PG(mg)
+-            (1,2,6,19,35,33)(3,9,26,14,31,23)(4,13,5)(7,22,17)(8,24,12)(10,16,32,27,20,28)(11,30,18)(15,25,36,34,29,21)
++            sage: PG(mg).order() # particular element depends on the set of GAP packages installed
++            6
+         """
+         # Note that the output of IsomorphismPermGroup() depends on
+         # memory locations and will change if you change the order of
+diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
+index c411b1e..0355cb6 100644
+--- a/src/sage/groups/perm_gps/permgroup.py
++++ b/src/sage/groups/perm_gps/permgroup.py
+@@ -850,7 +850,7 @@ class PermutationGroup_generic(FiniteGroup):
+            sage: f=PG._coerce_map_from_(MG)
+            sage: mg = MG.an_element()
+            sage: p = f(mg); p
+-           (1,2,6,19,35,33)(3,9,26,14,31,23)(4,13,5)(7,22,17)(8,24,12)(10,16,32,27,20,28)(11,30,18)(15,25,36,34,29,21)
++           (2,33,32,23,31,55)(3,49,38,44,40,28)(4,17,59,62,58,46)(5,21,47,20,43,8)(6,53,50)(7,37,12,57,14,29)(9,41,56,34,64,10)(11,25,19)(13,61,26,51,22,15)(16,45,36)(18,27,35,48,52,54)(24,63,42)(30,39,60)
+            sage: PG(p._gap_()) == p
+            True
+ 
+@@ -899,9 +899,9 @@ class PermutationGroup_generic(FiniteGroup):
+             False
+             sage: g1, g2, g3 = G.gens()
+             sage: P(g1*g2)
+-            (1,9,7,6)(2,10)(3,11)(4,5,8,12)
++            (1,3,7,12)(2,4,8,10)(5,11)(6,9)
+             sage: P1(g1*g2)
+-            (1,4,13,11)(2,5,14,18)(3,15,8,16)(6,7)(9,20,19,12)(10,17)
++            (2,29,25,68)(3,57,13,54)(4,11,72,37)(5,39,60,23)(6,64,75,63)(7,21,50,73)(8,46,38,32)(9,74,35,18)(10,44,49,48)(12,16,34,71)(14,79,27,40)(15,26)(17,62,59,76)(19,78,70,65)(20,22,58,51)(24,33,36,43)(28,81,80,52)(30,53,56,69)(31,61)(41,42,67,55)(45,77)(47,66)
+ 
+         Another check for :trac:`5583`::
+ 
+diff --git a/src/sage/interfaces/gap.py b/src/sage/interfaces/gap.py
+index 123afb8..67e3bbf 100644
+--- a/src/sage/interfaces/gap.py
++++ b/src/sage/interfaces/gap.py
+@@ -277,7 +277,7 @@ def get_gap_memory_pool_size():
+     # Don't eat all address space if the user set ulimit -v
+     suggested_size = min(suggested_size, vmax // 10)
+     # ~220MB is the minimum for long doctests
+-    suggested_size = max(suggested_size, 250 * 1024**2)
++    suggested_size = max(suggested_size, 400 * 1024**2)
+     return suggested_size
+ 
+ 
+@@ -886,7 +886,7 @@ class Gap_generic(ExtraTabCompletion, Expect):
+             sage: print(gap.version())
+             4...
+         """
+-        return self.eval('VERSION')[1:-1]
++        return self.eval('GAPInfo.Version')[1:-1]
+ 
+     def function_call(self, function, args=None, kwds=None):
+         """
+@@ -915,7 +915,7 @@ class Gap_generic(ExtraTabCompletion, Expect):
+         properly::
+ 
+             sage: g = Gap()
+-            sage: g.function_call("ConjugacyClassesSubgroups", sage.interfaces.gap.GapElement(g, 'SymmetricGroup(2)', name = 'a_variable_with_a_very_very_very_long_name'))
++            sage: g.function_call("ConjugacyClassesSubgroups", sage.interfaces.gap.GapElement(g, 'SymmetricGroup(2)', name = 'a_variable_with_a_very_very_very_long_name')) # random
+             [ ConjugacyClassSubgroups(SymmetricGroup( [ 1 .. 2 ] ),Group( () )),
+               ConjugacyClassSubgroups(SymmetricGroup( [ 1 .. 2 ] ),Group( [ (1,2) ] )) ]
+ 
+@@ -923,7 +923,7 @@ class Gap_generic(ExtraTabCompletion, Expect):
+         file to be communicated to GAP, this does not cause problems since
+         the file will contain a single command::
+ 
+-            sage: g.function_call("ConjugacyClassesSubgroups", sage.interfaces.gap.GapElement(g, 'SymmetricGroup(2)', name = 'a_variable_with_a_name_so_very_very_very_long_that_even_by_itself_will_make_expect_use_a_file'))
++            sage: g.function_call("ConjugacyClassesSubgroups", sage.interfaces.gap.GapElement(g, 'SymmetricGroup(2)', name = 'a_variable_with_a_name_so_very_very_very_long_that_even_by_itself_will_make_expect_use_a_file')) # random
+             [ ConjugacyClassSubgroups(SymmetricGroup( [ 1 .. 2 ] ),Group( () )),
+               ConjugacyClassSubgroups(SymmetricGroup( [ 1 .. 2 ] ),Group( [ (1,2) ] )) ]
+         """
+diff --git a/src/sage/libs/gap/sage.gaprc b/src/sage/libs/gap/sage.gaprc
+index 17613fa..39c878f 100644
+--- a/src/sage/libs/gap/sage.gaprc
++++ b/src/sage/libs/gap/sage.gaprc
+@@ -1,12 +1,3 @@
+ # This file is run by Sage when initializing libgap via GAP_Initialize, and may
+ # contain bug fixes/workarounds and/or any Sage-specific patches necessary for
+ # Sage's libgap interface.
+-
+-if GAPInfo.CommandLineOptions.norepl then
+-    # GAP 4.10.0 has a bug that an interactive session will be started
+-    # even if --norepl was set; see https://github.com/gap-system/gap/pull/2840
+-    # To work around this we redefine the SESSION function to a no-op
+-    MAKE_READ_WRITE_GLOBAL("SESSION");
+-    UNBIND_GLOBAL("SESSION");
+-    BIND_GLOBAL("SESSION", function() end);
+-fi;
+diff --git a/src/sage/tests/books/judson-abstract-algebra/sylow-sage.py b/src/sage/tests/books/judson-abstract-algebra/sylow-sage.py
+index b609313..0051f20 100644
+--- a/src/sage/tests/books/judson-abstract-algebra/sylow-sage.py
++++ b/src/sage/tests/books/judson-abstract-algebra/sylow-sage.py
+@@ -236,7 +236,7 @@ r"""
+ ~~~~~~~~~~~~~~~~~~~~~~ ::
+ 
+     sage: G.Center()
+-    Group( [ ( 1, 3, 5)( 2, 4, 6) ] )
++    Group( [ (1,3,5)(2,4,6) ] )
+ 
+ ~~~~~~~~~~~~~~~~~~~~~~ ::
+ 

Copied: sagemath/repos/community-testing-x86_64/sagemath-optional-packages.patch (from rev 749409, sagemath/trunk/sagemath-optional-packages.patch)
===================================================================
--- community-testing-x86_64/sagemath-optional-packages.patch	                        (rev 0)
+++ community-testing-x86_64/sagemath-optional-packages.patch	2020-11-10 07:32:08 UTC (rev 749410)
@@ -0,0 +1,22 @@
+diff --git a/src/setup.py b/src/setup.py
+index f7e04e61e9..3ebc34245f 100755
+--- a/src/setup.py
++++ b/src/setup.py
+@@ -59,14 +59,11 @@ t = time.time()
+ 
+ distributions = ['']
+ 
+-from sage_setup.optional_extension import is_package_installed_and_updated
+-
+ optional_packages_with_extensions = ['mcqd', 'bliss', 'tdlib', 'primecount',
+-                                     'coxeter3', 'fes', 'sirocco', 'meataxe']
++                                     'coxeter3', 'sirocco', 'meataxe']
+ 
+ distributions += ['sage-{}'.format(pkg)
+-                  for pkg in optional_packages_with_extensions
+-                  if is_package_installed_and_updated(pkg)]
++                  for pkg in optional_packages_with_extensions]
+ 
+ log.warn('distributions = {0}'.format(distributions))
+ 
+ 

Copied: sagemath/repos/community-testing-x86_64/sagemath-pari-2.13.patch (from rev 749409, sagemath/trunk/sagemath-pari-2.13.patch)
===================================================================
--- community-testing-x86_64/sagemath-pari-2.13.patch	                        (rev 0)
+++ community-testing-x86_64/sagemath-pari-2.13.patch	2020-11-10 07:32:08 UTC (rev 749410)
@@ -0,0 +1,2202 @@
+diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py
+index ba100c4a83..8aa96d8e14 100644
+--- a/src/sage/arith/misc.py
++++ b/src/sage/arith/misc.py
+@@ -1458,13 +1458,13 @@ def divisors(n):
+ 
+         sage: K.<a> = QuadraticField(7)
+         sage: divisors(K.ideal(7))
+-        [Fractional ideal (1), Fractional ideal (a), Fractional ideal (7)]
++        [Fractional ideal (1), Fractional ideal (-a), Fractional ideal (7)]
+         sage: divisors(K.ideal(3))
+         [Fractional ideal (1), Fractional ideal (3),
+         Fractional ideal (-a + 2), Fractional ideal (-a - 2)]
+         sage: divisors(K.ideal(35))
+-        [Fractional ideal (1), Fractional ideal (5), Fractional ideal (a),
+-        Fractional ideal (7), Fractional ideal (5*a), Fractional ideal (35)]
++        [Fractional ideal (1), Fractional ideal (5), Fractional ideal (-a),
++        Fractional ideal (7), Fractional ideal (-5*a), Fractional ideal (35)]
+ 
+     TESTS::
+ 
+diff --git a/src/sage/ext_data/pari/simon/ell.gp b/src/sage/ext_data/pari/simon/ell.gp
+index 74f0786646..21cff9cbb3 100644
+--- a/src/sage/ext_data/pari/simon/ell.gp
++++ b/src/sage/ext_data/pari/simon/ell.gp
+@@ -1038,7 +1038,7 @@ if( DEBUGLEVEL_ell >= 1, print(" trivial points on E(K) = ");
+   KS2gen = KS2gen[1];
+   for( i = 1, #KS2gen,
+     KS2gen[i] = nfbasistoalg(bnf, KS2gen[i]));
+-  KS2gen = concat(Mod(lift(bnf.tufu),bnf.pol),KS2gen);
++  KS2gen = concat(Mod(lift(concat(bnf.tu[2], bnf.fu)),bnf.pol),KS2gen);
+ if( DEBUGLEVEL_ell >= 2,
+   print("  #K(b,2)gen          = ",#KS2gen);
+   print("  K(b,2)gen = ",KS2gen));
+@@ -1072,7 +1072,7 @@ if( DEBUGLEVEL_ell >= 1,
+   KS2gen = KS2gen[1];
+   for( i = 1, #KS2gen,
+     KS2gen[i] = nfbasistoalg(bnf, KS2gen[i]));
+-  KS2gen = concat(Mod(lift(bnf.tufu),bnf.pol),KS2gen);
++  KS2gen = concat(Mod(lift(concat(bnf.tu[2], bnf.fu)),bnf.pol),KS2gen);
+ if( DEBUGLEVEL_ell >= 2,
+   print("  #K(a^2-4b,2)gen     = ",#KS2gen);
+   print("  K(a^2-4b,2)gen     = ",KS2gen));
+@@ -1244,11 +1244,11 @@ if( DEBUGLEVEL_ell >= 4, print("    bbbnf.clgp = ",bbbnf.clgp));
+   SL1 = idealmul(bbbnf,SL0,rnfeltup(rrrnf,bleg));
+   SL = idealfactor(bbbnf,SL1)[,1]~;
+   sunL = bnfsunit(bbbnf,SL);
+-  fondsunL = concat(bbbnf.futu,vector(#sunL[1],i,nfbasistoalg(bbbnf,sunL[1][i])));
++  fondsunL = concat(concat(bbbnf.fu, bbbnf.tu[2]),vector(#sunL[1],i,nfbasistoalg(bbbnf,sunL[1][i])));
+   normfondsunL = vector(#fondsunL, i, norm(rnfeltabstorel(rrrnf,fondsunL[i])));
+   SK = idealfactor(bnf,idealnorm(bbbnf,SL1))[,1]~;
+   sunK = bnfsunit(bnf,SK);
+-  fondsunK = concat(bnf.futu,vector(#sunK[1],i,nfbasistoalg(bnf,sunK[1][i])));
++  fondsunK = concat(concat(bnf.fu, bnf.tu[2]),vector(#sunK[1],i,nfbasistoalg(bnf,sunK[1][i])));
+   vecbleg = bnfissunit(bnf,sunK,bleg);
+   matnorm = matrix(#fondsunK,#normfondsunL,i,j,0);
+   for( i = 1, #normfondsunL,
+@@ -1345,7 +1345,7 @@ if( DEBUGLEVEL_ell >= 4, print("on factorise bb = ",bb));
+       sun = bnfsunit(bnf,idealfactor(bnf,bb)[,1]~);
+       fact = lift(bnfissunit(bnf,sun,bb));
+ if( DEBUGLEVEL_ell >= 4, print("fact = ",fact));
+-      suni = concat(bnf.futu,vector(#sun[1],i,nfbasistoalg(bnf,sun[1][i])));
++      suni = concat(concat(bnf.fu, bnf.tu[2]),vector(#sun[1],i,nfbasistoalg(bnf,sun[1][i])));
+       for( i = 1, #suni,
+         if( (f = fact[i]>>1), 
+           test =0;
+@@ -1554,7 +1554,7 @@ if( DEBUGLEVEL_ell >= 3, print("    KS2gen = ",KS2gen[1]));
+ 
+   LS2gen = LS2gen[1];
+   LS2 = vector(#LS2gen,i,lift(nfbasistoalg(Lrnf,LS2gen[i])));
+-  LS2 = concat(lift(Lrnf.futu),LS2);
++  LS2 = concat(lift(concat(Lrnf.fu, Lrnf.tu[2])),LS2);
+ 
+   LS2 = subst(LS2,'x,ttheta);
+   LS2 = LS2*Mod(1,polrel);
+@@ -1992,7 +1992,7 @@ if( DEBUGLEVEL_ell >= 2, print("  Algorithm of complete 2-descent"));
+   KS2gen = KS2gen[1];
+   for( i = 1, #KS2gen,
+     KS2gen[i] = nfbasistoalg(bnf, KS2gen[i]));
+-  KS2gen = concat(Mod(lift(bnf.tufu),bnf.pol),KS2gen);
++  KS2gen = concat(Mod(lift(concat(bnf.tu[2], bnf.fu)),bnf.pol),KS2gen);
+ if( DEBUGLEVEL_ell >= 2,
+   print("  #K(S,2)gen = ",#KS2gen);
+   print("   K(S,2)gen = ",KS2gen)
+diff --git a/src/sage/ext_data/pari/simon/ellQ.gp b/src/sage/ext_data/pari/simon/ellQ.gp
+index aede9fc941..27cc124372 100644
+--- a/src/sage/ext_data/pari/simon/ellQ.gp
++++ b/src/sage/ext_data/pari/simon/ellQ.gp
+@@ -1162,7 +1162,7 @@ if( DEBUGLEVEL_ell >= 4, print("    kerval = ",kerval));
+       LS2gen[j]^kerval[j,i]));
+ 
+ \\ Add the units
+-  LS2gen = concat(Mod(bnf[8][5],bnf.pol),LS2gen); \\ LS2gen = concat(bnf.fu,LS2gen);
++  LS2gen = concat(bnf.fu,LS2gen); \\ LS2gen = concat(bnf.fu,LS2gen);
+ \\ Add also the torsion unit if its order is divisible by p.
+   if( bnf[8][4][1]%p == 0, \\ if( bnf.tu[1]%p == 0,
+     LS2gen = concat( [Mod(bnf[8][4][2],bnf.pol)], LS2gen)); \\ LS2gen = concat( [Mod(bnf.tu[2],bnf.pol)], LS2gen));
+diff --git a/src/sage/geometry/cone.py b/src/sage/geometry/cone.py
+index 33b28dbede..1c6873eadd 100644
+--- a/src/sage/geometry/cone.py
++++ b/src/sage/geometry/cone.py
+@@ -4268,31 +4268,31 @@ class ConvexRationalPolyhedralCone(IntegralRayCollection, Container):
+             M(-5,  21,  0, -3),
+             M( 0,  -2,  0,  1),
+             M(15, -63, 25,  9),
+-            M( 2,  -3,  0,  1),
+-            M( 1,  -4,  1,  1),
+-            M(-1,   3,  0,  0),
+             M( 4,  -4,  0,  1),
+-            M( 1,  -5,  2,  1),
+             M( 3,  -5,  1,  1),
+-            M( 6,  -5,  0,  1),
+-            M( 3, -13,  5,  2),
+             M( 2,  -6,  2,  1),
+-            M( 5,  -6,  1,  1),
+-            M( 0,   1,  0,  0),
+-            M( 8,  -6,  0,  1),
++            M(-1,   7,  0, -1),
++            M( 6, -21,  8,  3),
++            M( 5, -21,  9,  3),
++            M(-1,   3,  0,  0),
++            M( 7, -28, 11,  4),
++            M( 1,  -5,  2,  1),
+             M(-2,   8,  0, -1),
++            M( 8,  -6,  0,  1),
++            M( 7,  -7,  1,  1),
++            M( 3, -13,  5,  2),
++            M( 2,  -3,  0,  1),
++            M( 1,  -4,  1,  1),
++            M(-3,  14,  0, -2),
+             M(10, -42, 17,  6),
+-            M( 7, -28, 11,  4),
+-            M( 5, -21,  9,  3),
+-            M( 6, -21,  8,  3),
++            M( 1,   0,  0,  0),
++            M( 0,   0,  1,  0),
++            M( 6,  -5,  0,  1),
++            M( 5,  -6,  1,  1),
++            M( 4,  -7,  2,  1),
+             M( 5, -14,  5,  2),
+             M( 2,  -7,  3,  1),
+-            M( 4,  -7,  2,  1),
+-            M( 7,  -7,  1,  1),
+-            M( 0,   0,  1,  0),
+-            M(-3,  14,  0, -2),
+-            M(-1,   7,  0, -1),
+-            M( 1,   0,  0,  0)
++            M( 0,   1,  0,  0)
+             in 4-d lattice M
+ 
+         Not a strictly convex cone::
+diff --git a/src/sage/groups/abelian_gps/abelian_group.py b/src/sage/groups/abelian_gps/abelian_group.py
+index dd9944370b..6ebf56b62d 100644
+--- a/src/sage/groups/abelian_gps/abelian_group.py
++++ b/src/sage/groups/abelian_gps/abelian_group.py
+@@ -1452,7 +1452,7 @@ class AbelianGroup_class(UniqueRepresentation, AbelianGroupBase):
+         EXAMPLES::
+ 
+             sage: AbelianGroup([2,3]).subgroups()
+-            [Multiplicative Abelian subgroup isomorphic to C2 x C3 generated by {f0*f1^2},
++            [Multiplicative Abelian subgroup isomorphic to C2 x C3 generated by {f0*f1},
+              Multiplicative Abelian subgroup isomorphic to C2 generated by {f0},
+              Multiplicative Abelian subgroup isomorphic to C3 generated by {f1},
+              Trivial Abelian subgroup]
+diff --git a/src/sage/groups/additive_abelian/additive_abelian_group.py b/src/sage/groups/additive_abelian/additive_abelian_group.py
+index 3dcedeb7e3..48747e4870 100644
+--- a/src/sage/groups/additive_abelian/additive_abelian_group.py
++++ b/src/sage/groups/additive_abelian/additive_abelian_group.py
+@@ -61,18 +61,18 @@ def AdditiveAbelianGroup(invs, remember_generators = True):
+         ((1, 0, 0), (0, 1, 0), (0, 0, 1))
+         sage: [H.0, H.1, H.2]
+         [(1, 0, 0), (0, 1, 0), (0, 0, 1)]
+-        sage: p=H.0+H.1+6*H.2; p
+-        (1, 1, 6)
++        sage: p=2*H.0+H.1+6*H.2; p
++        (2, 1, 6)
+ 
+         sage: H.smith_form_gens()
+-        ((2, 1, 0), (0, 0, 1))
++        ((1, 1, 0), (0, 0, 1))
+         sage: q=H.linear_combination_of_smith_form_gens([5,6]); q
+-        (1, 1, 6)
++        (2, 1, 6)
+         sage: p==q
+         True
+ 
+-        sage: r=H(vector([1,1,6])); r
+-        (1, 1, 6)
++        sage: r=H(vector([2,1,6])); r
++        (2, 1, 6)
+         sage: p==r
+         True
+ 
+@@ -85,21 +85,21 @@ def AdditiveAbelianGroup(invs, remember_generators = True):
+ 
+         sage: G=AdditiveAbelianGroup([3,2,0], remember_generators=False)
+         sage: G.gens()
+-        ((2, 1, 0), (0, 0, 1))
++        ((1, 1, 0), (0, 0, 1))
+         sage: [G.0, G.1]
+-        [(2, 1, 0), (0, 0, 1)]
++        [(1, 1, 0), (0, 0, 1)]
+         sage: p=5*G.0+6*G.1; p
+-        (1, 1, 6)
++        (2, 1, 6)
+ 
+         sage: H.smith_form_gens()
+-        ((2, 1, 0), (0, 0, 1))
++        ((1, 1, 0), (0, 0, 1))
+         sage: q=G.linear_combination_of_smith_form_gens([5,6]); q
+-        (1, 1, 6)
++        (2, 1, 6)
+         sage: p==q
+         True
+ 
+-        sage: r=G(vector([1,1,6])); r
+-        (1, 1, 6)
++        sage: r=G(vector([2,1,6])); r
++        (2, 1, 6)
+         sage: p==r
+         True
+ 
+@@ -427,7 +427,7 @@ class AdditiveAbelianGroup_fixed_gens(AdditiveAbelianGroup_class):
+             sage: G.gens()
+             ((1, 0), (0, 1))
+             sage: G.smith_form_gens()
+-            ((1, 2),)
++            ((1, 1),)
+         """
+         return self._orig_gens
+ 
+diff --git a/src/sage/groups/fqf_orthogonal.py b/src/sage/groups/fqf_orthogonal.py
+index 3c5190589b..c536f03064 100644
+--- a/src/sage/groups/fqf_orthogonal.py
++++ b/src/sage/groups/fqf_orthogonal.py
+@@ -156,9 +156,9 @@ class FqfOrthogonalGroup(AbelianGroupAutomorphismGroup_subgroup):
+         sage: S2 = 9 * T
+         sage: Q = S1/S2
+         sage: G = T.orthogonal_group()
+-        sage: g = G(matrix(ZZ, 2, [8, 0, 0, 1]))
++        sage: g = G(matrix(ZZ, 2, [7, 12, 8, 19]))
+         sage: Q.1 * g
+-        (0, 2)
++        (0, 1)
+     """
+     Element = FqfIsometry
+ 
+diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
+index c45f3bfd5c..233905dd87 100644
+--- a/src/sage/lfunctions/pari.py
++++ b/src/sage/lfunctions/pari.py
+@@ -422,7 +422,7 @@ class LFunction(SageObject):
+         sage: L.derivative(1,E.rank())
+         1.51863300057685
+         sage: L.taylor_series(1,4)
+-        -3...e-19 + (...e-19)*z + 0.759316500288427*z^2 - 0.430302337583362*z^3 + O(z^4)
++        ...e-19 + (...e-19)*z + 0.759316500288427*z^2 - 0.430302337583362*z^3 + O(z^4)
+ 
+     .. RUBRIC:: Number field
+ 
+diff --git a/src/sage/libs/pari/__init__.py b/src/sage/libs/pari/__init__.py
+index 77eda66097..3fa4618631 100644
+--- a/src/sage/libs/pari/__init__.py
++++ b/src/sage/libs/pari/__init__.py
+@@ -161,12 +161,12 @@ exact object. Therefore, you should set the precision for each method
+ call individually::
+ 
+     sage: e = pari([0,0,0,-82,0]).ellinit()
+-    sage: eta1 = e.elleta(precision=100)[0]
++    sage: eta1 = e.elleta(precision=50)[0]
+     sage: eta1.sage()
+     3.6054636014326520859158205642077267748
+     sage: eta1 = e.elleta(precision=180)[0]
+     sage: eta1.sage()
+-    3.60546360143265208591582056420772677481026899659802474544
++    3.605463601432652085915820564207726774810268996598024745444380641429820491740
+ 
+ """
+ 
+diff --git a/src/sage/libs/pari/convert_sage.pyx b/src/sage/libs/pari/convert_sage.pyx
+index 33aa4d2d46..b506227cff 100644
+--- a/src/sage/libs/pari/convert_sage.pyx
++++ b/src/sage/libs/pari/convert_sage.pyx
+@@ -144,6 +144,20 @@ cpdef gen_to_sage(Gen z, locals=None):
+         sage: a.parent()
+         Complex Field with 64 bits of precision
+ 
++        sage: z = pari('1 + 1.0*I'); z
++        1 + 1.00000000000000*I
++        sage: a = gen_to_sage(z); a
++        1.00000000000000000 + 1.00000000000000000*I
++        sage: a.parent()
++        Complex Field with 64 bits of precision
++
++        sage: z = pari('1.0 + 1*I'); z
++        1.00000000000000 + I
++        sage: a = gen_to_sage(z); a
++        1.00000000000000000 + 1.00000000000000000*I
++        sage: a.parent()
++        Complex Field with 64 bits of precision
++
+     Converting polynomials::
+ 
+         sage: f = pari('(2/3)*x^3 + x - 5/7 + y')
+@@ -241,7 +255,9 @@ cpdef gen_to_sage(Gen z, locals=None):
+     elif t == t_FRAC:
+         return Rational(z)
+     elif t == t_REAL:
+-        prec = prec_words_to_bits(z.precision())
++        prec = z.bitprecision()
++        if prec.type() == 't_INFINITY':
++            prec = 53
+         return RealField(prec)(z)
+     elif t == t_COMPLEX:
+         real = z.real()
+@@ -251,14 +267,19 @@ cpdef gen_to_sage(Gen z, locals=None):
+         if tx in [t_INTMOD, t_PADIC] or ty in [t_INTMOD, t_PADIC]:
+             raise NotImplementedError("No conversion to python available for t_COMPLEX with t_INTMOD or t_PADIC components")
+         if tx == t_REAL or ty == t_REAL:
+-            xprec = real.precision()  # will be 0 if exact
+-            yprec = imag.precision()  # will be 0 if exact
+-            if xprec == 0:
+-                prec = prec_words_to_bits(yprec)
+-            elif yprec == 0:
+-                prec = prec_words_to_bits(xprec)
++            xprec = real.bitprecision()  # will be 0 if exact
++            yprec = imag.bitprecision()  # will be 0 if exact
++            if xprec == 0 or yprec == 0:
++                raise RuntimeError
++            if xprec.type() == 't_INFINITY':
++                if yprec.type() == 't_INFINITY':
++                    prec = 53
++                else:
++                    prec = yprec
++            elif yprec.type() == 't_INFINITY':
++                prec = xprec
+             else:
+-                prec = max(prec_words_to_bits(xprec), prec_words_to_bits(yprec))
++                prec = max(xprec, yprec)
+ 
+             R = RealField(prec)
+             C = ComplexField(prec)
+diff --git a/src/sage/libs/pari/tests.py b/src/sage/libs/pari/tests.py
+index 415a707fe8..6a3626f308 100644
+--- a/src/sage/libs/pari/tests.py
++++ b/src/sage/libs/pari/tests.py
+@@ -135,7 +135,7 @@ Some more exotic examples::
+ 
+     sage: K.<a> = NumberField(polygen(QQ)^3 - 2)
+     sage: pari(K)
+-    [y^3 - 2, [1, 1], -108, 1, [[1, 1.25992104989487, 1.58740105196820; 1, -0.629960524947437 + 1.09112363597172*I, -0.793700525984100 - 1.37472963699860*I], [1, 1.25992104989487, 1.58740105196820; 1, 0.461163111024285, -2.16843016298270; 1, -1.72108416091916, 0.581029111014503], [1, 1, 2; 1, 0, -2; 1, -2, 1], [3, 0, 0; 0, 0, 6; 0, 6, 0], [6, 0, 0; 0, 6, 0; 0, 0, 3], [2, 0, 0; 0, 0, 1; 0, 1, 0], [2, [0, 0, 2; 1, 0, 0; 0, 1, 0]], []], [1.25992104989487, -0.629960524947437 + 1.09112363597172*I], [1, y, y^2], [1, 0, 0; 0, 1, 0; 0, 0, 1], [1, 0, 0, 0, 0, 2, 0, 2, 0; 0, 1, 0, 1, 0, 0, 0, 0, 2; 0, 0, 1, 0, 1, 0, 1, 0, 0]]
++    [y^3 - 2, [1, 1], -108, 1, [[1, 1.25992104989487, 1.58740105196820; 1, -0.629960524947437 + 1.09112363597172*I, -0.793700525984100 - 1.37472963699860*I], [1, 1.25992104989487, 1.58740105196820; 1, 0.461163111024285, -2.16843016298270; 1, -1.72108416091916, 0.581029111014503], [16, 20, 25; 16, 7, -35; 16, -28, 9], [3, 0, 0; 0, 0, 6; 0, 6, 0], [6, 0, 0; 0, 6, 0; 0, 0, 3], [2, 0, 0; 0, 0, 1; 0, 1, 0], [2, [0, 0, 2; 1, 0, 0; 0, 1, 0]], [2, 3]], [1.25992104989487, -0.629960524947437 + 1.09112363597172*I], [1, y, y^2], [1, 0, 0; 0, 1, 0; 0, 0, 1], [1, 0, 0, 0, 0, 2, 0, 2, 0; 0, 1, 0, 1, 0, 0, 0, 0, 2; 0, 0, 1, 0, 1, 0, 1, 0, 0]]
+ 
+     sage: E = EllipticCurve('37a1')
+     sage: pari(E)
+@@ -375,13 +375,13 @@ Constructors::
+     sage: pari('["bc","ab","bc"]').Set()
+     ["ab", "bc"]
+ 
+-    sage: pari([65,66,123]).Strchr()
++    sage: pari([65,66,123]).strchr()
+     "AB{"
+     sage: pari('"Sage"').Vecsmall()
+     Vecsmall([83, 97, 103, 101])
+-    sage: _.Strchr()
++    sage: _.strchr()
+     "Sage"
+-    sage: pari([83, 97, 103, 101]).Strchr()
++    sage: pari([83, 97, 103, 101]).strchr()
+     "Sage"
+ 
+ Basic functions::
+@@ -448,7 +448,7 @@ Basic functions::
+     sage: pari('x').component(0)
+     Traceback (most recent call last):
+     ...
+-    PariError: non-existent component: index < 1
++    PariError: nonexistent component: index < 1
+ 
+     sage: pari('x+1').conj()
+     x + 1
+@@ -763,7 +763,7 @@ Transcendental functions::
+     sage: pari(2).besseli(3+i)
+     1.12539407613913 + 2.08313822670661*I
+     sage: C.<i> = ComplexField()
+-    sage: pari(2+i).besseln(3)
++    sage: pari(2+i).bessely(3)
+     -0.280775566958244 - 0.486708533223726*I
+ 
+     sage: pari(1.5).cos()
+@@ -818,7 +818,7 @@ Transcendental functions::
+     sage: pari(-1).gamma()
+     Traceback (most recent call last):
+     ...
+-    PariError: domain error in gamma: argument = non-positive integer
++    PariError: domain error in gamma: argument = nonpositive integer
+ 
+     sage: pari(2).gammah()
+     1.32934038817914
+@@ -1629,7 +1624,7 @@ General number fields::
+ 
+     sage: x = QQ['x'].0; nf = pari(x^2 + 2).nfinit()
+     sage: nf.nfgaloisconj()
+-    [x, -x]~
++    [-x, x]~
+     sage: nf = pari(x^3 + 2).nfinit()
+     sage: nf.nfgaloisconj()
+     [x]~
+@@ -1672,7 +1667,7 @@ General number fields::
+     [[1, [7605, 4]~, [5610, 5]~, [7913, -6]~; 0, 1, 0, -1; 0, 0, 1, 0; 0, 0, 0, 1], [[19320, 13720; 0, 56], [2, 1; 0, 1], 1, 1]]
+ 
+     sage: pari('x^3 - 17').nfinit()
+-    [x^3 - 17, [1, 1], -867, 3, [[1, 1.68006914259990, 2.57128159065824; 1, -0.340034571299952 - 2.65083754153991*I, -1.28564079532912 + 2.22679517779329*I], [1, 1.68006914259990, 2.57128159065824; 1, -2.99087211283986, 0.941154382464174; 1, 2.31080297023995, -3.51243597312241], [1, 2, 3; 1, -3, 1; 1, 2, -4], [3, 1, 0; 1, -11, 17; 0, 17, 0], [51, 0, 16; 0, 17, 3; 0, 0, 1], [17, 0, -1; 0, 0, 3; -1, 3, 2], [51, [-17, 6, -1; 0, -18, 3; 1, 0, -16]], [3, 17]], [2.57128159065824, -1.28564079532912 + 2.22679517779329*I], [3, x^2 - x + 1, 3*x], [1, 0, -1; 0, 0, 3; 0, 1, 1], [1, 0, 0, 0, -4, 6, 0, 6, -1; 0, 1, 0, 1, 1, -1, 0, -1, 3; 0, 0, 1, 0, 2, 0, 1, 0, 1]]
++    [x^3 - 17, [1, 1], -867, 3, [[1, 1.68006914259990, 2.57128159065824; 1, -0.340034571299952 - 2.65083754153991*I, -1.28564079532912 + 2.22679517779329*I], [1, 1.68006914259990, 2.57128159065824; 1, -2.99087211283986, 0.941154382464174; 1, 2.31080297023995, -3.51243597312241], [16, 27, 41; 16, -48, 15; 16, 37, -56], [3, 1, 0; 1, -11, 17; 0, 17, 0], [51, 0, 16; 0, 17, 3; 0, 0, 1], [17, 0, -1; 0, 0, 3; -1, 3, 2], [51, [-17, 6, -1; 0, -18, 3; 1, 0, -16]], [3, 17]], [2.57128159065824, -1.28564079532912 + 2.22679517779329*I], [3, x^2 - x + 1, 3*x], [1, 0, -1; 0, 0, 3; 0, 1, 1], [1, 0, 0, 0, -4, 6, 0, 6, -1; 0, 1, 0, 1, 1, -1, 0, -1, 3; 0, 0, 1, 0, 2, 0, 1, 0, 1]]
+     sage: pari('x^2 + 10^100 + 1').nfinit()
+     [...]
+     sage: pari('1.0').nfinit()
+@@ -1733,7 +1728,7 @@ General number fields::
+     sage: pari(-23).quadhilbert()
+     x^3 - x^2 + 1
+     sage: pari(145).quadhilbert()
+-    x^4 - 6*x^2 - 5*x - 1
++    x^4 - x^3 - 5*x^2 - x + 1
+     sage: pari(-12).quadhilbert()   # Not fundamental
+     Traceback (most recent call last):
+     ...
+@@ -1758,7 +1753,7 @@ library::
+     sage: e = pari([0,0,0,-82,0]).ellinit()
+     sage: eta1 = e.elleta(precision=100)[0]
+     sage: eta1.sage()
+-    3.6054636014326520859158205642077267748
++    3.60546360143265208591582056420772677481026899659802474544
+     sage: eta1 = e.elleta(precision=180)[0]
+     sage: eta1.sage()
+     3.60546360143265208591582056420772677481026899659802474544
+diff --git a/src/sage/matrix/matrix1.pyx b/src/sage/matrix/matrix1.pyx
+index 689195dc85..6bca9e19ca 100644
+--- a/src/sage/matrix/matrix1.pyx
++++ b/src/sage/matrix/matrix1.pyx
+@@ -87,7 +87,7 @@ cdef class Matrix(Matrix0):
+             [1.000000000, 2.000000000; 3.000000000, 1.000000000] # 32-bit
+             [1.00000000000000, 2.00000000000000; 3.00000000000000, 1.00000000000000] # 64-bit
+             sage: b[0][0].precision()    # in words
+-            3
++            19
+         """
+         from sage.libs.pari.all import pari
+         return pari.matrix(self._nrows, self._ncols, self._list())
+diff --git a/src/sage/modular/local_comp/liftings.py b/src/sage/modular/local_comp/liftings.py
+index 5d7be71f16..5ed77f1785 100644
+--- a/src/sage/modular/local_comp/liftings.py
++++ b/src/sage/modular/local_comp/liftings.py
+@@ -222,9 +222,9 @@ def lift_for_SL(A, N=None):
+     TESTS::
+ 
+         sage: lift_for_SL(matrix(3,3,[1,2,0,3,4,0,0,0,1]),3)
+-        [10 14  3]
+-        [ 9 10  3]
+-        [ 3  3  1]
++        [ -2  -4   3]
++        [ -9 -14   3]
++        [ -6  -9   1]
+ 
+         sage: A = matrix(Zmod(7), 2, [1,0,0,1])
+         sage: L = lift_for_SL(A)
+diff --git a/src/sage/modular/local_comp/smoothchar.py b/src/sage/modular/local_comp/smoothchar.py
+index 6dedb26e7e..3b1ac90460 100644
+--- a/src/sage/modular/local_comp/smoothchar.py
++++ b/src/sage/modular/local_comp/smoothchar.py
+@@ -1617,8 +1617,8 @@ class SmoothCharacterGroupRamifiedQuadratic(SmoothCharacterGroupGeneric):
+             sage: G = SmoothCharacterGroupRamifiedQuadratic(3, 1, QQ)
+             sage: s = G.number_field().gen()
+             sage: G.discrete_log(4, 3 + 2*s)
+-            [5, 1, 1, 1]
+-            sage: gs = G.unit_gens(4); gs[0]^5 * gs[1] * gs[2] * gs[3] - (3 + 2*s) in G.ideal(4)
++            [1, 2, 2, 1]
++            sage: gs = G.unit_gens(4); gs[0] * gs[1]^2 * gs[2]^2 * gs[3] - (3 + 2*s) in G.ideal(4)
+             True
+         """
+         x = self.number_field().coerce(x)
+diff --git a/src/sage/modular/modsym/p1list_nf.py b/src/sage/modular/modsym/p1list_nf.py
+index 7a91d353e3..b71fc8aac4 100644
+--- a/src/sage/modular/modsym/p1list_nf.py
++++ b/src/sage/modular/modsym/p1list_nf.py
+@@ -956,7 +956,7 @@ class P1NFList(SageObject):
+             sage: N = k.ideal(a + 1)
+             sage: P = P1NFList(N)
+             sage: u = k.unit_group().gens_values(); u
+-            [-1, a^3 + a^2 + a + 12, a^3 + 3*a^2 - 1]
++            [-1, -a^3 - a^2 - a - 12, -a^3 - 3*a^2 + 1]
+             sage: P.apply_J_epsilon(3, u[2]^2)==P.apply_J_epsilon(P.apply_J_epsilon(3, u[2]),u[2])
+             True
+         """
+diff --git a/src/sage/modular/multiple_zeta.py b/src/sage/modular/multiple_zeta.py
+index 540e29d0e5..9083303db3 100644
+--- a/src/sage/modular/multiple_zeta.py
++++ b/src/sage/modular/multiple_zeta.py
+@@ -455,7 +455,7 @@ class MultizetaValues(UniqueRepresentation):
+         """
+         self.prec = int(prec)
+         self.max_weight = int(max_weight)
+-        self._data = pari.zetamultall(self.max_weight, self.prec)
++        self._data = pari.zetamultall(self.max_weight, precision=self.prec)
+ 
+     def update(self, max_weight, prec):
+         """
+diff --git a/src/sage/modules/fg_pid/fgp_element.py b/src/sage/modules/fg_pid/fgp_element.py
+index 53857d31a0..6557b7f308 100644
+--- a/src/sage/modules/fg_pid/fgp_element.py
++++ b/src/sage/modules/fg_pid/fgp_element.py
+@@ -39,7 +39,7 @@ class FGP_Element(ModuleElement):
+         sage: V = span([[1/2,1,1],[3/2,2,1],[0,0,1]],ZZ); W = V.span([2*V.0+4*V.1, 9*V.0+12*V.1, 4*V.2])
+         sage: Q = V/W
+         sage: x = Q(V.0-V.1); x #indirect doctest
+-        (0, 3)
++        (0, 9)
+         sage: isinstance(x, sage.modules.fg_pid.fgp_element.FGP_Element)
+         True
+         sage: type(x)
+@@ -94,14 +94,14 @@ class FGP_Element(ModuleElement):
+             sage: Q.1
+             (0, 1)
+             sage: Q.0.lift()
+-            (0, 0, 1)
++            (0, -6, 1)
+             sage: Q.1.lift()
+-            (0, 2, 0)
++            (0, -2, 0)
+             sage: x = Q(V.0); x
+-            (0, 4)
++            (0, 8)
+             sage: x.lift()
+             (1/2, 0, 0)
+-            sage: x == 4*Q.1
++            sage: x == 8*Q.1
+             True
+             sage: x.lift().parent() == V
+             True
+@@ -158,9 +158,9 @@ class FGP_Element(ModuleElement):
+         We test canonical coercion from V and W.
+ 
+             sage: Q.0 + V.0
+-            (1, 4)
++            (1, 8)
+             sage: V.0 + Q.0
+-            (1, 4)
++            (1, 8)
+             sage: W.0 + Q.0
+             (1, 0)
+             sage: W.0 + Q.0 == Q.0
+@@ -291,7 +291,7 @@ class FGP_Element(ModuleElement):
+             sage: V = span([[1/2,1,1],[3/2,2,1],[0,0,1]],ZZ); W = V.span([2*V.0+4*V.1, 9*V.0+12*V.1, 4*V.2])
+             sage: Q = V/W
+             sage: Q(V.1)._repr_()
+-            '(0, 1)'
++            '(0, 11)'
+         """
+         return repr(self.vector())
+ 
+diff --git a/src/sage/modules/fg_pid/fgp_module.py b/src/sage/modules/fg_pid/fgp_module.py
+index b111d7fb32..c518d7479a 100644
+--- a/src/sage/modules/fg_pid/fgp_module.py
++++ b/src/sage/modules/fg_pid/fgp_module.py
+@@ -70,17 +70,17 @@ the technical note has a V that need not be equal to V0, in general. ::
+     sage: M0.optimized()[0].V()
+     Free module of degree 3 and rank 2 over Integer Ring
+     User basis matrix:
+-    [0 0 1]
+-    [0 2 0]
++    [ 0 -8  1]
++    [ 0 -2  0]
+ 
+ Create elements of M0 either by coercing in elements of V0, getting generators,
+ or coercing in a list or tuple or coercing in 0. Finally, one can express an
+ element as a linear combination of the smith form generators ::
+ 
+     sage: M0(V0.0)
+-    (0, 14)
++    (0, 2)
+     sage: M0(V0.0 + W0.0)  # no difference modulo W0
+-    (0, 14)
++    (0, 2)
+     sage: M0.linear_combination_of_smith_form_gens([3,20])
+     (3, 4)
+     sage: 3*M0.0 + 20*M0.1
+@@ -93,9 +93,9 @@ coerces to V0, then take the equivalence class modulo W0. ::
+     sage: x = M0.0 - M0.1; x
+     (1, 15)
+     sage: x.lift()
+-    (0, -2, 1)
++    (0, -6, 1)
+     sage: M0(vector([1/2,0,0]))
+-    (0, 14)
++    (0, 2)
+     sage: x.additive_order()
+     16
+ 
+@@ -143,7 +143,7 @@ You can explicitly coerce elements of the kernel into M0 though. ::
+     sage: M0(K.0)
+     (2, 0)
+     sage: M0(K.1)
+-    (3, 1)
++    (1, 13)
+     sage: f(M0(K.0))
+     (0)
+     sage: f(M0(K.1))
+@@ -179,7 +179,7 @@ TESTS::
+     sage: Q.linear_combination_of_smith_form_gens([1,3])
+     (1, 3)
+     sage: Q(V([1,3,4]))
+-    (0, 11)
++    (0, 1)
+     sage: Q(W([1,16,0]))
+     (0, 0)
+     sage: V = span([[1/2,1,1],[3/2,2,1],[0,0,1]],QQ)
+@@ -632,7 +632,7 @@ class FGP_Module_class(Module):
+             sage: W = V.span([2*V.0+4*V.1, 9*V.0+12*V.1, 4*V.2])
+             sage: Q = V/W
+             sage: x = Q(V.0-V.1); x  # indirect doctest
+-            (0, 3)
++            (0, 9)
+             sage: type(x)
+             <class 'sage.modules.fg_pid.fgp_module.FGP_Module_class_with_category.element_class'>
+             sage: x is Q(x)
+@@ -931,9 +931,9 @@ class FGP_Module_class(Module):
+             sage: Q = V/W
+             sage: Q._smith_form()
+             (
+-            [ 1  0  0]  [1 0 0]  [ 1  0 -8]
+-            [ 0  4  0]  [0 0 1]  [ 0  0  1]
+-            [ 0  0 12], [0 1 0], [ 0  1  0]
++            [ 1  0  0]  [ 1  0  1]  [ 1 -4 20]
++            [ 0  4  0]  [ 0 -1  1]  [ 0  0 -1]
++            [ 0  0 12], [ 0 -1  0], [ 0  1 -3]
+             )
+         """
+         return self._relative_matrix().smith_form()
+@@ -1026,7 +1026,7 @@ class FGP_Module_class(Module):
+             sage: Q.smith_form_gens()
+             ((1, 0), (0, 1))
+             sage: [x.lift() for x in Q.smith_form_gens()]
+-            [(0, 0, 1), (0, 1, 0)]
++            [(0, -3, 1), (0, -1, 0)]
+         """
+         # Get the rightmost transformation in the Smith form
+         _, _, X = self._smith_form()
+@@ -1067,18 +1067,18 @@ class FGP_Module_class(Module):
+             [  0   0   0 1/3   0]
+             [  0   0   0   0 2/3]
+             sage: D.gens_to_smith()
+-            [0 3 0]
++            [0 3 6]
+             [0 0 3]
+-            [0 2 0]
+-            [1 0 0]
+-            [0 0 4]
++            [0 4 4]
++            [1 2 0]
++            [0 0 8]
+             sage: T = D.gens_to_smith()*D.smith_to_gens()
+             sage: T
+-            [ 3  0 15  0  0]
+-            [ 0 33  0  0  3]
+-            [ 2  0 10  0  0]
+-            [ 0  0  0  1  0]
+-            [ 0 44  0  0  4]
++            [27 48  3  0 60]
++            [12 21  0  0 24]
++            [20 36  4  0 48]
++            [ 2  4  3  1  9]
++            [32 56  0  0 64]
+ 
+         The matrix `T` now satisfies a certain congruence::
+ 
+@@ -1120,14 +1120,14 @@ class FGP_Module_class(Module):
+             [  0   0   0 1/3   0]
+             [  0   0   0   0 2/3]
+             sage: D.smith_to_gens()
+-            [ 0  0  0  1  0]
+-            [ 1  0  5  0  0]
+-            [ 0 11  0  0  1]
++            [0 0 1 1 1]
++            [1 2 1 0 4]
++            [4 7 0 0 8]
+             sage: T = D.smith_to_gens()*D.gens_to_smith()
+             sage: T
+-            [ 1  0  0]
+-            [ 0 13  0]
+-            [ 0  0 37]
++            [  1   6  12]
++            [  0   7  48]
++            [  0  12 109]
+ 
+         This matrix satisfies the congruence::
+ 
+@@ -1148,7 +1148,7 @@ class FGP_Module_class(Module):
+         of the user defined generators that is x::
+ 
+             sage: x.vector() * D.smith_to_gens()
+-            (2, 33, 10, 1, 3)
++            (14, 25, 3, 1, 33)
+         """
+         if self.base_ring() != ZZ:
+             # it is not
+@@ -1196,7 +1196,7 @@ class FGP_Module_class(Module):
+              sage: gens = [V(g) for g in gens]
+              sage: D = FGP_with_gens(V, W, gens)
+              sage: D.gens()
+-             ((0, 3, 0), (0, 0, 3), (0, 2, 0), (1, 0, 0), (0, 0, 8))
++             ((0, 3, 6), (0, 0, 9), (0, 4, 4), (1, 2, 0), (0, 0, 4))
+ 
+ 
+         We create some element of D::
+@@ -1209,12 +1209,12 @@ class FGP_Module_class(Module):
+ 
+             sage: v = D.gens_vector(x)
+             sage: v
+-            (2, 9, 10, 1, 33)
++            (26, 11, 3, 1, 18)
+ 
+         The output can be further reduced::
+ 
+             sage: D.gens_vector(x, reduce=True)
+-            (0, 1, 1, 1, 0)
++            (0, 3, 0, 1, 0)
+ 
+         Let us check::
+ 
+@@ -1278,28 +1278,28 @@ class FGP_Module_class(Module):
+             sage: O.V()
+             Free module of degree 3 and rank 2 over Integer Ring
+             User basis matrix:
+-            [0 0 1]
+-            [0 2 0]
++            [ 0 -6  1]
++            [ 0 -2  0]
+             sage: phi = Q.hom([Q.0, 4*Q.1])
+             sage: x = Q(V.0); x
+-            (0, 4)
++            (0, 8)
+             sage: Q.coordinate_vector(x, reduce=True)
+-            (0, 4)
++            (0, 8)
+             sage: Q.coordinate_vector(-x, reduce=False) # random
+-            (0, -4)
+-            sage: x == 4*Q.1
++            (0, -8)
++            sage: x == 8*Q.1
+             True
+             sage: x = Q(V.1); x
+-            (0, 1)
++            (0, 11)
+             sage: Q.coordinate_vector(x)
+-            (0, 1)
+-            sage: x == Q.1
++            (0, -1)
++            sage: x == -Q.1
+             True
+             sage: x = Q(V.2); x
+-            (1, 0)
++            (1, 9)
+             sage: Q.coordinate_vector(x)
+-            (1, 0)
+-            sage: x == Q.0
++            (1, -3)
++            sage: x == Q.0-3*Q.1
+             True
+         """
+         try:
+@@ -1407,8 +1407,8 @@ class FGP_Module_class(Module):
+             sage: O.V()
+             Free module of degree 3 and rank 2 over Integer Ring
+             User basis matrix:
+-            [0 0 1]
+-            [0 1 0]
++            [ 0 -3  1]
++            [ 0 -1  0]
+             sage: O.W()
+             Free module of degree 3 and rank 2 over Integer Ring
+             Echelon basis matrix:
+@@ -1699,7 +1699,7 @@ class FGP_Module_class(Module):
+             sage: V = span([[1/2,1,1],[3/2,2,1],[0,0,1]],ZZ); W = V.span([2*V.0+4*V.1, 9*V.0+12*V.1, 4*V.2])
+             sage: Q = V/W
+             sage: Q.random_element()
+-            (1, 10)
++            (1, 11)
+         """
+         return self(self._V.random_element(*args, **kwds))
+ 
+diff --git a/src/sage/modules/fg_pid/fgp_morphism.py b/src/sage/modules/fg_pid/fgp_morphism.py
+index 1944b3777b..91dbc39589 100644
+--- a/src/sage/modules/fg_pid/fgp_morphism.py
++++ b/src/sage/modules/fg_pid/fgp_morphism.py
+@@ -259,20 +259,20 @@ class FGP_Morphism(Morphism):
+             sage: O.V()
+             Free module of degree 3 and rank 2 over Integer Ring
+             User basis matrix:
+-            [0 0 1]
+-            [0 2 0]
++            [ 0 -6  1]
++            [ 0 -2  0]
+             sage: phi = Q.hom([Q.0, 4*Q.1])
+             sage: x = Q(V.0); x
+-            (0, 4)
+-            sage: x == 4*Q.1
++            (0, 8)
++            sage: x == 8*Q.1
+             True
+             sage: x in O.V()
+             False
+             sage: phi(x)
+-            (0, 4)
++            (0, 8)
+             sage: phi(4*Q.1)
+             (0, 4)
+-            sage: phi(4*Q.1) == phi(x)
++            sage: phi(8*Q.1) == phi(x)
+             True
+         """
+         from .fgp_module import is_FGP_Module
+diff --git a/src/sage/modules/torsion_quadratic_module.py b/src/sage/modules/torsion_quadratic_module.py
+index 39e7065ac4..6086d1180d 100644
+--- a/src/sage/modules/torsion_quadratic_module.py
++++ b/src/sage/modules/torsion_quadratic_module.py
+@@ -1230,24 +1230,24 @@ class TorsionQuadraticModule(FGP_Module_class, CachedRepresentation):
+             sage: q.twist(-1)
+             Finite quadratic module over Integer Ring with invariants (3, 9)
+             Gram matrix of the quadratic form with values in Q/Z:
+-            [2/3   0]
+-            [  0 8/9]
++            [2/3 1/3]
++            [1/3 8/9]
+ 
+         This form is defined modulo `3`::
+ 
+             sage: q.twist(3)
+             Finite quadratic module over Integer Ring with invariants (3, 9)
+             Gram matrix of the quadratic form with values in Q/3Z:
+-            [  1   0]
+-            [  0 1/3]
++            [  1   2]
++            [  2 1/3]
+ 
+         The next form is defined modulo `4`::
+ 
+             sage: q.twist(4)
+             Finite quadratic module over Integer Ring with invariants (3, 9)
+             Gram matrix of the quadratic form with values in Q/4Z:
+-            [4/3   0]
+-            [  0 4/9]
++            [4/3 8/3]
++            [8/3 4/9]
+         """
+         s = self.base_ring().fraction_field()(s)
+         n = self.V().degree()
+diff --git a/src/sage/quadratic_forms/genera/genus.py b/src/sage/quadratic_forms/genera/genus.py
+index 52435da65e..9037a85bc5 100644
+--- a/src/sage/quadratic_forms/genera/genus.py
++++ b/src/sage/quadratic_forms/genera/genus.py
+@@ -2661,18 +2661,18 @@ class GenusSymbol_global_ring(object):
+             sage: GS.discriminant_form()
+             Finite quadratic module over Integer Ring with invariants (2, 2, 4, 24)
+             Gram matrix of the quadratic form with values in Q/2Z:
+-            [ 1/2    0    0    0]
+-            [   0  3/2    0    0]
+-            [   0    0  7/4    0]
+-            [   0    0    0 7/24]
++            [  1/2     0     0     0]
++            [    0   1/2   1/2     0]
++            [    0   1/2   7/4     0]
++            [    0     0     0 31/24]
+             sage: A = matrix.diagonal(ZZ, [1,-4,6,8])
+             sage: GS = Genus(A)
+             sage: GS.discriminant_form()
+             Finite quadratic module over Integer Ring with invariants (2, 4, 24)
+             Gram matrix of the quadratic form with values in Q/Z:
+-            [ 1/2    0    0]
+-            [   0  3/4    0]
+-            [   0    0 7/24]
++            [  1/2   1/2     0]
++            [  1/2   3/4     0]
++            [    0     0 19/24]
+         """
+         from sage.modules.torsion_quadratic_module import TorsionQuadraticForm
+         qL = []
+diff --git a/src/sage/rings/finite_rings/finite_field_constructor.py b/src/sage/rings/finite_rings/finite_field_constructor.py
+index 80cf269cc0..9cb22461a0 100644
+--- a/src/sage/rings/finite_rings/finite_field_constructor.py
++++ b/src/sage/rings/finite_rings/finite_field_constructor.py
+@@ -285,11 +285,6 @@ class FiniteFieldFactory(UniqueFactory):
+     (a generator of the multiplicative group), use
+     ``modulus="primitive"`` if you need this::
+ 
+-        sage: K.<a> = GF(5^40)
+-        sage: a.multiplicative_order()
+-        189478062869360049565633138
+-        sage: a.is_square()
+-        True
+         sage: K.<b> = GF(5^40, modulus="primitive")
+         sage: b.multiplicative_order()
+         9094947017729282379150390624
+diff --git a/src/sage/rings/finite_rings/integer_mod_ring.py b/src/sage/rings/finite_rings/integer_mod_ring.py
+index d5072839b2..315aa4f9be 100644
+--- a/src/sage/rings/finite_rings/integer_mod_ring.py
++++ b/src/sage/rings/finite_rings/integer_mod_ring.py
+@@ -627,7 +627,7 @@ class IntegerModRing_generic(quotient_ring.QuotientRing_generic):
+             sage: Integers(5).multiplicative_subgroups()
+             ((2,), (4,), ())
+             sage: Integers(15).multiplicative_subgroups()
+-            ((11, 7), (4, 11), (8,), (11,), (14,), (7,), (4,), ())
++            ((14, 13), (4, 11), (8,), (11,), (14,), (7,), (4,), ())
+             sage: Integers(2).multiplicative_subgroups()
+             ((),)
+             sage: len(Integers(341).multiplicative_subgroups())
+diff --git a/src/sage/rings/finite_rings/residue_field.pyx b/src/sage/rings/finite_rings/residue_field.pyx
+index cd4c2212c3..007a68e4c0 100644
+--- a/src/sage/rings/finite_rings/residue_field.pyx
++++ b/src/sage/rings/finite_rings/residue_field.pyx
+@@ -1055,7 +1055,7 @@ cdef class ReductionMap(Map):
+             sage: f = k.convert_map_from(K)
+             sage: s = f.section(); s
+             Lifting map:
+-              From: Residue field in abar of Fractional ideal (14*a^4 - 24*a^3 - 26*a^2 + 58*a - 15)
++              From: Residue field in abar of Fractional ideal (-14*a^4 + 24*a^3 + 26*a^2 - 58*a + 15)
+               To:   Number Field in a with defining polynomial x^5 - 5*x + 2
+             sage: s(k.gen())
+             a
+@@ -1268,7 +1268,7 @@ cdef class ResidueFieldHomomorphism_global(RingHomomorphism):
+             sage: f = k.coerce_map_from(K.ring_of_integers())
+             sage: s = f.section(); s
+             Lifting map:
+-              From: Residue field in abar of Fractional ideal (14*a^4 - 24*a^3 - 26*a^2 + 58*a - 15)
++              From: Residue field in abar of Fractional ideal (-14*a^4 + 24*a^3 + 26*a^2 - 58*a + 15)
+               To:   Maximal Order in Number Field in a with defining polynomial x^5 - 5*x + 2
+             sage: s(k.gen())
+             a
+@@ -1371,10 +1371,10 @@ cdef class LiftingMap(Section):
+             sage: F = K.factor(7)[0][0].residue_field()
+             sage: L = F.lift_map(); L
+             Lifting map:
+-              From: Residue field in abar of Fractional ideal (-2*a^4 + a^3 - 4*a^2 + 2*a - 1)
++              From: Residue field in abar of Fractional ideal (2*a^4 - a^3 + 4*a^2 - 2*a + 1)
+               To:   Maximal Order in Number Field in a with defining polynomial x^5 + 2
+             sage: L.domain()
+-            Residue field in abar of Fractional ideal (-2*a^4 + a^3 - 4*a^2 + 2*a - 1)
++            Residue field in abar of Fractional ideal (2*a^4 - a^3 + 4*a^2 - 2*a + 1)
+ 
+             sage: K.<a> = CyclotomicField(7)
+             sage: F = K.factor(5)[0][0].residue_field()
+@@ -1498,7 +1498,7 @@ cdef class LiftingMap(Section):
+             sage: F.<tmod> = K.factor(7)[0][0].residue_field()
+             sage: F.lift_map() #indirect doctest
+             Lifting map:
+-              From: Residue field in tmod of Fractional ideal (-3*theta_12^2 + 1)
++              From: Residue field in tmod of Fractional ideal (theta_12^2 + 2)
+               To:   Maximal Order in Cyclotomic Field of order 12 and degree 4
+         """
+         return "Lifting"
+@@ -1515,7 +1515,7 @@ class ResidueFiniteField_prime_modn(ResidueField_generic, FiniteField_prime_modn
+         sage: P = K.ideal(29).factor()[1][0]
+         sage: k = ResidueField(P)
+         sage: k
+-        Residue field of Fractional ideal (a^2 + 2*a + 2)
++        Residue field of Fractional ideal (-a^2 - 2*a - 2)
+         sage: k.order()
+         29
+         sage: OK = K.maximal_order()
+@@ -1597,7 +1597,7 @@ class ResidueFiniteField_prime_modn(ResidueField_generic, FiniteField_prime_modn
+             sage: P = K.ideal(29).factor()[1][0]
+             sage: k = ResidueField(P)
+             sage: k
+-            Residue field of Fractional ideal (a^2 + 2*a + 2)
++            Residue field of Fractional ideal (-a^2 - 2*a - 2)
+             sage: OK = K.maximal_order()
+             sage: c = OK(a)
+             sage: b = k(a); b
+diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx
+index 4c835d0697..650669e1e1 100644
+--- a/src/sage/rings/integer.pyx
++++ b/src/sage/rings/integer.pyx
+@@ -5451,7 +5451,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
+             sage: 3._bnfisnorm(QuadraticField(-1, 'i'))
+             (1, 3)
+             sage: 7._bnfisnorm(CyclotomicField(7))
+-            (-zeta7^5 - zeta7^4 - 2*zeta7^3 - zeta7^2 - zeta7 - 1, 1)
++            (zeta7^5 - zeta7^2, 1)
+         """
+         from sage.rings.rational_field import QQ
+         return QQ(self)._bnfisnorm(K, proof=proof, extra_primes=extra_primes)
+diff --git a/src/sage/rings/number_field/S_unit_solver.py b/src/sage/rings/number_field/S_unit_solver.py
+index 270c696e5b..41009a07a9 100644
+--- a/src/sage/rings/number_field/S_unit_solver.py
++++ b/src/sage/rings/number_field/S_unit_solver.py
+@@ -24,10 +24,10 @@ EXAMPLES::
+     sage: from sage.rings.number_field.S_unit_solver import solve_S_unit_equation, eq_up_to_order
+     sage: K.<xi> = NumberField(x^2+x+1)
+     sage: S = K.primes_above(3)
+-    sage: expected = [((2, 1), (4, 0), xi + 2, -xi - 1),
+-    ....:             ((5, -1), (4, -1), 1/3*xi + 2/3, -1/3*xi + 1/3),
+-    ....:             ((5, 0), (1, 0), -xi, xi + 1),
+-    ....:             ((1, 1), (2, 0), -xi + 1, xi)]
++    sage: expected = [((0, 1), (4, 0), xi + 2, -xi - 1),
++    ....:             ((1, -1), (0, -1), 1/3*xi + 2/3, -1/3*xi + 1/3),
++    ....:             ((1, 0), (5, 0), xi + 1, -xi),
++    ....:             ((2, 0), (5, 1), xi, -xi + 1)]
+     sage: sols = solve_S_unit_equation(K, S, 200)
+     sage: eq_up_to_order(sols, expected)
+     True
+@@ -1781,20 +1781,20 @@ def sieve_ordering(SUK, q):
+         sage: SUK = K.S_unit_group(S=3)
+         sage: sieve_data = list(sieve_ordering(SUK, 19))
+         sage: sieve_data[0]
+-        (Fractional ideal (-2*xi^2 + 3),
+-        Fractional ideal (xi - 3),
+-        Fractional ideal (2*xi + 1))
++        (Fractional ideal (xi - 3),
++         Fractional ideal (-2*xi^2 + 3),
++         Fractional ideal (2*xi + 1))
+ 
+         sage: sieve_data[1]
+-        (Residue field of Fractional ideal (-2*xi^2 + 3),
+-        Residue field of Fractional ideal (xi - 3),
+-        Residue field of Fractional ideal (2*xi + 1))
++        (Residue field of Fractional ideal (xi - 3),
++         Residue field of Fractional ideal (-2*xi^2 + 3),
++         Residue field of Fractional ideal (2*xi + 1))
+ 
+         sage: sieve_data[2]
+-        ([18, 9, 16, 8], [18, 7, 10, 4], [18, 3, 12, 10])
++        ([18, 7, 16, 4], [18, 9, 12, 8], [18, 3, 10, 10])
+ 
+         sage: sieve_data[3]
+-        (972, 972, 3888)
++        (486, 648, 11664)
+     """
+ 
+     K = SUK.number_field()
+@@ -2655,10 +2655,10 @@ def sieve_below_bound(K, S, bound=10, bump=10, split_primes_list=[], verbose=Fal
+         sage: S = SUK.primes()
+         sage: sols = sieve_below_bound(K, S, 10)
+         sage: expected = [
+-        ....: ((5, -1), (4, -1), 1/3*xi + 2/3, -1/3*xi + 1/3),
+-        ....: ((2, 1), (4, 0), xi + 2, -xi - 1),
+-        ....: ((2, 0), (1, 1), xi, -xi + 1),
+-        ....: ((5, 0), (1, 0), -xi, xi + 1)]
++        ....: ((1, -1), (0, -1), 1/3*xi + 2/3, -1/3*xi + 1/3),
++        ....: ((0, 1), (4, 0), xi + 2, -xi - 1),
++        ....: ((2, 0), (5, 1), xi, -xi + 1),
++        ....: ((1, 0), (5, 0), xi + 1, -xi)]
+         sage: eq_up_to_order(sols, expected)
+         True
+     """
+@@ -2716,10 +2716,10 @@ def solve_S_unit_equation(K, S, prec=106, include_exponents=True, include_bound=
+         sage: S = K.primes_above(3)
+         sage: sols = solve_S_unit_equation(K, S, 200)
+         sage: expected = [
+-        ....: ((2, 1), (4, 0), xi + 2, -xi - 1),
+-        ....: ((5, -1), (4, -1), 1/3*xi + 2/3, -1/3*xi + 1/3),
+-        ....: ((5, 0), (1, 0), -xi, xi + 1),
+-        ....: ((1, 1), (2, 0), -xi + 1, xi)]
++        ....: ((0, 1), (4, 0), xi + 2, -xi - 1),
++        ....: ((1, -1), (0, -1), 1/3*xi + 2/3, -1/3*xi + 1/3),
++        ....: ((1, 0), (5, 0), xi + 1, -xi),
++        ....: ((2, 0), (5, 1), xi, -xi + 1)]
+         sage: eq_up_to_order(sols, expected)
+         True
+ 
+@@ -2727,7 +2727,7 @@ def solve_S_unit_equation(K, S, prec=106, include_exponents=True, include_bound=
+ 
+         sage: solutions, bound = solve_S_unit_equation(K, S, 100, include_bound=True)
+         sage: bound
+-        6
++        7
+ 
+     You can omit the exponent vectors::
+ 
+diff --git a/src/sage/rings/number_field/class_group.py b/src/sage/rings/number_field/class_group.py
+index 46d0ca8c9d..1ad6d583a8 100644
+--- a/src/sage/rings/number_field/class_group.py
++++ b/src/sage/rings/number_field/class_group.py
+@@ -157,7 +157,7 @@ class FractionalIdealClass(AbelianGroupWithValuesElement):
+             sage: C=K.class_group()
+             sage: c = C(2, a)
+             sage: c^2
+-            Fractional ideal class (2, a^2 + 2*a - 1)
++            Fractional ideal class (4, a)
+             sage: c^3
+             Trivial principal fractional ideal class
+             sage: c^1000
+@@ -467,7 +467,7 @@ class ClassGroup(AbelianGroupWithValues_class):
+             sage: CK = K.class_group()
+             sage: CL = L.class_group()
+             sage: [CL(I).exponents() for I in CK]
+-            [(0,), (4,), (2,)]
++            [(0,), (2,), (4,)]
+         """
+         if isinstance(args[0], FractionalIdealClass):
+             return self.element_class(self, None, self._number_field.ideal(args[0].ideal()))
+diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
+index 9bb756cc82..0b7cc29d83 100644
+--- a/src/sage/rings/number_field/number_field.py
++++ b/src/sage/rings/number_field/number_field.py
+@@ -3422,7 +3422,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: L.<b> = K.extension(x^2 - 3, x^2 + 1)
+             sage: M.<c> = L.extension(x^2 + 1)
+             sage: L.ideal(K.ideal(2, a))
+-            Fractional ideal (a)
++            Fractional ideal (-a)
+             sage: M.ideal(K.ideal(2, a)) == M.ideal(a*(b - c)/2)
+             True
+ 
+@@ -4590,7 +4576,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+              1/13*a^2 + 7/13*a - 332/13,
+              -1/13*a^2 + 6/13*a + 345/13,
+              -1,
+-             2/13*a^2 + 1/13*a - 755/13]
++             -2/13*a^2 - 1/13*a + 755/13]
+             sage: units[5] in (1/13*a^2 - 19/13*a - 7/13, 1/13*a^2 + 20/13*a - 7/13)
+             True
+             sage: len(units) == 6
+@@ -4632,8 +4618,8 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: K.<a> = QuadraticField(-105)
+             sage: K._S_class_group_quotient_matrix((K.ideal(11, a + 4),))
+             [0 0]
+-            [1 0]
+             [0 1]
++            [1 0]
+         """
+         from sage.matrix.constructor import matrix
+         S_clgp_gens = self._S_class_group_and_units(S)[1]
+@@ -4754,7 +4740,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+              1/13*a^2 + 7/13*a - 332/13,
+              -1/13*a^2 + 6/13*a + 345/13,
+              -1,
+-             2/13*a^2 + 1/13*a - 755/13]
++             -2/13*a^2 - 1/13*a + 755/13]
+             sage: gens[5] in (1/13*a^2 - 19/13*a - 7/13, 1/13*a^2 + 20/13*a - 7/13)
+             True
+             sage: gens[6] in (-1/13*a^2 + 45/13*a - 97/13, 1/13*a^2 - 45/13*a + 97/13)
+@@ -5930,28 +5930,37 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+         try:
+             return self._integral_basis_dict[v]
+         except (AttributeError, KeyError):
+-            f = self.pari_polynomial("y")
+-            if v:
+-                B = f.nfbasis(fa=v)
+-            elif self._assume_disc_small:
+-                B = f.nfbasis(1)
+-            elif not important:
+-                # Trial divide the discriminant with primes up to 10^6
+-                m = self.pari_polynomial().poldisc().abs().factor(limit=10**6)
+-                # Since we only need a *squarefree* factorization for
+-                # primes with exponent 1, we need trial division up to D^(1/3)
+-                # instead of D^(1/2).
+-                trialdivlimit2 = pari(10**12)
+-                trialdivlimit3 = pari(10**18)
+-                if all(p < trialdivlimit2 or (e == 1 and p < trialdivlimit3) or p.isprime() for p, e in zip(m[0], m[1])):
+-                    B = f.nfbasis(fa = m)
+-                else:
+-                    raise RuntimeError("Unable to factor discriminant with trial division")
++            pass
++
++        f = self.pari_polynomial("y")
++        if v:
++            # NOTE: here we make pari know about potentially big primes factors of
++            # the discriminant, see
++            # https://pari.math.u-bordeaux.fr/cgi-bin/bugreport.cgi?bug=2257
++            primelimit = pari.default("primelimit")
++            primes = [p for p in v if p > primelimit]
++            if primes:
++                pari.addprimes(primes)
++            B = f.nfbasis(fa=v)
++        elif self._assume_disc_small:
++            B = f.nfbasis(1)
++        elif not important:
++            # Trial divide the discriminant with primes up to 10^6
++            m = self.pari_polynomial().poldisc().abs().factor(limit=10**6)
++            # Since we only need a *squarefree* factorization for
++            # primes with exponent 1, we need trial division up to D^(1/3)
++            # instead of D^(1/2).
++            trialdivlimit2 = pari(10**12)
++            trialdivlimit3 = pari(10**18)
++            if all(p < trialdivlimit2 or (e == 1 and p < trialdivlimit3) or p.isprime() for p, e in zip(m[0], m[1])):
++                B = f.nfbasis(fa = m)
+             else:
+-                B = f.nfbasis()
++                raise RuntimeError("Unable to factor discriminant with trial division")
++        else:
++            B = f.nfbasis()
+ 
+-            self._integral_basis_dict[v] = B
+-            return B
++        self._integral_basis_dict[v] = B
++        return B
+ 
+     def reduced_basis(self, prec=None):
+         r"""
+@@ -6637,7 +6646,8 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+         """
+         Return generators for the unit group modulo torsion.
+ 
+-        ALGORITHM: Uses PARI's :pari:`bnfunit` command.
++        ALGORITHM: Uses PARI's :pari:`bnfinit` command (that computes fundamental units
++        among other things).
+ 
+         INPUT:
+ 
+@@ -6659,7 +6645,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: A = x^4 - 10*x^3 + 20*5*x^2 - 15*5^2*x + 11*5^3
+             sage: K = NumberField(A, 'a')
+             sage: K.units()
+-            (8/275*a^3 - 12/55*a^2 + 15/11*a - 3,)
++            (-1/275*a^3 - 4/55*a^2 + 5/11*a - 3,)
+ 
+         For big number fields, provably computing the unit group can
+         take a very long time.  In this case, one can ask for the
+@@ -6670,14 +6656,14 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: K.units(proof=True)  # takes forever, not tested
+             ...
+             sage: K.units(proof=False)  # result not independently verified
+-            (a^9 + a - 1,
+-             a^15 - a^12 + a^10 - a^9 - 2*a^8 + 3*a^7 + a^6 - 3*a^5 + a^4 + 4*a^3 - 3*a^2 - 2*a + 2,
+-             a^16 - a^15 + a^14 - a^12 + a^11 - a^10 - a^8 + a^7 - 2*a^6 + a^4 - 3*a^3 + 2*a^2 - 2*a + 1,
++            (-a^9 - a + 1,
++             -a^16 + a^15 - a^14 + a^12 - a^11 + a^10 + a^8 - a^7 + 2*a^6 - a^4 + 3*a^3 - 2*a^2 + 2*a - 1,
+              2*a^16 - a^14 - a^13 + 3*a^12 - 2*a^10 + a^9 + 3*a^8 - 3*a^6 + 3*a^5 + 3*a^4 - 2*a^3 - 2*a^2 + 3*a + 4,
+-             2*a^16 - 3*a^15 + 3*a^14 - 3*a^13 + 3*a^12 - a^11 + a^9 - 3*a^8 + 4*a^7 - 5*a^6 + 6*a^5 - 4*a^4 + 3*a^3 - 2*a^2 - 2*a + 4,
+-             a^16 - a^15 - 3*a^14 - 4*a^13 - 4*a^12 - 3*a^11 - a^10 + 2*a^9 + 4*a^8 + 5*a^7 + 4*a^6 + 2*a^5 - 2*a^4 - 6*a^3 - 9*a^2 - 9*a - 7,
+              a^15 + a^14 + 2*a^11 + a^10 - a^9 + a^8 + 2*a^7 - a^5 + 2*a^3 - a^2 - 3*a + 1,
+-             5*a^16 - 6*a^14 + a^13 + 7*a^12 - 2*a^11 - 7*a^10 + 4*a^9 + 7*a^8 - 6*a^7 - 7*a^6 + 8*a^5 + 6*a^4 - 11*a^3 - 5*a^2 + 13*a + 4)
++             -a^16 - a^15 - a^14 - a^13 - a^12 - a^11 - a^10 - a^9 - a^8 - a^7 - a^6 - a^5 - a^4 - a^3 - a^2 + 2,
++             -2*a^16 + 3*a^15 - 3*a^14 + 3*a^13 - 3*a^12 + a^11 - a^9 + 3*a^8 - 4*a^7 + 5*a^6 - 6*a^5 + 4*a^4 - 3*a^3 + 2*a^2 + 2*a - 4,
++             a^15 - a^12 + a^10 - a^9 - 2*a^8 + 3*a^7 + a^6 - 3*a^5 + a^4 + 4*a^3 - 3*a^2 - 2*a + 2,
++             -a^14 - a^13 + a^12 + 2*a^10 + a^8 - 2*a^7 - 2*a^6 + 2*a^3 - a^2 + 2*a - 2)
+ 
+         TESTS:
+ 
+@@ -6686,7 +6672,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+ 
+             sage: K.<a> = NumberField(1/2*x^2 - 1/6)
+             sage: K.units()
+-            (3*a - 2,)
++            (-3*a + 2,)
+         """
+         proof = proof_flag(proof)
+ 
+@@ -6704,7 +6714,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+                 pass
+ 
+         # get PARI to compute the units
+-        B = self.pari_bnf(proof).bnfunit()
++        B = self.pari_bnf(proof).bnf_get_fu()
+         B = tuple(self(b, check=False) for b in B)
+         if proof:
+             # cache the provable results and return them
+@@ -6719,7 +6729,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+         """
+         Return the unit group (including torsion) of this number field.
+ 
+-        ALGORITHM: Uses PARI's :pari:`bnfunit` command.
++        ALGORITHM: Uses PARI's :pari:`bnfinit` and :pari:`bnfunits`.
+ 
+         INPUT:
+ 
+@@ -6765,7 +6751,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: U.gens()
+             (u0, u1, u2, u3, u4, u5, u6, u7, u8)
+             sage: U.gens_values()  # result not independently verified
+-            [-1, a^9 + a - 1, a^15 - a^12 + a^10 - a^9 - 2*a^8 + 3*a^7 + a^6 - 3*a^5 + a^4 + 4*a^3 - 3*a^2 - 2*a + 2, a^16 - a^15 + a^14 - a^12 + a^11 - a^10 - a^8 + a^7 - 2*a^6 + a^4 - 3*a^3 + 2*a^2 - 2*a + 1, 2*a^16 - a^14 - a^13 + 3*a^12 - 2*a^10 + a^9 + 3*a^8 - 3*a^6 + 3*a^5 + 3*a^4 - 2*a^3 - 2*a^2 + 3*a + 4, 2*a^16 - 3*a^15 + 3*a^14 - 3*a^13 + 3*a^12 - a^11 + a^9 - 3*a^8 + 4*a^7 - 5*a^6 + 6*a^5 - 4*a^4 + 3*a^3 - 2*a^2 - 2*a + 4, a^16 - a^15 - 3*a^14 - 4*a^13 - 4*a^12 - 3*a^11 - a^10 + 2*a^9 + 4*a^8 + 5*a^7 + 4*a^6 + 2*a^5 - 2*a^4 - 6*a^3 - 9*a^2 - 9*a - 7, a^15 + a^14 + 2*a^11 + a^10 - a^9 + a^8 + 2*a^7 - a^5 + 2*a^3 - a^2 - 3*a + 1, 5*a^16 - 6*a^14 + a^13 + 7*a^12 - 2*a^11 - 7*a^10 + 4*a^9 + 7*a^8 - 6*a^7 - 7*a^6 + 8*a^5 + 6*a^4 - 11*a^3 - 5*a^2 + 13*a + 4]
++            [-1, -a^9 - a + 1, -a^16 + a^15 - a^14 + a^12 - a^11 + a^10 + a^8 - a^7 + 2*a^6 - a^4 + 3*a^3 - 2*a^2 + 2*a - 1, 2*a^16 - a^14 - a^13 + 3*a^12 - 2*a^10 + a^9 + 3*a^8 - 3*a^6 + 3*a^5 + 3*a^4 - 2*a^3 - 2*a^2 + 3*a + 4, a^15 + a^14 + 2*a^11 + a^10 - a^9 + a^8 + 2*a^7 - a^5 + 2*a^3 - a^2 - 3*a + 1, -a^16 - a^15 - a^14 - a^13 - a^12 - a^11 - a^10 - a^9 - a^8 - a^7 - a^6 - a^5 - a^4 - a^3 - a^2 + 2, -2*a^16 + 3*a^15 - 3*a^14 + 3*a^13 - 3*a^12 + a^11 - a^9 + 3*a^8 - 4*a^7 + 5*a^6 - 6*a^5 + 4*a^4 - 3*a^3 + 2*a^2 + 2*a - 4, a^15 - a^12 + a^10 - a^9 - 2*a^8 + 3*a^7 + a^6 - 3*a^5 + a^4 + 4*a^3 - 3*a^2 - 2*a + 2, -a^14 - a^13 + a^12 + 2*a^10 + a^8 - 2*a^7 - 2*a^6 + 2*a^3 - a^2 + 2*a - 2]
+         """
+         proof = proof_flag(proof)
+ 
+@@ -6953,7 +6939,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+ 
+             sage: solutions, bound = K.S_unit_solutions(S, prec=100, include_bound=True)
+             sage: bound
+-            6
++            7
+         """
+         from .S_unit_solver import solve_S_unit_equation
+         return solve_S_unit_equation(self, S, prec, include_exponents, include_bound, proof)
+@@ -10792,9 +10802,9 @@ class NumberField_cyclotomic(NumberField_absolute):
+         EXAMPLES::
+ 
+             sage: k5.<z> = CyclotomicField(5)
+-            sage: gap('E(5)^7 + 3')
++            sage: w = libgap.eval('E(5)^7 + 3')
++            sage: w
+             -3*E(5)-2*E(5)^2-3*E(5)^3-3*E(5)^4
+-            sage: w = gap('E(5)^7 + 3')
+             sage: z^7 + 3
+             z^2 + 3
+             sage: k5(w) # indirect doctest
+@@ -10805,7 +10815,7 @@ class NumberField_cyclotomic(NumberField_absolute):
+ 
+             sage: F = CyclotomicField(8)
+             sage: z = F.gen()
+-            sage: a = gap(z+1/z); a
++            sage: a = libgap(z+1/z); a
+             E(8)-E(8)^3
+             sage: F(a)
+             -zeta8^3 + zeta8
+@@ -10819,6 +10829,7 @@ class NumberField_cyclotomic(NumberField_absolute):
+ 
+         It also works with the old pexpect interface to GAP::
+ 
++            sage: a = gap(z + 1/z)
+             sage: b = gap(Matrix(F,[[z^2,1],[0,a+1]])); b
+             [ [ E(4), 1 ], [ 0, 1+E(8)-E(8)^3 ] ]
+             sage: b[1,2]
+diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx
+index 811edde5f0..80ac1604da 100644
+--- a/src/sage/rings/number_field/number_field_element.pyx
++++ b/src/sage/rings/number_field/number_field_element.pyx
+@@ -1629,7 +1629,7 @@ cdef class NumberFieldElement(FieldElement):
+             sage: Q.<X> = K[]
+             sage: L.<b> = NumberField(X^4 + a)
+             sage: t = (-a).is_norm(L, element=True); t
+-            (True, b^3 + 1)
++            (True, -b^3 - 1)
+             sage: t[1].norm(K)
+             -a
+ 
+@@ -1744,11 +1744,11 @@ cdef class NumberFieldElement(FieldElement):
+             sage: Q.<X> = K[]
+             sage: L.<b> = NumberField(X^4 + a)
+             sage: t = (-a)._rnfisnorm(L); t
+-            (b^3 + 1, 1)
++            (-b^3 - 1, 1)
+             sage: t[0].norm(K)
+             -a
+             sage: t = K(3)._rnfisnorm(L); t
+-            (-b^3 - a*b^2 - a^2*b + 1, 3*a^2 - 3*a + 6)
++            (b^3 + a*b^2 + a^2*b - 1, 3*a^2 - 3*a + 6)
+             sage: t[0].norm(K)*t[1]
+             3
+ 
+@@ -1801,7 +1801,7 @@ cdef class NumberFieldElement(FieldElement):
+             raise ValueError("L (=%s) must be a relative number field with base field K (=%s) in rnfisnorm" % (L, K))
+ 
+         rnf_data = K.pari_rnfnorm_data(L, proof=proof)
+-        x, q = self.__pari__().rnfisnorm(rnf_data)
++        x, q = pari.rnfisnorm(rnf_data, self)
+         return L(x, check=False), K(q, check=False)
+ 
+     def _mpfr_(self, R):
+diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
+index 3621d41e11..a5c3f16fff 100644
+--- a/src/sage/rings/number_field/number_field_ideal.py
++++ b/src/sage/rings/number_field/number_field_ideal.py
+@@ -232,7 +232,7 @@ class NumberFieldIdeal(Ideal_generic):
+             sage: K.<a> = NumberField(x^2 + 3); K
+             Number Field in a with defining polynomial x^2 + 3
+             sage: f = K.factor(15); f
+-            (Fractional ideal (-a))^2 * (Fractional ideal (5))
++            (Fractional ideal (1/2*a + 3/2))^2 * (Fractional ideal (5))
+             sage: (f[0][0] < f[1][0])
+             True
+             sage: (f[0][0] == f[0][0])
+@@ -621,7 +621,7 @@ class NumberFieldIdeal(Ideal_generic):
+ 
+             sage: K.<z> = CyclotomicField(7)
+             sage: I = K.factor(11)[0][0]; I
+-            Fractional ideal (-2*z^4 - 2*z^2 - 2*z + 1)
++            Fractional ideal (-3*z^4 - 2*z^3 - 2*z^2 - 2)
+             sage: A = I.free_module()
+             sage: A              # warning -- choice of basis can be somewhat random
+             Free module of degree 6 and rank 6 over Integer Ring
+@@ -3119,7 +3119,7 @@ class NumberFieldFractionalIdeal(MultiplicativeGroupElement, NumberFieldIdeal):
+             sage: K.<a> = NumberField(x^5 + 2); K
+             Number Field in a with defining polynomial x^5 + 2
+             sage: f = K.factor(19); f
+-            (Fractional ideal (a^2 + a - 3)) * (Fractional ideal (-2*a^4 - a^2 + 2*a - 1)) * (Fractional ideal (a^2 + a - 1))
++            (Fractional ideal (a^2 + a - 3)) * (Fractional ideal (2*a^4 + a^2 - 2*a + 1)) * (Fractional ideal (a^2 + a - 1))
+             sage: [i.residue_class_degree() for i, _ in f]
+             [2, 2, 1]
+         """
+diff --git a/src/sage/rings/number_field/number_field_ideal_rel.py b/src/sage/rings/number_field/number_field_ideal_rel.py
+index 4671b71fd2..4cf6b4c658 100644
+--- a/src/sage/rings/number_field/number_field_ideal_rel.py
++++ b/src/sage/rings/number_field/number_field_ideal_rel.py
+@@ -18,7 +18,7 @@ EXAMPLES::
+     sage: G = [from_A(z) for z in I.gens()]; G
+     [7, -2*b*a - 1]
+     sage: K.fractional_ideal(G)
+-    Fractional ideal (2*b*a + 1)
++    Fractional ideal ((1/2*b + 2)*a - 1/2*b + 2)
+     sage: K.fractional_ideal(G).absolute_norm().factor()
+     7^2
+ """
+diff --git a/src/sage/rings/number_field/number_field_rel.py b/src/sage/rings/number_field/number_field_rel.py
+index c8760280d1..6b72eff4a0 100644
+--- a/src/sage/rings/number_field/number_field_rel.py
++++ b/src/sage/rings/number_field/number_field_rel.py
+@@ -397,18 +397,18 @@ class NumberField_relative(NumberField_generic):
+             sage: K.<c> = F.extension(Y^2 - (1 + a)*(a + b)*a*b)
+             sage: K.subfields(2)
+             [
+-            (Number Field in c0 with defining polynomial x^2 - 24*x + 72, Ring morphism:
+-              From: Number Field in c0 with defining polynomial x^2 - 24*x + 72
++            (Number Field in c0 with defining polynomial x^2 - 24*x + 96, Ring morphism:
++              From: Number Field in c0 with defining polynomial x^2 - 24*x + 96
+               To:   Number Field in c with defining polynomial Y^2 + (-2*b - 3)*a - 2*b - 6 over its base field
+-              Defn: c0 |--> -6*a + 12, None),
++              Defn: c0 |--> -4*b + 12, None),
+             (Number Field in c1 with defining polynomial x^2 - 24*x + 120, Ring morphism:
+               From: Number Field in c1 with defining polynomial x^2 - 24*x + 120
+               To:   Number Field in c with defining polynomial Y^2 + (-2*b - 3)*a - 2*b - 6 over its base field
+               Defn: c1 |--> 2*b*a + 12, None),
+-            (Number Field in c2 with defining polynomial x^2 - 24*x + 96, Ring morphism:
+-              From: Number Field in c2 with defining polynomial x^2 - 24*x + 96
++            (Number Field in c2 with defining polynomial x^2 - 24*x + 72, Ring morphism:
++              From: Number Field in c2 with defining polynomial x^2 - 24*x + 72
+               To:   Number Field in c with defining polynomial Y^2 + (-2*b - 3)*a - 2*b - 6 over its base field
+-              Defn: c2 |--> -4*b + 12, None)
++              Defn: c2 |--> -6*a + 12, None)
+             ]
+             sage: K.subfields(8, 'w')
+             [
+diff --git a/src/sage/rings/number_field/order.py b/src/sage/rings/number_field/order.py
+index 82e2cd2d07..f15fe4ad17 100644
+--- a/src/sage/rings/number_field/order.py
++++ b/src/sage/rings/number_field/order.py
+@@ -2181,7 +2181,7 @@ def EisensteinIntegers(names="omega"):
+         sage: R
+         Eisenstein Integers in Number Field in omega with defining polynomial x^2 + x + 1 with omega = -0.50000000000000000? + 0.866025403784439?*I
+         sage: factor(3 + omega)
+-        (omega) * (-3*omega - 2)
++        (-1) * (-omega - 3)
+         sage: CC(omega)
+         -0.500000000000000 + 0.866025403784439*I
+         sage: omega.minpoly()
+diff --git a/src/sage/rings/number_field/unit_group.py b/src/sage/rings/number_field/unit_group.py
+index 5c94f7407d..47a2755e36 100644
+--- a/src/sage/rings/number_field/unit_group.py
++++ b/src/sage/rings/number_field/unit_group.py
+@@ -15,12 +15,12 @@ The first generator is a primitive root of unity in the field::
+     sage: UK.gens_values()  # random
+     [-1/12*a^3 + 1/6*a, 1/24*a^3 + 1/4*a^2 - 1/12*a - 1]
+     sage: UK.gen(0).value()
+-    -1/12*a^3 + 1/6*a
++    1/12*a^3 - 1/6*a
+ 
+     sage: UK.gen(0)
+     u0
+     sage: UK.gen(0) + K.one()   # coerce abstract generator into number field
+-    -1/12*a^3 + 1/6*a + 1
++    1/12*a^3 - 1/6*a + 1
+ 
+     sage: [u.multiplicative_order() for u in UK.gens()]
+     [4, +Infinity]
+@@ -37,18 +37,18 @@ as elements of an abstract multiplicative group::
+     sage: UK(-1)
+     u0^2
+     sage: [UK(u) for u in (x^4-1).roots(K, multiplicities=False)]
+-    [1, u0^2, u0^3, u0]
++    [1, u0^2, u0, u0^3]
+ 
+     sage: UK.fundamental_units() # random
+     [1/24*a^3 + 1/4*a^2 - 1/12*a - 1]
+     sage: torsion_gen = UK.torsion_generator();  torsion_gen
+     u0
+     sage: torsion_gen.value()
+-    -1/12*a^3 + 1/6*a
++    1/12*a^3 - 1/6*a
+     sage: UK.zeta_order()
+     4
+     sage: UK.roots_of_unity()
+-    [-1/12*a^3 + 1/6*a, -1, 1/12*a^3 - 1/6*a, 1]
++    [1/12*a^3 - 1/6*a, -1, -1/12*a^3 + 1/6*a, 1]
+ 
+ Exp and log functions provide maps between units as field elements and exponent
+ vectors with respect to the generators::
+@@ -82,7 +82,7 @@ S-unit groups may be constructed, where S is a set of primes::
+     sage: SUK.rank()
+     4
+     sage: SUK.gens_values()
+-    [-1, a^2 + 1, a^5 + a^4 - a^2 - a - 1, a + 1, -a + 1]
++    [-1, a^2 + 1, -a^5 - a^4 + a^2 + a + 1, a + 1, a - 1]
+     sage: u = 9*prod(SUK.gens_values()); u
+     -18*a^5 - 18*a^4 - 18*a^3 - 9*a^2 + 9*a + 27
+     sage: SUK.log(u)
+@@ -100,29 +100,29 @@ A relative number field example::
+     sage: UL.zeta_order()
+     24
+     sage: UL.roots_of_unity()
+-    [-b*a - b,
+-     b^2*a,
+-     b^3,
+-     a + 1,
+-     -b*a,
+-     -b^2,
+-     b^3*a + b^3,
+-     a,
+-     b,
++    [-b*a,
+      -b^2*a - b^2,
+-     b^3*a,
+-     -1,
+-     b*a + b,
+-     -b^2*a,
+      -b^3,
+-     -a - 1,
+-     b*a,
+-     b^2,
+-     -b^3*a - b^3,
+      -a,
++     -b*a - b,
++     -b^2,
++     b^3*a,
++     -a - 1,
+      -b,
++     b^2*a,
++     b^3*a + b^3,
++     -1,
++     b*a,
+      b^2*a + b^2,
++     b^3,
++     a,
++     b*a + b,
++     b^2,
+      -b^3*a,
++     a + 1,
++     b,
++     -b^2*a,
++     -b^3*a - b^3,
+      1]
+ 
+ A relative extension example, which worked thanks to the code review by F.W.Clarke::
+@@ -199,7 +199,7 @@ class UnitGroup(AbelianGroupWithValues_class):
+         sage: UK.gen(5)
+         u5
+         sage: UK.gen(5).value()
+-        z^7 + z
++        -z^7 - z
+ 
+     An S-unit group::
+ 
+@@ -216,7 +216,7 @@ class UnitGroup(AbelianGroupWithValues_class):
+         sage: SUK.zeta_order()
+         26
+         sage: SUK.log(21*z)
+-        (12, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1)
++        (25, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1)
+     """
+     # This structure is not a parent in the usual sense. The
+     # "elements" are NumberFieldElement_absolute. Instead, they should
+@@ -250,7 +250,7 @@ class UnitGroup(AbelianGroupWithValues_class):
+             sage: UK.gens()
+             (u0, u1)
+             sage: UK.gens_values()
+-            [-1, 6*a - 37]
++            [-1, -6*a + 37]
+ 
+             sage: K.<a> = QuadraticField(-3)
+             sage: UK = K.unit_group(); UK
+@@ -258,7 +258,7 @@ class UnitGroup(AbelianGroupWithValues_class):
+             sage: UK.gens()
+             (u,)
+             sage: UK.gens_values()
+-            [1/2*a + 1/2]
++            [-1/2*a + 1/2]
+ 
+             sage: K.<z> = CyclotomicField(13)
+             sage: UK = K.unit_group(); UK
+@@ -323,34 +323,31 @@ class UnitGroup(AbelianGroupWithValues_class):
+             self.__S = S
+             self.__pS = pS = [P.pari_prime() for P in S]
+ 
+-        # compute the fundamental units via pari:
+-        fu = [K(u, check=False) for u in pK.bnfunit()]
+-        self.__nfu = len(fu)
+-
+-        # compute the additional S-unit generators:
++        # compute units
++        # NOTE: old pari syntax for S-units (< 2.13.0): pK.bnfsunit(pS)
++        # NOTE: pari >= 2.13.0: the first component of the result of bnfunits
++        # are *all* units starting with S-units, followed by fundamental units
++        # followed by the torsion unit.
+         if S:
+-            self.__S_unit_data = pK.bnfsunit(pS)
+-            su = [K(u, check=False) for u in self.__S_unit_data[0]]
++            self.__S_unit_data = pK.bnfunits(pS)
+         else:
+-            su = []
+-        self.__nsu = len(su)
++            self.__S_unit_data = pK.bnfunits()
++        # TODO: converting the factored matrix representation of bnfunits into polynomial
++        # form is a *big* waste of time
++        su_fu_tu = [pK.nfbasistoalg(pK.nffactorback(z)) for z in self.__S_unit_data[0]]
++
++        self.__nfu = len(pK.bnf_get_fu())           # number of fundamental units
++        self.__nsu = len(su_fu_tu) - self.__nfu - 1 # number of S-units
++        self.__ntu = pK.bnf_get_tu()[0]             # order of torsion
+         self.__rank = self.__nfu + self.__nsu
+ 
+-        # compute a torsion generator and pick the 'simplest' one:
+-        n, z = pK[7][3] # number of roots of unity and bnf.tu as in pari documentation
+-        n = ZZ(n)
+-        self.__ntu = n
+-        z = K(z, check=False)
+-
+-        # If we replaced z by another torsion generator we would need
+-        # to allow for this in the dlog function!  So we do not.
++        # Move the torsion unit first, then fundamental units then S-units
++        gens = [K(u, check=False) for u in su_fu_tu]
++        gens = [gens[-1]] + gens[self.__nsu:-1] + gens[:self.__nsu]
+ 
+-        # Store the actual generators (torsion first):
+-        gens = [z] + fu + su
+-        values = Sequence(gens, immutable=True, universe=self, check=False)
+         # Construct the abtract group:
+-        gens_orders = tuple([ZZ(n)]+[ZZ(0)]*(self.__rank))
+-        AbelianGroupWithValues_class.__init__(self, gens_orders, 'u', values, number_field)
++        gens_orders = tuple([ZZ(self.__ntu)]+[ZZ(0)]*(self.__rank))
++        AbelianGroupWithValues_class.__init__(self, gens_orders, 'u', gens, number_field)
+ 
+     def _element_constructor_(self, u):
+         """
+@@ -375,7 +375,7 @@ class UnitGroup(AbelianGroupWithValues_class):
+             sage: UK.gens()
+             (u0, u1)
+             sage: UK.gens_values()
+-            [-1, 6*a - 37]
++            [-1, -6*a + 37]
+             sage: UK.ngens()
+             2
+             sage: [UK(u) for u in UK.gens()]
+@@ -394,8 +391,8 @@ class UnitGroup(AbelianGroupWithValues_class):
+         except TypeError:
+             raise ValueError("%s is not an element of %s"%(u,K))
+         if self.__S:
+-            m = pK.bnfissunit(self.__S_unit_data, pari(u)).mattranspose()
+-            if m.ncols()==0:
++            m = pK.bnfisunit(pari(u), self.__S_unit_data).mattranspose()
++            if m.ncols() == 0:
+                 raise ValueError("%s is not an S-unit"%u)
+         else:
+             if not u.is_integral() or u.norm().abs() != 1:
+@@ -405,9 +402,8 @@ class UnitGroup(AbelianGroupWithValues_class):
+         # convert column matrix to a list:
+         m = [ZZ(m[0,i].sage()) for i in range(m.ncols())]
+ 
+-        # NB pari puts the torsion after the fundamental units, before
+-        # the extra S-units but we have the torsion first:
+-        m = [m[self.__nfu]] + m[:self.__nfu] + m[self.__nfu+1:]
++        # NOTE: pari ordering for the units is (S-units, fundamental units, torsion unit)
++        m = [m[-1]] + m[self.__nsu:-1] + m[:self.__nsu]
+ 
+         return self.element_class(self, m)
+ 
+@@ -527,9 +527,9 @@ class UnitGroup(AbelianGroupWithValues_class):
+             sage: U.zeta(2, all=True)
+             [-1]
+             sage: U.zeta(3)
+-            1/2*z - 1/2
++            -1/2*z - 1/2
+             sage: U.zeta(3, all=True)
+-            [1/2*z - 1/2, -1/2*z - 1/2]
++            [-1/2*z - 1/2, 1/2*z - 1/2]
+             sage: U.zeta(4)
+             Traceback (most recent call last):
+             ...
+@@ -645,7 +645,7 @@ class UnitGroup(AbelianGroupWithValues_class):
+            sage: SUK = UnitGroup(K,S=2)
+            sage: v = (3,1,4,1,5,9,2)
+            sage: u = SUK.exp(v); u
+-           -8732*z^11 + 15496*z^10 + 51840*z^9 + 68804*z^8 + 51840*z^7 + 15496*z^6 - 8732*z^5 + 34216*z^3 + 64312*z^2 + 64312*z + 34216
++           8732*z^11 - 15496*z^10 - 51840*z^9 - 68804*z^8 - 51840*z^7 - 15496*z^6 + 8732*z^5 - 34216*z^3 - 64312*z^2 - 64312*z - 34216
+            sage: SUK.log(u)
+            (3, 1, 4, 1, 5, 9, 2)
+            sage: SUK.log(u) == v
+@@ -692,7 +692,7 @@ class UnitGroup(AbelianGroupWithValues_class):
+            sage: SUK = UnitGroup(K,S=2)
+            sage: v = (3,1,4,1,5,9,2)
+            sage: u = SUK.exp(v); u
+-           -8732*z^11 + 15496*z^10 + 51840*z^9 + 68804*z^8 + 51840*z^7 + 15496*z^6 - 8732*z^5 + 34216*z^3 + 64312*z^2 + 64312*z + 34216
++           8732*z^11 - 15496*z^10 - 51840*z^9 - 68804*z^8 - 51840*z^7 - 15496*z^6 + 8732*z^5 - 34216*z^3 - 64312*z^2 - 64312*z - 34216
+            sage: SUK.log(u)
+            (3, 1, 4, 1, 5, 9, 2)
+            sage: SUK.log(u) == v
+diff --git a/src/sage/rings/polynomial/multi_polynomial_ring.py b/src/sage/rings/polynomial/multi_polynomial_ring.py
+index 20f1574e90..bf4b831a75 100644
+--- a/src/sage/rings/polynomial/multi_polynomial_ring.py
++++ b/src/sage/rings/polynomial/multi_polynomial_ring.py
+@@ -526,6 +526,8 @@ class MPolynomialRing_polydict( MPolynomialRing_macaulay2_repr, PolynomialRing_s
+             # univariate polynomials.  Below, v is the variable
+             # with highest priority, and the x[i] are expressions
+             # in the remaining variables.
++            if x == 0:
++                return self.zero()
+             v = self.gens_dict_recursive()[str(x.variable())]
+             return sum(self(x[i]) * v ** i for i in range(x.poldegree() + 1))
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx
+index d562a46088..761d22c785 100644
+--- a/src/sage/rings/polynomial/polynomial_element.pyx
++++ b/src/sage/rings/polynomial/polynomial_element.pyx
+@@ -7550,7 +7550,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
+             [(-3.5074662110434039?e451, 1)]
+             sage: p = bigc*x + 1
+             sage: p.roots(ring=RR)
+-            [(0.000000000000000, 1)]
++            [(-2.85106096489671e-452, 1)]
+             sage: p.roots(ring=AA)
+             [(-2.8510609648967059?e-452, 1)]
+             sage: p.roots(ring=QQbar)
+diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
+index 66af8957b9..8d6dfe1e6e 100644
+--- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
++++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
+@@ -1306,7 +1306,16 @@ class PolynomialQuotientRing_generic(CommutativeRing):
+         fixed in :trac:`14489`)::
+ 
+             sage: S.S_class_group([K.ideal(a)])
+-            [((1/4*xbar^2 + 31/4, (-1/8*a + 1/8)*xbar^2 - 31/8*a + 31/8, 1/16*xbar^3 + 1/16*xbar^2 + 31/16*xbar + 31/16, -1/16*a*xbar^3 + (1/16*a + 1/8)*xbar^2 - 31/16*a*xbar + 31/16*a + 31/8), 6), ((-1/4*xbar^2 - 23/4, (1/8*a - 1/8)*xbar^2 + 23/8*a - 23/8, -1/16*xbar^3 - 1/16*xbar^2 - 23/16*xbar - 23/16, 1/16*a*xbar^3 + (-1/16*a - 1/8)*xbar^2 + 23/16*a*xbar - 23/16*a - 23/8), 2)]
++            [((1/4*xbar^2 + 31/4,
++               (-1/8*a + 1/8)*xbar^2 - 31/8*a + 31/8,
++               1/16*xbar^3 + 1/16*xbar^2 + 31/16*xbar + 31/16,
++               -1/16*a*xbar^3 + (1/16*a + 1/8)*xbar^2 - 31/16*a*xbar + 31/16*a + 31/8),
++              6),
++             ((-1/4*xbar^2 - 23/4,
++               1/4*a*xbar^2 + 23/4*a,
++               -1/8*xbar^3 + 1/8*xbar^2 - 23/8*xbar + 23/8,
++               (1/16*a - 1/16)*xbar^3 + (-1/16*a + 1/16)*xbar^2 + (23/16*a - 23/16)*xbar - 23/16*a + 23/16),
++              2)]
+ 
+         Note that all the returned values live where we expect them to::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_finite_field.py b/src/sage/schemes/elliptic_curves/ell_finite_field.py
+index 623b067e27..a4a09b3723 100644
+--- a/src/sage/schemes/elliptic_curves/ell_finite_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_finite_field.py
+@@ -786,11 +786,11 @@ class EllipticCurve_finite_field(EllipticCurve_field, HyperellipticCurve_finite_
+             sage: len(E.gens())
+             2
+             sage: E.cardinality()
+-            867361737988403547207212930746733987710588
++            867361737988403547206134229616487867594472
+             sage: E.gens()[0].order()
+-            433680868994201773603606465373366993855294
++            433680868994201773603067114808243933797236
+             sage: E.gens()[1].order()
+-            433680868994201773603606465373366993855294
++            433680868994201773603067114808243933797236
+         """
+         G = self.__pari__().ellgroup(flag=1)
+         return tuple(self.point(list(pt)) for pt in G[2])
+diff --git a/src/sage/schemes/elliptic_curves/ell_generic.py b/src/sage/schemes/elliptic_curves/ell_generic.py
+index b41ea4f6b6..588988f2c9 100644
+--- a/src/sage/schemes/elliptic_curves/ell_generic.py
++++ b/src/sage/schemes/elliptic_curves/ell_generic.py
+@@ -2935,15 +2935,7 @@ class EllipticCurve_generic(WithEqualityById, plane_curve.ProjectivePlaneCurve):
+             sage: K.<a> = QuadraticField(2)
+             sage: E = EllipticCurve([1,a])
+             sage: E.pari_curve()
+-            [Mod(0, y^2 - 2), Mod(0, y^2 - 2), Mod(0, y^2 - 2), Mod(1, y^2 - 2),
+-            Mod(y, y^2 - 2), Mod(0, y^2 - 2), Mod(2, y^2 - 2), Mod(4*y, y^2 - 2),
+-            Mod(-1, y^2 - 2), Mod(-48, y^2 - 2), Mod(-864*y, y^2 - 2),
+-            Mod(-928, y^2 - 2), Mod(3456/29, y^2 - 2), Vecsmall([5]),
+-            [[y^2 - 2, [2, 0], 8, 1, [[1, -1.41421356237310;
+-            1, 1.41421356237310], [1, -1.41421356237310; 1, 1.41421356237310],
+-            [1, -1; 1, 1], [2, 0; 0, 4], [4, 0; 0, 2], [2, 0; 0, 1],
+-            [2, [0, 2; 1, 0]], []], [-1.41421356237310, 1.41421356237310],
+-            [1, y], [1, 0; 0, 1], [1, 0, 0, 2; 0, 1, 1, 0]]], [0, 0, 0, 0, 0]]
++            [Mod(0, y^2 - 2), Mod(0, y^2 - 2), Mod(0, y^2 - 2), Mod(1, y^2 - 2), Mod(y, y^2 - 2), Mod(0, y^2 - 2), Mod(2, y^2 - 2), Mod(4*y, y^2 - 2), Mod(-1, y^2 - 2), Mod(-48, y^2 - 2), Mod(-864*y, y^2 - 2), Mod(-928, y^2 - 2), Mod(3456/29, y^2 - 2), Vecsmall([5]), [[y^2 - 2, [2, 0], 8, 1, [[1, -1.41421356237310; 1, 1.41421356237310], [1, -1.41421356237310; 1, 1.41421356237310], [16, -23; 16, 23], [2, 0; 0, 4], [4, 0; 0, 2], [2, 0; 0, 1], [2, [0, 2; 1, 0]], [2]], [-1.41421356237310, 1.41421356237310], [1, y], [1, 0; 0, 1], [1, 0, 0, 2; 0, 1, 1, 0]]], [0, 0, 0, 0, 0]]
+ 
+         PARI no longer requires that the `j`-invariant has negative `p`-adic valuation::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_number_field.py b/src/sage/schemes/elliptic_curves/ell_number_field.py
+index e1111c1c55..41a9c67214 100644
+--- a/src/sage/schemes/elliptic_curves/ell_number_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_number_field.py
+@@ -215,9 +215,9 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: E == loads(dumps(E))
+             True
+             sage: E.simon_two_descent()
+-            (2, 2, [(0 : 0 : 1), (1/8*a + 5/8 : -3/16*a - 7/16 : 1)])
++            (2, 2, [(0 : 0 : 1)])
+             sage: E.simon_two_descent(lim1=3, lim3=20, limtriv=5, maxprob=7, limbigprime=10)
+-            (2, 2, [(-1 : 0 : 1), (-1/8*a + 5/8 : -3/16*a - 9/16 : 1)])
++            (2, 2, [(-1 : 0 : 1), (5/32*a + 1/32 : -19/128*a + 41/128 : 1)])
+ 
+         ::
+ 
+@@ -245,22 +245,22 @@ class EllipticCurve_number_field(EllipticCurve_field):
+               C = Mod(y, y^2 + 7)
+             <BLANKLINE>
+               Computing L(S,2)
+-              L(S,2) = [Mod(Mod(-1/2*y + 1/2, y^2 + 7)*x^2 + Mod(-1/2*y - 1/2, y^2 + 7)*x + Mod(-y - 1, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(-x^2 + Mod(-1/2*y - 1/2, y^2 + 7)*x + 1, x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(-1, x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(x^2 + 2, x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(x + Mod(1/2*y + 3/2, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(x + Mod(1/2*y - 3/2, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7))]
++              L(S,2) = [Mod(Mod(1/2*y - 1/2, y^2 + 7)*x^2 + Mod(1/2*y + 1/2, y^2 + 7)*x + Mod(y + 1, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(x^2 + Mod(1/2*y + 1/2, y^2 + 7)*x - 1, x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(-1, x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(x^2 + 2, x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(x + Mod(1/2*y + 3/2, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(x + Mod(1/2*y - 3/2, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7))]
+             <BLANKLINE>
+               Computing the Selmer group
+               #LS2gen = 2
+-               LS2gen = [Mod(Mod(-1/2*y + 1/2, y^2 + 7)*x^2 + Mod(-1/2*y - 1/2, y^2 + 7)*x + Mod(-y - 1, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(x^2 + Mod(1/2*y + 1/2, y^2 + 7)*x - 1, x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7))]
++               LS2gen = [Mod(x^2 + Mod(1/2*y + 1/2, y^2 + 7)*x - 1, x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7)), Mod(Mod(-1/2*y + 1/2, y^2 + 7)*x^2 + Mod(-1/2*y - 1/2, y^2 + 7)*x + Mod(-y - 1, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7))]
+               Search for trivial points on the curve
+              Trivial points on the curve = [[Mod(1/2*y + 3/2, y^2 + 7), Mod(-y - 2, y^2 + 7)], [1, 1, 0], [Mod(1/2*y + 3/2, y^2 + 7), Mod(-y - 2, y^2 + 7), 1]]
++              zc = Mod(Mod(1, y^2 + 7)*x^2 + Mod(1/2*y + 1/2, y^2 + 7)*x + Mod(-1, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7))
++              comes from the trivial point [Mod(1/2*y + 3/2, y^2 + 7), Mod(-y - 2, y^2 + 7)]
+               zc = Mod(Mod(-1/2*y + 1/2, y^2 + 7)*x^2 + Mod(-1/2*y - 1/2, y^2 + 7)*x + Mod(-y - 1, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7))
+-              Hilbert symbol (Mod(1, y^2 + 7),Mod(-2*y + 2, y^2 + 7)) =
++              Hilbert symbol (Mod(1, y^2 + 7),Mod(-2*y + 2, y^2 + 7)) = 
+               sol of quadratic equation = [1, 1, 0]~
+               zc*z1^2 = Mod(4*x + Mod(-2*y + 6, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7))
+               quartic: (-1)*Y^2 = x^4 + (3*y - 9)*x^2 + (-8*y + 16)*x + (9/2*y - 11/2)
+               reduced: Y^2 = -x^4 + (-3*y + 9)*x^2 + (-8*y + 16)*x + (-9/2*y + 11/2)
+               not ELS at [2, [0, 1]~, 1, 1, [1, -2; 1, 0]]
+-              zc = Mod(Mod(1, y^2 + 7)*x^2 + Mod(1/2*y + 1/2, y^2 + 7)*x + Mod(-1, y^2 + 7), x^3 + Mod(1, y^2 + 7)*x + Mod(y, y^2 + 7))
+-              comes from the trivial point [Mod(1/2*y + 3/2, y^2 + 7), Mod(-y - 2, y^2 + 7)]
+               m1 = 1
+               m2 = 1
+             #S(E/K)[2]    = 2
+@@ -299,8 +299,8 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: E.simon_two_descent()  # long time (4s on sage.math, 2013)
+             (3,
+              3,
+-             [(0 : 0 : 1),
+-              (-1/2*zeta43_0^2 - 1/2*zeta43_0 + 7 : -3/2*zeta43_0^2 - 5/2*zeta43_0 + 18 : 1)...)
++             [(5/8*zeta43_0^2 + 17/8*zeta43_0 - 9/4 : -27/16*zeta43_0^2 - 103/16*zeta43_0 + 39/8 : 1),
++              (0 : 0 : 1)])
+         """
+         verbose = int(verbose)
+         if known_points is None:
+diff --git a/src/sage/schemes/elliptic_curves/ell_rational_field.py b/src/sage/schemes/elliptic_curves/ell_rational_field.py
+index 61074f21b9..9a19def280 100644
+--- a/src/sage/schemes/elliptic_curves/ell_rational_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_rational_field.py
+@@ -5403,9 +5403,9 @@ class EllipticCurve_rational_field(EllipticCurve_number_field):
+ 
+             sage: E = EllipticCurve('37a1')
+             sage: E.eval_modular_form([1.5+I,2.0+I,2.5+I],100) # abs tol 1e-20
+-            [-0.0018743978548152085771342944989052703431,
+-             0.0018604485340371083710285594393397945456,
+-            -0.0018743978548152085771342944989052703431]
++            [-0.00187439785481520858 - 6.91083670607514589e-22*I,
++             0.00186044853403710837 + 3.71914507780688601e-22*I,
++             -0.00187439785481520858 - 6.39417173217386647e-23*I]
+ 
+             sage: E.eval_modular_form(2.1+I, 100) # abs tol 1e-20
+             [0.00150864362757267079 + 0.00109100341113449845*I]
+diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
+index 7178da3685..ea0a7e88bc 100644
+--- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
++++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
+@@ -801,8 +801,8 @@ def isogenies_5_0(E, minimal_models=True):
+         sage: K.<a> = NumberField(x**6-320*x**3-320)
+         sage: E = EllipticCurve(K,[0,0,1,0,0])
+         sage: isogenies_5_0(E)
+-        [Isogeny of degree 5 from Elliptic Curve defined by y^2 + y = x^3 over Number Field in a with defining polynomial x^6 - 320*x^3 - 320 to Elliptic Curve defined by y^2 + y = x^3 + (643/8*a^5-15779/48*a^4-32939/24*a^3-71989/2*a^2+214321/6*a-112115/3)*x + (2901961/96*a^5+4045805/48*a^4+12594215/18*a^3-30029635/6*a^2+15341626/3*a-38944312/9) over Number Field in a with defining polynomial x^6 - 320*x^3 - 320,
+-        Isogeny of degree 5 from Elliptic Curve defined by y^2 + y = x^3 over Number Field in a with defining polynomial x^6 - 320*x^3 - 320 to Elliptic Curve defined by y^2 + y = x^3 + (-1109/8*a^5-53873/48*a^4-180281/24*a^3-14491/2*a^2+35899/6*a-43745/3)*x + (-17790679/96*a^5-60439571/48*a^4-77680504/9*a^3+1286245/6*a^2-4961854/3*a-73854632/9) over Number Field in a with defining polynomial x^6 - 320*x^3 - 320]
++        [Isogeny of degree 5 from Elliptic Curve defined by y^2 + y = x^3 over Number Field in a with defining polynomial x^6 - 320*x^3 - 320 to Elliptic Curve defined by y^2 + y = x^3 + (241565/32*a^5-362149/48*a^4+180281/24*a^3-9693307/4*a^2+14524871/6*a-7254985/3)*x + (1660391123/192*a^5-829315373/96*a^4+77680504/9*a^3-66622345345/24*a^2+33276655441/12*a-24931615912/9) over Number Field in a with defining polynomial x^6 - 320*x^3 - 320,
++         Isogeny of degree 5 from Elliptic Curve defined by y^2 + y = x^3 over Number Field in a with defining polynomial x^6 - 320*x^3 - 320 to Elliptic Curve defined by y^2 + y = x^3 + (47519/32*a^5-72103/48*a^4+32939/24*a^3-1909753/4*a^2+2861549/6*a-1429675/3)*x + (-131678717/192*a^5+65520419/96*a^4-12594215/18*a^3+5280985135/24*a^2-2637787519/12*a+1976130088/9) over Number Field in a with defining polynomial x^6 - 320*x^3 - 320]
+     """
+     F = E.base_field()
+     if E.j_invariant() != 0:
+diff --git a/src/sage/schemes/elliptic_curves/period_lattice.py b/src/sage/schemes/elliptic_curves/period_lattice.py
+index 42793dc1b3..6ae1dd593d 100644
+--- a/src/sage/schemes/elliptic_curves/period_lattice.py
++++ b/src/sage/schemes/elliptic_curves/period_lattice.py
+@@ -1626,7 +1626,7 @@ class PeriodLattice_ell(PeriodLattice):
+             sage: embs = K.embeddings(CC)
+             sage: Lambda = E.period_lattice(embs[0])
+             sage: Lambda.elliptic_logarithm(P+3*Q, 100)
+-            4.7100131126199672766973600998
++            4.3543876242043418255250464574
+             sage: R.<x> = QQ[]
+             sage: K.<a> = NumberField(x^2 + x + 5)
+             sage: E = EllipticCurve(K, [0,0,1,-3,-5])
+diff --git a/src/sage/schemes/toric/chow_group.py b/src/sage/schemes/toric/chow_group.py
+index 89e82467b0..78730f930a 100644
+--- a/src/sage/schemes/toric/chow_group.py
++++ b/src/sage/schemes/toric/chow_group.py
+@@ -62,7 +62,7 @@ EXAMPLES::
+     7
+     sage: a = sum( A.gen(i) * (i+1) for i in range(A.ngens()) )   # an element of A
+     sage: a  # long time (2s on sage.math, 2011)
+-    ( 3 | 1 mod 7 | 0 mod 2, 1 mod 2, 4, 5, 6, 7, 8 | 9 )
++    ( 3 | 1 mod 7 | 1 mod 2, 0 mod 2, 4, 5, 6, 7, 8 | 9 )
+ 
+ The Chow group elements are printed as ``( a0 | a1 mod 7 | a2 mod 2,
+ a3 mod 2, a4, a5, a6, a7, a8 | a9 )``, which denotes the element of
+@@ -93,13 +93,13 @@ Cones of toric varieties can determine their own Chow cycle::
+     sage: cone = X.fan(dim=2)[3]; cone
+     2-d cone of Rational polyhedral fan in 3-d lattice N
+     sage: A_cone = A(cone); A_cone
+-    ( 0 | 1 mod 7 | 0 mod 2, 0 mod 2, 0, 0, 0, 0, 0 | 0 )
++    ( 0 | 6 mod 7 | 0 mod 2, 0 mod 2, 0, 0, 0, 0, 0 | 0 )
+     sage: A_cone.degree()
+     1
+     sage: 2 * A_cone
+-    ( 0 | 2 mod 7 | 0 mod 2, 0 mod 2, 0, 0, 0, 0, 0 | 0 )
++    ( 0 | 5 mod 7 | 0 mod 2, 0 mod 2, 0, 0, 0, 0, 0 | 0 )
+     sage: A_cone + A.gen(0)
+-    ( 0 | 1 mod 7 | 0 mod 2, 1 mod 2, 0, 0, 0, 0, 0 | 0 )
++    ( 0 | 6 mod 7 | 1 mod 2, 0 mod 2, 0, 0, 0, 0, 0 | 0 )
+ 
+ Chow cycles can be of mixed degrees::
+ 
+diff --git a/src/sage/schemes/toric/homset.py b/src/sage/schemes/toric/homset.py
+index 4bff92bcb0..ff6211cabe 100644
+--- a/src/sage/schemes/toric/homset.py
++++ b/src/sage/schemes/toric/homset.py
+@@ -467,12 +467,27 @@ class SchemeHomset_points_toric_field(SchemeHomset_points_toric_base):
+         sage: point_set.cardinality()
+         21
+         sage: sorted(X.point_set().list())
+-        [[0 : 0 : 1], [0 : 1 : 0], [0 : 1 : 1], [0 : 1 : 3],
+-         [1 : 0 : 0], [1 : 0 : 1], [1 : 0 : 3], [1 : 1 : 0],
+-         [1 : 1 : 1], [1 : 1 : 2], [1 : 1 : 3], [1 : 1 : 4],
+-         [1 : 1 : 5], [1 : 1 : 6], [1 : 3 : 0], [1 : 3 : 1],
+-         [1 : 3 : 2], [1 : 3 : 3], [1 : 3 : 4], [1 : 3 : 5],
+-         [1 : 3 : 6]]
++        [[0 : 0 : 1],
++         [0 : 1 : 0],
++         [0 : 1 : 1],
++         [0 : 1 : 5],
++         [1 : 0 : 0],
++         [1 : 0 : 1],
++         [1 : 0 : 5],
++         [1 : 1 : 0],
++         [1 : 1 : 1],
++         [1 : 1 : 2],
++         [1 : 1 : 3],
++         [1 : 1 : 4],
++         [1 : 1 : 5],
++         [1 : 1 : 6],
++         [1 : 3 : 1],
++         [1 : 3 : 2],
++         [1 : 3 : 3],
++         [1 : 3 : 4],
++         [1 : 3 : 5],
++         [1 : 3 : 6],
++         [1 : 5 : 0]]
+ 
+     As for a non-compact example, the blow-up of the plane is the line
+     bundle $O_{\mathbf{P}^1}(-1)$. Its point set is the Cartesian
+@@ -641,7 +656,7 @@ class SchemeHomset_points_subscheme_toric_field(SchemeHomset_points_toric_base):
+             sage: P2.<x,y,z> = toric_varieties.P2(base_ring=GF(5))
+             sage: cubic = P2.subscheme([x^3 + y^3 + z^3])
+             sage: list(cubic.point_set())
+-            [[0 : 1 : 4], [1 : 0 : 4], [1 : 4 : 0], [1 : 2 : 1], [1 : 1 : 2], [1 : 3 : 3]]
++            [[0 : 1 : 4], [1 : 0 : 4], [1 : 4 : 0], [1 : 1 : 2], [1 : 2 : 1], [1 : 3 : 3]]
+             sage: cubic.point_set().cardinality()
+             6
+         """
+@@ -661,7 +676,7 @@ class SchemeHomset_points_subscheme_toric_field(SchemeHomset_points_toric_base):
+             sage: P2.<x,y,z> = toric_varieties.P2(base_ring=GF(5))
+             sage: cubic = P2.subscheme([x^3 + y^3 + z^3])
+             sage: list(cubic.point_set())
+-            [[0 : 1 : 4], [1 : 0 : 4], [1 : 4 : 0], [1 : 2 : 1], [1 : 1 : 2], [1 : 3 : 3]]
++            [[0 : 1 : 4], [1 : 0 : 4], [1 : 4 : 0], [1 : 1 : 2], [1 : 2 : 1], [1 : 3 : 3]]
+             sage: cubic.point_set().cardinality()
+             6
+         """
+diff --git a/src/sage/schemes/toric/points.py b/src/sage/schemes/toric/points.py
+index 4cec2b14ff..18c39d7096 100644
+--- a/src/sage/schemes/toric/points.py
++++ b/src/sage/schemes/toric/points.py
+@@ -538,7 +538,7 @@ class FiniteFieldPointEnumerator(NaiveFinitePointEnumerator):
+             sage: enum._Chow_group_torsion()
+             ((1, 2, 4), (1, 4, 2))
+             sage: enum._Chow_group_torsion_generators()
+-            ((1, 2, 4),)
++            ((1, 4, 2),)
+         """
+         if self.fan.is_smooth():
+             return tuple()
+@@ -674,7 +674,7 @@ class FiniteFieldPointEnumerator(NaiveFinitePointEnumerator):
+             sage: list(cokernel)
+             [(0), (1)]
+             sage: [p.lift() for p in cokernel]
+-            [(0, 0), (0, 1)]
++            [(0, 0), (0, -1)]
+         """
+         from sage.matrix.constructor import matrix, block_matrix, identity_matrix
+         from sage.rings.all import ZZ
+@@ -956,9 +956,9 @@ class FiniteFieldSubschemePointEnumerator(NaiveSubschemePointEnumerator):
+             sage: ffe.homogeneous_coordinates([0], nonzero_coordinates, cokernel)
+             (1, 1, 0)
+             sage: ffe.homogeneous_coordinates([1], nonzero_coordinates, cokernel)
+-            (1, 3, 0)
++            (1, 5, 0)
+             sage: ffe.homogeneous_coordinates([2], nonzero_coordinates, cokernel)
+-            (1, 2, 0)
++            (1, 4, 0)
+         """
+         z = [self.ambient.ring.zero()] * len(self.ambient.rays())
+         z_nonzero = self.ambient.exp(
+@@ -987,7 +987,7 @@ class FiniteFieldSubschemePointEnumerator(NaiveSubschemePointEnumerator):
+             sage: point_set = X.point_set()
+             sage: ffe = point_set._enumerator()
+             sage: list(ffe)   # indirect doctest
+-            [(1, 4, 3), (1, 1, 6), (1, 2, 5)]
++            [(1, 1, 6), (1, 2, 5), (1, 4, 3)]
+         """
+         for cone, nonzero_coordinates, cokernel in self.ambient.cone_points_iter():
+             R = PolynomialRing(self.ambient.ring, cokernel.ngens(), 't')
+@@ -1012,11 +1012,11 @@ class FiniteFieldSubschemePointEnumerator(NaiveSubschemePointEnumerator):
+             sage: Y = X.subscheme(u^3 + v^3 + w^3 + u*v*w)
+             sage: point_set = Y.point_set()
+             sage: list(point_set)
+-            [[0 : 1 : 3],
+-             [1 : 0 : 3],
+-             [1 : 3 : 0],
+-             [1 : 1 : 6],
++            [[0 : 1 : 5],
++             [1 : 0 : 5],
++             [1 : 5 : 0],
+              [1 : 1 : 4],
++             [1 : 1 : 6],
+              [1 : 3 : 2],
+              [1 : 3 : 5]]
+             sage: ffe = point_set._enumerator()
+diff --git a/src/sage/structure/factorization.py b/src/sage/structure/factorization.py
+index 1d32db0842..7636f1a9ba 100644
+--- a/src/sage/structure/factorization.py
++++ b/src/sage/structure/factorization.py
+@@ -133,17 +133,17 @@ Factorizations can involve fairly abstract mathematical objects::
+     sage: K.<a> = NumberField(x^2 + 3); K
+     Number Field in a with defining polynomial x^2 + 3
+     sage: f = K.factor(15); f
+-    (Fractional ideal (-a))^2 * (Fractional ideal (5))
++    (Fractional ideal (1/2*a + 3/2))^2 * (Fractional ideal (5))
+     sage: f.universe()
+     Monoid of ideals of Number Field in a with defining polynomial x^2 + 3
+     sage: f.unit()
+     Fractional ideal (1)
+     sage: g=K.factor(9); g
+-    (Fractional ideal (-a))^4
++    (Fractional ideal (1/2*a + 3/2))^4
+     sage: f.lcm(g)
+-    (Fractional ideal (-a))^4 * (Fractional ideal (5))
++    (Fractional ideal (1/2*a + 3/2))^4 * (Fractional ideal (5))
+     sage: f.gcd(g)
+-    (Fractional ideal (-a))^2
++    (Fractional ideal (1/2*a + 3/2))^2
+     sage: f.is_integral()
+     True
+ 
+diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/linalg_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/linalg_doctest.py
+index d67a33e7c4..7cba0ef6bb 100644
+--- a/src/sage/tests/books/computational-mathematics-with-sagemath/linalg_doctest.py
++++ b/src/sage/tests/books/computational-mathematics-with-sagemath/linalg_doctest.py
+@@ -232,13 +232,13 @@ Sage example in ./linalg.tex, line 1640::
+   sage: A = matrix(ZZ, 4, 5,\
+   ....:            [-1,-1,-1,-2,-2,-2,1,1,-1,2,2,2,2,2,-1,2,2,2,2,2])
+   sage: S,U,V = A.smith_form(); S,U,V
+-  (
+-                              [ 0 -2 -1 -5  0]
+-  [1 0 0 0 0]  [ 1  0  0  0]  [ 1  0  1 -1 -1]
+-  [0 1 0 0 0]  [ 0  0  1  0]  [ 0  0  0  0  1]
+-  [0 0 3 0 0]  [-2  1  0  0]  [-1  2  0  5  0]
+-  [0 0 0 6 0], [ 0  0 -2 -1], [ 0 -1  0 -2  0]
+-  )
++    (
++                                [ 0 -2  0 -5  0]
++    [1 0 0 0 0]  [ 1  0  0  0]  [ 1  0  0 -1 -1]
++    [0 1 0 0 0]  [-2  1  1  0]  [ 0  0  0  0  1]
++    [0 0 3 0 0]  [-4  2  3  0]  [-1  1  1  5  0]
++    [0 0 0 6 0], [ 4 -2 -2 -1], [ 0  0 -1 -2  0]
++    )
+ 
+ Sage example in ./linalg.tex, line 1674::
+ 
+diff --git a/src/sage/tests/books/judson-abstract-algebra/galois-sage.py b/src/sage/tests/books/judson-abstract-algebra/galois-sage.py
+index 6c25aa5dc5..8bdceb9424 100644
+--- a/src/sage/tests/books/judson-abstract-algebra/galois-sage.py
++++ b/src/sage/tests/books/judson-abstract-algebra/galois-sage.py
+@@ -385,69 +385,49 @@ r"""
+ 
+     sage: L.subfields()
+     [
+-    (Number Field in c0 with defining polynomial x,
+-     Ring morphism:
+-       From: Number Field in c0 with defining polynomial x
+-       To:   Number Field in c with defining polynomial x^8 + 28*x^4 + 2500
+-       Defn: 0 |--> 0,
+-     None),
+-    (Number Field in c1 with defining polynomial x^2 + 112*x + 40000,
+-     Ring morphism:
+-       From: Number Field in c1 with defining polynomial x^2 + 112*x + 40000
+-       To:   Number Field in c with defining polynomial x^8 + 28*x^4 + 2500
+-       Defn: c1 |--> 4*c^4,
+-     None),
+-    (Number Field in c2 with defining polynomial x^2 + 512,
+-     Ring morphism:
+-       From: Number Field in c2 with defining polynomial x^2 + 512
+-       To:   Number Field in c with defining polynomial x^8 + 28*x^4 + 2500
+-       Defn: c2 |--> 1/25*c^6 + 78/25*c^2,
+-     None),
+-    (Number Field in c3 with defining polynomial x^2 - 288,
+-     Ring morphism:
+-       From: Number Field in c3 with defining polynomial x^2 - 288
+-       To:   Number Field in c with defining polynomial x^8 + 28*x^4 + 2500
+-       Defn: c3 |--> -1/25*c^6 + 22/25*c^2,
+-     None),
+-    (Number Field in c4 with defining polynomial x^4 + 112*x^2 + 40000,
+-     Ring morphism:
+-       From: Number Field in c4 with defining polynomial x^4 + 112*x^2 + 40000
+-       To:   Number Field in c with defining polynomial x^8 + 28*x^4 + 2500
+-       Defn: c4 |--> 2*c^2,
+-     None),
+-    (Number Field in c5 with defining polynomial x^4 + 648,
+-     Ring morphism:
+-       From: Number Field in c5 with defining polynomial x^4 + 648
+-       To:   Number Field in c with defining polynomial x^8 + 28*x^4 + 2500
+-       Defn: c5 |--> 1/80*c^5 + 79/40*c,
+-     None),
+-    (Number Field in c6 with defining polynomial x^4 + 8,
+-    Ring morphism:
+-      From: Number Field in c6 with defining polynomial x^4 + 8
++    (Number Field in c0 with defining polynomial x, Ring morphism:
++      From: Number Field in c0 with defining polynomial x
+       To:   Number Field in c with defining polynomial x^8 + 28*x^4 + 2500
+-      Defn: c6 |--> -1/80*c^5 + 1/40*c,
+-      None),
+-    (Number Field in c7 with defining polynomial x^4 - 512,
+-     Ring morphism:
+-       From: Number Field in c7 with defining polynomial x^4 - 512
+-       To:   Number Field in c with defining polynomial x^8 + 28*x^4 + 2500
+-       Defn: c7 |--> -1/60*c^5 + 41/30*c,
+-     None),
+-    (Number Field in c8 with defining polynomial x^4 - 32,
+-     Ring morphism:
+-       From: Number Field in c8 with defining polynomial x^4 - 32
+-       To:   Number Field in c with defining polynomial x^8 + 28*x^4 + 2500
+-       Defn: c8 |--> 1/60*c^5 + 19/30*c,
+-     None),
+-    (Number Field in c9 with defining polynomial x^8 + 28*x^4 + 2500,
+-     Ring morphism:
+-       From: Number Field in c9 with defining polynomial x^8 + 28*x^4 + 2500
+-       To:   Number Field in c with defining polynomial x^8 + 28*x^4 + 2500
+-       Defn: c9 |--> c,
+-     Ring morphism:
+-       From: Number Field in c with defining polynomial x^8 + 28*x^4 + 2500
+-       To:   Number Field in c9 with defining polynomial x^8 + 28*x^4 + 2500
+-       Defn: c |--> c9)
++      Defn: 0 |--> 0, None),
++    (Number Field in c1 with defining polynomial x^2 + 112*x + 40000, Ring morphism:
++      From: Number Field in c1 with defining polynomial x^2 + 112*x + 40000
++      To:   Number Field in c with defining polynomial x^8 + 28*x^4 + 2500
++      Defn: c1 |--> 4*c^4, None),
++    (Number Field in c2 with defining polynomial x^2 + 512, Ring morphism:
++      From: Number Field in c2 with defining polynomial x^2 + 512
++      To:   Number Field in c with defining polynomial x^8 + 28*x^4 + 2500
++      Defn: c2 |--> 1/25*c^6 + 78/25*c^2, None),
++    (Number Field in c3 with defining polynomial x^2 - 288, Ring morphism:
++      From: Number Field in c3 with defining polynomial x^2 - 288
++      To:   Number Field in c with defining polynomial x^8 + 28*x^4 + 2500
++      Defn: c3 |--> -1/25*c^6 + 22/25*c^2, None),
++    (Number Field in c4 with defining polynomial x^4 + 112*x^2 + 40000, Ring morphism:
++      From: Number Field in c4 with defining polynomial x^4 + 112*x^2 + 40000
++      To:   Number Field in c with defining polynomial x^8 + 28*x^4 + 2500
++      Defn: c4 |--> 2*c^2, None),
++    (Number Field in c5 with defining polynomial x^4 + 8, Ring morphism:
++      From: Number Field in c5 with defining polynomial x^4 + 8
++      To:   Number Field in c with defining polynomial x^8 + 28*x^4 + 2500
++      Defn: c5 |--> -1/80*c^5 + 1/40*c, None),
++    (Number Field in c6 with defining polynomial x^4 + 648, Ring morphism:
++      From: Number Field in c6 with defining polynomial x^4 + 648
++      To:   Number Field in c with defining polynomial x^8 + 28*x^4 + 2500
++      Defn: c6 |--> 1/80*c^5 + 79/40*c, None),
++    (Number Field in c7 with defining polynomial x^4 - 512, Ring morphism:
++      From: Number Field in c7 with defining polynomial x^4 - 512
++      To:   Number Field in c with defining polynomial x^8 + 28*x^4 + 2500
++      Defn: c7 |--> -1/60*c^5 + 41/30*c, None),
++    (Number Field in c8 with defining polynomial x^4 - 32, Ring morphism:
++      From: Number Field in c8 with defining polynomial x^4 - 32
++      To:   Number Field in c with defining polynomial x^8 + 28*x^4 + 2500
++      Defn: c8 |--> 1/60*c^5 + 19/30*c, None),
++    (Number Field in c9 with defining polynomial x^8 + 28*x^4 + 2500, Ring morphism:
++      From: Number Field in c9 with defining polynomial x^8 + 28*x^4 + 2500
++      To:   Number Field in c with defining polynomial x^8 + 28*x^4 + 2500
++      Defn: c9 |--> c, Ring morphism:
++      From: Number Field in c with defining polynomial x^8 + 28*x^4 + 2500
++      To:   Number Field in c9 with defining polynomial x^8 + 28*x^4 + 2500
++      Defn: c |--> c9)
+     ]
+ 
+ ~~~~~~~~~~~~~~~~~~~~~~ ::
+diff --git a/src/sage/tests/parigp.py b/src/sage/tests/parigp.py
+index c118b6eb37..f567ade058 100644
+--- a/src/sage/tests/parigp.py
++++ b/src/sage/tests/parigp.py
+@@ -2,15 +2,6 @@ r"""
+ This file is meant to catch errors in the PARI/GP package which are not
+ caught by any other tests.
+ 
+-Check that :trac:`9876` has been fixed, this test comes from PARI's
+-self-test :pari:`rnfkummer` but was modified such that the answer is
+-canonical::
+-
+-    sage: pari('addprimes([31438243, 238576291, 18775387483, 24217212463267, 1427657500359111961, 135564809928627323997297867381959])')
+-    [31438243, 238576291, 18775387483, 24217212463267, 1427657500359111961, 135564809928627323997297867381959]
+-    sage: pari('K = bnfinit(y^4-52*y^2+26,1); pol = rnfkummer(bnrinit(K,3,1),Mat(5)); L = rnfinit(K, pol); polredabs(polredbest(L.polabs))')  # long time
+-    x^20 - 112*x^18 + 5108*x^16 - 123460*x^14 + 1724337*x^12 - 14266996*x^10 + 69192270*x^8 - 188583712*x^6 + 260329852*x^4 - 141461008*x^2 + 19860776
+-
+ Check that :trac:`10195` (PARI bug 1153) has been fixed::
+ 
+     sage: print(gp.eval("mathnf([0,0,0,0,0,0,0,0,0,13;0,0,0,0,0,0,0,0,23,6;0,0,0,0,0,0,0,23,-4,-7;0,0,0,0,0,0,17,-3,5,-5;0,0,0,0,0,56,16,-16,-15,-17;0,0,0,0,57,24,-16,-25,2,-21;0,0,0,114,9,56,51,-52,25,-55;0,0,113,-31,-11,24,0,28,34,-16;0,50,3,2,16,-6,-2,7,-19,-21;118,43,51,23,37,-52,18,38,51,28],0)"))

Copied: sagemath/repos/community-testing-x86_64/sagemath-singular-4.1.2.patch (from rev 749409, sagemath/trunk/sagemath-singular-4.1.2.patch)
===================================================================
--- community-testing-x86_64/sagemath-singular-4.1.2.patch	                        (rev 0)
+++ community-testing-x86_64/sagemath-singular-4.1.2.patch	2020-11-10 07:32:08 UTC (rev 749410)
@@ -0,0 +1,759 @@
+diff --git a/src/doc/en/constructions/algebraic_geometry.rst b/src/doc/en/constructions/algebraic_geometry.rst
+index a312548..d1c9c95 100644
+--- a/src/doc/en/constructions/algebraic_geometry.rst
++++ b/src/doc/en/constructions/algebraic_geometry.rst
+@@ -139,7 +139,7 @@ Other methods
+ 
+        sage: singular.lib("brnoeth.lib")
+        sage: s = singular.ring(2,'(x,y)','lp')
+-       sage: I = singular.ideal('[x^4+x, y^4+y]')
++       sage: I = singular.ideal('x^4+x', 'y^4+y')
+        sage: L = singular.closed_points(I)
+        sage: # Here you have all the points :
+        sage: print(L)
+@@ -325,7 +325,7 @@ Singular itself to help an understanding of how the wrapper works.
+        sage: X = Curve(f); pts = X.rational_points()
+        sage: D = X.divisor([ (3, pts[0]), (-1,pts[1]), (10, pts[5]) ])
+        sage: X.riemann_roch_basis(D)
+-       [(-x - 2*y)/(-2*x - 2*y), (-x + z)/(x + y)]
++       [(-2*x + y)/(x + y), (-x + z)/(x + y)]
+ 
+ -  Using Singular's ``BrillNoether`` command (for details see the section
+    Brill-Noether in the Singular online documentation
+diff --git a/src/sage/algebras/free_algebra.py b/src/sage/algebras/free_algebra.py
+index 7391dd9..7234f91 100644
+--- a/src/sage/algebras/free_algebra.py
++++ b/src/sage/algebras/free_algebra.py
+@@ -39,7 +39,15 @@ two-sided ideals, and thus provide ideal containment tests::
+     Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field
+     sage: I = F*[x*y+y*z,x^2+x*y-y*x-y^2]*F
+     sage: I.groebner_basis(degbound=4)
+-    Twosided Ideal (y*z*y*y - y*z*y*z + y*z*z*y - y*z*z*z, y*z*y*x + y*z*y*z + y*z*z*x + y*z*z*z, y*y*z*y - y*y*z*z + y*z*z*y - y*z*z*z, y*y*z*x + y*y*z*z + y*z*z*x + y*z*z*z, y*y*y - y*y*z + y*z*y - y*z*z, y*y*x + y*y*z + y*z*x + y*z*z, x*y + y*z, x*x - y*x - y*y - y*z) of Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field
++    Twosided Ideal (x*y + y*z,
++        x*x - y*x - y*y - y*z,
++        y*y*y - y*y*z + y*z*y - y*z*z,
++        y*y*x + y*y*z + y*z*x + y*z*z,
++        y*y*z*y - y*y*z*z + y*z*z*y - y*z*z*z,
++        y*z*y*y - y*z*y*z + y*z*z*y - y*z*z*z,
++        y*y*z*x + y*y*z*z + y*z*z*x + y*z*z*z,
++        y*z*y*x + y*z*y*z + y*z*z*x + y*z*z*z) of Free Associative Unital
++        Algebra on 3 generators (x, y, z) over Rational Field
+     sage: y*z*y*y*z*z + 2*y*z*y*z*z*x + y*z*y*z*z*z - y*z*z*y*z*x + y*z*z*z*z*x in I
+     True
+ 
+@@ -233,7 +241,7 @@ class FreeAlgebraFactory(UniqueFactory):
+         a*b^2*c^3
+     """
+     def create_key(self, base_ring, arg1=None, arg2=None,
+-            sparse=None, order='degrevlex',
++            sparse=None, order=None,
+             names=None, name=None,
+             implementation=None, degrees=None):
+         """
+@@ -264,6 +272,8 @@ class FreeAlgebraFactory(UniqueFactory):
+             return tuple(degrees),base_ring
+         # test if we can use libSingular/letterplace
+         if implementation == "letterplace":
++            if order is None:
++                order = 'degrevlex' if degrees is None else 'deglex'
+             args = [arg for arg in (arg1, arg2) if arg is not None]
+             kwds = dict(sparse=sparse, order=order, implementation="singular")
+             if name is not None:
+@@ -274,7 +284,7 @@ class FreeAlgebraFactory(UniqueFactory):
+             if degrees is None:
+                 return (PolRing,)
+             from sage.all import TermOrder
+-            T = PolRing.term_order() + TermOrder('lex',1)
++            T = TermOrder(PolRing.term_order(), PolRing.ngens() + 1)
+             varnames = list(PolRing.variable_names())
+             newname = 'x'
+             while newname in varnames:
+diff --git a/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx b/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx
+index ad863ea..d6127c9 100644
+--- a/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx
++++ b/src/sage/algebras/letterplace/free_algebra_element_letterplace.pyx
+@@ -17,6 +17,7 @@ AUTHOR:
+ #                  https://www.gnu.org/licenses/
+ # ****************************************************************************
+ 
++from sage.groups.perm_gps.all import CyclicPermutationGroup
+ from sage.libs.singular.function import lib, singular_function
+ from sage.misc.repr import repr_lincomb
+ from sage.rings.polynomial.multi_polynomial_ideal import MPolynomialIdeal
+@@ -25,7 +26,6 @@ from cpython.object cimport PyObject_RichCompare
+ # Define some singular functions
+ lib("freegb.lib")
+ poly_reduce = singular_function("NF")
+-singular_system=singular_function("system")
+ 
+ #####################
+ # Free algebra elements
+@@ -445,9 +445,10 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):
+         cdef int i
+         if P.monomial_divides(s_poly,p_poly):
+             return True
++        realngens = A._commutative_ring.ngens()
++        CG = CyclicPermutationGroup(P.ngens())
+         for i from 0 <= i < p_d-s_d:
+-            s_poly = singular_system("stest",s_poly,1,
+-                                     A._degbound,A.__ngens,ring=P)
++            s_poly = s_poly * CG[realngens]
+             if P.monomial_divides(s_poly,p_poly):
+                 return True
+         return False
+@@ -601,7 +602,9 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):
+         # we must put the polynomials into the same ring
+         left._poly = A._current_ring(left._poly)
+         right._poly = A._current_ring(right._poly)
+-        rshift = singular_system("stest",right._poly,left._poly.degree(),A._degbound,A.__ngens, ring=A._current_ring)
++        realngens = A._commutative_ring.ngens()
++        CG = CyclicPermutationGroup(A._current_ring.ngens())
++        rshift = right._poly * CG[left._poly.degree() * realngens]
+         return FreeAlgebraElement_letterplace(A,left._poly*rshift, check=False)
+ 
+     def __pow__(FreeAlgebraElement_letterplace self, int n, k):
+@@ -627,10 +630,11 @@ cdef class FreeAlgebraElement_letterplace(AlgebraElement):
+         self._poly = A._current_ring(self._poly)
+         cdef int d = self._poly.degree()
+         q = p = self._poly
++        realngens = A._commutative_ring.ngens()
+         cdef int i
++        CG = CyclicPermutationGroup(A._current_ring.ngens())
+         for i from 0<i<n:
+-            q = singular_system("stest",q,d,A._degbound,A.__ngens,
+-                                     ring=A._current_ring)
++            q = q * CG[d * realngens]
+             p *= q
+         return FreeAlgebraElement_letterplace(A, p, check=False)
+ 
+diff --git a/src/sage/algebras/letterplace/free_algebra_letterplace.pxd b/src/sage/algebras/letterplace/free_algebra_letterplace.pxd
+index 7e5f2bb..d1d162c 100644
+--- a/src/sage/algebras/letterplace/free_algebra_letterplace.pxd
++++ b/src/sage/algebras/letterplace/free_algebra_letterplace.pxd
+@@ -13,8 +13,15 @@ from sage.rings.ring cimport Algebra
+ from sage.structure.element cimport AlgebraElement, ModuleElement, RingElement, Element
+ from sage.rings.polynomial.multi_polynomial_libsingular cimport MPolynomialRing_libsingular, MPolynomial_libsingular
+ from sage.algebras.letterplace.free_algebra_element_letterplace cimport FreeAlgebraElement_letterplace
++from sage.libs.singular.decl cimport ring
+ 
+ 
++cdef class FreeAlgebra_letterplace_libsingular():
++    cdef ring* _lp_ring
++    cdef MPolynomialRing_libsingular _commutative_ring
++    cdef MPolynomialRing_libsingular _lp_ring_internal
++    cdef object __ngens
++
+ cdef class FreeAlgebra_letterplace(Algebra):
+     cdef MPolynomialRing_libsingular _commutative_ring
+     cdef MPolynomialRing_libsingular _current_ring
+diff --git a/src/sage/algebras/letterplace/free_algebra_letterplace.pyx b/src/sage/algebras/letterplace/free_algebra_letterplace.pyx
+index a9d09ad..714284e 100644
+--- a/src/sage/algebras/letterplace/free_algebra_letterplace.pyx
++++ b/src/sage/algebras/letterplace/free_algebra_letterplace.pyx
+@@ -37,7 +37,15 @@ The preceding containment test is based on the computation of Groebner
+ bases with degree bound::
+ 
+     sage: I.groebner_basis(degbound=4)
+-    Twosided Ideal (y*z*y*y - y*z*y*z + y*z*z*y - y*z*z*z, y*z*y*x + y*z*y*z + y*z*z*x + y*z*z*z, y*y*z*y - y*y*z*z + y*z*z*y - y*z*z*z, y*y*z*x + y*y*z*z + y*z*z*x + y*z*z*z, y*y*y - y*y*z + y*z*y - y*z*z, y*y*x + y*y*z + y*z*x + y*z*z, x*y + y*z, x*x - y*x - y*y - y*z) of Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field
++    Twosided Ideal (x*y + y*z,
++        x*x - y*x - y*y - y*z,
++        y*y*y - y*y*z + y*z*y - y*z*z,
++        y*y*x + y*y*z + y*z*x + y*z*z,
++        y*y*z*y - y*y*z*z + y*z*z*y - y*z*z*z,
++        y*z*y*y - y*z*y*z + y*z*z*y - y*z*z*z,
++        y*y*z*x + y*y*z*z + y*z*z*x + y*z*z*z,
++        y*z*y*x + y*z*y*z + y*z*z*x + y*z*z*z) of Free Associative Unital
++        Algebra on 3 generators (x, y, z) over Rational Field
+ 
+ When reducing an element by `I`, the original generators are chosen::
+ 
+@@ -67,7 +75,13 @@ different normal form::
+     Lexicographic term order
+     sage: J = L*[a*b+b*c,a^2+a*b-b*c-c^2]*L
+     sage: J.groebner_basis(4)
+-    Twosided Ideal (2*b*c*b - b*c*c + c*c*b, a*c*c - 2*b*c*a - 2*b*c*c - c*c*a, a*b + b*c, a*a - 2*b*c - c*c) of Free Associative Unital Algebra on 3 generators (a, b, c) over Rational Field
++    Twosided Ideal (2*b*c*b - b*c*c + c*c*b,
++        a*b + b*c,
++        -a*c*c + 2*b*c*a + 2*b*c*c + c*c*a,
++        a*c*c*b - 2*b*c*c*b + b*c*c*c,
++        a*a - 2*b*c - c*c,
++        a*c*c*a - 2*b*c*c*a - 4*b*c*c*c - c*c*c*c) of Free Associative Unital
++        Algebra on 3 generators (a, b, c) over Rational Field
+     sage: (b*c*b*b).normal_form(J)
+     1/2*b*c*c*b - 1/2*c*c*b*b
+ 
+@@ -105,15 +119,16 @@ TESTS::
+ from sage.misc.misc_c import prod
+ from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
+ from sage.libs.singular.function import lib, singular_function
+-from sage.rings.polynomial.term_order import TermOrder
++from sage.libs.singular.function cimport RingWrap
++from sage.libs.singular.ring cimport singular_ring_delete, singular_ring_reference
+ from sage.categories.algebras import Algebras
+ from sage.rings.noncommutative_ideals import IdealMonoid_nc
++from sage.rings.polynomial.plural cimport new_CRing
+ 
+ #####################
+ # Define some singular functions
+ lib("freegb.lib")
+-poly_reduce = singular_function("NF")
+-singular_system=singular_function("system")
++freeAlgebra = singular_function("freeAlgebra")
+ 
+ # unfortunately we can not set Singular attributes for MPolynomialRing_libsingular
+ # Hence, we must constantly work around Letterplace's sanity checks,
+@@ -242,7 +257,7 @@ cdef class FreeAlgebra_letterplace(Algebra):
+             sage: F.<a,b,c> = FreeAlgebra(K, implementation='letterplace')
+             sage: TestSuite(F).run()
+         """
+-        if not isinstance(R,MPolynomialRing_libsingular):
++        if not isinstance(R, MPolynomialRing_libsingular):
+             raise TypeError("A letterplace algebra must be provided by a polynomial ring of type %s" % MPolynomialRing_libsingular)
+         self.__ngens = R.ngens()
+         if degrees is None:
+@@ -260,7 +275,9 @@ cdef class FreeAlgebra_letterplace(Algebra):
+         if degrees is None:
+             self._degrees = tuple([int(1)]*self.__ngens)
+         else:
+-            if (not isinstance(degrees,(tuple,list))) or len(degrees)!=self.__ngens-1 or any(i <= 0 for i in degrees):
++            if (not isinstance(degrees, (tuple, list))) \
++                    or len(degrees) != self.__ngens - self._nb_slackvars \
++                    or any(i <= 0 for i in degrees):
+                 raise TypeError("The generator degrees must be given by a list or tuple of %d positive integers" % (self.__ngens-1))
+             self._degrees = tuple([int(i) for i in degrees])
+             self.set_degbound(max(self._degrees))
+@@ -666,7 +683,7 @@ cdef class FreeAlgebra_letterplace(Algebra):
+         Sage, since it does the reductions in a different order
+         compared to Singular. Therefore, we call the original Singular
+         reduction method, and prevent a warning message by asserting
+-        that `G` is a Groebner basis.
++        that `G` is a Groebner basis. ::
+ 
+             sage: from sage.libs.singular.function import singular_function
+             sage: poly_reduce = singular_function("NF")
+@@ -682,8 +699,10 @@ cdef class FreeAlgebra_letterplace(Algebra):
+         ngens = self.__ngens
+         degbound = self._degbound
+         cdef list G = [C(x._poly) for x in g]
++        from sage.groups.perm_gps.all import CyclicPermutationGroup
++        CG = CyclicPermutationGroup(C.ngens())
+         for y in G:
+-            out.extend([y]+[singular_system("stest",y,n+1,degbound,ngens,ring=C) for n in xrange(d-y.degree())])
++            out.extend([y]+[y * CG[ngens*(n+1)] for n in xrange(d-y.degree())])
+         return C.ideal(out)
+ 
+     ###########################
+@@ -879,3 +898,28 @@ cdef class FreeAlgebra_letterplace(Algebra):
+             PNames[P.ngens(): len(PNames): P.ngens()+1] = list(Names[self.ngens(): len(Names): self.ngens()+1])[:P.degbound()]
+             x = Ppoly.hom([Gens[Names.index(asdf)] for asdf in PNames])(x.letterplace_polynomial())
+         return FreeAlgebraElement_letterplace(self,self._current_ring(x))
++
++cdef class FreeAlgebra_letterplace_libsingular():
++    """
++    Internally used wrapper around a Singular Letterplace polynomial ring.
++    """
++
++    def __cinit__(self, MPolynomialRing_libsingular commutative_ring,
++                  int degbound):
++        cdef RingWrap rw = freeAlgebra(commutative_ring, degbound)
++        self._lp_ring = singular_ring_reference(rw._ring)
++        # `_lp_ring` viewed as `MPolynomialRing_libsingular` with additional
++        # letterplace attributes set (for internal use only)
++        self._lp_ring_internal = new_CRing(rw, commutative_ring.base_ring())
++        self._commutative_ring = commutative_ring
++
++    def __init__(self, commutative_ring, degbound):
++        self.__ngens = commutative_ring.ngens() * degbound
++
++    def __dealloc__(self):
++        r"""
++        Carefully deallocate the ring, without changing ``currRing``
++        (since this method can be at unpredictable times due to garbage
++        collection).
++        """
++        singular_ring_delete(self._lp_ring)
+diff --git a/src/sage/algebras/letterplace/letterplace_ideal.pyx b/src/sage/algebras/letterplace/letterplace_ideal.pyx
+index d7214d1..5b8cf48 100644
+--- a/src/sage/algebras/letterplace/letterplace_ideal.pyx
++++ b/src/sage/algebras/letterplace/letterplace_ideal.pyx
+@@ -18,7 +18,11 @@ One can compute Groebner bases out to a finite degree, can compute normal
+ forms and can test containment in the ideal::
+ 
+     sage: I.groebner_basis(degbound=3)
+-    Twosided Ideal (y*y*y - y*y*z + y*z*y - y*z*z, y*y*x + y*y*z + y*z*x + y*z*z, x*y + y*z, x*x - y*x - y*y - y*z) of Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field
++    Twosided Ideal (x*y + y*z,
++        x*x - y*x - y*y - y*z,
++        y*y*y - y*y*z + y*z*y - y*z*z,
++        y*y*x + y*y*z + y*z*x + y*z*z) of Free Associative Unital Algebra
++        on 3 generators (x, y, z) over Rational Field
+     sage: (x*y*z*y*x).normal_form(I)
+     y*z*z*y*z + y*z*z*z*x + y*z*z*z*z
+     sage: x*y*z*y*x - (x*y*z*y*x).normal_form(I) in I
+@@ -42,14 +46,14 @@ AUTHOR:
+ 
+ from sage.rings.noncommutative_ideals import Ideal_nc
+ from sage.libs.singular.function import lib, singular_function
+-from sage.algebras.letterplace.free_algebra_letterplace cimport FreeAlgebra_letterplace
++from sage.algebras.letterplace.free_algebra_letterplace cimport FreeAlgebra_letterplace, FreeAlgebra_letterplace_libsingular
+ from sage.algebras.letterplace.free_algebra_element_letterplace cimport FreeAlgebraElement_letterplace
+ from sage.rings.infinity import Infinity
+ 
+ #####################
+ # Define some singular functions
+ lib("freegb.lib")
+-singular_system=singular_function("system")
++singular_twostd=singular_function("twostd")
+ poly_reduce=singular_function("NF")
+ 
+ class LetterplaceIdeal(Ideal_nc):
+@@ -69,14 +73,22 @@ class LetterplaceIdeal(Ideal_nc):
+         sage: I.groebner_basis(2)
+         Twosided Ideal (x*y + y*z, x*x - y*x - y*y - y*z) of Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field
+         sage: I.groebner_basis(4)
+-        Twosided Ideal (y*z*y*y - y*z*y*z + y*z*z*y - y*z*z*z, y*z*y*x + y*z*y*z + y*z*z*x + y*z*z*z, y*y*z*y - y*y*z*z + y*z*z*y - y*z*z*z, y*y*z*x + y*y*z*z + y*z*z*x + y*z*z*z, y*y*y - y*y*z + y*z*y - y*z*z, y*y*x + y*y*z + y*z*x + y*z*z, x*y + y*z, x*x - y*x - y*y - y*z) of Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field
++        Twosided Ideal (x*y + y*z,
++            x*x - y*x - y*y - y*z,
++            y*y*y - y*y*z + y*z*y - y*z*z,
++            y*y*x + y*y*z + y*z*x + y*z*z,
++            y*y*z*y - y*y*z*z + y*z*z*y - y*z*z*z,
++            y*z*y*y - y*z*y*z + y*z*z*y - y*z*z*z,
++            y*y*z*x + y*y*z*z + y*z*z*x + y*z*z*z,
++            y*z*y*x + y*z*y*z + y*z*z*x + y*z*z*z) of Free Associative Unital
++            Algebra on 3 generators (x, y, z) over Rational Field
+ 
+     Groebner bases are cached. If one has computed a Groebner basis
+     out to a high degree then it will also be returned if a Groebner
+     basis with a lower degree bound is requested::
+ 
+-        sage: I.groebner_basis(2)
+-        Twosided Ideal (y*z*y*y - y*z*y*z + y*z*z*y - y*z*z*z, y*z*y*x + y*z*y*z + y*z*z*x + y*z*z*z, y*y*z*y - y*y*z*z + y*z*z*y - y*z*z*z, y*y*z*x + y*y*z*z + y*z*z*x + y*z*z*z, y*y*y - y*y*z + y*z*y - y*z*z, y*y*x + y*y*z + y*z*x + y*z*z, x*y + y*z, x*x - y*x - y*y - y*z) of Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field
++        sage: I.groebner_basis(2) is I.groebner_basis(4)
++        True
+ 
+     Of course, the normal form of any element has to satisfy the following::
+ 
+@@ -116,8 +128,11 @@ class LetterplaceIdeal(Ideal_nc):
+         sage: F.<x,y,z> = FreeAlgebra(QQ, implementation='letterplace',degrees=[1,2,3])
+         sage: I = F*[x*y+z-y*x,x*y*z-x^6+y^3]*F
+         sage: I.groebner_basis(Infinity)
+-        Twosided Ideal (x*z*z - y*x*x*z - y*x*y*y + y*x*z*x + y*y*y*x + z*x*z + z*y*y - z*z*x,
+-        x*y - y*x + z,
++        Twosided Ideal (x*y - y*x + z,
++        x*x*x*x*x*x - y*x*z - y*y*y + z*z,
++        x*z*z - y*x*x*z + y*x*z*x + y*y*z + y*z*y + z*x*z + z*y*y - z*z*x,
++        x*x*x*x*x*z + x*x*x*x*z*x + x*x*x*z*x*x + x*x*z*x*x*x + x*z*x*x*x*x +
++        y*x*z*y - y*y*x*z + y*z*z + z*x*x*x*x*x - z*z*y,
+         x*x*x*x*z*y*y + x*x*x*z*y*y*x - x*x*x*z*y*z - x*x*z*y*x*z + x*x*z*y*y*x*x +
+         x*x*z*y*y*y - x*x*z*y*z*x - x*z*y*x*x*z - x*z*y*x*z*x +
+         x*z*y*y*x*x*x + 2*x*z*y*y*y*x - 2*x*z*y*y*z - x*z*y*z*x*x -
+@@ -135,10 +150,7 @@ class LetterplaceIdeal(Ideal_nc):
+         z*y*y*y*y - 3*z*y*y*z*x - z*y*z*x*x*x - 2*z*y*z*y*x +
+         2*z*y*z*z - z*z*x*x*x*x*x + 4*z*z*x*x*z + 4*z*z*x*z*x -
+         4*z*z*y*x*x*x - 3*z*z*y*y*x + 4*z*z*y*z + 4*z*z*z*x*x +
+-        2*z*z*z*y,
+-        x*x*x*x*x*z + x*x*x*x*z*x + x*x*x*z*x*x + x*x*z*x*x*x + x*z*x*x*x*x +
+-        y*x*z*y - y*y*x*z + y*z*z + z*x*x*x*x*x - z*z*y,
+-        x*x*x*x*x*x - y*x*z - y*y*y + z*z)
++        2*z*z*z*y)
+         of Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field
+ 
+     Again, we can compute normal forms::
+@@ -226,7 +238,15 @@ class LetterplaceIdeal(Ideal_nc):
+             sage: I.groebner_basis()   # not tested
+             Twosided Ideal (y*y*y - y*y*z + y*z*y - y*z*z, y*y*x + y*y*z + y*z*x + y*z*z, x*y + y*z, x*x - y*x - y*y - y*z) of Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field
+             sage: I.groebner_basis(4)
+-            Twosided Ideal (y*z*y*y - y*z*y*z + y*z*z*y - y*z*z*z, y*z*y*x + y*z*y*z + y*z*z*x + y*z*z*z, y*y*z*y - y*y*z*z + y*z*z*y - y*z*z*z, y*y*z*x + y*y*z*z + y*z*z*x + y*z*z*z, y*y*y - y*y*z + y*z*y - y*z*z, y*y*x + y*y*z + y*z*x + y*z*z, x*y + y*z, x*x - y*x - y*y - y*z) of Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field
++            Twosided Ideal (x*y + y*z,
++                x*x - y*x - y*y - y*z,
++                y*y*y - y*y*z + y*z*y - y*z*z,
++                y*y*x + y*y*z + y*z*x + y*z*z,
++                y*y*z*y - y*y*z*z + y*z*z*y - y*z*z*z,
++                y*z*y*y - y*z*y*z + y*z*z*y - y*z*z*z,
++                y*y*z*x + y*y*z*z + y*z*z*x + y*z*z*z,
++                y*z*y*x + y*z*y*z + y*z*z*x + y*z*z*z) of Free Associative
++                Unital Algebra on 3 generators (x, y, z) over Rational Field
+             sage: I.groebner_basis(2) is I.groebner_basis(4)
+             True
+             sage: G = I.groebner_basis(4)
+@@ -238,7 +258,14 @@ class LetterplaceIdeal(Ideal_nc):
+ 
+             sage: I = F*[x*y-y*x,x*z-z*x,y*z-z*y,x^2*y-z^3,x*y^2+z*x^2]*F
+             sage: I.groebner_basis(Infinity)
+-            Twosided Ideal (z*z*z*y*y + z*z*z*z*x, z*x*x*x + z*z*z*y, y*z - z*y, y*y*x + z*x*x, y*x*x - z*z*z, x*z - z*x, x*y - y*x) of Free Associative Unital Algebra on 3 generators (x, y, z) over Rational Field
++            Twosided Ideal (-y*z + z*y,
++                -x*z + z*x,
++                -x*y + y*x,
++                x*x*z + x*y*y,
++                x*x*y - z*z*z,
++                x*x*x*z + y*z*z*z,
++                x*z*z*z*z + y*y*z*z*z) of Free Associative Unital Algebra
++                on 3 generators (x, y, z) over Rational Field
+ 
+         Since the commutators of the generators are contained in the ideal,
+         we can verify the above result by a computation in a polynomial ring
+@@ -276,9 +303,32 @@ class LetterplaceIdeal(Ideal_nc):
+         libsingular_options['redSB'] = True
+         A.set_degbound(degbound)
+         P = A._current_ring
+-        out = [FreeAlgebraElement_letterplace(A,X,check=False) for X in
+-               singular_system("freegb",P.ideal([x._poly for x in self.__GB.gens()]),
+-                               degbound,A.__ngens, ring = P)]
++
++        # note that degbound might be smaller than A._degbound due to caching,
++        # but degbound must be large enough to map all generators to the
++        # letterplace ring L
++        if degbound < A._degbound:
++            max_deg = max([x._poly.degree() for x in self.__GB.gens()])
++            if degbound < max_deg:
++                degbound = max_deg
++
++        # The following is a workaround for calling Singular's new Letterplace
++        # API (see :trac:`25993`). We construct a temporary polynomial ring L
++        # with letterplace attributes set as required by the API. As L has
++        # duplicate variable names, we need to handle this ring carefully; in
++        # particular, we cannot coerce to and from L, so we use homomorphisms
++        # for the conversion.
++
++        cdef FreeAlgebra_letterplace_libsingular lp_ring = \
++            FreeAlgebra_letterplace_libsingular(A._commutative_ring, degbound)
++        L = lp_ring._lp_ring_internal
++        to_L = P.hom(L.gens(), L, check=False)
++        from_L = L.hom(P.gens(), P, check=False)
++        I = L.ideal([to_L(x._poly) for x in self.__GB.gens()])
++        gb = singular_twostd(I)
++        out = [FreeAlgebraElement_letterplace(A, from_L(X), check=False)
++               for X in gb]
++
+         libsingular_options['redTail'] = bck[0]
+         libsingular_options['redSB'] = bck[1]
+         self.__GB = A.ideal(out,side='twosided',coerce=False)
+diff --git a/src/sage/combinat/root_system/hecke_algebra_representation.py b/src/sage/combinat/root_system/hecke_algebra_representation.py
+index 51f4113..ba42ed1 100644
+--- a/src/sage/combinat/root_system/hecke_algebra_representation.py
++++ b/src/sage/combinat/root_system/hecke_algebra_representation.py
+@@ -746,7 +746,7 @@ class HeckeAlgebraRepresentation(WithEqualityById, SageObject):
+              -2121 + 212,
+              (q2/(q1-q2))*2121 + (q2/(-q1+q2))*121 + (q2/(-q1+q2))*212 - 12 + ((-q2)/(-q1+q2))*21 + 2,
+              ((-q2^2)/(-q1^2+q1*q2-q2^2))*2121 - 121 + (q2^2/(-q1^2+q1*q2-q2^2))*212 + 21,
+-             ((q1^2+q2^2)/(-q1^2+q1*q2-q2^2))*2121 + ((-q1^2-q2^2)/(-q1^2+q1*q2-q2^2))*121 + ((-q2^2)/(-q1^2+q1*q2-q2^2))*212 + (q2^2/(-q1^2+q1*q2-q2^2))*12 - 21 + 1,
++             ((-q1^2-q2^2)/(q1^2-q1*q2+q2^2))*2121 + ((-q1^2-q2^2)/(-q1^2+q1*q2-q2^2))*121 + ((-q2^2)/(-q1^2+q1*q2-q2^2))*212 + (q2^2/(-q1^2+q1*q2-q2^2))*12 - 21 + 1,
+              2121,
+              (q2/(-q1+q2))*2121 + ((-q2)/(-q1+q2))*121 - 212 + 12,
+              -2121 + 121]
+diff --git a/src/sage/combinat/root_system/non_symmetric_macdonald_polynomials.py b/src/sage/combinat/root_system/non_symmetric_macdonald_polynomials.py
+index 3537772..ee8ddec 100644
+--- a/src/sage/combinat/root_system/non_symmetric_macdonald_polynomials.py
++++ b/src/sage/combinat/root_system/non_symmetric_macdonald_polynomials.py
+@@ -555,8 +555,7 @@ class NonSymmetricMacdonaldPolynomials(CherednikOperatorsEigenvectors):
+         B[(1, 0, 0)]
+ 
+         sage: E[-omega[1]]
+-        B[(-1, 0, 0)] + ((-q*q1^6-q*q1^5*q2-q1*q2^5-q2^6)/(-q^3*q1^6-q^2*q1^5*q2-q*q1*q2^5-q2^6))*B[(1, 0, 0)] + ((-q1-q2)/(-q*q1-q2))*B[(0, -1, 0)]
+-        + ((q1+q2)/(q*q1+q2))*B[(0, 1, 0)] + ((-q1-q2)/(-q*q1-q2))*B[(0, 0, -1)] + ((-q1-q2)/(-q*q1-q2))*B[(0, 0, 1)]
++        B[(-1, 0, 0)] + ((q*q1^6+q*q1^5*q2+q1*q2^5+q2^6)/(q^3*q1^6+q^2*q1^5*q2+q*q1*q2^5+q2^6))*B[(1, 0, 0)] + ((q1+q2)/(q*q1+q2))*B[(0, -1, 0)] + ((q1+q2)/(q*q1+q2))*B[(0, 1, 0)] + ((q1+q2)/(q*q1+q2))*B[(0, 0, -1)] + ((q1+q2)/(q*q1+q2))*B[(0, 0, 1)]
+ 
+         sage: E[omega[2]]
+         ((-q1*q2^3-q2^4)/(q*q1^4-q2^4))*B[(1, 0, 0)] + B[(0, 1, 0)]
+@@ -567,14 +566,7 @@ class NonSymmetricMacdonaldPolynomials(CherednikOperatorsEigenvectors):
+         + ((-q1*q2-q2^2)/(q*q1^2-q2^2))*B[(0, 0, -1)] + ((q1*q2+q2^2)/(-q*q1^2+q2^2))*B[(0, 0, 1)]
+ 
+         sage: E[-omega[1]-omega[2]]
+-        ((-q^3*q1^6-q^3*q1^5*q2-2*q^2*q1^6-3*q^2*q1^5*q2+q^2*q1^4*q2^2+2*q^2*q1^3*q2^3+q*q1^5*q2+2*q*q1^4*q2^2-q*q1^3*q2^3-2*q*q1^2*q2^4+q*q1*q2^5+q*q2^6-q1^3*q2^3-q1^2*q2^4+2*q1*q2^5+2*q2^6)/(-q^4*q1^6-q^3*q1^5*q2+q^3*q1^4*q2^2-q*q1^2*q2^4+q*q1*q2^5+q2^6))*B[(0, 0, 0)] + B[(-1, -1, 0)]
+-        + ((q*q1^4+q*q1^3*q2+q1*q2^3+q2^4)/(q^3*q1^4+q^2*q1^3*q2+q*q1*q2^3+q2^4))*B[(-1, 1, 0)] + ((q1+q2)/(q*q1+q2))*B[(-1, 0, -1)] + ((-q1-q2)/(-q*q1-q2))*B[(-1, 0, 1)]
+-        + ((q*q1^4+q*q1^3*q2+q1*q2^3+q2^4)/(q^3*q1^4+q^2*q1^3*q2+q*q1*q2^3+q2^4))*B[(1, -1, 0)]
+-        + ((-q^2*q1^6-q^2*q1^5*q2-q*q1^5*q2+q*q1^3*q2^3+q1^5*q2+q1^4*q2^2-q1^3*q2^3-q1^2*q2^4+q1*q2^5+q2^6)/(-q^4*q1^6-q^3*q1^5*q2+q^3*q1^4*q2^2-q*q1^2*q2^4+q*q1*q2^5+q2^6))*B[(1, 1, 0)]
+-        + ((-q*q1^4-2*q*q1^3*q2-q*q1^2*q2^2+q1^3*q2+q1^2*q2^2-q1*q2^3-q2^4)/(-q^3*q1^4-q^2*q1^3*q2-q*q1*q2^3-q2^4))*B[(1, 0, -1)]
+-        + ((-q*q1^4-2*q*q1^3*q2-q*q1^2*q2^2+q1^3*q2+q1^2*q2^2-q1*q2^3-q2^4)/(-q^3*q1^4-q^2*q1^3*q2-q*q1*q2^3-q2^4))*B[(1, 0, 1)] + ((q1+q2)/(q*q1+q2))*B[(0, -1, -1)]
+-        + ((-q1-q2)/(-q*q1-q2))*B[(0, -1, 1)] + ((q*q1^4+2*q*q1^3*q2+q*q1^2*q2^2-q1^3*q2-q1^2*q2^2+q1*q2^3+q2^4)/(q^3*q1^4+q^2*q1^3*q2+q*q1*q2^3+q2^4))*B[(0, 1, -1)]
+-        + ((q*q1^4+2*q*q1^3*q2+q*q1^2*q2^2-q1^3*q2-q1^2*q2^2+q1*q2^3+q2^4)/(q^3*q1^4+q^2*q1^3*q2+q*q1*q2^3+q2^4))*B[(0, 1, 1)]
++        ((q^3*q1^6+q^3*q1^5*q2+2*q^2*q1^6+3*q^2*q1^5*q2-q^2*q1^4*q2^2-2*q^2*q1^3*q2^3-q*q1^5*q2-2*q*q1^4*q2^2+q*q1^3*q2^3+2*q*q1^2*q2^4-q*q1*q2^5-q*q2^6+q1^3*q2^3+q1^2*q2^4-2*q1*q2^5-2*q2^6)/(q^4*q1^6+q^3*q1^5*q2-q^3*q1^4*q2^2+q*q1^2*q2^4-q*q1*q2^5-q2^6))*B[(0, 0, 0)] + B[(-1, -1, 0)] + ((q*q1^4+q*q1^3*q2+q1*q2^3+q2^4)/(q^3*q1^4+q^2*q1^3*q2+q*q1*q2^3+q2^4))*B[(-1, 1, 0)] + ((q1+q2)/(q*q1+q2))*B[(-1, 0, -1)] + ((-q1-q2)/(-q*q1-q2))*B[(-1, 0, 1)] + ((q*q1^4+q*q1^3*q2+q1*q2^3+q2^4)/(q^3*q1^4+q^2*q1^3*q2+q*q1*q2^3+q2^4))*B[(1, -1, 0)] + ((q^2*q1^6+q^2*q1^5*q2+q*q1^5*q2-q*q1^3*q2^3-q1^5*q2-q1^4*q2^2+q1^3*q2^3+q1^2*q2^4-q1*q2^5-q2^6)/(q^4*q1^6+q^3*q1^5*q2-q^3*q1^4*q2^2+q*q1^2*q2^4-q*q1*q2^5-q2^6))*B[(1, 1, 0)] + ((q*q1^4+2*q*q1^3*q2+q*q1^2*q2^2-q1^3*q2-q1^2*q2^2+q1*q2^3+q2^4)/(q^3*q1^4+q^2*q1^3*q2+q*q1*q2^3+q2^4))*B[(1, 0, -1)] + ((q*q1^4+2*q*q1^3*q2+q*q1^2*q2^2-q1^3*q2-q1^2*q2^2+q1*q2^3+q2^4)/(q^3*q1^4+q^2*q1^3*q2+q*q1*q2^3+q2^4))*B[(1, 0, 1)] + ((q1+q2)/(q*q1+q2))*B[(0, -1, -1)] + ((q1
 +q2)/(q*q1+q2))*B[(0, -1, 1)] + ((q*q1^4+2*q*q1^3*q2+q*q1^2*q2^2-q1^3*q2-q1^2*q2^2+q1*q2^3+q2^4)/(q^3*q1^4+q^2*q1^3*q2+q*q1*q2^3+q2^4))*B[(0, 1, -1)] + ((q*q1^4+2*q*q1^3*q2+q*q1^2*q2^2-q1^3*q2-q1^2*q2^2+q1*q2^3+q2^4)/(q^3*q1^4+q^2*q1^3*q2+q*q1*q2^3+q2^4))*B[(0, 1, 1)]
+ 
+         sage: E[omega[1]-omega[2]]
+         ((q^3*q1^7+q^3*q1^6*q2-q*q1*q2^6-q*q2^7)/(q^3*q1^7-q^2*q1^5*q2^2+q*q1^2*q2^5-q2^7))*B[(0, 0, 0)] + B[(1, -1, 0)]
+@@ -812,7 +804,7 @@ class NonSymmetricMacdonaldPolynomials(CherednikOperatorsEigenvectors):
+         ((-q*q1*q2^3-q*q2^4)/(q^2*q1^4-q2^4))*B[(0, 0)] + B[(1, 0)]
+ 
+         sage: E[2*omega[2]]      # long time # not checked against Bogdan's notes, but a good self-consistency test
+-        ((-q^12*q1^6-q^12*q1^5*q2+2*q^10*q1^5*q2+5*q^10*q1^4*q2^2+3*q^10*q1^3*q2^3+2*q^8*q1^5*q2+4*q^8*q1^4*q2^2+q^8*q1^3*q2^3-q^8*q1^2*q2^4+q^8*q1*q2^5+q^8*q2^6-q^6*q1^3*q2^3+q^6*q1^2*q2^4+4*q^6*q1*q2^5+2*q^6*q2^6+q^4*q1^3*q2^3+3*q^4*q1^2*q2^4+4*q^4*q1*q2^5+2*q^4*q2^6)/(-q^12*q1^6-q^10*q1^5*q2-q^8*q1^3*q2^3+q^6*q1^4*q2^2-q^6*q1^2*q2^4+q^4*q1^3*q2^3+q^2*q1*q2^5+q2^6))*B[(0, 0)] + ((q^7*q1^2*q2+2*q^7*q1*q2^2+q^7*q2^3+q^5*q1^2*q2+2*q^5*q1*q2^2+q^5*q2^3)/(-q^8*q1^3-q^6*q1^2*q2+q^2*q1*q2^2+q2^3))*B[(-1, 0)] + ((q^6*q1*q2+q^6*q2^2)/(-q^6*q1^2+q2^2))*B[(-1, -1)] + ((q^6*q1^2*q2+2*q^6*q1*q2^2+q^6*q2^3+q^4*q1^2*q2+2*q^4*q1*q2^2+q^4*q2^3)/(-q^8*q1^3-q^6*q1^2*q2+q^2*q1*q2^2+q2^3))*B[(-1, 1)] + ((q^3*q1*q2+q^3*q2^2)/(-q^6*q1^2+q2^2))*B[(-1, 2)] + ((-q^7*q1^3-q^7*q1^2*q2+q^7*q1*q2^2+q^7*q2^3+2*q^5*q1^2*q2+4*q^5*q1*q2^2+2*q^5*q2^3+2*q^3*q1^2*q2+4*q^3*q1*q2^2+2*q^3*q2^3)/(-q^8*q1^3-q^6*q1^2*q2+q^2*q1*q2^2+q2^3))*B[(1, 0)] + ((-q^6*q1^2*q2-2*q^6*q1*q2^2-q^6*q2^3-q^4*q1^2*q2-2*q^4*q1*q2^2-q^4*q2^3
 )/(q^8*q1^3+q^6*q1^2*q2-q^2*q1*q2^2-q2^3))*B[(1, -1)] + ((q^8*q1^3+q^8*q1^2*q2+q^6*q1^3+q^6*q1^2*q2-q^6*q1*q2^2-q^6*q2^3-2*q^4*q1^2*q2-4*q^4*q1*q2^2-2*q^4*q2^3-q^2*q1^2*q2-3*q^2*q1*q2^2-2*q^2*q2^3)/(q^8*q1^3+q^6*q1^2*q2-q^2*q1*q2^2-q2^3))*B[(1, 1)] + ((-q^5*q1^2-q^5*q1*q2+q^3*q1*q2+q^3*q2^2+q*q1*q2+q*q2^2)/(-q^6*q1^2+q2^2))*B[(1, 2)] + ((-q^6*q1^2-q^6*q1*q2+q^4*q1*q2+q^4*q2^2+q^2*q1*q2+q^2*q2^2)/(-q^6*q1^2+q2^2))*B[(2, 0)] + ((q^3*q1*q2+q^3*q2^2)/(-q^6*q1^2+q2^2))*B[(2, -1)] + ((-q^5*q1^2-q^5*q1*q2+q^3*q1*q2+q^3*q2^2+q*q1*q2+q*q2^2)/(-q^6*q1^2+q2^2))*B[(2, 1)] + B[(2, 2)] + ((-q^7*q1^2*q2-2*q^7*q1*q2^2-q^7*q2^3-q^5*q1^2*q2-2*q^5*q1*q2^2-q^5*q2^3)/(q^8*q1^3+q^6*q1^2*q2-q^2*q1*q2^2-q2^3))*B[(0, -1)] + ((q^7*q1^3+q^7*q1^2*q2-q^7*q1*q2^2-q^7*q2^3-2*q^5*q1^2*q2-4*q^5*q1*q2^2-2*q^5*q2^3-2*q^3*q1^2*q2-4*q^3*q1*q2^2-2*q^3*q2^3)/(q^8*q1^3+q^6*q1^2*q2-q^2*q1*q2^2-q2^3))*B[(0, 1)] + ((-q^6*q1^2-q^6*q1*q2+q^4*q1*q2+q^4*q2^2+q^2*q1*q2+q^2*q2^2)/(-q^6*q1^2+q2^2))*B[(0, 2)]
++        ((-q^12*q1^6-q^12*q1^5*q2+2*q^10*q1^5*q2+5*q^10*q1^4*q2^2+3*q^10*q1^3*q2^3+2*q^8*q1^5*q2+4*q^8*q1^4*q2^2+q^8*q1^3*q2^3-q^8*q1^2*q2^4+q^8*q1*q2^5+q^8*q2^6-q^6*q1^3*q2^3+q^6*q1^2*q2^4+4*q^6*q1*q2^5+2*q^6*q2^6+q^4*q1^3*q2^3+3*q^4*q1^2*q2^4+4*q^4*q1*q2^5+2*q^4*q2^6)/(-q^12*q1^6-q^10*q1^5*q2-q^8*q1^3*q2^3+q^6*q1^4*q2^2-q^6*q1^2*q2^4+q^4*q1^3*q2^3+q^2*q1*q2^5+q2^6))*B[(0, 0)] + ((q^7*q1^2*q2+2*q^7*q1*q2^2+q^7*q2^3+q^5*q1^2*q2+2*q^5*q1*q2^2+q^5*q2^3)/(-q^8*q1^3-q^6*q1^2*q2+q^2*q1*q2^2+q2^3))*B[(-1, 0)] + ((-q^6*q1*q2-q^6*q2^2)/(q^6*q1^2-q2^2))*B[(-1, -1)] + ((q^6*q1^2*q2+2*q^6*q1*q2^2+q^6*q2^3+q^4*q1^2*q2+2*q^4*q1*q2^2+q^4*q2^3)/(-q^8*q1^3-q^6*q1^2*q2+q^2*q1*q2^2+q2^3))*B[(-1, 1)] + ((-q^3*q1*q2-q^3*q2^2)/(q^6*q1^2-q2^2))*B[(-1, 2)] + ((q^7*q1^3+q^7*q1^2*q2-q^7*q1*q2^2-q^7*q2^3-2*q^5*q1^2*q2-4*q^5*q1*q2^2-2*q^5*q2^3-2*q^3*q1^2*q2-4*q^3*q1*q2^2-2*q^3*q2^3)/(q^8*q1^3+q^6*q1^2*q2-q^2*q1*q2^2-q2^3))*B[(1, 0)] + ((q^6*q1^2*q2+2*q^6*q1*q2^2+q^6*q2^3+q^4*q1^2*q2+2*q^4*q1*q2^2+q^4*q2^3)/(
 -q^8*q1^3-q^6*q1^2*q2+q^2*q1*q2^2+q2^3))*B[(1, -1)] + ((q^8*q1^3+q^8*q1^2*q2+q^6*q1^3+q^6*q1^2*q2-q^6*q1*q2^2-q^6*q2^3-2*q^4*q1^2*q2-4*q^4*q1*q2^2-2*q^4*q2^3-q^2*q1^2*q2-3*q^2*q1*q2^2-2*q^2*q2^3)/(q^8*q1^3+q^6*q1^2*q2-q^2*q1*q2^2-q2^3))*B[(1, 1)] + ((q^5*q1^2+q^5*q1*q2-q^3*q1*q2-q^3*q2^2-q*q1*q2-q*q2^2)/(q^6*q1^2-q2^2))*B[(1, 2)] + ((-q^6*q1^2-q^6*q1*q2+q^4*q1*q2+q^4*q2^2+q^2*q1*q2+q^2*q2^2)/(-q^6*q1^2+q2^2))*B[(2, 0)] + ((-q^3*q1*q2-q^3*q2^2)/(q^6*q1^2-q2^2))*B[(2, -1)] + ((-q^5*q1^2-q^5*q1*q2+q^3*q1*q2+q^3*q2^2+q*q1*q2+q*q2^2)/(-q^6*q1^2+q2^2))*B[(2, 1)] + B[(2, 2)] + ((q^7*q1^2*q2+2*q^7*q1*q2^2+q^7*q2^3+q^5*q1^2*q2+2*q^5*q1*q2^2+q^5*q2^3)/(-q^8*q1^3-q^6*q1^2*q2+q^2*q1*q2^2+q2^3))*B[(0, -1)] + ((q^7*q1^3+q^7*q1^2*q2-q^7*q1*q2^2-q^7*q2^3-2*q^5*q1^2*q2-4*q^5*q1*q2^2-2*q^5*q2^3-2*q^3*q1^2*q2-4*q^3*q1*q2^2-2*q^3*q2^3)/(q^8*q1^3+q^6*q1^2*q2-q^2*q1*q2^2-q2^3))*B[(0, 1)] + ((q^6*q1^2+q^6*q1*q2-q^4*q1*q2-q^4*q2^2-q^2*q1*q2-q^2*q2^2)/(q^6*q1^2-q2^2))*B[(0, 2)]
+         sage: E.recursion(2*omega[2])
+         [0, 1, 0, 2, 1, 0, 2, 1, 0]
+ 
+@@ -997,7 +989,7 @@ class NonSymmetricMacdonaldPolynomials(CherednikOperatorsEigenvectors):
+         sage: L0 = E.keys()
+         sage: omega = L0.fundamental_weights()
+         sage: E[2*omega[2]]
+-        ((q*q1+q*q2)/(q*q1+q2))*B[(1, 2, 1)] + ((q*q1+q*q2)/(q*q1+q2))*B[(2, 1, 1)] + B[(2, 2, 0)]
++        ((-q*q1-q*q2)/(-q*q1-q2))*B[(1, 2, 1)] + ((-q*q1-q*q2)/(-q*q1-q2))*B[(2, 1, 1)] + B[(2, 2, 0)]
+         sage: for d in range(4):                                    # long time (9s)
+         ....:     for weight in IntegerVectors(d,3).map(list).map(L0):
+         ....:         eigenvalues = E.eigenvalues(E[L0(weight)])
+diff --git a/src/sage/combinat/sf/macdonald.py b/src/sage/combinat/sf/macdonald.py
+index e664e21..cc525b4 100644
+--- a/src/sage/combinat/sf/macdonald.py
++++ b/src/sage/combinat/sf/macdonald.py
+@@ -483,7 +483,7 @@ class Macdonald(UniqueRepresentation):
+             sage: Ht = Sym.macdonald().Ht()
+             sage: s = Sym.schur()
+             sage: Ht(s([2,1]))
+-            ((-q)/(-q*t^2+t^3+q^2-q*t))*McdHt[1, 1, 1] + ((q^2+q*t+t^2)/(-q^2*t^2+q^3+t^3-q*t))*McdHt[2, 1] + (t/(-q^3+q^2*t+q*t-t^2))*McdHt[3]
++            (q/(q*t^2-t^3-q^2+q*t))*McdHt[1, 1, 1] + ((-q^2-q*t-t^2)/(q^2*t^2-q^3-t^3+q*t))*McdHt[2, 1] + (t/(-q^3+q^2*t+q*t-t^2))*McdHt[3]
+             sage: Ht(s([2]))
+             ((-q)/(-q+t))*McdHt[1, 1] + (t/(-q+t))*McdHt[2]
+         """
+@@ -901,7 +901,7 @@ class MacdonaldPolynomials_generic(sfa.SymmetricFunctionAlgebra_generic):
+             sage: Q._multiply(Q[1],Q[2])
+             McdQ[2, 1] + ((q^2*t-q^2+q*t-q+t-1)/(q^2*t-1))*McdQ[3]
+             sage: Ht._multiply(Ht[1],Ht[2])
+-            ((-q^2+1)/(-q^2+t))*McdHt[2, 1] + ((-t+1)/(q^2-t))*McdHt[3]
++            ((q^2-1)/(q^2-t))*McdHt[2, 1] + ((t-1)/(-q^2+t))*McdHt[3]
+         """
+         return self( self._s(left)*self._s(right) )
+ 
+diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py
+index 88a33b0..a7cf5ea 100644
+--- a/src/sage/interfaces/singular.py
++++ b/src/sage/interfaces/singular.py
+@@ -191,13 +191,21 @@ The 1x1 and 2x2 minors::
+     6*y+2*x^3-6*x^2*y,
+     6*x^2*y-6*x*y^2,
+     6*x^2*y-6*x*y^2,
+-    6*x+6*x*y^2-2*y^3
++    6*x+6*x*y^2-2*y^3,
++    0,
++    0,
++    0,
++    0
+     sage: H.minor(2)
+     12*y+4*x^3-12*x^2*y,
+     12*x^2*y-12*x*y^2,
+     12*x^2*y-12*x*y^2,
+     12*x+12*x*y^2-4*y^3,
+-    -36*x*y-12*x^4+36*x^3*y-36*x*y^3+12*y^4+24*x^4*y^2-32*x^3*y^3+24*x^2*y^4
++    -36*x*y-12*x^4+36*x^3*y-36*x*y^3+12*y^4+24*x^4*y^2-32*x^3*y^3+24*x^2*y^4,
++    0,
++    0,
++    0,
++    0
+ 
+ ::
+ 
+diff --git a/src/sage/libs/singular/function.pyx b/src/sage/libs/singular/function.pyx
+index 0fea70a..26c74d0 100644
+--- a/src/sage/libs/singular/function.pyx
++++ b/src/sage/libs/singular/function.pyx
+@@ -1257,7 +1257,7 @@ cdef class SingularFunction(SageObject):
+             Traceback (most recent call last):
+             ...
+             RuntimeError: error in Singular function call 'size':
+-            Wrong number of arguments (got 2 arguments, arity code is 300)
++            Wrong number of arguments (got 2 arguments, arity code is 302)
+             sage: size('foobar', ring=P)
+             6
+ 
+@@ -1308,7 +1308,7 @@ cdef class SingularFunction(SageObject):
+             ...
+             RuntimeError: error in Singular function call 'triangL':
+             The input is no groebner basis.
+-            leaving triang.lib::triangL
++            leaving triang.lib::triangL (0)
+ 
+         Flush any stray output -- see :trac:`28622`::
+ 
+@@ -1671,17 +1671,17 @@ def singular_function(name):
+         Traceback (most recent call last):
+         ...
+         RuntimeError: error in Singular function call 'factorize':
+-        Wrong number of arguments (got 0 arguments, arity code is 303)
++        Wrong number of arguments (got 0 arguments, arity code is 305)
+         sage: factorize(f, 1, 2)
+         Traceback (most recent call last):
+         ...
+         RuntimeError: error in Singular function call 'factorize':
+-        Wrong number of arguments (got 3 arguments, arity code is 303)
++        Wrong number of arguments (got 3 arguments, arity code is 305)
+         sage: factorize(f, 1, 2, 3)
+         Traceback (most recent call last):
+         ...
+         RuntimeError: error in Singular function call 'factorize':
+-        Wrong number of arguments (got 4 arguments, arity code is 303)
++        Wrong number of arguments (got 4 arguments, arity code is 305)
+ 
+     The Singular function ``list`` can be called with any number of
+     arguments::
+diff --git a/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py b/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py
+index 8b9367e..ef04d4f 100644
+--- a/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py
++++ b/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py
+@@ -1579,7 +1579,7 @@ class FractionWithFactoredDenominator(RingElement):
+             (1, [(x*y + x + y - 1, 2)])
+             sage: alpha = [4, 3]
+             sage: decomp = F.asymptotic_decomposition(alpha); decomp
+-            (0, []) + (-3/2*r*(1/y + 1) - 1/2/y - 1/2, [(x*y + x + y - 1, 1)])
++            (0, []) + (-2*r*(1/x + 1) - 1/2/x - 1/2, [(x*y + x + y - 1, 1)])
+             sage: F1 = decomp[1]
+             sage: p = {y: 1/3, x: 1/2}
+             sage: asy = F1.asymptotics(p, alpha, 2, verbose=True)
+@@ -1613,7 +1613,7 @@ class FractionWithFactoredDenominator(RingElement):
+             sage: alpha = [3, 3, 2]
+             sage: decomp = F.asymptotic_decomposition(alpha); decomp
+             (0, []) +
+-            (-16*r*(3/y - 4/z) - 16/y + 32/z,
++            (16*r*(3/x - 2/z) + 16/x - 16/z,
+              [(x + 2*y + z - 4, 1), (2*x + y + z - 4, 1)])
+             sage: F1 = decomp[1]
+             sage: p = {x: 1, y: 1, z: 1}
+diff --git a/src/sage/rings/polynomial/multi_polynomial_element.py b/src/sage/rings/polynomial/multi_polynomial_element.py
+index d86833f..3742439 100644
+--- a/src/sage/rings/polynomial/multi_polynomial_element.py
++++ b/src/sage/rings/polynomial/multi_polynomial_element.py
+@@ -2231,7 +2231,7 @@ def degree_lowest_rational_function(r, x):
+     ::
+ 
+         sage: r = f/g; r
+-        (-b*c^2 + 2)/(a*b^3*c^6 - 2*a*c)
++        (-2*b*c^2 - 1)/(2*a*b^3*c^6 + a*c)
+         sage: degree_lowest_rational_function(r,a)
+         -1
+         sage: degree_lowest_rational_function(r,b)
+diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py
+index f025b3a..94e130d 100644
+--- a/src/sage/rings/polynomial/multi_polynomial_ideal.py
++++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py
+@@ -154,7 +154,7 @@ when the system has no solutions over the rationals.
+     which is not 1. ::
+ 
+         sage: I.groebner_basis()
+-        [x + 130433*y + 59079*z, y^2 + 3*y + 17220, y*z + 5*y + 14504, 2*y + 158864, z^2 + 17223, 2*z + 41856, 164878]
++        [x + y + 57119*z + 4, y^2 + 3*y + 17220, y*z + y + 26532, 2*y + 158864, z^2 + 17223, 2*z + 41856, 164878]
+ 
+     Now for each prime `p` dividing this integer 164878, the Groebner
+     basis of I modulo `p` will be non-trivial and will thus give a
+@@ -1567,8 +1567,8 @@ class MPolynomialIdeal_singular_repr(
+             sage: I2 = y*R
+             sage: I3 = (x, y)*R
+             sage: I4 = (x^2 + x*y*z, y^2 - z^3*y, z^3 + y^5*x*z)*R
+-            sage: I1.intersection(I2, I3, I4)
+-            Ideal (x*y*z^20 - x*y*z^3, x*y^2 - x*y*z^3, x^2*y + x*y*z^4) of Multivariate Polynomial Ring in x, y, z over Rational Field
++            sage: I1.intersection(I2, I3, I4).groebner_basis()
++            [x^2*y + x*y*z^4, x*y^2 - x*y*z^3, x*y*z^20 - x*y*z^3]
+ 
+         The ideals must share the same ring::
+ 
+@@ -4008,7 +4008,7 @@ class MPolynomialIdeal( MPolynomialIdeal_singular_repr, \
+ 
+             sage: J.groebner_basis.set_cache(gb)
+             sage: ideal(J.transformed_basis()).change_ring(P).interreduced_basis()  # testing trac 21884
+-            [a - 60*c^3 + 158/7*c^2 + 8/7*c - 1, b + 30*c^3 - 79/7*c^2 + 3/7*c, c^4 - 10/21*c^3 + 1/84*c^2 + 1/84*c]
++            ...[a - 60*c^3 + 158/7*c^2 + 8/7*c - 1, b + 30*c^3 - 79/7*c^2 + 3/7*c, c^4 - 10/21*c^3 + 1/84*c^2 + 1/84*c]
+ 
+         Giac's gbasis over `\QQ` can benefit from a probabilistic lifting and
+         multi threaded operations::
+@@ -4111,9 +4111,9 @@ class MPolynomialIdeal( MPolynomialIdeal_singular_repr, \
+             sage: P.<a,b,c> = PolynomialRing(ZZ,3)
+             sage: I = P * (a + 2*b + 2*c - 1, a^2 - a + 2*b^2 + 2*c^2, 2*a*b + 2*b*c - b)
+             sage: I.groebner_basis()
+-            [b^3 - 181*b*c^2 + 222*c^3 - 26*b*c - 146*c^2 + 19*b + 24*c,
+-             2*b*c^2 - 48*c^3 + 3*b*c + 22*c^2 - 2*b - 2*c,
+-             42*c^3 + 45*b^2 + 54*b*c + 22*c^2 - 13*b - 12*c,
++            [b^3 + b*c^2 + 12*c^3 + b^2 + b*c - 4*c^2,
++             2*b*c^2 - 6*c^3 - b^2 - b*c + 2*c^2,
++             42*c^3 + b^2 + 2*b*c - 14*c^2 + b,
+              2*b^2 + 6*b*c + 6*c^2 - b - 2*c,
+              10*b*c + 12*c^2 - b - 4*c,
+              a + 2*b + 2*c - 1]
+diff --git a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx
+index 1758424..553d22d 100644
+--- a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx
++++ b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx
+@@ -1349,7 +1349,7 @@ cdef class MPolynomialRing_libsingular(MPolynomialRing_base):
+             sage: R = IntegerModRing(15)['x,y']
+             sage: singular(R)
+             polynomial ring, over a ring (with zero-divisors), global ordering
+-            //   coefficients: ZZ/bigint(15)
++            //   coefficients: ZZ/...(15)
+             //   number of vars : 2
+             //        block   1 : ordering dp
+             //                  : names    x y
+diff --git a/src/sage/rings/polynomial/plural.pyx b/src/sage/rings/polynomial/plural.pyx
+index c2792ae..aa2ef59 100644
+--- a/src/sage/rings/polynomial/plural.pyx
++++ b/src/sage/rings/polynomial/plural.pyx
+@@ -390,28 +390,30 @@ cdef class NCPolynomialRing_plural(Ring):
+         TESTS:
+ 
+         This example caused a segmentation fault with a previous version
+-        of this method::
++        of this method. This doctest still results in a segmentation fault
++        occasionally which is difficult to isolate, so this test is partially
++        disabled (:trac:`29528`)::
+ 
+             sage: import gc
+             sage: from sage.rings.polynomial.plural import NCPolynomialRing_plural
+             sage: from sage.algebras.free_algebra import FreeAlgebra
+             sage: A1.<x,y,z> = FreeAlgebra(QQ, 3)
+             sage: R1 = A1.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}, order=TermOrder('degrevlex', 2))
+-            sage: A2.<x,y,z> = FreeAlgebra(GF(5), 3)
+-            sage: R2 = A2.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}, order=TermOrder('degrevlex', 2))
+-            sage: A3.<x,y,z> = FreeAlgebra(GF(11), 3)
+-            sage: R3 = A3.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}, order=TermOrder('degrevlex', 2))
+-            sage: A4.<x,y,z> = FreeAlgebra(GF(13), 3)
+-            sage: R4 = A4.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}, order=TermOrder('degrevlex', 2))
++            sage: A2.<x,y,z> = FreeAlgebra(GF(5), 3)                                                         # not tested
++            sage: R2 = A2.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}, order=TermOrder('degrevlex', 2))  # not tested
++            sage: A3.<x,y,z> = FreeAlgebra(GF(11), 3)                                                        # not tested
++            sage: R3 = A3.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}, order=TermOrder('degrevlex', 2))  # not tested
++            sage: A4.<x,y,z> = FreeAlgebra(GF(13), 3)                                                        # not tested
++            sage: R4 = A4.g_algebra({y*x:x*y-z, z*x:x*z+2*x, z*y:y*z-2*y}, order=TermOrder('degrevlex', 2))  # not tested
+             sage: _ = gc.collect()
+             sage: foo = R1.gen(0)
+             sage: del foo
+             sage: del R1
+             sage: _ = gc.collect()
+-            sage: del R2
+-            sage: _ = gc.collect()
+-            sage: del R3
+-            sage: _ = gc.collect()
++            sage: del R2            # not tested
++            sage: _ = gc.collect()  # not tested
++            sage: del R3            # not tested
++            sage: _ = gc.collect()  # not tested
+         """
+         singular_ring_delete(self._ring)
+ 
+@@ -2886,7 +2888,8 @@ cpdef MPolynomialRing_libsingular new_CRing(RingWrap rw, base_ring):
+     self.__ngens = rw.ngens()
+     self.__term_order =  TermOrder(rw.ordering_string(), force=True)
+ 
+-    ParentWithGens.__init__(self, base_ring, rw.var_names())
++    ParentWithGens.__init__(self, base_ring, tuple(rw.var_names()),
++                            normalize=False)
+ #    self._populate_coercion_lists_()  # ???
+ 
+     #MPolynomialRing_generic.__init__(self, base_ring, n, names, order)
+diff --git a/src/sage/rings/polynomial/polynomial_singular_interface.py b/src/sage/rings/polynomial/polynomial_singular_interface.py
+index 74b8b82..beee5ad 100644
+--- a/src/sage/rings/polynomial/polynomial_singular_interface.py
++++ b/src/sage/rings/polynomial/polynomial_singular_interface.py
+@@ -165,7 +165,7 @@ class PolynomialRing_singular_repr:
+             sage: R = IntegerModRing(15)['x,y']
+             sage: singular(R)
+             polynomial ring, over a ring (with zero-divisors), global ordering
+-            //   coefficients: ZZ/bigint(15)
++            //   coefficients: ZZ/...(15)
+             //   number of vars : 2
+             //        block   1 : ordering dp
+             //                  : names    x y
+diff --git a/src/sage/schemes/curves/projective_curve.py b/src/sage/schemes/curves/projective_curve.py
+index 1091c29..4f5936e 100644
+--- a/src/sage/schemes/curves/projective_curve.py
++++ b/src/sage/schemes/curves/projective_curve.py
+@@ -2001,7 +2001,7 @@ class ProjectivePlaneCurve_finite_field(ProjectivePlaneCurve_field):
+             sage: C = Curve(f); pts = C.rational_points()
+             sage: D = C.divisor([ (3, pts[0]), (-1,pts[1]), (10, pts[5]) ])
+             sage: C.riemann_roch_basis(D)
+-            [(-x - 2*y)/(-2*x - 2*y), (-x + z)/(x + y)]
++            [(-2*x + y)/(x + y), (-x + z)/(x + y)]
+ 
+         .. NOTE::
+ 

Copied: sagemath/repos/community-testing-x86_64/test-optional.patch (from rev 749409, sagemath/trunk/test-optional.patch)
===================================================================
--- community-testing-x86_64/test-optional.patch	                        (rev 0)
+++ community-testing-x86_64/test-optional.patch	2020-11-10 07:32:08 UTC (rev 749410)
@@ -0,0 +1,25 @@
+diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py
+index 2d93841e50..937e20cd2e 100644
+--- a/src/sage/doctest/control.py
++++ b/src/sage/doctest/control.py
+@@ -356,20 +356,6 @@ class DocTestController(SageObject):
+                 # Special case to run all optional tests
+                 options.optional = True
+             else:
+-                # We replace the 'optional' tag by all optional
+-                # packages for which the installed version matches the
+-                # latest available version (this implies in particular
+-                # that the package is actually installed).
+-                if 'optional' in options.optional:
+-                    options.optional.discard('optional')
+-                    from sage.misc.package import list_packages
+-                    for pkg in list_packages('optional', local=True).values():
+-                        if pkg['installed'] and pkg['installed_version'] == pkg['remote_version']:
+-                            options.optional.add(pkg['name'])
+-
+-                    from sage.features import package_systems
+-                    options.optional.update(system.name for system in package_systems())
+-
+                 # Check that all tags are valid
+                 for o in options.optional:
+                     if not optionaltag_regex.search(o):



More information about the arch-commits mailing list