Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] DRAFT: sagemath update to 9.7
@ 2022-10-10 22:19 tornaria
  2022-10-11 12:58 ` tornaria
                   ` (32 more replies)
  0 siblings, 33 replies; 34+ messages in thread
From: tornaria @ 2022-10-10 22:19 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1878 bytes --]

There is a new pull request by tornaria against master on the void-packages repository

https://github.com/tornaria/void-packages sagemath-update
https://github.com/void-linux/void-packages/pull/39876

DRAFT: sagemath update to 9.7
This includes #39838, #39840, #39846, #39872, #39866, also update eclib-20220621.

For now I'm reverting python3-matplotlib to 3.5.3_1 since 3.6.0_1 gives a lot of problems (#39857 adds python3-contourpy which will solve some, but I think there are more issues).

I want to make sure everything works ok and the full testsuite passes as is. Then I'll just move matplotlib back to 3.6.0_1 and try to see if it's feasible to fix or workaround the issues (sagemath-the-distro is still on matplotlib 3.5.2 and I didn't find anything about the update to 3.6.0)

<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: currently running the testsuite in --long after the update of singular.

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/39876.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-sagemath-update-39876.patch --]
[-- Type: text/x-diff, Size: 87463 bytes --]

From c3b0a33ec06b1487c484de4a359f3484dc92b272 Mon Sep 17 00:00:00 2001
From: dkwo <nicolopiazzalunga@gmail.com>
Date: Mon, 10 Oct 2022 10:14:06 -0400
Subject: [PATCH 1/9] singular: update to 4.3.1p2 (fix gcc 12 build)

---
 common/shlibs             | 10 +++++-----
 srcpkgs/singular/template | 11 +++++++----
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 9f95ac87a7ea..54141e4cd4ba 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4055,11 +4055,11 @@ libumfpack.so.5 SuiteSparse-5.10.1_1
 libecl.so.21.2 ecl-21.2.1_1
 libecm.so.1 ecm-7.0.4_3
 libcliquer.so.1 cliquer-1.22_1
-libSingular-4.3.0.so singular-4.3.0_1
-libfactory-4.3.0.so singular-4.3.0_1
-libpolys-4.3.0.so singular-4.3.0_1
-libomalloc-0.9.6.so singular-4.3.0_1
-libsingular_resources-4.3.0.so singular-4.3.0_1
+libSingular-4.3.1.so singular-4.3.1p2_1
+libfactory-4.3.1.so singular-4.3.1p2_1
+libpolys-4.3.1.so singular-4.3.1p2_1
+libomalloc-0.9.6.so singular-4.3.1p2_1
+libsingular_resources-4.3.1.so singular-4.3.1p2_1
 libbrial.so.3 brial-1.2.10_1
 libbrial_groebner.so.3 brial-1.2.10_1
 libm4ri-0.0.20200125.so m4ri-20200125_1
diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index f23659ef5d83..441a5ba56134 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,7 +1,10 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.0
+_patchver=p2
+_majver=4.3.1
+version=${_majver}${_patchver}
 revision=1
+wrksrc=singular-${_majver}
 build_style=gnu-configure
 configure_args="--with-readline=ncurses
 	--enable-gfanlib
@@ -15,11 +18,11 @@ configure_args="--with-readline=ncurses
 hostmakedepends="perl tar doxygen"
 makedepends="flintlib-devel cddlib-devel readline-devel graphviz"
 short_desc="Computer algebra system for polynomial computations"
-maintainer="dkwo <nicolopiazzalunga@gmail.com>"
+maintainer="dkwo <npiazza@disroot.org>"
 license="GPL-2.0-or-later"
 homepage="https://www.singular.uni-kl.de"
-distfiles="https://www.singular.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${version//./-}/singular-${version}.tar.gz"
-checksum=74f38288203720e3f280256f2f8deb94030dd032b4237d844652aff0faab36e7
+distfiles="https://www.singular.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${_majver//./-}/singular-${version}.tar.gz"
+checksum=95814bba0f0bd0290cd9799ec1d2ecc6f4c8a4e6429d9a02eb7f9c4e5649682a
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From aaef221ac6cefeb5905f813d0ac3976abbf5c647 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Sun, 9 Oct 2022 12:31:47 -0300
Subject: [PATCH 2/9] fplll: update to 5.4.2.

---
 srcpkgs/fplll/template | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/fplll/template b/srcpkgs/fplll/template
index 524ce18887f7..d38719bf8d4a 100644
--- a/srcpkgs/fplll/template
+++ b/srcpkgs/fplll/template
@@ -1,6 +1,6 @@
 # Template file for 'fplll'
 pkgname=fplll
-version=5.4.1
+version=5.4.2
 revision=1
 build_style=gnu-configure
 makedepends="gmp-devel mpfr-devel"
@@ -8,8 +8,9 @@ short_desc="Lattice algorithms using floating-point orthogonalization and LLL"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="LGPL-2.1-or-later"
 homepage="https://github.com/fplll/fplll"
+changelog="https://github.com/fplll/fplll/releases"
 distfiles="https://github.com/fplll/fplll/releases/download/${version}/fplll-${version}.tar.gz"
-checksum=7bd887957173aa592091772c1c36f6aa606b3b2ace0d14e2c26c7463dcf2deb7
+checksum=6e7b1704fd56f29dd9fc1dd719cc1f2df1f58964fd77bbde162f594d7fff7ba5
 
 if [ "$XBPS_TARGET_NO_ATOMIC8" ]; then
 	makedepends+=" libatomic-devel"

From 3afdfcf17bd2fad1e4b42e2f851507b0cced0b2d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 00:44:56 -0300
Subject: [PATCH 3/9] python3-sympy: update to 1.11.1.

---
 srcpkgs/python3-sympy/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/python3-sympy/template b/srcpkgs/python3-sympy/template
index 3bb4df3bffdf..4d0c76534ae3 100644
--- a/srcpkgs/python3-sympy/template
+++ b/srcpkgs/python3-sympy/template
@@ -1,6 +1,6 @@
 # Template file for 'python3-sympy'
 pkgname=python3-sympy
-version=1.10.1
+version=1.11.1
 revision=1
 wrksrc="sympy-${version}"
 build_style=python3-module
@@ -12,7 +12,7 @@ maintainer="Alessio Sergi <al3hex@gmail.com>"
 license="BSD-3-Clause"
 homepage="https://sympy.org/"
 distfiles="${PYPI_SITE}/s/sympy/sympy-${version}.tar.gz"
-checksum=5939eeffdf9e152172601463626c022a2c27e75cf6278de8d401d50c9d58787b
+checksum=e32380dce63cb7c0108ed525570092fd45168bdae2faa17e528221ef72e88658
 
 post_install() {
 	vman doc/man/isympy.1

From dce38d7ae301e6645bf97db4af9aee2489462236 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Fri, 23 Sep 2022 16:42:40 -0300
Subject: [PATCH 4/9] eclib: update to 20220621.

---
 common/shlibs          | 2 +-
 srcpkgs/eclib/template | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 9f95ac87a7ea..4e924ccf375a 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4015,7 +4015,7 @@ libgf2x.so.3 gf2x-1.3.0_1
 libntl.so.44 ntl-11.5.1_1
 libflint.so.16 flintlib-2.8.0_1
 libarb.so.2 arb-2.20.0_1
-libec.so.8 eclib-20210625_1
+libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
 liblrcalc.so.2 lrcalc-2.1_1
diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 694a39ed4068..e33da0a859ca 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
-version=20210625
-revision=2
+version=20220621
+revision=1
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 hostmakedepends="automake autoconf-archive libtool"
@@ -11,7 +11,7 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="https://github.com/JohnCremona/eclib"
 distfiles="https://github.com/JohnCremona/eclib/archive/refs/tags/${version}.tar.gz"
-checksum=00333fd36afd237c9e6e410c7ab98536ddcd7fdc430e6837fe293247b835c572
+checksum=b0e06ffe6cd669354627eb1ff351cf558a4376dca1cf5c2d4ad042ae49fa5462
 
 pre_configure() {
 	autoreconf -fi

From 682f3e335e02f3d03e358ba13a9e48d3770dd0f6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Sun, 9 Oct 2022 19:58:13 -0300
Subject: [PATCH 5/9] Revert "python3-matplotlib: update to 3.6.0."

This reverts commit 4aacd2a636620b54534cb12e11b64d379237dfe6.
---
 .../patches/fix-setup.patch                   | 26 +++++++++++++++++++
 srcpkgs/python3-matplotlib/template           |  7 ++---
 2 files changed, 30 insertions(+), 3 deletions(-)
 create mode 100644 srcpkgs/python3-matplotlib/patches/fix-setup.patch

diff --git a/srcpkgs/python3-matplotlib/patches/fix-setup.patch b/srcpkgs/python3-matplotlib/patches/fix-setup.patch
new file mode 100644
index 000000000000..f987d97e4d57
--- /dev/null
+++ b/srcpkgs/python3-matplotlib/patches/fix-setup.patch
@@ -0,0 +1,26 @@
+The maximum version of setuptools_scm is pinned below 6 for no apparent reason
+and Void ships 7.x; remove the upper version restriction and also drop the
+requirement for setuptools_scm_git_archive that was originally patched out in
+the template.
+
+--- a/setup.py
++++ b/setup.py
+@@ -316,8 +316,7 @@
+     setup_requires=[
+         "certifi>=2020.06.20",
+         "numpy>=1.17",
+-        "setuptools_scm>=4,<7",
+-        "setuptools_scm_git_archive",
++        "setuptools_scm>=4",
+     ],
+     install_requires=[
+         "cycler>=0.10",
+@@ -330,7 +329,7 @@
+         "python-dateutil>=2.7",
+     ] + (
+         # Installing from a git checkout that is not producing a wheel.
+-        ["setuptools_scm>=4,<7"] if (
++        ["setuptools_scm>=4"] if (
+             Path(__file__).with_name(".git").exists() and
+             os.environ.get("CIBUILDWHEEL", "0") != "1"
+         ) else []
diff --git a/srcpkgs/python3-matplotlib/template b/srcpkgs/python3-matplotlib/template
index c48fd24d58d4..b71abf2aecd9 100644
--- a/srcpkgs/python3-matplotlib/template
+++ b/srcpkgs/python3-matplotlib/template
@@ -1,6 +1,7 @@
 # Template file for 'python3-matplotlib'
 pkgname=python3-matplotlib
-version=3.6.0
+reverts="3.5.2_1"
+version=3.5.3
 revision=1
 wrksrc="matplotlib-${version}"
 build_style=python3-module
@@ -13,8 +14,8 @@ short_desc="Python3 2D/3D plotting library"
 maintainer="Andrew J. Hesford <ajh@sideband.org>"
 license="custom:matplotlib, BSD-3-Clause, MIT"
 homepage="https://matplotlib.org/"
-distfiles="${PYPI_SITE}/m/matplotlib/matplotlib-${version}.tar.gz"
-checksum=c5108ebe67da60a9204497d8d403316228deb52b550388190c53a57394d41531
+distfiles="https://github.com/matplotlib/matplotlib/archive/v${version}.tar.gz"
+checksum=9d6ee7190fde3cb0c6285d462a0258c9735a72c7b532321a3983e05076aa41dc
 replaces="python3-matplotlib-data>=0"
 # Comparison of images is too frail for validation
 make_check="no"

From 74d4270dc68d8ab82a6344a81becb007be059498 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 00:49:01 -0300
Subject: [PATCH 6/9] sagemath: update to 9.7.

---
 .../patches/01-dont_link_ratpoints.patch      |  10 -
 ... => 02-fix_get_shared_lib_path--see_29644} |   0
 .../patches/03-doctest_have_program.patch     |  20 -
 .../patches/04-doctest_sage_getfile.patch     |  22 -
 .../patches/05-fix_sage_getfile.patch         |  16 -
 .../sagemath/patches/07-ignore_warning.patch  |  15 -
 ...24.patch => 08-dont_run_pytest--see_31924} |   0
 ...y_slow_doctest-polynomial_zmod_flint.patch |  14 -
 ...ry_slow_doctest-isogeny_small_degree.patch | 106 ---
 ...fix_very_slow_doctest-function_field.patch |  97 ---
 .../trac-31355-upgrade_lrcalc_to_2.1.patch    | 670 ------------------
 .../trac-33170-fix_doctest_ipython_8.patch    |  40 --
 .../trac-33170b-fix_doctest_ipython_8.1.patch |  13 -
 ...2ddd4e2dc92469c1590ebf0c40f8f69bf579.patch | 126 ----
 ...2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch |  40 --
 .../trac-33336-fix_doctest_scipy_1.8.patch    |  19 -
 ...cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch |  53 ++
 ...d9deaeaa6380ab2f0d50276d911233c00a04.patch |  99 ---
 ...ff347454ac7f07e5918470b20e97b8f2357e.patch |  29 -
 ...0a0b14f67f4804e7113c3db41bbcf8a58296.patch |  26 -
 ...d4e56243c609f44afc1f21c112b026f9e1fe.patch |  42 ++
 ...1318f032caf8dc1c0de9489346d894409091.patch |  19 +
 ...on.patch => zzz-loadable_module_extension} |   0
 srcpkgs/sagemath/template                     |  12 +-
 24 files changed, 120 insertions(+), 1368 deletions(-)
 delete mode 100644 srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
 rename srcpkgs/sagemath/patches/{02-fix_get_shared_lib_path--see_29644.patch => 02-fix_get_shared_lib_path--see_29644} (100%)
 delete mode 100644 srcpkgs/sagemath/patches/03-doctest_have_program.patch
 delete mode 100644 srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
 delete mode 100644 srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
 delete mode 100644 srcpkgs/sagemath/patches/07-ignore_warning.patch
 rename srcpkgs/sagemath/patches/{08-dont_run_pytest--see_31924.patch => 08-dont_run_pytest--see_31924} (100%)
 delete mode 100644 srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
 delete mode 100644 srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
 delete mode 100644 srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
 rename srcpkgs/sagemath/patches/{zzz-loadable_module_extension.patch => zzz-loadable_module_extension} (100%)

diff --git a/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch b/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
deleted file mode 100644
index e5c3f5776aa2..000000000000
--- a/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
+++ /dev/null
@@ -1,10 +0,0 @@
- - do not link ratpoints where it's not used
-
---- a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
-+++ b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
-@@ -1,5 +1,3 @@
--# distutils: libraries = ratpoints
--
- r"""
- Descent on elliptic curves over `\QQ` with a 2-isogeny
- """
diff --git a/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch b/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644
similarity index 100%
rename from srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
rename to srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644
diff --git a/srcpkgs/sagemath/patches/03-doctest_have_program.patch b/srcpkgs/sagemath/patches/03-doctest_have_program.patch
deleted file mode 100644
index 27ba3776470c..000000000000
--- a/srcpkgs/sagemath/patches/03-doctest_have_program.patch
+++ /dev/null
@@ -1,20 +0,0 @@
- - we don't know `SAGE_VENV/bin` contains `sage`, but `sys.argv[0]` should
-   be the full path to `sage-ipython` and the same directory should have `sage`
-
---- a/src/sage/misc/sage_ostools.pyx
-+++ b/src/sage/misc/sage_ostools.pyx
-@@ -32,12 +32,11 @@ def have_program(program, path=None):
-         True
-         sage: have_program('there_is_not_a_program_with_this_name')
-         False
--        sage: from sage.env import SAGE_VENV
--        sage: have_program('sage', os.path.join(SAGE_VENV, 'bin'))
-+        sage: have_program('sage', os.path.dirname(sys.argv[0]))
-         True
-         sage: have_program('sage', '/there_is_not_a_path_with_this_name')
-         False
--        sage: have_program('there_is_not_a_program_with_this_name', os.path.join(SAGE_VENV, 'bin'))
-+        sage: have_program('there_is_not_a_program_with_this_name', "/bin")
-         False
-     """
-     if path is None:
diff --git a/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch b/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
deleted file mode 100644
index 95bce107f854..000000000000
--- a/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
+++ /dev/null
@@ -1,22 +0,0 @@
- - add one doctest for coverage
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -1341,10 +1342,12 @@ def sage_getfile(obj):
-     EXAMPLES::
- 
-         sage: from sage.misc.sageinspect import sage_getfile
--        sage: sage_getfile(sage.rings.rational)[-23:]
--        'sage/rings/rational.pyx'
--        sage: sage_getfile(Sq)[-42:]
--        'sage/algebras/steenrod/steenrod_algebra.py'
-+        sage: sage_getfile(sage.rings.rational)
-+        '...sage/rings/rational.pyx'
-+        sage: sage_getfile(Sq)
-+        '...sage/algebras/steenrod/steenrod_algebra.py'
-+        sage: sage_getfile(x)
-+        '...sage/symbolic/expression.pyx'
- 
-     The following tests against some bugs fixed in :trac:`9976`::
- 
-
diff --git a/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch b/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
deleted file mode 100644
index 56c58078f319..000000000000
--- a/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
+++ /dev/null
@@ -1,16 +0,0 @@
- - fix sage_getfile() by checking all possible EXTENSION_SUFFIXES
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -1400,8 +1403,9 @@ def sage_getfile(obj):
-         sourcefile = inspect.getabsfile(obj)
-     except TypeError: # this happens for Python builtins
-         return ''
--    if sourcefile.endswith(loadable_module_extension()):
--        return sourcefile[:-len(loadable_module_extension())]+os.path.extsep+'pyx'
-+    for suffix in import_machinery.EXTENSION_SUFFIXES:
-+        if sourcefile.endswith(suffix):
-+            return sourcefile[:-len(suffix)]+os.path.extsep+'pyx'
-     return sourcefile
- 
- 
diff --git a/srcpkgs/sagemath/patches/07-ignore_warning.patch b/srcpkgs/sagemath/patches/07-ignore_warning.patch
deleted file mode 100644
index 69668678a40b..000000000000
--- a/srcpkgs/sagemath/patches/07-ignore_warning.patch
+++ /dev/null
@@ -1,15 +0,0 @@
- - this ignores a warning caused by old notebook
-
---- a/src/sage/all.py
-+++ b/src/sage/all.py
-@@ -100,6 +100,9 @@ warnings.filterwarnings('ignore', category=DeprecationWarning,
-                         message='The distutils(.sysconfig module| package) is deprecated',
-                         module='Cython|distutils|numpy|sage.env|sage.features')
- 
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"invalid escape sequence '\\s'")
-+
- ################ end setup warnings ###############################
- 
- 
-
diff --git a/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch b/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924
similarity index 100%
rename from srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
rename to srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924
diff --git a/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch b/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
deleted file mode 100644
index bae8387cf94a..000000000000
--- a/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
-+++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
-@@ -237,8 +237,9 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
- 
-             sage: a = ZZ['x'](range(100000))
-             sage: R = Integers(3)['x']
--            sage: R(a)  # long time (7s on sage.math, 2013)
--            2*x^99998 + ... + x
-+            sage: p = R(a)
-+            sage: p.truncate(10)  # testing the whole poly is VERY SLOW
-+            2*x^8 + x^7 + 2*x^5 + x^4 + 2*x^2 + x
-         """
-         sig_on()
-         fmpz_poly_get_nmod_poly(&self.x, x)
diff --git a/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch b/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
deleted file mode 100644
index f3da5bbb555e..000000000000
--- a/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
+++ /dev/null
@@ -1,106 +0,0 @@
-diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-index 43727346269..9d3ccd475cd 100644
---- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-+++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-@@ -186,7 +186,7 @@ def Psi(l, use_stored=True):
-         sage: assert Psi(3, use_stored=True) == Psi(3, use_stored=False)
-         sage: assert Psi(5, use_stored=True) == Psi(5, use_stored=False)
-         sage: assert Psi(7, use_stored=True) == Psi(7, use_stored=False)
--        sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False) # not tested (very long time)
-+        sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False)  # long time (2s)
-     """
-     if l not in [2, 3, 5, 7, 13]:
-         raise ValueError("Genus zero primes are 2, 3, 5, 7 or 13.")
-@@ -1207,7 +1207,7 @@ def isogenies_13_0(E, minimal_models=True):
-         sage: K.<a> = NumberField(f)
-         sage: E = EllipticCurve(j=K(0)); E.ainvs()
-         (0, 0, 0, 0, 1)
--        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]
-+        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]  # long time (4s)
-         [(0,
-           0,
-           20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
-@@ -1325,7 +1325,7 @@ def isogenies_13_1728(E, minimal_models=True):
-         sage: f = x^12 + 1092*x^10 - 432432*x^8 + 6641024*x^6 - 282896640*x^4 - 149879808*x^2 - 349360128
-         sage: K.<a> = NumberField(f)
-         sage: E = EllipticCurve(K, [1,0])
--        sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]
-+        sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]  # long time (3s)
-         [(0,
-         0,
-         0,
-@@ -1550,8 +1550,11 @@ def Psi2(l):
-         sage: from sage.schemes.elliptic_curves.isogeny_small_degree import Psi2
-         sage: Psi2(11)
-         x^5 - 55*x^4*u + 994*x^3*u^2 - 8774*x^2*u^3 + 41453*x*u^4 - 928945/11*u^5 + 33*x^4 + 276*x^3*u - 7794*x^2*u^2 + 4452*x*u^3 + 1319331/11*u^4 + 216*x^3*v - 4536*x^2*u*v + 31752*x*u^2*v - 842616/11*u^3*v + 162*x^3 + 38718*x^2*u - 610578*x*u^2 + 33434694/11*u^3 - 4536*x^2*v + 73872*x*u*v - 2745576/11*u^2*v - 16470*x^2 + 580068*x*u - 67821354/11*u^2 - 185976*x*v + 14143896/11*u*v + 7533*x - 20437029/11*u - 12389112/11*v + 19964151/11
--        sage: Psi2(71)  # long time (1 second)
--        -2209380711722505179506258739515288584116147237393815266468076436521/71*u^210 + ... - 14790739586438315394567393301990769678157425619440464678252277649/71
-+        sage: f = Psi2(71)
-+        sage: f.coefficient([0, 210, 0])
-+        -2209380711722505179506258739515288584116147237393815266468076436521/71
-+        sage: f.coefficient([0, 0, 0])
-+        -14790739586438315394567393301990769678157425619440464678252277649/71
- 
-     TESTS::
- 
-@@ -1665,17 +1668,17 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True):
-         sage: K = QuadraticField(5,'a')
-         sage: a = K.gen()
-         sage: E = EllipticCurve_from_j(184068066743177379840*a - 411588709724712960000)
--        sage: isogenies_prime_degree_genus_plus_0(E, 47) # long time (4.3s)
-+        sage: isogenies_prime_degree_genus_plus_0(E, 47)  # long time (2s)
-         [Isogeny of degree 47 from Elliptic Curve defined by y^2 = x^3 + (454562028554080355857852049849975895490560*a-1016431595837124114668689286176511361024000)*x + (-249456798429896080881440540950393713303830363999480904280965120*a+557802358738710443451273320227578156598454035482869042774016000) over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790? to Elliptic Curve defined by y^2 = x^3 + (39533118442361013730577638493616965245992960*a-88398740199669828340617478832005245173760000)*x + (214030321479466610282320528611562368963830105830555363061803253760*a-478586348074220699687616322532666163722004497458452316582576128000) over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790?]
- 
-         sage: K = QuadraticField(-66827,'a')
-         sage: a = K.gen()
-         sage: E = EllipticCurve_from_j(-98669236224000*a + 4401720074240000)
--        sage: isogenies_prime_degree_genus_plus_0(E, 59)   # long time (25s, 2012)
-+        sage: isogenies_prime_degree_genus_plus_0(E, 59)   # long time (5s)
-         [Isogeny of degree 59 from Elliptic Curve defined by y^2 = x^3 + (2605886146782144762297974784000*a+1893681048912773634944634716160000)*x + (-116918454256410782232296183198067568744071168000*a+17012043538294664027185882358514011304812871680000) over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I to Elliptic Curve defined by y^2 = x^3 + (-19387084027159786821400775098368000*a-4882059104868154225052787156713472000)*x + (-25659862010101415428713331477227179429538847260672000*a-2596038148441293485938798119003462972840818381946880000) over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I]
- 
-         sage: E = EllipticCurve_from_j(GF(13)(5))
--        sage: isogenies_prime_degree_genus_plus_0(E, 71) # long time
-+        sage: isogenies_prime_degree_genus_plus_0(E, 71)
-         [Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13, Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13]
- 
-         sage: E = EllipticCurve(GF(13),[0,1,1,1,0])
-@@ -2117,11 +2120,11 @@ def isogenies_prime_degree_general(E, l, minimal_models=True):
-         sage: isogenies_prime_degree_general(E, 19)
-         [Isogeny of degree 19 from Elliptic Curve defined by y^2 + y = x^3 - 1862*x - 30956 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - 672182*x + 212325489 over Rational Field]
-         sage: E = EllipticCurve([0, -1, 0, -6288, 211072])
--        sage: isogenies_prime_degree_general(E, 37)  # long time (10s)
-+        sage: isogenies_prime_degree_general(E, 37)  # long time (2s)
-         [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 - x^2 - 6288*x + 211072 over Rational Field to Elliptic Curve defined by y^2 = x^3 - x^2 - 163137088*x - 801950801728 over Rational Field]
- 
-         sage: E = EllipticCurve([-3440, 77658])
--        sage: isogenies_prime_degree_general(E, 43)  # long time (16s)
-+        sage: isogenies_prime_degree_general(E, 43)  # long time (2s)
-         [Isogeny of degree 43 from Elliptic Curve defined by y^2 = x^3 - 3440*x + 77658 over Rational Field to Elliptic Curve defined by y^2 = x^3 - 6360560*x - 6174354606 over Rational Field]
- 
-     Isogenies of degree equal to the characteristic are computed (but
-@@ -2175,7 +2178,7 @@ def isogenies_prime_degree_general(E, l, minimal_models=True):
- 
-         sage: K.<i> = QuadraticField(-1)
-         sage: E = EllipticCurve(K,[0,0,0,1,0])
--        sage: [phi.codomain().ainvs() for phi in E.isogenies_prime_degree(37)] # long time
-+        sage: [phi.codomain().ainvs() for phi in E.isogenies_prime_degree(37)]  # long time (6s)
-         [(0, 0, 0, -840*i + 1081, 0), (0, 0, 0, 840*i + 1081, 0)]
-     """
-     if not l.is_prime():
-@@ -2329,14 +2332,14 @@ def isogenies_prime_degree(E, l, minimal_models=True):
-         sage: E = EllipticCurve(GF(101), [-3440, 77658])
-         sage: E.isogenies_prime_degree(71) # fast
-         []
--        sage: E.isogenies_prime_degree(73) # slower (2s)
-+        sage: E.isogenies_prime_degree(73)  # long time (2s)
-         []
- 
-     Test that :trac:`32269` is fixed::
- 
-         sage: K = QuadraticField(-11)
-         sage: E = EllipticCurve(K, [0,1,0,-117,-541])
--        sage: E.isogenies_prime_degree(37)
-+        sage: E.isogenies_prime_degree(37)  # long time (9s)
-         [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I to Elliptic Curve defined by y^2 = x^3 + x^2 + (30800*a+123963)*x + (3931312*a-21805005) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I,
-          Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I to Elliptic Curve defined by y^2 = x^3 + x^2 + (-30800*a+123963)*x + (-3931312*a-21805005) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I]
- 
diff --git a/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch b/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
deleted file mode 100644
index 3b7b1ea843df..000000000000
--- a/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
+++ /dev/null
@@ -1,97 +0,0 @@
---- a/src/sage/rings/function_field/function_field.py
-+++ b/src/sage/rings/function_field/function_field.py
-@@ -111,22 +111,21 @@ Function fields over the algebraic field are supported::
-     sage: m = L.completion(pl, prec=5)
-     sage: m(x)
-     I + s + O(s^5)
--    sage: m(y)
-+    sage: m(y)                             # long time (4s)
-     -2*s + (-4 - I)*s^2 + (-15 - 4*I)*s^3 + (-75 - 23*I)*s^4 + (-413 - 154*I)*s^5 + O(s^6)
--    sage: m(y)^2 + m(y) + m(x) + 1/m(x)
-+    sage: m(y)^2 + m(y) + m(x) + 1/m(x)    # long time (8s)
-     O(s^5)
- 
- TESTS::
- 
-     sage: TestSuite(J).run()
--    sage: TestSuite(K).run(max_runs=1024) # long time (5s)
--    sage: TestSuite(L).run(max_runs=64)   # long time (10s)
--    sage: TestSuite(M).run(max_runs=32)   # long time (30s)
--    sage: TestSuite(N).run(max_runs=64, skip = '_test_derivation')  # long time (8s)
--    sage: TestSuite(O).run(max_runs=128, skip = '_test_derivation') # long time (8s)
--
-+    sage: TestSuite(K).run(max_runs=256)   # long time (10s)
-+    sage: TestSuite(L).run(max_runs=8)     # long time (25s)
-+    sage: TestSuite(M).run(max_runs=8)     # long time (35s)
-+    sage: TestSuite(N).run(max_runs=8, skip = '_test_derivation')    # long time (15s)
-+    sage: TestSuite(O).run()
-     sage: TestSuite(R).run()
--    sage: TestSuite(S).run() # long time (3s)
-+    sage: TestSuite(S).run()               # long time (4s)
- 
- Global function fields
- ----------------------
-@@ -287,7 +286,7 @@ class FunctionField(Field):
-         TESTS::
- 
-             sage: K.<x> = FunctionField(QQ)
--            sage: TestSuite(K).run()
-+            sage: TestSuite(K).run()               # long time (3s)
-         """
-         Field.__init__(self, base_field, names=names, category=category)
- 
-@@ -729,7 +728,7 @@ class FunctionField(Field):
-         EXAMPLES::
- 
-             sage: K.<x> = FunctionField(QQ)
--            sage: TestSuite(K).run() # indirect doctest
-+            sage: TestSuite(K).run()    # indirect doctest, long time (3s)
-         """
-         tester = self._tester(**options)
-         S = tester.some_elements()
-@@ -1209,7 +1208,7 @@ class FunctionField_polymod(FunctionField):
-             sage: K.<x> = FunctionField(QQ); R.<y> = K[]
-             sage: L = K.extension(y^5 - x^3 - 3*x + x*y); L
-             Function field in y defined by y^5 + x*y - x^3 - 3*x
--            sage: TestSuite(L).run()  # long time
-+            sage: TestSuite(L).run(max_runs=512)   # long time (15s)
- 
-         We can set the variable name, which doesn't have to be y::
- 
-@@ -2888,7 +2887,8 @@ class FunctionField_simple(FunctionField_polymod):
-             sage: F.<y> = K.extension(Y^3 - x^2*(x^2 + x + 1)^2)
-             sage: O = K.maximal_order()
-             sage: pls = [O.ideal(x-QQbar(sqrt(c))).place() for c in [-2, -1, 0, 1, 2]]
--            sage: all(q.place_below() == p for p in pls for q in F.places_above(p))
-+            sage: all(q.place_below() == p         # long time (4s)
-+            ....:     for p in pls for q in F.places_above(p))
-             True
-         """
-         R = self.base_field()
-@@ -3091,7 +3091,7 @@ class FunctionField_global(FunctionField_simple):
- 
-         sage: K.<x> = FunctionField(GF(4)); _.<Y> = K[]
-         sage: L.<y> = K.extension((1 - x)*Y^7 - x^3)
--        sage: L.gaps()
-+        sage: L.gaps()                         # long time (6s)
-         [1, 2, 3]
- 
-     or may define a trivial extension::
-@@ -3111,7 +3111,7 @@ class FunctionField_global(FunctionField_simple):
- 
-             sage: K.<x> = FunctionField(GF(5)); _.<Y> = K[]
-             sage: L.<y> = K.extension(Y^3 - (x^3 - 1)/(x^3 - 2))
--            sage: TestSuite(L).run()
-+            sage: TestSuite(L).run()               # long time (7s)
-         """
-         FunctionField_polymod.__init__(self, polynomial, names)
- 
-@@ -3807,7 +3807,7 @@ class RationalFunctionField(FunctionField):
- 
-             sage: K.<t> = FunctionField(CC); K
-             Rational function field in t over Complex Field with 53 bits of precision
--            sage: TestSuite(K).run()
-+            sage: TestSuite(K).run()               # long time (5s)
- 
-             sage: FunctionField(QQ[I], 'alpha')
-             Rational function field in alpha over Number Field in I with defining polynomial x^2 + 1 with I = 1*I
diff --git a/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch b/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
deleted file mode 100644
index 4bd6f4f4e2dc..000000000000
--- a/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
+++ /dev/null
@@ -1,670 +0,0 @@
-As produced by `git diff 9.5 9.6.beta3 -- src/sage/libs/lrcalc`
-
-diff --git a/src/sage/libs/lrcalc/lrcalc.pxd b/src/sage/libs/lrcalc/lrcalc.pxd
-deleted file mode 100644
-index 10b88db93f2..00000000000
---- a/src/sage/libs/lrcalc/lrcalc.pxd
-+++ /dev/null
-@@ -1,77 +0,0 @@
--# distutils: libraries = lrcalc
--
--cdef extern from "lrcalc/hashtab.h":
--    ctypedef struct hashtab:
--        pass
--
--    ctypedef struct hash_itr:
--        pass
--
--    ctypedef unsigned long hashkey_t
--    ctypedef int (*cmp_t) (void* a, void* b)
--    ctypedef hashkey_t (*hash_t) (void* a)
--
--    hashtab* hash_new(cmp_t cm, hash_t hsh)
--    void hash_free(hashtab *ht)
--
--    void* hash_lookup(hashtab *ht, void *key)
--    void* hash_insert(hashtab *ht, void *key, void *value)
--
--    bint hash_good(hash_itr)
--    void hash_first(hashtab* s, hash_itr itr)
--    void hash_next(hash_itr itr)
--    void* hash_key(hash_itr itr)
--    void* hash_value(hash_itr itr)
--    int hash_intvalue(hash_itr itr)
--
--cdef extern from "lrcalc/vector.h":
--    ctypedef struct vector:
--        size_t length
--        int* array
--
--    vector* v_new(int length)
--    void v_free(vector* v)
--    void v_print(vector *v)
--    int v_length(vector* v)
--    int v_elem(vector* v, int i)
--
--    ctypedef struct vecpair:
--        vector *first
--        vector *second
--
--    vector* vp_first(vecpair* vp)
--    vector* vp_second(vecpair* vp)
--
--cdef extern from "lrcalc/list.h":
--    cdef struct _list:
--        void **array
--        size_t allocated
--        size_t length
--    void l_free(_list *lst)
--
--cdef extern from "lrcalc/symfcn.h":
--    long long lrcoef_c "lrcoef"(vector* outer, vector* inner1, vector* inner2)
--    hashtab* mult_c "mult"(vector *sh1, vector *sh2, int maxrows)
--    hashtab* skew_c "skew"(vector *outer, vector *inner, int maxrows)
--    hashtab* coprod_c "coprod"(vector *part, int all)
--    void fusion_reduce_c "fusion_reduce"(hashtab* ht, int rows, int cols, int opt_zero)
--    _list *quantum_reduce_c "quantum_reduce"(hashtab* ht, int rows, int col)
--
--    ctypedef struct skewtab:
--        vector *outer
--        vector *inner
--        vector *conts
--        int maxrows
--        vector *conjugate
--        int rows
--        int cols
--        int matrix[1]
--
--    skewtab *st_new(vector *outer, vector *inner, vector *conts, int maxrows)
--    int st_next(skewtab *st)
--    void st_print(skewtab *st)
--    void st_free(skewtab *st)
--
--
--cdef extern from "lrcalc/schublib.h":
--    hashtab* mult_schubert_c "mult_schubert"(vector *sh1, vector *sh2, int rank)
-diff --git a/src/sage/libs/lrcalc/lrcalc.pyx b/src/sage/libs/lrcalc/lrcalc.py
-similarity index 60%
-rename from src/sage/libs/lrcalc/lrcalc.pyx
-rename to src/sage/libs/lrcalc/lrcalc.py
-index b591081ec4c..b541bfacd89 100644
---- a/src/sage/libs/lrcalc/lrcalc.pyx
-+++ b/src/sage/libs/lrcalc/lrcalc.py
-@@ -10,7 +10,8 @@ fusion products. All of the above are achieved by counting LR
- appropriate shape and content by iterating through them.
- Additionally, ``lrcalc`` handles products of Schubert polynomials.
- 
--The web page of ``lrcalc`` is `<http://sites.math.rutgers.edu/~asbuch/lrcalc/>`_.
-+The web page of ``lrcalc`` is
-+`<http://sites.math.rutgers.edu/~asbuch/lrcalc/>`_.
- 
- The following describes the Sage interface to this library.
- 
-@@ -36,12 +37,13 @@ Schur expansion::
-      [4, 2]: 1}
- 
- Same product, but include only partitions with at most 3 rows.  This
--corresponds to computing in the representation ring of gl(3)::
-+corresponds to computing in the representation ring of `\mathfrak{gl}(3)`::
- 
-     sage: lrcalc.mult([2,1], [2,1], 3)
-     {[2, 2, 2]: 1, [3, 2, 1]: 2, [3, 3]: 1, [4, 1, 1]: 1, [4, 2]: 1}
- 
--We can also compute the fusion product, here for sl(3) and level 2::
-+We can also compute the fusion product, here for `\mathfrak{sl}(3)`
-+and level 2::
- 
-     sage: lrcalc.mult([3,2,1], [3,2,1], 3,2)
-     {[4, 4, 4]: 1, [5, 4, 3]: 1}
-@@ -77,42 +79,38 @@ Multiply two Schubert polynomials::
-      [6, 2, 1, 4, 3, 5]: 1}
- 
- Same product, but include only permutations of 5 elements in the result.
--This corresponds to computing in the cohomology ring of Fl(5)::
-+This corresponds to computing in the cohomology ring of `Fl(5)`::
- 
-     sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3], 5)
-     {[4, 5, 1, 3, 2]: 1, [5, 3, 1, 4, 2]: 1, [5, 4, 1, 2, 3]: 1}
- 
- List all Littlewood-Richardson tableaux of skew shape `\mu/\nu`; in
- this example `\mu=[3,2,1]` and `\nu=[2,1]`. Specifying a third entry
--`maxrows` restricts the alphabet to `\{1,2,\ldots,maxrows\}`::
-+`M' = ``maxrows`` restricts the alphabet to `\{1,2,\ldots,M\}`::
- 
-     sage: list(lrcalc.lrskew([3,2,1],[2,1]))
-     [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
-     [[None, None, 1], [None, 2], [1]], [[None, None, 1], [None, 2], [3]]]
- 
-     sage: list(lrcalc.lrskew([3,2,1],[2,1],maxrows=2))
--    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]], [[None, None, 1], [None, 2], [1]]]
-+    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
-+     [[None, None, 1], [None, 2], [1]]]
- 
- .. TODO::
- 
--    use this library in the :class:`SymmetricFunctions` code, to
-+    Use this library in the :class:`SymmetricFunctions` code, to
-     make it easy to apply it to linear combinations of Schur functions.
- 
- .. SEEALSO::
- 
-     - :func:`lrcoef`
--
-     - :func:`mult`
--
-     - :func:`coprod`
--
-     - :func:`skew`
--
-     - :func:`lrskew`
--
-     - :func:`mult_schubert`
- 
--.. rubric:: Underlying algorithmic in lrcalc
-+.. RUBRIC:: Underlying algorithmic in lrcalc
- 
- Here is some additional information regarding the main low-level
- C-functions in `lrcalc`. Given two partitions ``outer`` and ``inner``
-@@ -187,180 +185,24 @@ AUTHORS:
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from sage.rings.integer cimport Integer
--from sage.structure.parent cimport Parent
- from sage.combinat.partition import _Partitions
- from sage.combinat.permutation import Permutation
--from sage.combinat.skew_tableau import SkewTableau
--
--
--cdef vector* iterable_to_vector(it):
--    """
--    Return an lrcalc vector (which is a list of integers) from a Python iterable.
--
--    TESTS::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector(Partition([3,2,1])); x   #indirect doctest
--        [3, 2, 1]
--    """
--    cdef vector* v
--    cdef list itr = list(it)
--    cdef int n = len(itr)
--    cdef int i
--    v = v_new(n)
--    for i in range(n):
--        v.array[i] = int(itr[i])
--    return v
--
--
--cdef list vector_to_list(vector *v):
--    """
--    Converts a lrcalc vector to Python list.
--
--    TESTS::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector([]); x         #indirect doctest
--        []
--    """
--    cdef int i, n
--    n = v_length(v)
--    cdef list result = [None]*n
--    for i in range(n):
--        result[i] = Integer(v_elem(v, i))
--    return result
--
--
--def test_iterable_to_vector(it):
--    """
--    A wrapper function for the cdef function ``iterable_to_vector``
--    and ``vector_to_list``, to test that they are working correctly.
-+from sage.combinat.skew_tableau import SemistandardSkewTableaux
-+from sage.combinat.skew_partition import SkewPartition
-+from sage.rings.integer import Integer
-+import lrcalc
- 
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector([3,2,1]); x
--        [3, 2, 1]
--    """
--    cdef vector *v = iterable_to_vector(it)
--    result = vector_to_list(v)
--    v_free(v)
--    return result
--
--
--cdef skewtab_to_SkewTableau(skewtab *st):
--    """
--    A wrapper function which transforms the data set ``st`` used in
--    ``lrcalc`` to a ``SkewTableau`` in Sage.
-+def _lrcalc_dict_to_sage(result):
-+    r"""
-+    Translate from lrcalc output format to Sage expected format.
- 
-     TESTS::
- 
--        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
--        sage: test_skewtab_to_SkewTableau([],[])
--        []
--    """
--    inner = vector_to_list(st.inner)
--    outer = vector_to_list(st.outer)
--    return SkewTableau(expr=[[inner[y] for y in range(len(outer))],
--                             [[st.matrix[x + y * st.cols] + 1
--                                for x in range(inner[y], outer[y])]
--                              for y in range(len(outer) - 1, -1, -1)]])
--
--
--def test_skewtab_to_SkewTableau(outer, inner):
--    """
--    A wrapper function for the cdef function ``skewtab_to_SkewTableau``
--    for testing purposes.
--
--    It constructs the first LR skew tableau of shape ``outer/inner``
--    as an ``lrcalc`` ``skewtab``, and converts it to a
--    :class:`SkewTableau`.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
--        sage: test_skewtab_to_SkewTableau([3,2,1],[])
--        [[1, 1, 1], [2, 2], [3]]
--        sage: test_skewtab_to_SkewTableau([4,3,2,1],[1,1]).pp()
--        .  1  1  1
--        .  2  2
--        1  3
--        2
--    """
--    cdef vector* o = iterable_to_vector(outer)
--    cdef vector* i = iterable_to_vector(inner+[0]*(len(outer)-len(inner)))
--    cdef skewtab* st = st_new(o, i, NULL, 0)
--    return skewtab_to_SkewTableau(st)
--
--
--cdef dict sf_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary representing a Schur function. The keys are
--    partitions and the values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
-         sage: from sage.libs.lrcalc.lrcalc import mult
--        sage: sorted(mult([1],[1]).items())        #indirect doctest
--        [([1, 1], 1), ([2], 1)]
--        sage: assert isinstance(mult([1],[1]),dict)#indirect doctest
--    """
--    cdef hash_itr itr
--    cdef dict result = {}
--    cdef list p
--    hash_first(ht, itr)
--    while hash_good(itr):
--        p = vector_to_list(<vector*> hash_key(itr))
--        result[_Partitions(p)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
--
--cdef dict schubert_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary corresponding to a Schubert polynomial whose keys
--    are permutations and whose values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import mult_schubert
--        sage: mult_schubert([3,2,1], [1,2,3])      #indirect doctest
--        {[3, 2, 1]: 1}
--    """
--    cdef hash_itr itr
--    cdef dict result = {}
--    hash_first(ht, itr)
--    while hash_good(itr):
--        p = vector_to_list(<vector*> hash_key(itr))
--        result[Permutation(p)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
--
--cdef dict vp_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary corresponding to the coproduct of a Schur function whose keys are
--    pairs of partitions and whose values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import coprod
--        sage: coprod([1])      #indirect doctest
--        {([1], []): 1}
-+        sage: mult([2,1],[3,2,1],3) # indirect doctest
-+        {[3, 3, 3]: 1, [4, 3, 2]: 2, [4, 4, 1]: 1, [5, 2, 2]: 1, [5, 3, 1]: 1}
-     """
--    cdef hash_itr itr
--    cdef vecpair* vp
--    cdef dict result = {}
--    hash_first(ht, itr)
--    while hash_good(itr):
--        vp = <vecpair*> hash_key(itr)
--        p1 = _Partitions(vector_to_list(vp_first(vp)))
--        p2 = _Partitions(vector_to_list(vp_second(vp)))
--        result[(p1, p2)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
-+    return {_Partitions(la): Integer(k) for la, k in result.items()}
- 
- def lrcoef_unsafe(outer, inner1, inner2):
-     r"""
-@@ -371,13 +213,11 @@ def lrcoef_unsafe(outer, inner1, inner2):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
--
--    - ``inner1`` -- a partition.
-+    - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
-+    - ``inner1`` -- a partition
-+    - ``inner2`` -- a partition
- 
--    - ``inner2`` -- a partition.
--
--    .. warning::
-+    .. WARNING::
- 
-        This function does not do any check on its input.  If you want
-        to use a safer version, use :func:`lrcoef`.
-@@ -392,18 +232,7 @@ def lrcoef_unsafe(outer, inner1, inner2):
-         sage: lrcoef_unsafe([2,1,1,1,1], [2,1], [2,1])
-         0
-     """
--    cdef long long result
--    cdef vector *o
--    cdef vector *i1
--    cdef vector *i2
--    o = iterable_to_vector(outer)
--    i1 = iterable_to_vector(inner1)
--    i2 = iterable_to_vector(inner2)
--    result = lrcoef_c(o, i1, i2)
--    v_free(o)
--    v_free(i1)
--    v_free(i2)
--    return Integer(result)
-+    return Integer(lrcalc.lrcoef(outer, inner1, inner2))
- 
- 
- def lrcoef(outer, inner1, inner2):
-@@ -415,11 +244,9 @@ def lrcoef(outer, inner1, inner2):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
--
--    - ``inner1`` -- a partition.
--
--    - ``inner2`` -- a partition.
-+    - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
-+    - ``inner1`` -- a partition
-+    - ``inner2`` -- a partition
- 
-     .. NOTE::
- 
-@@ -436,7 +263,6 @@ def lrcoef(outer, inner1, inner2):
-         1
-         sage: lrcoef([2,1,1,1,1], [2,1], [2,1])
-         0
--
-     """
-     return lrcoef_unsafe(_Partitions(outer), _Partitions(inner1), _Partitions(inner2))
- 
-@@ -451,13 +277,9 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-     INPUT:
- 
-     - ``part1`` -- a partition
--
-     - ``part2`` -- a partition
--
-     - ``maxrows`` -- (optional) an integer
--
-     - ``level`` -- (optional) an integer
--
-     - ``quantum`` -- (optional) an element of a ring
- 
-     If ``maxrows`` is specified, then only partitions with at most
-@@ -479,7 +301,8 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-         sage: sorted(mult([2],[2]).items())
-         [([2, 2], 1), ([3, 1], 1), ([4], 1)]
-         sage: sorted(mult([2,1],[2,1]).items())
--        [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1), ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
-+        [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1),
-+         ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
-         sage: sorted(mult([2,1],[2,1],maxrows=2).items())
-         [([3, 3], 1), ([4, 2], 1)]
-         sage: mult([2,1],[3,2,1],3)
-@@ -510,44 +333,24 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-     if quantum is not None and (level is None or maxrows is None):
-         raise ValueError('missing parameters maxrows or level')
- 
--    cdef vector* v1 = iterable_to_vector(part1)
--    cdef vector* v2 = iterable_to_vector(part2)
--    if maxrows is None:
--        maxrows = 0
--    cdef hashtab* ht = mult_c(v1, v2, int(maxrows))
--    cdef hashtab* tab
--    cdef dict result
--
-     if quantum is None:
-         if level is not None:
--            fusion_reduce_c(ht, int(maxrows), int(level), int(0))
--        result = sf_hashtab_to_dict(ht)
--        v_free(v1)
--        v_free(v2)
--        hash_free(ht)
--        return result
-+            return _lrcalc_dict_to_sage(lrcalc.mult_fusion(part1, part2, maxrows, level))
-+        if maxrows is None:
-+            maxrows = -1
-+        return _lrcalc_dict_to_sage(lrcalc.mult(part1, part2, maxrows))
- 
-     # Otherwise do quantum multiplication
--    cdef _list *qlist
--    cdef dict temp
--    qlist = quantum_reduce_c(ht, int(maxrows), int(level))
--    # The above call frees the memory associated with ht
--    v_free(v1)
--    v_free(v2)
--
--    cdef Parent P = quantum.parent()
--    result = {}
--    for i in range(qlist.length):
--        tab = <hashtab*>(qlist.array[i])
--        temp = sf_hashtab_to_dict(tab)
--        for k in temp:
--            result[k] = result.get(k, P.zero()) + quantum**i * temp[k]
--        hash_free(tab)
--    l_free(qlist)
--    return result
--
--
--def skew(outer, inner, maxrows=0):
-+    result = lrcalc.mult_quantum(part1, part2, maxrows, level, degrees=True)
-+    P = quantum.parent()
-+    output = {}
-+    for i,k in result.items():
-+        la = _Partitions(i[0])
-+        output[la] = output.get(la, P.zero()) + k * quantum**(i[1])
-+    return output
-+
-+
-+def skew(outer, inner, maxrows=-1):
-     """
-     Compute the Schur expansion of a skew Schur function.
- 
-@@ -557,11 +360,9 @@ def skew(outer, inner, maxrows=0):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition.
--
--    - ``inner`` -- a partition.
--
--    - ``maxrows`` -- an integer or ``None``.
-+    - ``outer`` -- a partition
-+    - ``inner`` -- a partition
-+    - ``maxrows`` -- an integer or ``None``
- 
-     If ``maxrows`` is specified, then only partitions with at most
-     this number of rows are included in the result.
-@@ -572,14 +373,7 @@ def skew(outer, inner, maxrows=0):
-         sage: sorted(skew([2,1],[1]).items())
-         [([1, 1], 1), ([2], 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(outer)
--    cdef vector* v2 = iterable_to_vector(inner)
--    cdef hashtab* ht = skew_c(v1, v2, int(maxrows))
--    result = sf_hashtab_to_dict(ht)
--    v_free(v1)
--    v_free(v2)
--    hash_free(ht)
--    return result
-+    return _lrcalc_dict_to_sage(lrcalc.skew(outer, inner, maxrows))
- 
- 
- def coprod(part, all=0):
-@@ -592,9 +386,8 @@ def coprod(part, all=0):
- 
-     INPUT:
- 
--    - ``part`` -- a partition.
--
--    - ``all`` -- an integer.
-+    - ``part`` -- a partition
-+    - ``all`` -- an integer
- 
-     If ``all`` is non-zero then all terms are included in the result.
-     If ``all`` is zero, then only pairs of partitions ``(part1,
-@@ -609,12 +402,9 @@ def coprod(part, all=0):
-         sage: sorted(coprod([2,1]).items())
-         [(([1, 1], [1]), 1), (([2], [1]), 1), (([2, 1], []), 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(part)
--    cdef hashtab* ht = coprod_c(v1, int(all))
--    result = vp_hashtab_to_dict(ht)
--    v_free(v1)
--    hash_free(ht)
--    return result
-+    result = lrcalc.coprod(part, all)
-+    return {tuple([_Partitions(mu) for mu in la]): Integer(k)
-+            for la, k in result.items()}
- 
- 
- def mult_schubert(w1, w2, rank=0):
-@@ -627,11 +417,9 @@ def mult_schubert(w1, w2, rank=0):
- 
-     INPUT:
- 
--    - ``w1`` -- a permutation.
--
--    - ``w2`` -- a permutation.
--
--    - ``rank`` -- an integer.
-+    - ``w1`` -- a permutation
-+    - ``w2`` -- a permutation
-+    - ``rank`` -- an integer
- 
-     If ``rank`` is non-zero, then only permutations from the symmetric
-     group `S(\mathrm{rank})` are included in the result.
-@@ -646,33 +434,24 @@ def mult_schubert(w1, w2, rank=0):
-          ([6, 4, 3, 1, 2, 5], 1), ([6, 5, 2, 1, 3, 4], 1),
-          ([7, 3, 4, 1, 2, 5, 6], 1), ([7, 4, 2, 1, 3, 5, 6], 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(w1)
--    cdef vector* v2 = iterable_to_vector(w2)
--    cdef hashtab* ht = mult_schubert_c(v1, v2, int(rank))
--    result = schubert_hashtab_to_dict(ht)
--    v_free(v1)
--    v_free(v2)
--    hash_free(ht)
--    return result
-+    result = lrcalc.schubmult(w1, w2, rank)
-+    return {Permutation(list(la)):Integer(k) for la,k in result.items()}
- 
- 
--def lrskew(outer, inner, weight=None, maxrows=0):
-+def lrskew(outer, inner, weight=None, maxrows=-1):
-     r"""
-     Iterate over the skew LR tableaux of shape ``outer / inner``.
- 
-     INPUT:
- 
-     - ``outer`` -- a partition
--
-     - ``inner`` -- a partition
--
-     - ``weight`` -- a partition (optional)
--
--    - ``maxrows`` -- an integer (optional)
-+    - ``maxrows`` -- a positive integer (optional)
- 
-     OUTPUT: an iterator of :class:`SkewTableau`
- 
--    Specifying ``maxrows`` restricts the alphabet to `\{1,2,\ldots,maxrows\}`.
-+    Specifying ``maxrows`` = `M` restricts the alphabet to `\{1,2,\ldots,M\}`.
- 
-     Specifying ``weight`` returns only those tableaux of given content/weight.
- 
-@@ -702,22 +481,40 @@ def lrskew(outer, inner, weight=None, maxrows=0):
- 
-         sage: list(lrskew([3,2,1],[2], weight=[3,1]))
-         [[[None, None, 1], [1, 1], [2]]]
-+
-+    TESTS::
-+
-+        sage: from sage.libs.lrcalc.lrcalc import lrskew
-+        sage: list(lrskew([3,2,1],[2], weight=[]))
-+        []
-+        sage: list(lrskew([3,2,1],[2], weight=[0]))
-+        []
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[]))
-+        [[[None, None, None], [None, None], [None]]]
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[0]))
-+        [[[None, None, None], [None, None], [None]]]
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[1]))
-+        []
-     """
--    cdef vector* o = iterable_to_vector(outer)
--    cdef vector* i = iterable_to_vector(inner + [0]*(len(outer) - len(inner)))
--    cdef skewtab* st = st_new(o, i, NULL, int(maxrows))
-+    iterator = lrcalc.lr_iterator(outer, inner, maxrows)
-+    shape = SkewPartition([outer, inner])
- 
-     if weight is None:
--        yield skewtab_to_SkewTableau(st)
--        while st_next(st):
--            yield skewtab_to_SkewTableau(st)
-+        ST = SemistandardSkewTableaux(shape)
-+        for data in iterator:
-+            yield ST.from_shape_and_word(shape, [i+1 for i in data])
-     else:
-         wt = _Partitions(weight)
--        r = skewtab_to_SkewTableau(st)
--        if r.weight() == wt:
--            yield r
--        while st_next(st):
--            r = skewtab_to_SkewTableau(st)
--            if r.weight() == wt:
--                yield r
--    st_free(st)
-+        ST = SemistandardSkewTableaux(shape, wt)
-+        m = len(wt)
-+        for data in iterator:
-+            w = [0] * m
-+            for j in data:
-+                if j >= m:
-+                    # We know they are not equal, so make the check below quick
-+                    w = None
-+                    break
-+                w[j] += 1
-+            if w == wt:
-+                yield ST.from_shape_and_word(shape, [i+1 for i in data])
-+
diff --git a/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch b/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
deleted file mode 100644
index 1e2e0ba90742..000000000000
--- a/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-As produced by `git diff a90a3146{^^,}`
-
-diff --git a/src/sage/repl/interface_magic.py b/src/sage/repl/interface_magic.py
-index 8a455b69b0e..a93e1c9e04c 100644
---- a/src/sage/repl/interface_magic.py
-+++ b/src/sage/repl/interface_magic.py
-@@ -260,7 +260,7 @@ class InterfaceMagic(object):
-             2
-             120
-             sage: shell.run_cell('%%gap foo\n1+1;\n')
--            ...File "<string>", line unknown
-+            ...File...<string>...
-             SyntaxError: Interface magics have no options, got "foo"
-             <BLANKLINE>
-             sage: shell.run_cell('%%gap?')
-diff --git a/src/sage/repl/interpreter.py b/src/sage/repl/interpreter.py
-index 7468afe52d7..06c47b7374a 100644
---- a/src/sage/repl/interpreter.py
-+++ b/src/sage/repl/interpreter.py
-@@ -78,9 +78,9 @@ Check that Cython source code appears in tracebacks::
-     dummy line
-     ...
-     ZeroDivisionError...Traceback (most recent call last)
--    <ipython-input-...> in <module>...
-+    ...in <module>...
-     ----> 1 Integer(1)/Integer(0)
--    .../sage/rings/integer.pyx in sage.rings.integer.Integer...div...
-+    .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
-     ...
-     -> ...                  raise ZeroDivisionError("rational division by zero")
-        ....:            x = <Rational> Rational.__new__(Rational)
-@@ -423,7 +423,7 @@ def SagePreparseTransformer(lines):
-         sage: from sage.repl.interpreter import get_test_shell
-         sage: shell = get_test_shell()
-         sage: shell.run_cell(bad_syntax)
--          File "<string>", line unknown
-+          File...<string>...
-         SyntaxError: Mismatched ']'
-         <BLANKLINE>
-         sage: shell.quit()
diff --git a/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch b/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
deleted file mode 100644
index 853813b0f5bd..000000000000
--- a/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Fix for ipython 8.1
-
---- a/src/sage/repl/interpreter.py
-+++ b/src/sage/repl/interpreter.py
-@@ -78,7 +78,7 @@ Check that Cython source code appears in tracebacks::
-     dummy line
-     ...
-     ZeroDivisionError...Traceback (most recent call last)
--    ...in <module>...
-+    ...
-     ----> 1 Integer(1)/Integer(0)
-     .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
-     ...
diff --git a/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch b/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
deleted file mode 100644
index b861af7ec982..000000000000
--- a/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
+++ /dev/null
@@ -1,126 +0,0 @@
-From 24cc94b1988a90f3bd22a2368ec30c086283af13 Mon Sep 17 00:00:00 2001
-From: Antonio Rojas <arojas@archlinux.org>
-Date: Sun, 16 Jan 2022 11:55:04 +0100
-Subject: Add abs tol to some arb tests
-
----
- src/sage/functions/error.py    |  2 +-
- src/sage/rings/complex_arb.pyx |  6 +++---
- src/sage/rings/real_arb.pyx    | 10 +++++-----
- 3 files changed, 9 insertions(+), 9 deletions(-)
-
-diff --git a/src/sage/functions/error.py b/src/sage/functions/error.py
-index f48d04f..06f0b24 100644
---- a/src/sage/functions/error.py
-+++ b/src/sage/functions/error.py
-@@ -267,7 +267,7 @@ class Function_erf(BuiltinFunction):
- 
-         Check that real ball evaluation is fixed :trac:`28061`::
- 
--            sage: RealBallField(128)(erf(5))
-+            sage: RealBallField(128)(erf(5)) # abs tol 1e-38
-             [0.99999999999846254020557196514981165651 +/- 7.33e-39]
-         """
-         R = parent or s_parent(x)
-diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
-index f986970..93ff565 100644
---- a/src/sage/rings/complex_arb.pyx
-+++ b/src/sage/rings/complex_arb.pyx
-@@ -3974,8 +3974,8 @@ cdef class ComplexBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: CBF(20).erfc()
--            [5.39586561160790e-176 +/- ...e-191]
-+            sage: CBF(20).erfc() # abs tol 1e-190
-+            [5.39586561160790e-176 +/- 6.73e-191]
-             sage: CBF(100, 100).erfc()
-             [0.00065234366376858 +/- ...e-18] + [-0.00393572636292141 +/- ...e-18]*I
-         """
-@@ -4280,7 +4280,7 @@ cdef class ComplexBall(RingElement):
- 
-         TESTS:
- 
--            sage: CBF(Shi(I))
-+            sage: CBF(Shi(I)) # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]*I
-         """
-         cdef ComplexBall result = self._new()
-diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
-index 4a81784..292bfea 100644
---- a/src/sage/rings/real_arb.pyx
-+++ b/src/sage/rings/real_arb.pyx
-@@ -3506,7 +3506,7 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1/2).erf()
-+            sage: RBF(1/2).erf() # abs tol 1e-16
-             [0.520499877813047 +/- 6.10e-16]
-         """
-         cdef RealBall res = self._new()
-@@ -3556,12 +3556,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Si()
-+            sage: RBF(1).Si() # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]
- 
-         TESTS::
- 
--            sage: RBF(Si(1))
-+            sage: RBF(Si(1)) # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]
-         """
-         cdef RealBall res = self._new()
-@@ -3578,12 +3578,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Ci()  # abs tol 1e-16
-+            sage: RBF(1).Ci()  # abs tol 1e-15
-             [0.337403922900968 +/- 3.25e-16]
- 
-         TESTS::
- 
--            sage: RBF(Ci(1))  # abs tol 1e-16
-+            sage: RBF(Ci(1))  # abs tol 1e-15
-             [0.337403922900968 +/- 3.25e-16]
-         """
-         cdef RealBall res = self._new()
--- 
-cgit v1.0-1-gd88e
-
-
-From 53532ddd4e2dc92469c1590ebf0c40f8f69bf579 Mon Sep 17 00:00:00 2001
-From: Antonio Rojas <arojas@archlinux.org>
-Date: Sun, 16 Jan 2022 14:16:53 +0100
-Subject: Decrease abs tol
-
----
- src/sage/rings/real_arb.pyx | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
-index 292bfea..eb30f7f 100644
---- a/src/sage/rings/real_arb.pyx
-+++ b/src/sage/rings/real_arb.pyx
-@@ -3578,12 +3578,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Ci()  # abs tol 1e-15
-+            sage: RBF(1).Ci()  # abs tol 5e-16
-             [0.337403922900968 +/- 3.25e-16]
- 
-         TESTS::
- 
--            sage: RBF(Ci(1))  # abs tol 1e-15
-+            sage: RBF(Ci(1))  # abs tol 5e-16
-             [0.337403922900968 +/- 3.25e-16]
-         """
-         cdef RealBall res = self._new()
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch b/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
deleted file mode 100644
index d4e8f8be60e3..000000000000
--- a/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From 33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c Mon Sep 17 00:00:00 2001
-From: Michael Orlitzky <michael@orlitzky.com>
-Date: Mon, 24 Jan 2022 09:03:29 -0500
-Subject: Trac #33226: update doctests for giac-1.7.0.45.
-
-We have two failing doctests with giac-1.7.0.45: one is a trivial
-tolerance issue, but the other is a symbolic integration result for
-which giac is no longer willing to return a symbolic answer. We add
-"abs tol" to the numeric test, and drop the symbolic one entirely.
----
- src/sage/functions/min_max.py | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/src/sage/functions/min_max.py b/src/sage/functions/min_max.py
-index fc18373..9b7d6d9 100644
---- a/src/sage/functions/min_max.py
-+++ b/src/sage/functions/min_max.py
-@@ -228,15 +228,15 @@ class MaxSymbolic(MinMax_base):
-             ...
-             TypeError: cannot evaluate symbolic expression numerically
- 
--        ::
-+        We can usually integrate these expressions, but can't
-+        guarantee a symbolic answer in closed form::
- 
-             sage: f = max_symbolic(sin(x), cos(x))
-             sage: r = integral(f, x, 0, 1)
-             ...
--            sage: r
--            sqrt(2) - cos(1)
--            sage: r.n()
-+            sage: r.n()  # abs tol 1e-8
-             0.873911256504955
-+
-         """
-         return max_symbolic(args)
- 
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch b/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
deleted file mode 100644
index 19b69700a4f6..000000000000
--- a/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-commit 9c8235e44ffb509efa8a3ca6cdb55154e2b5066d
-Author: Antonio Rojas <arojas@archlinux.org>
-Date:   Sun Feb 13 19:53:14 2022 +0100
-
-    Fix deprecation warning with scipy 1.8
-
-diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-index e9b60dae5ec..7932167b41d 100644
---- a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-@@ -356,7 +356,7 @@ Sage example in ./linsolve.tex, line 2230::
- 
- Sage example in ./linsolve.tex, line 2609::
- 
--  sage: from scipy.sparse.linalg.dsolve import *
-+  sage: from scipy.sparse.linalg import factorized
-   sage: from scipy.sparse import lil_matrix
-   sage: from numpy import array
-   sage: n = 200
diff --git a/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch b/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
new file mode 100644
index 000000000000..e052e306e7a1
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
@@ -0,0 +1,53 @@
+From 6330cee1a69229b2f5d8ac4a09a73d8152f5e14d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Mon, 28 Feb 2022 23:15:16 -0300
+Subject: trac 33360: avoid factoring in is_prime()
+
+In the added TEST, the ideal norm is product of two primes but factoring
+this product takes about half an hour, so factoring the ideal is slow.
+
+To fix the issue, we only factor the ideal if the norm is a prime power.
+---
+ src/sage/rings/number_field/number_field_ideal.py | 22 ++++++++++++++++++++++
+ 1 file changed, 22 insertions(+)
+
+diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
+index f785f22..10d1f88 100644
+--- a/src/sage/rings/number_field/number_field_ideal.py
++++ b/src/sage/rings/number_field/number_field_ideal.py
+@@ -995,10 +995,32 @@ class NumberFieldIdeal(Ideal_generic):
+             False
+             sage: K.ideal(17).is_prime()  # ramified
+             False
++
++        TESTS::
++
++        Check that we do not factor the norm of the ideal, this used
++        to take half an hour, see :trac:`33360`
++
++           sage: K.<a,b,c> = NumberField([x^2-2,x^2-3,x^2-5])
++           sage: t = (((-2611940*c + 1925290/7653)*b - 1537130/7653*c
++           ....:       + 10130950)*a + (1343014/7653*c - 8349770)*b
++           ....:       + 6477058*c - 2801449990/4002519)
++           sage: t.is_prime()
++           False
++
+         """
+         try:
+             return self._pari_prime is not None
+         except AttributeError:
++            K = self.number_field().pari_nf()
++            I = self.pari_hnf()
++            # This would be better, but it is broken in pari 2.13.3.
++            #   self._pari_prime = K.idealismaximal(I) or None
++            # Instead we factor I, but only if the norm is a prime power
++            n = K.idealnorm(I)
++            if n.denominator() > 1 or not n.isprimepower():
++                self._pari_prime = None
++                return False
+             F = self.factor()  # factorization with caching
+             if len(F) != 1 or F[0][1] != 1:
+                 self._pari_prime = None
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
deleted file mode 100644
index 9ba7ca5a6b7d..000000000000
--- a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
+++ /dev/null
@@ -1,99 +0,0 @@
-From 609dd9deaeaa6380ab2f0d50276d911233c00a04 Mon Sep 17 00:00:00 2001
-From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
-Date: Fri, 4 Mar 2022 16:07:09 -0800
-Subject: sage.manifolds: Update doctests for SymPy 1.10
-
----
- src/sage/manifolds/continuous_map.py              | 3 +--
- src/sage/manifolds/differentiable/diff_form.py    | 4 ++--
- src/sage/manifolds/differentiable/tensorfield.py  | 8 ++++----
- src/sage/manifolds/vector_bundle_fiber_element.py | 2 +-
- 4 files changed, 8 insertions(+), 9 deletions(-)
-
-diff --git a/src/sage/manifolds/continuous_map.py b/src/sage/manifolds/continuous_map.py
-index a6356e7..f6f9b6d 100644
---- a/src/sage/manifolds/continuous_map.py
-+++ b/src/sage/manifolds/continuous_map.py
-@@ -1357,8 +1357,7 @@ class ContinuousMap(Morphism):
-             sage: Phi.coord_functions(c_uv, c_xyz)
-             Coordinate functions (u*v, u/v, u + v) on the Chart (M, (u, v))
-             sage: Phi.coord_functions(c_UV, c_xyz)
--            Coordinate functions (-U**2/4 + V**2/4, -(U + V)/(U - V), V)
--             on the Chart (M, (U, V))
-+            Coordinate functions (-U**2/4 + V**2/4, (-U - V)/(U - V), V) on the Chart (M, (U, V))
-             sage: Phi.coord_functions(c_UV, c_XYZ)
-             Coordinate functions ((-U**3 + U**2*V + U*V**2 + 2*U*V + 6*U - V**3
-              - 2*V**2 + 6*V)/(2*(U - V)), (U**3/4 - U**2*V/4 - U*V**2/4 + U*V
-diff --git a/src/sage/manifolds/differentiable/diff_form.py b/src/sage/manifolds/differentiable/diff_form.py
-index 70dd8fb..0aa3469 100644
---- a/src/sage/manifolds/differentiable/diff_form.py
-+++ b/src/sage/manifolds/differentiable/diff_form.py
-@@ -266,7 +266,7 @@ class DiffForm(TensorField):
- 
-         sage: s = a.wedge(b)
-         sage: s.display(eU)
--        a∧b = -x*(2*x*y + 1) dx∧dy
-+        a∧b = x*(-2*x*y - 1) dx∧dy
-         sage: s.display(eV)
-         a∧b = (u**3/8 + u**2*v/8 - u*v**2/8 + u/4 - v**3/8 + v/4) du∧dv
- 
-@@ -275,7 +275,7 @@ class DiffForm(TensorField):
-         sage: f = M.scalar_field({c_xy: (x+y)^2, c_uv: u^2}, name='f')
-         sage: s = f*a
-         sage: s.display(eU)
--        f*a = -y*(x**2 + 2*x*y + y**2) dx + x*(x**2 + 2*x*y + y**2) dy
-+        f*a = y*(-x**2 - 2*x*y - y**2) dx + x*(x**2 + 2*x*y + y**2) dy
-         sage: s.display(eV)
-         f*a = u**2*v/2 du - u**3/2 dv
- 
-diff --git a/src/sage/manifolds/differentiable/tensorfield.py b/src/sage/manifolds/differentiable/tensorfield.py
-index 2775be9..6bc5c50 100644
---- a/src/sage/manifolds/differentiable/tensorfield.py
-+++ b/src/sage/manifolds/differentiable/tensorfield.py
-@@ -334,7 +334,7 @@ class TensorField(ModuleElementWithMutability):
-         sage: f.display()  # long time
-         t(a,b): S^2 → ℝ
-         on U: (x, y) ↦ -2*x*y - 3*x - y**2
--        on V: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+        on V: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
- 
-     The vectors can be defined only on subsets of `S^2`, the domain of the
-     result is then the common subset::
-@@ -343,12 +343,12 @@ class TensorField(ModuleElementWithMutability):
-         sage: s.display()  # long time
-         t(a,b): U → ℝ
-            (x, y) ↦ -2*x*y - 3*x - y**2
--        on W: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+        on W: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
-         sage: s = t(a.restrict(U), b.restrict(W))  # long time
-         sage: s.display()  # long time
-         t(a,b): W → ℝ
-            (x, y) ↦ -2*x*y - 3*x - y**2
--           (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+           (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
- 
-     The tensor itself can be defined only on some open subset of `S^2`,
-     yielding a result whose domain is this subset::
-@@ -356,7 +356,7 @@ class TensorField(ModuleElementWithMutability):
-         sage: s = t.restrict(V)(a,b)  # long time
-         sage: s.display()  # long time
-         t(a,b): V → ℝ
--           (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+           (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
-         on W: (x, y) ↦ -2*x*y - 3*x - y**2
- 
-     Tests regarding the multiplication by a scalar field::
-diff --git a/src/sage/manifolds/vector_bundle_fiber_element.py b/src/sage/manifolds/vector_bundle_fiber_element.py
-index 29ee81d..048275a 100644
---- a/src/sage/manifolds/vector_bundle_fiber_element.py
-+++ b/src/sage/manifolds/vector_bundle_fiber_element.py
-@@ -110,4 +110,4 @@ class VectorBundleFiberElement(FiniteRankFreeModuleElement):
-             desc += str(self._name) + " "
-         desc += "in the fiber of {} at {}".format(self._vbundle._name,
-                                                   self._point)
--        return desc
-\ No newline at end of file
-+        return desc
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
deleted file mode 100644
index f5ac180baa90..000000000000
--- a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From c49eff347454ac7f07e5918470b20e97b8f2357e Mon Sep 17 00:00:00 2001
-From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
-Date: Fri, 4 Mar 2022 15:14:43 -0800
-Subject: src/sage/calculus/calculus.py: Update laplace doctest for sympy 1.10
-
----
- src/sage/calculus/calculus.py | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/src/sage/calculus/calculus.py b/src/sage/calculus/calculus.py
-index 9c2f226..b335093 100644
---- a/src/sage/calculus/calculus.py
-+++ b/src/sage/calculus/calculus.py
-@@ -1639,9 +1639,9 @@ def laplace(ex, t, s, algorithm='maxima'):
-         sage: laplace(dirac_delta(t), t, s)
-         1
-         sage: F, a, cond = laplace(dirac_delta(t), t, s, algorithm='sympy')
--        sage: a, cond
--        (-oo, True)
--        sage: F       # random - sympy <1.9 includes undefined heaviside(0) in answer
-+        sage: a, cond  # random - sympy <1.10 gives (-oo, True)
-+        (0, True)
-+        sage: F        # random - sympy <1.9 includes undefined heaviside(0) in answer
-         1
-         sage: laplace(dirac_delta(t), t, s, algorithm='giac')
-         1
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch b/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
deleted file mode 100644
index 8e7bb64f5b01..000000000000
--- a/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From a04a0a0b14f67f4804e7113c3db41bbcf8a58296 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
-Date: Mon, 28 Mar 2022 20:39:59 -0300
-Subject: Trac #33585: fix doctest when dochtml is missing...
-
-...but sphinx is available in PYTHONPATH.
----
- src/sage/misc/sagedoc.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/sage/misc/sagedoc.py b/src/sage/misc/sagedoc.py
-index 4b3853f..08c4225 100644
---- a/src/sage/misc/sagedoc.py
-+++ b/src/sage/misc/sagedoc.py
-@@ -1401,7 +1401,7 @@ class _sage_doc:
-             "...**File:**...**Type:**...**Definition:** identity_matrix..."
-             sage: identity_matrix.__doc__ in browse_sage_doc(identity_matrix, 'rst')
-             True
--            sage: browse_sage_doc(identity_matrix, 'html', False)             # optional - sphinx
-+            sage: browse_sage_doc(identity_matrix, 'html', False)             # optional - sphinx sagemath_doc_html
-             '...div...File:...Type:...Definition:...identity_matrix...'
- 
-         In the 'text' version, double colons have been replaced with
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch b/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
new file mode 100644
index 000000000000..977a42400e59
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
@@ -0,0 +1,42 @@
+commit 5db5d4e56243c609f44afc1f21c112b026f9e1fe
+Author: Oscar Benjamin <oscar.j.benjamin@gmail.com>
+Date:   Mon Jul 11 21:24:01 2022 +0100
+
+    Update doctests for SymPy 1.11
+    
+    Doctests related to SymPy's rsolve function are updated in:
+    
+    src/sage/calculus/test_sympy.py
+    src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+    
+    The form of the output from SymPy has changed since
+    
+    https://github.com/sympy/sympy/pull/23567
+
+diff --git a/src/sage/calculus/test_sympy.py b/src/sage/calculus/test_sympy.py
+index 7cf7f3f6bfd..927e6ee4fb6 100644
+--- a/src/sage/calculus/test_sympy.py
++++ b/src/sage/calculus/test_sympy.py
+@@ -193,7 +193,7 @@ This was fixed in Sympy, see :trac:`14437`::
+     sage: u = Function('u')
+     sage: n = Symbol('n', integer=True)
+     sage: f = u(n+2) - u(n+1) + u(n)/4
+-    sage: 2**n * rsolve(f,u(n))
+-    C1*n + C0
++    sage: expand(2**n * rsolve(f,u(n)))
++    2*C1*n + C0
+ 
+ """
+diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+index 1062f4f7e8c..f53f813d793 100644
+--- a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
++++ b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+@@ -382,7 +382,7 @@ Sage example in ./recequadiff.tex, line 1798::
+   sage: from sympy import rsolve_hyper
+   sage: from sympy.abc import n
+   sage: rsolve_hyper([-2,1],2**(n+2),n)
+-  2**n*C0 + 2**(n + 2)*(C0 + n/2)
++  2**n*C0 + 2**(n + 1)*n
+ 
+ """
+ 
diff --git a/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch b/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
new file mode 100644
index 000000000000..8fedcb78cf71
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
@@ -0,0 +1,19 @@
+commit 04971318f032caf8dc1c0de9489346d894409091
+Author: John H. Palmieri <jhpalmieri64@gmail.com>
+Date:   Wed Aug 31 14:22:26 2022 -0700
+
+    trac 34465: fix invalid escape sequence in functions/special.py
+
+diff --git a/src/sage/functions/special.py b/src/sage/functions/special.py
+index 02596e49620..901f02f9bee 100644
+--- a/src/sage/functions/special.py
++++ b/src/sage/functions/special.py
+@@ -849,7 +849,7 @@ class EllipticF(BuiltinFunction):
+     - :wikipedia:`Elliptic_integral#Incomplete_elliptic_integral_of_the_first_kind`
+     """
+     def __init__(self):
+-        """
++        r"""
+         EXAMPLES::
+ 
+             sage: loads(dumps(elliptic_f))
diff --git a/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch b/srcpkgs/sagemath/patches/zzz-loadable_module_extension
similarity index 100%
rename from srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch
rename to srcpkgs/sagemath/patches/zzz-loadable_module_extension
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 0d793262d572..8df50e4e13b6 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,7 +1,7 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=9.5
-revision=2
+version=9.7
+revision=1
 wrksrc=sage-$version
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
@@ -33,12 +33,9 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="http://sagemath.org/"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=8d70a3b26080802c5b2e33dda4c23795d494d8216a0c2ecfcd608ebab0e64ff6
+checksum=9f26f14aa322e3cf38a71835b12ac34b23026b467f74d54b064c5d025e76fbfd
 
 post_patch() {
-	# these are unused and nothing else uses ratpoints
-	rm sage/libs/ratpoints.{pyx,pxd}
-
 	# git tree needs bootstrapping
 	pushd $wrksrc/build/pkgs/sagelib
 	PATH=../../bin:$PATH BOOTSTRAP_QUIET=no ./bootstrap
@@ -65,6 +62,7 @@ do_configure() {
 
 pre_build() {
 	export PYTHONPATH=../sage-setup
+	export PYTHONDONTWRITEBYTECODE=yes
 	export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
 }
 
@@ -77,6 +75,7 @@ post_build() {
 
 pre_install() {
 	export PYTHONPATH=../sage-setup
+	export PYTHONDONTWRITEBYTECODE=yes
 	export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
 }
 
@@ -104,6 +103,7 @@ post_install() {
 do_check() {
 	_scripts=$(cd build/scripts* && pwd)
 	export PYTHONPATH=$(cd build/lib* && pwd)
+	export PYTHONDONTWRITEBYTECODE=yes
 
 	# get out of $build_wrksrc, otherwise python picks the wrong sage module
 	cd $(mktemp -dp build)

From bbc1e07a1f892dee293cc4eab2ddfb4ecd9132e9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Sun, 9 Oct 2022 12:31:52 -0300
Subject: [PATCH 7/9] python3-fpylll: update to 0.5.7.

---
 srcpkgs/python3-fpylll/patches/python-3.11.patch | 11 -----------
 srcpkgs/python3-fpylll/template                  |  5 +++--
 2 files changed, 3 insertions(+), 13 deletions(-)
 delete mode 100644 srcpkgs/python3-fpylll/patches/python-3.11.patch

diff --git a/srcpkgs/python3-fpylll/patches/python-3.11.patch b/srcpkgs/python3-fpylll/patches/python-3.11.patch
deleted file mode 100644
index b5a6c0efbf1e..000000000000
--- a/srcpkgs/python3-fpylll/patches/python-3.11.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/src/fpylll/gmp/pylong.pxd
-+++ b/src/fpylll/gmp/pylong.pxd
-@@ -3,7 +3,7 @@
- Various functions to deal with conversion mpz <-> Python int/long
- """
- 
--cdef extern from "longintrepr.h":
-+cdef extern from "Python.h":
-     cdef _PyLong_New(Py_ssize_t s)
-     cdef long PyLong_SHIFT
-     ctypedef unsigned int digit
diff --git a/srcpkgs/python3-fpylll/template b/srcpkgs/python3-fpylll/template
index dd2adcee6fce..9bb8dd735edb 100644
--- a/srcpkgs/python3-fpylll/template
+++ b/srcpkgs/python3-fpylll/template
@@ -1,6 +1,6 @@
 # Template file for 'python3-fpylll'
 pkgname=python3-fpylll
-version=0.5.6
+version=0.5.7
 revision=1
 wrksrc="fpylll-${version}"
 build_style=python3-module
@@ -12,8 +12,9 @@ short_desc="Python wrapper to fplll (floating point lattice algorithms)"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="https://github.com/fplll/fpylll"
+changelog="https://github.com/fplll/fpylll/releases"
 distfiles="${PYPI_SITE}/f/fpylll/fpylll-${version}.tar.gz"
-checksum=6eb8a63fb933c0bf92f290dd66fd884807659214d0ce524afe3687a6a6b13a8b
+checksum=1afc88feee50a3e84de55e3913295922c25691f6edafb9ecfe8f2e90306758f6
 
 case $XBPS_TARGET_MACHINE in
 	# skip a test with numerical noise on 32 bit

From 174ea320c9025099de6f53637fad8067472e7a1a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Sun, 9 Oct 2022 13:16:42 -0300
Subject: [PATCH 8/9] python3-memory_allocator: update to 0.1.3.

---
 srcpkgs/python3-memory_allocator/template | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/python3-memory_allocator/template b/srcpkgs/python3-memory_allocator/template
index e4fbb51478fa..52e1590492fb 100644
--- a/srcpkgs/python3-memory_allocator/template
+++ b/srcpkgs/python3-memory_allocator/template
@@ -1,6 +1,6 @@
 # Template file for 'python3-memory_allocator'
 pkgname=python3-memory_allocator
-version=0.1.2
+version=0.1.3
 revision=1
 wrksrc=memory_allocator-$version
 build_style=python3-module
@@ -9,6 +9,7 @@ makedepends="python3-devel"
 short_desc="Extension class to allocate memory easily with cython"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-3.0-or-later"
-homepage="https://github.com/kliem/memory_allocator"
+homepage="https://github.com/sagemath/memory_allocator"
+changelog="https://github.com/sagemath/memory_allocator#changelog"
 distfiles="${PYPI_SITE}/m/memory_allocator/memory_allocator-${version}.tar.gz"
-checksum=ddf42a2dcc678062f30c63c868335204d46a4ecdf4db0dc43ed4529f1d0ffab9
+checksum=13805c2ae1c01b7489fab5e8eac9361662b4f2c02412e3652eece48ff6953162

From 2797f098a61d5afa77177d3dfe3d925b5e43b56f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Sun, 9 Oct 2022 17:46:15 -0300
Subject: [PATCH 9/9] SuiteSparse: update to 5.13.0.

---
 srcpkgs/SuiteSparse/template | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/SuiteSparse/template b/srcpkgs/SuiteSparse/template
index b304dfc8f786..2bb671a50c32 100644
--- a/srcpkgs/SuiteSparse/template
+++ b/srcpkgs/SuiteSparse/template
@@ -1,8 +1,7 @@
 # Template file for 'SuiteSparse'
 pkgname=SuiteSparse
-version=5.12.0
+version=5.13.0
 revision=1
-# XXX: re-enable TBB=-ltbb -DSPQR_CONFIG=-DHAVE_TBB when updating, if possible
 make_build_args="BLAS=-lblas LAPACK=-llapack"
 hostmakedepends="cmake chrpath"
 makedepends="libgomp-devel lapack-devel mpfr-devel"
@@ -12,7 +11,7 @@ license="custom:multiple"
 homepage="https://people.engr.tamu.edu/davis/suitesparse.html"
 changelog="https://raw.githubusercontent.com/DrTimothyAldenDavis/SuiteSparse/master/ChangeLog"
 distfiles="https://github.com/DrTimothyAldenDavis/SuiteSparse/archive/refs/tags/v${version}.tar.gz"
-checksum=5fb0064a3398111976f30c5908a8c0b40df44c6dd8f0cc4bfa7b9e45d8c647de
+checksum=59c6ca2959623f0c69226cf9afb9a018d12a37fab3a8869db5f6d7f83b6b147d
 
 do_build() {
 	make config library $make_build_args JOBS=$XBPS_MAKEJOBS

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: DRAFT: sagemath update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
@ 2022-10-11 12:58 ` tornaria
  2022-10-11 13:51 ` dkwo
                   ` (31 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: tornaria @ 2022-10-11 12:58 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1399 bytes --]

New comment by tornaria on void-packages repository

https://github.com/void-linux/void-packages/pull/39876#issuecomment-1274649461

Comment:
There was one failure that may be related to singular, or maybe it's just some transient failure with pexpect. I'm copying it here to save it. I'll soon push an updated PR using matplotlib 3.6, the CI will run again then and we'll see.
```
sage -t --warn-long 30.0 --random-seed=0 /builddir/sage-9.7/pkgs/sagemath-standard/build/lib.linux-x86_64-cpython-310/sage/interfaces/expect.py
**********************************************************************
File "/builddir/sage-9.7/pkgs/sagemath-standard/build/lib.linux-x86_64-cpython-310/sage/interfaces/expect.py", line 937, in sage.interfaces.expect.Expect._eval_line
Failed example:
    singular.interrupt()
Expected:
    True
Got:
    False
**********************************************************************
File "/builddir/sage-9.7/pkgs/sagemath-standard/build/lib.linux-x86_64-cpython-310/sage/interfaces/expect.py", line 943, in sage.interfaces.expect.Expect._eval_line
Failed example:
    singular('2+3')
Expected:
    Singular crashed -- automatically restarting.
    5
Got:
    5
**********************************************************************
1 item had failures:
   2 of  16 in sage.interfaces.expect.Expect._eval_line
    [101 tests, 2 failures, 23.78 s]
```

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: DRAFT: sagemath update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
  2022-10-11 12:58 ` tornaria
@ 2022-10-11 13:51 ` dkwo
  2022-10-11 14:33 ` ahesford
                   ` (30 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: dkwo @ 2022-10-11 13:51 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 440 bytes --]

New comment by dkwo on void-packages repository

https://github.com/void-linux/void-packages/pull/39876#issuecomment-1274720653

Comment:
Some comments:
- please have a look at  #39346, to see whether any changes to sagemath template can be incorporated here
- at some point I can build and test on aarch64, if we care about it
- I still favor the idea to split a subpackage with all the *devel stuff, needed to pass comprehensive tests

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: DRAFT: sagemath update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
  2022-10-11 12:58 ` tornaria
  2022-10-11 13:51 ` dkwo
@ 2022-10-11 14:33 ` ahesford
  2022-10-11 19:13 ` tornaria
                   ` (29 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: ahesford @ 2022-10-11 14:33 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 362 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/39876#issuecomment-1274794411

Comment:
Please make sure to pull `python-3.11.patch` from 6229f313450ecae88743b4d5e99da2ed4de44e07.

How does sagemath break with matplotlib >= 3.6.0 (aside from the contourpy dependency that I overlooked in the last update)?

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: DRAFT: sagemath update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (2 preceding siblings ...)
  2022-10-11 14:33 ` ahesford
@ 2022-10-11 19:13 ` tornaria
  2022-10-11 19:23 ` ahesford
                   ` (28 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: tornaria @ 2022-10-11 19:13 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 761 bytes --]

New comment by tornaria on void-packages repository

https://github.com/void-linux/void-packages/pull/39876#issuecomment-1275156699

Comment:
> Please make sure to pull `python-3.11.patch` from [6229f31](https://github.com/void-linux/void-packages/commit/6229f313450ecae88743b4d5e99da2ed4de44e07).

Thanks, I'll include that and try to upstream whatever is needed to support python 3.11 (cf https://trac.sagemath.org/ticket/33842)

What's the expected/intended ETA for python 3.11?


> How does sagemath break with matplotlib >= 3.6.0 (aside from the contourpy dependency that I overlooked in the last update)?

I think I managed to fix everything -- I didn't get the time to make a proper patch and push, but I'll try to do it soon and upstream it.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: DRAFT: sagemath update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (3 preceding siblings ...)
  2022-10-11 19:13 ` tornaria
@ 2022-10-11 19:23 ` ahesford
  2022-10-11 21:35 ` [PR PATCH] [Updated] " tornaria
                   ` (27 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: ahesford @ 2022-10-11 19:23 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 485 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/39876#issuecomment-1275168242

Comment:
The last official word I saw was a Py 3.11 release 24 Oct. I've been regularly building the python world with rc2 but haven't really run-tested much. As we get closer, I'll probably install rc2 on something that I use regularly, then bump to the official release and use it for a week or so. I'll probably aim to merge 3.11 by early November.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PR PATCH] [Updated] DRAFT: sagemath update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (4 preceding siblings ...)
  2022-10-11 19:23 ` ahesford
@ 2022-10-11 21:35 ` tornaria
  2022-10-11 21:37 ` tornaria
                   ` (26 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: tornaria @ 2022-10-11 21:35 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1883 bytes --]

There is an updated pull request by tornaria against master on the void-packages repository

https://github.com/tornaria/void-packages sagemath-update
https://github.com/void-linux/void-packages/pull/39876

DRAFT: sagemath update to 9.7
This includes #39838, #39840, #39846, #39872, #39866, also update eclib-20220621.

For now I'm reverting python3-matplotlib to 3.5.3_1 since 3.6.0_1 gives a lot of problems (#39857 adds python3-contourpy which will solve some, but I think there are more issues).

I want to make sure everything works ok and the full testsuite passes as is. Then I'll just move matplotlib back to 3.6.0_1 and try to see if it's feasible to fix or workaround the issues (sagemath-the-distro is still on matplotlib 3.5.2 and I didn't find anything about the update to 3.6.0)

<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: currently running the testsuite in --long after the update of singular.

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/39876.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-sagemath-update-39876.patch --]
[-- Type: text/x-diff, Size: 86281 bytes --]

From b3c746a6ca5b079488eeb5da0233843bd662c071 Mon Sep 17 00:00:00 2001
From: dkwo <nicolopiazzalunga@gmail.com>
Date: Mon, 10 Oct 2022 10:14:06 -0400
Subject: [PATCH 1/4] singular: update to 4.3.1p2 (fix gcc 12 build)

---
 common/shlibs             | 10 +++++-----
 srcpkgs/singular/template | 26 ++++++++++++++------------
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 9f95ac87a7ea..54141e4cd4ba 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4055,11 +4055,11 @@ libumfpack.so.5 SuiteSparse-5.10.1_1
 libecl.so.21.2 ecl-21.2.1_1
 libecm.so.1 ecm-7.0.4_3
 libcliquer.so.1 cliquer-1.22_1
-libSingular-4.3.0.so singular-4.3.0_1
-libfactory-4.3.0.so singular-4.3.0_1
-libpolys-4.3.0.so singular-4.3.0_1
-libomalloc-0.9.6.so singular-4.3.0_1
-libsingular_resources-4.3.0.so singular-4.3.0_1
+libSingular-4.3.1.so singular-4.3.1p2_1
+libfactory-4.3.1.so singular-4.3.1p2_1
+libpolys-4.3.1.so singular-4.3.1p2_1
+libomalloc-0.9.6.so singular-4.3.1p2_1
+libsingular_resources-4.3.1.so singular-4.3.1p2_1
 libbrial.so.3 brial-1.2.10_1
 libbrial_groebner.so.3 brial-1.2.10_1
 libm4ri-0.0.20200125.so m4ri-20200125_1
diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index f23659ef5d83..a30beef915d2 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,25 +1,27 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.0
+version=4.3.1p2
 revision=1
+_majver=${version%p*}
+wrksrc=singular-${_majver}
 build_style=gnu-configure
 configure_args="--with-readline=ncurses
-	--enable-gfanlib
-	--enable-Singular
-	--enable-factory
-	--disable-doc
-	--disable-polymake
-	--without-python
-	--with-libparse
-	ac_cv_lib_cddgmp_dd_free_global_constants=yes"
+ --enable-gfanlib
+ --enable-Singular
+ --enable-factory
+ --disable-doc
+ --disable-polymake
+ --without-python
+ --with-libparse
+ ac_cv_lib_cddgmp_dd_free_global_constants=yes"
 hostmakedepends="perl tar doxygen"
 makedepends="flintlib-devel cddlib-devel readline-devel graphviz"
 short_desc="Computer algebra system for polynomial computations"
-maintainer="dkwo <nicolopiazzalunga@gmail.com>"
+maintainer="dkwo <npiazza@disroot.org>"
 license="GPL-2.0-or-later"
 homepage="https://www.singular.uni-kl.de"
-distfiles="https://www.singular.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${version//./-}/singular-${version}.tar.gz"
-checksum=74f38288203720e3f280256f2f8deb94030dd032b4237d844652aff0faab36e7
+distfiles="https://www.singular.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${_majver//./-}/singular-${version}.tar.gz"
+checksum=95814bba0f0bd0290cd9799ec1d2ecc6f4c8a4e6429d9a02eb7f9c4e5649682a
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From 086931f1a7894c0311006d49867d7d67545f2968 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Sun, 9 Oct 2022 17:46:15 -0300
Subject: [PATCH 2/4] SuiteSparse: update to 5.13.0.

---
 srcpkgs/SuiteSparse/template | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/SuiteSparse/template b/srcpkgs/SuiteSparse/template
index b304dfc8f786..2bb671a50c32 100644
--- a/srcpkgs/SuiteSparse/template
+++ b/srcpkgs/SuiteSparse/template
@@ -1,8 +1,7 @@
 # Template file for 'SuiteSparse'
 pkgname=SuiteSparse
-version=5.12.0
+version=5.13.0
 revision=1
-# XXX: re-enable TBB=-ltbb -DSPQR_CONFIG=-DHAVE_TBB when updating, if possible
 make_build_args="BLAS=-lblas LAPACK=-llapack"
 hostmakedepends="cmake chrpath"
 makedepends="libgomp-devel lapack-devel mpfr-devel"
@@ -12,7 +11,7 @@ license="custom:multiple"
 homepage="https://people.engr.tamu.edu/davis/suitesparse.html"
 changelog="https://raw.githubusercontent.com/DrTimothyAldenDavis/SuiteSparse/master/ChangeLog"
 distfiles="https://github.com/DrTimothyAldenDavis/SuiteSparse/archive/refs/tags/v${version}.tar.gz"
-checksum=5fb0064a3398111976f30c5908a8c0b40df44c6dd8f0cc4bfa7b9e45d8c647de
+checksum=59c6ca2959623f0c69226cf9afb9a018d12a37fab3a8869db5f6d7f83b6b147d
 
 do_build() {
 	make config library $make_build_args JOBS=$XBPS_MAKEJOBS

From 38f80d61d3c19d280d198db0d0e2ea8df74d399b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Fri, 23 Sep 2022 16:42:40 -0300
Subject: [PATCH 3/4] eclib: update to 20220621.

---
 common/shlibs          | 2 +-
 srcpkgs/eclib/template | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 54141e4cd4ba..3694a838a760 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4015,7 +4015,7 @@ libgf2x.so.3 gf2x-1.3.0_1
 libntl.so.44 ntl-11.5.1_1
 libflint.so.16 flintlib-2.8.0_1
 libarb.so.2 arb-2.20.0_1
-libec.so.8 eclib-20210625_1
+libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
 liblrcalc.so.2 lrcalc-2.1_1
diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 694a39ed4068..e33da0a859ca 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
-version=20210625
-revision=2
+version=20220621
+revision=1
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 hostmakedepends="automake autoconf-archive libtool"
@@ -11,7 +11,7 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="https://github.com/JohnCremona/eclib"
 distfiles="https://github.com/JohnCremona/eclib/archive/refs/tags/${version}.tar.gz"
-checksum=00333fd36afd237c9e6e410c7ab98536ddcd7fdc430e6837fe293247b835c572
+checksum=b0e06ffe6cd669354627eb1ff351cf558a4376dca1cf5c2d4ad042ae49fa5462
 
 pre_configure() {
 	autoreconf -fi

From 8961a928719db2a9eff61ea857f5af31de1dceae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 00:49:01 -0300
Subject: [PATCH 4/4] sagemath: update to 9.7.

---
 .../patches/01-dont_link_ratpoints.patch      |  10 -
 ...2-fix_get_shared_lib_path--see_29644.patch |  13 -
 .../patches/03-doctest_have_program.patch     |  20 -
 .../patches/04-doctest_sage_getfile.patch     |  22 -
 .../patches/05-fix_sage_getfile.patch         |  16 -
 .../sagemath/patches/07-ignore_warning.patch  |  15 -
 .../08-dont_run_pytest--see_31924.patch       |  27 -
 ...y_slow_doctest-polynomial_zmod_flint.patch |  14 -
 ...ry_slow_doctest-isogeny_small_degree.patch | 106 ---
 ...fix_very_slow_doctest-function_field.patch |  97 ---
 srcpkgs/sagemath/patches/matplotlib-3.6.patch |  72 ++
 srcpkgs/sagemath/patches/python-3.11.patch    |  45 ++
 .../trac-31355-upgrade_lrcalc_to_2.1.patch    | 670 ------------------
 .../trac-33170-fix_doctest_ipython_8.patch    |  40 --
 .../trac-33170b-fix_doctest_ipython_8.1.patch |  13 -
 ...2ddd4e2dc92469c1590ebf0c40f8f69bf579.patch | 126 ----
 ...2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch |  40 --
 .../trac-33336-fix_doctest_scipy_1.8.patch    |  19 -
 ...cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch |  53 ++
 ...d9deaeaa6380ab2f0d50276d911233c00a04.patch |  99 ---
 ...ff347454ac7f07e5918470b20e97b8f2357e.patch |  29 -
 ...0a0b14f67f4804e7113c3db41bbcf8a58296.patch |  26 -
 ...d4e56243c609f44afc1f21c112b026f9e1fe.patch |  42 ++
 ...1318f032caf8dc1c0de9489346d894409091.patch |  19 +
 .../zzz-loadable_module_extension.patch       |  14 -
 srcpkgs/sagemath/template                     |  12 +-
 26 files changed, 237 insertions(+), 1422 deletions(-)
 delete mode 100644 srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
 delete mode 100644 srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
 delete mode 100644 srcpkgs/sagemath/patches/03-doctest_have_program.patch
 delete mode 100644 srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
 delete mode 100644 srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
 delete mode 100644 srcpkgs/sagemath/patches/07-ignore_warning.patch
 delete mode 100644 srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
 delete mode 100644 srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
 delete mode 100644 srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
 delete mode 100644 srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
 create mode 100644 srcpkgs/sagemath/patches/matplotlib-3.6.patch
 create mode 100644 srcpkgs/sagemath/patches/python-3.11.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
 delete mode 100644 srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch

diff --git a/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch b/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
deleted file mode 100644
index e5c3f5776aa2..000000000000
--- a/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
+++ /dev/null
@@ -1,10 +0,0 @@
- - do not link ratpoints where it's not used
-
---- a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
-+++ b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
-@@ -1,5 +1,3 @@
--# distutils: libraries = ratpoints
--
- r"""
- Descent on elliptic curves over `\QQ` with a 2-isogeny
- """
diff --git a/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch b/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
deleted file mode 100644
index d3672b094c1c..000000000000
--- a/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
+++ /dev/null
@@ -1,13 +0,0 @@
- - fix _get_shared_lib_path() so we don't need to configure GAP_SO
-
---- a/src/sage/env.py
-+++ b/src/sage/env.py
-@@ -293,7 +293,7 @@ def _get_shared_lib_path(*libnames: str) -> Optional[str]:
-             if sys.platform == 'darwin':
-                 ext = 'dylib'
-             else:
--                ext = 'so'
-+                ext = 'so*'
- 
-             if SAGE_LOCAL:
-                 search_directories.append(Path(SAGE_LOCAL) / 'lib')
diff --git a/srcpkgs/sagemath/patches/03-doctest_have_program.patch b/srcpkgs/sagemath/patches/03-doctest_have_program.patch
deleted file mode 100644
index 27ba3776470c..000000000000
--- a/srcpkgs/sagemath/patches/03-doctest_have_program.patch
+++ /dev/null
@@ -1,20 +0,0 @@
- - we don't know `SAGE_VENV/bin` contains `sage`, but `sys.argv[0]` should
-   be the full path to `sage-ipython` and the same directory should have `sage`
-
---- a/src/sage/misc/sage_ostools.pyx
-+++ b/src/sage/misc/sage_ostools.pyx
-@@ -32,12 +32,11 @@ def have_program(program, path=None):
-         True
-         sage: have_program('there_is_not_a_program_with_this_name')
-         False
--        sage: from sage.env import SAGE_VENV
--        sage: have_program('sage', os.path.join(SAGE_VENV, 'bin'))
-+        sage: have_program('sage', os.path.dirname(sys.argv[0]))
-         True
-         sage: have_program('sage', '/there_is_not_a_path_with_this_name')
-         False
--        sage: have_program('there_is_not_a_program_with_this_name', os.path.join(SAGE_VENV, 'bin'))
-+        sage: have_program('there_is_not_a_program_with_this_name', "/bin")
-         False
-     """
-     if path is None:
diff --git a/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch b/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
deleted file mode 100644
index 95bce107f854..000000000000
--- a/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
+++ /dev/null
@@ -1,22 +0,0 @@
- - add one doctest for coverage
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -1341,10 +1342,12 @@ def sage_getfile(obj):
-     EXAMPLES::
- 
-         sage: from sage.misc.sageinspect import sage_getfile
--        sage: sage_getfile(sage.rings.rational)[-23:]
--        'sage/rings/rational.pyx'
--        sage: sage_getfile(Sq)[-42:]
--        'sage/algebras/steenrod/steenrod_algebra.py'
-+        sage: sage_getfile(sage.rings.rational)
-+        '...sage/rings/rational.pyx'
-+        sage: sage_getfile(Sq)
-+        '...sage/algebras/steenrod/steenrod_algebra.py'
-+        sage: sage_getfile(x)
-+        '...sage/symbolic/expression.pyx'
- 
-     The following tests against some bugs fixed in :trac:`9976`::
- 
-
diff --git a/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch b/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
deleted file mode 100644
index 56c58078f319..000000000000
--- a/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
+++ /dev/null
@@ -1,16 +0,0 @@
- - fix sage_getfile() by checking all possible EXTENSION_SUFFIXES
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -1400,8 +1403,9 @@ def sage_getfile(obj):
-         sourcefile = inspect.getabsfile(obj)
-     except TypeError: # this happens for Python builtins
-         return ''
--    if sourcefile.endswith(loadable_module_extension()):
--        return sourcefile[:-len(loadable_module_extension())]+os.path.extsep+'pyx'
-+    for suffix in import_machinery.EXTENSION_SUFFIXES:
-+        if sourcefile.endswith(suffix):
-+            return sourcefile[:-len(suffix)]+os.path.extsep+'pyx'
-     return sourcefile
- 
- 
diff --git a/srcpkgs/sagemath/patches/07-ignore_warning.patch b/srcpkgs/sagemath/patches/07-ignore_warning.patch
deleted file mode 100644
index 69668678a40b..000000000000
--- a/srcpkgs/sagemath/patches/07-ignore_warning.patch
+++ /dev/null
@@ -1,15 +0,0 @@
- - this ignores a warning caused by old notebook
-
---- a/src/sage/all.py
-+++ b/src/sage/all.py
-@@ -100,6 +100,9 @@ warnings.filterwarnings('ignore', category=DeprecationWarning,
-                         message='The distutils(.sysconfig module| package) is deprecated',
-                         module='Cython|distutils|numpy|sage.env|sage.features')
- 
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"invalid escape sequence '\\s'")
-+
- ################ end setup warnings ###############################
- 
- 
-
diff --git a/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch b/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
deleted file mode 100644
index 06bd2ccae6fb..000000000000
--- a/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
+++ /dev/null
@@ -1,27 +0,0 @@
- - using pytest is broken, see #31924
-
---- a/src/bin/sage-runtests
-+++ b/src/bin/sage-runtests
-@@ -154,21 +154,4 @@ if __name__ == "__main__":
-     DC = DocTestController(args, args.filenames)
-     err = DC.run()
- 
--    try:
--        exit_code_pytest = 0
--        import pytest
--        pytest_options = ["--import-mode", "importlib"]
--        if args.verbose:
--            pytest_options.append("-v")
--        exit_code_pytest = pytest.main(pytest_options + args.filenames)
--        if exit_code_pytest == 5:
--            # Exit code 5 means there were no test files, pass in this case
--            exit_code_pytest = 0
--
--    except ModuleNotFoundError:
--        print("Pytest is not installed, skip checking tests that rely on it.")
--
--    if err == 0:
--        sys.exit(exit_code_pytest)
--    else:
--        sys.exit(err)
-+    sys.exit(err)
diff --git a/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch b/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
deleted file mode 100644
index bae8387cf94a..000000000000
--- a/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
-+++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
-@@ -237,8 +237,9 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
- 
-             sage: a = ZZ['x'](range(100000))
-             sage: R = Integers(3)['x']
--            sage: R(a)  # long time (7s on sage.math, 2013)
--            2*x^99998 + ... + x
-+            sage: p = R(a)
-+            sage: p.truncate(10)  # testing the whole poly is VERY SLOW
-+            2*x^8 + x^7 + 2*x^5 + x^4 + 2*x^2 + x
-         """
-         sig_on()
-         fmpz_poly_get_nmod_poly(&self.x, x)
diff --git a/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch b/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
deleted file mode 100644
index f3da5bbb555e..000000000000
--- a/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
+++ /dev/null
@@ -1,106 +0,0 @@
-diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-index 43727346269..9d3ccd475cd 100644
---- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-+++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-@@ -186,7 +186,7 @@ def Psi(l, use_stored=True):
-         sage: assert Psi(3, use_stored=True) == Psi(3, use_stored=False)
-         sage: assert Psi(5, use_stored=True) == Psi(5, use_stored=False)
-         sage: assert Psi(7, use_stored=True) == Psi(7, use_stored=False)
--        sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False) # not tested (very long time)
-+        sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False)  # long time (2s)
-     """
-     if l not in [2, 3, 5, 7, 13]:
-         raise ValueError("Genus zero primes are 2, 3, 5, 7 or 13.")
-@@ -1207,7 +1207,7 @@ def isogenies_13_0(E, minimal_models=True):
-         sage: K.<a> = NumberField(f)
-         sage: E = EllipticCurve(j=K(0)); E.ainvs()
-         (0, 0, 0, 0, 1)
--        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]
-+        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]  # long time (4s)
-         [(0,
-           0,
-           20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
-@@ -1325,7 +1325,7 @@ def isogenies_13_1728(E, minimal_models=True):
-         sage: f = x^12 + 1092*x^10 - 432432*x^8 + 6641024*x^6 - 282896640*x^4 - 149879808*x^2 - 349360128
-         sage: K.<a> = NumberField(f)
-         sage: E = EllipticCurve(K, [1,0])
--        sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]
-+        sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]  # long time (3s)
-         [(0,
-         0,
-         0,
-@@ -1550,8 +1550,11 @@ def Psi2(l):
-         sage: from sage.schemes.elliptic_curves.isogeny_small_degree import Psi2
-         sage: Psi2(11)
-         x^5 - 55*x^4*u + 994*x^3*u^2 - 8774*x^2*u^3 + 41453*x*u^4 - 928945/11*u^5 + 33*x^4 + 276*x^3*u - 7794*x^2*u^2 + 4452*x*u^3 + 1319331/11*u^4 + 216*x^3*v - 4536*x^2*u*v + 31752*x*u^2*v - 842616/11*u^3*v + 162*x^3 + 38718*x^2*u - 610578*x*u^2 + 33434694/11*u^3 - 4536*x^2*v + 73872*x*u*v - 2745576/11*u^2*v - 16470*x^2 + 580068*x*u - 67821354/11*u^2 - 185976*x*v + 14143896/11*u*v + 7533*x - 20437029/11*u - 12389112/11*v + 19964151/11
--        sage: Psi2(71)  # long time (1 second)
--        -2209380711722505179506258739515288584116147237393815266468076436521/71*u^210 + ... - 14790739586438315394567393301990769678157425619440464678252277649/71
-+        sage: f = Psi2(71)
-+        sage: f.coefficient([0, 210, 0])
-+        -2209380711722505179506258739515288584116147237393815266468076436521/71
-+        sage: f.coefficient([0, 0, 0])
-+        -14790739586438315394567393301990769678157425619440464678252277649/71
- 
-     TESTS::
- 
-@@ -1665,17 +1668,17 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True):
-         sage: K = QuadraticField(5,'a')
-         sage: a = K.gen()
-         sage: E = EllipticCurve_from_j(184068066743177379840*a - 411588709724712960000)
--        sage: isogenies_prime_degree_genus_plus_0(E, 47) # long time (4.3s)
-+        sage: isogenies_prime_degree_genus_plus_0(E, 47)  # long time (2s)
-         [Isogeny of degree 47 from Elliptic Curve defined by y^2 = x^3 + (454562028554080355857852049849975895490560*a-1016431595837124114668689286176511361024000)*x + (-249456798429896080881440540950393713303830363999480904280965120*a+557802358738710443451273320227578156598454035482869042774016000) over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790? to Elliptic Curve defined by y^2 = x^3 + (39533118442361013730577638493616965245992960*a-88398740199669828340617478832005245173760000)*x + (214030321479466610282320528611562368963830105830555363061803253760*a-478586348074220699687616322532666163722004497458452316582576128000) over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790?]
- 
-         sage: K = QuadraticField(-66827,'a')
-         sage: a = K.gen()
-         sage: E = EllipticCurve_from_j(-98669236224000*a + 4401720074240000)
--        sage: isogenies_prime_degree_genus_plus_0(E, 59)   # long time (25s, 2012)
-+        sage: isogenies_prime_degree_genus_plus_0(E, 59)   # long time (5s)
-         [Isogeny of degree 59 from Elliptic Curve defined by y^2 = x^3 + (2605886146782144762297974784000*a+1893681048912773634944634716160000)*x + (-116918454256410782232296183198067568744071168000*a+17012043538294664027185882358514011304812871680000) over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I to Elliptic Curve defined by y^2 = x^3 + (-19387084027159786821400775098368000*a-4882059104868154225052787156713472000)*x + (-25659862010101415428713331477227179429538847260672000*a-2596038148441293485938798119003462972840818381946880000) over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I]
- 
-         sage: E = EllipticCurve_from_j(GF(13)(5))
--        sage: isogenies_prime_degree_genus_plus_0(E, 71) # long time
-+        sage: isogenies_prime_degree_genus_plus_0(E, 71)
-         [Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13, Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13]
- 
-         sage: E = EllipticCurve(GF(13),[0,1,1,1,0])
-@@ -2117,11 +2120,11 @@ def isogenies_prime_degree_general(E, l, minimal_models=True):
-         sage: isogenies_prime_degree_general(E, 19)
-         [Isogeny of degree 19 from Elliptic Curve defined by y^2 + y = x^3 - 1862*x - 30956 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - 672182*x + 212325489 over Rational Field]
-         sage: E = EllipticCurve([0, -1, 0, -6288, 211072])
--        sage: isogenies_prime_degree_general(E, 37)  # long time (10s)
-+        sage: isogenies_prime_degree_general(E, 37)  # long time (2s)
-         [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 - x^2 - 6288*x + 211072 over Rational Field to Elliptic Curve defined by y^2 = x^3 - x^2 - 163137088*x - 801950801728 over Rational Field]
- 
-         sage: E = EllipticCurve([-3440, 77658])
--        sage: isogenies_prime_degree_general(E, 43)  # long time (16s)
-+        sage: isogenies_prime_degree_general(E, 43)  # long time (2s)
-         [Isogeny of degree 43 from Elliptic Curve defined by y^2 = x^3 - 3440*x + 77658 over Rational Field to Elliptic Curve defined by y^2 = x^3 - 6360560*x - 6174354606 over Rational Field]
- 
-     Isogenies of degree equal to the characteristic are computed (but
-@@ -2175,7 +2178,7 @@ def isogenies_prime_degree_general(E, l, minimal_models=True):
- 
-         sage: K.<i> = QuadraticField(-1)
-         sage: E = EllipticCurve(K,[0,0,0,1,0])
--        sage: [phi.codomain().ainvs() for phi in E.isogenies_prime_degree(37)] # long time
-+        sage: [phi.codomain().ainvs() for phi in E.isogenies_prime_degree(37)]  # long time (6s)
-         [(0, 0, 0, -840*i + 1081, 0), (0, 0, 0, 840*i + 1081, 0)]
-     """
-     if not l.is_prime():
-@@ -2329,14 +2332,14 @@ def isogenies_prime_degree(E, l, minimal_models=True):
-         sage: E = EllipticCurve(GF(101), [-3440, 77658])
-         sage: E.isogenies_prime_degree(71) # fast
-         []
--        sage: E.isogenies_prime_degree(73) # slower (2s)
-+        sage: E.isogenies_prime_degree(73)  # long time (2s)
-         []
- 
-     Test that :trac:`32269` is fixed::
- 
-         sage: K = QuadraticField(-11)
-         sage: E = EllipticCurve(K, [0,1,0,-117,-541])
--        sage: E.isogenies_prime_degree(37)
-+        sage: E.isogenies_prime_degree(37)  # long time (9s)
-         [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I to Elliptic Curve defined by y^2 = x^3 + x^2 + (30800*a+123963)*x + (3931312*a-21805005) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I,
-          Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I to Elliptic Curve defined by y^2 = x^3 + x^2 + (-30800*a+123963)*x + (-3931312*a-21805005) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I]
- 
diff --git a/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch b/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
deleted file mode 100644
index 3b7b1ea843df..000000000000
--- a/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
+++ /dev/null
@@ -1,97 +0,0 @@
---- a/src/sage/rings/function_field/function_field.py
-+++ b/src/sage/rings/function_field/function_field.py
-@@ -111,22 +111,21 @@ Function fields over the algebraic field are supported::
-     sage: m = L.completion(pl, prec=5)
-     sage: m(x)
-     I + s + O(s^5)
--    sage: m(y)
-+    sage: m(y)                             # long time (4s)
-     -2*s + (-4 - I)*s^2 + (-15 - 4*I)*s^3 + (-75 - 23*I)*s^4 + (-413 - 154*I)*s^5 + O(s^6)
--    sage: m(y)^2 + m(y) + m(x) + 1/m(x)
-+    sage: m(y)^2 + m(y) + m(x) + 1/m(x)    # long time (8s)
-     O(s^5)
- 
- TESTS::
- 
-     sage: TestSuite(J).run()
--    sage: TestSuite(K).run(max_runs=1024) # long time (5s)
--    sage: TestSuite(L).run(max_runs=64)   # long time (10s)
--    sage: TestSuite(M).run(max_runs=32)   # long time (30s)
--    sage: TestSuite(N).run(max_runs=64, skip = '_test_derivation')  # long time (8s)
--    sage: TestSuite(O).run(max_runs=128, skip = '_test_derivation') # long time (8s)
--
-+    sage: TestSuite(K).run(max_runs=256)   # long time (10s)
-+    sage: TestSuite(L).run(max_runs=8)     # long time (25s)
-+    sage: TestSuite(M).run(max_runs=8)     # long time (35s)
-+    sage: TestSuite(N).run(max_runs=8, skip = '_test_derivation')    # long time (15s)
-+    sage: TestSuite(O).run()
-     sage: TestSuite(R).run()
--    sage: TestSuite(S).run() # long time (3s)
-+    sage: TestSuite(S).run()               # long time (4s)
- 
- Global function fields
- ----------------------
-@@ -287,7 +286,7 @@ class FunctionField(Field):
-         TESTS::
- 
-             sage: K.<x> = FunctionField(QQ)
--            sage: TestSuite(K).run()
-+            sage: TestSuite(K).run()               # long time (3s)
-         """
-         Field.__init__(self, base_field, names=names, category=category)
- 
-@@ -729,7 +728,7 @@ class FunctionField(Field):
-         EXAMPLES::
- 
-             sage: K.<x> = FunctionField(QQ)
--            sage: TestSuite(K).run() # indirect doctest
-+            sage: TestSuite(K).run()    # indirect doctest, long time (3s)
-         """
-         tester = self._tester(**options)
-         S = tester.some_elements()
-@@ -1209,7 +1208,7 @@ class FunctionField_polymod(FunctionField):
-             sage: K.<x> = FunctionField(QQ); R.<y> = K[]
-             sage: L = K.extension(y^5 - x^3 - 3*x + x*y); L
-             Function field in y defined by y^5 + x*y - x^3 - 3*x
--            sage: TestSuite(L).run()  # long time
-+            sage: TestSuite(L).run(max_runs=512)   # long time (15s)
- 
-         We can set the variable name, which doesn't have to be y::
- 
-@@ -2888,7 +2887,8 @@ class FunctionField_simple(FunctionField_polymod):
-             sage: F.<y> = K.extension(Y^3 - x^2*(x^2 + x + 1)^2)
-             sage: O = K.maximal_order()
-             sage: pls = [O.ideal(x-QQbar(sqrt(c))).place() for c in [-2, -1, 0, 1, 2]]
--            sage: all(q.place_below() == p for p in pls for q in F.places_above(p))
-+            sage: all(q.place_below() == p         # long time (4s)
-+            ....:     for p in pls for q in F.places_above(p))
-             True
-         """
-         R = self.base_field()
-@@ -3091,7 +3091,7 @@ class FunctionField_global(FunctionField_simple):
- 
-         sage: K.<x> = FunctionField(GF(4)); _.<Y> = K[]
-         sage: L.<y> = K.extension((1 - x)*Y^7 - x^3)
--        sage: L.gaps()
-+        sage: L.gaps()                         # long time (6s)
-         [1, 2, 3]
- 
-     or may define a trivial extension::
-@@ -3111,7 +3111,7 @@ class FunctionField_global(FunctionField_simple):
- 
-             sage: K.<x> = FunctionField(GF(5)); _.<Y> = K[]
-             sage: L.<y> = K.extension(Y^3 - (x^3 - 1)/(x^3 - 2))
--            sage: TestSuite(L).run()
-+            sage: TestSuite(L).run()               # long time (7s)
-         """
-         FunctionField_polymod.__init__(self, polynomial, names)
- 
-@@ -3807,7 +3807,7 @@ class RationalFunctionField(FunctionField):
- 
-             sage: K.<t> = FunctionField(CC); K
-             Rational function field in t over Complex Field with 53 bits of precision
--            sage: TestSuite(K).run()
-+            sage: TestSuite(K).run()               # long time (5s)
- 
-             sage: FunctionField(QQ[I], 'alpha')
-             Rational function field in alpha over Number Field in I with defining polynomial x^2 + 1 with I = 1*I
diff --git a/srcpkgs/sagemath/patches/matplotlib-3.6.patch b/srcpkgs/sagemath/patches/matplotlib-3.6.patch
new file mode 100644
index 000000000000..6afaf1b7162f
--- /dev/null
+++ b/srcpkgs/sagemath/patches/matplotlib-3.6.patch
@@ -0,0 +1,72 @@
+commit 5501e0de0dca1cff0355326dd42bd8c7e5749568
+Author: Gonzalo Tornaría <tornaria@cmat.edu.uy>
+Date:   Tue Oct 11 17:25:04 2022 -0300
+
+    Support matplotlib 3.6
+
+diff --git a/src/sage/plot/arc.py b/src/sage/plot/arc.py
+index bb834763afc..f65973bcbd5 100644
+--- a/src/sage/plot/arc.py
++++ b/src/sage/plot/arc.py
+@@ -273,9 +273,9 @@ class Arc(GraphicPrimitive):
+         p = patches.Arc((self.x, self.y),
+                         2. * self.r1,
+                         2. * self.r2,
+-                        fmod(self.angle, 2 * pi) * (180. / pi),
+-                        self.s1 * (180. / pi),
+-                        self.s2 * (180. / pi))
++                        angle=fmod(self.angle, 2 * pi) * (180. / pi),
++                        theta1=self.s1 * (180. / pi),
++                        theta2=self.s2 * (180. / pi))
+         return p
+ 
+     def bezier_path(self):
+diff --git a/src/sage/plot/ellipse.py b/src/sage/plot/ellipse.py
+index a77e6fe640a..c35bed574ef 100644
+--- a/src/sage/plot/ellipse.py
++++ b/src/sage/plot/ellipse.py
+@@ -192,7 +192,8 @@ class Ellipse(GraphicPrimitive):
+         options = self.options()
+         p = patches.Ellipse(
+                 (self.x,self.y),
+-                self.r1*2.,self.r2*2.,self.angle/pi*180.)
++                self.r1*2.,self.r2*2.,
++                angle=self.angle/pi*180.)
+         p.set_linewidth(float(options['thickness']))
+         p.set_fill(options['fill'])
+         a = float(options['alpha'])
+diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
+index e779e1210e3..8d620b5c625 100644
+--- a/src/sage/plot/graphics.py
++++ b/src/sage/plot/graphics.py
+@@ -2007,7 +2007,7 @@ class Graphics(WithEqualityById, SageObject):
+         We can also do custom formatting if you need it.  See above for full
+         details::
+ 
+-            sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex")
++            sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex") # not tested (broken with matplotlib 3.6)
+             Graphics object consisting of 1 graphics primitive
+ 
+         This is particularly useful when setting custom ticks in multiples
+@@ -2341,7 +2341,7 @@ class Graphics(WithEqualityById, SageObject):
+             sage: subplot = Figure().add_subplot(111)
+             sage: p._objects[0]._render_on_subplot(subplot)
+             sage: p._matplotlib_tick_formatter(subplot, **d)
+-            (<AxesSubplot:>,
++            (<AxesSubplot:...>,
+             <matplotlib.ticker.MaxNLocator object at ...>,
+             <matplotlib.ticker.MaxNLocator object at ...>,
+             <matplotlib.ticker.ScalarFormatter object at ...>,
+diff --git a/src/sage/plot/plot.py b/src/sage/plot/plot.py
+index b36ee57227c..5301a05c3dc 100644
+--- a/src/sage/plot/plot.py
++++ b/src/sage/plot/plot.py
+@@ -1741,7 +1741,7 @@ def plot(funcs, *args, **kwds):
+ 
+     ::
+ 
+-        sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex")
++        sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex") # not tested (broken with matplotlib 3.6)
+         Graphics object consisting of 1 graphics primitive
+ 
+     .. PLOT::
diff --git a/srcpkgs/sagemath/patches/python-3.11.patch b/srcpkgs/sagemath/patches/python-3.11.patch
new file mode 100644
index 000000000000..eafe76bfb794
--- /dev/null
+++ b/srcpkgs/sagemath/patches/python-3.11.patch
@@ -0,0 +1,45 @@
+--- a/src/sage/cpython/cython_metaclass.h
++++ b/src/sage/cpython/cython_metaclass.h
+@@ -66,7 +66,7 @@
+         }
+ 
+         /* Now, set t.__class__ to metaclass */
+-        Py_TYPE(t) = metaclass;
++        Py_SET_TYPE(t, metaclass);
+         PyType_Modified(t);
+     }
+     else
+--- a/src/sage/symbolic/ginac/numeric.cpp
++++ b/src/sage/symbolic/ginac/numeric.cpp
+@@ -52,7 +52,6 @@
+ #define register
+ #define PY_SSIZE_T_CLEAN
+ #include <Python.h>
+-#include <longintrepr.h>
+ #include "flint/fmpz.h"
+ #include "flint/fmpz_factor.h"
+ 
+--- a/src/sage/libs/gmp/pylong.pyx
++++ b/src/sage/libs/gmp/pylong.pyx
+@@ -32,7 +32,7 @@
+ from .mpz cimport *
+ 
+ cdef extern from *:
+-    Py_ssize_t* Py_SIZE_PTR "&Py_SIZE"(object)
++    void Py_SET_SIZE(object, Py_ssize_t)
+     int hash_bits """
+         #ifdef _PyHASH_BITS
+         _PyHASH_BITS         /* Python 3 */
+@@ -57,10 +57,8 @@
+     mpz_export(L.ob_digit, NULL,
+             -1, sizeof(digit), 0, PyLong_nails, z)
+     if mpz_sgn(z) < 0:
+-        # Set correct size (use a pointer to hack around Cython's
+-        # non-support for lvalues).
+-        sizeptr = Py_SIZE_PTR(L)
+-        sizeptr[0] = -pylong_size
++        # Set correct size
++        Py_SET_SIZE(L, -pylong_size)
+     return L
+ 
+ 
diff --git a/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch b/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
deleted file mode 100644
index 4bd6f4f4e2dc..000000000000
--- a/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
+++ /dev/null
@@ -1,670 +0,0 @@
-As produced by `git diff 9.5 9.6.beta3 -- src/sage/libs/lrcalc`
-
-diff --git a/src/sage/libs/lrcalc/lrcalc.pxd b/src/sage/libs/lrcalc/lrcalc.pxd
-deleted file mode 100644
-index 10b88db93f2..00000000000
---- a/src/sage/libs/lrcalc/lrcalc.pxd
-+++ /dev/null
-@@ -1,77 +0,0 @@
--# distutils: libraries = lrcalc
--
--cdef extern from "lrcalc/hashtab.h":
--    ctypedef struct hashtab:
--        pass
--
--    ctypedef struct hash_itr:
--        pass
--
--    ctypedef unsigned long hashkey_t
--    ctypedef int (*cmp_t) (void* a, void* b)
--    ctypedef hashkey_t (*hash_t) (void* a)
--
--    hashtab* hash_new(cmp_t cm, hash_t hsh)
--    void hash_free(hashtab *ht)
--
--    void* hash_lookup(hashtab *ht, void *key)
--    void* hash_insert(hashtab *ht, void *key, void *value)
--
--    bint hash_good(hash_itr)
--    void hash_first(hashtab* s, hash_itr itr)
--    void hash_next(hash_itr itr)
--    void* hash_key(hash_itr itr)
--    void* hash_value(hash_itr itr)
--    int hash_intvalue(hash_itr itr)
--
--cdef extern from "lrcalc/vector.h":
--    ctypedef struct vector:
--        size_t length
--        int* array
--
--    vector* v_new(int length)
--    void v_free(vector* v)
--    void v_print(vector *v)
--    int v_length(vector* v)
--    int v_elem(vector* v, int i)
--
--    ctypedef struct vecpair:
--        vector *first
--        vector *second
--
--    vector* vp_first(vecpair* vp)
--    vector* vp_second(vecpair* vp)
--
--cdef extern from "lrcalc/list.h":
--    cdef struct _list:
--        void **array
--        size_t allocated
--        size_t length
--    void l_free(_list *lst)
--
--cdef extern from "lrcalc/symfcn.h":
--    long long lrcoef_c "lrcoef"(vector* outer, vector* inner1, vector* inner2)
--    hashtab* mult_c "mult"(vector *sh1, vector *sh2, int maxrows)
--    hashtab* skew_c "skew"(vector *outer, vector *inner, int maxrows)
--    hashtab* coprod_c "coprod"(vector *part, int all)
--    void fusion_reduce_c "fusion_reduce"(hashtab* ht, int rows, int cols, int opt_zero)
--    _list *quantum_reduce_c "quantum_reduce"(hashtab* ht, int rows, int col)
--
--    ctypedef struct skewtab:
--        vector *outer
--        vector *inner
--        vector *conts
--        int maxrows
--        vector *conjugate
--        int rows
--        int cols
--        int matrix[1]
--
--    skewtab *st_new(vector *outer, vector *inner, vector *conts, int maxrows)
--    int st_next(skewtab *st)
--    void st_print(skewtab *st)
--    void st_free(skewtab *st)
--
--
--cdef extern from "lrcalc/schublib.h":
--    hashtab* mult_schubert_c "mult_schubert"(vector *sh1, vector *sh2, int rank)
-diff --git a/src/sage/libs/lrcalc/lrcalc.pyx b/src/sage/libs/lrcalc/lrcalc.py
-similarity index 60%
-rename from src/sage/libs/lrcalc/lrcalc.pyx
-rename to src/sage/libs/lrcalc/lrcalc.py
-index b591081ec4c..b541bfacd89 100644
---- a/src/sage/libs/lrcalc/lrcalc.pyx
-+++ b/src/sage/libs/lrcalc/lrcalc.py
-@@ -10,7 +10,8 @@ fusion products. All of the above are achieved by counting LR
- appropriate shape and content by iterating through them.
- Additionally, ``lrcalc`` handles products of Schubert polynomials.
- 
--The web page of ``lrcalc`` is `<http://sites.math.rutgers.edu/~asbuch/lrcalc/>`_.
-+The web page of ``lrcalc`` is
-+`<http://sites.math.rutgers.edu/~asbuch/lrcalc/>`_.
- 
- The following describes the Sage interface to this library.
- 
-@@ -36,12 +37,13 @@ Schur expansion::
-      [4, 2]: 1}
- 
- Same product, but include only partitions with at most 3 rows.  This
--corresponds to computing in the representation ring of gl(3)::
-+corresponds to computing in the representation ring of `\mathfrak{gl}(3)`::
- 
-     sage: lrcalc.mult([2,1], [2,1], 3)
-     {[2, 2, 2]: 1, [3, 2, 1]: 2, [3, 3]: 1, [4, 1, 1]: 1, [4, 2]: 1}
- 
--We can also compute the fusion product, here for sl(3) and level 2::
-+We can also compute the fusion product, here for `\mathfrak{sl}(3)`
-+and level 2::
- 
-     sage: lrcalc.mult([3,2,1], [3,2,1], 3,2)
-     {[4, 4, 4]: 1, [5, 4, 3]: 1}
-@@ -77,42 +79,38 @@ Multiply two Schubert polynomials::
-      [6, 2, 1, 4, 3, 5]: 1}
- 
- Same product, but include only permutations of 5 elements in the result.
--This corresponds to computing in the cohomology ring of Fl(5)::
-+This corresponds to computing in the cohomology ring of `Fl(5)`::
- 
-     sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3], 5)
-     {[4, 5, 1, 3, 2]: 1, [5, 3, 1, 4, 2]: 1, [5, 4, 1, 2, 3]: 1}
- 
- List all Littlewood-Richardson tableaux of skew shape `\mu/\nu`; in
- this example `\mu=[3,2,1]` and `\nu=[2,1]`. Specifying a third entry
--`maxrows` restricts the alphabet to `\{1,2,\ldots,maxrows\}`::
-+`M' = ``maxrows`` restricts the alphabet to `\{1,2,\ldots,M\}`::
- 
-     sage: list(lrcalc.lrskew([3,2,1],[2,1]))
-     [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
-     [[None, None, 1], [None, 2], [1]], [[None, None, 1], [None, 2], [3]]]
- 
-     sage: list(lrcalc.lrskew([3,2,1],[2,1],maxrows=2))
--    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]], [[None, None, 1], [None, 2], [1]]]
-+    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
-+     [[None, None, 1], [None, 2], [1]]]
- 
- .. TODO::
- 
--    use this library in the :class:`SymmetricFunctions` code, to
-+    Use this library in the :class:`SymmetricFunctions` code, to
-     make it easy to apply it to linear combinations of Schur functions.
- 
- .. SEEALSO::
- 
-     - :func:`lrcoef`
--
-     - :func:`mult`
--
-     - :func:`coprod`
--
-     - :func:`skew`
--
-     - :func:`lrskew`
--
-     - :func:`mult_schubert`
- 
--.. rubric:: Underlying algorithmic in lrcalc
-+.. RUBRIC:: Underlying algorithmic in lrcalc
- 
- Here is some additional information regarding the main low-level
- C-functions in `lrcalc`. Given two partitions ``outer`` and ``inner``
-@@ -187,180 +185,24 @@ AUTHORS:
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from sage.rings.integer cimport Integer
--from sage.structure.parent cimport Parent
- from sage.combinat.partition import _Partitions
- from sage.combinat.permutation import Permutation
--from sage.combinat.skew_tableau import SkewTableau
--
--
--cdef vector* iterable_to_vector(it):
--    """
--    Return an lrcalc vector (which is a list of integers) from a Python iterable.
--
--    TESTS::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector(Partition([3,2,1])); x   #indirect doctest
--        [3, 2, 1]
--    """
--    cdef vector* v
--    cdef list itr = list(it)
--    cdef int n = len(itr)
--    cdef int i
--    v = v_new(n)
--    for i in range(n):
--        v.array[i] = int(itr[i])
--    return v
--
--
--cdef list vector_to_list(vector *v):
--    """
--    Converts a lrcalc vector to Python list.
--
--    TESTS::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector([]); x         #indirect doctest
--        []
--    """
--    cdef int i, n
--    n = v_length(v)
--    cdef list result = [None]*n
--    for i in range(n):
--        result[i] = Integer(v_elem(v, i))
--    return result
--
--
--def test_iterable_to_vector(it):
--    """
--    A wrapper function for the cdef function ``iterable_to_vector``
--    and ``vector_to_list``, to test that they are working correctly.
-+from sage.combinat.skew_tableau import SemistandardSkewTableaux
-+from sage.combinat.skew_partition import SkewPartition
-+from sage.rings.integer import Integer
-+import lrcalc
- 
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector([3,2,1]); x
--        [3, 2, 1]
--    """
--    cdef vector *v = iterable_to_vector(it)
--    result = vector_to_list(v)
--    v_free(v)
--    return result
--
--
--cdef skewtab_to_SkewTableau(skewtab *st):
--    """
--    A wrapper function which transforms the data set ``st`` used in
--    ``lrcalc`` to a ``SkewTableau`` in Sage.
-+def _lrcalc_dict_to_sage(result):
-+    r"""
-+    Translate from lrcalc output format to Sage expected format.
- 
-     TESTS::
- 
--        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
--        sage: test_skewtab_to_SkewTableau([],[])
--        []
--    """
--    inner = vector_to_list(st.inner)
--    outer = vector_to_list(st.outer)
--    return SkewTableau(expr=[[inner[y] for y in range(len(outer))],
--                             [[st.matrix[x + y * st.cols] + 1
--                                for x in range(inner[y], outer[y])]
--                              for y in range(len(outer) - 1, -1, -1)]])
--
--
--def test_skewtab_to_SkewTableau(outer, inner):
--    """
--    A wrapper function for the cdef function ``skewtab_to_SkewTableau``
--    for testing purposes.
--
--    It constructs the first LR skew tableau of shape ``outer/inner``
--    as an ``lrcalc`` ``skewtab``, and converts it to a
--    :class:`SkewTableau`.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
--        sage: test_skewtab_to_SkewTableau([3,2,1],[])
--        [[1, 1, 1], [2, 2], [3]]
--        sage: test_skewtab_to_SkewTableau([4,3,2,1],[1,1]).pp()
--        .  1  1  1
--        .  2  2
--        1  3
--        2
--    """
--    cdef vector* o = iterable_to_vector(outer)
--    cdef vector* i = iterable_to_vector(inner+[0]*(len(outer)-len(inner)))
--    cdef skewtab* st = st_new(o, i, NULL, 0)
--    return skewtab_to_SkewTableau(st)
--
--
--cdef dict sf_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary representing a Schur function. The keys are
--    partitions and the values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
-         sage: from sage.libs.lrcalc.lrcalc import mult
--        sage: sorted(mult([1],[1]).items())        #indirect doctest
--        [([1, 1], 1), ([2], 1)]
--        sage: assert isinstance(mult([1],[1]),dict)#indirect doctest
--    """
--    cdef hash_itr itr
--    cdef dict result = {}
--    cdef list p
--    hash_first(ht, itr)
--    while hash_good(itr):
--        p = vector_to_list(<vector*> hash_key(itr))
--        result[_Partitions(p)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
--
--cdef dict schubert_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary corresponding to a Schubert polynomial whose keys
--    are permutations and whose values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import mult_schubert
--        sage: mult_schubert([3,2,1], [1,2,3])      #indirect doctest
--        {[3, 2, 1]: 1}
--    """
--    cdef hash_itr itr
--    cdef dict result = {}
--    hash_first(ht, itr)
--    while hash_good(itr):
--        p = vector_to_list(<vector*> hash_key(itr))
--        result[Permutation(p)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
--
--cdef dict vp_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary corresponding to the coproduct of a Schur function whose keys are
--    pairs of partitions and whose values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import coprod
--        sage: coprod([1])      #indirect doctest
--        {([1], []): 1}
-+        sage: mult([2,1],[3,2,1],3) # indirect doctest
-+        {[3, 3, 3]: 1, [4, 3, 2]: 2, [4, 4, 1]: 1, [5, 2, 2]: 1, [5, 3, 1]: 1}
-     """
--    cdef hash_itr itr
--    cdef vecpair* vp
--    cdef dict result = {}
--    hash_first(ht, itr)
--    while hash_good(itr):
--        vp = <vecpair*> hash_key(itr)
--        p1 = _Partitions(vector_to_list(vp_first(vp)))
--        p2 = _Partitions(vector_to_list(vp_second(vp)))
--        result[(p1, p2)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
-+    return {_Partitions(la): Integer(k) for la, k in result.items()}
- 
- def lrcoef_unsafe(outer, inner1, inner2):
-     r"""
-@@ -371,13 +213,11 @@ def lrcoef_unsafe(outer, inner1, inner2):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
--
--    - ``inner1`` -- a partition.
-+    - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
-+    - ``inner1`` -- a partition
-+    - ``inner2`` -- a partition
- 
--    - ``inner2`` -- a partition.
--
--    .. warning::
-+    .. WARNING::
- 
-        This function does not do any check on its input.  If you want
-        to use a safer version, use :func:`lrcoef`.
-@@ -392,18 +232,7 @@ def lrcoef_unsafe(outer, inner1, inner2):
-         sage: lrcoef_unsafe([2,1,1,1,1], [2,1], [2,1])
-         0
-     """
--    cdef long long result
--    cdef vector *o
--    cdef vector *i1
--    cdef vector *i2
--    o = iterable_to_vector(outer)
--    i1 = iterable_to_vector(inner1)
--    i2 = iterable_to_vector(inner2)
--    result = lrcoef_c(o, i1, i2)
--    v_free(o)
--    v_free(i1)
--    v_free(i2)
--    return Integer(result)
-+    return Integer(lrcalc.lrcoef(outer, inner1, inner2))
- 
- 
- def lrcoef(outer, inner1, inner2):
-@@ -415,11 +244,9 @@ def lrcoef(outer, inner1, inner2):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
--
--    - ``inner1`` -- a partition.
--
--    - ``inner2`` -- a partition.
-+    - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
-+    - ``inner1`` -- a partition
-+    - ``inner2`` -- a partition
- 
-     .. NOTE::
- 
-@@ -436,7 +263,6 @@ def lrcoef(outer, inner1, inner2):
-         1
-         sage: lrcoef([2,1,1,1,1], [2,1], [2,1])
-         0
--
-     """
-     return lrcoef_unsafe(_Partitions(outer), _Partitions(inner1), _Partitions(inner2))
- 
-@@ -451,13 +277,9 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-     INPUT:
- 
-     - ``part1`` -- a partition
--
-     - ``part2`` -- a partition
--
-     - ``maxrows`` -- (optional) an integer
--
-     - ``level`` -- (optional) an integer
--
-     - ``quantum`` -- (optional) an element of a ring
- 
-     If ``maxrows`` is specified, then only partitions with at most
-@@ -479,7 +301,8 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-         sage: sorted(mult([2],[2]).items())
-         [([2, 2], 1), ([3, 1], 1), ([4], 1)]
-         sage: sorted(mult([2,1],[2,1]).items())
--        [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1), ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
-+        [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1),
-+         ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
-         sage: sorted(mult([2,1],[2,1],maxrows=2).items())
-         [([3, 3], 1), ([4, 2], 1)]
-         sage: mult([2,1],[3,2,1],3)
-@@ -510,44 +333,24 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-     if quantum is not None and (level is None or maxrows is None):
-         raise ValueError('missing parameters maxrows or level')
- 
--    cdef vector* v1 = iterable_to_vector(part1)
--    cdef vector* v2 = iterable_to_vector(part2)
--    if maxrows is None:
--        maxrows = 0
--    cdef hashtab* ht = mult_c(v1, v2, int(maxrows))
--    cdef hashtab* tab
--    cdef dict result
--
-     if quantum is None:
-         if level is not None:
--            fusion_reduce_c(ht, int(maxrows), int(level), int(0))
--        result = sf_hashtab_to_dict(ht)
--        v_free(v1)
--        v_free(v2)
--        hash_free(ht)
--        return result
-+            return _lrcalc_dict_to_sage(lrcalc.mult_fusion(part1, part2, maxrows, level))
-+        if maxrows is None:
-+            maxrows = -1
-+        return _lrcalc_dict_to_sage(lrcalc.mult(part1, part2, maxrows))
- 
-     # Otherwise do quantum multiplication
--    cdef _list *qlist
--    cdef dict temp
--    qlist = quantum_reduce_c(ht, int(maxrows), int(level))
--    # The above call frees the memory associated with ht
--    v_free(v1)
--    v_free(v2)
--
--    cdef Parent P = quantum.parent()
--    result = {}
--    for i in range(qlist.length):
--        tab = <hashtab*>(qlist.array[i])
--        temp = sf_hashtab_to_dict(tab)
--        for k in temp:
--            result[k] = result.get(k, P.zero()) + quantum**i * temp[k]
--        hash_free(tab)
--    l_free(qlist)
--    return result
--
--
--def skew(outer, inner, maxrows=0):
-+    result = lrcalc.mult_quantum(part1, part2, maxrows, level, degrees=True)
-+    P = quantum.parent()
-+    output = {}
-+    for i,k in result.items():
-+        la = _Partitions(i[0])
-+        output[la] = output.get(la, P.zero()) + k * quantum**(i[1])
-+    return output
-+
-+
-+def skew(outer, inner, maxrows=-1):
-     """
-     Compute the Schur expansion of a skew Schur function.
- 
-@@ -557,11 +360,9 @@ def skew(outer, inner, maxrows=0):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition.
--
--    - ``inner`` -- a partition.
--
--    - ``maxrows`` -- an integer or ``None``.
-+    - ``outer`` -- a partition
-+    - ``inner`` -- a partition
-+    - ``maxrows`` -- an integer or ``None``
- 
-     If ``maxrows`` is specified, then only partitions with at most
-     this number of rows are included in the result.
-@@ -572,14 +373,7 @@ def skew(outer, inner, maxrows=0):
-         sage: sorted(skew([2,1],[1]).items())
-         [([1, 1], 1), ([2], 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(outer)
--    cdef vector* v2 = iterable_to_vector(inner)
--    cdef hashtab* ht = skew_c(v1, v2, int(maxrows))
--    result = sf_hashtab_to_dict(ht)
--    v_free(v1)
--    v_free(v2)
--    hash_free(ht)
--    return result
-+    return _lrcalc_dict_to_sage(lrcalc.skew(outer, inner, maxrows))
- 
- 
- def coprod(part, all=0):
-@@ -592,9 +386,8 @@ def coprod(part, all=0):
- 
-     INPUT:
- 
--    - ``part`` -- a partition.
--
--    - ``all`` -- an integer.
-+    - ``part`` -- a partition
-+    - ``all`` -- an integer
- 
-     If ``all`` is non-zero then all terms are included in the result.
-     If ``all`` is zero, then only pairs of partitions ``(part1,
-@@ -609,12 +402,9 @@ def coprod(part, all=0):
-         sage: sorted(coprod([2,1]).items())
-         [(([1, 1], [1]), 1), (([2], [1]), 1), (([2, 1], []), 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(part)
--    cdef hashtab* ht = coprod_c(v1, int(all))
--    result = vp_hashtab_to_dict(ht)
--    v_free(v1)
--    hash_free(ht)
--    return result
-+    result = lrcalc.coprod(part, all)
-+    return {tuple([_Partitions(mu) for mu in la]): Integer(k)
-+            for la, k in result.items()}
- 
- 
- def mult_schubert(w1, w2, rank=0):
-@@ -627,11 +417,9 @@ def mult_schubert(w1, w2, rank=0):
- 
-     INPUT:
- 
--    - ``w1`` -- a permutation.
--
--    - ``w2`` -- a permutation.
--
--    - ``rank`` -- an integer.
-+    - ``w1`` -- a permutation
-+    - ``w2`` -- a permutation
-+    - ``rank`` -- an integer
- 
-     If ``rank`` is non-zero, then only permutations from the symmetric
-     group `S(\mathrm{rank})` are included in the result.
-@@ -646,33 +434,24 @@ def mult_schubert(w1, w2, rank=0):
-          ([6, 4, 3, 1, 2, 5], 1), ([6, 5, 2, 1, 3, 4], 1),
-          ([7, 3, 4, 1, 2, 5, 6], 1), ([7, 4, 2, 1, 3, 5, 6], 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(w1)
--    cdef vector* v2 = iterable_to_vector(w2)
--    cdef hashtab* ht = mult_schubert_c(v1, v2, int(rank))
--    result = schubert_hashtab_to_dict(ht)
--    v_free(v1)
--    v_free(v2)
--    hash_free(ht)
--    return result
-+    result = lrcalc.schubmult(w1, w2, rank)
-+    return {Permutation(list(la)):Integer(k) for la,k in result.items()}
- 
- 
--def lrskew(outer, inner, weight=None, maxrows=0):
-+def lrskew(outer, inner, weight=None, maxrows=-1):
-     r"""
-     Iterate over the skew LR tableaux of shape ``outer / inner``.
- 
-     INPUT:
- 
-     - ``outer`` -- a partition
--
-     - ``inner`` -- a partition
--
-     - ``weight`` -- a partition (optional)
--
--    - ``maxrows`` -- an integer (optional)
-+    - ``maxrows`` -- a positive integer (optional)
- 
-     OUTPUT: an iterator of :class:`SkewTableau`
- 
--    Specifying ``maxrows`` restricts the alphabet to `\{1,2,\ldots,maxrows\}`.
-+    Specifying ``maxrows`` = `M` restricts the alphabet to `\{1,2,\ldots,M\}`.
- 
-     Specifying ``weight`` returns only those tableaux of given content/weight.
- 
-@@ -702,22 +481,40 @@ def lrskew(outer, inner, weight=None, maxrows=0):
- 
-         sage: list(lrskew([3,2,1],[2], weight=[3,1]))
-         [[[None, None, 1], [1, 1], [2]]]
-+
-+    TESTS::
-+
-+        sage: from sage.libs.lrcalc.lrcalc import lrskew
-+        sage: list(lrskew([3,2,1],[2], weight=[]))
-+        []
-+        sage: list(lrskew([3,2,1],[2], weight=[0]))
-+        []
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[]))
-+        [[[None, None, None], [None, None], [None]]]
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[0]))
-+        [[[None, None, None], [None, None], [None]]]
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[1]))
-+        []
-     """
--    cdef vector* o = iterable_to_vector(outer)
--    cdef vector* i = iterable_to_vector(inner + [0]*(len(outer) - len(inner)))
--    cdef skewtab* st = st_new(o, i, NULL, int(maxrows))
-+    iterator = lrcalc.lr_iterator(outer, inner, maxrows)
-+    shape = SkewPartition([outer, inner])
- 
-     if weight is None:
--        yield skewtab_to_SkewTableau(st)
--        while st_next(st):
--            yield skewtab_to_SkewTableau(st)
-+        ST = SemistandardSkewTableaux(shape)
-+        for data in iterator:
-+            yield ST.from_shape_and_word(shape, [i+1 for i in data])
-     else:
-         wt = _Partitions(weight)
--        r = skewtab_to_SkewTableau(st)
--        if r.weight() == wt:
--            yield r
--        while st_next(st):
--            r = skewtab_to_SkewTableau(st)
--            if r.weight() == wt:
--                yield r
--    st_free(st)
-+        ST = SemistandardSkewTableaux(shape, wt)
-+        m = len(wt)
-+        for data in iterator:
-+            w = [0] * m
-+            for j in data:
-+                if j >= m:
-+                    # We know they are not equal, so make the check below quick
-+                    w = None
-+                    break
-+                w[j] += 1
-+            if w == wt:
-+                yield ST.from_shape_and_word(shape, [i+1 for i in data])
-+
diff --git a/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch b/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
deleted file mode 100644
index 1e2e0ba90742..000000000000
--- a/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-As produced by `git diff a90a3146{^^,}`
-
-diff --git a/src/sage/repl/interface_magic.py b/src/sage/repl/interface_magic.py
-index 8a455b69b0e..a93e1c9e04c 100644
---- a/src/sage/repl/interface_magic.py
-+++ b/src/sage/repl/interface_magic.py
-@@ -260,7 +260,7 @@ class InterfaceMagic(object):
-             2
-             120
-             sage: shell.run_cell('%%gap foo\n1+1;\n')
--            ...File "<string>", line unknown
-+            ...File...<string>...
-             SyntaxError: Interface magics have no options, got "foo"
-             <BLANKLINE>
-             sage: shell.run_cell('%%gap?')
-diff --git a/src/sage/repl/interpreter.py b/src/sage/repl/interpreter.py
-index 7468afe52d7..06c47b7374a 100644
---- a/src/sage/repl/interpreter.py
-+++ b/src/sage/repl/interpreter.py
-@@ -78,9 +78,9 @@ Check that Cython source code appears in tracebacks::
-     dummy line
-     ...
-     ZeroDivisionError...Traceback (most recent call last)
--    <ipython-input-...> in <module>...
-+    ...in <module>...
-     ----> 1 Integer(1)/Integer(0)
--    .../sage/rings/integer.pyx in sage.rings.integer.Integer...div...
-+    .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
-     ...
-     -> ...                  raise ZeroDivisionError("rational division by zero")
-        ....:            x = <Rational> Rational.__new__(Rational)
-@@ -423,7 +423,7 @@ def SagePreparseTransformer(lines):
-         sage: from sage.repl.interpreter import get_test_shell
-         sage: shell = get_test_shell()
-         sage: shell.run_cell(bad_syntax)
--          File "<string>", line unknown
-+          File...<string>...
-         SyntaxError: Mismatched ']'
-         <BLANKLINE>
-         sage: shell.quit()
diff --git a/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch b/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
deleted file mode 100644
index 853813b0f5bd..000000000000
--- a/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Fix for ipython 8.1
-
---- a/src/sage/repl/interpreter.py
-+++ b/src/sage/repl/interpreter.py
-@@ -78,7 +78,7 @@ Check that Cython source code appears in tracebacks::
-     dummy line
-     ...
-     ZeroDivisionError...Traceback (most recent call last)
--    ...in <module>...
-+    ...
-     ----> 1 Integer(1)/Integer(0)
-     .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
-     ...
diff --git a/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch b/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
deleted file mode 100644
index b861af7ec982..000000000000
--- a/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
+++ /dev/null
@@ -1,126 +0,0 @@
-From 24cc94b1988a90f3bd22a2368ec30c086283af13 Mon Sep 17 00:00:00 2001
-From: Antonio Rojas <arojas@archlinux.org>
-Date: Sun, 16 Jan 2022 11:55:04 +0100
-Subject: Add abs tol to some arb tests
-
----
- src/sage/functions/error.py    |  2 +-
- src/sage/rings/complex_arb.pyx |  6 +++---
- src/sage/rings/real_arb.pyx    | 10 +++++-----
- 3 files changed, 9 insertions(+), 9 deletions(-)
-
-diff --git a/src/sage/functions/error.py b/src/sage/functions/error.py
-index f48d04f..06f0b24 100644
---- a/src/sage/functions/error.py
-+++ b/src/sage/functions/error.py
-@@ -267,7 +267,7 @@ class Function_erf(BuiltinFunction):
- 
-         Check that real ball evaluation is fixed :trac:`28061`::
- 
--            sage: RealBallField(128)(erf(5))
-+            sage: RealBallField(128)(erf(5)) # abs tol 1e-38
-             [0.99999999999846254020557196514981165651 +/- 7.33e-39]
-         """
-         R = parent or s_parent(x)
-diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
-index f986970..93ff565 100644
---- a/src/sage/rings/complex_arb.pyx
-+++ b/src/sage/rings/complex_arb.pyx
-@@ -3974,8 +3974,8 @@ cdef class ComplexBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: CBF(20).erfc()
--            [5.39586561160790e-176 +/- ...e-191]
-+            sage: CBF(20).erfc() # abs tol 1e-190
-+            [5.39586561160790e-176 +/- 6.73e-191]
-             sage: CBF(100, 100).erfc()
-             [0.00065234366376858 +/- ...e-18] + [-0.00393572636292141 +/- ...e-18]*I
-         """
-@@ -4280,7 +4280,7 @@ cdef class ComplexBall(RingElement):
- 
-         TESTS:
- 
--            sage: CBF(Shi(I))
-+            sage: CBF(Shi(I)) # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]*I
-         """
-         cdef ComplexBall result = self._new()
-diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
-index 4a81784..292bfea 100644
---- a/src/sage/rings/real_arb.pyx
-+++ b/src/sage/rings/real_arb.pyx
-@@ -3506,7 +3506,7 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1/2).erf()
-+            sage: RBF(1/2).erf() # abs tol 1e-16
-             [0.520499877813047 +/- 6.10e-16]
-         """
-         cdef RealBall res = self._new()
-@@ -3556,12 +3556,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Si()
-+            sage: RBF(1).Si() # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]
- 
-         TESTS::
- 
--            sage: RBF(Si(1))
-+            sage: RBF(Si(1)) # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]
-         """
-         cdef RealBall res = self._new()
-@@ -3578,12 +3578,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Ci()  # abs tol 1e-16
-+            sage: RBF(1).Ci()  # abs tol 1e-15
-             [0.337403922900968 +/- 3.25e-16]
- 
-         TESTS::
- 
--            sage: RBF(Ci(1))  # abs tol 1e-16
-+            sage: RBF(Ci(1))  # abs tol 1e-15
-             [0.337403922900968 +/- 3.25e-16]
-         """
-         cdef RealBall res = self._new()
--- 
-cgit v1.0-1-gd88e
-
-
-From 53532ddd4e2dc92469c1590ebf0c40f8f69bf579 Mon Sep 17 00:00:00 2001
-From: Antonio Rojas <arojas@archlinux.org>
-Date: Sun, 16 Jan 2022 14:16:53 +0100
-Subject: Decrease abs tol
-
----
- src/sage/rings/real_arb.pyx | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
-index 292bfea..eb30f7f 100644
---- a/src/sage/rings/real_arb.pyx
-+++ b/src/sage/rings/real_arb.pyx
-@@ -3578,12 +3578,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Ci()  # abs tol 1e-15
-+            sage: RBF(1).Ci()  # abs tol 5e-16
-             [0.337403922900968 +/- 3.25e-16]
- 
-         TESTS::
- 
--            sage: RBF(Ci(1))  # abs tol 1e-15
-+            sage: RBF(Ci(1))  # abs tol 5e-16
-             [0.337403922900968 +/- 3.25e-16]
-         """
-         cdef RealBall res = self._new()
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch b/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
deleted file mode 100644
index d4e8f8be60e3..000000000000
--- a/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From 33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c Mon Sep 17 00:00:00 2001
-From: Michael Orlitzky <michael@orlitzky.com>
-Date: Mon, 24 Jan 2022 09:03:29 -0500
-Subject: Trac #33226: update doctests for giac-1.7.0.45.
-
-We have two failing doctests with giac-1.7.0.45: one is a trivial
-tolerance issue, but the other is a symbolic integration result for
-which giac is no longer willing to return a symbolic answer. We add
-"abs tol" to the numeric test, and drop the symbolic one entirely.
----
- src/sage/functions/min_max.py | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/src/sage/functions/min_max.py b/src/sage/functions/min_max.py
-index fc18373..9b7d6d9 100644
---- a/src/sage/functions/min_max.py
-+++ b/src/sage/functions/min_max.py
-@@ -228,15 +228,15 @@ class MaxSymbolic(MinMax_base):
-             ...
-             TypeError: cannot evaluate symbolic expression numerically
- 
--        ::
-+        We can usually integrate these expressions, but can't
-+        guarantee a symbolic answer in closed form::
- 
-             sage: f = max_symbolic(sin(x), cos(x))
-             sage: r = integral(f, x, 0, 1)
-             ...
--            sage: r
--            sqrt(2) - cos(1)
--            sage: r.n()
-+            sage: r.n()  # abs tol 1e-8
-             0.873911256504955
-+
-         """
-         return max_symbolic(args)
- 
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch b/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
deleted file mode 100644
index 19b69700a4f6..000000000000
--- a/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-commit 9c8235e44ffb509efa8a3ca6cdb55154e2b5066d
-Author: Antonio Rojas <arojas@archlinux.org>
-Date:   Sun Feb 13 19:53:14 2022 +0100
-
-    Fix deprecation warning with scipy 1.8
-
-diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-index e9b60dae5ec..7932167b41d 100644
---- a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-@@ -356,7 +356,7 @@ Sage example in ./linsolve.tex, line 2230::
- 
- Sage example in ./linsolve.tex, line 2609::
- 
--  sage: from scipy.sparse.linalg.dsolve import *
-+  sage: from scipy.sparse.linalg import factorized
-   sage: from scipy.sparse import lil_matrix
-   sage: from numpy import array
-   sage: n = 200
diff --git a/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch b/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
new file mode 100644
index 000000000000..e052e306e7a1
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
@@ -0,0 +1,53 @@
+From 6330cee1a69229b2f5d8ac4a09a73d8152f5e14d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Mon, 28 Feb 2022 23:15:16 -0300
+Subject: trac 33360: avoid factoring in is_prime()
+
+In the added TEST, the ideal norm is product of two primes but factoring
+this product takes about half an hour, so factoring the ideal is slow.
+
+To fix the issue, we only factor the ideal if the norm is a prime power.
+---
+ src/sage/rings/number_field/number_field_ideal.py | 22 ++++++++++++++++++++++
+ 1 file changed, 22 insertions(+)
+
+diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
+index f785f22..10d1f88 100644
+--- a/src/sage/rings/number_field/number_field_ideal.py
++++ b/src/sage/rings/number_field/number_field_ideal.py
+@@ -995,10 +995,32 @@ class NumberFieldIdeal(Ideal_generic):
+             False
+             sage: K.ideal(17).is_prime()  # ramified
+             False
++
++        TESTS::
++
++        Check that we do not factor the norm of the ideal, this used
++        to take half an hour, see :trac:`33360`
++
++           sage: K.<a,b,c> = NumberField([x^2-2,x^2-3,x^2-5])
++           sage: t = (((-2611940*c + 1925290/7653)*b - 1537130/7653*c
++           ....:       + 10130950)*a + (1343014/7653*c - 8349770)*b
++           ....:       + 6477058*c - 2801449990/4002519)
++           sage: t.is_prime()
++           False
++
+         """
+         try:
+             return self._pari_prime is not None
+         except AttributeError:
++            K = self.number_field().pari_nf()
++            I = self.pari_hnf()
++            # This would be better, but it is broken in pari 2.13.3.
++            #   self._pari_prime = K.idealismaximal(I) or None
++            # Instead we factor I, but only if the norm is a prime power
++            n = K.idealnorm(I)
++            if n.denominator() > 1 or not n.isprimepower():
++                self._pari_prime = None
++                return False
+             F = self.factor()  # factorization with caching
+             if len(F) != 1 or F[0][1] != 1:
+                 self._pari_prime = None
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
deleted file mode 100644
index 9ba7ca5a6b7d..000000000000
--- a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
+++ /dev/null
@@ -1,99 +0,0 @@
-From 609dd9deaeaa6380ab2f0d50276d911233c00a04 Mon Sep 17 00:00:00 2001
-From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
-Date: Fri, 4 Mar 2022 16:07:09 -0800
-Subject: sage.manifolds: Update doctests for SymPy 1.10
-
----
- src/sage/manifolds/continuous_map.py              | 3 +--
- src/sage/manifolds/differentiable/diff_form.py    | 4 ++--
- src/sage/manifolds/differentiable/tensorfield.py  | 8 ++++----
- src/sage/manifolds/vector_bundle_fiber_element.py | 2 +-
- 4 files changed, 8 insertions(+), 9 deletions(-)
-
-diff --git a/src/sage/manifolds/continuous_map.py b/src/sage/manifolds/continuous_map.py
-index a6356e7..f6f9b6d 100644
---- a/src/sage/manifolds/continuous_map.py
-+++ b/src/sage/manifolds/continuous_map.py
-@@ -1357,8 +1357,7 @@ class ContinuousMap(Morphism):
-             sage: Phi.coord_functions(c_uv, c_xyz)
-             Coordinate functions (u*v, u/v, u + v) on the Chart (M, (u, v))
-             sage: Phi.coord_functions(c_UV, c_xyz)
--            Coordinate functions (-U**2/4 + V**2/4, -(U + V)/(U - V), V)
--             on the Chart (M, (U, V))
-+            Coordinate functions (-U**2/4 + V**2/4, (-U - V)/(U - V), V) on the Chart (M, (U, V))
-             sage: Phi.coord_functions(c_UV, c_XYZ)
-             Coordinate functions ((-U**3 + U**2*V + U*V**2 + 2*U*V + 6*U - V**3
-              - 2*V**2 + 6*V)/(2*(U - V)), (U**3/4 - U**2*V/4 - U*V**2/4 + U*V
-diff --git a/src/sage/manifolds/differentiable/diff_form.py b/src/sage/manifolds/differentiable/diff_form.py
-index 70dd8fb..0aa3469 100644
---- a/src/sage/manifolds/differentiable/diff_form.py
-+++ b/src/sage/manifolds/differentiable/diff_form.py
-@@ -266,7 +266,7 @@ class DiffForm(TensorField):
- 
-         sage: s = a.wedge(b)
-         sage: s.display(eU)
--        a∧b = -x*(2*x*y + 1) dx∧dy
-+        a∧b = x*(-2*x*y - 1) dx∧dy
-         sage: s.display(eV)
-         a∧b = (u**3/8 + u**2*v/8 - u*v**2/8 + u/4 - v**3/8 + v/4) du∧dv
- 
-@@ -275,7 +275,7 @@ class DiffForm(TensorField):
-         sage: f = M.scalar_field({c_xy: (x+y)^2, c_uv: u^2}, name='f')
-         sage: s = f*a
-         sage: s.display(eU)
--        f*a = -y*(x**2 + 2*x*y + y**2) dx + x*(x**2 + 2*x*y + y**2) dy
-+        f*a = y*(-x**2 - 2*x*y - y**2) dx + x*(x**2 + 2*x*y + y**2) dy
-         sage: s.display(eV)
-         f*a = u**2*v/2 du - u**3/2 dv
- 
-diff --git a/src/sage/manifolds/differentiable/tensorfield.py b/src/sage/manifolds/differentiable/tensorfield.py
-index 2775be9..6bc5c50 100644
---- a/src/sage/manifolds/differentiable/tensorfield.py
-+++ b/src/sage/manifolds/differentiable/tensorfield.py
-@@ -334,7 +334,7 @@ class TensorField(ModuleElementWithMutability):
-         sage: f.display()  # long time
-         t(a,b): S^2 → ℝ
-         on U: (x, y) ↦ -2*x*y - 3*x - y**2
--        on V: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+        on V: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
- 
-     The vectors can be defined only on subsets of `S^2`, the domain of the
-     result is then the common subset::
-@@ -343,12 +343,12 @@ class TensorField(ModuleElementWithMutability):
-         sage: s.display()  # long time
-         t(a,b): U → ℝ
-            (x, y) ↦ -2*x*y - 3*x - y**2
--        on W: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+        on W: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
-         sage: s = t(a.restrict(U), b.restrict(W))  # long time
-         sage: s.display()  # long time
-         t(a,b): W → ℝ
-            (x, y) ↦ -2*x*y - 3*x - y**2
--           (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+           (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
- 
-     The tensor itself can be defined only on some open subset of `S^2`,
-     yielding a result whose domain is this subset::
-@@ -356,7 +356,7 @@ class TensorField(ModuleElementWithMutability):
-         sage: s = t.restrict(V)(a,b)  # long time
-         sage: s.display()  # long time
-         t(a,b): V → ℝ
--           (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+           (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
-         on W: (x, y) ↦ -2*x*y - 3*x - y**2
- 
-     Tests regarding the multiplication by a scalar field::
-diff --git a/src/sage/manifolds/vector_bundle_fiber_element.py b/src/sage/manifolds/vector_bundle_fiber_element.py
-index 29ee81d..048275a 100644
---- a/src/sage/manifolds/vector_bundle_fiber_element.py
-+++ b/src/sage/manifolds/vector_bundle_fiber_element.py
-@@ -110,4 +110,4 @@ class VectorBundleFiberElement(FiniteRankFreeModuleElement):
-             desc += str(self._name) + " "
-         desc += "in the fiber of {} at {}".format(self._vbundle._name,
-                                                   self._point)
--        return desc
-\ No newline at end of file
-+        return desc
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
deleted file mode 100644
index f5ac180baa90..000000000000
--- a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From c49eff347454ac7f07e5918470b20e97b8f2357e Mon Sep 17 00:00:00 2001
-From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
-Date: Fri, 4 Mar 2022 15:14:43 -0800
-Subject: src/sage/calculus/calculus.py: Update laplace doctest for sympy 1.10
-
----
- src/sage/calculus/calculus.py | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/src/sage/calculus/calculus.py b/src/sage/calculus/calculus.py
-index 9c2f226..b335093 100644
---- a/src/sage/calculus/calculus.py
-+++ b/src/sage/calculus/calculus.py
-@@ -1639,9 +1639,9 @@ def laplace(ex, t, s, algorithm='maxima'):
-         sage: laplace(dirac_delta(t), t, s)
-         1
-         sage: F, a, cond = laplace(dirac_delta(t), t, s, algorithm='sympy')
--        sage: a, cond
--        (-oo, True)
--        sage: F       # random - sympy <1.9 includes undefined heaviside(0) in answer
-+        sage: a, cond  # random - sympy <1.10 gives (-oo, True)
-+        (0, True)
-+        sage: F        # random - sympy <1.9 includes undefined heaviside(0) in answer
-         1
-         sage: laplace(dirac_delta(t), t, s, algorithm='giac')
-         1
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch b/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
deleted file mode 100644
index 8e7bb64f5b01..000000000000
--- a/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From a04a0a0b14f67f4804e7113c3db41bbcf8a58296 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
-Date: Mon, 28 Mar 2022 20:39:59 -0300
-Subject: Trac #33585: fix doctest when dochtml is missing...
-
-...but sphinx is available in PYTHONPATH.
----
- src/sage/misc/sagedoc.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/sage/misc/sagedoc.py b/src/sage/misc/sagedoc.py
-index 4b3853f..08c4225 100644
---- a/src/sage/misc/sagedoc.py
-+++ b/src/sage/misc/sagedoc.py
-@@ -1401,7 +1401,7 @@ class _sage_doc:
-             "...**File:**...**Type:**...**Definition:** identity_matrix..."
-             sage: identity_matrix.__doc__ in browse_sage_doc(identity_matrix, 'rst')
-             True
--            sage: browse_sage_doc(identity_matrix, 'html', False)             # optional - sphinx
-+            sage: browse_sage_doc(identity_matrix, 'html', False)             # optional - sphinx sagemath_doc_html
-             '...div...File:...Type:...Definition:...identity_matrix...'
- 
-         In the 'text' version, double colons have been replaced with
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch b/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
new file mode 100644
index 000000000000..977a42400e59
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
@@ -0,0 +1,42 @@
+commit 5db5d4e56243c609f44afc1f21c112b026f9e1fe
+Author: Oscar Benjamin <oscar.j.benjamin@gmail.com>
+Date:   Mon Jul 11 21:24:01 2022 +0100
+
+    Update doctests for SymPy 1.11
+    
+    Doctests related to SymPy's rsolve function are updated in:
+    
+    src/sage/calculus/test_sympy.py
+    src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+    
+    The form of the output from SymPy has changed since
+    
+    https://github.com/sympy/sympy/pull/23567
+
+diff --git a/src/sage/calculus/test_sympy.py b/src/sage/calculus/test_sympy.py
+index 7cf7f3f6bfd..927e6ee4fb6 100644
+--- a/src/sage/calculus/test_sympy.py
++++ b/src/sage/calculus/test_sympy.py
+@@ -193,7 +193,7 @@ This was fixed in Sympy, see :trac:`14437`::
+     sage: u = Function('u')
+     sage: n = Symbol('n', integer=True)
+     sage: f = u(n+2) - u(n+1) + u(n)/4
+-    sage: 2**n * rsolve(f,u(n))
+-    C1*n + C0
++    sage: expand(2**n * rsolve(f,u(n)))
++    2*C1*n + C0
+ 
+ """
+diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+index 1062f4f7e8c..f53f813d793 100644
+--- a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
++++ b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+@@ -382,7 +382,7 @@ Sage example in ./recequadiff.tex, line 1798::
+   sage: from sympy import rsolve_hyper
+   sage: from sympy.abc import n
+   sage: rsolve_hyper([-2,1],2**(n+2),n)
+-  2**n*C0 + 2**(n + 2)*(C0 + n/2)
++  2**n*C0 + 2**(n + 1)*n
+ 
+ """
+ 
diff --git a/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch b/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
new file mode 100644
index 000000000000..8fedcb78cf71
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
@@ -0,0 +1,19 @@
+commit 04971318f032caf8dc1c0de9489346d894409091
+Author: John H. Palmieri <jhpalmieri64@gmail.com>
+Date:   Wed Aug 31 14:22:26 2022 -0700
+
+    trac 34465: fix invalid escape sequence in functions/special.py
+
+diff --git a/src/sage/functions/special.py b/src/sage/functions/special.py
+index 02596e49620..901f02f9bee 100644
+--- a/src/sage/functions/special.py
++++ b/src/sage/functions/special.py
+@@ -849,7 +849,7 @@ class EllipticF(BuiltinFunction):
+     - :wikipedia:`Elliptic_integral#Incomplete_elliptic_integral_of_the_first_kind`
+     """
+     def __init__(self):
+-        """
++        r"""
+         EXAMPLES::
+ 
+             sage: loads(dumps(elliptic_f))
diff --git a/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch b/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch
deleted file mode 100644
index f3eb0aad2cca..000000000000
--- a/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch
+++ /dev/null
@@ -1,14 +0,0 @@
- - this is not a proper fix... should fix sage_getfile() instead
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -187,7 +187,8 @@ def loadable_module_extension():
-         True
-     """
-     # Return the full platform-specific extension module suffix
--    return import_machinery.EXTENSION_SUFFIXES[0]
-+    # PATCHED for void linux, we use the shortest extension (.so)
-+    return import_machinery.EXTENSION_SUFFIXES[-1]
- 
- 
- def isclassinstance(obj):
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 0d793262d572..8df50e4e13b6 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,7 +1,7 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=9.5
-revision=2
+version=9.7
+revision=1
 wrksrc=sage-$version
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
@@ -33,12 +33,9 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="http://sagemath.org/"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=8d70a3b26080802c5b2e33dda4c23795d494d8216a0c2ecfcd608ebab0e64ff6
+checksum=9f26f14aa322e3cf38a71835b12ac34b23026b467f74d54b064c5d025e76fbfd
 
 post_patch() {
-	# these are unused and nothing else uses ratpoints
-	rm sage/libs/ratpoints.{pyx,pxd}
-
 	# git tree needs bootstrapping
 	pushd $wrksrc/build/pkgs/sagelib
 	PATH=../../bin:$PATH BOOTSTRAP_QUIET=no ./bootstrap
@@ -65,6 +62,7 @@ do_configure() {
 
 pre_build() {
 	export PYTHONPATH=../sage-setup
+	export PYTHONDONTWRITEBYTECODE=yes
 	export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
 }
 
@@ -77,6 +75,7 @@ post_build() {
 
 pre_install() {
 	export PYTHONPATH=../sage-setup
+	export PYTHONDONTWRITEBYTECODE=yes
 	export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
 }
 
@@ -104,6 +103,7 @@ post_install() {
 do_check() {
 	_scripts=$(cd build/scripts* && pwd)
 	export PYTHONPATH=$(cd build/lib* && pwd)
+	export PYTHONDONTWRITEBYTECODE=yes
 
 	# get out of $build_wrksrc, otherwise python picks the wrong sage module
 	cd $(mktemp -dp build)

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: DRAFT: sagemath update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (5 preceding siblings ...)
  2022-10-11 21:35 ` [PR PATCH] [Updated] " tornaria
@ 2022-10-11 21:37 ` tornaria
  2022-10-12 14:46 ` [PR PATCH] [Updated] " tornaria
                   ` (25 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: tornaria @ 2022-10-11 21:37 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 227 bytes --]

New comment by tornaria on void-packages repository

https://github.com/void-linux/void-packages/pull/39876#issuecomment-1275301640

Comment:
I've just pushed a version that passes all doctests (x86_64) using matplotlib 3.6.1.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PR PATCH] [Updated] DRAFT: sagemath update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (6 preceding siblings ...)
  2022-10-11 21:37 ` tornaria
@ 2022-10-12 14:46 ` tornaria
  2022-10-12 18:18 ` dkwo
                   ` (24 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: tornaria @ 2022-10-12 14:46 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1883 bytes --]

There is an updated pull request by tornaria against master on the void-packages repository

https://github.com/tornaria/void-packages sagemath-update
https://github.com/void-linux/void-packages/pull/39876

DRAFT: sagemath update to 9.7
This includes #39838, #39840, #39846, #39872, #39866, also update eclib-20220621.

For now I'm reverting python3-matplotlib to 3.5.3_1 since 3.6.0_1 gives a lot of problems (#39857 adds python3-contourpy which will solve some, but I think there are more issues).

I want to make sure everything works ok and the full testsuite passes as is. Then I'll just move matplotlib back to 3.6.0_1 and try to see if it's feasible to fix or workaround the issues (sagemath-the-distro is still on matplotlib 3.5.2 and I didn't find anything about the update to 3.6.0)

<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: currently running the testsuite in --long after the update of singular.

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/39876.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-sagemath-update-39876.patch --]
[-- Type: text/x-diff, Size: 189487 bytes --]

From 9869c3e3425cb02afb15bd641488e4497b4986af Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 19:14:02 -0300
Subject: [PATCH 01/12] flintlib: update to 2.9.0.

---
 common/shlibs             | 2 +-
 srcpkgs/flintlib/template | 7 ++-----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 9f95ac87a7ea..f5ecd7a99746 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4013,7 +4013,7 @@ libgtkdatabox.so.1 gtkdatabox3-1.0.0_1
 libxcvt.so.0 libxcvt-0.1.1_1
 libgf2x.so.3 gf2x-1.3.0_1
 libntl.so.44 ntl-11.5.1_1
-libflint.so.16 flintlib-2.8.0_1
+libflint.so.17 flintlib-2.9.0_1
 libarb.so.2 arb-2.20.0_1
 libec.so.8 eclib-20210625_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index 968dbcb525c2..bf5cfe0c0bd9 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,6 +1,6 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.8.5
+version=2.9.0
 revision=1
 wrksrc="flint-${version}"
 build_style=configure
@@ -14,11 +14,10 @@ license="LGPL-2.1-or-later"
 homepage="https://flintlib.org"
 changelog="https://raw.githubusercontent.com/wbhart/flint2/trunk/NEWS"
 distfiles="https://flintlib.org/flint-${version}.tar.gz"
-checksum=5911fedff911100f15781f35e3a4fa934fe60e4aea02a8c10cc8918101c1eed8
+checksum=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
-build_options_default=""
 
 if [ -z "$CROSS_BUILD" ]; then
 	build_options_default+=" ntl"
@@ -28,8 +27,6 @@ case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*|aarch64*|arm*|ppc64*) build_options_default+=" openblas";;
 esac
 
-CFLAGS="-D_GNU_SOURCE" # needed for cpu_set_t
-
 flintlib-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision} mpfr-devel"
 	short_desc+=" - development files"

From cfeb9c641c0a6eb80522266ef2ba9dfd5e7904ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 19:16:18 -0300
Subject: [PATCH 02/12] arb: update to 2.23.0.

---
 srcpkgs/arb/template | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
index 52f11ef83c90..84a62c7ffdba 100644
--- a/srcpkgs/arb/template
+++ b/srcpkgs/arb/template
@@ -1,6 +1,6 @@
 # Template file for 'arb'
 pkgname=arb
-version=2.22.1
+version=2.23.0
 revision=1
 build_style=configure
 configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
@@ -11,9 +11,7 @@ license="LGPL-2.1-or-later"
 homepage="https://arblib.org"
 changelog="https://raw.githubusercontent.com/fredrik-johansson/arb/master/doc/source/history.rst"
 distfiles="https://github.com/fredrik-johansson/arb/archive/${version}.tar.gz"
-checksum=1ef85518eee04885e8a90196498bc75e4e2410621d4184f2bc01d46b7080a243
-
-CFLAGS="-D_GNU_SOURCE" # needed for cpu_set_t
+checksum=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
 
 arb-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"

From 3dc8a2fb02999bed1de4923b0e23100ff9de66a6 Mon Sep 17 00:00:00 2001
From: dkwo <nicolopiazzalunga@gmail.com>
Date: Mon, 10 Oct 2022 10:14:06 -0400
Subject: [PATCH 03/12] singular: update to 4.3.1p2 (fix gcc 12 build)

---
 common/shlibs             | 10 +++++-----
 srcpkgs/singular/template | 26 ++++++++++++++------------
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index f5ecd7a99746..108073356e34 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4055,11 +4055,11 @@ libumfpack.so.5 SuiteSparse-5.10.1_1
 libecl.so.21.2 ecl-21.2.1_1
 libecm.so.1 ecm-7.0.4_3
 libcliquer.so.1 cliquer-1.22_1
-libSingular-4.3.0.so singular-4.3.0_1
-libfactory-4.3.0.so singular-4.3.0_1
-libpolys-4.3.0.so singular-4.3.0_1
-libomalloc-0.9.6.so singular-4.3.0_1
-libsingular_resources-4.3.0.so singular-4.3.0_1
+libSingular-4.3.1.so singular-4.3.1p2_1
+libfactory-4.3.1.so singular-4.3.1p2_1
+libpolys-4.3.1.so singular-4.3.1p2_1
+libomalloc-0.9.6.so singular-4.3.1p2_1
+libsingular_resources-4.3.1.so singular-4.3.1p2_1
 libbrial.so.3 brial-1.2.10_1
 libbrial_groebner.so.3 brial-1.2.10_1
 libm4ri-0.0.20200125.so m4ri-20200125_1
diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index f23659ef5d83..a30beef915d2 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,25 +1,27 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.0
+version=4.3.1p2
 revision=1
+_majver=${version%p*}
+wrksrc=singular-${_majver}
 build_style=gnu-configure
 configure_args="--with-readline=ncurses
-	--enable-gfanlib
-	--enable-Singular
-	--enable-factory
-	--disable-doc
-	--disable-polymake
-	--without-python
-	--with-libparse
-	ac_cv_lib_cddgmp_dd_free_global_constants=yes"
+ --enable-gfanlib
+ --enable-Singular
+ --enable-factory
+ --disable-doc
+ --disable-polymake
+ --without-python
+ --with-libparse
+ ac_cv_lib_cddgmp_dd_free_global_constants=yes"
 hostmakedepends="perl tar doxygen"
 makedepends="flintlib-devel cddlib-devel readline-devel graphviz"
 short_desc="Computer algebra system for polynomial computations"
-maintainer="dkwo <nicolopiazzalunga@gmail.com>"
+maintainer="dkwo <npiazza@disroot.org>"
 license="GPL-2.0-or-later"
 homepage="https://www.singular.uni-kl.de"
-distfiles="https://www.singular.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${version//./-}/singular-${version}.tar.gz"
-checksum=74f38288203720e3f280256f2f8deb94030dd032b4237d844652aff0faab36e7
+distfiles="https://www.singular.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${_majver//./-}/singular-${version}.tar.gz"
+checksum=95814bba0f0bd0290cd9799ec1d2ecc6f4c8a4e6429d9a02eb7f9c4e5649682a
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From 9ce30bdf92fee48de1435eaebe8a2db560a12cf9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 19:34:32 -0300
Subject: [PATCH 04/12] pari-nflistdata: update to 20220729.

Note that upstream doesn't change the filenames on updates.
We use the timestamp in the http server to manage the version.

In b7a1bbcde8d5277e7c9186928aca11bbd2d67dc2 the checksum was "fixed"
(i.e. changed to the checksum of the new version) but the package in the
void packages repository was not rebuilt.

Now we change the version so it's rebuilt.
---
 srcpkgs/pari-nflistdata/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/pari-nflistdata/template b/srcpkgs/pari-nflistdata/template
index cd64a18eabb9..ef4e37a791d0 100644
--- a/srcpkgs/pari-nflistdata/template
+++ b/srcpkgs/pari-nflistdata/template
@@ -1,6 +1,6 @@
 # Template file for 'pari-nflistdata'
 pkgname=pari-nflistdata
-version=20220326
+version=20220729
 revision=1
 create_wrksrc=yes
 short_desc="PARI/GP database needed by nflist"

From b76fd349a88259fdb2e66811ced86ff2e41a0bf8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 19:59:20 -0300
Subject: [PATCH 05/12] pari: update to 2.15.0.

---
 common/shlibs         | 3 +--
 srcpkgs/pari/template | 7 ++++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 108073356e34..53415e6baf74 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4004,8 +4004,7 @@ libsimavrparts.so.1 simavr-1.6_2
 libsword-1.8.1.so libsword-1.8.1_6
 libgivaro.so.9 givaro-4.1.1_1
 liblinbox.so.0 linbox-1.6.3_1
-libpari-gmp.so.7 pari-2.13.0_1
-libpari-gmp-tls.so.7 pari-2.13.2_1
+libpari-gmp-tls.so.8 pari-2.15.0_1
 libtree-sitter.so.0 tree-sitter-0.19.0_1
 libplanarity.so.0 planarity-3.0.1.1_1
 libgap.so.0 gap-4.11.1_1
diff --git a/srcpkgs/pari/template b/srcpkgs/pari/template
index 8bac1e0343f8..873cddb4946f 100644
--- a/srcpkgs/pari/template
+++ b/srcpkgs/pari/template
@@ -1,6 +1,6 @@
 # Template file for 'pari'
 pkgname=pari
-version=2.13.4
+version=2.15.0
 revision=1
 build_style=configure
 build_helper=qemu
@@ -11,14 +11,15 @@ make_check_target=statest-all
 make_install_target="install install-lib-sta install-lib-dyn"
 hostmakedepends="perl texlive"
 makedepends="gmp-devel readline-devel $(vopt_if x11 libX11-devel)"
-checkdepends="pari-elldata-small pari-galdata pari-galpol-small pari-seadata-small"
+checkdepends="pari-elldata-small pari-galdata pari-galpol-small
+ pari-seadata-small pari-nflistdata"
 short_desc="Fast computations library in number theory"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="https://pari.math.u-bordeaux.fr"
 changelog="https://pari.math.u-bordeaux.fr/cgi-bin/gitweb.cgi?p=pari.git;a=blob_plain;f=CHANGES;hb=refs/heads/pari-${version%.*}"
 distfiles="https://pari.math.u-bordeaux.fr/pub/pari/unix/${pkgname}-${version}.tar.gz"
-checksum=bcde9eceae1592814381c1697cdb7063567b6504201b1be47bb58920f3bce185
+checksum=e474851e0d16d4e4f9a0d9612c746a2ae7c9a1ec185d04c440b1c74a85755685
 
 build_options="x11 pthreads"
 build_options_default="x11 pthreads"

From 814885a38d662ffd59d267b5fef6022b8c8e6223 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 20:33:23 -0300
Subject: [PATCH 06/12] gp2c: update to 0.0.13.

---
 srcpkgs/gp2c/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gp2c/template b/srcpkgs/gp2c/template
index f82cf95c2d90..9cf0f6fdce6e 100644
--- a/srcpkgs/gp2c/template
+++ b/srcpkgs/gp2c/template
@@ -1,6 +1,6 @@
 # Template file for 'gp2c'
 pkgname=gp2c
-version=0.0.12pl1
+version=0.0.13
 revision=1
 build_style=gnu-configure
 hostmakedepends="perl"
@@ -12,4 +12,4 @@ license="GPL-2.0-or-later"
 homepage="http://pari.math.u-bordeaux.fr/"
 changelog="http://pari.math.u-bordeaux.fr/cgi-bin/gitweb.cgi?p=gp2c.git;a=blob_plain;f=ChangeLog;hb=HEAD"
 distfiles="${homepage}pub/pari/GP2C/${pkgname}-${version}.tar.gz"
-checksum=79a8c46f7ad3331e4d8ae6af6b496c4742fd73a73b996b3ca7ead61452ca6e8d
+checksum=261374eca73ebd76c112a9593dca28b64812aa762561fda5a4b2c2cd79a69d36

From 636f6dd1865a1f9246a4448eae83cdb6e46e63c5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Fri, 23 Sep 2022 16:42:40 -0300
Subject: [PATCH 07/12] eclib: update to 20220621.

---
 common/shlibs          | 2 +-
 srcpkgs/eclib/template | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 53415e6baf74..2fbb20102502 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4014,7 +4014,7 @@ libgf2x.so.3 gf2x-1.3.0_1
 libntl.so.44 ntl-11.5.1_1
 libflint.so.17 flintlib-2.9.0_1
 libarb.so.2 arb-2.20.0_1
-libec.so.8 eclib-20210625_1
+libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
 liblrcalc.so.2 lrcalc-2.1_1
diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 694a39ed4068..e33da0a859ca 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
-version=20210625
-revision=2
+version=20220621
+revision=1
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 hostmakedepends="automake autoconf-archive libtool"
@@ -11,7 +11,7 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="https://github.com/JohnCremona/eclib"
 distfiles="https://github.com/JohnCremona/eclib/archive/refs/tags/${version}.tar.gz"
-checksum=00333fd36afd237c9e6e410c7ab98536ddcd7fdc430e6837fe293247b835c572
+checksum=b0e06ffe6cd669354627eb1ff351cf558a4376dca1cf5c2d4ad042ae49fa5462
 
 pre_configure() {
 	autoreconf -fi

From 28a63ef5a50b6af0e700cdc02e9db6461a21b7ff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:19 -0300
Subject: [PATCH 08/12] lcalc: revbump for pari 2.15.0

---
 srcpkgs/lcalc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lcalc/template b/srcpkgs/lcalc/template
index 270078df9a54..3c6be5fcbc28 100644
--- a/srcpkgs/lcalc/template
+++ b/srcpkgs/lcalc/template
@@ -1,7 +1,7 @@
 # Template file for 'lcalc'
 pkgname=lcalc
 version=2.0.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--with-pari"
 hostmakedepends="automake libtool pkg-config gengetopt"

From 650d68b687e73fb1f37cf31d77885273fa7ffeeb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:20 -0300
Subject: [PATCH 09/12] giac: update to 1.9.0.21.

---
 srcpkgs/giac/patches/giac-pari-2.15.patch | 20 ++++++++++++++++++++
 srcpkgs/giac/template                     |  4 ++--
 2 files changed, 22 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/giac/patches/giac-pari-2.15.patch

diff --git a/srcpkgs/giac/patches/giac-pari-2.15.patch b/srcpkgs/giac/patches/giac-pari-2.15.patch
new file mode 100644
index 000000000000..be409be38f53
--- /dev/null
+++ b/srcpkgs/giac/patches/giac-pari-2.15.patch
@@ -0,0 +1,20 @@
+ANYARG patch
+
+diff --git a/src/pari.cc b/src/pari.cc
+index 76ce8e1..50d08ab 100644
+--- a/src/pari.cc
++++ b/src/pari.cc
+@@ -40,6 +40,13 @@ using namespace std;
+ 
+ #ifdef HAVE_LIBPARI
+ 
++// Anyarg disappeared from PARI 2.15.0
++#ifdef __cplusplus
++#  define ANYARG ...
++#else
++#  define ANYARG
++#endif
++
+ #ifdef HAVE_PTHREAD_H
+ #include <pthread.h>
+ #endif
diff --git a/srcpkgs/giac/template b/srcpkgs/giac/template
index e892c8bf7506..31045e9128ee 100644
--- a/srcpkgs/giac/template
+++ b/srcpkgs/giac/template
@@ -1,6 +1,6 @@
 # Template file for 'giac'
 pkgname=giac
-version=1.9.0.7
+version=1.9.0.21
 revision=1
 wrksrc="giac-${version%.*}"
 build_style=gnu-configure
@@ -14,7 +14,7 @@ license="GPL-3.0-or-later"
 homepage="https://www-fourier.ujf-grenoble.fr/~parisse/giac.html"
 changelog="https://www-fourier.ujf-grenoble.fr/~parisse/install_en#new"
 distfiles="https://www-fourier.ujf-grenoble.fr/~parisse/debian/dists/stable/main/source/giac_${version%.*}-${version##*.}.tar.gz"
-checksum=72016988b7180e9b630ecabecc60969213e7b61418c2598c91acbaec139fd740
+checksum=120cd16f2e033817302d2a03a22bd413dc1d85df8b225ba4f76b93a7805b07fe
 
 # need more than 4*65536 stack, see try_parse() in gen.cc line 11812
 LDFLAGS="-Wl,-z,stack-size=2097152"

From dc5582fca8dc721e56706afb73fddd9946abd6ef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:21 -0300
Subject: [PATCH 10/12] python3-cysignals: revbump for pari 2.15.0

---
 srcpkgs/python3-cysignals/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/python3-cysignals/template b/srcpkgs/python3-cysignals/template
index 4655eead2a9c..08d1010976ff 100644
--- a/srcpkgs/python3-cysignals/template
+++ b/srcpkgs/python3-cysignals/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-cysignals'
 pkgname=python3-cysignals
 version=1.11.2
-revision=1
+revision=2
 wrksrc="cysignals-${version}"
 build_style=python3-module
 hostmakedepends="python3-setuptools python3-Cython autoconf"

From 1ef07032a03968b63854240623109b5d71f8c60a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:58:16 -0300
Subject: [PATCH 11/12] python3-cypari2: revbump for pari 2.15.0

---
 srcpkgs/python3-cypari2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/python3-cypari2/template b/srcpkgs/python3-cypari2/template
index 9ded61101e8e..9db3070a087c 100644
--- a/srcpkgs/python3-cypari2/template
+++ b/srcpkgs/python3-cypari2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-cypari2'
 pkgname=python3-cypari2
 version=2.1.2
-revision=1
+revision=2
 wrksrc=cypari2-${version}
 build_style=python3-module
 hostmakedepends="python3-setuptools python3-Cython pari perl"

From 0a9293a7b5f6c09df6112836316756545af4ea97 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 00:49:01 -0300
Subject: [PATCH 12/12] sagemath: update to 9.7.

---
 .../patches/01-dont_link_ratpoints.patch      |   10 -
 ...2-fix_get_shared_lib_path--see_29644.patch |   13 -
 .../patches/03-doctest_have_program.patch     |   20 -
 .../patches/04-doctest_sage_getfile.patch     |   22 -
 .../patches/05-fix_sage_getfile.patch         |   16 -
 .../sagemath/patches/07-ignore_warning.patch  |   15 -
 .../08-dont_run_pytest--see_31924.patch       |   27 -
 ...y_slow_doctest-polynomial_zmod_flint.patch |   14 -
 ...ry_slow_doctest-isogeny_small_degree.patch |  106 -
 ...fix_very_slow_doctest-function_field.patch |   97 -
 srcpkgs/sagemath/patches/matplotlib-3.6.patch |   72 +
 srcpkgs/sagemath/patches/python-3.11.patch    |   45 +
 .../sagemath/patches/sagemath-pari-2.15.patch | 1750 +++++++++++++++++
 .../patches/sagemath-pari-2.15b.patch         |   29 +
 .../trac-31355-upgrade_lrcalc_to_2.1.patch    |  670 -------
 .../trac-33170-fix_doctest_ipython_8.patch    |   40 -
 .../trac-33170b-fix_doctest_ipython_8.1.patch |   13 -
 ...2ddd4e2dc92469c1590ebf0c40f8f69bf579.patch |  126 --
 ...2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch |   40 -
 .../trac-33336-fix_doctest_scipy_1.8.patch    |   19 -
 ...cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch |   53 +
 ...d9deaeaa6380ab2f0d50276d911233c00a04.patch |   99 -
 ...ff347454ac7f07e5918470b20e97b8f2357e.patch |   29 -
 ...0a0b14f67f4804e7113c3db41bbcf8a58296.patch |   26 -
 ...d4e56243c609f44afc1f21c112b026f9e1fe.patch |   42 +
 ...1318f032caf8dc1c0de9489346d894409091.patch |   19 +
 .../zzz-loadable_module_extension.patch       |   14 -
 srcpkgs/sagemath/template                     |   12 +-
 28 files changed, 2016 insertions(+), 1422 deletions(-)
 delete mode 100644 srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
 delete mode 100644 srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
 delete mode 100644 srcpkgs/sagemath/patches/03-doctest_have_program.patch
 delete mode 100644 srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
 delete mode 100644 srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
 delete mode 100644 srcpkgs/sagemath/patches/07-ignore_warning.patch
 delete mode 100644 srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
 delete mode 100644 srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
 delete mode 100644 srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
 delete mode 100644 srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
 create mode 100644 srcpkgs/sagemath/patches/matplotlib-3.6.patch
 create mode 100644 srcpkgs/sagemath/patches/python-3.11.patch
 create mode 100644 srcpkgs/sagemath/patches/sagemath-pari-2.15.patch
 create mode 100644 srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
 delete mode 100644 srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch

diff --git a/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch b/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
deleted file mode 100644
index e5c3f5776aa2..000000000000
--- a/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
+++ /dev/null
@@ -1,10 +0,0 @@
- - do not link ratpoints where it's not used
-
---- a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
-+++ b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
-@@ -1,5 +1,3 @@
--# distutils: libraries = ratpoints
--
- r"""
- Descent on elliptic curves over `\QQ` with a 2-isogeny
- """
diff --git a/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch b/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
deleted file mode 100644
index d3672b094c1c..000000000000
--- a/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
+++ /dev/null
@@ -1,13 +0,0 @@
- - fix _get_shared_lib_path() so we don't need to configure GAP_SO
-
---- a/src/sage/env.py
-+++ b/src/sage/env.py
-@@ -293,7 +293,7 @@ def _get_shared_lib_path(*libnames: str) -> Optional[str]:
-             if sys.platform == 'darwin':
-                 ext = 'dylib'
-             else:
--                ext = 'so'
-+                ext = 'so*'
- 
-             if SAGE_LOCAL:
-                 search_directories.append(Path(SAGE_LOCAL) / 'lib')
diff --git a/srcpkgs/sagemath/patches/03-doctest_have_program.patch b/srcpkgs/sagemath/patches/03-doctest_have_program.patch
deleted file mode 100644
index 27ba3776470c..000000000000
--- a/srcpkgs/sagemath/patches/03-doctest_have_program.patch
+++ /dev/null
@@ -1,20 +0,0 @@
- - we don't know `SAGE_VENV/bin` contains `sage`, but `sys.argv[0]` should
-   be the full path to `sage-ipython` and the same directory should have `sage`
-
---- a/src/sage/misc/sage_ostools.pyx
-+++ b/src/sage/misc/sage_ostools.pyx
-@@ -32,12 +32,11 @@ def have_program(program, path=None):
-         True
-         sage: have_program('there_is_not_a_program_with_this_name')
-         False
--        sage: from sage.env import SAGE_VENV
--        sage: have_program('sage', os.path.join(SAGE_VENV, 'bin'))
-+        sage: have_program('sage', os.path.dirname(sys.argv[0]))
-         True
-         sage: have_program('sage', '/there_is_not_a_path_with_this_name')
-         False
--        sage: have_program('there_is_not_a_program_with_this_name', os.path.join(SAGE_VENV, 'bin'))
-+        sage: have_program('there_is_not_a_program_with_this_name', "/bin")
-         False
-     """
-     if path is None:
diff --git a/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch b/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
deleted file mode 100644
index 95bce107f854..000000000000
--- a/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
+++ /dev/null
@@ -1,22 +0,0 @@
- - add one doctest for coverage
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -1341,10 +1342,12 @@ def sage_getfile(obj):
-     EXAMPLES::
- 
-         sage: from sage.misc.sageinspect import sage_getfile
--        sage: sage_getfile(sage.rings.rational)[-23:]
--        'sage/rings/rational.pyx'
--        sage: sage_getfile(Sq)[-42:]
--        'sage/algebras/steenrod/steenrod_algebra.py'
-+        sage: sage_getfile(sage.rings.rational)
-+        '...sage/rings/rational.pyx'
-+        sage: sage_getfile(Sq)
-+        '...sage/algebras/steenrod/steenrod_algebra.py'
-+        sage: sage_getfile(x)
-+        '...sage/symbolic/expression.pyx'
- 
-     The following tests against some bugs fixed in :trac:`9976`::
- 
-
diff --git a/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch b/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
deleted file mode 100644
index 56c58078f319..000000000000
--- a/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
+++ /dev/null
@@ -1,16 +0,0 @@
- - fix sage_getfile() by checking all possible EXTENSION_SUFFIXES
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -1400,8 +1403,9 @@ def sage_getfile(obj):
-         sourcefile = inspect.getabsfile(obj)
-     except TypeError: # this happens for Python builtins
-         return ''
--    if sourcefile.endswith(loadable_module_extension()):
--        return sourcefile[:-len(loadable_module_extension())]+os.path.extsep+'pyx'
-+    for suffix in import_machinery.EXTENSION_SUFFIXES:
-+        if sourcefile.endswith(suffix):
-+            return sourcefile[:-len(suffix)]+os.path.extsep+'pyx'
-     return sourcefile
- 
- 
diff --git a/srcpkgs/sagemath/patches/07-ignore_warning.patch b/srcpkgs/sagemath/patches/07-ignore_warning.patch
deleted file mode 100644
index 69668678a40b..000000000000
--- a/srcpkgs/sagemath/patches/07-ignore_warning.patch
+++ /dev/null
@@ -1,15 +0,0 @@
- - this ignores a warning caused by old notebook
-
---- a/src/sage/all.py
-+++ b/src/sage/all.py
-@@ -100,6 +100,9 @@ warnings.filterwarnings('ignore', category=DeprecationWarning,
-                         message='The distutils(.sysconfig module| package) is deprecated',
-                         module='Cython|distutils|numpy|sage.env|sage.features')
- 
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"invalid escape sequence '\\s'")
-+
- ################ end setup warnings ###############################
- 
- 
-
diff --git a/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch b/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
deleted file mode 100644
index 06bd2ccae6fb..000000000000
--- a/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
+++ /dev/null
@@ -1,27 +0,0 @@
- - using pytest is broken, see #31924
-
---- a/src/bin/sage-runtests
-+++ b/src/bin/sage-runtests
-@@ -154,21 +154,4 @@ if __name__ == "__main__":
-     DC = DocTestController(args, args.filenames)
-     err = DC.run()
- 
--    try:
--        exit_code_pytest = 0
--        import pytest
--        pytest_options = ["--import-mode", "importlib"]
--        if args.verbose:
--            pytest_options.append("-v")
--        exit_code_pytest = pytest.main(pytest_options + args.filenames)
--        if exit_code_pytest == 5:
--            # Exit code 5 means there were no test files, pass in this case
--            exit_code_pytest = 0
--
--    except ModuleNotFoundError:
--        print("Pytest is not installed, skip checking tests that rely on it.")
--
--    if err == 0:
--        sys.exit(exit_code_pytest)
--    else:
--        sys.exit(err)
-+    sys.exit(err)
diff --git a/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch b/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
deleted file mode 100644
index bae8387cf94a..000000000000
--- a/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
-+++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
-@@ -237,8 +237,9 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
- 
-             sage: a = ZZ['x'](range(100000))
-             sage: R = Integers(3)['x']
--            sage: R(a)  # long time (7s on sage.math, 2013)
--            2*x^99998 + ... + x
-+            sage: p = R(a)
-+            sage: p.truncate(10)  # testing the whole poly is VERY SLOW
-+            2*x^8 + x^7 + 2*x^5 + x^4 + 2*x^2 + x
-         """
-         sig_on()
-         fmpz_poly_get_nmod_poly(&self.x, x)
diff --git a/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch b/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
deleted file mode 100644
index f3da5bbb555e..000000000000
--- a/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
+++ /dev/null
@@ -1,106 +0,0 @@
-diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-index 43727346269..9d3ccd475cd 100644
---- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-+++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-@@ -186,7 +186,7 @@ def Psi(l, use_stored=True):
-         sage: assert Psi(3, use_stored=True) == Psi(3, use_stored=False)
-         sage: assert Psi(5, use_stored=True) == Psi(5, use_stored=False)
-         sage: assert Psi(7, use_stored=True) == Psi(7, use_stored=False)
--        sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False) # not tested (very long time)
-+        sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False)  # long time (2s)
-     """
-     if l not in [2, 3, 5, 7, 13]:
-         raise ValueError("Genus zero primes are 2, 3, 5, 7 or 13.")
-@@ -1207,7 +1207,7 @@ def isogenies_13_0(E, minimal_models=True):
-         sage: K.<a> = NumberField(f)
-         sage: E = EllipticCurve(j=K(0)); E.ainvs()
-         (0, 0, 0, 0, 1)
--        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]
-+        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]  # long time (4s)
-         [(0,
-           0,
-           20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
-@@ -1325,7 +1325,7 @@ def isogenies_13_1728(E, minimal_models=True):
-         sage: f = x^12 + 1092*x^10 - 432432*x^8 + 6641024*x^6 - 282896640*x^4 - 149879808*x^2 - 349360128
-         sage: K.<a> = NumberField(f)
-         sage: E = EllipticCurve(K, [1,0])
--        sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]
-+        sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]  # long time (3s)
-         [(0,
-         0,
-         0,
-@@ -1550,8 +1550,11 @@ def Psi2(l):
-         sage: from sage.schemes.elliptic_curves.isogeny_small_degree import Psi2
-         sage: Psi2(11)
-         x^5 - 55*x^4*u + 994*x^3*u^2 - 8774*x^2*u^3 + 41453*x*u^4 - 928945/11*u^5 + 33*x^4 + 276*x^3*u - 7794*x^2*u^2 + 4452*x*u^3 + 1319331/11*u^4 + 216*x^3*v - 4536*x^2*u*v + 31752*x*u^2*v - 842616/11*u^3*v + 162*x^3 + 38718*x^2*u - 610578*x*u^2 + 33434694/11*u^3 - 4536*x^2*v + 73872*x*u*v - 2745576/11*u^2*v - 16470*x^2 + 580068*x*u - 67821354/11*u^2 - 185976*x*v + 14143896/11*u*v + 7533*x - 20437029/11*u - 12389112/11*v + 19964151/11
--        sage: Psi2(71)  # long time (1 second)
--        -2209380711722505179506258739515288584116147237393815266468076436521/71*u^210 + ... - 14790739586438315394567393301990769678157425619440464678252277649/71
-+        sage: f = Psi2(71)
-+        sage: f.coefficient([0, 210, 0])
-+        -2209380711722505179506258739515288584116147237393815266468076436521/71
-+        sage: f.coefficient([0, 0, 0])
-+        -14790739586438315394567393301990769678157425619440464678252277649/71
- 
-     TESTS::
- 
-@@ -1665,17 +1668,17 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True):
-         sage: K = QuadraticField(5,'a')
-         sage: a = K.gen()
-         sage: E = EllipticCurve_from_j(184068066743177379840*a - 411588709724712960000)
--        sage: isogenies_prime_degree_genus_plus_0(E, 47) # long time (4.3s)
-+        sage: isogenies_prime_degree_genus_plus_0(E, 47)  # long time (2s)
-         [Isogeny of degree 47 from Elliptic Curve defined by y^2 = x^3 + (454562028554080355857852049849975895490560*a-1016431595837124114668689286176511361024000)*x + (-249456798429896080881440540950393713303830363999480904280965120*a+557802358738710443451273320227578156598454035482869042774016000) over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790? to Elliptic Curve defined by y^2 = x^3 + (39533118442361013730577638493616965245992960*a-88398740199669828340617478832005245173760000)*x + (214030321479466610282320528611562368963830105830555363061803253760*a-478586348074220699687616322532666163722004497458452316582576128000) over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790?]
- 
-         sage: K = QuadraticField(-66827,'a')
-         sage: a = K.gen()
-         sage: E = EllipticCurve_from_j(-98669236224000*a + 4401720074240000)
--        sage: isogenies_prime_degree_genus_plus_0(E, 59)   # long time (25s, 2012)
-+        sage: isogenies_prime_degree_genus_plus_0(E, 59)   # long time (5s)
-         [Isogeny of degree 59 from Elliptic Curve defined by y^2 = x^3 + (2605886146782144762297974784000*a+1893681048912773634944634716160000)*x + (-116918454256410782232296183198067568744071168000*a+17012043538294664027185882358514011304812871680000) over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I to Elliptic Curve defined by y^2 = x^3 + (-19387084027159786821400775098368000*a-4882059104868154225052787156713472000)*x + (-25659862010101415428713331477227179429538847260672000*a-2596038148441293485938798119003462972840818381946880000) over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I]
- 
-         sage: E = EllipticCurve_from_j(GF(13)(5))
--        sage: isogenies_prime_degree_genus_plus_0(E, 71) # long time
-+        sage: isogenies_prime_degree_genus_plus_0(E, 71)
-         [Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13, Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13]
- 
-         sage: E = EllipticCurve(GF(13),[0,1,1,1,0])
-@@ -2117,11 +2120,11 @@ def isogenies_prime_degree_general(E, l, minimal_models=True):
-         sage: isogenies_prime_degree_general(E, 19)
-         [Isogeny of degree 19 from Elliptic Curve defined by y^2 + y = x^3 - 1862*x - 30956 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - 672182*x + 212325489 over Rational Field]
-         sage: E = EllipticCurve([0, -1, 0, -6288, 211072])
--        sage: isogenies_prime_degree_general(E, 37)  # long time (10s)
-+        sage: isogenies_prime_degree_general(E, 37)  # long time (2s)
-         [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 - x^2 - 6288*x + 211072 over Rational Field to Elliptic Curve defined by y^2 = x^3 - x^2 - 163137088*x - 801950801728 over Rational Field]
- 
-         sage: E = EllipticCurve([-3440, 77658])
--        sage: isogenies_prime_degree_general(E, 43)  # long time (16s)
-+        sage: isogenies_prime_degree_general(E, 43)  # long time (2s)
-         [Isogeny of degree 43 from Elliptic Curve defined by y^2 = x^3 - 3440*x + 77658 over Rational Field to Elliptic Curve defined by y^2 = x^3 - 6360560*x - 6174354606 over Rational Field]
- 
-     Isogenies of degree equal to the characteristic are computed (but
-@@ -2175,7 +2178,7 @@ def isogenies_prime_degree_general(E, l, minimal_models=True):
- 
-         sage: K.<i> = QuadraticField(-1)
-         sage: E = EllipticCurve(K,[0,0,0,1,0])
--        sage: [phi.codomain().ainvs() for phi in E.isogenies_prime_degree(37)] # long time
-+        sage: [phi.codomain().ainvs() for phi in E.isogenies_prime_degree(37)]  # long time (6s)
-         [(0, 0, 0, -840*i + 1081, 0), (0, 0, 0, 840*i + 1081, 0)]
-     """
-     if not l.is_prime():
-@@ -2329,14 +2332,14 @@ def isogenies_prime_degree(E, l, minimal_models=True):
-         sage: E = EllipticCurve(GF(101), [-3440, 77658])
-         sage: E.isogenies_prime_degree(71) # fast
-         []
--        sage: E.isogenies_prime_degree(73) # slower (2s)
-+        sage: E.isogenies_prime_degree(73)  # long time (2s)
-         []
- 
-     Test that :trac:`32269` is fixed::
- 
-         sage: K = QuadraticField(-11)
-         sage: E = EllipticCurve(K, [0,1,0,-117,-541])
--        sage: E.isogenies_prime_degree(37)
-+        sage: E.isogenies_prime_degree(37)  # long time (9s)
-         [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I to Elliptic Curve defined by y^2 = x^3 + x^2 + (30800*a+123963)*x + (3931312*a-21805005) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I,
-          Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I to Elliptic Curve defined by y^2 = x^3 + x^2 + (-30800*a+123963)*x + (-3931312*a-21805005) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I]
- 
diff --git a/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch b/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
deleted file mode 100644
index 3b7b1ea843df..000000000000
--- a/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
+++ /dev/null
@@ -1,97 +0,0 @@
---- a/src/sage/rings/function_field/function_field.py
-+++ b/src/sage/rings/function_field/function_field.py
-@@ -111,22 +111,21 @@ Function fields over the algebraic field are supported::
-     sage: m = L.completion(pl, prec=5)
-     sage: m(x)
-     I + s + O(s^5)
--    sage: m(y)
-+    sage: m(y)                             # long time (4s)
-     -2*s + (-4 - I)*s^2 + (-15 - 4*I)*s^3 + (-75 - 23*I)*s^4 + (-413 - 154*I)*s^5 + O(s^6)
--    sage: m(y)^2 + m(y) + m(x) + 1/m(x)
-+    sage: m(y)^2 + m(y) + m(x) + 1/m(x)    # long time (8s)
-     O(s^5)
- 
- TESTS::
- 
-     sage: TestSuite(J).run()
--    sage: TestSuite(K).run(max_runs=1024) # long time (5s)
--    sage: TestSuite(L).run(max_runs=64)   # long time (10s)
--    sage: TestSuite(M).run(max_runs=32)   # long time (30s)
--    sage: TestSuite(N).run(max_runs=64, skip = '_test_derivation')  # long time (8s)
--    sage: TestSuite(O).run(max_runs=128, skip = '_test_derivation') # long time (8s)
--
-+    sage: TestSuite(K).run(max_runs=256)   # long time (10s)
-+    sage: TestSuite(L).run(max_runs=8)     # long time (25s)
-+    sage: TestSuite(M).run(max_runs=8)     # long time (35s)
-+    sage: TestSuite(N).run(max_runs=8, skip = '_test_derivation')    # long time (15s)
-+    sage: TestSuite(O).run()
-     sage: TestSuite(R).run()
--    sage: TestSuite(S).run() # long time (3s)
-+    sage: TestSuite(S).run()               # long time (4s)
- 
- Global function fields
- ----------------------
-@@ -287,7 +286,7 @@ class FunctionField(Field):
-         TESTS::
- 
-             sage: K.<x> = FunctionField(QQ)
--            sage: TestSuite(K).run()
-+            sage: TestSuite(K).run()               # long time (3s)
-         """
-         Field.__init__(self, base_field, names=names, category=category)
- 
-@@ -729,7 +728,7 @@ class FunctionField(Field):
-         EXAMPLES::
- 
-             sage: K.<x> = FunctionField(QQ)
--            sage: TestSuite(K).run() # indirect doctest
-+            sage: TestSuite(K).run()    # indirect doctest, long time (3s)
-         """
-         tester = self._tester(**options)
-         S = tester.some_elements()
-@@ -1209,7 +1208,7 @@ class FunctionField_polymod(FunctionField):
-             sage: K.<x> = FunctionField(QQ); R.<y> = K[]
-             sage: L = K.extension(y^5 - x^3 - 3*x + x*y); L
-             Function field in y defined by y^5 + x*y - x^3 - 3*x
--            sage: TestSuite(L).run()  # long time
-+            sage: TestSuite(L).run(max_runs=512)   # long time (15s)
- 
-         We can set the variable name, which doesn't have to be y::
- 
-@@ -2888,7 +2887,8 @@ class FunctionField_simple(FunctionField_polymod):
-             sage: F.<y> = K.extension(Y^3 - x^2*(x^2 + x + 1)^2)
-             sage: O = K.maximal_order()
-             sage: pls = [O.ideal(x-QQbar(sqrt(c))).place() for c in [-2, -1, 0, 1, 2]]
--            sage: all(q.place_below() == p for p in pls for q in F.places_above(p))
-+            sage: all(q.place_below() == p         # long time (4s)
-+            ....:     for p in pls for q in F.places_above(p))
-             True
-         """
-         R = self.base_field()
-@@ -3091,7 +3091,7 @@ class FunctionField_global(FunctionField_simple):
- 
-         sage: K.<x> = FunctionField(GF(4)); _.<Y> = K[]
-         sage: L.<y> = K.extension((1 - x)*Y^7 - x^3)
--        sage: L.gaps()
-+        sage: L.gaps()                         # long time (6s)
-         [1, 2, 3]
- 
-     or may define a trivial extension::
-@@ -3111,7 +3111,7 @@ class FunctionField_global(FunctionField_simple):
- 
-             sage: K.<x> = FunctionField(GF(5)); _.<Y> = K[]
-             sage: L.<y> = K.extension(Y^3 - (x^3 - 1)/(x^3 - 2))
--            sage: TestSuite(L).run()
-+            sage: TestSuite(L).run()               # long time (7s)
-         """
-         FunctionField_polymod.__init__(self, polynomial, names)
- 
-@@ -3807,7 +3807,7 @@ class RationalFunctionField(FunctionField):
- 
-             sage: K.<t> = FunctionField(CC); K
-             Rational function field in t over Complex Field with 53 bits of precision
--            sage: TestSuite(K).run()
-+            sage: TestSuite(K).run()               # long time (5s)
- 
-             sage: FunctionField(QQ[I], 'alpha')
-             Rational function field in alpha over Number Field in I with defining polynomial x^2 + 1 with I = 1*I
diff --git a/srcpkgs/sagemath/patches/matplotlib-3.6.patch b/srcpkgs/sagemath/patches/matplotlib-3.6.patch
new file mode 100644
index 000000000000..6afaf1b7162f
--- /dev/null
+++ b/srcpkgs/sagemath/patches/matplotlib-3.6.patch
@@ -0,0 +1,72 @@
+commit 5501e0de0dca1cff0355326dd42bd8c7e5749568
+Author: Gonzalo Tornaría <tornaria@cmat.edu.uy>
+Date:   Tue Oct 11 17:25:04 2022 -0300
+
+    Support matplotlib 3.6
+
+diff --git a/src/sage/plot/arc.py b/src/sage/plot/arc.py
+index bb834763afc..f65973bcbd5 100644
+--- a/src/sage/plot/arc.py
++++ b/src/sage/plot/arc.py
+@@ -273,9 +273,9 @@ class Arc(GraphicPrimitive):
+         p = patches.Arc((self.x, self.y),
+                         2. * self.r1,
+                         2. * self.r2,
+-                        fmod(self.angle, 2 * pi) * (180. / pi),
+-                        self.s1 * (180. / pi),
+-                        self.s2 * (180. / pi))
++                        angle=fmod(self.angle, 2 * pi) * (180. / pi),
++                        theta1=self.s1 * (180. / pi),
++                        theta2=self.s2 * (180. / pi))
+         return p
+ 
+     def bezier_path(self):
+diff --git a/src/sage/plot/ellipse.py b/src/sage/plot/ellipse.py
+index a77e6fe640a..c35bed574ef 100644
+--- a/src/sage/plot/ellipse.py
++++ b/src/sage/plot/ellipse.py
+@@ -192,7 +192,8 @@ class Ellipse(GraphicPrimitive):
+         options = self.options()
+         p = patches.Ellipse(
+                 (self.x,self.y),
+-                self.r1*2.,self.r2*2.,self.angle/pi*180.)
++                self.r1*2.,self.r2*2.,
++                angle=self.angle/pi*180.)
+         p.set_linewidth(float(options['thickness']))
+         p.set_fill(options['fill'])
+         a = float(options['alpha'])
+diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
+index e779e1210e3..8d620b5c625 100644
+--- a/src/sage/plot/graphics.py
++++ b/src/sage/plot/graphics.py
+@@ -2007,7 +2007,7 @@ class Graphics(WithEqualityById, SageObject):
+         We can also do custom formatting if you need it.  See above for full
+         details::
+ 
+-            sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex")
++            sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex") # not tested (broken with matplotlib 3.6)
+             Graphics object consisting of 1 graphics primitive
+ 
+         This is particularly useful when setting custom ticks in multiples
+@@ -2341,7 +2341,7 @@ class Graphics(WithEqualityById, SageObject):
+             sage: subplot = Figure().add_subplot(111)
+             sage: p._objects[0]._render_on_subplot(subplot)
+             sage: p._matplotlib_tick_formatter(subplot, **d)
+-            (<AxesSubplot:>,
++            (<AxesSubplot:...>,
+             <matplotlib.ticker.MaxNLocator object at ...>,
+             <matplotlib.ticker.MaxNLocator object at ...>,
+             <matplotlib.ticker.ScalarFormatter object at ...>,
+diff --git a/src/sage/plot/plot.py b/src/sage/plot/plot.py
+index b36ee57227c..5301a05c3dc 100644
+--- a/src/sage/plot/plot.py
++++ b/src/sage/plot/plot.py
+@@ -1741,7 +1741,7 @@ def plot(funcs, *args, **kwds):
+ 
+     ::
+ 
+-        sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex")
++        sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex") # not tested (broken with matplotlib 3.6)
+         Graphics object consisting of 1 graphics primitive
+ 
+     .. PLOT::
diff --git a/srcpkgs/sagemath/patches/python-3.11.patch b/srcpkgs/sagemath/patches/python-3.11.patch
new file mode 100644
index 000000000000..eafe76bfb794
--- /dev/null
+++ b/srcpkgs/sagemath/patches/python-3.11.patch
@@ -0,0 +1,45 @@
+--- a/src/sage/cpython/cython_metaclass.h
++++ b/src/sage/cpython/cython_metaclass.h
+@@ -66,7 +66,7 @@
+         }
+ 
+         /* Now, set t.__class__ to metaclass */
+-        Py_TYPE(t) = metaclass;
++        Py_SET_TYPE(t, metaclass);
+         PyType_Modified(t);
+     }
+     else
+--- a/src/sage/symbolic/ginac/numeric.cpp
++++ b/src/sage/symbolic/ginac/numeric.cpp
+@@ -52,7 +52,6 @@
+ #define register
+ #define PY_SSIZE_T_CLEAN
+ #include <Python.h>
+-#include <longintrepr.h>
+ #include "flint/fmpz.h"
+ #include "flint/fmpz_factor.h"
+ 
+--- a/src/sage/libs/gmp/pylong.pyx
++++ b/src/sage/libs/gmp/pylong.pyx
+@@ -32,7 +32,7 @@
+ from .mpz cimport *
+ 
+ cdef extern from *:
+-    Py_ssize_t* Py_SIZE_PTR "&Py_SIZE"(object)
++    void Py_SET_SIZE(object, Py_ssize_t)
+     int hash_bits """
+         #ifdef _PyHASH_BITS
+         _PyHASH_BITS         /* Python 3 */
+@@ -57,10 +57,8 @@
+     mpz_export(L.ob_digit, NULL,
+             -1, sizeof(digit), 0, PyLong_nails, z)
+     if mpz_sgn(z) < 0:
+-        # Set correct size (use a pointer to hack around Cython's
+-        # non-support for lvalues).
+-        sizeptr = Py_SIZE_PTR(L)
+-        sizeptr[0] = -pylong_size
++        # Set correct size
++        Py_SET_SIZE(L, -pylong_size)
+     return L
+ 
+ 
diff --git a/srcpkgs/sagemath/patches/sagemath-pari-2.15.patch b/srcpkgs/sagemath/patches/sagemath-pari-2.15.patch
new file mode 100644
index 000000000000..ccafad5070c4
--- /dev/null
+++ b/srcpkgs/sagemath/patches/sagemath-pari-2.15.patch
@@ -0,0 +1,1750 @@
+diff --git a/build/pkgs/giac/patches/pari_2_15.patch b/build/pkgs/giac/patches/pari_2_15.patch
+new file mode 100644
+index 0000000000..d2900a5ffc
+--- /dev/null
++++ b/build/pkgs/giac/patches/pari_2_15.patch
+@@ -0,0 +1,21 @@
++ANYARG patch
++
++diff --git a/src/pari.cc b/src/pari.cc
++index 76ce8e1..50d08ab 100644
++--- a/src/pari.cc
+++++ b/src/pari.cc
++@@ -40,6 +40,13 @@ using namespace std;
++ 
++ #ifdef HAVE_LIBPARI
++ 
+++// Anyarg disappeared from PARI 2.15.0
+++#ifdef __cplusplus
+++#  define ANYARG ...
+++#else
+++#  define ANYARG
+++#endif
+++
++ #ifdef HAVE_PTHREAD_H
++ #include <pthread.h>
++ #endif
++
+diff --git a/build/pkgs/pari/checksums.ini b/build/pkgs/pari/checksums.ini
+index b736feed31..bafd0f36f4 100644
+--- a/build/pkgs/pari/checksums.ini
++++ b/build/pkgs/pari/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=pari-VERSION.tar.gz
+-sha1=e01647aab7e96a8cb4922cf26a4f224337c6647f
+-md5=922f740fcdf8630b30d63dc76b58f756
+-cksum=297133525
++sha1=cba9b279f67d5efe2fbbccf3be6e9725f816cf07
++md5=76d430f1bea1b07fa2ad9712deeaa736
++cksum=1990743897
+ upstream_url=https://pari.math.u-bordeaux.fr/pub/pari/unix/pari-VERSION.tar.gz
+diff --git a/build/pkgs/pari/package-version.txt b/build/pkgs/pari/package-version.txt
+index a1a4224dd5..68e69e405e 100644
+--- a/build/pkgs/pari/package-version.txt
++++ b/build/pkgs/pari/package-version.txt
+@@ -1 +1 @@
+-2.13.3
++2.15.0
+diff --git a/src/doc/de/tutorial/tour_numtheory.rst b/src/doc/de/tutorial/tour_numtheory.rst
+index a012234c99..e3149fe949 100644
+--- a/src/doc/de/tutorial/tour_numtheory.rst
++++ b/src/doc/de/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ implementiert.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/en/tutorial/tour_numtheory.rst b/src/doc/en/tutorial/tour_numtheory.rst
+index 3064d100e2..075e0ac0ad 100644
+--- a/src/doc/en/tutorial/tour_numtheory.rst
++++ b/src/doc/en/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ NumberField class.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/es/tutorial/tour_numtheory.rst b/src/doc/es/tutorial/tour_numtheory.rst
+index a1f7d1a87b..48e5376cfe 100644
+--- a/src/doc/es/tutorial/tour_numtheory.rst
++++ b/src/doc/es/tutorial/tour_numtheory.rst
+@@ -140,7 +140,7 @@ Varios métodos relacionados están implementados en la clase ``NumberField``::
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/fr/tutorial/tour_numtheory.rst b/src/doc/fr/tutorial/tour_numtheory.rst
+index 871092f5fa..d1b2fee883 100644
+--- a/src/doc/fr/tutorial/tour_numtheory.rst
++++ b/src/doc/fr/tutorial/tour_numtheory.rst
+@@ -159,7 +159,7 @@ dans la classe NumberField.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/ja/tutorial/tour_numtheory.rst b/src/doc/ja/tutorial/tour_numtheory.rst
+index 47af68c862..4d4ed52d50 100644
+--- a/src/doc/ja/tutorial/tour_numtheory.rst
++++ b/src/doc/ja/tutorial/tour_numtheory.rst
+@@ -161,7 +161,7 @@ Sageには :math:`p` \-進数体も組込まれている.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/pt/tutorial/tour_numtheory.rst b/src/doc/pt/tutorial/tour_numtheory.rst
+index 6371b491ea..a3dc973a93 100644
+--- a/src/doc/pt/tutorial/tour_numtheory.rst
++++ b/src/doc/pt/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ NumberField.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus 
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/ru/tutorial/tour_numtheory.rst b/src/doc/ru/tutorial/tour_numtheory.rst
+index 652abfbc99..a985d49fbd 100644
+--- a/src/doc/ru/tutorial/tour_numtheory.rst
++++ b/src/doc/ru/tutorial/tour_numtheory.rst
+@@ -150,7 +150,7 @@ Sage содержит стандартные функции теории чис
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py
+index e57076646f..fec75d07c1 100644
+--- a/src/sage/arith/misc.py
++++ b/src/sage/arith/misc.py
+@@ -1465,13 +1465,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)]
++        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::
+ 
+@@ -2569,7 +2569,7 @@ def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds):
+ 
+         sage: K.<i> = QuadraticField(-1)
+         sage: factor(122 - 454*i)
+-        (-3*i - 2) * (-i - 2)^3 * (i + 1)^3 * (i + 4)
++        (-i) * (-i - 2)^3 * (i + 1)^3 * (-2*i + 3) * (i + 4)
+ 
+     To access the data in a factorization::
+ 
+diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
+index cdfc11a9e5..b6e1280d6e 100644
+--- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
++++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
+@@ -7825,9 +7825,9 @@ class DynamicalSystem_projective_field(DynamicalSystem_projective,
+             sage: f = DynamicalSystem_projective([x^2 + QQbar(sqrt(3))*y^2, y^2, QQbar(sqrt(2))*z^2])
+             sage: f.reduce_base_field()
+             Dynamical System of Projective Space of dimension 2 over Number Field in a with
+-            defining polynomial y^4 - 4*y^2 + 1 with a = 1.931851652578137?
++            defining polynomial y^4 - 4*y^2 + 1 with a = -0.5176380902050415?
+               Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x^2 + (a^2 - 2)*y^2 : y^2 : (a^3 - 3*a)*z^2)
++                    (x^2 + (-a^2 + 2)*y^2 : y^2 : (a^3 - 3*a)*z^2)
+ 
+         ::
+ 
+diff --git a/src/sage/ext_data/pari/simon/ellQ.gp b/src/sage/ext_data/pari/simon/ellQ.gp
+index 420af8f6a2..65e8386779 100644
+--- a/src/sage/ext_data/pari/simon/ellQ.gp
++++ b/src/sage/ext_data/pari/simon/ellQ.gp
+@@ -40,7 +40,7 @@
+   gp > \r ellcommon.gp
+   gp > \r ellQ.gp
+ 
+-  The main function is ellrank(), which takes as an argument
++  The main function is ellQ_ellrank(), which takes as an argument
+   any elliptic curve in the form [a1,a2,a3,a4,a6]
+   the result is a vector [r,s,v], where
+     r is a lower bound for the rank,
+@@ -50,7 +50,7 @@
+   Example:
+ 
+   gp > ell = [1,2,3,4,5];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+   %1 = [1, 1, [[1,2]]
+   In this example, the rank is exactly 1, and [1,2] has infinite order.
+ 
+@@ -92,7 +92,7 @@
+   \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+ 
+   Explications succintes :
+-  La fonction ellrank() accepte toutes les courbes sous la forme
++  La fonction ellQ_ellrank() accepte toutes les courbes sous la forme
+   [a1,a2,a3,a4,a6]
+   Les coefficients peuvent etre entiers ou non.
+   L'algorithme utilise est celui de la 2-descente.
+@@ -100,7 +100,7 @@
+   Il suffit de taper : 
+ 
+   gp > ell = [a1,a2,a3,a4,a6];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+ 
+   Retourne un vecteur [r,s,v] ou
+     r est le rang probable (c'est toujours une minoration du rang),
+@@ -110,7 +110,7 @@
+   Exemple :
+ 
+   gp > ell = [1,2,3,4,5];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+   %1 = [1, 1, [[1,2]]
+   Ici, le rang est exactement 1, et le point [1,2] est d'ordre infini.
+ 
+@@ -1571,12 +1571,12 @@ if( DEBUGLEVEL_ell >= 4, print("    end of ell2descent_gen"));
+     print("rank(E/Q)    >= ",m1)
+   );
+ }
+-{ellrank(ell,help=[]) =
++{ellQ_ellrank(ell,help=[]) =
+ \\ Algorithm of 2-descent on the elliptic curve ell.
+ \\ help is a list of known points on ell.
+ my(urst,urst1,den,eqell,tors2,bnf,rang,time1);
+ 
+-if( DEBUGLEVEL_ell >= 3, print("   starting ellrank"));
++if( DEBUGLEVEL_ell >= 3, print("   starting ellQ_ellrank"));
+   if( #ell < 13, ell = ellinit(ell));
+ 
+ \\ kill the coefficients a1 and a3
+@@ -1630,7 +1630,7 @@ if( DEBUGLEVEL_ell >= 1, print(" Elliptic curve: Y^2 = ",eqell));
+   ));
+ 
+   rang[3] = ellchangepoint(rang[3],ellinverturst(urst));
+-if( DEBUGLEVEL_ell >= 3, print("   end of ellrank"));
++if( DEBUGLEVEL_ell >= 3, print("   end of ellQ_ellrank"));
+ 
+   return(rang);
+ }
+@@ -2106,13 +2106,13 @@ if( DEBUGLEVEL_ell >= 3, print("   end of ell2descent_viaisog"));
+ {
+ \\                  functions for elliptic curves
+   addhelp(ell2descent_complete,
+-    "ell2descent_complete(e1,e2,e3): Performs a complete 2-descent on the elliptic curve y^2 = (x-e1)*(x-e2)*(x-e3). See ?ellrank for the format of the output.");
++    "ell2descent_complete(e1,e2,e3): Performs a complete 2-descent on the elliptic curve y^2 = (x-e1)*(x-e2)*(x-e3). See ?ellQ_ellrank for the format of the output.");
+   addhelp(ell2descent_gen,
+-    "ell2descent_gen((E,bnf,k=1,help=[]): E is a vector of the form [0,A,0,B,C], (or the result of ellinit of such a vector) A,B,C integers such that x^3+A*x^2+B*x+C; bnf is the corresponding bnfinit(,1); Performs 2-descent on the elliptic curve Ek: k*y^2=x^3+A*x^2+B*x+C. See ?ellrank for the format of the output.");
++    "ell2descent_gen((E,bnf,k=1,help=[]): E is a vector of the form [0,A,0,B,C], (or the result of ellinit of such a vector) A,B,C integers such that x^3+A*x^2+B*x+C; bnf is the corresponding bnfinit(,1); Performs 2-descent on the elliptic curve Ek: k*y^2=x^3+A*x^2+B*x+C. See ?ellQ_ellrank for the format of the output.");
+   addhelp(ell2descent_viaisog,
+-    "ell2descent_viaisog(E,help=[]): E is an elliptic curve of the form [0,a,0,b,0], with a, b integers. Performs a 2-descent via isogeny on E. See ?ellrank for the format of the output.");
+-  addhelp(ellrank,
+-    "ellrank(E,help=[]): E is any elliptic curve defined over Q. Returns a vector [r,s,v], where r is a lower bound for the rank of E, s is the rank of its 2-Selmer group and v is a list of independant points in E(Q)/2E(Q). If help is a vector of nontrivial points on E, the result might be faster. This function might be used in conjunction with elltors2(E). See also ?default_ellQ");
++    "ell2descent_viaisog(E,help=[]): E is an elliptic curve of the form [0,a,0,b,0], with a, b integers. Performs a 2-descent via isogeny on E. See ?ellQ_ellrank for the format of the output.");
++  addhelp(ellQ_ellrank,
++    "ellQ_ellrank(E,help=[]): E is any elliptic curve defined over Q. Returns a vector [r,s,v], where r is a lower bound for the rank of E, s is the rank of its 2-Selmer group and v is a list of independant points in E(Q)/2E(Q). If help is a vector of nontrivial points on E, the result might be faster. This function might be used in conjunction with elltors2(E). See also ?default_ellQ");
+   addhelp(ellhalf,
+     "ellhalf(E,P): returns the vector of all points Q on the elliptic curve E such that 2Q = P");
+   addhelp(ellredgen,
+@@ -2143,7 +2143,7 @@ if( DEBUGLEVEL_ell >= 3, print("   end of ell2descent_viaisog"));
+ 
+ \\                  others
+   addhelp(default_ellQ,
+-    "default_ellQ(DEBUGLEVEL_ell, LIM1, LIM3, LIMTRIV, ELLREDGENFLAG, COMPLETE, MAXPROB, LIMBIGPRIME): set the value of the global variables used for ellrank() and other related functions. DEBUGLEVEL_ell: 0-5: choose the quantity of information printed during the computation (default=0: print nothing); LIM1 (resp LIM3): search limit for easy (resp hard) points on quartics; LIMTRIV: search limit for trivial points on elliptic curves; ELLREDGENFLAG: if != 0, try to reduce the generators at the end; COMPLETE: if != 0 and full 2-torsion, use complete 2-descent, otherwise via 2-isogeny; MAXPROB, LIMBIGPRIME: technical.");
++    "default_ellQ(DEBUGLEVEL_ell, LIM1, LIM3, LIMTRIV, ELLREDGENFLAG, COMPLETE, MAXPROB, LIMBIGPRIME): set the value of the global variables used for ellQ_ellrank() and other related functions. DEBUGLEVEL_ell: 0-5: choose the quantity of information printed during the computation (default=0: print nothing); LIM1 (resp LIM3): search limit for easy (resp hard) points on quartics; LIMTRIV: search limit for trivial points on elliptic curves; ELLREDGENFLAG: if != 0, try to reduce the generators at the end; COMPLETE: if != 0 and full 2-torsion, use complete 2-descent, otherwise via 2-isogeny; MAXPROB, LIMBIGPRIME: technical.");
+ /*  addhelp(DEBUGLEVEL_ell,
+     "DEBUGLEVEL_ell: Choose a higher value of this global variable to have more details of the computations printed during the 2-descent algorithm. 0 = don't print anything; 1 = (default) just print the result; 2 = print more details including the Selmer group and the nontrivial quartics.");
+ */
+diff --git a/src/sage/ext_data/pari/simon/qfsolve.gp b/src/sage/ext_data/pari/simon/qfsolve.gp
+index 501fb50828..2107288c1d 100644
+--- a/src/sage/ext_data/pari/simon/qfsolve.gp
++++ b/src/sage/ext_data/pari/simon/qfsolve.gp
+@@ -434,146 +434,6 @@ my(cc);
+ return([U3~*G3*U3,red[2]*U1*U2*U3]);
+ }
+ 
+-\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+-\\        QUADRATIC FORMS MINIMIZATION         \\
+-\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+-
+-\\ Minimization of the quadratic form G, with nonzero determinant.
+-\\ of dimension n>=2.
+-\\ G must by symmetric and have integral coefficients.
+-\\ Returns [G',U,factd] with U in GLn(Q) such that G'=U~*G*U*constant
+-\\ is integral and has minimal determinant.
+-\\ In dimension 3 or 4, may return a prime p
+-\\ if the reduction at p is impossible because of the local non solvability.
+-\\ If given, factdetG must be equal to factor(abs(det(G))).
+-{qfminimize(G,factdetG) =
+-my(factd,U,Ker,Ker2,sol,aux,di);
+-my(p);
+-my(n,lf,i,vp,dimKer,dimKer2,m);
+-
+-  n = length(G);
+-  factd = matrix(0,2);
+-  if( !factdetG, factdetG = factor(matdet(G)));
+-
+-  lf = length(factdetG[,1]);
+-  i = 1; U = matid(n);
+-
+-  while(i <= lf,
+-    vp = factdetG[i,2];
+-    if( vp == 0, i++; next);
+-    p = factdetG[i,1];
+-    if( p == -1, i++; next);
+-if( DEBUGLEVEL_qfsolve >= 4, print("    p = ",p,"^",vp));
+-
+-\\ The case vp = 1 can be minimized only if n is odd.
+-    if( vp == 1 && n%2 == 0,
+-      factd = concat(factd~, Mat([p,1])~)~;
+-      i++; next
+-    );
+-    Ker = kermodp(G,p); dimKer = Ker[1]; Ker = Ker[2];
+-
+-\\ Rem: we must have dimKer <= vp
+-if( DEBUGLEVEL_qfsolve >= 4, print("    dimKer = ",dimKer));
+-\\ trivial case: dimKer = n
+-    if( dimKer == n, 
+-if( DEBUGLEVEL_qfsolve >= 4, print("     case 0: dimKer = n"));
+-      G /= p;
+-      factdetG[i,2] -= n;
+-      next
+-    );
+-    G = Ker~*G*Ker;
+-    U = U*Ker;
+-
+-\\ 1st case: dimKer < vp
+-\\ then the kernel mod p contains a kernel mod p^2
+-    if( dimKer < vp,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 1: dimker < vp"));
+-      if( dimKer == 1,
+-\\        G[,1] /= p; G[1,] /= p;
+-        G[,1] /= p; G[1,] = G[1,]/p;
+-        U[,1] /= p;
+-        factdetG[i,2] -= 2
+-      , 
+-        Ker2 = kermodp(matrix(dimKer,dimKer,j,k,G[j,k]/p),p);
+-        dimKer2 = Ker2[1]; Ker2 = Ker2[2];
+-        for( j = 1, dimKer2, Ker2[,j] /= p);
+-        Ker2 = matdiagonalblock([Ker2,matid(n-dimKer)]);
+-        G = Ker2~*G*Ker2;
+-        U = U*Ker2;
+-        factdetG[i,2] -= 2*dimKer2
+-);
+-
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 1"));
+-      next
+-    );
+-
+-\\ Now, we have vp = dimKer 
+-\\ 2nd case: the dimension of the kernel is >=2
+-\\ and contains an element of norm 0 mod p^2
+-
+-\\ search for an element of norm p^2... in the kernel
+-    if( dimKer > 2 || 
+-       (dimKer == 2 && issquare( di = Mod((G[1,2]^2-G[1,1]*G[2,2])/p^2,p))),
+-      if( dimKer > 2,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 2.1"));
+-        dimKer = 3;
+-        sol = qfsolvemodp(matrix(3,3,j,k,G[j,k]/p),p)
+-      ,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 2.2"));
+-        if( G[1,1]%p^2 == 0, 
+-          sol = [1,0]~
+-        , sol = [-G[1,2]/p+sqrt(di),Mod(G[1,1]/p,p)]~
+-        )
+-      );
+-      sol = centerlift(sol);
+-      sol /= content(sol);
+-if( DEBUGLEVEL_qfsolve >= 4, print("    sol = ",sol));
+-      Ker = vectorv(n, j, if( j<= dimKer, sol[j], 0)); \\ fill with 0's
+-      Ker = completebasis(Ker,1);
+-      Ker[,n] /= p;
+-      G = Ker~*G*Ker;
+-      U = U*Ker;
+-      factdetG[i,2] -= 2;
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 2"));
+-      next
+-    );
+-
+-\\ Now, we have vp = dimKer <= 2 
+-\\   and the kernel contains no vector with norm p^2...
+-
+-\\ In some cases, exchanging the kernel and the image
+-\\ makes the minimization easy.
+-
+-    m = (n-1)\2-1;
+-    if( ( vp == 1 && issquare(Mod(-(-1)^m*matdet(G)/G[1,1],p)))
+-     || ( vp == 2 && n%2 == 1 && n >= 5)
+-     || ( vp == 2 && n%2 == 0 && !issquare(Mod((-1)^m*matdet(G)/p^2,p)))
+-    , 
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 3"));
+-      Ker = matid(n);
+-      for( j = dimKer+1, n, Ker[j,j] = p);
+-      G = Ker~*G*Ker/p;
+-      U = U*Ker;
+-      factdetG[i,2] -= 2*dimKer-n;
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 3"));
+-      next
+-    );
+-
+-\\ Minimization was not possible se far.
+-\\ If n == 3 or 4, this proves the local non-solubility at p.
+-    if( n == 3 || n == 4, 
+-if( DEBUGLEVEL_qfsolve >= 1, print(" no local solution at ",p));
+-      return(p));
+-
+-if( DEBUGLEVEL_qfsolve >= 4, print("    prime ",p," finished"));
+-    factd = concat(factd~,Mat([p,vp])~)~;
+-    i++
+-  );
+-\\ apply LLL to avoid coefficients explosion
+-  aux = qflll(U/content(U));
+-return([aux~*G*aux,U*aux,factd]);
+-}
+-
+ \\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+ \\          CLASS GROUP COMPUTATIONS           \\
+ \\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+diff --git a/src/sage/geometry/polyhedron/backend_field.py b/src/sage/geometry/polyhedron/backend_field.py
+index 6b921d23a6..2f32c58b1e 100644
+--- a/src/sage/geometry/polyhedron/backend_field.py
++++ b/src/sage/geometry/polyhedron/backend_field.py
+@@ -265,7 +265,7 @@ class Polyhedron_field(Polyhedron_base):
+              An inequality (-0.1419794359520263?, -1.698172434277148?) x + 1.200789243901438? >= 0,
+              An inequality (0.3001973109753594?, 0.600394621950719?) x - 0.4245431085692869? >= 0)
+             sage: p.Vrepresentation()                                           # optional - sage.rings.number_field
+-            (A vertex at (0.?e-15, 0.707106781186548?),
++            (A vertex at (0.?e-16, 0.7071067811865475?),
+              A vertex at (1.414213562373095?, 0),
+              A vertex at (4.000000000000000?, 0.372677996249965?))
+         """
+@@ -308,7 +308,7 @@ class Polyhedron_field(Polyhedron_base):
+              An inequality (-0.1419794359520263?, -1.698172434277148?) x + 1.200789243901438? >= 0,
+              An inequality (0.3001973109753594?, 0.600394621950719?) x - 0.4245431085692869? >= 0)
+             sage: p.Vrepresentation()                                           # optional - sage.rings.number_field
+-            (A vertex at (0.?e-15, 0.707106781186548?),
++            (A vertex at (0.?e-16, 0.7071067811865475?),
+              A vertex at (1.414213562373095?, 0),
+              A vertex at (4.000000000000000?, 0.372677996249965?))
+         """
+diff --git a/src/sage/geometry/polyhedron/backend_normaliz.py b/src/sage/geometry/polyhedron/backend_normaliz.py
+index 86b89632a5..ca8a43b248 100644
+--- a/src/sage/geometry/polyhedron/backend_normaliz.py
++++ b/src/sage/geometry/polyhedron/backend_normaliz.py
+@@ -53,7 +53,7 @@ def _number_field_elements_from_algebraics_list_of_lists_of_lists(listss, **kwds
+         1.732050807568878?
+         sage: from sage.geometry.polyhedron.backend_normaliz import _number_field_elements_from_algebraics_list_of_lists_of_lists
+         sage: K, results, hom = _number_field_elements_from_algebraics_list_of_lists_of_lists([[[rt2], [1]], [[rt3]], [[1], []]]); results  # optional - sage.rings.number_field
+-        [[[-a^3 + 3*a], [1]], [[-a^2 + 2]], [[1], []]]
++        [[[-a^3 + 3*a], [1]], [[a^2 - 2]], [[1], []]]
+     """
+     from sage.rings.qqbar import number_field_elements_from_algebraics
+     numbers = []
+diff --git a/src/sage/groups/matrix_gps/isometries.py b/src/sage/groups/matrix_gps/isometries.py
+index f9111a2c92..cca45e7175 100644
+--- a/src/sage/groups/matrix_gps/isometries.py
++++ b/src/sage/groups/matrix_gps/isometries.py
+@@ -11,11 +11,11 @@ EXAMPLES::
+     sage: L = IntegralLattice("D4")
+     sage: O = L.orthogonal_group()
+     sage: O
+-    Group of isometries with 5 generators (
+-    [-1  0  0  0]  [0 0 0 1]  [-1 -1 -1 -1]  [ 1  1  0  0]  [ 1  0  0  0]
+-    [ 0 -1  0  0]  [0 1 0 0]  [ 0  0  1  0]  [ 0  0  1  0]  [-1 -1 -1 -1]
+-    [ 0  0 -1  0]  [0 0 1 0]  [ 0  1  0  1]  [ 0  1  0  1]  [ 0  0  1  0]
+-    [ 0  0  0 -1], [1 0 0 0], [ 0 -1 -1  0], [ 0 -1 -1  0], [ 0  0  0  1]
++    Group of isometries with 3 generators (
++    [0 0 0 1]  [ 1  1  0  0]  [ 1  0  0  0]
++    [0 1 0 0]  [ 0  0  1  0]  [-1 -1 -1 -1]
++    [0 0 1 0]  [ 0  1  0  1]  [ 0  0  1  0]
++    [1 0 0 0], [ 0 -1 -1  0], [ 0  0  0  1]
+     )
+ 
+ Basic functionality is provided by GAP::
+diff --git a/src/sage/interfaces/genus2reduction.py b/src/sage/interfaces/genus2reduction.py
+index 56ae04b235..7a4794daf2 100644
+--- a/src/sage/interfaces/genus2reduction.py
++++ b/src/sage/interfaces/genus2reduction.py
+@@ -143,31 +143,31 @@ class ReductionData(SageObject):
+        sur un corps de valuation discrète", Trans. AMS 348 (1996),
+        4577-4610, Section 7.2, Proposition 4).
+     """
+-    def __init__(self, pari_result, P, Q, minimal_equation, minimal_disc,
+-                 local_data, conductor, prime_to_2_conductor_only):
++    def __init__(self, pari_result, P, Q, Pmin, Qmin, minimal_disc,
++                 local_data, conductor):
+         self.pari_result = pari_result
+         self.P = P
+         self.Q = Q
+-        self.minimal_equation = minimal_equation
++        self.Pmin = Pmin
++        self.Qmin = Qmin
+         self.minimal_disc = minimal_disc
+         self.local_data = local_data
+         self.conductor = conductor
+-        self.prime_to_2_conductor_only = prime_to_2_conductor_only
+ 
+     def _repr_(self):
+-        if self.prime_to_2_conductor_only:
+-            ex = ' (away from 2)'
+-        else:
+-            ex = ''
+         if self.Q == 0:
+             yterm = ''
+         else:
+             yterm = '+ (%s)*y '%self.Q
++
+         s = 'Reduction data about this proper smooth genus 2 curve:\n'
+         s += '\ty^2 %s= %s\n'%(yterm, self.P)
+-        s += 'A Minimal Equation (away from 2):\n\ty^2 = %s\n'%self.minimal_equation
+-        s += 'Minimal Discriminant (away from 2):  %s\n'%self.minimal_disc
+-        s += 'Conductor%s: %s\n'%(ex, self.conductor)
++        if self.Qmin:
++            s += 'A Minimal Equation:\n\ty^2 + (%s)y = %s\n'%(self.Qmin, self.Pmin)
++        else:
++            s += 'A Minimal Equation:\n\ty^2 = %s\n'%self.Pmin
++        s += 'Minimal Discriminant: %s\n'%self.minimal_disc
++        s += 'Conductor: %s\n'%self.conductor
+         s += 'Local Data:\n%s'%self._local_data_str()
+         return s
+ 
+@@ -242,17 +242,7 @@ class Genus2reduction(SageObject):
+         sage: factor(R.conductor)
+         5^4 * 2267
+ 
+-    This means that only the odd part of the conductor is known.
+-
+-    ::
+-
+-        sage: R.prime_to_2_conductor_only
+-        True
+-
+-    The discriminant is always minimal away from 2, but possibly not at
+-    2.
+-
+-    ::
++    The discriminant is always minimal::
+ 
+         sage: factor(R.minimal_disc)
+         2^3 * 5^5 * 2267
+@@ -264,10 +254,10 @@ class Genus2reduction(SageObject):
+         sage: R
+         Reduction data about this proper smooth genus 2 curve:
+             y^2 + (x^3 - 2*x^2 - 2*x + 1)*y = -5*x^5
+-        A Minimal Equation (away from 2):
+-            y^2 = x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855
+-        Minimal Discriminant (away from 2):  56675000
+-        Conductor (away from 2): 1416875
++        A Minimal Equation:
++            y^2 ...
++        Minimal Discriminant: 56675000
++        Conductor: 1416875
+         Local Data:
+             p=2
+             (potential) stable reduction:  (II), j=1
+@@ -293,10 +283,10 @@ class Genus2reduction(SageObject):
+         sage: genus2reduction(0, x^6 + 3*x^3 + 63)
+         Reduction data about this proper smooth genus 2 curve:
+                 y^2 = x^6 + 3*x^3 + 63
+-        A Minimal Equation (away from 2):
+-                y^2 = x^6 + 3*x^3 + 63
+-        Minimal Discriminant (away from 2):  10628388316852992
+-        Conductor (away from 2): 2893401
++        A Minimal Equation:
++                y^2 ...
++        Minimal Discriminant: -10628388316852992
++        Conductor: 2893401
+         Local Data:
+                 p=2
+                 (potential) stable reduction:  (V), j1+j2=0, j1*j2=0
+@@ -327,9 +317,9 @@ class Genus2reduction(SageObject):
+         sage: genus2reduction(x^3-x^2-1, x^2 - x)
+         Reduction data about this proper smooth genus 2 curve:
+                 y^2 + (x^3 - x^2 - 1)*y = x^2 - x
+-        A Minimal Equation (away from 2):
+-                y^2 = x^6 + 58*x^5 + 1401*x^4 + 18038*x^3 + 130546*x^2 + 503516*x + 808561
+-        Minimal Discriminant (away from 2):  169
++        A Minimal Equation:
++                y^2 ...
++        Minimal Discriminant: -169
+         Conductor: 169
+         Local Data:
+                 p=13
+@@ -370,10 +360,10 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^3 - 2*x^2 - 2*x + 1, -5*x^5)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^3 - 2*x^2 - 2*x + 1)*y = -5*x^5
+-            A Minimal Equation (away from 2):
+-                    y^2 = x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855
+-            Minimal Discriminant (away from 2):  56675000
+-            Conductor (away from 2): 1416875
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 56675000
++            Conductor: 1416875
+             Local Data:
+                     p=2
+                     (potential) stable reduction:  (II), j=1
+@@ -389,9 +379,9 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^2 + 1, -5*x^5)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^2 + 1)*y = -5*x^5
+-            A Minimal Equation (away from 2):
+-                    y^2 = -20*x^5 + x^4 + 2*x^2 + 1
+-            Minimal Discriminant (away from 2):  48838125
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 48838125
+             Conductor: 32025
+             Local Data:
+                     p=3
+@@ -412,9 +402,9 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^3 + x^2 + x,-2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^3 + x^2 + x)*y = -2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2
+-            A Minimal Equation (away from 2):
+-                    y^2 = x^6 + 18*x^3 + 36*x^2 - 27
+-            Minimal Discriminant (away from 2):  1520984142
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 1520984142
+             Conductor: 954
+             Local Data:
+                     p=2
+@@ -436,18 +426,10 @@ class Genus2reduction(SageObject):
+             raise ValueError("Q (=%s) must have degree at most 3" % Q)
+ 
+         res = pari.genus2red([P, Q])
+-
+         conductor = ZZ(res[0])
+-        minimal_equation = R(res[2])
+-
+-        minimal_disc = QQ(res[2].poldisc()).abs()
+-        if minimal_equation.degree() == 5:
+-            minimal_disc *= minimal_equation[5]**2
+-        # Multiply with suitable power of 2 of the form 2^(2*(d-1) - 12)
+-        b = 2 * (minimal_equation.degree() - 1)
+-        k = QQ((12 - minimal_disc.valuation(2), b)).ceil()
+-        minimal_disc >>= 12 - b*k
+-        minimal_disc = ZZ(minimal_disc)
++        Pmin = R(res[2][0])
++        Qmin = R(res[2][1])
++        minimal_disc = ZZ(pari.hyperelldisc(res[2]))
+ 
+         local_data = {}
+         for red in res[3]:
+@@ -468,9 +450,7 @@ class Genus2reduction(SageObject):
+ 
+             local_data[p] = data
+ 
+-        prime_to_2_conductor_only = (-1 in res[1].component(2))
+-        return ReductionData(res, P, Q, minimal_equation, minimal_disc, local_data,
+-                             conductor, prime_to_2_conductor_only)
++        return ReductionData(res, P, Q, Pmin, Qmin, minimal_disc, local_data, conductor)
+ 
+     def __reduce__(self):
+         return _reduce_load_genus2reduction, tuple([])
+diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
+index fec450d7bc..236402c293 100644
+--- a/src/sage/lfunctions/dokchitser.py
++++ b/src/sage/lfunctions/dokchitser.py
+@@ -337,6 +337,7 @@ class Dokchitser(SageObject):
+             # After init_coeffs is called, future calls to this method should
+             # return the full output for further parsing
+             raise RuntimeError("unable to create L-series, due to precision or other limits in PARI")
++        t = t.replace("  *** _^_: Warning: normalizing a series with 0 leading term.\n", "")
+         return t
+ 
+     def __check_init(self):
+diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
+index d2b20f1891..6c31efe239 100644
+--- a/src/sage/lfunctions/pari.py
++++ b/src/sage/lfunctions/pari.py
+@@ -339,7 +339,7 @@ def lfun_eta_quotient(scalings, exponents):
+         0.0374412812685155
+ 
+         sage: lfun_eta_quotient([6],[4])
+-        [[Vecsmall([7]), [Vecsmall([6]), Vecsmall([4])]], 0, [0, 1], 2, 36, 1]
++        [[Vecsmall([7]), [Vecsmall([6]), Vecsmall([4]), 0]], 0, [0, 1], 2, 36, 1]
+ 
+         sage: lfun_eta_quotient([2,1,4], [5,-2,-2])
+         Traceback (most recent call last):
+diff --git a/src/sage/libs/pari/tests.py b/src/sage/libs/pari/tests.py
+index e5a2aa2517..0efcb15de0 100644
+--- a/src/sage/libs/pari/tests.py
++++ b/src/sage/libs/pari/tests.py
+@@ -356,7 +356,7 @@ Constructors::
+     [2, 4]~*x + [1, 3]~
+ 
+     sage: pari(3).Qfb(7, 1)
+-    Qfb(3, 7, 1, 0.E-19)
++    Qfb(3, 7, 1)
+     sage: pari(3).Qfb(7, 2)
+     Traceback (most recent call last):
+     ...
+@@ -512,7 +512,7 @@ Basic functions::
+     sage: pari('sqrt(-2)').frac()
+     Traceback (most recent call last):
+     ...
+-    PariError: incorrect type in gfloor (t_COMPLEX)
++    PariError: incorrect type in gfrac (t_COMPLEX)
+ 
+     sage: pari('1+2*I').imag()
+     2
+diff --git a/src/sage/modular/cusps_nf.py b/src/sage/modular/cusps_nf.py
+index 25d93cac92..157ebabe29 100644
+--- a/src/sage/modular/cusps_nf.py
++++ b/src/sage/modular/cusps_nf.py
+@@ -1220,7 +1220,7 @@ def units_mod_ideal(I):
+         sage: I = k.ideal(5, a + 1)
+         sage: units_mod_ideal(I)
+         [1,
+-        2*a^2 + 4*a - 1,
++        -2*a^2 - 4*a + 1,
+         ...]
+ 
+     ::
+diff --git a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
+index a881336596..090d1bfaf0 100644
+--- a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
++++ b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
+@@ -43,7 +43,7 @@ def coerce_AA(p):
+         sage: AA(p)._exact_field()
+         Number Field in a with defining polynomial y^8 ... with a in ...
+         sage: coerce_AA(p)._exact_field()
+-        Number Field in a with defining polynomial y^4 - 1910*y^2 - 3924*y + 681058 with a in 39.710518724...?
++        Number Field in a with defining polynomial y^4 - 1910*y^2 - 3924*y + 681058 with a in ...?
+     """
+     el = AA(p)
+     el.simplify()
+diff --git a/src/sage/modular/modsym/p1list_nf.py b/src/sage/modular/modsym/p1list_nf.py
+index 222caacca8..f9d969732c 100644
+--- a/src/sage/modular/modsym/p1list_nf.py
++++ b/src/sage/modular/modsym/p1list_nf.py
+@@ -58,7 +58,7 @@ Lift an MSymbol to a matrix in `SL(2, R)`:
+ 
+     sage: alpha = MSymbol(N, a + 2, 3*a^2)
+     sage: alpha.lift_to_sl2_Ok()
+-    [-3*a^2 + a + 12, 25*a^2 - 50*a + 100, a + 2, a^2 - 3*a + 3]
++    [-1, 4*a^2 - 13*a + 23, a + 2, 5*a^2 + 3*a - 3]
+     sage: Ok = k.ring_of_integers()
+     sage: M = Matrix(Ok, 2, alpha.lift_to_sl2_Ok())
+     sage: det(M)
+@@ -945,11 +945,11 @@ class P1NFList(SageObject):
+             sage: N = k.ideal(5, a + 1)
+             sage: P = P1NFList(N)
+             sage: u = k.unit_group().gens_values(); u
+-            [-1, 2*a^2 + 4*a - 1]
++            [-1, -2*a^2 - 4*a + 1]
+             sage: P.apply_J_epsilon(4, -1)
+             2
+             sage: P.apply_J_epsilon(4, u[0], u[1])
+-            1
++            5
+ 
+         ::
+ 
+diff --git a/src/sage/modules/free_quadratic_module_integer_symmetric.py b/src/sage/modules/free_quadratic_module_integer_symmetric.py
+index a206f0c721..aeb19ab669 100644
+--- a/src/sage/modules/free_quadratic_module_integer_symmetric.py
++++ b/src/sage/modules/free_quadratic_module_integer_symmetric.py
+@@ -1168,11 +1168,11 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+             sage: A4 = IntegralLattice("A4")
+             sage: Aut = A4.orthogonal_group()
+             sage: Aut
+-            Group of isometries with 5 generators (
+-            [-1  0  0  0]  [0 0 0 1]  [-1 -1 -1  0]  [ 1  0  0  0]  [ 1  0  0  0]
+-            [ 0 -1  0  0]  [0 0 1 0]  [ 0  0  0 -1]  [-1 -1 -1 -1]  [ 0  1  0  0]
+-            [ 0  0 -1  0]  [0 1 0 0]  [ 0  0  1  1]  [ 0  0  0  1]  [ 0  0  1  1]
+-            [ 0  0  0 -1], [1 0 0 0], [ 0  1  0  0], [ 0  0  1  0], [ 0  0  0 -1]
++            Group of isometries with 4 generators (
++            [0 0 0 1]  [-1 -1 -1  0]  [ 1  0  0  0]  [ 1  0  0  0]
++            [0 0 1 0]  [ 0  0  0 -1]  [-1 -1 -1 -1]  [ 0  1  0  0]
++            [0 1 0 0]  [ 0  0  1  1]  [ 0  0  0  1]  [ 0  0  1  1]
++            [1 0 0 0], [ 0  1  0  0], [ 0  0  1  0], [ 0  0  0 -1]
+             )
+ 
+         The group acts from the right on the lattice and its discriminant group::
+@@ -1180,19 +1180,19 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+             sage: x = A4.an_element()
+             sage: g = Aut.an_element()
+             sage: g
+-            [ 1  1  1  0]
+-            [ 0  0 -1  0]
+-            [ 0  0  1  1]
+-            [ 0 -1 -1 -1]
++            [-1 -1 -1  0]
++            [ 0  0  1  0]
++            [ 0  0 -1 -1]
++            [ 0  1  1  1]
+             sage: x*g
+-            (1, 1, 1, 0)
++            (-1, -1, -1, 0)
+             sage: (x*g).parent()==A4
+             True
+             sage: (g*x).parent()
+             Vector space of dimension 4 over Rational Field
+             sage: y = A4.discriminant_group().an_element()
+             sage: y*g
+-            (1)
++            (4)
+ 
+         If the group is finite we can compute the usual things::
+ 
+@@ -1208,10 +1208,10 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+ 
+             sage: A2 = IntegralLattice(matrix.identity(3),Matrix(ZZ,2,3,[1,-1,0,0,1,-1]))
+             sage: A2.orthogonal_group()
+-            Group of isometries with 3 generators (
+-            [-1/3  2/3  2/3]  [ 2/3  2/3 -1/3]  [1 0 0]
+-            [ 2/3 -1/3  2/3]  [ 2/3 -1/3  2/3]  [0 0 1]
+-            [ 2/3  2/3 -1/3], [-1/3  2/3  2/3], [0 1 0]
++            Group of isometries with 2 generators (
++            [ 2/3  2/3 -1/3]  [1 0 0]
++            [ 2/3 -1/3  2/3]  [0 0 1]
++            [-1/3  2/3  2/3], [0 1 0]
+             )
+ 
+         It can be negative definite as well::
+diff --git a/src/sage/quadratic_forms/binary_qf.py b/src/sage/quadratic_forms/binary_qf.py
+index cfa3ada73e..5ac823bc6c 100755
+--- a/src/sage/quadratic_forms/binary_qf.py
++++ b/src/sage/quadratic_forms/binary_qf.py
+@@ -141,7 +141,7 @@ class BinaryQF(SageObject):
+                   and a.degree() == 2 and a.parent().ngens() == 2):
+                 x, y = a.parent().gens()
+                 a, b, c = [a.monomial_coefficient(mon) for mon in [x**2, x*y, y**2]]
+-            elif isinstance(a, pari_gen) and a.type() in ('t_QFI', 't_QFR'):
++            elif isinstance(a, pari_gen) and a.type() in ('t_QFI', 't_QFR', 't_QFB'):
+                 # a has 3 or 4 components
+                 a, b, c = a[0], a[1], a[2]
+         try:
+diff --git a/src/sage/quadratic_forms/genera/genus.py b/src/sage/quadratic_forms/genera/genus.py
+index 8290b6c4fa..0fc43f33c6 100644
+--- a/src/sage/quadratic_forms/genera/genus.py
++++ b/src/sage/quadratic_forms/genera/genus.py
+@@ -3088,8 +3088,8 @@ class GenusSymbol_global_ring():
+             sage: G = Genus(matrix(ZZ, 3, [6,3,0, 3,6,0, 0,0,2]))
+             sage: G.representatives()
+             (
+-            [2 0 0]  [ 2 -1  0]
+-            [0 6 3]  [-1  2  0]
++            [2 0 0]  [ 2  1  0]
++            [0 6 3]  [ 1  2  0]
+             [0 3 6], [ 0  0 18]
+             )
+ 
+diff --git a/src/sage/quadratic_forms/qfsolve.py b/src/sage/quadratic_forms/qfsolve.py
+index ddde95e04f..d5e15d9f83 100644
+--- a/src/sage/quadratic_forms/qfsolve.py
++++ b/src/sage/quadratic_forms/qfsolve.py
+@@ -70,7 +70,7 @@ def qfsolve(G):
+ 
+         sage: M = Matrix(QQ, [[3, 0, 0, 0], [0, 5, 0, 0], [0, 0, -7, 0], [0, 0, 0, -11]])
+         sage: qfsolve(M)
+-        (3, -4, -3, -2)
++        (3, 4, -3, -2)
+     """
+     ret = G.__pari__().qfsolve()
+     if ret.type() == 't_COL':
+diff --git a/src/sage/quadratic_forms/quadratic_form__automorphisms.py b/src/sage/quadratic_forms/quadratic_form__automorphisms.py
+index c36c667e3b..3d72cf3be1 100644
+--- a/src/sage/quadratic_forms/quadratic_form__automorphisms.py
++++ b/src/sage/quadratic_forms/quadratic_form__automorphisms.py
+@@ -300,9 +300,9 @@ def automorphism_group(self):
+         sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1])
+         sage: Q.automorphism_group()
+         Matrix group over Rational Field with 3 generators (
+-        [-1  0  0]  [0 0 1]  [ 0  0  1]
+-        [ 0 -1  0]  [0 1 0]  [-1  0  0]
+-        [ 0  0 -1], [1 0 0], [ 0  1  0]
++        [ 0  0  1]  [1 0 0]  [ 1  0  0]
++        [-1  0  0]  [0 0 1]  [ 0 -1  0]
++        [ 0  1  0], [0 1 0], [ 0  0  1]
+         )
+ 
+     ::
+diff --git a/src/sage/rings/finite_rings/finite_field_prime_modn.py b/src/sage/rings/finite_rings/finite_field_prime_modn.py
+index 9129ecb56a..d5a4cb8f22 100644
+--- a/src/sage/rings/finite_rings/finite_field_prime_modn.py
++++ b/src/sage/rings/finite_rings/finite_field_prime_modn.py
+@@ -111,7 +111,7 @@ class FiniteField_prime_modn(FiniteField_generic, integer_mod_ring.IntegerModRin
+             sage: RF13 = K.residue_field(pp)
+             sage: RF13.hom([GF(13)(1)])
+             Ring morphism:
+-             From: Residue field of Fractional ideal (w + 18)
++             From: Residue field of Fractional ideal (-w - 18)
+              To:   Finite Field of size 13
+              Defn: 1 |--> 1
+ 
+diff --git a/src/sage/rings/finite_rings/residue_field.pyx b/src/sage/rings/finite_rings/residue_field.pyx
+index 7596f2a302..1e1869f1b1 100644
+--- a/src/sage/rings/finite_rings/residue_field.pyx
++++ b/src/sage/rings/finite_rings/residue_field.pyx
+@@ -20,13 +20,13 @@ monogenic (i.e., 2 is an essential discriminant divisor)::
+ 
+     sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8)
+     sage: F = K.factor(2); F
+-    (Fractional ideal (1/2*a^2 - 1/2*a + 1)) * (Fractional ideal (-a^2 + 2*a - 3)) * (Fractional ideal (-3/2*a^2 + 5/2*a - 4))
++    (Fractional ideal (-1/2*a^2 + 1/2*a - 1)) * (Fractional ideal (-a^2 + 2*a - 3)) * (Fractional ideal (3/2*a^2 - 5/2*a + 4))
+     sage: F[0][0].residue_field()
+-    Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++    Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+     sage: F[1][0].residue_field()
+     Residue field of Fractional ideal (-a^2 + 2*a - 3)
+     sage: F[2][0].residue_field()
+-    Residue field of Fractional ideal (-3/2*a^2 + 5/2*a - 4)
++    Residue field of Fractional ideal (3/2*a^2 - 5/2*a + 4)
+ 
+ We can also form residue fields from `\ZZ`::
+ 
+@@ -258,9 +258,9 @@ class ResidueFieldFactory(UniqueFactory):
+     the index of ``ZZ[a]`` in the maximal order for all ``a``::
+ 
+         sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8); P = K.ideal(2).factor()[0][0]; P
+-        Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F = K.residue_field(P); F
+-        Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F(a)
+         0
+         sage: B = K.maximal_order().basis(); B
+@@ -270,7 +270,7 @@ class ResidueFieldFactory(UniqueFactory):
+         sage: F(B[2])
+         0
+         sage: F
+-        Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F.degree()
+         1
+ 
+@@ -730,15 +730,15 @@ class ResidueField_generic(Field):
+         EXAMPLES::
+ 
+             sage: I = QQ[3^(1/3)].factor(5)[1][0]; I
+-            Fractional ideal (-a + 2)
++            Fractional ideal (a - 2)
+             sage: k = I.residue_field(); k
+-            Residue field of Fractional ideal (-a + 2)
++            Residue field of Fractional ideal (a - 2)
+             sage: f = k.lift_map(); f
+             Lifting map:
+-              From: Residue field of Fractional ideal (-a + 2)
++              From: Residue field of Fractional ideal (a - 2)
+               To:   Maximal Order in Number Field in a with defining polynomial x^3 - 3 with a = 1.442249570307409?
+             sage: f.domain()
+-            Residue field of Fractional ideal (-a + 2)
++            Residue field of Fractional ideal (a - 2)
+             sage: f.codomain()
+             Maximal Order in Number Field in a with defining polynomial x^3 - 3 with a = 1.442249570307409?
+             sage: f(k.0)
+@@ -768,7 +768,7 @@ class ResidueField_generic(Field):
+ 
+             sage: K.<a> = NumberField(x^3-11)
+             sage: F = K.ideal(37).factor(); F
+-            (Fractional ideal (37, a + 9)) * (Fractional ideal (37, a + 12)) * (Fractional ideal (2*a - 5))
++            (Fractional ideal (37, a + 9)) * (Fractional ideal (37, a + 12)) * (Fractional ideal (-2*a + 5))
+             sage: k = K.residue_field(F[0][0])
+             sage: l = K.residue_field(F[1][0])
+             sage: k == l
+@@ -846,7 +846,7 @@ cdef class ReductionMap(Map):
+             sage: F.reduction_map()
+             Partially defined reduction map:
+               From: Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
+-              To:   Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++              To:   Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+ 
+             sage: K.<theta_5> = CyclotomicField(5)
+             sage: F = K.factor(7)[0][0].residue_field()
+diff --git a/src/sage/rings/number_field/S_unit_solver.py b/src/sage/rings/number_field/S_unit_solver.py
+index e99dff850f..759cbfb334 100644
+--- a/src/sage/rings/number_field/S_unit_solver.py
++++ b/src/sage/rings/number_field/S_unit_solver.py
+@@ -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 (xi - 3),
+-         Fractional ideal (-2*xi^2 + 3),
++        (Fractional ideal (-2*xi^2 + 3),
++         Fractional ideal (-xi + 3),
+          Fractional ideal (2*xi + 1))
+ 
+         sage: sieve_data[1]
+-        (Residue field of Fractional ideal (xi - 3),
+-         Residue field of Fractional ideal (-2*xi^2 + 3),
++        (Residue field of Fractional ideal (-2*xi^2 + 3),
++         Residue field of Fractional ideal (-xi + 3),
+          Residue field of Fractional ideal (2*xi + 1))
+ 
+         sage: sieve_data[2]
+-        ([18, 7, 16, 4], [18, 9, 12, 8], [18, 3, 10, 10])
++        ([18, 12, 16, 8], [18, 16, 10, 4], [18, 10, 12, 10])
+ 
+         sage: sieve_data[3]
+-        (486, 648, 11664)
++        (648, 2916, 3888)
+     """
+ 
+     K = SUK.number_field()
+diff --git a/src/sage/rings/number_field/bdd_height.py b/src/sage/rings/number_field/bdd_height.py
+index beb047ae02..b7c8c33d0b 100644
+--- a/src/sage/rings/number_field/bdd_height.py
++++ b/src/sage/rings/number_field/bdd_height.py
+@@ -248,7 +248,7 @@ def bdd_norm_pr_ideal_gens(K, norm_list):
+         sage: from sage.rings.number_field.bdd_height import bdd_norm_pr_ideal_gens
+         sage: K.<g> = QuadraticField(123)
+         sage: bdd_norm_pr_ideal_gens(K, range(5))
+-        {0: [0], 1: [1], 2: [-g - 11], 3: [], 4: [2]}
++        {0: [0], 1: [1], 2: [g + 11], 3: [], 4: [2]}
+ 
+     ::
+ 
+diff --git a/src/sage/rings/number_field/class_group.py b/src/sage/rings/number_field/class_group.py
+index 018ff5f5c6..73c0462cd1 100644
+--- a/src/sage/rings/number_field/class_group.py
++++ b/src/sage/rings/number_field/class_group.py
+@@ -221,11 +221,11 @@ class FractionalIdealClass(AbelianGroupWithValuesElement):
+             Class group of order 76 with structure C38 x C2
+             of Number Field in a with defining polynomial x^2 + 20072
+             sage: I = (G.0)^11; I
+-            Fractional ideal class (41, 1/2*a + 5)
++            Fractional ideal class (33, 1/2*a + 8)
+             sage: J = G(I.ideal()^5); J
+-            Fractional ideal class (115856201, 1/2*a + 40407883)
++            Fractional ideal class (39135393, 1/2*a + 13654253)
+             sage: J.reduce()
+-            Fractional ideal class (57, 1/2*a + 44)
++            Fractional ideal class (73, 1/2*a + 47)
+             sage: J == I^5
+             True
+         """
+diff --git a/src/sage/rings/number_field/galois_group.py b/src/sage/rings/number_field/galois_group.py
+index 79acd053bb..e060148e4d 100644
+--- a/src/sage/rings/number_field/galois_group.py
++++ b/src/sage/rings/number_field/galois_group.py
+@@ -944,7 +944,7 @@ class GaloisGroup_v2(GaloisGroup_perm):
+             sage: K.<b> = NumberField(x^4 - 2*x^2 + 2, 'a').galois_closure()
+             sage: G = K.galois_group()
+             sage: [G.artin_symbol(P) for P in K.primes_above(7)]
+-            [(1,5)(2,6)(3,7)(4,8), (1,5)(2,6)(3,7)(4,8), (1,4)(2,3)(5,8)(6,7), (1,4)(2,3)(5,8)(6,7)]
++            [(1,4)(2,3)(5,8)(6,7), (1,4)(2,3)(5,8)(6,7), (1,5)(2,6)(3,7)(4,8), (1,5)(2,6)(3,7)(4,8)]
+             sage: G.artin_symbol(17)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
+index 58463d570d..ff65634e99 100644
+--- a/src/sage/rings/number_field/number_field.py
++++ b/src/sage/rings/number_field/number_field.py
+@@ -3643,7 +3643,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
+ 
+@@ -4227,7 +4227,8 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             (y^2 + 6, Mod(1/6*y, y^2 + 6), Mod(6*y, y^2 + 1/6))
+         """
+         f = self.absolute_polynomial()._pari_with_name('y')
+-        if f.pollead() == f.content().denominator() == 1:
++        f = f * f.content().denominator()
++        if f.pollead() == 1:
+             g = f
+             alpha = beta = g.variable().Mod(g)
+         else:
+@@ -4821,7 +4822,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+ 
+             sage: K.<a> = NumberField(2*x^2 - 1/3)
+             sage: K._S_class_group_and_units(tuple(K.primes_above(2) + K.primes_above(3)))
+-            ([-6*a + 2, 6*a + 3, -1, 12*a + 5], [])
++            ([6*a + 2, 6*a + 3, -1, -12*a + 5], [])
+         """
+         K_pari = self.pari_bnf(proof=proof)
+         S_pari = [p.pari_prime() for p in sorted(set(S))]
+@@ -5166,7 +5167,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+ 
+             sage: [K.ideal(g).factor() for g in gens]
+             [(Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1)),
+-            Fractional ideal (-a),
++            Fractional ideal (a),
+             (Fractional ideal (2, a + 1))^2,
+             1]
+ 
+@@ -5751,7 +5752,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: K.elements_of_norm(3)
+             []
+             sage: K.elements_of_norm(50)
+-            [-7*a + 1, 5*a - 5, 7*a + 1]
++            [-a - 7, 5*a - 5, 7*a + 1]
+ 
+         TESTS:
+ 
+@@ -5863,7 +5864,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: K.factor(1+a)
+             Fractional ideal (a + 1)
+             sage: K.factor(1+a/5)
+-            (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1 * (Fractional ideal (-3*a - 2))
++            (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1 * (Fractional ideal (-2*a + 3))
+ 
+         An example over a relative number field::
+ 
+@@ -6460,9 +6461,9 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: new_basis = k.reduced_basis(prec=120)
+             sage: [c.minpoly() for c in new_basis]
+             [x - 1,
+-             x^2 - x + 1,
++             x^2 + x + 1,
++             x^6 + 3*x^5 - 102*x^4 - 103*x^3 + 10572*x^2 - 59919*x + 127657,
+              x^6 + 3*x^5 - 102*x^4 - 103*x^3 + 10572*x^2 - 59919*x + 127657,
+-             x^6 - 3*x^5 - 102*x^4 + 315*x^3 + 10254*x^2 - 80955*x + 198147,
+              x^3 - 171*x + 848,
+              x^6 + 171*x^4 + 1696*x^3 + 29241*x^2 + 145008*x + 719104]
+             sage: R = k.order(new_basis)
+@@ -7058,7 +7059,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+              -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)
++             2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7)
+ 
+         TESTS:
+ 
+@@ -7067,7 +7068,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)
+ 
+@@ -7146,7 +7147,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^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]
++            [-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, 2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7]
+         """
+         proof = proof_flag(proof)
+ 
+diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx
+index 784c239dc1..aa740069dc 100644
+--- a/src/sage/rings/number_field/number_field_element.pyx
++++ b/src/sage/rings/number_field/number_field_element.pyx
+@@ -4446,7 +4446,7 @@ cdef class NumberFieldElement(FieldElement):
+             sage: f = Qi.embeddings(K)[0]
+             sage: a = f(2+3*i) * (2-zeta)^2
+             sage: a.descend_mod_power(Qi,2)
+-            [-3*i - 2, -2*i + 3]
++            [-2*i + 3, 3*i + 2]
+ 
+         An absolute example::
+ 
+@@ -5124,7 +5124,7 @@ cdef class NumberFieldElement_relative(NumberFieldElement):
+         EXAMPLES::
+ 
+             sage: K.<a, b, c> = NumberField([x^2 - 2, x^2 - 3, x^2 - 5])
+-            sage: P = K.prime_factors(5)[0]
++            sage: P = K.prime_factors(5)[1]
+             sage: (2*a + b - c).valuation(P)
+             1
+         """
+diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
+index 5f587556a4..33481fead0 100644
+--- a/src/sage/rings/number_field/number_field_ideal.py
++++ b/src/sage/rings/number_field/number_field_ideal.py
+@@ -3355,7 +3355,7 @@ def quotient_char_p(I, p):
+         []
+ 
+         sage: I = K.factor(13)[0][0]; I
+-        Fractional ideal (-3*i - 2)
++        Fractional ideal (-2*i + 3)
+         sage: I.residue_class_degree()
+         1
+         sage: quotient_char_p(I, 13)[0]
+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 bae36d4b9c..f64bd5b761 100644
+--- a/src/sage/rings/number_field/number_field_ideal_rel.py
++++ b/src/sage/rings/number_field/number_field_ideal_rel.py
+@@ -272,7 +272,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.gens_reduced()
+-            (2, 15*a*b + 3*a + 1)
++            (2, -15*a*b + 3*a + 1)
+         """
+         try:
+             # Compute the single generator, if it exists
+@@ -401,7 +401,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.relative_norm()
+-            Fractional ideal (-6*a + 2)
++            Fractional ideal (6*a + 2)
+         """
+         L = self.number_field()
+         K = L.base_field()
+@@ -518,7 +518,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.ideal_below()
+-            Fractional ideal (-6*a + 2)
++            Fractional ideal (6*a + 2)
+         """
+         L = self.number_field()
+         K = L.base_field()
+diff --git a/src/sage/rings/number_field/number_field_rel.py b/src/sage/rings/number_field/number_field_rel.py
+index d33980c4b1..50e846b205 100644
+--- a/src/sage/rings/number_field/number_field_rel.py
++++ b/src/sage/rings/number_field/number_field_rel.py
+@@ -213,14 +213,14 @@ class NumberField_relative(NumberField_generic):
+             sage: l.<b> = k.extension(5*x^2 + 3); l
+             Number Field in b with defining polynomial 5*x^2 + 3 over its base field
+             sage: l.pari_rnf()
+-            [x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4), ..., y^4 + 6*y^2 + 1, x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4)], [0, 0]]
++            [x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4), ..., y^4 + 6*y^2 + 1, x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4)], [0, 0]]
+             sage: b
+             b
+ 
+             sage: l.<b> = k.extension(x^2 + 3/5); l
+             Number Field in b with defining polynomial x^2 + 3/5 over its base field
+             sage: l.pari_rnf()
+-            [x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4), ..., y^4 + 6*y^2 + 1, x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4)], [0, 0]]
++            [x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4), ..., y^4 + 6*y^2 + 1, x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4)], [0, 0]]
+             sage: b
+             b
+ 
+diff --git a/src/sage/rings/number_field/order.py b/src/sage/rings/number_field/order.py
+index 6eca89ed8d..78ef4c3b33 100644
+--- a/src/sage/rings/number_field/order.py
++++ b/src/sage/rings/number_field/order.py
+@@ -520,7 +520,7 @@ class Order(IntegralDomain, sage.rings.abc.Order):
+             sage: k.<a> = NumberField(x^2 + 5077); G = k.class_group(); G
+             Class group of order 22 with structure C22 of Number Field in a with defining polynomial x^2 + 5077
+             sage: G.0 ^ -9
+-            Fractional ideal class (11, a + 7)
++            Fractional ideal class (43, a + 13)
+             sage: Ok = k.maximal_order(); Ok
+             Maximal Order in Number Field in a with defining polynomial x^2 + 5077
+             sage: Ok * (11, a + 7)
+diff --git a/src/sage/rings/number_field/selmer_group.py b/src/sage/rings/number_field/selmer_group.py
+index c534aaa9f6..6bc67565d2 100644
+--- a/src/sage/rings/number_field/selmer_group.py
++++ b/src/sage/rings/number_field/selmer_group.py
+@@ -491,7 +491,7 @@ def pSelmerGroup(K, S, p, proof=None, debug=False):
+ 
+         sage: [K.ideal(g).factor() for g in gens]
+         [(Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1)),
+-        Fractional ideal (-a),
++        Fractional ideal (a),
+         (Fractional ideal (2, a + 1))^2,
+         1]
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
+index bb5d8356be..8a7e5fa66f 100644
+--- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
++++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
+@@ -1791,7 +1791,7 @@ class PolynomialQuotientRing_generic(CommutativeRing):
+             sage: D.selmer_generators([K.ideal(2, -a+1), K.ideal(3, a+1)], 3)
+             [2, a + 1]
+             sage: D.selmer_generators([K.ideal(2, -a+1), K.ideal(3, a+1), K.ideal(a)], 3)
+-            [2, a + 1, a]
++            [2, a + 1, -a]
+ 
+         """
+         fields, isos, iso_classes = self._S_decomposition(tuple(S))
+diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py
+index 704b77ce5f..83ee4549e4 100644
+--- a/src/sage/rings/qqbar.py
++++ b/src/sage/rings/qqbar.py
+@@ -312,8 +312,8 @@ and we get a way to produce the number directly::
+     True
+     sage: sage_input(n)
+     R.<y> = QQ[]
+-    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(RR(0.51763809020504148), RR(0.51763809020504159)))
+-    -109*v^3 - 89*v^2 + 327*v + 178
++    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(-RR(1.9318516525781366), -RR(1.9318516525781364)))
++    -109*v^3 + 89*v^2 + 327*v - 178
+ 
+ We can also see that some computations (basically, those which are
+ easy to perform exactly) are performed directly, instead of storing
+@@ -362,7 +362,7 @@ algorithms in :trac:`10255`::
+     # Verified
+     R1.<x> = QQbar[]
+     R2.<y> = QQ[]
+-    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(RR(0.51763809020504148), RR(0.51763809020504159)))
++    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(-RR(1.9318516525781366), -RR(1.9318516525781364)))
+     AA.polynomial_root(AA.common_polynomial(x^4 + QQbar(v^3 - 3*v - 1)*x^3 + QQbar(-v^3 + 3*v - 3)*x^2 + QQbar(-3*v^3 + 9*v + 3)*x + QQbar(3*v^3 - 9*v)), RIF(RR(0.99999999999999989), RR(1.0000000000000002)))
+     sage: one
+     1
+@@ -2310,7 +2310,7 @@ def do_polred(poly, threshold=32):
+     cost = 2 * bitsize.nbits() + 5 * poly.degree().nbits()
+     if cost > threshold:
+         return parent.gen(), parent.gen(), poly
+-    new_poly, elt_back = poly.__pari__().polredbest(flag=1)
++    new_poly, elt_back = poly.numerator().__pari__().polredbest(flag=1)
+     elt_fwd = elt_back.modreverse()
+     return parent(elt_fwd.lift()), parent(elt_back.lift()), parent(new_poly)
+ 
+@@ -2542,10 +2542,10 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+            Defn: a |--> 1.414213562373095?)
+ 
+         sage: number_field_elements_from_algebraics((rt2,rt3))
+-        (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, [-a^3 + 3*a, -a^2 + 2], Ring morphism:
++        (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, [-a^3 + 3*a, a^2 - 2], Ring morphism:
+             From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+             To:   Algebraic Real Field
+-            Defn: a |--> 0.5176380902050415?)
++            Defn: a |--> -1.931851652578137?)
+ 
+     ``rt3a`` is a real number in ``QQbar``.  Ordinarily, we'd get a homomorphism
+     to ``AA`` (because all elements are real), but if we specify ``same_field=True``,
+@@ -2570,7 +2570,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, -a^3 + 3*a, Ring morphism:
+             From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+             To:   Algebraic Real Field
+-            Defn: a |--> 0.5176380902050415?)
++            Defn: a |--> -1.931851652578137?)
+ 
+     We can specify ``minimal=True`` if we want the smallest number field::
+ 
+@@ -2618,7 +2618,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         sage: nfI^2
+         -1
+         sage: sum = nfrt2 + nfrt3 + nfI + nfz3; sum
+-        2*a^6 + a^5 - a^4 - a^3 - 2*a^2 - a
++        a^5 + a^4 - a^3 + 2*a^2 - a - 1
+         sage: hom(sum)
+         2.646264369941973? + 1.866025403784439?*I
+         sage: hom(sum) == rt2 + rt3 + qqI + z3
+@@ -2658,7 +2658,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         sage: nf, nums, hom = number_field_elements_from_algebraics(elems, embedded=True)
+         sage: nf
+         Number Field in a with defining polynomial y^24 - 6*y^23 ...- 9*y^2 + 1
+-          with a = 0.2598678911433438? + 0.0572892247058457?*I
++          with a = 0.2598679? + 0.0572892?*I
+         sage: list(map(QQbar, nums)) == elems == list(map(hom, nums))
+         True
+ 
+@@ -2725,7 +2725,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+                          sqrt(2), AA.polynomial_root(x^3-3, RIF(0,3)), 11/9, 1]
+         sage: res = number_field_elements_from_algebraics(my_nums, embedded=True)
+         sage: res[0]
+-        Number Field in a with defining polynomial y^24 - 107010*y^22 - 24*y^21 + ... + 250678447193040618624307096815048024318853254384 with a = -95.5053039433554?
++        Number Field in a with defining polynomial y^24 - 107010*y^22 - 24*y^21 + ... + 250678447193040618624307096815048024318853254384 with a = 93.32530798172420?
+     """
+     gen = qq_generator
+ 
+@@ -3129,7 +3129,7 @@ class AlgebraicGenerator(SageObject):
+             sage: root = ANRoot(x^2 - x - 1, RIF(1, 2))
+             sage: gen = AlgebraicGenerator(nf, root)
+             sage: gen.pari_field()
+-             [y^2 - y - 1, [2, 0], ...]
++            [[y^2 - y - 1, [2, 0], ...]
+         """
+         if self.is_trivial():
+             raise ValueError("No PARI field attached to trivial generator")
+@@ -3213,7 +3213,7 @@ class AlgebraicGenerator(SageObject):
+             sage: qq_generator.union(gen3) is gen3
+             True
+             sage: gen2.union(gen3)
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+         """
+         if self._trivial:
+             return other
+@@ -3306,13 +3306,13 @@ class AlgebraicGenerator(SageObject):
+             Number Field in a with defining polynomial y^2 - 3 with a in 1.732050807568878?
+             sage: gen2_3 = gen2.union(gen3)
+             sage: gen2_3
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+             sage: qq_generator.super_poly(gen2) is None
+             True
+             sage: gen2.super_poly(gen2_3)
+             -a^3 + 3*a
+             sage: gen3.super_poly(gen2_3)
+-            -a^2 + 2
++            a^2 - 2
+ 
+         """
+         if checked is None:
+@@ -3360,13 +3360,13 @@ class AlgebraicGenerator(SageObject):
+             sage: sqrt3 = ANExtensionElement(gen3, nf3.gen())
+             sage: gen2_3 = gen2.union(gen3)
+             sage: gen2_3
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+             sage: gen2_3(sqrt2)
+             -a^3 + 3*a
+             sage: gen2_3(ANRational(1/7))
+             1/7
+             sage: gen2_3(sqrt3)
+-            -a^2 + 2
++            a^2 - 2
+         """
+         if self._trivial:
+             return elt._value
+@@ -4336,10 +4336,10 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: rt3 = AA(sqrt(3))
+             sage: rt3b = rt2 + rt3 - rt2
+             sage: rt3b.as_number_field_element()
+-            (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, -a^2 + 2, Ring morphism:
++            (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, a^2 - 2, Ring morphism:
+                 From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+                 To:   Algebraic Real Field
+-                Defn: a |--> 0.5176380902050415?)
++                Defn: a |--> -1.931851652578137?)
+             sage: rt3b.as_number_field_element(minimal=True)
+             (Number Field in a with defining polynomial y^2 - 3, a, Ring morphism:
+                From: Number Field in a with defining polynomial y^2 - 3
+@@ -4401,7 +4401,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: rt2b = rt3 + rt2 - rt3
+             sage: rt2b.exactify()
+             sage: rt2b._exact_value()
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b.simplify()
+             sage: rt2b._exact_value()
+             a where a^2 - 2 = 0 and a in 1.414213562373095?
+@@ -4422,7 +4422,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: QQbar(2)._exact_field()
+             Trivial generator
+             sage: (sqrt(QQbar(2)) + sqrt(QQbar(19)))._exact_field()
+-            Number Field in a with defining polynomial y^4 - 20*y^2 + 81 with a in 2.375100220297941?
++            Number Field in a with defining polynomial y^4 - 20*y^2 + 81 with a in -3.789313782671036?
+             sage: (QQbar(7)^(3/5))._exact_field()
+             Number Field in a with defining polynomial y^5 - 2*y^4 - 18*y^3 + 38*y^2 + 82*y - 181 with a in 2.554256611698490?
+         """
+@@ -4442,7 +4442,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: QQbar(2)._exact_value()
+             2
+             sage: (sqrt(QQbar(2)) + sqrt(QQbar(19)))._exact_value()
+-            -1/9*a^3 - a^2 + 11/9*a + 10 where a^4 - 20*a^2 + 81 = 0 and a in 2.375100220297941?
++            -1/9*a^3 + a^2 + 11/9*a - 10 where a^4 - 20*a^2 + 81 = 0 and a in -3.789313782671036?
+             sage: (QQbar(7)^(3/5))._exact_value()
+             2*a^4 + 2*a^3 - 34*a^2 - 17*a + 150 where a^5 - 2*a^4 - 18*a^3 + 38*a^2 + 82*a - 181 = 0 and a in 2.554256611698490?
+         """
+@@ -6857,7 +6857,7 @@ class AlgebraicPolynomialTracker(SageObject):
+             sage: p = sqrt(AA(2)) * x^2 - sqrt(AA(3))
+             sage: cp = AA.common_polynomial(p)
+             sage: cp.generator()
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 1.931851652578137?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -0.5176380902050415?
+         """
+         self.exactify()
+         return self._gen
+@@ -7706,7 +7706,7 @@ class ANExtensionElement(ANDescr):
+ 
+             sage: rt2b.exactify()
+             sage: rt2b._descr
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b._descr.is_simple()
+             False
+         """
+@@ -7791,7 +7791,7 @@ class ANExtensionElement(ANDescr):
+             sage: rt2b = rt3 + rt2 - rt3
+             sage: rt2b.exactify()
+             sage: rt2b._descr
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b._descr.simplify(rt2b)
+             a where a^2 - 2 = 0 and a in 1.414213562373095?
+         """
+@@ -7830,9 +7830,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.neg(a)
+-            1/3*a^3 - 2/3*a^2 + 4/3*a - 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -1/3*a^3 + 1/3*a^2 - a - 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+             sage: b.neg("ham spam and eggs")
+-            1/3*a^3 - 2/3*a^2 + 4/3*a - 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -1/3*a^3 + 1/3*a^2 - a - 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+         """
+         return ANExtensionElement(self._generator, -self._value)
+ 
+@@ -7848,9 +7848,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.invert(a)
+-            7/3*a^3 - 2/3*a^2 + 4/3*a - 12 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -7/3*a^3 + 19/3*a^2 - 7*a - 9 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+             sage: b.invert("ham spam and eggs")
+-            7/3*a^3 - 2/3*a^2 + 4/3*a - 12 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -7/3*a^3 + 19/3*a^2 - 7*a - 9 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+         """
+         return ANExtensionElement(self._generator, ~self._value)
+ 
+@@ -7866,9 +7866,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.conjugate(a)
+-            -1/3*a^3 + 2/3*a^2 - 4/3*a + 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? + 1.573132184970987?*I
++            1/3*a^3 - 1/3*a^2 + a + 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? - 1.573132184970987?*I
+             sage: b.conjugate("ham spam and eggs")
+-            -1/3*a^3 + 2/3*a^2 - 4/3*a + 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? + 1.573132184970987?*I
++            1/3*a^3 - 1/3*a^2 + a + 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? - 1.573132184970987?*I
+         """
+         if self._exactly_real:
+             return self
+@@ -8501,7 +8501,7 @@ def an_binop_expr(a, b, op):
+         sage: x = an_binop_expr(a, b, operator.add); x
+         <sage.rings.qqbar.ANBinaryExpr object at ...>
+         sage: x.exactify()
+-        -6/7*a^7 + 2/7*a^6 + 71/7*a^5 - 26/7*a^4 - 125/7*a^3 + 72/7*a^2 + 43/7*a - 47/7 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in 3.12580...?
++        6/7*a^7 - 2/7*a^6 - 71/7*a^5 + 26/7*a^4 + 125/7*a^3 - 72/7*a^2 - 43/7*a + 47/7 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in -0.3199179336182997?
+ 
+         sage: a = QQbar(sqrt(2)) + QQbar(sqrt(3))
+         sage: b = QQbar(sqrt(3)) + QQbar(sqrt(5))
+@@ -8510,7 +8510,7 @@ def an_binop_expr(a, b, op):
+         sage: x = an_binop_expr(a, b, operator.mul); x
+         <sage.rings.qqbar.ANBinaryExpr object at ...>
+         sage: x.exactify()
+-        2*a^7 - a^6 - 24*a^5 + 12*a^4 + 46*a^3 - 22*a^2 - 22*a + 9 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in 3.1258...?
++        2*a^7 - a^6 - 24*a^5 + 12*a^4 + 46*a^3 - 22*a^2 - 22*a + 9 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in -0.3199179336182997?
+     """
+     return ANBinaryExpr(a, b, op)
+ 
+diff --git a/src/sage/schemes/affine/affine_morphism.py b/src/sage/schemes/affine/affine_morphism.py
+index 1c4f2dff18..32c2e47e49 100644
+--- a/src/sage/schemes/affine/affine_morphism.py
++++ b/src/sage/schemes/affine/affine_morphism.py
+@@ -1148,9 +1148,9 @@ class SchemeMorphism_polynomial_affine_space_field(SchemeMorphism_polynomial_aff
+             sage: H = End(A)
+             sage: f = H([(QQbar(sqrt(2))*x^2 + 1/QQbar(sqrt(3))) / (5*x)])
+             sage: f.reduce_base_field()
+-            Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a = 1.931851652578137?
++            Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a = ...?
+               Defn: Defined on coordinates by sending (x) to
+-                    (((a^3 - 3*a)*x^2 + (1/3*a^2 - 2/3))/(5*x))
++                    (((a^3 - 3*a)*x^2 + (-1/3*a^2 + 2/3))/(5*x))
+ 
+         ::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_field.py b/src/sage/schemes/elliptic_curves/ell_field.py
+index 68b8375dae..48f358ea6a 100644
+--- a/src/sage/schemes/elliptic_curves/ell_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_field.py
+@@ -845,7 +845,7 @@ class EllipticCurve_field(ell_generic.EllipticCurve_generic, ProjectivePlaneCurv
+             sage: E = E.base_extend(G).quadratic_twist(c); E
+             Elliptic Curve defined by y^2 = x^3 + 5*a0*x^2 + (-200*a0^2)*x + (-42000*a0^2+42000*a0+126000) over Number Field in a0 with defining polynomial x^3 - 3*x^2 + 3*x + 9
+             sage: K.<b> = E.division_field(3, simplify_all=True); K
+-            Number Field in b with defining polynomial x^12 - 10*x^10 + 55*x^8 - 60*x^6 + 75*x^4 + 1350*x^2 + 2025
++            Number Field in b with defining polynomial x^12 + 5*x^10 + 40*x^8 + 315*x^6 + 750*x^4 + 675*x^2 + 2025
+ 
+         Some higher-degree examples::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_generic.py b/src/sage/schemes/elliptic_curves/ell_generic.py
+index 926ae310ea..3bae819fb0 100644
+--- a/src/sage/schemes/elliptic_curves/ell_generic.py
++++ b/src/sage/schemes/elliptic_curves/ell_generic.py
+@@ -3324,8 +3324,8 @@ 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),
++            [0, 0, 0, Mod(1, y^2 - 2),
++            Mod(y, y^2 - 2), 0, 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;
+diff --git a/src/sage/schemes/elliptic_curves/ell_number_field.py b/src/sage/schemes/elliptic_curves/ell_number_field.py
+index edbd196090..c44c803aa8 100644
+--- a/src/sage/schemes/elliptic_curves/ell_number_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_number_field.py
+@@ -218,7 +218,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: E == loads(dumps(E))
+             True
+             sage: E.simon_two_descent()
+-            (2, 2, [(0 : 0 : 1)])
++            (2, 2, [(0 : 0 : 1), (1/18*a + 7/18 : -5/54*a - 17/54 : 1)])
+             sage: E.simon_two_descent(lim1=5, lim3=5, limtriv=10, maxprob=7, limbigprime=10)
+             (2, 2, [(-1 : 0 : 1), (-2 : -1/2*a - 1/2 : 1)])
+ 
+@@ -274,7 +274,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: E.simon_two_descent()  # long time (4s on sage.math, 2013)
+             (3,
+              3,
+-             [(5/8*zeta43_0^2 + 17/8*zeta43_0 - 9/4 : -27/16*zeta43_0^2 - 103/16*zeta43_0 + 39/8 : 1),
++             [(1/8*zeta43_0^2 - 3/8*zeta43_0 - 1/4 : -5/16*zeta43_0^2 + 7/16*zeta43_0 + 1/8 : 1),
+               (0 : 0 : 1)])
+         """
+         verbose = int(verbose)
+@@ -865,7 +865,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             Conductor exponent: 1
+             Kodaira Symbol: I1
+             Tamagawa Number: 1,
+-            Local data at Fractional ideal (-3*i - 2):
++            Local data at Fractional ideal (-2*i + 3):
+             Reduction type: bad split multiplicative
+             Local minimal model: Elliptic Curve defined by y^2 + (i+1)*x*y + y = x^3 over Number Field in i with defining polynomial x^2 + 1
+             Minimal discriminant valuation: 2
+@@ -2645,12 +2645,12 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             [-92, -23, -23]
+ 
+             sage: C.matrix()  # long time
+-            [1 2 2 4 2 4]
+-            [2 1 2 2 4 4]
+-            [2 2 1 4 4 2]
+-            [4 2 4 1 3 3]
+-            [2 4 4 3 1 3]
+-            [4 4 2 3 3 1]
++            [1 2 2 4 4 2]
++            [2 1 2 4 2 4]
++            [2 2 1 2 4 4]
++            [4 4 2 1 3 3]
++            [4 2 4 3 1 3]
++            [2 4 4 3 3 1]
+ 
+         The graph of this isogeny class has a shape which does not
+         occur over `\QQ`: a triangular prism.  Note that for curves
+@@ -2677,12 +2677,12 @@ class EllipticCurve_number_field(EllipticCurve_field):
+ 
+             sage: G = C.graph()  # long time
+             sage: G.adjacency_matrix()  # long time
+-            [0 1 1 0 1 0]
+-            [1 0 1 1 0 0]
+-            [1 1 0 0 0 1]
+-            [0 1 0 0 1 1]
+-            [1 0 0 1 0 1]
+-            [0 0 1 1 1 0]
++            [0 1 1 0 0 1]
++            [1 0 1 0 1 0]
++            [1 1 0 1 0 0]
++            [0 0 1 0 1 1]
++            [0 1 0 1 0 1]
++            [1 0 0 1 1 0]
+ 
+         To display the graph without any edge labels::
+ 
+@@ -3316,7 +3316,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: points = [E.lift_x(x) for x in xi]
+             sage: newpoints, U = E.lll_reduce(points)  # long time (35s on sage.math, 2011)
+             sage: [P[0] for P in newpoints]            # long time
+-            [6823803569166584943, 5949539878899294213, 2005024558054813068, 5864879778877955778, 23955263915878682727/4, 5922188321411938518, 5286988283823825378, 175620639884534615751/25, -11451575907286171572, 3502708072571012181, 1500143935183238709184/225, 27180522378120223419/4, -5811874164190604461581/625, 26807786527159569093, 7404442636649562303, 475656155255883588, 265757454726766017891/49, 7272142121019825303, 50628679173833693415/4, 6951643522366348968, 6842515151518070703, 111593750389650846885/16, 2607467890531740394315/9, -1829928525835506297]
++            [6823803569166584943, 5949539878899294213, 2005024558054813068, 5864879778877955778, 23955263915878682727/4, 5922188321411938518, 5286988283823825378, 11465667352242779838, -11451575907286171572, 3502708072571012181, 1500143935183238709184/225, 27180522378120223419/4, -5811874164190604461581/625, 26807786527159569093, 7041412654828066743, 475656155255883588, 265757454726766017891/49, 7272142121019825303, 50628679173833693415/4, 6951643522366348968, 6842515151518070703, 111593750389650846885/16, 2607467890531740394315/9, -1829928525835506297]
+ 
+         An example to show the explicit use of the height pairing matrix::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_rational_field.py b/src/sage/schemes/elliptic_curves/ell_rational_field.py
+index 3808822812..a75290ea35 100644
+--- a/src/sage/schemes/elliptic_curves/ell_rational_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_rational_field.py
+@@ -1827,7 +1827,7 @@ class EllipticCurve_rational_field(EllipticCurve_number_field):
+             sage: E = EllipticCurve('389a1')
+             sage: E._known_points = []  # clear cached points
+             sage: E.simon_two_descent()
+-            (2, 2, [(1 : 0 : 1), (-11/9 : 28/27 : 1)])
++            (2, 2, [(5/4 : 5/8 : 1), (-3/4 : 7/8 : 1)])
+             sage: E = EllipticCurve('5077a1')
+             sage: E.simon_two_descent()
+             (3, 3, [(1 : 0 : 1), (2 : 0 : 1), (0 : 2 : 1)])
+diff --git a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
+index 81ad295160..d484a4a18b 100644
+--- a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
++++ b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
+@@ -780,12 +780,12 @@ def deg_one_primes_iter(K, principal_only=False):
+         [Fractional ideal (2, a + 1),
+          Fractional ideal (3, a + 1),
+          Fractional ideal (3, a + 2),
+-         Fractional ideal (-a),
++         Fractional ideal (a),
+          Fractional ideal (7, a + 3),
+          Fractional ideal (7, a + 4)]
+         sage: it = deg_one_primes_iter(K, True)
+         sage: [next(it) for _ in range(6)]
+-        [Fractional ideal (-a),
++        [Fractional ideal (a),
+          Fractional ideal (-2*a + 3),
+          Fractional ideal (2*a + 3),
+          Fractional ideal (a + 6),
+diff --git a/src/sage/schemes/elliptic_curves/gp_simon.py b/src/sage/schemes/elliptic_curves/gp_simon.py
+index 28b97f34af..9f7d1b6020 100644
+--- a/src/sage/schemes/elliptic_curves/gp_simon.py
++++ b/src/sage/schemes/elliptic_curves/gp_simon.py
+@@ -56,7 +56,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+         sage: import sage.schemes.elliptic_curves.gp_simon
+         sage: E=EllipticCurve('389a1')
+         sage: sage.schemes.elliptic_curves.gp_simon.simon_two_descent(E)
+-        (2, 2, [(1 : 0 : 1), (-11/9 : 28/27 : 1)])
++        (2, 2, [(5/4 : 5/8 : 1), (-3/4 : 7/8 : 1)])
+ 
+     TESTS::
+ 
+@@ -117,7 +117,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+     # The block below mimics the defaults in Simon's scripts, and needs to be changed
+     # when these are updated.
+     if K is QQ:
+-        cmd = 'ellrank(%s, %s);' % (list(E.ainvs()), [P.__pari__() for P in known_points])
++        cmd = 'ellQ_ellrank(%s, %s);' % (list(E.ainvs()), [P.__pari__() for P in known_points])
+         if lim1 is None:
+             lim1 = 5
+         if lim3 is None:
+@@ -144,7 +144,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+     if verbose > 0:
+         print(s)
+     v = gp.eval('ans')
+-    if v=='ans': # then the call to ellrank() or bnfellrank() failed
++    if v=='ans': # then the call to ellQ_ellrank() or bnfellrank() failed
+         raise RuntimeError("An error occurred while running Simon's 2-descent program")
+     if verbose >= 2:
+         print("v = %s" % v)
+diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
+index a936deb74f..dc19254d8c 100644
+--- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
++++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
+@@ -1208,14 +1208,14 @@ def isogenies_13_0(E, minimal_models=True):
+         sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]  # long time (4s)
+         [(0,
+           0,
+-          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
++          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 + 1887439/1146978983704320*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 + 1030632647/7965131831280*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 - 43618899433/204234149520*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 2535050171/1418292705,
+           -139861295/2650795873449984*a^11 - 3455957/5664093746688*a^10 - 345310571/50976843720192*a^9 - 500530795/118001953056*a^8 - 12860048113/265504394376*a^7 - 25007420461/44250732396*a^6 + 458134176455/1416023436672*a^5 + 16701880631/9077073312*a^4 + 155941666417/9077073312*a^3 + 3499310115/378211388*a^2 - 736774863/94552847*a - 21954102381/94552847,
+-          579363345221/13763747804451840*a^11 + 371192377511/860234237778240*a^10 + 8855090365657/1146978983704320*a^9 + 5367261541663/1633873196160*a^8 + 614883554332193/15930263662560*a^7 + 30485197378483/68078049840*a^6 - 131000897588387/2450809794240*a^5 - 203628705777949/306351224280*a^4 - 1587619388190379/204234149520*a^3 + 14435069706551/11346341640*a^2 + 7537273048614/472764235*a + 89198980034806/472764235),
++          8342795944891/198197968384106496*a^11 + 8908625263589/20645621706677760*a^10 + 53130542636623/6881873902225920*a^9 + 376780111042213/114697898370432*a^8 + 614884052146333/15930263662560*a^7 + 3566768133324359/7965131831280*a^6 - 1885593809102545/35291661037056*a^5 - 2443732172026523/3676214691360*a^4 - 9525729503937541/1225404897120*a^3 + 51990274442321/40846829904*a^2 + 67834019370596/4254878115*a + 267603083706812/1418292705),
+          (0,
+           0,
+-          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
++          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 + 1887439/1146978983704320*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 + 1030632647/7965131831280*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 - 43618899433/204234149520*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 2535050171/1418292705,
+           -6465569317/1325397936724992*a^11 - 112132307/1960647835392*a^10 - 17075412917/25488421860096*a^9 - 207832519229/531008788752*a^8 - 1218275067617/265504394376*a^7 - 9513766502551/177002929584*a^6 + 4297077855437/708011718336*a^5 + 354485975837/4538536656*a^4 + 4199379308059/4538536656*a^3 - 30841577919/189105694*a^2 - 181916484042/94552847*a - 2135779171614/94552847,
+-          -132601797212627/3440936951112960*a^11 - 6212467020502021/13763747804451840*a^10 - 1515926454902497/286744745926080*a^9 - 15154913741799637/4901619588480*a^8 - 576888119803859263/15930263662560*a^7 - 86626751639648671/204234149520*a^6 + 16436657569218427/306351224280*a^5 + 1540027900265659087/2450809794240*a^4 + 375782662805915809/51058537380*a^3 - 14831920924677883/11346341640*a^2 - 7237947774817724/472764235*a - 84773764066089509/472764235)]
++          -1316873026840277/34172063514501120*a^11 - 18637401045099413/41291243413355520*a^10 - 36382234917217247/6881873902225920*a^9 - 61142238484016213/19775499719040*a^8 - 576888119306045123/15930263662560*a^7 - 3378443313906256321/7965131831280*a^6 + 326466167429333279/6084769144320*a^5 + 4620083325391594991/7352429382720*a^4 + 9018783894167184149/1225404897120*a^3 - 9206015742300283/7042556880*a^2 - 65141531411426446/4254878115*a - 254321286054666133/1418292705)]
+     """
+     if E.j_invariant()!=0:
+         raise ValueError("j-invariant must be 0.")
diff --git a/srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch b/srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch
new file mode 100644
index 000000000000..762bb2612632
--- /dev/null
+++ b/srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch
@@ -0,0 +1,29 @@
+From f0365f30834b6890313790b3845c647d0160fa6a Mon Sep 17 00:00:00 2001
+From: Vincent Delecroix <20100.delecroix@gmail.com*>
+Date: Fri, 30 Sep 2022 16:31:08 +0200
+Subject: fix doctest if fqf_orthogonal
+
+---
+ src/sage/groups/fqf_orthogonal.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/sage/groups/fqf_orthogonal.py b/src/sage/groups/fqf_orthogonal.py
+index 75de408..7fc4dbe 100644
+--- a/src/sage/groups/fqf_orthogonal.py
++++ b/src/sage/groups/fqf_orthogonal.py
+@@ -245,10 +245,10 @@ class FqfOrthogonalGroup(AbelianGroupAutomorphismGroup_subgroup):
+             sage: all(x*f==x*fbar for x in q.gens())
+             True
+             sage: L = IntegralLattice("A2").twist(3)
+-            sage: q = L.discriminant_group()
+             sage: OL = L.orthogonal_group()
++            sage: assert OL(OL.0.matrix()) == OL.0
++            sage: q = L.discriminant_group()
+             sage: Oq = q.orthogonal_group()
+-            sage: assert Oq(OL.0) == Oq(OL.0.matrix())
+             sage: assert Oq(Oq.0.matrix()) == Oq.0
+         """
+         from sage.libs.gap.element import GapElement
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch b/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
deleted file mode 100644
index 4bd6f4f4e2dc..000000000000
--- a/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
+++ /dev/null
@@ -1,670 +0,0 @@
-As produced by `git diff 9.5 9.6.beta3 -- src/sage/libs/lrcalc`
-
-diff --git a/src/sage/libs/lrcalc/lrcalc.pxd b/src/sage/libs/lrcalc/lrcalc.pxd
-deleted file mode 100644
-index 10b88db93f2..00000000000
---- a/src/sage/libs/lrcalc/lrcalc.pxd
-+++ /dev/null
-@@ -1,77 +0,0 @@
--# distutils: libraries = lrcalc
--
--cdef extern from "lrcalc/hashtab.h":
--    ctypedef struct hashtab:
--        pass
--
--    ctypedef struct hash_itr:
--        pass
--
--    ctypedef unsigned long hashkey_t
--    ctypedef int (*cmp_t) (void* a, void* b)
--    ctypedef hashkey_t (*hash_t) (void* a)
--
--    hashtab* hash_new(cmp_t cm, hash_t hsh)
--    void hash_free(hashtab *ht)
--
--    void* hash_lookup(hashtab *ht, void *key)
--    void* hash_insert(hashtab *ht, void *key, void *value)
--
--    bint hash_good(hash_itr)
--    void hash_first(hashtab* s, hash_itr itr)
--    void hash_next(hash_itr itr)
--    void* hash_key(hash_itr itr)
--    void* hash_value(hash_itr itr)
--    int hash_intvalue(hash_itr itr)
--
--cdef extern from "lrcalc/vector.h":
--    ctypedef struct vector:
--        size_t length
--        int* array
--
--    vector* v_new(int length)
--    void v_free(vector* v)
--    void v_print(vector *v)
--    int v_length(vector* v)
--    int v_elem(vector* v, int i)
--
--    ctypedef struct vecpair:
--        vector *first
--        vector *second
--
--    vector* vp_first(vecpair* vp)
--    vector* vp_second(vecpair* vp)
--
--cdef extern from "lrcalc/list.h":
--    cdef struct _list:
--        void **array
--        size_t allocated
--        size_t length
--    void l_free(_list *lst)
--
--cdef extern from "lrcalc/symfcn.h":
--    long long lrcoef_c "lrcoef"(vector* outer, vector* inner1, vector* inner2)
--    hashtab* mult_c "mult"(vector *sh1, vector *sh2, int maxrows)
--    hashtab* skew_c "skew"(vector *outer, vector *inner, int maxrows)
--    hashtab* coprod_c "coprod"(vector *part, int all)
--    void fusion_reduce_c "fusion_reduce"(hashtab* ht, int rows, int cols, int opt_zero)
--    _list *quantum_reduce_c "quantum_reduce"(hashtab* ht, int rows, int col)
--
--    ctypedef struct skewtab:
--        vector *outer
--        vector *inner
--        vector *conts
--        int maxrows
--        vector *conjugate
--        int rows
--        int cols
--        int matrix[1]
--
--    skewtab *st_new(vector *outer, vector *inner, vector *conts, int maxrows)
--    int st_next(skewtab *st)
--    void st_print(skewtab *st)
--    void st_free(skewtab *st)
--
--
--cdef extern from "lrcalc/schublib.h":
--    hashtab* mult_schubert_c "mult_schubert"(vector *sh1, vector *sh2, int rank)
-diff --git a/src/sage/libs/lrcalc/lrcalc.pyx b/src/sage/libs/lrcalc/lrcalc.py
-similarity index 60%
-rename from src/sage/libs/lrcalc/lrcalc.pyx
-rename to src/sage/libs/lrcalc/lrcalc.py
-index b591081ec4c..b541bfacd89 100644
---- a/src/sage/libs/lrcalc/lrcalc.pyx
-+++ b/src/sage/libs/lrcalc/lrcalc.py
-@@ -10,7 +10,8 @@ fusion products. All of the above are achieved by counting LR
- appropriate shape and content by iterating through them.
- Additionally, ``lrcalc`` handles products of Schubert polynomials.
- 
--The web page of ``lrcalc`` is `<http://sites.math.rutgers.edu/~asbuch/lrcalc/>`_.
-+The web page of ``lrcalc`` is
-+`<http://sites.math.rutgers.edu/~asbuch/lrcalc/>`_.
- 
- The following describes the Sage interface to this library.
- 
-@@ -36,12 +37,13 @@ Schur expansion::
-      [4, 2]: 1}
- 
- Same product, but include only partitions with at most 3 rows.  This
--corresponds to computing in the representation ring of gl(3)::
-+corresponds to computing in the representation ring of `\mathfrak{gl}(3)`::
- 
-     sage: lrcalc.mult([2,1], [2,1], 3)
-     {[2, 2, 2]: 1, [3, 2, 1]: 2, [3, 3]: 1, [4, 1, 1]: 1, [4, 2]: 1}
- 
--We can also compute the fusion product, here for sl(3) and level 2::
-+We can also compute the fusion product, here for `\mathfrak{sl}(3)`
-+and level 2::
- 
-     sage: lrcalc.mult([3,2,1], [3,2,1], 3,2)
-     {[4, 4, 4]: 1, [5, 4, 3]: 1}
-@@ -77,42 +79,38 @@ Multiply two Schubert polynomials::
-      [6, 2, 1, 4, 3, 5]: 1}
- 
- Same product, but include only permutations of 5 elements in the result.
--This corresponds to computing in the cohomology ring of Fl(5)::
-+This corresponds to computing in the cohomology ring of `Fl(5)`::
- 
-     sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3], 5)
-     {[4, 5, 1, 3, 2]: 1, [5, 3, 1, 4, 2]: 1, [5, 4, 1, 2, 3]: 1}
- 
- List all Littlewood-Richardson tableaux of skew shape `\mu/\nu`; in
- this example `\mu=[3,2,1]` and `\nu=[2,1]`. Specifying a third entry
--`maxrows` restricts the alphabet to `\{1,2,\ldots,maxrows\}`::
-+`M' = ``maxrows`` restricts the alphabet to `\{1,2,\ldots,M\}`::
- 
-     sage: list(lrcalc.lrskew([3,2,1],[2,1]))
-     [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
-     [[None, None, 1], [None, 2], [1]], [[None, None, 1], [None, 2], [3]]]
- 
-     sage: list(lrcalc.lrskew([3,2,1],[2,1],maxrows=2))
--    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]], [[None, None, 1], [None, 2], [1]]]
-+    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
-+     [[None, None, 1], [None, 2], [1]]]
- 
- .. TODO::
- 
--    use this library in the :class:`SymmetricFunctions` code, to
-+    Use this library in the :class:`SymmetricFunctions` code, to
-     make it easy to apply it to linear combinations of Schur functions.
- 
- .. SEEALSO::
- 
-     - :func:`lrcoef`
--
-     - :func:`mult`
--
-     - :func:`coprod`
--
-     - :func:`skew`
--
-     - :func:`lrskew`
--
-     - :func:`mult_schubert`
- 
--.. rubric:: Underlying algorithmic in lrcalc
-+.. RUBRIC:: Underlying algorithmic in lrcalc
- 
- Here is some additional information regarding the main low-level
- C-functions in `lrcalc`. Given two partitions ``outer`` and ``inner``
-@@ -187,180 +185,24 @@ AUTHORS:
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from sage.rings.integer cimport Integer
--from sage.structure.parent cimport Parent
- from sage.combinat.partition import _Partitions
- from sage.combinat.permutation import Permutation
--from sage.combinat.skew_tableau import SkewTableau
--
--
--cdef vector* iterable_to_vector(it):
--    """
--    Return an lrcalc vector (which is a list of integers) from a Python iterable.
--
--    TESTS::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector(Partition([3,2,1])); x   #indirect doctest
--        [3, 2, 1]
--    """
--    cdef vector* v
--    cdef list itr = list(it)
--    cdef int n = len(itr)
--    cdef int i
--    v = v_new(n)
--    for i in range(n):
--        v.array[i] = int(itr[i])
--    return v
--
--
--cdef list vector_to_list(vector *v):
--    """
--    Converts a lrcalc vector to Python list.
--
--    TESTS::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector([]); x         #indirect doctest
--        []
--    """
--    cdef int i, n
--    n = v_length(v)
--    cdef list result = [None]*n
--    for i in range(n):
--        result[i] = Integer(v_elem(v, i))
--    return result
--
--
--def test_iterable_to_vector(it):
--    """
--    A wrapper function for the cdef function ``iterable_to_vector``
--    and ``vector_to_list``, to test that they are working correctly.
-+from sage.combinat.skew_tableau import SemistandardSkewTableaux
-+from sage.combinat.skew_partition import SkewPartition
-+from sage.rings.integer import Integer
-+import lrcalc
- 
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector([3,2,1]); x
--        [3, 2, 1]
--    """
--    cdef vector *v = iterable_to_vector(it)
--    result = vector_to_list(v)
--    v_free(v)
--    return result
--
--
--cdef skewtab_to_SkewTableau(skewtab *st):
--    """
--    A wrapper function which transforms the data set ``st`` used in
--    ``lrcalc`` to a ``SkewTableau`` in Sage.
-+def _lrcalc_dict_to_sage(result):
-+    r"""
-+    Translate from lrcalc output format to Sage expected format.
- 
-     TESTS::
- 
--        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
--        sage: test_skewtab_to_SkewTableau([],[])
--        []
--    """
--    inner = vector_to_list(st.inner)
--    outer = vector_to_list(st.outer)
--    return SkewTableau(expr=[[inner[y] for y in range(len(outer))],
--                             [[st.matrix[x + y * st.cols] + 1
--                                for x in range(inner[y], outer[y])]
--                              for y in range(len(outer) - 1, -1, -1)]])
--
--
--def test_skewtab_to_SkewTableau(outer, inner):
--    """
--    A wrapper function for the cdef function ``skewtab_to_SkewTableau``
--    for testing purposes.
--
--    It constructs the first LR skew tableau of shape ``outer/inner``
--    as an ``lrcalc`` ``skewtab``, and converts it to a
--    :class:`SkewTableau`.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
--        sage: test_skewtab_to_SkewTableau([3,2,1],[])
--        [[1, 1, 1], [2, 2], [3]]
--        sage: test_skewtab_to_SkewTableau([4,3,2,1],[1,1]).pp()
--        .  1  1  1
--        .  2  2
--        1  3
--        2
--    """
--    cdef vector* o = iterable_to_vector(outer)
--    cdef vector* i = iterable_to_vector(inner+[0]*(len(outer)-len(inner)))
--    cdef skewtab* st = st_new(o, i, NULL, 0)
--    return skewtab_to_SkewTableau(st)
--
--
--cdef dict sf_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary representing a Schur function. The keys are
--    partitions and the values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
-         sage: from sage.libs.lrcalc.lrcalc import mult
--        sage: sorted(mult([1],[1]).items())        #indirect doctest
--        [([1, 1], 1), ([2], 1)]
--        sage: assert isinstance(mult([1],[1]),dict)#indirect doctest
--    """
--    cdef hash_itr itr
--    cdef dict result = {}
--    cdef list p
--    hash_first(ht, itr)
--    while hash_good(itr):
--        p = vector_to_list(<vector*> hash_key(itr))
--        result[_Partitions(p)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
--
--cdef dict schubert_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary corresponding to a Schubert polynomial whose keys
--    are permutations and whose values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import mult_schubert
--        sage: mult_schubert([3,2,1], [1,2,3])      #indirect doctest
--        {[3, 2, 1]: 1}
--    """
--    cdef hash_itr itr
--    cdef dict result = {}
--    hash_first(ht, itr)
--    while hash_good(itr):
--        p = vector_to_list(<vector*> hash_key(itr))
--        result[Permutation(p)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
--
--cdef dict vp_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary corresponding to the coproduct of a Schur function whose keys are
--    pairs of partitions and whose values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import coprod
--        sage: coprod([1])      #indirect doctest
--        {([1], []): 1}
-+        sage: mult([2,1],[3,2,1],3) # indirect doctest
-+        {[3, 3, 3]: 1, [4, 3, 2]: 2, [4, 4, 1]: 1, [5, 2, 2]: 1, [5, 3, 1]: 1}
-     """
--    cdef hash_itr itr
--    cdef vecpair* vp
--    cdef dict result = {}
--    hash_first(ht, itr)
--    while hash_good(itr):
--        vp = <vecpair*> hash_key(itr)
--        p1 = _Partitions(vector_to_list(vp_first(vp)))
--        p2 = _Partitions(vector_to_list(vp_second(vp)))
--        result[(p1, p2)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
-+    return {_Partitions(la): Integer(k) for la, k in result.items()}
- 
- def lrcoef_unsafe(outer, inner1, inner2):
-     r"""
-@@ -371,13 +213,11 @@ def lrcoef_unsafe(outer, inner1, inner2):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
--
--    - ``inner1`` -- a partition.
-+    - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
-+    - ``inner1`` -- a partition
-+    - ``inner2`` -- a partition
- 
--    - ``inner2`` -- a partition.
--
--    .. warning::
-+    .. WARNING::
- 
-        This function does not do any check on its input.  If you want
-        to use a safer version, use :func:`lrcoef`.
-@@ -392,18 +232,7 @@ def lrcoef_unsafe(outer, inner1, inner2):
-         sage: lrcoef_unsafe([2,1,1,1,1], [2,1], [2,1])
-         0
-     """
--    cdef long long result
--    cdef vector *o
--    cdef vector *i1
--    cdef vector *i2
--    o = iterable_to_vector(outer)
--    i1 = iterable_to_vector(inner1)
--    i2 = iterable_to_vector(inner2)
--    result = lrcoef_c(o, i1, i2)
--    v_free(o)
--    v_free(i1)
--    v_free(i2)
--    return Integer(result)
-+    return Integer(lrcalc.lrcoef(outer, inner1, inner2))
- 
- 
- def lrcoef(outer, inner1, inner2):
-@@ -415,11 +244,9 @@ def lrcoef(outer, inner1, inner2):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
--
--    - ``inner1`` -- a partition.
--
--    - ``inner2`` -- a partition.
-+    - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
-+    - ``inner1`` -- a partition
-+    - ``inner2`` -- a partition
- 
-     .. NOTE::
- 
-@@ -436,7 +263,6 @@ def lrcoef(outer, inner1, inner2):
-         1
-         sage: lrcoef([2,1,1,1,1], [2,1], [2,1])
-         0
--
-     """
-     return lrcoef_unsafe(_Partitions(outer), _Partitions(inner1), _Partitions(inner2))
- 
-@@ -451,13 +277,9 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-     INPUT:
- 
-     - ``part1`` -- a partition
--
-     - ``part2`` -- a partition
--
-     - ``maxrows`` -- (optional) an integer
--
-     - ``level`` -- (optional) an integer
--
-     - ``quantum`` -- (optional) an element of a ring
- 
-     If ``maxrows`` is specified, then only partitions with at most
-@@ -479,7 +301,8 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-         sage: sorted(mult([2],[2]).items())
-         [([2, 2], 1), ([3, 1], 1), ([4], 1)]
-         sage: sorted(mult([2,1],[2,1]).items())
--        [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1), ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
-+        [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1),
-+         ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
-         sage: sorted(mult([2,1],[2,1],maxrows=2).items())
-         [([3, 3], 1), ([4, 2], 1)]
-         sage: mult([2,1],[3,2,1],3)
-@@ -510,44 +333,24 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-     if quantum is not None and (level is None or maxrows is None):
-         raise ValueError('missing parameters maxrows or level')
- 
--    cdef vector* v1 = iterable_to_vector(part1)
--    cdef vector* v2 = iterable_to_vector(part2)
--    if maxrows is None:
--        maxrows = 0
--    cdef hashtab* ht = mult_c(v1, v2, int(maxrows))
--    cdef hashtab* tab
--    cdef dict result
--
-     if quantum is None:
-         if level is not None:
--            fusion_reduce_c(ht, int(maxrows), int(level), int(0))
--        result = sf_hashtab_to_dict(ht)
--        v_free(v1)
--        v_free(v2)
--        hash_free(ht)
--        return result
-+            return _lrcalc_dict_to_sage(lrcalc.mult_fusion(part1, part2, maxrows, level))
-+        if maxrows is None:
-+            maxrows = -1
-+        return _lrcalc_dict_to_sage(lrcalc.mult(part1, part2, maxrows))
- 
-     # Otherwise do quantum multiplication
--    cdef _list *qlist
--    cdef dict temp
--    qlist = quantum_reduce_c(ht, int(maxrows), int(level))
--    # The above call frees the memory associated with ht
--    v_free(v1)
--    v_free(v2)
--
--    cdef Parent P = quantum.parent()
--    result = {}
--    for i in range(qlist.length):
--        tab = <hashtab*>(qlist.array[i])
--        temp = sf_hashtab_to_dict(tab)
--        for k in temp:
--            result[k] = result.get(k, P.zero()) + quantum**i * temp[k]
--        hash_free(tab)
--    l_free(qlist)
--    return result
--
--
--def skew(outer, inner, maxrows=0):
-+    result = lrcalc.mult_quantum(part1, part2, maxrows, level, degrees=True)
-+    P = quantum.parent()
-+    output = {}
-+    for i,k in result.items():
-+        la = _Partitions(i[0])
-+        output[la] = output.get(la, P.zero()) + k * quantum**(i[1])
-+    return output
-+
-+
-+def skew(outer, inner, maxrows=-1):
-     """
-     Compute the Schur expansion of a skew Schur function.
- 
-@@ -557,11 +360,9 @@ def skew(outer, inner, maxrows=0):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition.
--
--    - ``inner`` -- a partition.
--
--    - ``maxrows`` -- an integer or ``None``.
-+    - ``outer`` -- a partition
-+    - ``inner`` -- a partition
-+    - ``maxrows`` -- an integer or ``None``
- 
-     If ``maxrows`` is specified, then only partitions with at most
-     this number of rows are included in the result.
-@@ -572,14 +373,7 @@ def skew(outer, inner, maxrows=0):
-         sage: sorted(skew([2,1],[1]).items())
-         [([1, 1], 1), ([2], 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(outer)
--    cdef vector* v2 = iterable_to_vector(inner)
--    cdef hashtab* ht = skew_c(v1, v2, int(maxrows))
--    result = sf_hashtab_to_dict(ht)
--    v_free(v1)
--    v_free(v2)
--    hash_free(ht)
--    return result
-+    return _lrcalc_dict_to_sage(lrcalc.skew(outer, inner, maxrows))
- 
- 
- def coprod(part, all=0):
-@@ -592,9 +386,8 @@ def coprod(part, all=0):
- 
-     INPUT:
- 
--    - ``part`` -- a partition.
--
--    - ``all`` -- an integer.
-+    - ``part`` -- a partition
-+    - ``all`` -- an integer
- 
-     If ``all`` is non-zero then all terms are included in the result.
-     If ``all`` is zero, then only pairs of partitions ``(part1,
-@@ -609,12 +402,9 @@ def coprod(part, all=0):
-         sage: sorted(coprod([2,1]).items())
-         [(([1, 1], [1]), 1), (([2], [1]), 1), (([2, 1], []), 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(part)
--    cdef hashtab* ht = coprod_c(v1, int(all))
--    result = vp_hashtab_to_dict(ht)
--    v_free(v1)
--    hash_free(ht)
--    return result
-+    result = lrcalc.coprod(part, all)
-+    return {tuple([_Partitions(mu) for mu in la]): Integer(k)
-+            for la, k in result.items()}
- 
- 
- def mult_schubert(w1, w2, rank=0):
-@@ -627,11 +417,9 @@ def mult_schubert(w1, w2, rank=0):
- 
-     INPUT:
- 
--    - ``w1`` -- a permutation.
--
--    - ``w2`` -- a permutation.
--
--    - ``rank`` -- an integer.
-+    - ``w1`` -- a permutation
-+    - ``w2`` -- a permutation
-+    - ``rank`` -- an integer
- 
-     If ``rank`` is non-zero, then only permutations from the symmetric
-     group `S(\mathrm{rank})` are included in the result.
-@@ -646,33 +434,24 @@ def mult_schubert(w1, w2, rank=0):
-          ([6, 4, 3, 1, 2, 5], 1), ([6, 5, 2, 1, 3, 4], 1),
-          ([7, 3, 4, 1, 2, 5, 6], 1), ([7, 4, 2, 1, 3, 5, 6], 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(w1)
--    cdef vector* v2 = iterable_to_vector(w2)
--    cdef hashtab* ht = mult_schubert_c(v1, v2, int(rank))
--    result = schubert_hashtab_to_dict(ht)
--    v_free(v1)
--    v_free(v2)
--    hash_free(ht)
--    return result
-+    result = lrcalc.schubmult(w1, w2, rank)
-+    return {Permutation(list(la)):Integer(k) for la,k in result.items()}
- 
- 
--def lrskew(outer, inner, weight=None, maxrows=0):
-+def lrskew(outer, inner, weight=None, maxrows=-1):
-     r"""
-     Iterate over the skew LR tableaux of shape ``outer / inner``.
- 
-     INPUT:
- 
-     - ``outer`` -- a partition
--
-     - ``inner`` -- a partition
--
-     - ``weight`` -- a partition (optional)
--
--    - ``maxrows`` -- an integer (optional)
-+    - ``maxrows`` -- a positive integer (optional)
- 
-     OUTPUT: an iterator of :class:`SkewTableau`
- 
--    Specifying ``maxrows`` restricts the alphabet to `\{1,2,\ldots,maxrows\}`.
-+    Specifying ``maxrows`` = `M` restricts the alphabet to `\{1,2,\ldots,M\}`.
- 
-     Specifying ``weight`` returns only those tableaux of given content/weight.
- 
-@@ -702,22 +481,40 @@ def lrskew(outer, inner, weight=None, maxrows=0):
- 
-         sage: list(lrskew([3,2,1],[2], weight=[3,1]))
-         [[[None, None, 1], [1, 1], [2]]]
-+
-+    TESTS::
-+
-+        sage: from sage.libs.lrcalc.lrcalc import lrskew
-+        sage: list(lrskew([3,2,1],[2], weight=[]))
-+        []
-+        sage: list(lrskew([3,2,1],[2], weight=[0]))
-+        []
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[]))
-+        [[[None, None, None], [None, None], [None]]]
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[0]))
-+        [[[None, None, None], [None, None], [None]]]
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[1]))
-+        []
-     """
--    cdef vector* o = iterable_to_vector(outer)
--    cdef vector* i = iterable_to_vector(inner + [0]*(len(outer) - len(inner)))
--    cdef skewtab* st = st_new(o, i, NULL, int(maxrows))
-+    iterator = lrcalc.lr_iterator(outer, inner, maxrows)
-+    shape = SkewPartition([outer, inner])
- 
-     if weight is None:
--        yield skewtab_to_SkewTableau(st)
--        while st_next(st):
--            yield skewtab_to_SkewTableau(st)
-+        ST = SemistandardSkewTableaux(shape)
-+        for data in iterator:
-+            yield ST.from_shape_and_word(shape, [i+1 for i in data])
-     else:
-         wt = _Partitions(weight)
--        r = skewtab_to_SkewTableau(st)
--        if r.weight() == wt:
--            yield r
--        while st_next(st):
--            r = skewtab_to_SkewTableau(st)
--            if r.weight() == wt:
--                yield r
--    st_free(st)
-+        ST = SemistandardSkewTableaux(shape, wt)
-+        m = len(wt)
-+        for data in iterator:
-+            w = [0] * m
-+            for j in data:
-+                if j >= m:
-+                    # We know they are not equal, so make the check below quick
-+                    w = None
-+                    break
-+                w[j] += 1
-+            if w == wt:
-+                yield ST.from_shape_and_word(shape, [i+1 for i in data])
-+
diff --git a/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch b/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
deleted file mode 100644
index 1e2e0ba90742..000000000000
--- a/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-As produced by `git diff a90a3146{^^,}`
-
-diff --git a/src/sage/repl/interface_magic.py b/src/sage/repl/interface_magic.py
-index 8a455b69b0e..a93e1c9e04c 100644
---- a/src/sage/repl/interface_magic.py
-+++ b/src/sage/repl/interface_magic.py
-@@ -260,7 +260,7 @@ class InterfaceMagic(object):
-             2
-             120
-             sage: shell.run_cell('%%gap foo\n1+1;\n')
--            ...File "<string>", line unknown
-+            ...File...<string>...
-             SyntaxError: Interface magics have no options, got "foo"
-             <BLANKLINE>
-             sage: shell.run_cell('%%gap?')
-diff --git a/src/sage/repl/interpreter.py b/src/sage/repl/interpreter.py
-index 7468afe52d7..06c47b7374a 100644
---- a/src/sage/repl/interpreter.py
-+++ b/src/sage/repl/interpreter.py
-@@ -78,9 +78,9 @@ Check that Cython source code appears in tracebacks::
-     dummy line
-     ...
-     ZeroDivisionError...Traceback (most recent call last)
--    <ipython-input-...> in <module>...
-+    ...in <module>...
-     ----> 1 Integer(1)/Integer(0)
--    .../sage/rings/integer.pyx in sage.rings.integer.Integer...div...
-+    .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
-     ...
-     -> ...                  raise ZeroDivisionError("rational division by zero")
-        ....:            x = <Rational> Rational.__new__(Rational)
-@@ -423,7 +423,7 @@ def SagePreparseTransformer(lines):
-         sage: from sage.repl.interpreter import get_test_shell
-         sage: shell = get_test_shell()
-         sage: shell.run_cell(bad_syntax)
--          File "<string>", line unknown
-+          File...<string>...
-         SyntaxError: Mismatched ']'
-         <BLANKLINE>
-         sage: shell.quit()
diff --git a/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch b/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
deleted file mode 100644
index 853813b0f5bd..000000000000
--- a/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Fix for ipython 8.1
-
---- a/src/sage/repl/interpreter.py
-+++ b/src/sage/repl/interpreter.py
-@@ -78,7 +78,7 @@ Check that Cython source code appears in tracebacks::
-     dummy line
-     ...
-     ZeroDivisionError...Traceback (most recent call last)
--    ...in <module>...
-+    ...
-     ----> 1 Integer(1)/Integer(0)
-     .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
-     ...
diff --git a/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch b/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
deleted file mode 100644
index b861af7ec982..000000000000
--- a/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
+++ /dev/null
@@ -1,126 +0,0 @@
-From 24cc94b1988a90f3bd22a2368ec30c086283af13 Mon Sep 17 00:00:00 2001
-From: Antonio Rojas <arojas@archlinux.org>
-Date: Sun, 16 Jan 2022 11:55:04 +0100
-Subject: Add abs tol to some arb tests
-
----
- src/sage/functions/error.py    |  2 +-
- src/sage/rings/complex_arb.pyx |  6 +++---
- src/sage/rings/real_arb.pyx    | 10 +++++-----
- 3 files changed, 9 insertions(+), 9 deletions(-)
-
-diff --git a/src/sage/functions/error.py b/src/sage/functions/error.py
-index f48d04f..06f0b24 100644
---- a/src/sage/functions/error.py
-+++ b/src/sage/functions/error.py
-@@ -267,7 +267,7 @@ class Function_erf(BuiltinFunction):
- 
-         Check that real ball evaluation is fixed :trac:`28061`::
- 
--            sage: RealBallField(128)(erf(5))
-+            sage: RealBallField(128)(erf(5)) # abs tol 1e-38
-             [0.99999999999846254020557196514981165651 +/- 7.33e-39]
-         """
-         R = parent or s_parent(x)
-diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
-index f986970..93ff565 100644
---- a/src/sage/rings/complex_arb.pyx
-+++ b/src/sage/rings/complex_arb.pyx
-@@ -3974,8 +3974,8 @@ cdef class ComplexBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: CBF(20).erfc()
--            [5.39586561160790e-176 +/- ...e-191]
-+            sage: CBF(20).erfc() # abs tol 1e-190
-+            [5.39586561160790e-176 +/- 6.73e-191]
-             sage: CBF(100, 100).erfc()
-             [0.00065234366376858 +/- ...e-18] + [-0.00393572636292141 +/- ...e-18]*I
-         """
-@@ -4280,7 +4280,7 @@ cdef class ComplexBall(RingElement):
- 
-         TESTS:
- 
--            sage: CBF(Shi(I))
-+            sage: CBF(Shi(I)) # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]*I
-         """
-         cdef ComplexBall result = self._new()
-diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
-index 4a81784..292bfea 100644
---- a/src/sage/rings/real_arb.pyx
-+++ b/src/sage/rings/real_arb.pyx
-@@ -3506,7 +3506,7 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1/2).erf()
-+            sage: RBF(1/2).erf() # abs tol 1e-16
-             [0.520499877813047 +/- 6.10e-16]
-         """
-         cdef RealBall res = self._new()
-@@ -3556,12 +3556,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Si()
-+            sage: RBF(1).Si() # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]
- 
-         TESTS::
- 
--            sage: RBF(Si(1))
-+            sage: RBF(Si(1)) # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]
-         """
-         cdef RealBall res = self._new()
-@@ -3578,12 +3578,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Ci()  # abs tol 1e-16
-+            sage: RBF(1).Ci()  # abs tol 1e-15
-             [0.337403922900968 +/- 3.25e-16]
- 
-         TESTS::
- 
--            sage: RBF(Ci(1))  # abs tol 1e-16
-+            sage: RBF(Ci(1))  # abs tol 1e-15
-             [0.337403922900968 +/- 3.25e-16]
-         """
-         cdef RealBall res = self._new()
--- 
-cgit v1.0-1-gd88e
-
-
-From 53532ddd4e2dc92469c1590ebf0c40f8f69bf579 Mon Sep 17 00:00:00 2001
-From: Antonio Rojas <arojas@archlinux.org>
-Date: Sun, 16 Jan 2022 14:16:53 +0100
-Subject: Decrease abs tol
-
----
- src/sage/rings/real_arb.pyx | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
-index 292bfea..eb30f7f 100644
---- a/src/sage/rings/real_arb.pyx
-+++ b/src/sage/rings/real_arb.pyx
-@@ -3578,12 +3578,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Ci()  # abs tol 1e-15
-+            sage: RBF(1).Ci()  # abs tol 5e-16
-             [0.337403922900968 +/- 3.25e-16]
- 
-         TESTS::
- 
--            sage: RBF(Ci(1))  # abs tol 1e-15
-+            sage: RBF(Ci(1))  # abs tol 5e-16
-             [0.337403922900968 +/- 3.25e-16]
-         """
-         cdef RealBall res = self._new()
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch b/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
deleted file mode 100644
index d4e8f8be60e3..000000000000
--- a/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From 33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c Mon Sep 17 00:00:00 2001
-From: Michael Orlitzky <michael@orlitzky.com>
-Date: Mon, 24 Jan 2022 09:03:29 -0500
-Subject: Trac #33226: update doctests for giac-1.7.0.45.
-
-We have two failing doctests with giac-1.7.0.45: one is a trivial
-tolerance issue, but the other is a symbolic integration result for
-which giac is no longer willing to return a symbolic answer. We add
-"abs tol" to the numeric test, and drop the symbolic one entirely.
----
- src/sage/functions/min_max.py | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/src/sage/functions/min_max.py b/src/sage/functions/min_max.py
-index fc18373..9b7d6d9 100644
---- a/src/sage/functions/min_max.py
-+++ b/src/sage/functions/min_max.py
-@@ -228,15 +228,15 @@ class MaxSymbolic(MinMax_base):
-             ...
-             TypeError: cannot evaluate symbolic expression numerically
- 
--        ::
-+        We can usually integrate these expressions, but can't
-+        guarantee a symbolic answer in closed form::
- 
-             sage: f = max_symbolic(sin(x), cos(x))
-             sage: r = integral(f, x, 0, 1)
-             ...
--            sage: r
--            sqrt(2) - cos(1)
--            sage: r.n()
-+            sage: r.n()  # abs tol 1e-8
-             0.873911256504955
-+
-         """
-         return max_symbolic(args)
- 
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch b/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
deleted file mode 100644
index 19b69700a4f6..000000000000
--- a/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-commit 9c8235e44ffb509efa8a3ca6cdb55154e2b5066d
-Author: Antonio Rojas <arojas@archlinux.org>
-Date:   Sun Feb 13 19:53:14 2022 +0100
-
-    Fix deprecation warning with scipy 1.8
-
-diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-index e9b60dae5ec..7932167b41d 100644
---- a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-@@ -356,7 +356,7 @@ Sage example in ./linsolve.tex, line 2230::
- 
- Sage example in ./linsolve.tex, line 2609::
- 
--  sage: from scipy.sparse.linalg.dsolve import *
-+  sage: from scipy.sparse.linalg import factorized
-   sage: from scipy.sparse import lil_matrix
-   sage: from numpy import array
-   sage: n = 200
diff --git a/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch b/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
new file mode 100644
index 000000000000..e052e306e7a1
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
@@ -0,0 +1,53 @@
+From 6330cee1a69229b2f5d8ac4a09a73d8152f5e14d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Mon, 28 Feb 2022 23:15:16 -0300
+Subject: trac 33360: avoid factoring in is_prime()
+
+In the added TEST, the ideal norm is product of two primes but factoring
+this product takes about half an hour, so factoring the ideal is slow.
+
+To fix the issue, we only factor the ideal if the norm is a prime power.
+---
+ src/sage/rings/number_field/number_field_ideal.py | 22 ++++++++++++++++++++++
+ 1 file changed, 22 insertions(+)
+
+diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
+index f785f22..10d1f88 100644
+--- a/src/sage/rings/number_field/number_field_ideal.py
++++ b/src/sage/rings/number_field/number_field_ideal.py
+@@ -995,10 +995,32 @@ class NumberFieldIdeal(Ideal_generic):
+             False
+             sage: K.ideal(17).is_prime()  # ramified
+             False
++
++        TESTS::
++
++        Check that we do not factor the norm of the ideal, this used
++        to take half an hour, see :trac:`33360`
++
++           sage: K.<a,b,c> = NumberField([x^2-2,x^2-3,x^2-5])
++           sage: t = (((-2611940*c + 1925290/7653)*b - 1537130/7653*c
++           ....:       + 10130950)*a + (1343014/7653*c - 8349770)*b
++           ....:       + 6477058*c - 2801449990/4002519)
++           sage: t.is_prime()
++           False
++
+         """
+         try:
+             return self._pari_prime is not None
+         except AttributeError:
++            K = self.number_field().pari_nf()
++            I = self.pari_hnf()
++            # This would be better, but it is broken in pari 2.13.3.
++            #   self._pari_prime = K.idealismaximal(I) or None
++            # Instead we factor I, but only if the norm is a prime power
++            n = K.idealnorm(I)
++            if n.denominator() > 1 or not n.isprimepower():
++                self._pari_prime = None
++                return False
+             F = self.factor()  # factorization with caching
+             if len(F) != 1 or F[0][1] != 1:
+                 self._pari_prime = None
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
deleted file mode 100644
index 9ba7ca5a6b7d..000000000000
--- a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
+++ /dev/null
@@ -1,99 +0,0 @@
-From 609dd9deaeaa6380ab2f0d50276d911233c00a04 Mon Sep 17 00:00:00 2001
-From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
-Date: Fri, 4 Mar 2022 16:07:09 -0800
-Subject: sage.manifolds: Update doctests for SymPy 1.10
-
----
- src/sage/manifolds/continuous_map.py              | 3 +--
- src/sage/manifolds/differentiable/diff_form.py    | 4 ++--
- src/sage/manifolds/differentiable/tensorfield.py  | 8 ++++----
- src/sage/manifolds/vector_bundle_fiber_element.py | 2 +-
- 4 files changed, 8 insertions(+), 9 deletions(-)
-
-diff --git a/src/sage/manifolds/continuous_map.py b/src/sage/manifolds/continuous_map.py
-index a6356e7..f6f9b6d 100644
---- a/src/sage/manifolds/continuous_map.py
-+++ b/src/sage/manifolds/continuous_map.py
-@@ -1357,8 +1357,7 @@ class ContinuousMap(Morphism):
-             sage: Phi.coord_functions(c_uv, c_xyz)
-             Coordinate functions (u*v, u/v, u + v) on the Chart (M, (u, v))
-             sage: Phi.coord_functions(c_UV, c_xyz)
--            Coordinate functions (-U**2/4 + V**2/4, -(U + V)/(U - V), V)
--             on the Chart (M, (U, V))
-+            Coordinate functions (-U**2/4 + V**2/4, (-U - V)/(U - V), V) on the Chart (M, (U, V))
-             sage: Phi.coord_functions(c_UV, c_XYZ)
-             Coordinate functions ((-U**3 + U**2*V + U*V**2 + 2*U*V + 6*U - V**3
-              - 2*V**2 + 6*V)/(2*(U - V)), (U**3/4 - U**2*V/4 - U*V**2/4 + U*V
-diff --git a/src/sage/manifolds/differentiable/diff_form.py b/src/sage/manifolds/differentiable/diff_form.py
-index 70dd8fb..0aa3469 100644
---- a/src/sage/manifolds/differentiable/diff_form.py
-+++ b/src/sage/manifolds/differentiable/diff_form.py
-@@ -266,7 +266,7 @@ class DiffForm(TensorField):
- 
-         sage: s = a.wedge(b)
-         sage: s.display(eU)
--        a∧b = -x*(2*x*y + 1) dx∧dy
-+        a∧b = x*(-2*x*y - 1) dx∧dy
-         sage: s.display(eV)
-         a∧b = (u**3/8 + u**2*v/8 - u*v**2/8 + u/4 - v**3/8 + v/4) du∧dv
- 
-@@ -275,7 +275,7 @@ class DiffForm(TensorField):
-         sage: f = M.scalar_field({c_xy: (x+y)^2, c_uv: u^2}, name='f')
-         sage: s = f*a
-         sage: s.display(eU)
--        f*a = -y*(x**2 + 2*x*y + y**2) dx + x*(x**2 + 2*x*y + y**2) dy
-+        f*a = y*(-x**2 - 2*x*y - y**2) dx + x*(x**2 + 2*x*y + y**2) dy
-         sage: s.display(eV)
-         f*a = u**2*v/2 du - u**3/2 dv
- 
-diff --git a/src/sage/manifolds/differentiable/tensorfield.py b/src/sage/manifolds/differentiable/tensorfield.py
-index 2775be9..6bc5c50 100644
---- a/src/sage/manifolds/differentiable/tensorfield.py
-+++ b/src/sage/manifolds/differentiable/tensorfield.py
-@@ -334,7 +334,7 @@ class TensorField(ModuleElementWithMutability):
-         sage: f.display()  # long time
-         t(a,b): S^2 → ℝ
-         on U: (x, y) ↦ -2*x*y - 3*x - y**2
--        on V: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+        on V: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
- 
-     The vectors can be defined only on subsets of `S^2`, the domain of the
-     result is then the common subset::
-@@ -343,12 +343,12 @@ class TensorField(ModuleElementWithMutability):
-         sage: s.display()  # long time
-         t(a,b): U → ℝ
-            (x, y) ↦ -2*x*y - 3*x - y**2
--        on W: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+        on W: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
-         sage: s = t(a.restrict(U), b.restrict(W))  # long time
-         sage: s.display()  # long time
-         t(a,b): W → ℝ
-            (x, y) ↦ -2*x*y - 3*x - y**2
--           (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+           (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
- 
-     The tensor itself can be defined only on some open subset of `S^2`,
-     yielding a result whose domain is this subset::
-@@ -356,7 +356,7 @@ class TensorField(ModuleElementWithMutability):
-         sage: s = t.restrict(V)(a,b)  # long time
-         sage: s.display()  # long time
-         t(a,b): V → ℝ
--           (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+           (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
-         on W: (x, y) ↦ -2*x*y - 3*x - y**2
- 
-     Tests regarding the multiplication by a scalar field::
-diff --git a/src/sage/manifolds/vector_bundle_fiber_element.py b/src/sage/manifolds/vector_bundle_fiber_element.py
-index 29ee81d..048275a 100644
---- a/src/sage/manifolds/vector_bundle_fiber_element.py
-+++ b/src/sage/manifolds/vector_bundle_fiber_element.py
-@@ -110,4 +110,4 @@ class VectorBundleFiberElement(FiniteRankFreeModuleElement):
-             desc += str(self._name) + " "
-         desc += "in the fiber of {} at {}".format(self._vbundle._name,
-                                                   self._point)
--        return desc
-\ No newline at end of file
-+        return desc
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
deleted file mode 100644
index f5ac180baa90..000000000000
--- a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From c49eff347454ac7f07e5918470b20e97b8f2357e Mon Sep 17 00:00:00 2001
-From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
-Date: Fri, 4 Mar 2022 15:14:43 -0800
-Subject: src/sage/calculus/calculus.py: Update laplace doctest for sympy 1.10
-
----
- src/sage/calculus/calculus.py | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/src/sage/calculus/calculus.py b/src/sage/calculus/calculus.py
-index 9c2f226..b335093 100644
---- a/src/sage/calculus/calculus.py
-+++ b/src/sage/calculus/calculus.py
-@@ -1639,9 +1639,9 @@ def laplace(ex, t, s, algorithm='maxima'):
-         sage: laplace(dirac_delta(t), t, s)
-         1
-         sage: F, a, cond = laplace(dirac_delta(t), t, s, algorithm='sympy')
--        sage: a, cond
--        (-oo, True)
--        sage: F       # random - sympy <1.9 includes undefined heaviside(0) in answer
-+        sage: a, cond  # random - sympy <1.10 gives (-oo, True)
-+        (0, True)
-+        sage: F        # random - sympy <1.9 includes undefined heaviside(0) in answer
-         1
-         sage: laplace(dirac_delta(t), t, s, algorithm='giac')
-         1
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch b/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
deleted file mode 100644
index 8e7bb64f5b01..000000000000
--- a/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From a04a0a0b14f67f4804e7113c3db41bbcf8a58296 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
-Date: Mon, 28 Mar 2022 20:39:59 -0300
-Subject: Trac #33585: fix doctest when dochtml is missing...
-
-...but sphinx is available in PYTHONPATH.
----
- src/sage/misc/sagedoc.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/sage/misc/sagedoc.py b/src/sage/misc/sagedoc.py
-index 4b3853f..08c4225 100644
---- a/src/sage/misc/sagedoc.py
-+++ b/src/sage/misc/sagedoc.py
-@@ -1401,7 +1401,7 @@ class _sage_doc:
-             "...**File:**...**Type:**...**Definition:** identity_matrix..."
-             sage: identity_matrix.__doc__ in browse_sage_doc(identity_matrix, 'rst')
-             True
--            sage: browse_sage_doc(identity_matrix, 'html', False)             # optional - sphinx
-+            sage: browse_sage_doc(identity_matrix, 'html', False)             # optional - sphinx sagemath_doc_html
-             '...div...File:...Type:...Definition:...identity_matrix...'
- 
-         In the 'text' version, double colons have been replaced with
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch b/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
new file mode 100644
index 000000000000..977a42400e59
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
@@ -0,0 +1,42 @@
+commit 5db5d4e56243c609f44afc1f21c112b026f9e1fe
+Author: Oscar Benjamin <oscar.j.benjamin@gmail.com>
+Date:   Mon Jul 11 21:24:01 2022 +0100
+
+    Update doctests for SymPy 1.11
+    
+    Doctests related to SymPy's rsolve function are updated in:
+    
+    src/sage/calculus/test_sympy.py
+    src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+    
+    The form of the output from SymPy has changed since
+    
+    https://github.com/sympy/sympy/pull/23567
+
+diff --git a/src/sage/calculus/test_sympy.py b/src/sage/calculus/test_sympy.py
+index 7cf7f3f6bfd..927e6ee4fb6 100644
+--- a/src/sage/calculus/test_sympy.py
++++ b/src/sage/calculus/test_sympy.py
+@@ -193,7 +193,7 @@ This was fixed in Sympy, see :trac:`14437`::
+     sage: u = Function('u')
+     sage: n = Symbol('n', integer=True)
+     sage: f = u(n+2) - u(n+1) + u(n)/4
+-    sage: 2**n * rsolve(f,u(n))
+-    C1*n + C0
++    sage: expand(2**n * rsolve(f,u(n)))
++    2*C1*n + C0
+ 
+ """
+diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+index 1062f4f7e8c..f53f813d793 100644
+--- a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
++++ b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+@@ -382,7 +382,7 @@ Sage example in ./recequadiff.tex, line 1798::
+   sage: from sympy import rsolve_hyper
+   sage: from sympy.abc import n
+   sage: rsolve_hyper([-2,1],2**(n+2),n)
+-  2**n*C0 + 2**(n + 2)*(C0 + n/2)
++  2**n*C0 + 2**(n + 1)*n
+ 
+ """
+ 
diff --git a/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch b/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
new file mode 100644
index 000000000000..8fedcb78cf71
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
@@ -0,0 +1,19 @@
+commit 04971318f032caf8dc1c0de9489346d894409091
+Author: John H. Palmieri <jhpalmieri64@gmail.com>
+Date:   Wed Aug 31 14:22:26 2022 -0700
+
+    trac 34465: fix invalid escape sequence in functions/special.py
+
+diff --git a/src/sage/functions/special.py b/src/sage/functions/special.py
+index 02596e49620..901f02f9bee 100644
+--- a/src/sage/functions/special.py
++++ b/src/sage/functions/special.py
+@@ -849,7 +849,7 @@ class EllipticF(BuiltinFunction):
+     - :wikipedia:`Elliptic_integral#Incomplete_elliptic_integral_of_the_first_kind`
+     """
+     def __init__(self):
+-        """
++        r"""
+         EXAMPLES::
+ 
+             sage: loads(dumps(elliptic_f))
diff --git a/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch b/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch
deleted file mode 100644
index f3eb0aad2cca..000000000000
--- a/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch
+++ /dev/null
@@ -1,14 +0,0 @@
- - this is not a proper fix... should fix sage_getfile() instead
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -187,7 +187,8 @@ def loadable_module_extension():
-         True
-     """
-     # Return the full platform-specific extension module suffix
--    return import_machinery.EXTENSION_SUFFIXES[0]
-+    # PATCHED for void linux, we use the shortest extension (.so)
-+    return import_machinery.EXTENSION_SUFFIXES[-1]
- 
- 
- def isclassinstance(obj):
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 0d793262d572..8df50e4e13b6 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,7 +1,7 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=9.5
-revision=2
+version=9.7
+revision=1
 wrksrc=sage-$version
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
@@ -33,12 +33,9 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="http://sagemath.org/"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=8d70a3b26080802c5b2e33dda4c23795d494d8216a0c2ecfcd608ebab0e64ff6
+checksum=9f26f14aa322e3cf38a71835b12ac34b23026b467f74d54b064c5d025e76fbfd
 
 post_patch() {
-	# these are unused and nothing else uses ratpoints
-	rm sage/libs/ratpoints.{pyx,pxd}
-
 	# git tree needs bootstrapping
 	pushd $wrksrc/build/pkgs/sagelib
 	PATH=../../bin:$PATH BOOTSTRAP_QUIET=no ./bootstrap
@@ -65,6 +62,7 @@ do_configure() {
 
 pre_build() {
 	export PYTHONPATH=../sage-setup
+	export PYTHONDONTWRITEBYTECODE=yes
 	export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
 }
 
@@ -77,6 +75,7 @@ post_build() {
 
 pre_install() {
 	export PYTHONPATH=../sage-setup
+	export PYTHONDONTWRITEBYTECODE=yes
 	export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
 }
 
@@ -104,6 +103,7 @@ post_install() {
 do_check() {
 	_scripts=$(cd build/scripts* && pwd)
 	export PYTHONPATH=$(cd build/lib* && pwd)
+	export PYTHONDONTWRITEBYTECODE=yes
 
 	# get out of $build_wrksrc, otherwise python picks the wrong sage module
 	cd $(mktemp -dp build)

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: DRAFT: sagemath update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (7 preceding siblings ...)
  2022-10-12 14:46 ` [PR PATCH] [Updated] " tornaria
@ 2022-10-12 18:18 ` dkwo
  2022-10-12 18:18 ` dkwo
                   ` (23 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: dkwo @ 2022-10-12 18:18 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 376 bytes --]

New comment by dkwo on void-packages repository

https://github.com/void-linux/void-packages/pull/39876#issuecomment-1276561989

Comment:
Trying to natively build and check this on aarch64: I encounter 1 test failure in giac, then it works successfully with ntl and singular (using the libtool PR), but fails with sbcl (in do_build I get `mmap: Invalid argument`). Any ideas?

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: DRAFT: sagemath update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (8 preceding siblings ...)
  2022-10-12 18:18 ` dkwo
@ 2022-10-12 18:18 ` dkwo
  2022-10-12 20:17 ` tornaria
                   ` (22 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: dkwo @ 2022-10-12 18:18 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 155 bytes --]

New comment by dkwo on void-packages repository

https://github.com/void-linux/void-packages/pull/39876#issuecomment-1276562473

Comment:
@leahneukirchen 

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: DRAFT: sagemath update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (9 preceding siblings ...)
  2022-10-12 18:18 ` dkwo
@ 2022-10-12 20:17 ` tornaria
  2022-10-12 22:02 ` dkwo
                   ` (21 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: tornaria @ 2022-10-12 20:17 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 786 bytes --]

New comment by tornaria on void-packages repository

https://github.com/void-linux/void-packages/pull/39876#issuecomment-1276686079

Comment:
> Trying to natively build and check this on aarch64: I encounter 1 test failure in giac, then it works successfully with ntl and singular (using the libtool PR), but fails with sbcl (in do_build I get `mmap: Invalid argument`). Any ideas?

Ouch, yes... I forgot about giac so the CI failed at that. That is a known issue on giac testsuite, safe to ignore (I shall disable the test if I don't find an easy workaround). Other than that, everything passes for me.

I don't know about sbcl. Did you try building maxima with ~sbcl (or just remove aarch64 from the case in maxima template? I think maxima-ecl should be good enough for sagemath.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: DRAFT: sagemath update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (10 preceding siblings ...)
  2022-10-12 20:17 ` tornaria
@ 2022-10-12 22:02 ` dkwo
  2022-10-13  3:15 ` [PR PATCH] [Updated] " tornaria
                   ` (20 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: dkwo @ 2022-10-12 22:02 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 346 bytes --]

New comment by dkwo on void-packages repository

https://github.com/void-linux/void-packages/pull/39876#issuecomment-1276779945

Comment:
Thanks, with ~sbcl then it works.

After building some nocross stuff (I wish we had native builders :),
it only fails a few tests by timeout, so it looks good.
I used XBPS_CHECK_PKGS=yes, not full, for now.


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PR PATCH] [Updated] DRAFT: sagemath update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (11 preceding siblings ...)
  2022-10-12 22:02 ` dkwo
@ 2022-10-13  3:15 ` tornaria
  2022-10-13 14:03 ` tornaria
                   ` (19 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: tornaria @ 2022-10-13  3:15 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1883 bytes --]

There is an updated pull request by tornaria against master on the void-packages repository

https://github.com/tornaria/void-packages sagemath-update
https://github.com/void-linux/void-packages/pull/39876

DRAFT: sagemath update to 9.7
This includes #39838, #39840, #39846, #39872, #39866, also update eclib-20220621.

For now I'm reverting python3-matplotlib to 3.5.3_1 since 3.6.0_1 gives a lot of problems (#39857 adds python3-contourpy which will solve some, but I think there are more issues).

I want to make sure everything works ok and the full testsuite passes as is. Then I'll just move matplotlib back to 3.6.0_1 and try to see if it's feasible to fix or workaround the issues (sagemath-the-distro is still on matplotlib 3.5.2 and I didn't find anything about the update to 3.6.0)

<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: currently running the testsuite in --long after the update of singular.

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/39876.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-sagemath-update-39876.patch --]
[-- Type: text/x-diff, Size: 193847 bytes --]

From 76caa92f0f6c54a6f3db44d4345dd8f91ba8953e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 19:14:02 -0300
Subject: [PATCH 01/14] flintlib: update to 2.9.0.

---
 common/shlibs             | 2 +-
 srcpkgs/flintlib/template | 7 ++-----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index de0428d0987d..f220c136eced 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4014,7 +4014,7 @@ libgtkdatabox.so.1 gtkdatabox3-1.0.0_1
 libxcvt.so.0 libxcvt-0.1.1_1
 libgf2x.so.3 gf2x-1.3.0_1
 libntl.so.44 ntl-11.5.1_1
-libflint.so.16 flintlib-2.8.0_1
+libflint.so.17 flintlib-2.9.0_1
 libarb.so.2 arb-2.20.0_1
 libec.so.8 eclib-20210625_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index 968dbcb525c2..bf5cfe0c0bd9 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,6 +1,6 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.8.5
+version=2.9.0
 revision=1
 wrksrc="flint-${version}"
 build_style=configure
@@ -14,11 +14,10 @@ license="LGPL-2.1-or-later"
 homepage="https://flintlib.org"
 changelog="https://raw.githubusercontent.com/wbhart/flint2/trunk/NEWS"
 distfiles="https://flintlib.org/flint-${version}.tar.gz"
-checksum=5911fedff911100f15781f35e3a4fa934fe60e4aea02a8c10cc8918101c1eed8
+checksum=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
-build_options_default=""
 
 if [ -z "$CROSS_BUILD" ]; then
 	build_options_default+=" ntl"
@@ -28,8 +27,6 @@ case "$XBPS_TARGET_MACHINE" in
 	x86_64*|i686*|aarch64*|arm*|ppc64*) build_options_default+=" openblas";;
 esac
 
-CFLAGS="-D_GNU_SOURCE" # needed for cpu_set_t
-
 flintlib-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision} mpfr-devel"
 	short_desc+=" - development files"

From cba9e789f06c14d7c34f406fa3dc3e94068fb24f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 19:16:18 -0300
Subject: [PATCH 02/14] arb: update to 2.23.0.

---
 srcpkgs/arb/template | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
index 52f11ef83c90..84a62c7ffdba 100644
--- a/srcpkgs/arb/template
+++ b/srcpkgs/arb/template
@@ -1,6 +1,6 @@
 # Template file for 'arb'
 pkgname=arb
-version=2.22.1
+version=2.23.0
 revision=1
 build_style=configure
 configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
@@ -11,9 +11,7 @@ license="LGPL-2.1-or-later"
 homepage="https://arblib.org"
 changelog="https://raw.githubusercontent.com/fredrik-johansson/arb/master/doc/source/history.rst"
 distfiles="https://github.com/fredrik-johansson/arb/archive/${version}.tar.gz"
-checksum=1ef85518eee04885e8a90196498bc75e4e2410621d4184f2bc01d46b7080a243
-
-CFLAGS="-D_GNU_SOURCE" # needed for cpu_set_t
+checksum=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
 
 arb-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"

From 41015c7c4b25cb6fed9d5ca7886fa1678c1a5666 Mon Sep 17 00:00:00 2001
From: dkwo <nicolopiazzalunga@gmail.com>
Date: Mon, 10 Oct 2022 10:14:06 -0400
Subject: [PATCH 03/14] singular: update to 4.3.1p2 (fix gcc 12 build)

---
 common/shlibs             | 10 +++++-----
 srcpkgs/singular/template | 26 ++++++++++++++------------
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index f220c136eced..af06967e6133 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4056,11 +4056,11 @@ libumfpack.so.5 SuiteSparse-5.10.1_1
 libecl.so.21.2 ecl-21.2.1_1
 libecm.so.1 ecm-7.0.4_3
 libcliquer.so.1 cliquer-1.22_1
-libSingular-4.3.0.so singular-4.3.0_1
-libfactory-4.3.0.so singular-4.3.0_1
-libpolys-4.3.0.so singular-4.3.0_1
-libomalloc-0.9.6.so singular-4.3.0_1
-libsingular_resources-4.3.0.so singular-4.3.0_1
+libSingular-4.3.1.so singular-4.3.1p2_1
+libfactory-4.3.1.so singular-4.3.1p2_1
+libpolys-4.3.1.so singular-4.3.1p2_1
+libomalloc-0.9.6.so singular-4.3.1p2_1
+libsingular_resources-4.3.1.so singular-4.3.1p2_1
 libbrial.so.3 brial-1.2.10_1
 libbrial_groebner.so.3 brial-1.2.10_1
 libm4ri-0.0.20200125.so m4ri-20200125_1
diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index f23659ef5d83..a30beef915d2 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,25 +1,27 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.0
+version=4.3.1p2
 revision=1
+_majver=${version%p*}
+wrksrc=singular-${_majver}
 build_style=gnu-configure
 configure_args="--with-readline=ncurses
-	--enable-gfanlib
-	--enable-Singular
-	--enable-factory
-	--disable-doc
-	--disable-polymake
-	--without-python
-	--with-libparse
-	ac_cv_lib_cddgmp_dd_free_global_constants=yes"
+ --enable-gfanlib
+ --enable-Singular
+ --enable-factory
+ --disable-doc
+ --disable-polymake
+ --without-python
+ --with-libparse
+ ac_cv_lib_cddgmp_dd_free_global_constants=yes"
 hostmakedepends="perl tar doxygen"
 makedepends="flintlib-devel cddlib-devel readline-devel graphviz"
 short_desc="Computer algebra system for polynomial computations"
-maintainer="dkwo <nicolopiazzalunga@gmail.com>"
+maintainer="dkwo <npiazza@disroot.org>"
 license="GPL-2.0-or-later"
 homepage="https://www.singular.uni-kl.de"
-distfiles="https://www.singular.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${version//./-}/singular-${version}.tar.gz"
-checksum=74f38288203720e3f280256f2f8deb94030dd032b4237d844652aff0faab36e7
+distfiles="https://www.singular.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${_majver//./-}/singular-${version}.tar.gz"
+checksum=95814bba0f0bd0290cd9799ec1d2ecc6f4c8a4e6429d9a02eb7f9c4e5649682a
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From 8ccb02978befd9d6184ab87285e2994e77ae67f2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 19:59:20 -0300
Subject: [PATCH 04/14] pari: update to 2.15.0.

---
 common/shlibs         | 3 +--
 srcpkgs/pari/template | 7 ++++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index af06967e6133..106f76574252 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4005,8 +4005,7 @@ libsimavrparts.so.1 simavr-1.6_2
 libsword-1.8.1.so libsword-1.8.1_6
 libgivaro.so.9 givaro-4.1.1_1
 liblinbox.so.0 linbox-1.6.3_1
-libpari-gmp.so.7 pari-2.13.0_1
-libpari-gmp-tls.so.7 pari-2.13.2_1
+libpari-gmp-tls.so.8 pari-2.15.0_1
 libtree-sitter.so.0 tree-sitter-0.19.0_1
 libplanarity.so.0 planarity-3.0.1.1_1
 libgap.so.0 gap-4.11.1_1
diff --git a/srcpkgs/pari/template b/srcpkgs/pari/template
index 8bac1e0343f8..873cddb4946f 100644
--- a/srcpkgs/pari/template
+++ b/srcpkgs/pari/template
@@ -1,6 +1,6 @@
 # Template file for 'pari'
 pkgname=pari
-version=2.13.4
+version=2.15.0
 revision=1
 build_style=configure
 build_helper=qemu
@@ -11,14 +11,15 @@ make_check_target=statest-all
 make_install_target="install install-lib-sta install-lib-dyn"
 hostmakedepends="perl texlive"
 makedepends="gmp-devel readline-devel $(vopt_if x11 libX11-devel)"
-checkdepends="pari-elldata-small pari-galdata pari-galpol-small pari-seadata-small"
+checkdepends="pari-elldata-small pari-galdata pari-galpol-small
+ pari-seadata-small pari-nflistdata"
 short_desc="Fast computations library in number theory"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="https://pari.math.u-bordeaux.fr"
 changelog="https://pari.math.u-bordeaux.fr/cgi-bin/gitweb.cgi?p=pari.git;a=blob_plain;f=CHANGES;hb=refs/heads/pari-${version%.*}"
 distfiles="https://pari.math.u-bordeaux.fr/pub/pari/unix/${pkgname}-${version}.tar.gz"
-checksum=bcde9eceae1592814381c1697cdb7063567b6504201b1be47bb58920f3bce185
+checksum=e474851e0d16d4e4f9a0d9612c746a2ae7c9a1ec185d04c440b1c74a85755685
 
 build_options="x11 pthreads"
 build_options_default="x11 pthreads"

From 786bfec41bd161335a49febfd2d472ca531ad47e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 20:33:23 -0300
Subject: [PATCH 05/14] gp2c: update to 0.0.13.

---
 srcpkgs/gp2c/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gp2c/template b/srcpkgs/gp2c/template
index f82cf95c2d90..9cf0f6fdce6e 100644
--- a/srcpkgs/gp2c/template
+++ b/srcpkgs/gp2c/template
@@ -1,6 +1,6 @@
 # Template file for 'gp2c'
 pkgname=gp2c
-version=0.0.12pl1
+version=0.0.13
 revision=1
 build_style=gnu-configure
 hostmakedepends="perl"
@@ -12,4 +12,4 @@ license="GPL-2.0-or-later"
 homepage="http://pari.math.u-bordeaux.fr/"
 changelog="http://pari.math.u-bordeaux.fr/cgi-bin/gitweb.cgi?p=gp2c.git;a=blob_plain;f=ChangeLog;hb=HEAD"
 distfiles="${homepage}pub/pari/GP2C/${pkgname}-${version}.tar.gz"
-checksum=79a8c46f7ad3331e4d8ae6af6b496c4742fd73a73b996b3ca7ead61452ca6e8d
+checksum=261374eca73ebd76c112a9593dca28b64812aa762561fda5a4b2c2cd79a69d36

From c96bd3a5f16e470dec35b1f24aeaf929be8476c8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Fri, 23 Sep 2022 16:42:40 -0300
Subject: [PATCH 06/14] eclib: update to 20220621.

---
 common/shlibs          | 2 +-
 srcpkgs/eclib/template | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 106f76574252..f21ccacd6477 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4015,7 +4015,7 @@ libgf2x.so.3 gf2x-1.3.0_1
 libntl.so.44 ntl-11.5.1_1
 libflint.so.17 flintlib-2.9.0_1
 libarb.so.2 arb-2.20.0_1
-libec.so.8 eclib-20210625_1
+libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
 liblrcalc.so.2 lrcalc-2.1_1
diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 694a39ed4068..e33da0a859ca 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
-version=20210625
-revision=2
+version=20220621
+revision=1
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 hostmakedepends="automake autoconf-archive libtool"
@@ -11,7 +11,7 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="https://github.com/JohnCremona/eclib"
 distfiles="https://github.com/JohnCremona/eclib/archive/refs/tags/${version}.tar.gz"
-checksum=00333fd36afd237c9e6e410c7ab98536ddcd7fdc430e6837fe293247b835c572
+checksum=b0e06ffe6cd669354627eb1ff351cf558a4376dca1cf5c2d4ad042ae49fa5462
 
 pre_configure() {
 	autoreconf -fi

From b68858ee8c076a769e2ad39d53d7e14384c6c8e1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Thu, 13 Oct 2022 00:02:31 -0300
Subject: [PATCH 07/14] eclib: update to 20221012.

---
 srcpkgs/eclib/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index e33da0a859ca..31a3a01921fa 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,6 +1,6 @@
 # Template file for 'eclib'
 pkgname=eclib
-version=20220621
+version=20221012
 revision=1
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
@@ -11,7 +11,7 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="https://github.com/JohnCremona/eclib"
 distfiles="https://github.com/JohnCremona/eclib/archive/refs/tags/${version}.tar.gz"
-checksum=b0e06ffe6cd669354627eb1ff351cf558a4376dca1cf5c2d4ad042ae49fa5462
+checksum=bd6f0191876c1426ca57db851ce06ef79ea1755f01e81dd747358d1b76b5e932
 
 pre_configure() {
 	autoreconf -fi

From 2c79c4b19587df1c30f38798a546ac2a0b5efe56 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:20 -0300
Subject: [PATCH 08/14] giac: update to 1.9.0.21.

---
 srcpkgs/giac/patches/giac-pari-2.15.patch | 20 ++++++++++++++++++++
 srcpkgs/giac/template                     |  4 ++--
 2 files changed, 22 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/giac/patches/giac-pari-2.15.patch

diff --git a/srcpkgs/giac/patches/giac-pari-2.15.patch b/srcpkgs/giac/patches/giac-pari-2.15.patch
new file mode 100644
index 000000000000..be409be38f53
--- /dev/null
+++ b/srcpkgs/giac/patches/giac-pari-2.15.patch
@@ -0,0 +1,20 @@
+ANYARG patch
+
+diff --git a/src/pari.cc b/src/pari.cc
+index 76ce8e1..50d08ab 100644
+--- a/src/pari.cc
++++ b/src/pari.cc
+@@ -40,6 +40,13 @@ using namespace std;
+ 
+ #ifdef HAVE_LIBPARI
+ 
++// Anyarg disappeared from PARI 2.15.0
++#ifdef __cplusplus
++#  define ANYARG ...
++#else
++#  define ANYARG
++#endif
++
+ #ifdef HAVE_PTHREAD_H
+ #include <pthread.h>
+ #endif
diff --git a/srcpkgs/giac/template b/srcpkgs/giac/template
index e892c8bf7506..31045e9128ee 100644
--- a/srcpkgs/giac/template
+++ b/srcpkgs/giac/template
@@ -1,6 +1,6 @@
 # Template file for 'giac'
 pkgname=giac
-version=1.9.0.7
+version=1.9.0.21
 revision=1
 wrksrc="giac-${version%.*}"
 build_style=gnu-configure
@@ -14,7 +14,7 @@ license="GPL-3.0-or-later"
 homepage="https://www-fourier.ujf-grenoble.fr/~parisse/giac.html"
 changelog="https://www-fourier.ujf-grenoble.fr/~parisse/install_en#new"
 distfiles="https://www-fourier.ujf-grenoble.fr/~parisse/debian/dists/stable/main/source/giac_${version%.*}-${version##*.}.tar.gz"
-checksum=72016988b7180e9b630ecabecc60969213e7b61418c2598c91acbaec139fd740
+checksum=120cd16f2e033817302d2a03a22bd413dc1d85df8b225ba4f76b93a7805b07fe
 
 # need more than 4*65536 stack, see try_parse() in gen.cc line 11812
 LDFLAGS="-Wl,-z,stack-size=2097152"

From 7dfeafb68890fbef80c2296a50eca3e1c53143be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 12 Oct 2022 23:59:37 -0300
Subject: [PATCH 09/14] gap: update to 4.12.0.

---
 common/shlibs                          |  2 +-
 srcpkgs/gap/patches/fix-atlasrep.patch | 11 +++++++++++
 srcpkgs/gap/template                   | 11 ++++++-----
 3 files changed, 18 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/gap/patches/fix-atlasrep.patch

diff --git a/common/shlibs b/common/shlibs
index f21ccacd6477..48b61abc836d 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4008,7 +4008,7 @@ liblinbox.so.0 linbox-1.6.3_1
 libpari-gmp-tls.so.8 pari-2.15.0_1
 libtree-sitter.so.0 tree-sitter-0.19.0_1
 libplanarity.so.0 planarity-3.0.1.1_1
-libgap.so.0 gap-4.11.1_1
+libgap.so.8 gap-4.12.0_1
 libgtkdatabox.so.1 gtkdatabox3-1.0.0_1
 libxcvt.so.0 libxcvt-0.1.1_1
 libgf2x.so.3 gf2x-1.3.0_1
diff --git a/srcpkgs/gap/patches/fix-atlasrep.patch b/srcpkgs/gap/patches/fix-atlasrep.patch
new file mode 100644
index 000000000000..ccb9ae587d4b
--- /dev/null
+++ b/srcpkgs/gap/patches/fix-atlasrep.patch
@@ -0,0 +1,11 @@
+--- a/pkg/atlasrep/gap/access.gi.orig	2022-08-05 19:11:16.000000000 -0300
++++ b/pkg/atlasrep/gap/access.gi	2022-10-12 23:40:48.816642751 -0300
+@@ -3156,7 +3156,7 @@
+         uri:= url{ [ p .. Length( url ) ] };
+         body:= AtlasOfGroupRepresentationsTransferFile( domain, uri, fail,
+                                                         fail );
+-        if body = fail then
++        if body = false then
+           Info( InfoAtlasRep, 1,
+                 "AtlasOfGroupRepresentationsNotifyData:\n",
+                 "#I  cannot read '", url, "'" );
diff --git a/srcpkgs/gap/template b/srcpkgs/gap/template
index 7bc7d13ace20..a8788616e449 100644
--- a/srcpkgs/gap/template
+++ b/srcpkgs/gap/template
@@ -1,6 +1,6 @@
 # Template file for 'gap'
 pkgname=gap
-version=4.11.1
+version=4.12.0
 revision=1
 build_style=gnu-configure
 make_install_target="install-bin install-gaproot install-headers install-libgap"
@@ -10,8 +10,9 @@ short_desc="Groups, Algorithms, Programming - computational discrete algebra"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="http://www.gap-system.org/"
+changelog="https://raw.githubusercontent.com/gap-system/gap/master/CHANGES.md"
 distfiles="https://github.com/gap-system/gap/releases/download/v${version}/gap-${version}.tar.gz"
-checksum=6635c5da7d82755f8339486b9cac33766f58712f297e8234fba40818902ea304
+checksum=6005d0c0316fe8803d84681f30be64eace83a9542f975f5cb3dedfadd4391849
 
 if [ "$XBPS_CHECK_PKGS" = full ]; then
 	# not sure about this -- takes about 25 minutes
@@ -21,10 +22,10 @@ fi
 _GAPROOT=/usr/share/gap/
 
 # minimal required packages
-_GAPPKGS="GAPDoc primgrp SmallGrp transgrp"
+_GAPPKGS="gapdoc primgrp smallgrp transgrp"
 
 # other expected packages
-_GAPPKGS+=" atlasrep autpgrp alnuth crisp ctbllib FactInt fga irredsol laguna
+_GAPPKGS+=" atlasrep autpgrp alnuth crisp ctbllib factint fga irredsol laguna
  polenta polycyclic resclasses sophus tomlib"
 
 post_install() {
@@ -34,7 +35,7 @@ post_install() {
 		vcopy "pkg/$p" ${_GAPROOT}/pkg
 	done
 	# not handled by make install-headers
-	vcopy gen/config.h /usr/include/gap
+	vcopy build/config.h /usr/include/gap
 }
 
 gap-devel_package() {

From e3ceac2a17830d86a47d41d4a6dc0d2d227e0a94 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:19 -0300
Subject: [PATCH 10/14] lcalc: revbump for pari 2.15.0

---
 srcpkgs/lcalc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lcalc/template b/srcpkgs/lcalc/template
index 270078df9a54..3c6be5fcbc28 100644
--- a/srcpkgs/lcalc/template
+++ b/srcpkgs/lcalc/template
@@ -1,7 +1,7 @@
 # Template file for 'lcalc'
 pkgname=lcalc
 version=2.0.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--with-pari"
 hostmakedepends="automake libtool pkg-config gengetopt"

From 32a350fef3725a937637c2ce1452d703b932e3c2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:21 -0300
Subject: [PATCH 11/14] python3-cysignals: revbump for pari 2.15.0

---
 srcpkgs/python3-cysignals/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/python3-cysignals/template b/srcpkgs/python3-cysignals/template
index 4655eead2a9c..08d1010976ff 100644
--- a/srcpkgs/python3-cysignals/template
+++ b/srcpkgs/python3-cysignals/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-cysignals'
 pkgname=python3-cysignals
 version=1.11.2
-revision=1
+revision=2
 wrksrc="cysignals-${version}"
 build_style=python3-module
 hostmakedepends="python3-setuptools python3-Cython autoconf"

From 0e53174d443b7f77387b6d59f03d3cf4f253f385 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:58:16 -0300
Subject: [PATCH 12/14] python3-cypari2: revbump for pari 2.15.0

---
 srcpkgs/python3-cypari2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/python3-cypari2/template b/srcpkgs/python3-cypari2/template
index 9ded61101e8e..9db3070a087c 100644
--- a/srcpkgs/python3-cypari2/template
+++ b/srcpkgs/python3-cypari2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-cypari2'
 pkgname=python3-cypari2
 version=2.1.2
-revision=1
+revision=2
 wrksrc=cypari2-${version}
 build_style=python3-module
 hostmakedepends="python3-setuptools python3-Cython pari perl"

From 45a14ad0740c2b4b12233f167c9cb58a582822b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 00:49:01 -0300
Subject: [PATCH 13/14] sagemath: update to 9.7.

---
 .../patches/01-dont_link_ratpoints.patch      |   10 -
 ...2-fix_get_shared_lib_path--see_29644.patch |   13 -
 .../patches/03-doctest_have_program.patch     |   20 -
 .../patches/04-doctest_sage_getfile.patch     |   22 -
 .../patches/05-fix_sage_getfile.patch         |   16 -
 .../sagemath/patches/07-ignore_warning.patch  |   15 -
 .../08-dont_run_pytest--see_31924.patch       |   27 -
 ...y_slow_doctest-polynomial_zmod_flint.patch |   14 -
 ...ry_slow_doctest-isogeny_small_degree.patch |  106 -
 ...fix_very_slow_doctest-function_field.patch |   97 -
 srcpkgs/sagemath/patches/matplotlib-3.6.patch |   72 +
 srcpkgs/sagemath/patches/python-3.11.patch    |   45 +
 .../sagemath/patches/sagemath-pari-2.15.patch | 1750 +++++++++++++++++
 .../patches/sagemath-pari-2.15b.patch         |   29 +
 .../trac-31355-upgrade_lrcalc_to_2.1.patch    |  670 -------
 .../trac-33170-fix_doctest_ipython_8.patch    |   40 -
 .../trac-33170b-fix_doctest_ipython_8.1.patch |   13 -
 ...2ddd4e2dc92469c1590ebf0c40f8f69bf579.patch |  126 --
 ...2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch |   40 -
 .../trac-33336-fix_doctest_scipy_1.8.patch    |   19 -
 ...cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch |   53 +
 ...d9deaeaa6380ab2f0d50276d911233c00a04.patch |   99 -
 ...ff347454ac7f07e5918470b20e97b8f2357e.patch |   29 -
 ...0a0b14f67f4804e7113c3db41bbcf8a58296.patch |   26 -
 ...d4e56243c609f44afc1f21c112b026f9e1fe.patch |   42 +
 ...1318f032caf8dc1c0de9489346d894409091.patch |   19 +
 .../zzz-loadable_module_extension.patch       |   14 -
 srcpkgs/sagemath/template                     |   12 +-
 28 files changed, 2016 insertions(+), 1422 deletions(-)
 delete mode 100644 srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
 delete mode 100644 srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
 delete mode 100644 srcpkgs/sagemath/patches/03-doctest_have_program.patch
 delete mode 100644 srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
 delete mode 100644 srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
 delete mode 100644 srcpkgs/sagemath/patches/07-ignore_warning.patch
 delete mode 100644 srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
 delete mode 100644 srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
 delete mode 100644 srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
 delete mode 100644 srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
 create mode 100644 srcpkgs/sagemath/patches/matplotlib-3.6.patch
 create mode 100644 srcpkgs/sagemath/patches/python-3.11.patch
 create mode 100644 srcpkgs/sagemath/patches/sagemath-pari-2.15.patch
 create mode 100644 srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
 delete mode 100644 srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch

diff --git a/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch b/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
deleted file mode 100644
index e5c3f5776aa2..000000000000
--- a/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
+++ /dev/null
@@ -1,10 +0,0 @@
- - do not link ratpoints where it's not used
-
---- a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
-+++ b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
-@@ -1,5 +1,3 @@
--# distutils: libraries = ratpoints
--
- r"""
- Descent on elliptic curves over `\QQ` with a 2-isogeny
- """
diff --git a/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch b/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
deleted file mode 100644
index d3672b094c1c..000000000000
--- a/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
+++ /dev/null
@@ -1,13 +0,0 @@
- - fix _get_shared_lib_path() so we don't need to configure GAP_SO
-
---- a/src/sage/env.py
-+++ b/src/sage/env.py
-@@ -293,7 +293,7 @@ def _get_shared_lib_path(*libnames: str) -> Optional[str]:
-             if sys.platform == 'darwin':
-                 ext = 'dylib'
-             else:
--                ext = 'so'
-+                ext = 'so*'
- 
-             if SAGE_LOCAL:
-                 search_directories.append(Path(SAGE_LOCAL) / 'lib')
diff --git a/srcpkgs/sagemath/patches/03-doctest_have_program.patch b/srcpkgs/sagemath/patches/03-doctest_have_program.patch
deleted file mode 100644
index 27ba3776470c..000000000000
--- a/srcpkgs/sagemath/patches/03-doctest_have_program.patch
+++ /dev/null
@@ -1,20 +0,0 @@
- - we don't know `SAGE_VENV/bin` contains `sage`, but `sys.argv[0]` should
-   be the full path to `sage-ipython` and the same directory should have `sage`
-
---- a/src/sage/misc/sage_ostools.pyx
-+++ b/src/sage/misc/sage_ostools.pyx
-@@ -32,12 +32,11 @@ def have_program(program, path=None):
-         True
-         sage: have_program('there_is_not_a_program_with_this_name')
-         False
--        sage: from sage.env import SAGE_VENV
--        sage: have_program('sage', os.path.join(SAGE_VENV, 'bin'))
-+        sage: have_program('sage', os.path.dirname(sys.argv[0]))
-         True
-         sage: have_program('sage', '/there_is_not_a_path_with_this_name')
-         False
--        sage: have_program('there_is_not_a_program_with_this_name', os.path.join(SAGE_VENV, 'bin'))
-+        sage: have_program('there_is_not_a_program_with_this_name', "/bin")
-         False
-     """
-     if path is None:
diff --git a/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch b/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
deleted file mode 100644
index 95bce107f854..000000000000
--- a/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
+++ /dev/null
@@ -1,22 +0,0 @@
- - add one doctest for coverage
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -1341,10 +1342,12 @@ def sage_getfile(obj):
-     EXAMPLES::
- 
-         sage: from sage.misc.sageinspect import sage_getfile
--        sage: sage_getfile(sage.rings.rational)[-23:]
--        'sage/rings/rational.pyx'
--        sage: sage_getfile(Sq)[-42:]
--        'sage/algebras/steenrod/steenrod_algebra.py'
-+        sage: sage_getfile(sage.rings.rational)
-+        '...sage/rings/rational.pyx'
-+        sage: sage_getfile(Sq)
-+        '...sage/algebras/steenrod/steenrod_algebra.py'
-+        sage: sage_getfile(x)
-+        '...sage/symbolic/expression.pyx'
- 
-     The following tests against some bugs fixed in :trac:`9976`::
- 
-
diff --git a/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch b/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
deleted file mode 100644
index 56c58078f319..000000000000
--- a/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
+++ /dev/null
@@ -1,16 +0,0 @@
- - fix sage_getfile() by checking all possible EXTENSION_SUFFIXES
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -1400,8 +1403,9 @@ def sage_getfile(obj):
-         sourcefile = inspect.getabsfile(obj)
-     except TypeError: # this happens for Python builtins
-         return ''
--    if sourcefile.endswith(loadable_module_extension()):
--        return sourcefile[:-len(loadable_module_extension())]+os.path.extsep+'pyx'
-+    for suffix in import_machinery.EXTENSION_SUFFIXES:
-+        if sourcefile.endswith(suffix):
-+            return sourcefile[:-len(suffix)]+os.path.extsep+'pyx'
-     return sourcefile
- 
- 
diff --git a/srcpkgs/sagemath/patches/07-ignore_warning.patch b/srcpkgs/sagemath/patches/07-ignore_warning.patch
deleted file mode 100644
index 69668678a40b..000000000000
--- a/srcpkgs/sagemath/patches/07-ignore_warning.patch
+++ /dev/null
@@ -1,15 +0,0 @@
- - this ignores a warning caused by old notebook
-
---- a/src/sage/all.py
-+++ b/src/sage/all.py
-@@ -100,6 +100,9 @@ warnings.filterwarnings('ignore', category=DeprecationWarning,
-                         message='The distutils(.sysconfig module| package) is deprecated',
-                         module='Cython|distutils|numpy|sage.env|sage.features')
- 
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"invalid escape sequence '\\s'")
-+
- ################ end setup warnings ###############################
- 
- 
-
diff --git a/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch b/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
deleted file mode 100644
index 06bd2ccae6fb..000000000000
--- a/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
+++ /dev/null
@@ -1,27 +0,0 @@
- - using pytest is broken, see #31924
-
---- a/src/bin/sage-runtests
-+++ b/src/bin/sage-runtests
-@@ -154,21 +154,4 @@ if __name__ == "__main__":
-     DC = DocTestController(args, args.filenames)
-     err = DC.run()
- 
--    try:
--        exit_code_pytest = 0
--        import pytest
--        pytest_options = ["--import-mode", "importlib"]
--        if args.verbose:
--            pytest_options.append("-v")
--        exit_code_pytest = pytest.main(pytest_options + args.filenames)
--        if exit_code_pytest == 5:
--            # Exit code 5 means there were no test files, pass in this case
--            exit_code_pytest = 0
--
--    except ModuleNotFoundError:
--        print("Pytest is not installed, skip checking tests that rely on it.")
--
--    if err == 0:
--        sys.exit(exit_code_pytest)
--    else:
--        sys.exit(err)
-+    sys.exit(err)
diff --git a/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch b/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
deleted file mode 100644
index bae8387cf94a..000000000000
--- a/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
-+++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
-@@ -237,8 +237,9 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
- 
-             sage: a = ZZ['x'](range(100000))
-             sage: R = Integers(3)['x']
--            sage: R(a)  # long time (7s on sage.math, 2013)
--            2*x^99998 + ... + x
-+            sage: p = R(a)
-+            sage: p.truncate(10)  # testing the whole poly is VERY SLOW
-+            2*x^8 + x^7 + 2*x^5 + x^4 + 2*x^2 + x
-         """
-         sig_on()
-         fmpz_poly_get_nmod_poly(&self.x, x)
diff --git a/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch b/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
deleted file mode 100644
index f3da5bbb555e..000000000000
--- a/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
+++ /dev/null
@@ -1,106 +0,0 @@
-diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-index 43727346269..9d3ccd475cd 100644
---- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-+++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-@@ -186,7 +186,7 @@ def Psi(l, use_stored=True):
-         sage: assert Psi(3, use_stored=True) == Psi(3, use_stored=False)
-         sage: assert Psi(5, use_stored=True) == Psi(5, use_stored=False)
-         sage: assert Psi(7, use_stored=True) == Psi(7, use_stored=False)
--        sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False) # not tested (very long time)
-+        sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False)  # long time (2s)
-     """
-     if l not in [2, 3, 5, 7, 13]:
-         raise ValueError("Genus zero primes are 2, 3, 5, 7 or 13.")
-@@ -1207,7 +1207,7 @@ def isogenies_13_0(E, minimal_models=True):
-         sage: K.<a> = NumberField(f)
-         sage: E = EllipticCurve(j=K(0)); E.ainvs()
-         (0, 0, 0, 0, 1)
--        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]
-+        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]  # long time (4s)
-         [(0,
-           0,
-           20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
-@@ -1325,7 +1325,7 @@ def isogenies_13_1728(E, minimal_models=True):
-         sage: f = x^12 + 1092*x^10 - 432432*x^8 + 6641024*x^6 - 282896640*x^4 - 149879808*x^2 - 349360128
-         sage: K.<a> = NumberField(f)
-         sage: E = EllipticCurve(K, [1,0])
--        sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]
-+        sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]  # long time (3s)
-         [(0,
-         0,
-         0,
-@@ -1550,8 +1550,11 @@ def Psi2(l):
-         sage: from sage.schemes.elliptic_curves.isogeny_small_degree import Psi2
-         sage: Psi2(11)
-         x^5 - 55*x^4*u + 994*x^3*u^2 - 8774*x^2*u^3 + 41453*x*u^4 - 928945/11*u^5 + 33*x^4 + 276*x^3*u - 7794*x^2*u^2 + 4452*x*u^3 + 1319331/11*u^4 + 216*x^3*v - 4536*x^2*u*v + 31752*x*u^2*v - 842616/11*u^3*v + 162*x^3 + 38718*x^2*u - 610578*x*u^2 + 33434694/11*u^3 - 4536*x^2*v + 73872*x*u*v - 2745576/11*u^2*v - 16470*x^2 + 580068*x*u - 67821354/11*u^2 - 185976*x*v + 14143896/11*u*v + 7533*x - 20437029/11*u - 12389112/11*v + 19964151/11
--        sage: Psi2(71)  # long time (1 second)
--        -2209380711722505179506258739515288584116147237393815266468076436521/71*u^210 + ... - 14790739586438315394567393301990769678157425619440464678252277649/71
-+        sage: f = Psi2(71)
-+        sage: f.coefficient([0, 210, 0])
-+        -2209380711722505179506258739515288584116147237393815266468076436521/71
-+        sage: f.coefficient([0, 0, 0])
-+        -14790739586438315394567393301990769678157425619440464678252277649/71
- 
-     TESTS::
- 
-@@ -1665,17 +1668,17 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True):
-         sage: K = QuadraticField(5,'a')
-         sage: a = K.gen()
-         sage: E = EllipticCurve_from_j(184068066743177379840*a - 411588709724712960000)
--        sage: isogenies_prime_degree_genus_plus_0(E, 47) # long time (4.3s)
-+        sage: isogenies_prime_degree_genus_plus_0(E, 47)  # long time (2s)
-         [Isogeny of degree 47 from Elliptic Curve defined by y^2 = x^3 + (454562028554080355857852049849975895490560*a-1016431595837124114668689286176511361024000)*x + (-249456798429896080881440540950393713303830363999480904280965120*a+557802358738710443451273320227578156598454035482869042774016000) over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790? to Elliptic Curve defined by y^2 = x^3 + (39533118442361013730577638493616965245992960*a-88398740199669828340617478832005245173760000)*x + (214030321479466610282320528611562368963830105830555363061803253760*a-478586348074220699687616322532666163722004497458452316582576128000) over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790?]
- 
-         sage: K = QuadraticField(-66827,'a')
-         sage: a = K.gen()
-         sage: E = EllipticCurve_from_j(-98669236224000*a + 4401720074240000)
--        sage: isogenies_prime_degree_genus_plus_0(E, 59)   # long time (25s, 2012)
-+        sage: isogenies_prime_degree_genus_plus_0(E, 59)   # long time (5s)
-         [Isogeny of degree 59 from Elliptic Curve defined by y^2 = x^3 + (2605886146782144762297974784000*a+1893681048912773634944634716160000)*x + (-116918454256410782232296183198067568744071168000*a+17012043538294664027185882358514011304812871680000) over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I to Elliptic Curve defined by y^2 = x^3 + (-19387084027159786821400775098368000*a-4882059104868154225052787156713472000)*x + (-25659862010101415428713331477227179429538847260672000*a-2596038148441293485938798119003462972840818381946880000) over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I]
- 
-         sage: E = EllipticCurve_from_j(GF(13)(5))
--        sage: isogenies_prime_degree_genus_plus_0(E, 71) # long time
-+        sage: isogenies_prime_degree_genus_plus_0(E, 71)
-         [Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13, Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13]
- 
-         sage: E = EllipticCurve(GF(13),[0,1,1,1,0])
-@@ -2117,11 +2120,11 @@ def isogenies_prime_degree_general(E, l, minimal_models=True):
-         sage: isogenies_prime_degree_general(E, 19)
-         [Isogeny of degree 19 from Elliptic Curve defined by y^2 + y = x^3 - 1862*x - 30956 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - 672182*x + 212325489 over Rational Field]
-         sage: E = EllipticCurve([0, -1, 0, -6288, 211072])
--        sage: isogenies_prime_degree_general(E, 37)  # long time (10s)
-+        sage: isogenies_prime_degree_general(E, 37)  # long time (2s)
-         [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 - x^2 - 6288*x + 211072 over Rational Field to Elliptic Curve defined by y^2 = x^3 - x^2 - 163137088*x - 801950801728 over Rational Field]
- 
-         sage: E = EllipticCurve([-3440, 77658])
--        sage: isogenies_prime_degree_general(E, 43)  # long time (16s)
-+        sage: isogenies_prime_degree_general(E, 43)  # long time (2s)
-         [Isogeny of degree 43 from Elliptic Curve defined by y^2 = x^3 - 3440*x + 77658 over Rational Field to Elliptic Curve defined by y^2 = x^3 - 6360560*x - 6174354606 over Rational Field]
- 
-     Isogenies of degree equal to the characteristic are computed (but
-@@ -2175,7 +2178,7 @@ def isogenies_prime_degree_general(E, l, minimal_models=True):
- 
-         sage: K.<i> = QuadraticField(-1)
-         sage: E = EllipticCurve(K,[0,0,0,1,0])
--        sage: [phi.codomain().ainvs() for phi in E.isogenies_prime_degree(37)] # long time
-+        sage: [phi.codomain().ainvs() for phi in E.isogenies_prime_degree(37)]  # long time (6s)
-         [(0, 0, 0, -840*i + 1081, 0), (0, 0, 0, 840*i + 1081, 0)]
-     """
-     if not l.is_prime():
-@@ -2329,14 +2332,14 @@ def isogenies_prime_degree(E, l, minimal_models=True):
-         sage: E = EllipticCurve(GF(101), [-3440, 77658])
-         sage: E.isogenies_prime_degree(71) # fast
-         []
--        sage: E.isogenies_prime_degree(73) # slower (2s)
-+        sage: E.isogenies_prime_degree(73)  # long time (2s)
-         []
- 
-     Test that :trac:`32269` is fixed::
- 
-         sage: K = QuadraticField(-11)
-         sage: E = EllipticCurve(K, [0,1,0,-117,-541])
--        sage: E.isogenies_prime_degree(37)
-+        sage: E.isogenies_prime_degree(37)  # long time (9s)
-         [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I to Elliptic Curve defined by y^2 = x^3 + x^2 + (30800*a+123963)*x + (3931312*a-21805005) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I,
-          Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I to Elliptic Curve defined by y^2 = x^3 + x^2 + (-30800*a+123963)*x + (-3931312*a-21805005) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I]
- 
diff --git a/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch b/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
deleted file mode 100644
index 3b7b1ea843df..000000000000
--- a/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
+++ /dev/null
@@ -1,97 +0,0 @@
---- a/src/sage/rings/function_field/function_field.py
-+++ b/src/sage/rings/function_field/function_field.py
-@@ -111,22 +111,21 @@ Function fields over the algebraic field are supported::
-     sage: m = L.completion(pl, prec=5)
-     sage: m(x)
-     I + s + O(s^5)
--    sage: m(y)
-+    sage: m(y)                             # long time (4s)
-     -2*s + (-4 - I)*s^2 + (-15 - 4*I)*s^3 + (-75 - 23*I)*s^4 + (-413 - 154*I)*s^5 + O(s^6)
--    sage: m(y)^2 + m(y) + m(x) + 1/m(x)
-+    sage: m(y)^2 + m(y) + m(x) + 1/m(x)    # long time (8s)
-     O(s^5)
- 
- TESTS::
- 
-     sage: TestSuite(J).run()
--    sage: TestSuite(K).run(max_runs=1024) # long time (5s)
--    sage: TestSuite(L).run(max_runs=64)   # long time (10s)
--    sage: TestSuite(M).run(max_runs=32)   # long time (30s)
--    sage: TestSuite(N).run(max_runs=64, skip = '_test_derivation')  # long time (8s)
--    sage: TestSuite(O).run(max_runs=128, skip = '_test_derivation') # long time (8s)
--
-+    sage: TestSuite(K).run(max_runs=256)   # long time (10s)
-+    sage: TestSuite(L).run(max_runs=8)     # long time (25s)
-+    sage: TestSuite(M).run(max_runs=8)     # long time (35s)
-+    sage: TestSuite(N).run(max_runs=8, skip = '_test_derivation')    # long time (15s)
-+    sage: TestSuite(O).run()
-     sage: TestSuite(R).run()
--    sage: TestSuite(S).run() # long time (3s)
-+    sage: TestSuite(S).run()               # long time (4s)
- 
- Global function fields
- ----------------------
-@@ -287,7 +286,7 @@ class FunctionField(Field):
-         TESTS::
- 
-             sage: K.<x> = FunctionField(QQ)
--            sage: TestSuite(K).run()
-+            sage: TestSuite(K).run()               # long time (3s)
-         """
-         Field.__init__(self, base_field, names=names, category=category)
- 
-@@ -729,7 +728,7 @@ class FunctionField(Field):
-         EXAMPLES::
- 
-             sage: K.<x> = FunctionField(QQ)
--            sage: TestSuite(K).run() # indirect doctest
-+            sage: TestSuite(K).run()    # indirect doctest, long time (3s)
-         """
-         tester = self._tester(**options)
-         S = tester.some_elements()
-@@ -1209,7 +1208,7 @@ class FunctionField_polymod(FunctionField):
-             sage: K.<x> = FunctionField(QQ); R.<y> = K[]
-             sage: L = K.extension(y^5 - x^3 - 3*x + x*y); L
-             Function field in y defined by y^5 + x*y - x^3 - 3*x
--            sage: TestSuite(L).run()  # long time
-+            sage: TestSuite(L).run(max_runs=512)   # long time (15s)
- 
-         We can set the variable name, which doesn't have to be y::
- 
-@@ -2888,7 +2887,8 @@ class FunctionField_simple(FunctionField_polymod):
-             sage: F.<y> = K.extension(Y^3 - x^2*(x^2 + x + 1)^2)
-             sage: O = K.maximal_order()
-             sage: pls = [O.ideal(x-QQbar(sqrt(c))).place() for c in [-2, -1, 0, 1, 2]]
--            sage: all(q.place_below() == p for p in pls for q in F.places_above(p))
-+            sage: all(q.place_below() == p         # long time (4s)
-+            ....:     for p in pls for q in F.places_above(p))
-             True
-         """
-         R = self.base_field()
-@@ -3091,7 +3091,7 @@ class FunctionField_global(FunctionField_simple):
- 
-         sage: K.<x> = FunctionField(GF(4)); _.<Y> = K[]
-         sage: L.<y> = K.extension((1 - x)*Y^7 - x^3)
--        sage: L.gaps()
-+        sage: L.gaps()                         # long time (6s)
-         [1, 2, 3]
- 
-     or may define a trivial extension::
-@@ -3111,7 +3111,7 @@ class FunctionField_global(FunctionField_simple):
- 
-             sage: K.<x> = FunctionField(GF(5)); _.<Y> = K[]
-             sage: L.<y> = K.extension(Y^3 - (x^3 - 1)/(x^3 - 2))
--            sage: TestSuite(L).run()
-+            sage: TestSuite(L).run()               # long time (7s)
-         """
-         FunctionField_polymod.__init__(self, polynomial, names)
- 
-@@ -3807,7 +3807,7 @@ class RationalFunctionField(FunctionField):
- 
-             sage: K.<t> = FunctionField(CC); K
-             Rational function field in t over Complex Field with 53 bits of precision
--            sage: TestSuite(K).run()
-+            sage: TestSuite(K).run()               # long time (5s)
- 
-             sage: FunctionField(QQ[I], 'alpha')
-             Rational function field in alpha over Number Field in I with defining polynomial x^2 + 1 with I = 1*I
diff --git a/srcpkgs/sagemath/patches/matplotlib-3.6.patch b/srcpkgs/sagemath/patches/matplotlib-3.6.patch
new file mode 100644
index 000000000000..6afaf1b7162f
--- /dev/null
+++ b/srcpkgs/sagemath/patches/matplotlib-3.6.patch
@@ -0,0 +1,72 @@
+commit 5501e0de0dca1cff0355326dd42bd8c7e5749568
+Author: Gonzalo Tornaría <tornaria@cmat.edu.uy>
+Date:   Tue Oct 11 17:25:04 2022 -0300
+
+    Support matplotlib 3.6
+
+diff --git a/src/sage/plot/arc.py b/src/sage/plot/arc.py
+index bb834763afc..f65973bcbd5 100644
+--- a/src/sage/plot/arc.py
++++ b/src/sage/plot/arc.py
+@@ -273,9 +273,9 @@ class Arc(GraphicPrimitive):
+         p = patches.Arc((self.x, self.y),
+                         2. * self.r1,
+                         2. * self.r2,
+-                        fmod(self.angle, 2 * pi) * (180. / pi),
+-                        self.s1 * (180. / pi),
+-                        self.s2 * (180. / pi))
++                        angle=fmod(self.angle, 2 * pi) * (180. / pi),
++                        theta1=self.s1 * (180. / pi),
++                        theta2=self.s2 * (180. / pi))
+         return p
+ 
+     def bezier_path(self):
+diff --git a/src/sage/plot/ellipse.py b/src/sage/plot/ellipse.py
+index a77e6fe640a..c35bed574ef 100644
+--- a/src/sage/plot/ellipse.py
++++ b/src/sage/plot/ellipse.py
+@@ -192,7 +192,8 @@ class Ellipse(GraphicPrimitive):
+         options = self.options()
+         p = patches.Ellipse(
+                 (self.x,self.y),
+-                self.r1*2.,self.r2*2.,self.angle/pi*180.)
++                self.r1*2.,self.r2*2.,
++                angle=self.angle/pi*180.)
+         p.set_linewidth(float(options['thickness']))
+         p.set_fill(options['fill'])
+         a = float(options['alpha'])
+diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
+index e779e1210e3..8d620b5c625 100644
+--- a/src/sage/plot/graphics.py
++++ b/src/sage/plot/graphics.py
+@@ -2007,7 +2007,7 @@ class Graphics(WithEqualityById, SageObject):
+         We can also do custom formatting if you need it.  See above for full
+         details::
+ 
+-            sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex")
++            sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex") # not tested (broken with matplotlib 3.6)
+             Graphics object consisting of 1 graphics primitive
+ 
+         This is particularly useful when setting custom ticks in multiples
+@@ -2341,7 +2341,7 @@ class Graphics(WithEqualityById, SageObject):
+             sage: subplot = Figure().add_subplot(111)
+             sage: p._objects[0]._render_on_subplot(subplot)
+             sage: p._matplotlib_tick_formatter(subplot, **d)
+-            (<AxesSubplot:>,
++            (<AxesSubplot:...>,
+             <matplotlib.ticker.MaxNLocator object at ...>,
+             <matplotlib.ticker.MaxNLocator object at ...>,
+             <matplotlib.ticker.ScalarFormatter object at ...>,
+diff --git a/src/sage/plot/plot.py b/src/sage/plot/plot.py
+index b36ee57227c..5301a05c3dc 100644
+--- a/src/sage/plot/plot.py
++++ b/src/sage/plot/plot.py
+@@ -1741,7 +1741,7 @@ def plot(funcs, *args, **kwds):
+ 
+     ::
+ 
+-        sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex")
++        sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex") # not tested (broken with matplotlib 3.6)
+         Graphics object consisting of 1 graphics primitive
+ 
+     .. PLOT::
diff --git a/srcpkgs/sagemath/patches/python-3.11.patch b/srcpkgs/sagemath/patches/python-3.11.patch
new file mode 100644
index 000000000000..eafe76bfb794
--- /dev/null
+++ b/srcpkgs/sagemath/patches/python-3.11.patch
@@ -0,0 +1,45 @@
+--- a/src/sage/cpython/cython_metaclass.h
++++ b/src/sage/cpython/cython_metaclass.h
+@@ -66,7 +66,7 @@
+         }
+ 
+         /* Now, set t.__class__ to metaclass */
+-        Py_TYPE(t) = metaclass;
++        Py_SET_TYPE(t, metaclass);
+         PyType_Modified(t);
+     }
+     else
+--- a/src/sage/symbolic/ginac/numeric.cpp
++++ b/src/sage/symbolic/ginac/numeric.cpp
+@@ -52,7 +52,6 @@
+ #define register
+ #define PY_SSIZE_T_CLEAN
+ #include <Python.h>
+-#include <longintrepr.h>
+ #include "flint/fmpz.h"
+ #include "flint/fmpz_factor.h"
+ 
+--- a/src/sage/libs/gmp/pylong.pyx
++++ b/src/sage/libs/gmp/pylong.pyx
+@@ -32,7 +32,7 @@
+ from .mpz cimport *
+ 
+ cdef extern from *:
+-    Py_ssize_t* Py_SIZE_PTR "&Py_SIZE"(object)
++    void Py_SET_SIZE(object, Py_ssize_t)
+     int hash_bits """
+         #ifdef _PyHASH_BITS
+         _PyHASH_BITS         /* Python 3 */
+@@ -57,10 +57,8 @@
+     mpz_export(L.ob_digit, NULL,
+             -1, sizeof(digit), 0, PyLong_nails, z)
+     if mpz_sgn(z) < 0:
+-        # Set correct size (use a pointer to hack around Cython's
+-        # non-support for lvalues).
+-        sizeptr = Py_SIZE_PTR(L)
+-        sizeptr[0] = -pylong_size
++        # Set correct size
++        Py_SET_SIZE(L, -pylong_size)
+     return L
+ 
+ 
diff --git a/srcpkgs/sagemath/patches/sagemath-pari-2.15.patch b/srcpkgs/sagemath/patches/sagemath-pari-2.15.patch
new file mode 100644
index 000000000000..ccafad5070c4
--- /dev/null
+++ b/srcpkgs/sagemath/patches/sagemath-pari-2.15.patch
@@ -0,0 +1,1750 @@
+diff --git a/build/pkgs/giac/patches/pari_2_15.patch b/build/pkgs/giac/patches/pari_2_15.patch
+new file mode 100644
+index 0000000000..d2900a5ffc
+--- /dev/null
++++ b/build/pkgs/giac/patches/pari_2_15.patch
+@@ -0,0 +1,21 @@
++ANYARG patch
++
++diff --git a/src/pari.cc b/src/pari.cc
++index 76ce8e1..50d08ab 100644
++--- a/src/pari.cc
+++++ b/src/pari.cc
++@@ -40,6 +40,13 @@ using namespace std;
++ 
++ #ifdef HAVE_LIBPARI
++ 
+++// Anyarg disappeared from PARI 2.15.0
+++#ifdef __cplusplus
+++#  define ANYARG ...
+++#else
+++#  define ANYARG
+++#endif
+++
++ #ifdef HAVE_PTHREAD_H
++ #include <pthread.h>
++ #endif
++
+diff --git a/build/pkgs/pari/checksums.ini b/build/pkgs/pari/checksums.ini
+index b736feed31..bafd0f36f4 100644
+--- a/build/pkgs/pari/checksums.ini
++++ b/build/pkgs/pari/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=pari-VERSION.tar.gz
+-sha1=e01647aab7e96a8cb4922cf26a4f224337c6647f
+-md5=922f740fcdf8630b30d63dc76b58f756
+-cksum=297133525
++sha1=cba9b279f67d5efe2fbbccf3be6e9725f816cf07
++md5=76d430f1bea1b07fa2ad9712deeaa736
++cksum=1990743897
+ upstream_url=https://pari.math.u-bordeaux.fr/pub/pari/unix/pari-VERSION.tar.gz
+diff --git a/build/pkgs/pari/package-version.txt b/build/pkgs/pari/package-version.txt
+index a1a4224dd5..68e69e405e 100644
+--- a/build/pkgs/pari/package-version.txt
++++ b/build/pkgs/pari/package-version.txt
+@@ -1 +1 @@
+-2.13.3
++2.15.0
+diff --git a/src/doc/de/tutorial/tour_numtheory.rst b/src/doc/de/tutorial/tour_numtheory.rst
+index a012234c99..e3149fe949 100644
+--- a/src/doc/de/tutorial/tour_numtheory.rst
++++ b/src/doc/de/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ implementiert.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/en/tutorial/tour_numtheory.rst b/src/doc/en/tutorial/tour_numtheory.rst
+index 3064d100e2..075e0ac0ad 100644
+--- a/src/doc/en/tutorial/tour_numtheory.rst
++++ b/src/doc/en/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ NumberField class.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/es/tutorial/tour_numtheory.rst b/src/doc/es/tutorial/tour_numtheory.rst
+index a1f7d1a87b..48e5376cfe 100644
+--- a/src/doc/es/tutorial/tour_numtheory.rst
++++ b/src/doc/es/tutorial/tour_numtheory.rst
+@@ -140,7 +140,7 @@ Varios métodos relacionados están implementados en la clase ``NumberField``::
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/fr/tutorial/tour_numtheory.rst b/src/doc/fr/tutorial/tour_numtheory.rst
+index 871092f5fa..d1b2fee883 100644
+--- a/src/doc/fr/tutorial/tour_numtheory.rst
++++ b/src/doc/fr/tutorial/tour_numtheory.rst
+@@ -159,7 +159,7 @@ dans la classe NumberField.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/ja/tutorial/tour_numtheory.rst b/src/doc/ja/tutorial/tour_numtheory.rst
+index 47af68c862..4d4ed52d50 100644
+--- a/src/doc/ja/tutorial/tour_numtheory.rst
++++ b/src/doc/ja/tutorial/tour_numtheory.rst
+@@ -161,7 +161,7 @@ Sageには :math:`p` \-進数体も組込まれている.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/pt/tutorial/tour_numtheory.rst b/src/doc/pt/tutorial/tour_numtheory.rst
+index 6371b491ea..a3dc973a93 100644
+--- a/src/doc/pt/tutorial/tour_numtheory.rst
++++ b/src/doc/pt/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ NumberField.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus 
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/ru/tutorial/tour_numtheory.rst b/src/doc/ru/tutorial/tour_numtheory.rst
+index 652abfbc99..a985d49fbd 100644
+--- a/src/doc/ru/tutorial/tour_numtheory.rst
++++ b/src/doc/ru/tutorial/tour_numtheory.rst
+@@ -150,7 +150,7 @@ Sage содержит стандартные функции теории чис
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py
+index e57076646f..fec75d07c1 100644
+--- a/src/sage/arith/misc.py
++++ b/src/sage/arith/misc.py
+@@ -1465,13 +1465,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)]
++        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::
+ 
+@@ -2569,7 +2569,7 @@ def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds):
+ 
+         sage: K.<i> = QuadraticField(-1)
+         sage: factor(122 - 454*i)
+-        (-3*i - 2) * (-i - 2)^3 * (i + 1)^3 * (i + 4)
++        (-i) * (-i - 2)^3 * (i + 1)^3 * (-2*i + 3) * (i + 4)
+ 
+     To access the data in a factorization::
+ 
+diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
+index cdfc11a9e5..b6e1280d6e 100644
+--- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
++++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
+@@ -7825,9 +7825,9 @@ class DynamicalSystem_projective_field(DynamicalSystem_projective,
+             sage: f = DynamicalSystem_projective([x^2 + QQbar(sqrt(3))*y^2, y^2, QQbar(sqrt(2))*z^2])
+             sage: f.reduce_base_field()
+             Dynamical System of Projective Space of dimension 2 over Number Field in a with
+-            defining polynomial y^4 - 4*y^2 + 1 with a = 1.931851652578137?
++            defining polynomial y^4 - 4*y^2 + 1 with a = -0.5176380902050415?
+               Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x^2 + (a^2 - 2)*y^2 : y^2 : (a^3 - 3*a)*z^2)
++                    (x^2 + (-a^2 + 2)*y^2 : y^2 : (a^3 - 3*a)*z^2)
+ 
+         ::
+ 
+diff --git a/src/sage/ext_data/pari/simon/ellQ.gp b/src/sage/ext_data/pari/simon/ellQ.gp
+index 420af8f6a2..65e8386779 100644
+--- a/src/sage/ext_data/pari/simon/ellQ.gp
++++ b/src/sage/ext_data/pari/simon/ellQ.gp
+@@ -40,7 +40,7 @@
+   gp > \r ellcommon.gp
+   gp > \r ellQ.gp
+ 
+-  The main function is ellrank(), which takes as an argument
++  The main function is ellQ_ellrank(), which takes as an argument
+   any elliptic curve in the form [a1,a2,a3,a4,a6]
+   the result is a vector [r,s,v], where
+     r is a lower bound for the rank,
+@@ -50,7 +50,7 @@
+   Example:
+ 
+   gp > ell = [1,2,3,4,5];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+   %1 = [1, 1, [[1,2]]
+   In this example, the rank is exactly 1, and [1,2] has infinite order.
+ 
+@@ -92,7 +92,7 @@
+   \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+ 
+   Explications succintes :
+-  La fonction ellrank() accepte toutes les courbes sous la forme
++  La fonction ellQ_ellrank() accepte toutes les courbes sous la forme
+   [a1,a2,a3,a4,a6]
+   Les coefficients peuvent etre entiers ou non.
+   L'algorithme utilise est celui de la 2-descente.
+@@ -100,7 +100,7 @@
+   Il suffit de taper : 
+ 
+   gp > ell = [a1,a2,a3,a4,a6];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+ 
+   Retourne un vecteur [r,s,v] ou
+     r est le rang probable (c'est toujours une minoration du rang),
+@@ -110,7 +110,7 @@
+   Exemple :
+ 
+   gp > ell = [1,2,3,4,5];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+   %1 = [1, 1, [[1,2]]
+   Ici, le rang est exactement 1, et le point [1,2] est d'ordre infini.
+ 
+@@ -1571,12 +1571,12 @@ if( DEBUGLEVEL_ell >= 4, print("    end of ell2descent_gen"));
+     print("rank(E/Q)    >= ",m1)
+   );
+ }
+-{ellrank(ell,help=[]) =
++{ellQ_ellrank(ell,help=[]) =
+ \\ Algorithm of 2-descent on the elliptic curve ell.
+ \\ help is a list of known points on ell.
+ my(urst,urst1,den,eqell,tors2,bnf,rang,time1);
+ 
+-if( DEBUGLEVEL_ell >= 3, print("   starting ellrank"));
++if( DEBUGLEVEL_ell >= 3, print("   starting ellQ_ellrank"));
+   if( #ell < 13, ell = ellinit(ell));
+ 
+ \\ kill the coefficients a1 and a3
+@@ -1630,7 +1630,7 @@ if( DEBUGLEVEL_ell >= 1, print(" Elliptic curve: Y^2 = ",eqell));
+   ));
+ 
+   rang[3] = ellchangepoint(rang[3],ellinverturst(urst));
+-if( DEBUGLEVEL_ell >= 3, print("   end of ellrank"));
++if( DEBUGLEVEL_ell >= 3, print("   end of ellQ_ellrank"));
+ 
+   return(rang);
+ }
+@@ -2106,13 +2106,13 @@ if( DEBUGLEVEL_ell >= 3, print("   end of ell2descent_viaisog"));
+ {
+ \\                  functions for elliptic curves
+   addhelp(ell2descent_complete,
+-    "ell2descent_complete(e1,e2,e3): Performs a complete 2-descent on the elliptic curve y^2 = (x-e1)*(x-e2)*(x-e3). See ?ellrank for the format of the output.");
++    "ell2descent_complete(e1,e2,e3): Performs a complete 2-descent on the elliptic curve y^2 = (x-e1)*(x-e2)*(x-e3). See ?ellQ_ellrank for the format of the output.");
+   addhelp(ell2descent_gen,
+-    "ell2descent_gen((E,bnf,k=1,help=[]): E is a vector of the form [0,A,0,B,C], (or the result of ellinit of such a vector) A,B,C integers such that x^3+A*x^2+B*x+C; bnf is the corresponding bnfinit(,1); Performs 2-descent on the elliptic curve Ek: k*y^2=x^3+A*x^2+B*x+C. See ?ellrank for the format of the output.");
++    "ell2descent_gen((E,bnf,k=1,help=[]): E is a vector of the form [0,A,0,B,C], (or the result of ellinit of such a vector) A,B,C integers such that x^3+A*x^2+B*x+C; bnf is the corresponding bnfinit(,1); Performs 2-descent on the elliptic curve Ek: k*y^2=x^3+A*x^2+B*x+C. See ?ellQ_ellrank for the format of the output.");
+   addhelp(ell2descent_viaisog,
+-    "ell2descent_viaisog(E,help=[]): E is an elliptic curve of the form [0,a,0,b,0], with a, b integers. Performs a 2-descent via isogeny on E. See ?ellrank for the format of the output.");
+-  addhelp(ellrank,
+-    "ellrank(E,help=[]): E is any elliptic curve defined over Q. Returns a vector [r,s,v], where r is a lower bound for the rank of E, s is the rank of its 2-Selmer group and v is a list of independant points in E(Q)/2E(Q). If help is a vector of nontrivial points on E, the result might be faster. This function might be used in conjunction with elltors2(E). See also ?default_ellQ");
++    "ell2descent_viaisog(E,help=[]): E is an elliptic curve of the form [0,a,0,b,0], with a, b integers. Performs a 2-descent via isogeny on E. See ?ellQ_ellrank for the format of the output.");
++  addhelp(ellQ_ellrank,
++    "ellQ_ellrank(E,help=[]): E is any elliptic curve defined over Q. Returns a vector [r,s,v], where r is a lower bound for the rank of E, s is the rank of its 2-Selmer group and v is a list of independant points in E(Q)/2E(Q). If help is a vector of nontrivial points on E, the result might be faster. This function might be used in conjunction with elltors2(E). See also ?default_ellQ");
+   addhelp(ellhalf,
+     "ellhalf(E,P): returns the vector of all points Q on the elliptic curve E such that 2Q = P");
+   addhelp(ellredgen,
+@@ -2143,7 +2143,7 @@ if( DEBUGLEVEL_ell >= 3, print("   end of ell2descent_viaisog"));
+ 
+ \\                  others
+   addhelp(default_ellQ,
+-    "default_ellQ(DEBUGLEVEL_ell, LIM1, LIM3, LIMTRIV, ELLREDGENFLAG, COMPLETE, MAXPROB, LIMBIGPRIME): set the value of the global variables used for ellrank() and other related functions. DEBUGLEVEL_ell: 0-5: choose the quantity of information printed during the computation (default=0: print nothing); LIM1 (resp LIM3): search limit for easy (resp hard) points on quartics; LIMTRIV: search limit for trivial points on elliptic curves; ELLREDGENFLAG: if != 0, try to reduce the generators at the end; COMPLETE: if != 0 and full 2-torsion, use complete 2-descent, otherwise via 2-isogeny; MAXPROB, LIMBIGPRIME: technical.");
++    "default_ellQ(DEBUGLEVEL_ell, LIM1, LIM3, LIMTRIV, ELLREDGENFLAG, COMPLETE, MAXPROB, LIMBIGPRIME): set the value of the global variables used for ellQ_ellrank() and other related functions. DEBUGLEVEL_ell: 0-5: choose the quantity of information printed during the computation (default=0: print nothing); LIM1 (resp LIM3): search limit for easy (resp hard) points on quartics; LIMTRIV: search limit for trivial points on elliptic curves; ELLREDGENFLAG: if != 0, try to reduce the generators at the end; COMPLETE: if != 0 and full 2-torsion, use complete 2-descent, otherwise via 2-isogeny; MAXPROB, LIMBIGPRIME: technical.");
+ /*  addhelp(DEBUGLEVEL_ell,
+     "DEBUGLEVEL_ell: Choose a higher value of this global variable to have more details of the computations printed during the 2-descent algorithm. 0 = don't print anything; 1 = (default) just print the result; 2 = print more details including the Selmer group and the nontrivial quartics.");
+ */
+diff --git a/src/sage/ext_data/pari/simon/qfsolve.gp b/src/sage/ext_data/pari/simon/qfsolve.gp
+index 501fb50828..2107288c1d 100644
+--- a/src/sage/ext_data/pari/simon/qfsolve.gp
++++ b/src/sage/ext_data/pari/simon/qfsolve.gp
+@@ -434,146 +434,6 @@ my(cc);
+ return([U3~*G3*U3,red[2]*U1*U2*U3]);
+ }
+ 
+-\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+-\\        QUADRATIC FORMS MINIMIZATION         \\
+-\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+-
+-\\ Minimization of the quadratic form G, with nonzero determinant.
+-\\ of dimension n>=2.
+-\\ G must by symmetric and have integral coefficients.
+-\\ Returns [G',U,factd] with U in GLn(Q) such that G'=U~*G*U*constant
+-\\ is integral and has minimal determinant.
+-\\ In dimension 3 or 4, may return a prime p
+-\\ if the reduction at p is impossible because of the local non solvability.
+-\\ If given, factdetG must be equal to factor(abs(det(G))).
+-{qfminimize(G,factdetG) =
+-my(factd,U,Ker,Ker2,sol,aux,di);
+-my(p);
+-my(n,lf,i,vp,dimKer,dimKer2,m);
+-
+-  n = length(G);
+-  factd = matrix(0,2);
+-  if( !factdetG, factdetG = factor(matdet(G)));
+-
+-  lf = length(factdetG[,1]);
+-  i = 1; U = matid(n);
+-
+-  while(i <= lf,
+-    vp = factdetG[i,2];
+-    if( vp == 0, i++; next);
+-    p = factdetG[i,1];
+-    if( p == -1, i++; next);
+-if( DEBUGLEVEL_qfsolve >= 4, print("    p = ",p,"^",vp));
+-
+-\\ The case vp = 1 can be minimized only if n is odd.
+-    if( vp == 1 && n%2 == 0,
+-      factd = concat(factd~, Mat([p,1])~)~;
+-      i++; next
+-    );
+-    Ker = kermodp(G,p); dimKer = Ker[1]; Ker = Ker[2];
+-
+-\\ Rem: we must have dimKer <= vp
+-if( DEBUGLEVEL_qfsolve >= 4, print("    dimKer = ",dimKer));
+-\\ trivial case: dimKer = n
+-    if( dimKer == n, 
+-if( DEBUGLEVEL_qfsolve >= 4, print("     case 0: dimKer = n"));
+-      G /= p;
+-      factdetG[i,2] -= n;
+-      next
+-    );
+-    G = Ker~*G*Ker;
+-    U = U*Ker;
+-
+-\\ 1st case: dimKer < vp
+-\\ then the kernel mod p contains a kernel mod p^2
+-    if( dimKer < vp,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 1: dimker < vp"));
+-      if( dimKer == 1,
+-\\        G[,1] /= p; G[1,] /= p;
+-        G[,1] /= p; G[1,] = G[1,]/p;
+-        U[,1] /= p;
+-        factdetG[i,2] -= 2
+-      , 
+-        Ker2 = kermodp(matrix(dimKer,dimKer,j,k,G[j,k]/p),p);
+-        dimKer2 = Ker2[1]; Ker2 = Ker2[2];
+-        for( j = 1, dimKer2, Ker2[,j] /= p);
+-        Ker2 = matdiagonalblock([Ker2,matid(n-dimKer)]);
+-        G = Ker2~*G*Ker2;
+-        U = U*Ker2;
+-        factdetG[i,2] -= 2*dimKer2
+-);
+-
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 1"));
+-      next
+-    );
+-
+-\\ Now, we have vp = dimKer 
+-\\ 2nd case: the dimension of the kernel is >=2
+-\\ and contains an element of norm 0 mod p^2
+-
+-\\ search for an element of norm p^2... in the kernel
+-    if( dimKer > 2 || 
+-       (dimKer == 2 && issquare( di = Mod((G[1,2]^2-G[1,1]*G[2,2])/p^2,p))),
+-      if( dimKer > 2,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 2.1"));
+-        dimKer = 3;
+-        sol = qfsolvemodp(matrix(3,3,j,k,G[j,k]/p),p)
+-      ,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 2.2"));
+-        if( G[1,1]%p^2 == 0, 
+-          sol = [1,0]~
+-        , sol = [-G[1,2]/p+sqrt(di),Mod(G[1,1]/p,p)]~
+-        )
+-      );
+-      sol = centerlift(sol);
+-      sol /= content(sol);
+-if( DEBUGLEVEL_qfsolve >= 4, print("    sol = ",sol));
+-      Ker = vectorv(n, j, if( j<= dimKer, sol[j], 0)); \\ fill with 0's
+-      Ker = completebasis(Ker,1);
+-      Ker[,n] /= p;
+-      G = Ker~*G*Ker;
+-      U = U*Ker;
+-      factdetG[i,2] -= 2;
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 2"));
+-      next
+-    );
+-
+-\\ Now, we have vp = dimKer <= 2 
+-\\   and the kernel contains no vector with norm p^2...
+-
+-\\ In some cases, exchanging the kernel and the image
+-\\ makes the minimization easy.
+-
+-    m = (n-1)\2-1;
+-    if( ( vp == 1 && issquare(Mod(-(-1)^m*matdet(G)/G[1,1],p)))
+-     || ( vp == 2 && n%2 == 1 && n >= 5)
+-     || ( vp == 2 && n%2 == 0 && !issquare(Mod((-1)^m*matdet(G)/p^2,p)))
+-    , 
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 3"));
+-      Ker = matid(n);
+-      for( j = dimKer+1, n, Ker[j,j] = p);
+-      G = Ker~*G*Ker/p;
+-      U = U*Ker;
+-      factdetG[i,2] -= 2*dimKer-n;
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 3"));
+-      next
+-    );
+-
+-\\ Minimization was not possible se far.
+-\\ If n == 3 or 4, this proves the local non-solubility at p.
+-    if( n == 3 || n == 4, 
+-if( DEBUGLEVEL_qfsolve >= 1, print(" no local solution at ",p));
+-      return(p));
+-
+-if( DEBUGLEVEL_qfsolve >= 4, print("    prime ",p," finished"));
+-    factd = concat(factd~,Mat([p,vp])~)~;
+-    i++
+-  );
+-\\ apply LLL to avoid coefficients explosion
+-  aux = qflll(U/content(U));
+-return([aux~*G*aux,U*aux,factd]);
+-}
+-
+ \\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+ \\          CLASS GROUP COMPUTATIONS           \\
+ \\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+diff --git a/src/sage/geometry/polyhedron/backend_field.py b/src/sage/geometry/polyhedron/backend_field.py
+index 6b921d23a6..2f32c58b1e 100644
+--- a/src/sage/geometry/polyhedron/backend_field.py
++++ b/src/sage/geometry/polyhedron/backend_field.py
+@@ -265,7 +265,7 @@ class Polyhedron_field(Polyhedron_base):
+              An inequality (-0.1419794359520263?, -1.698172434277148?) x + 1.200789243901438? >= 0,
+              An inequality (0.3001973109753594?, 0.600394621950719?) x - 0.4245431085692869? >= 0)
+             sage: p.Vrepresentation()                                           # optional - sage.rings.number_field
+-            (A vertex at (0.?e-15, 0.707106781186548?),
++            (A vertex at (0.?e-16, 0.7071067811865475?),
+              A vertex at (1.414213562373095?, 0),
+              A vertex at (4.000000000000000?, 0.372677996249965?))
+         """
+@@ -308,7 +308,7 @@ class Polyhedron_field(Polyhedron_base):
+              An inequality (-0.1419794359520263?, -1.698172434277148?) x + 1.200789243901438? >= 0,
+              An inequality (0.3001973109753594?, 0.600394621950719?) x - 0.4245431085692869? >= 0)
+             sage: p.Vrepresentation()                                           # optional - sage.rings.number_field
+-            (A vertex at (0.?e-15, 0.707106781186548?),
++            (A vertex at (0.?e-16, 0.7071067811865475?),
+              A vertex at (1.414213562373095?, 0),
+              A vertex at (4.000000000000000?, 0.372677996249965?))
+         """
+diff --git a/src/sage/geometry/polyhedron/backend_normaliz.py b/src/sage/geometry/polyhedron/backend_normaliz.py
+index 86b89632a5..ca8a43b248 100644
+--- a/src/sage/geometry/polyhedron/backend_normaliz.py
++++ b/src/sage/geometry/polyhedron/backend_normaliz.py
+@@ -53,7 +53,7 @@ def _number_field_elements_from_algebraics_list_of_lists_of_lists(listss, **kwds
+         1.732050807568878?
+         sage: from sage.geometry.polyhedron.backend_normaliz import _number_field_elements_from_algebraics_list_of_lists_of_lists
+         sage: K, results, hom = _number_field_elements_from_algebraics_list_of_lists_of_lists([[[rt2], [1]], [[rt3]], [[1], []]]); results  # optional - sage.rings.number_field
+-        [[[-a^3 + 3*a], [1]], [[-a^2 + 2]], [[1], []]]
++        [[[-a^3 + 3*a], [1]], [[a^2 - 2]], [[1], []]]
+     """
+     from sage.rings.qqbar import number_field_elements_from_algebraics
+     numbers = []
+diff --git a/src/sage/groups/matrix_gps/isometries.py b/src/sage/groups/matrix_gps/isometries.py
+index f9111a2c92..cca45e7175 100644
+--- a/src/sage/groups/matrix_gps/isometries.py
++++ b/src/sage/groups/matrix_gps/isometries.py
+@@ -11,11 +11,11 @@ EXAMPLES::
+     sage: L = IntegralLattice("D4")
+     sage: O = L.orthogonal_group()
+     sage: O
+-    Group of isometries with 5 generators (
+-    [-1  0  0  0]  [0 0 0 1]  [-1 -1 -1 -1]  [ 1  1  0  0]  [ 1  0  0  0]
+-    [ 0 -1  0  0]  [0 1 0 0]  [ 0  0  1  0]  [ 0  0  1  0]  [-1 -1 -1 -1]
+-    [ 0  0 -1  0]  [0 0 1 0]  [ 0  1  0  1]  [ 0  1  0  1]  [ 0  0  1  0]
+-    [ 0  0  0 -1], [1 0 0 0], [ 0 -1 -1  0], [ 0 -1 -1  0], [ 0  0  0  1]
++    Group of isometries with 3 generators (
++    [0 0 0 1]  [ 1  1  0  0]  [ 1  0  0  0]
++    [0 1 0 0]  [ 0  0  1  0]  [-1 -1 -1 -1]
++    [0 0 1 0]  [ 0  1  0  1]  [ 0  0  1  0]
++    [1 0 0 0], [ 0 -1 -1  0], [ 0  0  0  1]
+     )
+ 
+ Basic functionality is provided by GAP::
+diff --git a/src/sage/interfaces/genus2reduction.py b/src/sage/interfaces/genus2reduction.py
+index 56ae04b235..7a4794daf2 100644
+--- a/src/sage/interfaces/genus2reduction.py
++++ b/src/sage/interfaces/genus2reduction.py
+@@ -143,31 +143,31 @@ class ReductionData(SageObject):
+        sur un corps de valuation discrète", Trans. AMS 348 (1996),
+        4577-4610, Section 7.2, Proposition 4).
+     """
+-    def __init__(self, pari_result, P, Q, minimal_equation, minimal_disc,
+-                 local_data, conductor, prime_to_2_conductor_only):
++    def __init__(self, pari_result, P, Q, Pmin, Qmin, minimal_disc,
++                 local_data, conductor):
+         self.pari_result = pari_result
+         self.P = P
+         self.Q = Q
+-        self.minimal_equation = minimal_equation
++        self.Pmin = Pmin
++        self.Qmin = Qmin
+         self.minimal_disc = minimal_disc
+         self.local_data = local_data
+         self.conductor = conductor
+-        self.prime_to_2_conductor_only = prime_to_2_conductor_only
+ 
+     def _repr_(self):
+-        if self.prime_to_2_conductor_only:
+-            ex = ' (away from 2)'
+-        else:
+-            ex = ''
+         if self.Q == 0:
+             yterm = ''
+         else:
+             yterm = '+ (%s)*y '%self.Q
++
+         s = 'Reduction data about this proper smooth genus 2 curve:\n'
+         s += '\ty^2 %s= %s\n'%(yterm, self.P)
+-        s += 'A Minimal Equation (away from 2):\n\ty^2 = %s\n'%self.minimal_equation
+-        s += 'Minimal Discriminant (away from 2):  %s\n'%self.minimal_disc
+-        s += 'Conductor%s: %s\n'%(ex, self.conductor)
++        if self.Qmin:
++            s += 'A Minimal Equation:\n\ty^2 + (%s)y = %s\n'%(self.Qmin, self.Pmin)
++        else:
++            s += 'A Minimal Equation:\n\ty^2 = %s\n'%self.Pmin
++        s += 'Minimal Discriminant: %s\n'%self.minimal_disc
++        s += 'Conductor: %s\n'%self.conductor
+         s += 'Local Data:\n%s'%self._local_data_str()
+         return s
+ 
+@@ -242,17 +242,7 @@ class Genus2reduction(SageObject):
+         sage: factor(R.conductor)
+         5^4 * 2267
+ 
+-    This means that only the odd part of the conductor is known.
+-
+-    ::
+-
+-        sage: R.prime_to_2_conductor_only
+-        True
+-
+-    The discriminant is always minimal away from 2, but possibly not at
+-    2.
+-
+-    ::
++    The discriminant is always minimal::
+ 
+         sage: factor(R.minimal_disc)
+         2^3 * 5^5 * 2267
+@@ -264,10 +254,10 @@ class Genus2reduction(SageObject):
+         sage: R
+         Reduction data about this proper smooth genus 2 curve:
+             y^2 + (x^3 - 2*x^2 - 2*x + 1)*y = -5*x^5
+-        A Minimal Equation (away from 2):
+-            y^2 = x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855
+-        Minimal Discriminant (away from 2):  56675000
+-        Conductor (away from 2): 1416875
++        A Minimal Equation:
++            y^2 ...
++        Minimal Discriminant: 56675000
++        Conductor: 1416875
+         Local Data:
+             p=2
+             (potential) stable reduction:  (II), j=1
+@@ -293,10 +283,10 @@ class Genus2reduction(SageObject):
+         sage: genus2reduction(0, x^6 + 3*x^3 + 63)
+         Reduction data about this proper smooth genus 2 curve:
+                 y^2 = x^6 + 3*x^3 + 63
+-        A Minimal Equation (away from 2):
+-                y^2 = x^6 + 3*x^3 + 63
+-        Minimal Discriminant (away from 2):  10628388316852992
+-        Conductor (away from 2): 2893401
++        A Minimal Equation:
++                y^2 ...
++        Minimal Discriminant: -10628388316852992
++        Conductor: 2893401
+         Local Data:
+                 p=2
+                 (potential) stable reduction:  (V), j1+j2=0, j1*j2=0
+@@ -327,9 +317,9 @@ class Genus2reduction(SageObject):
+         sage: genus2reduction(x^3-x^2-1, x^2 - x)
+         Reduction data about this proper smooth genus 2 curve:
+                 y^2 + (x^3 - x^2 - 1)*y = x^2 - x
+-        A Minimal Equation (away from 2):
+-                y^2 = x^6 + 58*x^5 + 1401*x^4 + 18038*x^3 + 130546*x^2 + 503516*x + 808561
+-        Minimal Discriminant (away from 2):  169
++        A Minimal Equation:
++                y^2 ...
++        Minimal Discriminant: -169
+         Conductor: 169
+         Local Data:
+                 p=13
+@@ -370,10 +360,10 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^3 - 2*x^2 - 2*x + 1, -5*x^5)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^3 - 2*x^2 - 2*x + 1)*y = -5*x^5
+-            A Minimal Equation (away from 2):
+-                    y^2 = x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855
+-            Minimal Discriminant (away from 2):  56675000
+-            Conductor (away from 2): 1416875
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 56675000
++            Conductor: 1416875
+             Local Data:
+                     p=2
+                     (potential) stable reduction:  (II), j=1
+@@ -389,9 +379,9 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^2 + 1, -5*x^5)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^2 + 1)*y = -5*x^5
+-            A Minimal Equation (away from 2):
+-                    y^2 = -20*x^5 + x^4 + 2*x^2 + 1
+-            Minimal Discriminant (away from 2):  48838125
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 48838125
+             Conductor: 32025
+             Local Data:
+                     p=3
+@@ -412,9 +402,9 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^3 + x^2 + x,-2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^3 + x^2 + x)*y = -2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2
+-            A Minimal Equation (away from 2):
+-                    y^2 = x^6 + 18*x^3 + 36*x^2 - 27
+-            Minimal Discriminant (away from 2):  1520984142
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 1520984142
+             Conductor: 954
+             Local Data:
+                     p=2
+@@ -436,18 +426,10 @@ class Genus2reduction(SageObject):
+             raise ValueError("Q (=%s) must have degree at most 3" % Q)
+ 
+         res = pari.genus2red([P, Q])
+-
+         conductor = ZZ(res[0])
+-        minimal_equation = R(res[2])
+-
+-        minimal_disc = QQ(res[2].poldisc()).abs()
+-        if minimal_equation.degree() == 5:
+-            minimal_disc *= minimal_equation[5]**2
+-        # Multiply with suitable power of 2 of the form 2^(2*(d-1) - 12)
+-        b = 2 * (minimal_equation.degree() - 1)
+-        k = QQ((12 - minimal_disc.valuation(2), b)).ceil()
+-        minimal_disc >>= 12 - b*k
+-        minimal_disc = ZZ(minimal_disc)
++        Pmin = R(res[2][0])
++        Qmin = R(res[2][1])
++        minimal_disc = ZZ(pari.hyperelldisc(res[2]))
+ 
+         local_data = {}
+         for red in res[3]:
+@@ -468,9 +450,7 @@ class Genus2reduction(SageObject):
+ 
+             local_data[p] = data
+ 
+-        prime_to_2_conductor_only = (-1 in res[1].component(2))
+-        return ReductionData(res, P, Q, minimal_equation, minimal_disc, local_data,
+-                             conductor, prime_to_2_conductor_only)
++        return ReductionData(res, P, Q, Pmin, Qmin, minimal_disc, local_data, conductor)
+ 
+     def __reduce__(self):
+         return _reduce_load_genus2reduction, tuple([])
+diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
+index fec450d7bc..236402c293 100644
+--- a/src/sage/lfunctions/dokchitser.py
++++ b/src/sage/lfunctions/dokchitser.py
+@@ -337,6 +337,7 @@ class Dokchitser(SageObject):
+             # After init_coeffs is called, future calls to this method should
+             # return the full output for further parsing
+             raise RuntimeError("unable to create L-series, due to precision or other limits in PARI")
++        t = t.replace("  *** _^_: Warning: normalizing a series with 0 leading term.\n", "")
+         return t
+ 
+     def __check_init(self):
+diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
+index d2b20f1891..6c31efe239 100644
+--- a/src/sage/lfunctions/pari.py
++++ b/src/sage/lfunctions/pari.py
+@@ -339,7 +339,7 @@ def lfun_eta_quotient(scalings, exponents):
+         0.0374412812685155
+ 
+         sage: lfun_eta_quotient([6],[4])
+-        [[Vecsmall([7]), [Vecsmall([6]), Vecsmall([4])]], 0, [0, 1], 2, 36, 1]
++        [[Vecsmall([7]), [Vecsmall([6]), Vecsmall([4]), 0]], 0, [0, 1], 2, 36, 1]
+ 
+         sage: lfun_eta_quotient([2,1,4], [5,-2,-2])
+         Traceback (most recent call last):
+diff --git a/src/sage/libs/pari/tests.py b/src/sage/libs/pari/tests.py
+index e5a2aa2517..0efcb15de0 100644
+--- a/src/sage/libs/pari/tests.py
++++ b/src/sage/libs/pari/tests.py
+@@ -356,7 +356,7 @@ Constructors::
+     [2, 4]~*x + [1, 3]~
+ 
+     sage: pari(3).Qfb(7, 1)
+-    Qfb(3, 7, 1, 0.E-19)
++    Qfb(3, 7, 1)
+     sage: pari(3).Qfb(7, 2)
+     Traceback (most recent call last):
+     ...
+@@ -512,7 +512,7 @@ Basic functions::
+     sage: pari('sqrt(-2)').frac()
+     Traceback (most recent call last):
+     ...
+-    PariError: incorrect type in gfloor (t_COMPLEX)
++    PariError: incorrect type in gfrac (t_COMPLEX)
+ 
+     sage: pari('1+2*I').imag()
+     2
+diff --git a/src/sage/modular/cusps_nf.py b/src/sage/modular/cusps_nf.py
+index 25d93cac92..157ebabe29 100644
+--- a/src/sage/modular/cusps_nf.py
++++ b/src/sage/modular/cusps_nf.py
+@@ -1220,7 +1220,7 @@ def units_mod_ideal(I):
+         sage: I = k.ideal(5, a + 1)
+         sage: units_mod_ideal(I)
+         [1,
+-        2*a^2 + 4*a - 1,
++        -2*a^2 - 4*a + 1,
+         ...]
+ 
+     ::
+diff --git a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
+index a881336596..090d1bfaf0 100644
+--- a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
++++ b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
+@@ -43,7 +43,7 @@ def coerce_AA(p):
+         sage: AA(p)._exact_field()
+         Number Field in a with defining polynomial y^8 ... with a in ...
+         sage: coerce_AA(p)._exact_field()
+-        Number Field in a with defining polynomial y^4 - 1910*y^2 - 3924*y + 681058 with a in 39.710518724...?
++        Number Field in a with defining polynomial y^4 - 1910*y^2 - 3924*y + 681058 with a in ...?
+     """
+     el = AA(p)
+     el.simplify()
+diff --git a/src/sage/modular/modsym/p1list_nf.py b/src/sage/modular/modsym/p1list_nf.py
+index 222caacca8..f9d969732c 100644
+--- a/src/sage/modular/modsym/p1list_nf.py
++++ b/src/sage/modular/modsym/p1list_nf.py
+@@ -58,7 +58,7 @@ Lift an MSymbol to a matrix in `SL(2, R)`:
+ 
+     sage: alpha = MSymbol(N, a + 2, 3*a^2)
+     sage: alpha.lift_to_sl2_Ok()
+-    [-3*a^2 + a + 12, 25*a^2 - 50*a + 100, a + 2, a^2 - 3*a + 3]
++    [-1, 4*a^2 - 13*a + 23, a + 2, 5*a^2 + 3*a - 3]
+     sage: Ok = k.ring_of_integers()
+     sage: M = Matrix(Ok, 2, alpha.lift_to_sl2_Ok())
+     sage: det(M)
+@@ -945,11 +945,11 @@ class P1NFList(SageObject):
+             sage: N = k.ideal(5, a + 1)
+             sage: P = P1NFList(N)
+             sage: u = k.unit_group().gens_values(); u
+-            [-1, 2*a^2 + 4*a - 1]
++            [-1, -2*a^2 - 4*a + 1]
+             sage: P.apply_J_epsilon(4, -1)
+             2
+             sage: P.apply_J_epsilon(4, u[0], u[1])
+-            1
++            5
+ 
+         ::
+ 
+diff --git a/src/sage/modules/free_quadratic_module_integer_symmetric.py b/src/sage/modules/free_quadratic_module_integer_symmetric.py
+index a206f0c721..aeb19ab669 100644
+--- a/src/sage/modules/free_quadratic_module_integer_symmetric.py
++++ b/src/sage/modules/free_quadratic_module_integer_symmetric.py
+@@ -1168,11 +1168,11 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+             sage: A4 = IntegralLattice("A4")
+             sage: Aut = A4.orthogonal_group()
+             sage: Aut
+-            Group of isometries with 5 generators (
+-            [-1  0  0  0]  [0 0 0 1]  [-1 -1 -1  0]  [ 1  0  0  0]  [ 1  0  0  0]
+-            [ 0 -1  0  0]  [0 0 1 0]  [ 0  0  0 -1]  [-1 -1 -1 -1]  [ 0  1  0  0]
+-            [ 0  0 -1  0]  [0 1 0 0]  [ 0  0  1  1]  [ 0  0  0  1]  [ 0  0  1  1]
+-            [ 0  0  0 -1], [1 0 0 0], [ 0  1  0  0], [ 0  0  1  0], [ 0  0  0 -1]
++            Group of isometries with 4 generators (
++            [0 0 0 1]  [-1 -1 -1  0]  [ 1  0  0  0]  [ 1  0  0  0]
++            [0 0 1 0]  [ 0  0  0 -1]  [-1 -1 -1 -1]  [ 0  1  0  0]
++            [0 1 0 0]  [ 0  0  1  1]  [ 0  0  0  1]  [ 0  0  1  1]
++            [1 0 0 0], [ 0  1  0  0], [ 0  0  1  0], [ 0  0  0 -1]
+             )
+ 
+         The group acts from the right on the lattice and its discriminant group::
+@@ -1180,19 +1180,19 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+             sage: x = A4.an_element()
+             sage: g = Aut.an_element()
+             sage: g
+-            [ 1  1  1  0]
+-            [ 0  0 -1  0]
+-            [ 0  0  1  1]
+-            [ 0 -1 -1 -1]
++            [-1 -1 -1  0]
++            [ 0  0  1  0]
++            [ 0  0 -1 -1]
++            [ 0  1  1  1]
+             sage: x*g
+-            (1, 1, 1, 0)
++            (-1, -1, -1, 0)
+             sage: (x*g).parent()==A4
+             True
+             sage: (g*x).parent()
+             Vector space of dimension 4 over Rational Field
+             sage: y = A4.discriminant_group().an_element()
+             sage: y*g
+-            (1)
++            (4)
+ 
+         If the group is finite we can compute the usual things::
+ 
+@@ -1208,10 +1208,10 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+ 
+             sage: A2 = IntegralLattice(matrix.identity(3),Matrix(ZZ,2,3,[1,-1,0,0,1,-1]))
+             sage: A2.orthogonal_group()
+-            Group of isometries with 3 generators (
+-            [-1/3  2/3  2/3]  [ 2/3  2/3 -1/3]  [1 0 0]
+-            [ 2/3 -1/3  2/3]  [ 2/3 -1/3  2/3]  [0 0 1]
+-            [ 2/3  2/3 -1/3], [-1/3  2/3  2/3], [0 1 0]
++            Group of isometries with 2 generators (
++            [ 2/3  2/3 -1/3]  [1 0 0]
++            [ 2/3 -1/3  2/3]  [0 0 1]
++            [-1/3  2/3  2/3], [0 1 0]
+             )
+ 
+         It can be negative definite as well::
+diff --git a/src/sage/quadratic_forms/binary_qf.py b/src/sage/quadratic_forms/binary_qf.py
+index cfa3ada73e..5ac823bc6c 100755
+--- a/src/sage/quadratic_forms/binary_qf.py
++++ b/src/sage/quadratic_forms/binary_qf.py
+@@ -141,7 +141,7 @@ class BinaryQF(SageObject):
+                   and a.degree() == 2 and a.parent().ngens() == 2):
+                 x, y = a.parent().gens()
+                 a, b, c = [a.monomial_coefficient(mon) for mon in [x**2, x*y, y**2]]
+-            elif isinstance(a, pari_gen) and a.type() in ('t_QFI', 't_QFR'):
++            elif isinstance(a, pari_gen) and a.type() in ('t_QFI', 't_QFR', 't_QFB'):
+                 # a has 3 or 4 components
+                 a, b, c = a[0], a[1], a[2]
+         try:
+diff --git a/src/sage/quadratic_forms/genera/genus.py b/src/sage/quadratic_forms/genera/genus.py
+index 8290b6c4fa..0fc43f33c6 100644
+--- a/src/sage/quadratic_forms/genera/genus.py
++++ b/src/sage/quadratic_forms/genera/genus.py
+@@ -3088,8 +3088,8 @@ class GenusSymbol_global_ring():
+             sage: G = Genus(matrix(ZZ, 3, [6,3,0, 3,6,0, 0,0,2]))
+             sage: G.representatives()
+             (
+-            [2 0 0]  [ 2 -1  0]
+-            [0 6 3]  [-1  2  0]
++            [2 0 0]  [ 2  1  0]
++            [0 6 3]  [ 1  2  0]
+             [0 3 6], [ 0  0 18]
+             )
+ 
+diff --git a/src/sage/quadratic_forms/qfsolve.py b/src/sage/quadratic_forms/qfsolve.py
+index ddde95e04f..d5e15d9f83 100644
+--- a/src/sage/quadratic_forms/qfsolve.py
++++ b/src/sage/quadratic_forms/qfsolve.py
+@@ -70,7 +70,7 @@ def qfsolve(G):
+ 
+         sage: M = Matrix(QQ, [[3, 0, 0, 0], [0, 5, 0, 0], [0, 0, -7, 0], [0, 0, 0, -11]])
+         sage: qfsolve(M)
+-        (3, -4, -3, -2)
++        (3, 4, -3, -2)
+     """
+     ret = G.__pari__().qfsolve()
+     if ret.type() == 't_COL':
+diff --git a/src/sage/quadratic_forms/quadratic_form__automorphisms.py b/src/sage/quadratic_forms/quadratic_form__automorphisms.py
+index c36c667e3b..3d72cf3be1 100644
+--- a/src/sage/quadratic_forms/quadratic_form__automorphisms.py
++++ b/src/sage/quadratic_forms/quadratic_form__automorphisms.py
+@@ -300,9 +300,9 @@ def automorphism_group(self):
+         sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1])
+         sage: Q.automorphism_group()
+         Matrix group over Rational Field with 3 generators (
+-        [-1  0  0]  [0 0 1]  [ 0  0  1]
+-        [ 0 -1  0]  [0 1 0]  [-1  0  0]
+-        [ 0  0 -1], [1 0 0], [ 0  1  0]
++        [ 0  0  1]  [1 0 0]  [ 1  0  0]
++        [-1  0  0]  [0 0 1]  [ 0 -1  0]
++        [ 0  1  0], [0 1 0], [ 0  0  1]
+         )
+ 
+     ::
+diff --git a/src/sage/rings/finite_rings/finite_field_prime_modn.py b/src/sage/rings/finite_rings/finite_field_prime_modn.py
+index 9129ecb56a..d5a4cb8f22 100644
+--- a/src/sage/rings/finite_rings/finite_field_prime_modn.py
++++ b/src/sage/rings/finite_rings/finite_field_prime_modn.py
+@@ -111,7 +111,7 @@ class FiniteField_prime_modn(FiniteField_generic, integer_mod_ring.IntegerModRin
+             sage: RF13 = K.residue_field(pp)
+             sage: RF13.hom([GF(13)(1)])
+             Ring morphism:
+-             From: Residue field of Fractional ideal (w + 18)
++             From: Residue field of Fractional ideal (-w - 18)
+              To:   Finite Field of size 13
+              Defn: 1 |--> 1
+ 
+diff --git a/src/sage/rings/finite_rings/residue_field.pyx b/src/sage/rings/finite_rings/residue_field.pyx
+index 7596f2a302..1e1869f1b1 100644
+--- a/src/sage/rings/finite_rings/residue_field.pyx
++++ b/src/sage/rings/finite_rings/residue_field.pyx
+@@ -20,13 +20,13 @@ monogenic (i.e., 2 is an essential discriminant divisor)::
+ 
+     sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8)
+     sage: F = K.factor(2); F
+-    (Fractional ideal (1/2*a^2 - 1/2*a + 1)) * (Fractional ideal (-a^2 + 2*a - 3)) * (Fractional ideal (-3/2*a^2 + 5/2*a - 4))
++    (Fractional ideal (-1/2*a^2 + 1/2*a - 1)) * (Fractional ideal (-a^2 + 2*a - 3)) * (Fractional ideal (3/2*a^2 - 5/2*a + 4))
+     sage: F[0][0].residue_field()
+-    Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++    Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+     sage: F[1][0].residue_field()
+     Residue field of Fractional ideal (-a^2 + 2*a - 3)
+     sage: F[2][0].residue_field()
+-    Residue field of Fractional ideal (-3/2*a^2 + 5/2*a - 4)
++    Residue field of Fractional ideal (3/2*a^2 - 5/2*a + 4)
+ 
+ We can also form residue fields from `\ZZ`::
+ 
+@@ -258,9 +258,9 @@ class ResidueFieldFactory(UniqueFactory):
+     the index of ``ZZ[a]`` in the maximal order for all ``a``::
+ 
+         sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8); P = K.ideal(2).factor()[0][0]; P
+-        Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F = K.residue_field(P); F
+-        Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F(a)
+         0
+         sage: B = K.maximal_order().basis(); B
+@@ -270,7 +270,7 @@ class ResidueFieldFactory(UniqueFactory):
+         sage: F(B[2])
+         0
+         sage: F
+-        Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F.degree()
+         1
+ 
+@@ -730,15 +730,15 @@ class ResidueField_generic(Field):
+         EXAMPLES::
+ 
+             sage: I = QQ[3^(1/3)].factor(5)[1][0]; I
+-            Fractional ideal (-a + 2)
++            Fractional ideal (a - 2)
+             sage: k = I.residue_field(); k
+-            Residue field of Fractional ideal (-a + 2)
++            Residue field of Fractional ideal (a - 2)
+             sage: f = k.lift_map(); f
+             Lifting map:
+-              From: Residue field of Fractional ideal (-a + 2)
++              From: Residue field of Fractional ideal (a - 2)
+               To:   Maximal Order in Number Field in a with defining polynomial x^3 - 3 with a = 1.442249570307409?
+             sage: f.domain()
+-            Residue field of Fractional ideal (-a + 2)
++            Residue field of Fractional ideal (a - 2)
+             sage: f.codomain()
+             Maximal Order in Number Field in a with defining polynomial x^3 - 3 with a = 1.442249570307409?
+             sage: f(k.0)
+@@ -768,7 +768,7 @@ class ResidueField_generic(Field):
+ 
+             sage: K.<a> = NumberField(x^3-11)
+             sage: F = K.ideal(37).factor(); F
+-            (Fractional ideal (37, a + 9)) * (Fractional ideal (37, a + 12)) * (Fractional ideal (2*a - 5))
++            (Fractional ideal (37, a + 9)) * (Fractional ideal (37, a + 12)) * (Fractional ideal (-2*a + 5))
+             sage: k = K.residue_field(F[0][0])
+             sage: l = K.residue_field(F[1][0])
+             sage: k == l
+@@ -846,7 +846,7 @@ cdef class ReductionMap(Map):
+             sage: F.reduction_map()
+             Partially defined reduction map:
+               From: Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
+-              To:   Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++              To:   Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+ 
+             sage: K.<theta_5> = CyclotomicField(5)
+             sage: F = K.factor(7)[0][0].residue_field()
+diff --git a/src/sage/rings/number_field/S_unit_solver.py b/src/sage/rings/number_field/S_unit_solver.py
+index e99dff850f..759cbfb334 100644
+--- a/src/sage/rings/number_field/S_unit_solver.py
++++ b/src/sage/rings/number_field/S_unit_solver.py
+@@ -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 (xi - 3),
+-         Fractional ideal (-2*xi^2 + 3),
++        (Fractional ideal (-2*xi^2 + 3),
++         Fractional ideal (-xi + 3),
+          Fractional ideal (2*xi + 1))
+ 
+         sage: sieve_data[1]
+-        (Residue field of Fractional ideal (xi - 3),
+-         Residue field of Fractional ideal (-2*xi^2 + 3),
++        (Residue field of Fractional ideal (-2*xi^2 + 3),
++         Residue field of Fractional ideal (-xi + 3),
+          Residue field of Fractional ideal (2*xi + 1))
+ 
+         sage: sieve_data[2]
+-        ([18, 7, 16, 4], [18, 9, 12, 8], [18, 3, 10, 10])
++        ([18, 12, 16, 8], [18, 16, 10, 4], [18, 10, 12, 10])
+ 
+         sage: sieve_data[3]
+-        (486, 648, 11664)
++        (648, 2916, 3888)
+     """
+ 
+     K = SUK.number_field()
+diff --git a/src/sage/rings/number_field/bdd_height.py b/src/sage/rings/number_field/bdd_height.py
+index beb047ae02..b7c8c33d0b 100644
+--- a/src/sage/rings/number_field/bdd_height.py
++++ b/src/sage/rings/number_field/bdd_height.py
+@@ -248,7 +248,7 @@ def bdd_norm_pr_ideal_gens(K, norm_list):
+         sage: from sage.rings.number_field.bdd_height import bdd_norm_pr_ideal_gens
+         sage: K.<g> = QuadraticField(123)
+         sage: bdd_norm_pr_ideal_gens(K, range(5))
+-        {0: [0], 1: [1], 2: [-g - 11], 3: [], 4: [2]}
++        {0: [0], 1: [1], 2: [g + 11], 3: [], 4: [2]}
+ 
+     ::
+ 
+diff --git a/src/sage/rings/number_field/class_group.py b/src/sage/rings/number_field/class_group.py
+index 018ff5f5c6..73c0462cd1 100644
+--- a/src/sage/rings/number_field/class_group.py
++++ b/src/sage/rings/number_field/class_group.py
+@@ -221,11 +221,11 @@ class FractionalIdealClass(AbelianGroupWithValuesElement):
+             Class group of order 76 with structure C38 x C2
+             of Number Field in a with defining polynomial x^2 + 20072
+             sage: I = (G.0)^11; I
+-            Fractional ideal class (41, 1/2*a + 5)
++            Fractional ideal class (33, 1/2*a + 8)
+             sage: J = G(I.ideal()^5); J
+-            Fractional ideal class (115856201, 1/2*a + 40407883)
++            Fractional ideal class (39135393, 1/2*a + 13654253)
+             sage: J.reduce()
+-            Fractional ideal class (57, 1/2*a + 44)
++            Fractional ideal class (73, 1/2*a + 47)
+             sage: J == I^5
+             True
+         """
+diff --git a/src/sage/rings/number_field/galois_group.py b/src/sage/rings/number_field/galois_group.py
+index 79acd053bb..e060148e4d 100644
+--- a/src/sage/rings/number_field/galois_group.py
++++ b/src/sage/rings/number_field/galois_group.py
+@@ -944,7 +944,7 @@ class GaloisGroup_v2(GaloisGroup_perm):
+             sage: K.<b> = NumberField(x^4 - 2*x^2 + 2, 'a').galois_closure()
+             sage: G = K.galois_group()
+             sage: [G.artin_symbol(P) for P in K.primes_above(7)]
+-            [(1,5)(2,6)(3,7)(4,8), (1,5)(2,6)(3,7)(4,8), (1,4)(2,3)(5,8)(6,7), (1,4)(2,3)(5,8)(6,7)]
++            [(1,4)(2,3)(5,8)(6,7), (1,4)(2,3)(5,8)(6,7), (1,5)(2,6)(3,7)(4,8), (1,5)(2,6)(3,7)(4,8)]
+             sage: G.artin_symbol(17)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
+index 58463d570d..ff65634e99 100644
+--- a/src/sage/rings/number_field/number_field.py
++++ b/src/sage/rings/number_field/number_field.py
+@@ -3643,7 +3643,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
+ 
+@@ -4227,7 +4227,8 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             (y^2 + 6, Mod(1/6*y, y^2 + 6), Mod(6*y, y^2 + 1/6))
+         """
+         f = self.absolute_polynomial()._pari_with_name('y')
+-        if f.pollead() == f.content().denominator() == 1:
++        f = f * f.content().denominator()
++        if f.pollead() == 1:
+             g = f
+             alpha = beta = g.variable().Mod(g)
+         else:
+@@ -4821,7 +4822,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+ 
+             sage: K.<a> = NumberField(2*x^2 - 1/3)
+             sage: K._S_class_group_and_units(tuple(K.primes_above(2) + K.primes_above(3)))
+-            ([-6*a + 2, 6*a + 3, -1, 12*a + 5], [])
++            ([6*a + 2, 6*a + 3, -1, -12*a + 5], [])
+         """
+         K_pari = self.pari_bnf(proof=proof)
+         S_pari = [p.pari_prime() for p in sorted(set(S))]
+@@ -5166,7 +5167,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+ 
+             sage: [K.ideal(g).factor() for g in gens]
+             [(Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1)),
+-            Fractional ideal (-a),
++            Fractional ideal (a),
+             (Fractional ideal (2, a + 1))^2,
+             1]
+ 
+@@ -5751,7 +5752,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: K.elements_of_norm(3)
+             []
+             sage: K.elements_of_norm(50)
+-            [-7*a + 1, 5*a - 5, 7*a + 1]
++            [-a - 7, 5*a - 5, 7*a + 1]
+ 
+         TESTS:
+ 
+@@ -5863,7 +5864,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: K.factor(1+a)
+             Fractional ideal (a + 1)
+             sage: K.factor(1+a/5)
+-            (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1 * (Fractional ideal (-3*a - 2))
++            (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1 * (Fractional ideal (-2*a + 3))
+ 
+         An example over a relative number field::
+ 
+@@ -6460,9 +6461,9 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: new_basis = k.reduced_basis(prec=120)
+             sage: [c.minpoly() for c in new_basis]
+             [x - 1,
+-             x^2 - x + 1,
++             x^2 + x + 1,
++             x^6 + 3*x^5 - 102*x^4 - 103*x^3 + 10572*x^2 - 59919*x + 127657,
+              x^6 + 3*x^5 - 102*x^4 - 103*x^3 + 10572*x^2 - 59919*x + 127657,
+-             x^6 - 3*x^5 - 102*x^4 + 315*x^3 + 10254*x^2 - 80955*x + 198147,
+              x^3 - 171*x + 848,
+              x^6 + 171*x^4 + 1696*x^3 + 29241*x^2 + 145008*x + 719104]
+             sage: R = k.order(new_basis)
+@@ -7058,7 +7059,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+              -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)
++             2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7)
+ 
+         TESTS:
+ 
+@@ -7067,7 +7068,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)
+ 
+@@ -7146,7 +7147,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^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]
++            [-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, 2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7]
+         """
+         proof = proof_flag(proof)
+ 
+diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx
+index 784c239dc1..aa740069dc 100644
+--- a/src/sage/rings/number_field/number_field_element.pyx
++++ b/src/sage/rings/number_field/number_field_element.pyx
+@@ -4446,7 +4446,7 @@ cdef class NumberFieldElement(FieldElement):
+             sage: f = Qi.embeddings(K)[0]
+             sage: a = f(2+3*i) * (2-zeta)^2
+             sage: a.descend_mod_power(Qi,2)
+-            [-3*i - 2, -2*i + 3]
++            [-2*i + 3, 3*i + 2]
+ 
+         An absolute example::
+ 
+@@ -5124,7 +5124,7 @@ cdef class NumberFieldElement_relative(NumberFieldElement):
+         EXAMPLES::
+ 
+             sage: K.<a, b, c> = NumberField([x^2 - 2, x^2 - 3, x^2 - 5])
+-            sage: P = K.prime_factors(5)[0]
++            sage: P = K.prime_factors(5)[1]
+             sage: (2*a + b - c).valuation(P)
+             1
+         """
+diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
+index 5f587556a4..33481fead0 100644
+--- a/src/sage/rings/number_field/number_field_ideal.py
++++ b/src/sage/rings/number_field/number_field_ideal.py
+@@ -3355,7 +3355,7 @@ def quotient_char_p(I, p):
+         []
+ 
+         sage: I = K.factor(13)[0][0]; I
+-        Fractional ideal (-3*i - 2)
++        Fractional ideal (-2*i + 3)
+         sage: I.residue_class_degree()
+         1
+         sage: quotient_char_p(I, 13)[0]
+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 bae36d4b9c..f64bd5b761 100644
+--- a/src/sage/rings/number_field/number_field_ideal_rel.py
++++ b/src/sage/rings/number_field/number_field_ideal_rel.py
+@@ -272,7 +272,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.gens_reduced()
+-            (2, 15*a*b + 3*a + 1)
++            (2, -15*a*b + 3*a + 1)
+         """
+         try:
+             # Compute the single generator, if it exists
+@@ -401,7 +401,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.relative_norm()
+-            Fractional ideal (-6*a + 2)
++            Fractional ideal (6*a + 2)
+         """
+         L = self.number_field()
+         K = L.base_field()
+@@ -518,7 +518,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.ideal_below()
+-            Fractional ideal (-6*a + 2)
++            Fractional ideal (6*a + 2)
+         """
+         L = self.number_field()
+         K = L.base_field()
+diff --git a/src/sage/rings/number_field/number_field_rel.py b/src/sage/rings/number_field/number_field_rel.py
+index d33980c4b1..50e846b205 100644
+--- a/src/sage/rings/number_field/number_field_rel.py
++++ b/src/sage/rings/number_field/number_field_rel.py
+@@ -213,14 +213,14 @@ class NumberField_relative(NumberField_generic):
+             sage: l.<b> = k.extension(5*x^2 + 3); l
+             Number Field in b with defining polynomial 5*x^2 + 3 over its base field
+             sage: l.pari_rnf()
+-            [x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4), ..., y^4 + 6*y^2 + 1, x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4)], [0, 0]]
++            [x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4), ..., y^4 + 6*y^2 + 1, x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4)], [0, 0]]
+             sage: b
+             b
+ 
+             sage: l.<b> = k.extension(x^2 + 3/5); l
+             Number Field in b with defining polynomial x^2 + 3/5 over its base field
+             sage: l.pari_rnf()
+-            [x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4), ..., y^4 + 6*y^2 + 1, x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4)], [0, 0]]
++            [x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4), ..., y^4 + 6*y^2 + 1, x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4)], [0, 0]]
+             sage: b
+             b
+ 
+diff --git a/src/sage/rings/number_field/order.py b/src/sage/rings/number_field/order.py
+index 6eca89ed8d..78ef4c3b33 100644
+--- a/src/sage/rings/number_field/order.py
++++ b/src/sage/rings/number_field/order.py
+@@ -520,7 +520,7 @@ class Order(IntegralDomain, sage.rings.abc.Order):
+             sage: k.<a> = NumberField(x^2 + 5077); G = k.class_group(); G
+             Class group of order 22 with structure C22 of Number Field in a with defining polynomial x^2 + 5077
+             sage: G.0 ^ -9
+-            Fractional ideal class (11, a + 7)
++            Fractional ideal class (43, a + 13)
+             sage: Ok = k.maximal_order(); Ok
+             Maximal Order in Number Field in a with defining polynomial x^2 + 5077
+             sage: Ok * (11, a + 7)
+diff --git a/src/sage/rings/number_field/selmer_group.py b/src/sage/rings/number_field/selmer_group.py
+index c534aaa9f6..6bc67565d2 100644
+--- a/src/sage/rings/number_field/selmer_group.py
++++ b/src/sage/rings/number_field/selmer_group.py
+@@ -491,7 +491,7 @@ def pSelmerGroup(K, S, p, proof=None, debug=False):
+ 
+         sage: [K.ideal(g).factor() for g in gens]
+         [(Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1)),
+-        Fractional ideal (-a),
++        Fractional ideal (a),
+         (Fractional ideal (2, a + 1))^2,
+         1]
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
+index bb5d8356be..8a7e5fa66f 100644
+--- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
++++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
+@@ -1791,7 +1791,7 @@ class PolynomialQuotientRing_generic(CommutativeRing):
+             sage: D.selmer_generators([K.ideal(2, -a+1), K.ideal(3, a+1)], 3)
+             [2, a + 1]
+             sage: D.selmer_generators([K.ideal(2, -a+1), K.ideal(3, a+1), K.ideal(a)], 3)
+-            [2, a + 1, a]
++            [2, a + 1, -a]
+ 
+         """
+         fields, isos, iso_classes = self._S_decomposition(tuple(S))
+diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py
+index 704b77ce5f..83ee4549e4 100644
+--- a/src/sage/rings/qqbar.py
++++ b/src/sage/rings/qqbar.py
+@@ -312,8 +312,8 @@ and we get a way to produce the number directly::
+     True
+     sage: sage_input(n)
+     R.<y> = QQ[]
+-    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(RR(0.51763809020504148), RR(0.51763809020504159)))
+-    -109*v^3 - 89*v^2 + 327*v + 178
++    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(-RR(1.9318516525781366), -RR(1.9318516525781364)))
++    -109*v^3 + 89*v^2 + 327*v - 178
+ 
+ We can also see that some computations (basically, those which are
+ easy to perform exactly) are performed directly, instead of storing
+@@ -362,7 +362,7 @@ algorithms in :trac:`10255`::
+     # Verified
+     R1.<x> = QQbar[]
+     R2.<y> = QQ[]
+-    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(RR(0.51763809020504148), RR(0.51763809020504159)))
++    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(-RR(1.9318516525781366), -RR(1.9318516525781364)))
+     AA.polynomial_root(AA.common_polynomial(x^4 + QQbar(v^3 - 3*v - 1)*x^3 + QQbar(-v^3 + 3*v - 3)*x^2 + QQbar(-3*v^3 + 9*v + 3)*x + QQbar(3*v^3 - 9*v)), RIF(RR(0.99999999999999989), RR(1.0000000000000002)))
+     sage: one
+     1
+@@ -2310,7 +2310,7 @@ def do_polred(poly, threshold=32):
+     cost = 2 * bitsize.nbits() + 5 * poly.degree().nbits()
+     if cost > threshold:
+         return parent.gen(), parent.gen(), poly
+-    new_poly, elt_back = poly.__pari__().polredbest(flag=1)
++    new_poly, elt_back = poly.numerator().__pari__().polredbest(flag=1)
+     elt_fwd = elt_back.modreverse()
+     return parent(elt_fwd.lift()), parent(elt_back.lift()), parent(new_poly)
+ 
+@@ -2542,10 +2542,10 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+            Defn: a |--> 1.414213562373095?)
+ 
+         sage: number_field_elements_from_algebraics((rt2,rt3))
+-        (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, [-a^3 + 3*a, -a^2 + 2], Ring morphism:
++        (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, [-a^3 + 3*a, a^2 - 2], Ring morphism:
+             From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+             To:   Algebraic Real Field
+-            Defn: a |--> 0.5176380902050415?)
++            Defn: a |--> -1.931851652578137?)
+ 
+     ``rt3a`` is a real number in ``QQbar``.  Ordinarily, we'd get a homomorphism
+     to ``AA`` (because all elements are real), but if we specify ``same_field=True``,
+@@ -2570,7 +2570,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, -a^3 + 3*a, Ring morphism:
+             From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+             To:   Algebraic Real Field
+-            Defn: a |--> 0.5176380902050415?)
++            Defn: a |--> -1.931851652578137?)
+ 
+     We can specify ``minimal=True`` if we want the smallest number field::
+ 
+@@ -2618,7 +2618,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         sage: nfI^2
+         -1
+         sage: sum = nfrt2 + nfrt3 + nfI + nfz3; sum
+-        2*a^6 + a^5 - a^4 - a^3 - 2*a^2 - a
++        a^5 + a^4 - a^3 + 2*a^2 - a - 1
+         sage: hom(sum)
+         2.646264369941973? + 1.866025403784439?*I
+         sage: hom(sum) == rt2 + rt3 + qqI + z3
+@@ -2658,7 +2658,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         sage: nf, nums, hom = number_field_elements_from_algebraics(elems, embedded=True)
+         sage: nf
+         Number Field in a with defining polynomial y^24 - 6*y^23 ...- 9*y^2 + 1
+-          with a = 0.2598678911433438? + 0.0572892247058457?*I
++          with a = 0.2598679? + 0.0572892?*I
+         sage: list(map(QQbar, nums)) == elems == list(map(hom, nums))
+         True
+ 
+@@ -2725,7 +2725,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+                          sqrt(2), AA.polynomial_root(x^3-3, RIF(0,3)), 11/9, 1]
+         sage: res = number_field_elements_from_algebraics(my_nums, embedded=True)
+         sage: res[0]
+-        Number Field in a with defining polynomial y^24 - 107010*y^22 - 24*y^21 + ... + 250678447193040618624307096815048024318853254384 with a = -95.5053039433554?
++        Number Field in a with defining polynomial y^24 - 107010*y^22 - 24*y^21 + ... + 250678447193040618624307096815048024318853254384 with a = 93.32530798172420?
+     """
+     gen = qq_generator
+ 
+@@ -3129,7 +3129,7 @@ class AlgebraicGenerator(SageObject):
+             sage: root = ANRoot(x^2 - x - 1, RIF(1, 2))
+             sage: gen = AlgebraicGenerator(nf, root)
+             sage: gen.pari_field()
+-             [y^2 - y - 1, [2, 0], ...]
++            [[y^2 - y - 1, [2, 0], ...]
+         """
+         if self.is_trivial():
+             raise ValueError("No PARI field attached to trivial generator")
+@@ -3213,7 +3213,7 @@ class AlgebraicGenerator(SageObject):
+             sage: qq_generator.union(gen3) is gen3
+             True
+             sage: gen2.union(gen3)
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+         """
+         if self._trivial:
+             return other
+@@ -3306,13 +3306,13 @@ class AlgebraicGenerator(SageObject):
+             Number Field in a with defining polynomial y^2 - 3 with a in 1.732050807568878?
+             sage: gen2_3 = gen2.union(gen3)
+             sage: gen2_3
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+             sage: qq_generator.super_poly(gen2) is None
+             True
+             sage: gen2.super_poly(gen2_3)
+             -a^3 + 3*a
+             sage: gen3.super_poly(gen2_3)
+-            -a^2 + 2
++            a^2 - 2
+ 
+         """
+         if checked is None:
+@@ -3360,13 +3360,13 @@ class AlgebraicGenerator(SageObject):
+             sage: sqrt3 = ANExtensionElement(gen3, nf3.gen())
+             sage: gen2_3 = gen2.union(gen3)
+             sage: gen2_3
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+             sage: gen2_3(sqrt2)
+             -a^3 + 3*a
+             sage: gen2_3(ANRational(1/7))
+             1/7
+             sage: gen2_3(sqrt3)
+-            -a^2 + 2
++            a^2 - 2
+         """
+         if self._trivial:
+             return elt._value
+@@ -4336,10 +4336,10 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: rt3 = AA(sqrt(3))
+             sage: rt3b = rt2 + rt3 - rt2
+             sage: rt3b.as_number_field_element()
+-            (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, -a^2 + 2, Ring morphism:
++            (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, a^2 - 2, Ring morphism:
+                 From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+                 To:   Algebraic Real Field
+-                Defn: a |--> 0.5176380902050415?)
++                Defn: a |--> -1.931851652578137?)
+             sage: rt3b.as_number_field_element(minimal=True)
+             (Number Field in a with defining polynomial y^2 - 3, a, Ring morphism:
+                From: Number Field in a with defining polynomial y^2 - 3
+@@ -4401,7 +4401,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: rt2b = rt3 + rt2 - rt3
+             sage: rt2b.exactify()
+             sage: rt2b._exact_value()
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b.simplify()
+             sage: rt2b._exact_value()
+             a where a^2 - 2 = 0 and a in 1.414213562373095?
+@@ -4422,7 +4422,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: QQbar(2)._exact_field()
+             Trivial generator
+             sage: (sqrt(QQbar(2)) + sqrt(QQbar(19)))._exact_field()
+-            Number Field in a with defining polynomial y^4 - 20*y^2 + 81 with a in 2.375100220297941?
++            Number Field in a with defining polynomial y^4 - 20*y^2 + 81 with a in -3.789313782671036?
+             sage: (QQbar(7)^(3/5))._exact_field()
+             Number Field in a with defining polynomial y^5 - 2*y^4 - 18*y^3 + 38*y^2 + 82*y - 181 with a in 2.554256611698490?
+         """
+@@ -4442,7 +4442,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: QQbar(2)._exact_value()
+             2
+             sage: (sqrt(QQbar(2)) + sqrt(QQbar(19)))._exact_value()
+-            -1/9*a^3 - a^2 + 11/9*a + 10 where a^4 - 20*a^2 + 81 = 0 and a in 2.375100220297941?
++            -1/9*a^3 + a^2 + 11/9*a - 10 where a^4 - 20*a^2 + 81 = 0 and a in -3.789313782671036?
+             sage: (QQbar(7)^(3/5))._exact_value()
+             2*a^4 + 2*a^3 - 34*a^2 - 17*a + 150 where a^5 - 2*a^4 - 18*a^3 + 38*a^2 + 82*a - 181 = 0 and a in 2.554256611698490?
+         """
+@@ -6857,7 +6857,7 @@ class AlgebraicPolynomialTracker(SageObject):
+             sage: p = sqrt(AA(2)) * x^2 - sqrt(AA(3))
+             sage: cp = AA.common_polynomial(p)
+             sage: cp.generator()
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 1.931851652578137?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -0.5176380902050415?
+         """
+         self.exactify()
+         return self._gen
+@@ -7706,7 +7706,7 @@ class ANExtensionElement(ANDescr):
+ 
+             sage: rt2b.exactify()
+             sage: rt2b._descr
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b._descr.is_simple()
+             False
+         """
+@@ -7791,7 +7791,7 @@ class ANExtensionElement(ANDescr):
+             sage: rt2b = rt3 + rt2 - rt3
+             sage: rt2b.exactify()
+             sage: rt2b._descr
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b._descr.simplify(rt2b)
+             a where a^2 - 2 = 0 and a in 1.414213562373095?
+         """
+@@ -7830,9 +7830,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.neg(a)
+-            1/3*a^3 - 2/3*a^2 + 4/3*a - 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -1/3*a^3 + 1/3*a^2 - a - 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+             sage: b.neg("ham spam and eggs")
+-            1/3*a^3 - 2/3*a^2 + 4/3*a - 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -1/3*a^3 + 1/3*a^2 - a - 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+         """
+         return ANExtensionElement(self._generator, -self._value)
+ 
+@@ -7848,9 +7848,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.invert(a)
+-            7/3*a^3 - 2/3*a^2 + 4/3*a - 12 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -7/3*a^3 + 19/3*a^2 - 7*a - 9 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+             sage: b.invert("ham spam and eggs")
+-            7/3*a^3 - 2/3*a^2 + 4/3*a - 12 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -7/3*a^3 + 19/3*a^2 - 7*a - 9 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+         """
+         return ANExtensionElement(self._generator, ~self._value)
+ 
+@@ -7866,9 +7866,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.conjugate(a)
+-            -1/3*a^3 + 2/3*a^2 - 4/3*a + 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? + 1.573132184970987?*I
++            1/3*a^3 - 1/3*a^2 + a + 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? - 1.573132184970987?*I
+             sage: b.conjugate("ham spam and eggs")
+-            -1/3*a^3 + 2/3*a^2 - 4/3*a + 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? + 1.573132184970987?*I
++            1/3*a^3 - 1/3*a^2 + a + 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? - 1.573132184970987?*I
+         """
+         if self._exactly_real:
+             return self
+@@ -8501,7 +8501,7 @@ def an_binop_expr(a, b, op):
+         sage: x = an_binop_expr(a, b, operator.add); x
+         <sage.rings.qqbar.ANBinaryExpr object at ...>
+         sage: x.exactify()
+-        -6/7*a^7 + 2/7*a^6 + 71/7*a^5 - 26/7*a^4 - 125/7*a^3 + 72/7*a^2 + 43/7*a - 47/7 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in 3.12580...?
++        6/7*a^7 - 2/7*a^6 - 71/7*a^5 + 26/7*a^4 + 125/7*a^3 - 72/7*a^2 - 43/7*a + 47/7 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in -0.3199179336182997?
+ 
+         sage: a = QQbar(sqrt(2)) + QQbar(sqrt(3))
+         sage: b = QQbar(sqrt(3)) + QQbar(sqrt(5))
+@@ -8510,7 +8510,7 @@ def an_binop_expr(a, b, op):
+         sage: x = an_binop_expr(a, b, operator.mul); x
+         <sage.rings.qqbar.ANBinaryExpr object at ...>
+         sage: x.exactify()
+-        2*a^7 - a^6 - 24*a^5 + 12*a^4 + 46*a^3 - 22*a^2 - 22*a + 9 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in 3.1258...?
++        2*a^7 - a^6 - 24*a^5 + 12*a^4 + 46*a^3 - 22*a^2 - 22*a + 9 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in -0.3199179336182997?
+     """
+     return ANBinaryExpr(a, b, op)
+ 
+diff --git a/src/sage/schemes/affine/affine_morphism.py b/src/sage/schemes/affine/affine_morphism.py
+index 1c4f2dff18..32c2e47e49 100644
+--- a/src/sage/schemes/affine/affine_morphism.py
++++ b/src/sage/schemes/affine/affine_morphism.py
+@@ -1148,9 +1148,9 @@ class SchemeMorphism_polynomial_affine_space_field(SchemeMorphism_polynomial_aff
+             sage: H = End(A)
+             sage: f = H([(QQbar(sqrt(2))*x^2 + 1/QQbar(sqrt(3))) / (5*x)])
+             sage: f.reduce_base_field()
+-            Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a = 1.931851652578137?
++            Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a = ...?
+               Defn: Defined on coordinates by sending (x) to
+-                    (((a^3 - 3*a)*x^2 + (1/3*a^2 - 2/3))/(5*x))
++                    (((a^3 - 3*a)*x^2 + (-1/3*a^2 + 2/3))/(5*x))
+ 
+         ::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_field.py b/src/sage/schemes/elliptic_curves/ell_field.py
+index 68b8375dae..48f358ea6a 100644
+--- a/src/sage/schemes/elliptic_curves/ell_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_field.py
+@@ -845,7 +845,7 @@ class EllipticCurve_field(ell_generic.EllipticCurve_generic, ProjectivePlaneCurv
+             sage: E = E.base_extend(G).quadratic_twist(c); E
+             Elliptic Curve defined by y^2 = x^3 + 5*a0*x^2 + (-200*a0^2)*x + (-42000*a0^2+42000*a0+126000) over Number Field in a0 with defining polynomial x^3 - 3*x^2 + 3*x + 9
+             sage: K.<b> = E.division_field(3, simplify_all=True); K
+-            Number Field in b with defining polynomial x^12 - 10*x^10 + 55*x^8 - 60*x^6 + 75*x^4 + 1350*x^2 + 2025
++            Number Field in b with defining polynomial x^12 + 5*x^10 + 40*x^8 + 315*x^6 + 750*x^4 + 675*x^2 + 2025
+ 
+         Some higher-degree examples::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_generic.py b/src/sage/schemes/elliptic_curves/ell_generic.py
+index 926ae310ea..3bae819fb0 100644
+--- a/src/sage/schemes/elliptic_curves/ell_generic.py
++++ b/src/sage/schemes/elliptic_curves/ell_generic.py
+@@ -3324,8 +3324,8 @@ 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),
++            [0, 0, 0, Mod(1, y^2 - 2),
++            Mod(y, y^2 - 2), 0, 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;
+diff --git a/src/sage/schemes/elliptic_curves/ell_number_field.py b/src/sage/schemes/elliptic_curves/ell_number_field.py
+index edbd196090..c44c803aa8 100644
+--- a/src/sage/schemes/elliptic_curves/ell_number_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_number_field.py
+@@ -218,7 +218,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: E == loads(dumps(E))
+             True
+             sage: E.simon_two_descent()
+-            (2, 2, [(0 : 0 : 1)])
++            (2, 2, [(0 : 0 : 1), (1/18*a + 7/18 : -5/54*a - 17/54 : 1)])
+             sage: E.simon_two_descent(lim1=5, lim3=5, limtriv=10, maxprob=7, limbigprime=10)
+             (2, 2, [(-1 : 0 : 1), (-2 : -1/2*a - 1/2 : 1)])
+ 
+@@ -274,7 +274,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: E.simon_two_descent()  # long time (4s on sage.math, 2013)
+             (3,
+              3,
+-             [(5/8*zeta43_0^2 + 17/8*zeta43_0 - 9/4 : -27/16*zeta43_0^2 - 103/16*zeta43_0 + 39/8 : 1),
++             [(1/8*zeta43_0^2 - 3/8*zeta43_0 - 1/4 : -5/16*zeta43_0^2 + 7/16*zeta43_0 + 1/8 : 1),
+               (0 : 0 : 1)])
+         """
+         verbose = int(verbose)
+@@ -865,7 +865,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             Conductor exponent: 1
+             Kodaira Symbol: I1
+             Tamagawa Number: 1,
+-            Local data at Fractional ideal (-3*i - 2):
++            Local data at Fractional ideal (-2*i + 3):
+             Reduction type: bad split multiplicative
+             Local minimal model: Elliptic Curve defined by y^2 + (i+1)*x*y + y = x^3 over Number Field in i with defining polynomial x^2 + 1
+             Minimal discriminant valuation: 2
+@@ -2645,12 +2645,12 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             [-92, -23, -23]
+ 
+             sage: C.matrix()  # long time
+-            [1 2 2 4 2 4]
+-            [2 1 2 2 4 4]
+-            [2 2 1 4 4 2]
+-            [4 2 4 1 3 3]
+-            [2 4 4 3 1 3]
+-            [4 4 2 3 3 1]
++            [1 2 2 4 4 2]
++            [2 1 2 4 2 4]
++            [2 2 1 2 4 4]
++            [4 4 2 1 3 3]
++            [4 2 4 3 1 3]
++            [2 4 4 3 3 1]
+ 
+         The graph of this isogeny class has a shape which does not
+         occur over `\QQ`: a triangular prism.  Note that for curves
+@@ -2677,12 +2677,12 @@ class EllipticCurve_number_field(EllipticCurve_field):
+ 
+             sage: G = C.graph()  # long time
+             sage: G.adjacency_matrix()  # long time
+-            [0 1 1 0 1 0]
+-            [1 0 1 1 0 0]
+-            [1 1 0 0 0 1]
+-            [0 1 0 0 1 1]
+-            [1 0 0 1 0 1]
+-            [0 0 1 1 1 0]
++            [0 1 1 0 0 1]
++            [1 0 1 0 1 0]
++            [1 1 0 1 0 0]
++            [0 0 1 0 1 1]
++            [0 1 0 1 0 1]
++            [1 0 0 1 1 0]
+ 
+         To display the graph without any edge labels::
+ 
+@@ -3316,7 +3316,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: points = [E.lift_x(x) for x in xi]
+             sage: newpoints, U = E.lll_reduce(points)  # long time (35s on sage.math, 2011)
+             sage: [P[0] for P in newpoints]            # long time
+-            [6823803569166584943, 5949539878899294213, 2005024558054813068, 5864879778877955778, 23955263915878682727/4, 5922188321411938518, 5286988283823825378, 175620639884534615751/25, -11451575907286171572, 3502708072571012181, 1500143935183238709184/225, 27180522378120223419/4, -5811874164190604461581/625, 26807786527159569093, 7404442636649562303, 475656155255883588, 265757454726766017891/49, 7272142121019825303, 50628679173833693415/4, 6951643522366348968, 6842515151518070703, 111593750389650846885/16, 2607467890531740394315/9, -1829928525835506297]
++            [6823803569166584943, 5949539878899294213, 2005024558054813068, 5864879778877955778, 23955263915878682727/4, 5922188321411938518, 5286988283823825378, 11465667352242779838, -11451575907286171572, 3502708072571012181, 1500143935183238709184/225, 27180522378120223419/4, -5811874164190604461581/625, 26807786527159569093, 7041412654828066743, 475656155255883588, 265757454726766017891/49, 7272142121019825303, 50628679173833693415/4, 6951643522366348968, 6842515151518070703, 111593750389650846885/16, 2607467890531740394315/9, -1829928525835506297]
+ 
+         An example to show the explicit use of the height pairing matrix::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_rational_field.py b/src/sage/schemes/elliptic_curves/ell_rational_field.py
+index 3808822812..a75290ea35 100644
+--- a/src/sage/schemes/elliptic_curves/ell_rational_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_rational_field.py
+@@ -1827,7 +1827,7 @@ class EllipticCurve_rational_field(EllipticCurve_number_field):
+             sage: E = EllipticCurve('389a1')
+             sage: E._known_points = []  # clear cached points
+             sage: E.simon_two_descent()
+-            (2, 2, [(1 : 0 : 1), (-11/9 : 28/27 : 1)])
++            (2, 2, [(5/4 : 5/8 : 1), (-3/4 : 7/8 : 1)])
+             sage: E = EllipticCurve('5077a1')
+             sage: E.simon_two_descent()
+             (3, 3, [(1 : 0 : 1), (2 : 0 : 1), (0 : 2 : 1)])
+diff --git a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
+index 81ad295160..d484a4a18b 100644
+--- a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
++++ b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
+@@ -780,12 +780,12 @@ def deg_one_primes_iter(K, principal_only=False):
+         [Fractional ideal (2, a + 1),
+          Fractional ideal (3, a + 1),
+          Fractional ideal (3, a + 2),
+-         Fractional ideal (-a),
++         Fractional ideal (a),
+          Fractional ideal (7, a + 3),
+          Fractional ideal (7, a + 4)]
+         sage: it = deg_one_primes_iter(K, True)
+         sage: [next(it) for _ in range(6)]
+-        [Fractional ideal (-a),
++        [Fractional ideal (a),
+          Fractional ideal (-2*a + 3),
+          Fractional ideal (2*a + 3),
+          Fractional ideal (a + 6),
+diff --git a/src/sage/schemes/elliptic_curves/gp_simon.py b/src/sage/schemes/elliptic_curves/gp_simon.py
+index 28b97f34af..9f7d1b6020 100644
+--- a/src/sage/schemes/elliptic_curves/gp_simon.py
++++ b/src/sage/schemes/elliptic_curves/gp_simon.py
+@@ -56,7 +56,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+         sage: import sage.schemes.elliptic_curves.gp_simon
+         sage: E=EllipticCurve('389a1')
+         sage: sage.schemes.elliptic_curves.gp_simon.simon_two_descent(E)
+-        (2, 2, [(1 : 0 : 1), (-11/9 : 28/27 : 1)])
++        (2, 2, [(5/4 : 5/8 : 1), (-3/4 : 7/8 : 1)])
+ 
+     TESTS::
+ 
+@@ -117,7 +117,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+     # The block below mimics the defaults in Simon's scripts, and needs to be changed
+     # when these are updated.
+     if K is QQ:
+-        cmd = 'ellrank(%s, %s);' % (list(E.ainvs()), [P.__pari__() for P in known_points])
++        cmd = 'ellQ_ellrank(%s, %s);' % (list(E.ainvs()), [P.__pari__() for P in known_points])
+         if lim1 is None:
+             lim1 = 5
+         if lim3 is None:
+@@ -144,7 +144,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+     if verbose > 0:
+         print(s)
+     v = gp.eval('ans')
+-    if v=='ans': # then the call to ellrank() or bnfellrank() failed
++    if v=='ans': # then the call to ellQ_ellrank() or bnfellrank() failed
+         raise RuntimeError("An error occurred while running Simon's 2-descent program")
+     if verbose >= 2:
+         print("v = %s" % v)
+diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
+index a936deb74f..dc19254d8c 100644
+--- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
++++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
+@@ -1208,14 +1208,14 @@ def isogenies_13_0(E, minimal_models=True):
+         sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]  # long time (4s)
+         [(0,
+           0,
+-          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
++          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 + 1887439/1146978983704320*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 + 1030632647/7965131831280*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 - 43618899433/204234149520*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 2535050171/1418292705,
+           -139861295/2650795873449984*a^11 - 3455957/5664093746688*a^10 - 345310571/50976843720192*a^9 - 500530795/118001953056*a^8 - 12860048113/265504394376*a^7 - 25007420461/44250732396*a^6 + 458134176455/1416023436672*a^5 + 16701880631/9077073312*a^4 + 155941666417/9077073312*a^3 + 3499310115/378211388*a^2 - 736774863/94552847*a - 21954102381/94552847,
+-          579363345221/13763747804451840*a^11 + 371192377511/860234237778240*a^10 + 8855090365657/1146978983704320*a^9 + 5367261541663/1633873196160*a^8 + 614883554332193/15930263662560*a^7 + 30485197378483/68078049840*a^6 - 131000897588387/2450809794240*a^5 - 203628705777949/306351224280*a^4 - 1587619388190379/204234149520*a^3 + 14435069706551/11346341640*a^2 + 7537273048614/472764235*a + 89198980034806/472764235),
++          8342795944891/198197968384106496*a^11 + 8908625263589/20645621706677760*a^10 + 53130542636623/6881873902225920*a^9 + 376780111042213/114697898370432*a^8 + 614884052146333/15930263662560*a^7 + 3566768133324359/7965131831280*a^6 - 1885593809102545/35291661037056*a^5 - 2443732172026523/3676214691360*a^4 - 9525729503937541/1225404897120*a^3 + 51990274442321/40846829904*a^2 + 67834019370596/4254878115*a + 267603083706812/1418292705),
+          (0,
+           0,
+-          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
++          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 + 1887439/1146978983704320*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 + 1030632647/7965131831280*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 - 43618899433/204234149520*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 2535050171/1418292705,
+           -6465569317/1325397936724992*a^11 - 112132307/1960647835392*a^10 - 17075412917/25488421860096*a^9 - 207832519229/531008788752*a^8 - 1218275067617/265504394376*a^7 - 9513766502551/177002929584*a^6 + 4297077855437/708011718336*a^5 + 354485975837/4538536656*a^4 + 4199379308059/4538536656*a^3 - 30841577919/189105694*a^2 - 181916484042/94552847*a - 2135779171614/94552847,
+-          -132601797212627/3440936951112960*a^11 - 6212467020502021/13763747804451840*a^10 - 1515926454902497/286744745926080*a^9 - 15154913741799637/4901619588480*a^8 - 576888119803859263/15930263662560*a^7 - 86626751639648671/204234149520*a^6 + 16436657569218427/306351224280*a^5 + 1540027900265659087/2450809794240*a^4 + 375782662805915809/51058537380*a^3 - 14831920924677883/11346341640*a^2 - 7237947774817724/472764235*a - 84773764066089509/472764235)]
++          -1316873026840277/34172063514501120*a^11 - 18637401045099413/41291243413355520*a^10 - 36382234917217247/6881873902225920*a^9 - 61142238484016213/19775499719040*a^8 - 576888119306045123/15930263662560*a^7 - 3378443313906256321/7965131831280*a^6 + 326466167429333279/6084769144320*a^5 + 4620083325391594991/7352429382720*a^4 + 9018783894167184149/1225404897120*a^3 - 9206015742300283/7042556880*a^2 - 65141531411426446/4254878115*a - 254321286054666133/1418292705)]
+     """
+     if E.j_invariant()!=0:
+         raise ValueError("j-invariant must be 0.")
diff --git a/srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch b/srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch
new file mode 100644
index 000000000000..762bb2612632
--- /dev/null
+++ b/srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch
@@ -0,0 +1,29 @@
+From f0365f30834b6890313790b3845c647d0160fa6a Mon Sep 17 00:00:00 2001
+From: Vincent Delecroix <20100.delecroix@gmail.com*>
+Date: Fri, 30 Sep 2022 16:31:08 +0200
+Subject: fix doctest if fqf_orthogonal
+
+---
+ src/sage/groups/fqf_orthogonal.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/sage/groups/fqf_orthogonal.py b/src/sage/groups/fqf_orthogonal.py
+index 75de408..7fc4dbe 100644
+--- a/src/sage/groups/fqf_orthogonal.py
++++ b/src/sage/groups/fqf_orthogonal.py
+@@ -245,10 +245,10 @@ class FqfOrthogonalGroup(AbelianGroupAutomorphismGroup_subgroup):
+             sage: all(x*f==x*fbar for x in q.gens())
+             True
+             sage: L = IntegralLattice("A2").twist(3)
+-            sage: q = L.discriminant_group()
+             sage: OL = L.orthogonal_group()
++            sage: assert OL(OL.0.matrix()) == OL.0
++            sage: q = L.discriminant_group()
+             sage: Oq = q.orthogonal_group()
+-            sage: assert Oq(OL.0) == Oq(OL.0.matrix())
+             sage: assert Oq(Oq.0.matrix()) == Oq.0
+         """
+         from sage.libs.gap.element import GapElement
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch b/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
deleted file mode 100644
index 4bd6f4f4e2dc..000000000000
--- a/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
+++ /dev/null
@@ -1,670 +0,0 @@
-As produced by `git diff 9.5 9.6.beta3 -- src/sage/libs/lrcalc`
-
-diff --git a/src/sage/libs/lrcalc/lrcalc.pxd b/src/sage/libs/lrcalc/lrcalc.pxd
-deleted file mode 100644
-index 10b88db93f2..00000000000
---- a/src/sage/libs/lrcalc/lrcalc.pxd
-+++ /dev/null
-@@ -1,77 +0,0 @@
--# distutils: libraries = lrcalc
--
--cdef extern from "lrcalc/hashtab.h":
--    ctypedef struct hashtab:
--        pass
--
--    ctypedef struct hash_itr:
--        pass
--
--    ctypedef unsigned long hashkey_t
--    ctypedef int (*cmp_t) (void* a, void* b)
--    ctypedef hashkey_t (*hash_t) (void* a)
--
--    hashtab* hash_new(cmp_t cm, hash_t hsh)
--    void hash_free(hashtab *ht)
--
--    void* hash_lookup(hashtab *ht, void *key)
--    void* hash_insert(hashtab *ht, void *key, void *value)
--
--    bint hash_good(hash_itr)
--    void hash_first(hashtab* s, hash_itr itr)
--    void hash_next(hash_itr itr)
--    void* hash_key(hash_itr itr)
--    void* hash_value(hash_itr itr)
--    int hash_intvalue(hash_itr itr)
--
--cdef extern from "lrcalc/vector.h":
--    ctypedef struct vector:
--        size_t length
--        int* array
--
--    vector* v_new(int length)
--    void v_free(vector* v)
--    void v_print(vector *v)
--    int v_length(vector* v)
--    int v_elem(vector* v, int i)
--
--    ctypedef struct vecpair:
--        vector *first
--        vector *second
--
--    vector* vp_first(vecpair* vp)
--    vector* vp_second(vecpair* vp)
--
--cdef extern from "lrcalc/list.h":
--    cdef struct _list:
--        void **array
--        size_t allocated
--        size_t length
--    void l_free(_list *lst)
--
--cdef extern from "lrcalc/symfcn.h":
--    long long lrcoef_c "lrcoef"(vector* outer, vector* inner1, vector* inner2)
--    hashtab* mult_c "mult"(vector *sh1, vector *sh2, int maxrows)
--    hashtab* skew_c "skew"(vector *outer, vector *inner, int maxrows)
--    hashtab* coprod_c "coprod"(vector *part, int all)
--    void fusion_reduce_c "fusion_reduce"(hashtab* ht, int rows, int cols, int opt_zero)
--    _list *quantum_reduce_c "quantum_reduce"(hashtab* ht, int rows, int col)
--
--    ctypedef struct skewtab:
--        vector *outer
--        vector *inner
--        vector *conts
--        int maxrows
--        vector *conjugate
--        int rows
--        int cols
--        int matrix[1]
--
--    skewtab *st_new(vector *outer, vector *inner, vector *conts, int maxrows)
--    int st_next(skewtab *st)
--    void st_print(skewtab *st)
--    void st_free(skewtab *st)
--
--
--cdef extern from "lrcalc/schublib.h":
--    hashtab* mult_schubert_c "mult_schubert"(vector *sh1, vector *sh2, int rank)
-diff --git a/src/sage/libs/lrcalc/lrcalc.pyx b/src/sage/libs/lrcalc/lrcalc.py
-similarity index 60%
-rename from src/sage/libs/lrcalc/lrcalc.pyx
-rename to src/sage/libs/lrcalc/lrcalc.py
-index b591081ec4c..b541bfacd89 100644
---- a/src/sage/libs/lrcalc/lrcalc.pyx
-+++ b/src/sage/libs/lrcalc/lrcalc.py
-@@ -10,7 +10,8 @@ fusion products. All of the above are achieved by counting LR
- appropriate shape and content by iterating through them.
- Additionally, ``lrcalc`` handles products of Schubert polynomials.
- 
--The web page of ``lrcalc`` is `<http://sites.math.rutgers.edu/~asbuch/lrcalc/>`_.
-+The web page of ``lrcalc`` is
-+`<http://sites.math.rutgers.edu/~asbuch/lrcalc/>`_.
- 
- The following describes the Sage interface to this library.
- 
-@@ -36,12 +37,13 @@ Schur expansion::
-      [4, 2]: 1}
- 
- Same product, but include only partitions with at most 3 rows.  This
--corresponds to computing in the representation ring of gl(3)::
-+corresponds to computing in the representation ring of `\mathfrak{gl}(3)`::
- 
-     sage: lrcalc.mult([2,1], [2,1], 3)
-     {[2, 2, 2]: 1, [3, 2, 1]: 2, [3, 3]: 1, [4, 1, 1]: 1, [4, 2]: 1}
- 
--We can also compute the fusion product, here for sl(3) and level 2::
-+We can also compute the fusion product, here for `\mathfrak{sl}(3)`
-+and level 2::
- 
-     sage: lrcalc.mult([3,2,1], [3,2,1], 3,2)
-     {[4, 4, 4]: 1, [5, 4, 3]: 1}
-@@ -77,42 +79,38 @@ Multiply two Schubert polynomials::
-      [6, 2, 1, 4, 3, 5]: 1}
- 
- Same product, but include only permutations of 5 elements in the result.
--This corresponds to computing in the cohomology ring of Fl(5)::
-+This corresponds to computing in the cohomology ring of `Fl(5)`::
- 
-     sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3], 5)
-     {[4, 5, 1, 3, 2]: 1, [5, 3, 1, 4, 2]: 1, [5, 4, 1, 2, 3]: 1}
- 
- List all Littlewood-Richardson tableaux of skew shape `\mu/\nu`; in
- this example `\mu=[3,2,1]` and `\nu=[2,1]`. Specifying a third entry
--`maxrows` restricts the alphabet to `\{1,2,\ldots,maxrows\}`::
-+`M' = ``maxrows`` restricts the alphabet to `\{1,2,\ldots,M\}`::
- 
-     sage: list(lrcalc.lrskew([3,2,1],[2,1]))
-     [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
-     [[None, None, 1], [None, 2], [1]], [[None, None, 1], [None, 2], [3]]]
- 
-     sage: list(lrcalc.lrskew([3,2,1],[2,1],maxrows=2))
--    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]], [[None, None, 1], [None, 2], [1]]]
-+    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
-+     [[None, None, 1], [None, 2], [1]]]
- 
- .. TODO::
- 
--    use this library in the :class:`SymmetricFunctions` code, to
-+    Use this library in the :class:`SymmetricFunctions` code, to
-     make it easy to apply it to linear combinations of Schur functions.
- 
- .. SEEALSO::
- 
-     - :func:`lrcoef`
--
-     - :func:`mult`
--
-     - :func:`coprod`
--
-     - :func:`skew`
--
-     - :func:`lrskew`
--
-     - :func:`mult_schubert`
- 
--.. rubric:: Underlying algorithmic in lrcalc
-+.. RUBRIC:: Underlying algorithmic in lrcalc
- 
- Here is some additional information regarding the main low-level
- C-functions in `lrcalc`. Given two partitions ``outer`` and ``inner``
-@@ -187,180 +185,24 @@ AUTHORS:
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from sage.rings.integer cimport Integer
--from sage.structure.parent cimport Parent
- from sage.combinat.partition import _Partitions
- from sage.combinat.permutation import Permutation
--from sage.combinat.skew_tableau import SkewTableau
--
--
--cdef vector* iterable_to_vector(it):
--    """
--    Return an lrcalc vector (which is a list of integers) from a Python iterable.
--
--    TESTS::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector(Partition([3,2,1])); x   #indirect doctest
--        [3, 2, 1]
--    """
--    cdef vector* v
--    cdef list itr = list(it)
--    cdef int n = len(itr)
--    cdef int i
--    v = v_new(n)
--    for i in range(n):
--        v.array[i] = int(itr[i])
--    return v
--
--
--cdef list vector_to_list(vector *v):
--    """
--    Converts a lrcalc vector to Python list.
--
--    TESTS::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector([]); x         #indirect doctest
--        []
--    """
--    cdef int i, n
--    n = v_length(v)
--    cdef list result = [None]*n
--    for i in range(n):
--        result[i] = Integer(v_elem(v, i))
--    return result
--
--
--def test_iterable_to_vector(it):
--    """
--    A wrapper function for the cdef function ``iterable_to_vector``
--    and ``vector_to_list``, to test that they are working correctly.
-+from sage.combinat.skew_tableau import SemistandardSkewTableaux
-+from sage.combinat.skew_partition import SkewPartition
-+from sage.rings.integer import Integer
-+import lrcalc
- 
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector([3,2,1]); x
--        [3, 2, 1]
--    """
--    cdef vector *v = iterable_to_vector(it)
--    result = vector_to_list(v)
--    v_free(v)
--    return result
--
--
--cdef skewtab_to_SkewTableau(skewtab *st):
--    """
--    A wrapper function which transforms the data set ``st`` used in
--    ``lrcalc`` to a ``SkewTableau`` in Sage.
-+def _lrcalc_dict_to_sage(result):
-+    r"""
-+    Translate from lrcalc output format to Sage expected format.
- 
-     TESTS::
- 
--        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
--        sage: test_skewtab_to_SkewTableau([],[])
--        []
--    """
--    inner = vector_to_list(st.inner)
--    outer = vector_to_list(st.outer)
--    return SkewTableau(expr=[[inner[y] for y in range(len(outer))],
--                             [[st.matrix[x + y * st.cols] + 1
--                                for x in range(inner[y], outer[y])]
--                              for y in range(len(outer) - 1, -1, -1)]])
--
--
--def test_skewtab_to_SkewTableau(outer, inner):
--    """
--    A wrapper function for the cdef function ``skewtab_to_SkewTableau``
--    for testing purposes.
--
--    It constructs the first LR skew tableau of shape ``outer/inner``
--    as an ``lrcalc`` ``skewtab``, and converts it to a
--    :class:`SkewTableau`.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
--        sage: test_skewtab_to_SkewTableau([3,2,1],[])
--        [[1, 1, 1], [2, 2], [3]]
--        sage: test_skewtab_to_SkewTableau([4,3,2,1],[1,1]).pp()
--        .  1  1  1
--        .  2  2
--        1  3
--        2
--    """
--    cdef vector* o = iterable_to_vector(outer)
--    cdef vector* i = iterable_to_vector(inner+[0]*(len(outer)-len(inner)))
--    cdef skewtab* st = st_new(o, i, NULL, 0)
--    return skewtab_to_SkewTableau(st)
--
--
--cdef dict sf_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary representing a Schur function. The keys are
--    partitions and the values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
-         sage: from sage.libs.lrcalc.lrcalc import mult
--        sage: sorted(mult([1],[1]).items())        #indirect doctest
--        [([1, 1], 1), ([2], 1)]
--        sage: assert isinstance(mult([1],[1]),dict)#indirect doctest
--    """
--    cdef hash_itr itr
--    cdef dict result = {}
--    cdef list p
--    hash_first(ht, itr)
--    while hash_good(itr):
--        p = vector_to_list(<vector*> hash_key(itr))
--        result[_Partitions(p)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
--
--cdef dict schubert_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary corresponding to a Schubert polynomial whose keys
--    are permutations and whose values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import mult_schubert
--        sage: mult_schubert([3,2,1], [1,2,3])      #indirect doctest
--        {[3, 2, 1]: 1}
--    """
--    cdef hash_itr itr
--    cdef dict result = {}
--    hash_first(ht, itr)
--    while hash_good(itr):
--        p = vector_to_list(<vector*> hash_key(itr))
--        result[Permutation(p)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
--
--cdef dict vp_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary corresponding to the coproduct of a Schur function whose keys are
--    pairs of partitions and whose values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import coprod
--        sage: coprod([1])      #indirect doctest
--        {([1], []): 1}
-+        sage: mult([2,1],[3,2,1],3) # indirect doctest
-+        {[3, 3, 3]: 1, [4, 3, 2]: 2, [4, 4, 1]: 1, [5, 2, 2]: 1, [5, 3, 1]: 1}
-     """
--    cdef hash_itr itr
--    cdef vecpair* vp
--    cdef dict result = {}
--    hash_first(ht, itr)
--    while hash_good(itr):
--        vp = <vecpair*> hash_key(itr)
--        p1 = _Partitions(vector_to_list(vp_first(vp)))
--        p2 = _Partitions(vector_to_list(vp_second(vp)))
--        result[(p1, p2)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
-+    return {_Partitions(la): Integer(k) for la, k in result.items()}
- 
- def lrcoef_unsafe(outer, inner1, inner2):
-     r"""
-@@ -371,13 +213,11 @@ def lrcoef_unsafe(outer, inner1, inner2):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
--
--    - ``inner1`` -- a partition.
-+    - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
-+    - ``inner1`` -- a partition
-+    - ``inner2`` -- a partition
- 
--    - ``inner2`` -- a partition.
--
--    .. warning::
-+    .. WARNING::
- 
-        This function does not do any check on its input.  If you want
-        to use a safer version, use :func:`lrcoef`.
-@@ -392,18 +232,7 @@ def lrcoef_unsafe(outer, inner1, inner2):
-         sage: lrcoef_unsafe([2,1,1,1,1], [2,1], [2,1])
-         0
-     """
--    cdef long long result
--    cdef vector *o
--    cdef vector *i1
--    cdef vector *i2
--    o = iterable_to_vector(outer)
--    i1 = iterable_to_vector(inner1)
--    i2 = iterable_to_vector(inner2)
--    result = lrcoef_c(o, i1, i2)
--    v_free(o)
--    v_free(i1)
--    v_free(i2)
--    return Integer(result)
-+    return Integer(lrcalc.lrcoef(outer, inner1, inner2))
- 
- 
- def lrcoef(outer, inner1, inner2):
-@@ -415,11 +244,9 @@ def lrcoef(outer, inner1, inner2):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
--
--    - ``inner1`` -- a partition.
--
--    - ``inner2`` -- a partition.
-+    - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
-+    - ``inner1`` -- a partition
-+    - ``inner2`` -- a partition
- 
-     .. NOTE::
- 
-@@ -436,7 +263,6 @@ def lrcoef(outer, inner1, inner2):
-         1
-         sage: lrcoef([2,1,1,1,1], [2,1], [2,1])
-         0
--
-     """
-     return lrcoef_unsafe(_Partitions(outer), _Partitions(inner1), _Partitions(inner2))
- 
-@@ -451,13 +277,9 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-     INPUT:
- 
-     - ``part1`` -- a partition
--
-     - ``part2`` -- a partition
--
-     - ``maxrows`` -- (optional) an integer
--
-     - ``level`` -- (optional) an integer
--
-     - ``quantum`` -- (optional) an element of a ring
- 
-     If ``maxrows`` is specified, then only partitions with at most
-@@ -479,7 +301,8 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-         sage: sorted(mult([2],[2]).items())
-         [([2, 2], 1), ([3, 1], 1), ([4], 1)]
-         sage: sorted(mult([2,1],[2,1]).items())
--        [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1), ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
-+        [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1),
-+         ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
-         sage: sorted(mult([2,1],[2,1],maxrows=2).items())
-         [([3, 3], 1), ([4, 2], 1)]
-         sage: mult([2,1],[3,2,1],3)
-@@ -510,44 +333,24 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-     if quantum is not None and (level is None or maxrows is None):
-         raise ValueError('missing parameters maxrows or level')
- 
--    cdef vector* v1 = iterable_to_vector(part1)
--    cdef vector* v2 = iterable_to_vector(part2)
--    if maxrows is None:
--        maxrows = 0
--    cdef hashtab* ht = mult_c(v1, v2, int(maxrows))
--    cdef hashtab* tab
--    cdef dict result
--
-     if quantum is None:
-         if level is not None:
--            fusion_reduce_c(ht, int(maxrows), int(level), int(0))
--        result = sf_hashtab_to_dict(ht)
--        v_free(v1)
--        v_free(v2)
--        hash_free(ht)
--        return result
-+            return _lrcalc_dict_to_sage(lrcalc.mult_fusion(part1, part2, maxrows, level))
-+        if maxrows is None:
-+            maxrows = -1
-+        return _lrcalc_dict_to_sage(lrcalc.mult(part1, part2, maxrows))
- 
-     # Otherwise do quantum multiplication
--    cdef _list *qlist
--    cdef dict temp
--    qlist = quantum_reduce_c(ht, int(maxrows), int(level))
--    # The above call frees the memory associated with ht
--    v_free(v1)
--    v_free(v2)
--
--    cdef Parent P = quantum.parent()
--    result = {}
--    for i in range(qlist.length):
--        tab = <hashtab*>(qlist.array[i])
--        temp = sf_hashtab_to_dict(tab)
--        for k in temp:
--            result[k] = result.get(k, P.zero()) + quantum**i * temp[k]
--        hash_free(tab)
--    l_free(qlist)
--    return result
--
--
--def skew(outer, inner, maxrows=0):
-+    result = lrcalc.mult_quantum(part1, part2, maxrows, level, degrees=True)
-+    P = quantum.parent()
-+    output = {}
-+    for i,k in result.items():
-+        la = _Partitions(i[0])
-+        output[la] = output.get(la, P.zero()) + k * quantum**(i[1])
-+    return output
-+
-+
-+def skew(outer, inner, maxrows=-1):
-     """
-     Compute the Schur expansion of a skew Schur function.
- 
-@@ -557,11 +360,9 @@ def skew(outer, inner, maxrows=0):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition.
--
--    - ``inner`` -- a partition.
--
--    - ``maxrows`` -- an integer or ``None``.
-+    - ``outer`` -- a partition
-+    - ``inner`` -- a partition
-+    - ``maxrows`` -- an integer or ``None``
- 
-     If ``maxrows`` is specified, then only partitions with at most
-     this number of rows are included in the result.
-@@ -572,14 +373,7 @@ def skew(outer, inner, maxrows=0):
-         sage: sorted(skew([2,1],[1]).items())
-         [([1, 1], 1), ([2], 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(outer)
--    cdef vector* v2 = iterable_to_vector(inner)
--    cdef hashtab* ht = skew_c(v1, v2, int(maxrows))
--    result = sf_hashtab_to_dict(ht)
--    v_free(v1)
--    v_free(v2)
--    hash_free(ht)
--    return result
-+    return _lrcalc_dict_to_sage(lrcalc.skew(outer, inner, maxrows))
- 
- 
- def coprod(part, all=0):
-@@ -592,9 +386,8 @@ def coprod(part, all=0):
- 
-     INPUT:
- 
--    - ``part`` -- a partition.
--
--    - ``all`` -- an integer.
-+    - ``part`` -- a partition
-+    - ``all`` -- an integer
- 
-     If ``all`` is non-zero then all terms are included in the result.
-     If ``all`` is zero, then only pairs of partitions ``(part1,
-@@ -609,12 +402,9 @@ def coprod(part, all=0):
-         sage: sorted(coprod([2,1]).items())
-         [(([1, 1], [1]), 1), (([2], [1]), 1), (([2, 1], []), 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(part)
--    cdef hashtab* ht = coprod_c(v1, int(all))
--    result = vp_hashtab_to_dict(ht)
--    v_free(v1)
--    hash_free(ht)
--    return result
-+    result = lrcalc.coprod(part, all)
-+    return {tuple([_Partitions(mu) for mu in la]): Integer(k)
-+            for la, k in result.items()}
- 
- 
- def mult_schubert(w1, w2, rank=0):
-@@ -627,11 +417,9 @@ def mult_schubert(w1, w2, rank=0):
- 
-     INPUT:
- 
--    - ``w1`` -- a permutation.
--
--    - ``w2`` -- a permutation.
--
--    - ``rank`` -- an integer.
-+    - ``w1`` -- a permutation
-+    - ``w2`` -- a permutation
-+    - ``rank`` -- an integer
- 
-     If ``rank`` is non-zero, then only permutations from the symmetric
-     group `S(\mathrm{rank})` are included in the result.
-@@ -646,33 +434,24 @@ def mult_schubert(w1, w2, rank=0):
-          ([6, 4, 3, 1, 2, 5], 1), ([6, 5, 2, 1, 3, 4], 1),
-          ([7, 3, 4, 1, 2, 5, 6], 1), ([7, 4, 2, 1, 3, 5, 6], 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(w1)
--    cdef vector* v2 = iterable_to_vector(w2)
--    cdef hashtab* ht = mult_schubert_c(v1, v2, int(rank))
--    result = schubert_hashtab_to_dict(ht)
--    v_free(v1)
--    v_free(v2)
--    hash_free(ht)
--    return result
-+    result = lrcalc.schubmult(w1, w2, rank)
-+    return {Permutation(list(la)):Integer(k) for la,k in result.items()}
- 
- 
--def lrskew(outer, inner, weight=None, maxrows=0):
-+def lrskew(outer, inner, weight=None, maxrows=-1):
-     r"""
-     Iterate over the skew LR tableaux of shape ``outer / inner``.
- 
-     INPUT:
- 
-     - ``outer`` -- a partition
--
-     - ``inner`` -- a partition
--
-     - ``weight`` -- a partition (optional)
--
--    - ``maxrows`` -- an integer (optional)
-+    - ``maxrows`` -- a positive integer (optional)
- 
-     OUTPUT: an iterator of :class:`SkewTableau`
- 
--    Specifying ``maxrows`` restricts the alphabet to `\{1,2,\ldots,maxrows\}`.
-+    Specifying ``maxrows`` = `M` restricts the alphabet to `\{1,2,\ldots,M\}`.
- 
-     Specifying ``weight`` returns only those tableaux of given content/weight.
- 
-@@ -702,22 +481,40 @@ def lrskew(outer, inner, weight=None, maxrows=0):
- 
-         sage: list(lrskew([3,2,1],[2], weight=[3,1]))
-         [[[None, None, 1], [1, 1], [2]]]
-+
-+    TESTS::
-+
-+        sage: from sage.libs.lrcalc.lrcalc import lrskew
-+        sage: list(lrskew([3,2,1],[2], weight=[]))
-+        []
-+        sage: list(lrskew([3,2,1],[2], weight=[0]))
-+        []
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[]))
-+        [[[None, None, None], [None, None], [None]]]
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[0]))
-+        [[[None, None, None], [None, None], [None]]]
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[1]))
-+        []
-     """
--    cdef vector* o = iterable_to_vector(outer)
--    cdef vector* i = iterable_to_vector(inner + [0]*(len(outer) - len(inner)))
--    cdef skewtab* st = st_new(o, i, NULL, int(maxrows))
-+    iterator = lrcalc.lr_iterator(outer, inner, maxrows)
-+    shape = SkewPartition([outer, inner])
- 
-     if weight is None:
--        yield skewtab_to_SkewTableau(st)
--        while st_next(st):
--            yield skewtab_to_SkewTableau(st)
-+        ST = SemistandardSkewTableaux(shape)
-+        for data in iterator:
-+            yield ST.from_shape_and_word(shape, [i+1 for i in data])
-     else:
-         wt = _Partitions(weight)
--        r = skewtab_to_SkewTableau(st)
--        if r.weight() == wt:
--            yield r
--        while st_next(st):
--            r = skewtab_to_SkewTableau(st)
--            if r.weight() == wt:
--                yield r
--    st_free(st)
-+        ST = SemistandardSkewTableaux(shape, wt)
-+        m = len(wt)
-+        for data in iterator:
-+            w = [0] * m
-+            for j in data:
-+                if j >= m:
-+                    # We know they are not equal, so make the check below quick
-+                    w = None
-+                    break
-+                w[j] += 1
-+            if w == wt:
-+                yield ST.from_shape_and_word(shape, [i+1 for i in data])
-+
diff --git a/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch b/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
deleted file mode 100644
index 1e2e0ba90742..000000000000
--- a/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-As produced by `git diff a90a3146{^^,}`
-
-diff --git a/src/sage/repl/interface_magic.py b/src/sage/repl/interface_magic.py
-index 8a455b69b0e..a93e1c9e04c 100644
---- a/src/sage/repl/interface_magic.py
-+++ b/src/sage/repl/interface_magic.py
-@@ -260,7 +260,7 @@ class InterfaceMagic(object):
-             2
-             120
-             sage: shell.run_cell('%%gap foo\n1+1;\n')
--            ...File "<string>", line unknown
-+            ...File...<string>...
-             SyntaxError: Interface magics have no options, got "foo"
-             <BLANKLINE>
-             sage: shell.run_cell('%%gap?')
-diff --git a/src/sage/repl/interpreter.py b/src/sage/repl/interpreter.py
-index 7468afe52d7..06c47b7374a 100644
---- a/src/sage/repl/interpreter.py
-+++ b/src/sage/repl/interpreter.py
-@@ -78,9 +78,9 @@ Check that Cython source code appears in tracebacks::
-     dummy line
-     ...
-     ZeroDivisionError...Traceback (most recent call last)
--    <ipython-input-...> in <module>...
-+    ...in <module>...
-     ----> 1 Integer(1)/Integer(0)
--    .../sage/rings/integer.pyx in sage.rings.integer.Integer...div...
-+    .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
-     ...
-     -> ...                  raise ZeroDivisionError("rational division by zero")
-        ....:            x = <Rational> Rational.__new__(Rational)
-@@ -423,7 +423,7 @@ def SagePreparseTransformer(lines):
-         sage: from sage.repl.interpreter import get_test_shell
-         sage: shell = get_test_shell()
-         sage: shell.run_cell(bad_syntax)
--          File "<string>", line unknown
-+          File...<string>...
-         SyntaxError: Mismatched ']'
-         <BLANKLINE>
-         sage: shell.quit()
diff --git a/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch b/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
deleted file mode 100644
index 853813b0f5bd..000000000000
--- a/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Fix for ipython 8.1
-
---- a/src/sage/repl/interpreter.py
-+++ b/src/sage/repl/interpreter.py
-@@ -78,7 +78,7 @@ Check that Cython source code appears in tracebacks::
-     dummy line
-     ...
-     ZeroDivisionError...Traceback (most recent call last)
--    ...in <module>...
-+    ...
-     ----> 1 Integer(1)/Integer(0)
-     .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
-     ...
diff --git a/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch b/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
deleted file mode 100644
index b861af7ec982..000000000000
--- a/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
+++ /dev/null
@@ -1,126 +0,0 @@
-From 24cc94b1988a90f3bd22a2368ec30c086283af13 Mon Sep 17 00:00:00 2001
-From: Antonio Rojas <arojas@archlinux.org>
-Date: Sun, 16 Jan 2022 11:55:04 +0100
-Subject: Add abs tol to some arb tests
-
----
- src/sage/functions/error.py    |  2 +-
- src/sage/rings/complex_arb.pyx |  6 +++---
- src/sage/rings/real_arb.pyx    | 10 +++++-----
- 3 files changed, 9 insertions(+), 9 deletions(-)
-
-diff --git a/src/sage/functions/error.py b/src/sage/functions/error.py
-index f48d04f..06f0b24 100644
---- a/src/sage/functions/error.py
-+++ b/src/sage/functions/error.py
-@@ -267,7 +267,7 @@ class Function_erf(BuiltinFunction):
- 
-         Check that real ball evaluation is fixed :trac:`28061`::
- 
--            sage: RealBallField(128)(erf(5))
-+            sage: RealBallField(128)(erf(5)) # abs tol 1e-38
-             [0.99999999999846254020557196514981165651 +/- 7.33e-39]
-         """
-         R = parent or s_parent(x)
-diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
-index f986970..93ff565 100644
---- a/src/sage/rings/complex_arb.pyx
-+++ b/src/sage/rings/complex_arb.pyx
-@@ -3974,8 +3974,8 @@ cdef class ComplexBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: CBF(20).erfc()
--            [5.39586561160790e-176 +/- ...e-191]
-+            sage: CBF(20).erfc() # abs tol 1e-190
-+            [5.39586561160790e-176 +/- 6.73e-191]
-             sage: CBF(100, 100).erfc()
-             [0.00065234366376858 +/- ...e-18] + [-0.00393572636292141 +/- ...e-18]*I
-         """
-@@ -4280,7 +4280,7 @@ cdef class ComplexBall(RingElement):
- 
-         TESTS:
- 
--            sage: CBF(Shi(I))
-+            sage: CBF(Shi(I)) # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]*I
-         """
-         cdef ComplexBall result = self._new()
-diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
-index 4a81784..292bfea 100644
---- a/src/sage/rings/real_arb.pyx
-+++ b/src/sage/rings/real_arb.pyx
-@@ -3506,7 +3506,7 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1/2).erf()
-+            sage: RBF(1/2).erf() # abs tol 1e-16
-             [0.520499877813047 +/- 6.10e-16]
-         """
-         cdef RealBall res = self._new()
-@@ -3556,12 +3556,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Si()
-+            sage: RBF(1).Si() # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]
- 
-         TESTS::
- 
--            sage: RBF(Si(1))
-+            sage: RBF(Si(1)) # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]
-         """
-         cdef RealBall res = self._new()
-@@ -3578,12 +3578,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Ci()  # abs tol 1e-16
-+            sage: RBF(1).Ci()  # abs tol 1e-15
-             [0.337403922900968 +/- 3.25e-16]
- 
-         TESTS::
- 
--            sage: RBF(Ci(1))  # abs tol 1e-16
-+            sage: RBF(Ci(1))  # abs tol 1e-15
-             [0.337403922900968 +/- 3.25e-16]
-         """
-         cdef RealBall res = self._new()
--- 
-cgit v1.0-1-gd88e
-
-
-From 53532ddd4e2dc92469c1590ebf0c40f8f69bf579 Mon Sep 17 00:00:00 2001
-From: Antonio Rojas <arojas@archlinux.org>
-Date: Sun, 16 Jan 2022 14:16:53 +0100
-Subject: Decrease abs tol
-
----
- src/sage/rings/real_arb.pyx | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
-index 292bfea..eb30f7f 100644
---- a/src/sage/rings/real_arb.pyx
-+++ b/src/sage/rings/real_arb.pyx
-@@ -3578,12 +3578,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Ci()  # abs tol 1e-15
-+            sage: RBF(1).Ci()  # abs tol 5e-16
-             [0.337403922900968 +/- 3.25e-16]
- 
-         TESTS::
- 
--            sage: RBF(Ci(1))  # abs tol 1e-15
-+            sage: RBF(Ci(1))  # abs tol 5e-16
-             [0.337403922900968 +/- 3.25e-16]
-         """
-         cdef RealBall res = self._new()
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch b/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
deleted file mode 100644
index d4e8f8be60e3..000000000000
--- a/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From 33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c Mon Sep 17 00:00:00 2001
-From: Michael Orlitzky <michael@orlitzky.com>
-Date: Mon, 24 Jan 2022 09:03:29 -0500
-Subject: Trac #33226: update doctests for giac-1.7.0.45.
-
-We have two failing doctests with giac-1.7.0.45: one is a trivial
-tolerance issue, but the other is a symbolic integration result for
-which giac is no longer willing to return a symbolic answer. We add
-"abs tol" to the numeric test, and drop the symbolic one entirely.
----
- src/sage/functions/min_max.py | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/src/sage/functions/min_max.py b/src/sage/functions/min_max.py
-index fc18373..9b7d6d9 100644
---- a/src/sage/functions/min_max.py
-+++ b/src/sage/functions/min_max.py
-@@ -228,15 +228,15 @@ class MaxSymbolic(MinMax_base):
-             ...
-             TypeError: cannot evaluate symbolic expression numerically
- 
--        ::
-+        We can usually integrate these expressions, but can't
-+        guarantee a symbolic answer in closed form::
- 
-             sage: f = max_symbolic(sin(x), cos(x))
-             sage: r = integral(f, x, 0, 1)
-             ...
--            sage: r
--            sqrt(2) - cos(1)
--            sage: r.n()
-+            sage: r.n()  # abs tol 1e-8
-             0.873911256504955
-+
-         """
-         return max_symbolic(args)
- 
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch b/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
deleted file mode 100644
index 19b69700a4f6..000000000000
--- a/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-commit 9c8235e44ffb509efa8a3ca6cdb55154e2b5066d
-Author: Antonio Rojas <arojas@archlinux.org>
-Date:   Sun Feb 13 19:53:14 2022 +0100
-
-    Fix deprecation warning with scipy 1.8
-
-diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-index e9b60dae5ec..7932167b41d 100644
---- a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-@@ -356,7 +356,7 @@ Sage example in ./linsolve.tex, line 2230::
- 
- Sage example in ./linsolve.tex, line 2609::
- 
--  sage: from scipy.sparse.linalg.dsolve import *
-+  sage: from scipy.sparse.linalg import factorized
-   sage: from scipy.sparse import lil_matrix
-   sage: from numpy import array
-   sage: n = 200
diff --git a/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch b/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
new file mode 100644
index 000000000000..e052e306e7a1
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
@@ -0,0 +1,53 @@
+From 6330cee1a69229b2f5d8ac4a09a73d8152f5e14d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Mon, 28 Feb 2022 23:15:16 -0300
+Subject: trac 33360: avoid factoring in is_prime()
+
+In the added TEST, the ideal norm is product of two primes but factoring
+this product takes about half an hour, so factoring the ideal is slow.
+
+To fix the issue, we only factor the ideal if the norm is a prime power.
+---
+ src/sage/rings/number_field/number_field_ideal.py | 22 ++++++++++++++++++++++
+ 1 file changed, 22 insertions(+)
+
+diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
+index f785f22..10d1f88 100644
+--- a/src/sage/rings/number_field/number_field_ideal.py
++++ b/src/sage/rings/number_field/number_field_ideal.py
+@@ -995,10 +995,32 @@ class NumberFieldIdeal(Ideal_generic):
+             False
+             sage: K.ideal(17).is_prime()  # ramified
+             False
++
++        TESTS::
++
++        Check that we do not factor the norm of the ideal, this used
++        to take half an hour, see :trac:`33360`
++
++           sage: K.<a,b,c> = NumberField([x^2-2,x^2-3,x^2-5])
++           sage: t = (((-2611940*c + 1925290/7653)*b - 1537130/7653*c
++           ....:       + 10130950)*a + (1343014/7653*c - 8349770)*b
++           ....:       + 6477058*c - 2801449990/4002519)
++           sage: t.is_prime()
++           False
++
+         """
+         try:
+             return self._pari_prime is not None
+         except AttributeError:
++            K = self.number_field().pari_nf()
++            I = self.pari_hnf()
++            # This would be better, but it is broken in pari 2.13.3.
++            #   self._pari_prime = K.idealismaximal(I) or None
++            # Instead we factor I, but only if the norm is a prime power
++            n = K.idealnorm(I)
++            if n.denominator() > 1 or not n.isprimepower():
++                self._pari_prime = None
++                return False
+             F = self.factor()  # factorization with caching
+             if len(F) != 1 or F[0][1] != 1:
+                 self._pari_prime = None
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
deleted file mode 100644
index 9ba7ca5a6b7d..000000000000
--- a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
+++ /dev/null
@@ -1,99 +0,0 @@
-From 609dd9deaeaa6380ab2f0d50276d911233c00a04 Mon Sep 17 00:00:00 2001
-From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
-Date: Fri, 4 Mar 2022 16:07:09 -0800
-Subject: sage.manifolds: Update doctests for SymPy 1.10
-
----
- src/sage/manifolds/continuous_map.py              | 3 +--
- src/sage/manifolds/differentiable/diff_form.py    | 4 ++--
- src/sage/manifolds/differentiable/tensorfield.py  | 8 ++++----
- src/sage/manifolds/vector_bundle_fiber_element.py | 2 +-
- 4 files changed, 8 insertions(+), 9 deletions(-)
-
-diff --git a/src/sage/manifolds/continuous_map.py b/src/sage/manifolds/continuous_map.py
-index a6356e7..f6f9b6d 100644
---- a/src/sage/manifolds/continuous_map.py
-+++ b/src/sage/manifolds/continuous_map.py
-@@ -1357,8 +1357,7 @@ class ContinuousMap(Morphism):
-             sage: Phi.coord_functions(c_uv, c_xyz)
-             Coordinate functions (u*v, u/v, u + v) on the Chart (M, (u, v))
-             sage: Phi.coord_functions(c_UV, c_xyz)
--            Coordinate functions (-U**2/4 + V**2/4, -(U + V)/(U - V), V)
--             on the Chart (M, (U, V))
-+            Coordinate functions (-U**2/4 + V**2/4, (-U - V)/(U - V), V) on the Chart (M, (U, V))
-             sage: Phi.coord_functions(c_UV, c_XYZ)
-             Coordinate functions ((-U**3 + U**2*V + U*V**2 + 2*U*V + 6*U - V**3
-              - 2*V**2 + 6*V)/(2*(U - V)), (U**3/4 - U**2*V/4 - U*V**2/4 + U*V
-diff --git a/src/sage/manifolds/differentiable/diff_form.py b/src/sage/manifolds/differentiable/diff_form.py
-index 70dd8fb..0aa3469 100644
---- a/src/sage/manifolds/differentiable/diff_form.py
-+++ b/src/sage/manifolds/differentiable/diff_form.py
-@@ -266,7 +266,7 @@ class DiffForm(TensorField):
- 
-         sage: s = a.wedge(b)
-         sage: s.display(eU)
--        a∧b = -x*(2*x*y + 1) dx∧dy
-+        a∧b = x*(-2*x*y - 1) dx∧dy
-         sage: s.display(eV)
-         a∧b = (u**3/8 + u**2*v/8 - u*v**2/8 + u/4 - v**3/8 + v/4) du∧dv
- 
-@@ -275,7 +275,7 @@ class DiffForm(TensorField):
-         sage: f = M.scalar_field({c_xy: (x+y)^2, c_uv: u^2}, name='f')
-         sage: s = f*a
-         sage: s.display(eU)
--        f*a = -y*(x**2 + 2*x*y + y**2) dx + x*(x**2 + 2*x*y + y**2) dy
-+        f*a = y*(-x**2 - 2*x*y - y**2) dx + x*(x**2 + 2*x*y + y**2) dy
-         sage: s.display(eV)
-         f*a = u**2*v/2 du - u**3/2 dv
- 
-diff --git a/src/sage/manifolds/differentiable/tensorfield.py b/src/sage/manifolds/differentiable/tensorfield.py
-index 2775be9..6bc5c50 100644
---- a/src/sage/manifolds/differentiable/tensorfield.py
-+++ b/src/sage/manifolds/differentiable/tensorfield.py
-@@ -334,7 +334,7 @@ class TensorField(ModuleElementWithMutability):
-         sage: f.display()  # long time
-         t(a,b): S^2 → ℝ
-         on U: (x, y) ↦ -2*x*y - 3*x - y**2
--        on V: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+        on V: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
- 
-     The vectors can be defined only on subsets of `S^2`, the domain of the
-     result is then the common subset::
-@@ -343,12 +343,12 @@ class TensorField(ModuleElementWithMutability):
-         sage: s.display()  # long time
-         t(a,b): U → ℝ
-            (x, y) ↦ -2*x*y - 3*x - y**2
--        on W: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+        on W: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
-         sage: s = t(a.restrict(U), b.restrict(W))  # long time
-         sage: s.display()  # long time
-         t(a,b): W → ℝ
-            (x, y) ↦ -2*x*y - 3*x - y**2
--           (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+           (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
- 
-     The tensor itself can be defined only on some open subset of `S^2`,
-     yielding a result whose domain is this subset::
-@@ -356,7 +356,7 @@ class TensorField(ModuleElementWithMutability):
-         sage: s = t.restrict(V)(a,b)  # long time
-         sage: s.display()  # long time
-         t(a,b): V → ℝ
--           (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+           (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
-         on W: (x, y) ↦ -2*x*y - 3*x - y**2
- 
-     Tests regarding the multiplication by a scalar field::
-diff --git a/src/sage/manifolds/vector_bundle_fiber_element.py b/src/sage/manifolds/vector_bundle_fiber_element.py
-index 29ee81d..048275a 100644
---- a/src/sage/manifolds/vector_bundle_fiber_element.py
-+++ b/src/sage/manifolds/vector_bundle_fiber_element.py
-@@ -110,4 +110,4 @@ class VectorBundleFiberElement(FiniteRankFreeModuleElement):
-             desc += str(self._name) + " "
-         desc += "in the fiber of {} at {}".format(self._vbundle._name,
-                                                   self._point)
--        return desc
-\ No newline at end of file
-+        return desc
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
deleted file mode 100644
index f5ac180baa90..000000000000
--- a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From c49eff347454ac7f07e5918470b20e97b8f2357e Mon Sep 17 00:00:00 2001
-From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
-Date: Fri, 4 Mar 2022 15:14:43 -0800
-Subject: src/sage/calculus/calculus.py: Update laplace doctest for sympy 1.10
-
----
- src/sage/calculus/calculus.py | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/src/sage/calculus/calculus.py b/src/sage/calculus/calculus.py
-index 9c2f226..b335093 100644
---- a/src/sage/calculus/calculus.py
-+++ b/src/sage/calculus/calculus.py
-@@ -1639,9 +1639,9 @@ def laplace(ex, t, s, algorithm='maxima'):
-         sage: laplace(dirac_delta(t), t, s)
-         1
-         sage: F, a, cond = laplace(dirac_delta(t), t, s, algorithm='sympy')
--        sage: a, cond
--        (-oo, True)
--        sage: F       # random - sympy <1.9 includes undefined heaviside(0) in answer
-+        sage: a, cond  # random - sympy <1.10 gives (-oo, True)
-+        (0, True)
-+        sage: F        # random - sympy <1.9 includes undefined heaviside(0) in answer
-         1
-         sage: laplace(dirac_delta(t), t, s, algorithm='giac')
-         1
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch b/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
deleted file mode 100644
index 8e7bb64f5b01..000000000000
--- a/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From a04a0a0b14f67f4804e7113c3db41bbcf8a58296 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
-Date: Mon, 28 Mar 2022 20:39:59 -0300
-Subject: Trac #33585: fix doctest when dochtml is missing...
-
-...but sphinx is available in PYTHONPATH.
----
- src/sage/misc/sagedoc.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/sage/misc/sagedoc.py b/src/sage/misc/sagedoc.py
-index 4b3853f..08c4225 100644
---- a/src/sage/misc/sagedoc.py
-+++ b/src/sage/misc/sagedoc.py
-@@ -1401,7 +1401,7 @@ class _sage_doc:
-             "...**File:**...**Type:**...**Definition:** identity_matrix..."
-             sage: identity_matrix.__doc__ in browse_sage_doc(identity_matrix, 'rst')
-             True
--            sage: browse_sage_doc(identity_matrix, 'html', False)             # optional - sphinx
-+            sage: browse_sage_doc(identity_matrix, 'html', False)             # optional - sphinx sagemath_doc_html
-             '...div...File:...Type:...Definition:...identity_matrix...'
- 
-         In the 'text' version, double colons have been replaced with
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch b/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
new file mode 100644
index 000000000000..977a42400e59
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
@@ -0,0 +1,42 @@
+commit 5db5d4e56243c609f44afc1f21c112b026f9e1fe
+Author: Oscar Benjamin <oscar.j.benjamin@gmail.com>
+Date:   Mon Jul 11 21:24:01 2022 +0100
+
+    Update doctests for SymPy 1.11
+    
+    Doctests related to SymPy's rsolve function are updated in:
+    
+    src/sage/calculus/test_sympy.py
+    src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+    
+    The form of the output from SymPy has changed since
+    
+    https://github.com/sympy/sympy/pull/23567
+
+diff --git a/src/sage/calculus/test_sympy.py b/src/sage/calculus/test_sympy.py
+index 7cf7f3f6bfd..927e6ee4fb6 100644
+--- a/src/sage/calculus/test_sympy.py
++++ b/src/sage/calculus/test_sympy.py
+@@ -193,7 +193,7 @@ This was fixed in Sympy, see :trac:`14437`::
+     sage: u = Function('u')
+     sage: n = Symbol('n', integer=True)
+     sage: f = u(n+2) - u(n+1) + u(n)/4
+-    sage: 2**n * rsolve(f,u(n))
+-    C1*n + C0
++    sage: expand(2**n * rsolve(f,u(n)))
++    2*C1*n + C0
+ 
+ """
+diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+index 1062f4f7e8c..f53f813d793 100644
+--- a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
++++ b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+@@ -382,7 +382,7 @@ Sage example in ./recequadiff.tex, line 1798::
+   sage: from sympy import rsolve_hyper
+   sage: from sympy.abc import n
+   sage: rsolve_hyper([-2,1],2**(n+2),n)
+-  2**n*C0 + 2**(n + 2)*(C0 + n/2)
++  2**n*C0 + 2**(n + 1)*n
+ 
+ """
+ 
diff --git a/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch b/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
new file mode 100644
index 000000000000..8fedcb78cf71
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
@@ -0,0 +1,19 @@
+commit 04971318f032caf8dc1c0de9489346d894409091
+Author: John H. Palmieri <jhpalmieri64@gmail.com>
+Date:   Wed Aug 31 14:22:26 2022 -0700
+
+    trac 34465: fix invalid escape sequence in functions/special.py
+
+diff --git a/src/sage/functions/special.py b/src/sage/functions/special.py
+index 02596e49620..901f02f9bee 100644
+--- a/src/sage/functions/special.py
++++ b/src/sage/functions/special.py
+@@ -849,7 +849,7 @@ class EllipticF(BuiltinFunction):
+     - :wikipedia:`Elliptic_integral#Incomplete_elliptic_integral_of_the_first_kind`
+     """
+     def __init__(self):
+-        """
++        r"""
+         EXAMPLES::
+ 
+             sage: loads(dumps(elliptic_f))
diff --git a/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch b/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch
deleted file mode 100644
index f3eb0aad2cca..000000000000
--- a/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch
+++ /dev/null
@@ -1,14 +0,0 @@
- - this is not a proper fix... should fix sage_getfile() instead
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -187,7 +187,8 @@ def loadable_module_extension():
-         True
-     """
-     # Return the full platform-specific extension module suffix
--    return import_machinery.EXTENSION_SUFFIXES[0]
-+    # PATCHED for void linux, we use the shortest extension (.so)
-+    return import_machinery.EXTENSION_SUFFIXES[-1]
- 
- 
- def isclassinstance(obj):
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 0d793262d572..8df50e4e13b6 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,7 +1,7 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=9.5
-revision=2
+version=9.7
+revision=1
 wrksrc=sage-$version
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
@@ -33,12 +33,9 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="http://sagemath.org/"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=8d70a3b26080802c5b2e33dda4c23795d494d8216a0c2ecfcd608ebab0e64ff6
+checksum=9f26f14aa322e3cf38a71835b12ac34b23026b467f74d54b064c5d025e76fbfd
 
 post_patch() {
-	# these are unused and nothing else uses ratpoints
-	rm sage/libs/ratpoints.{pyx,pxd}
-
 	# git tree needs bootstrapping
 	pushd $wrksrc/build/pkgs/sagelib
 	PATH=../../bin:$PATH BOOTSTRAP_QUIET=no ./bootstrap
@@ -65,6 +62,7 @@ do_configure() {
 
 pre_build() {
 	export PYTHONPATH=../sage-setup
+	export PYTHONDONTWRITEBYTECODE=yes
 	export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
 }
 
@@ -77,6 +75,7 @@ post_build() {
 
 pre_install() {
 	export PYTHONPATH=../sage-setup
+	export PYTHONDONTWRITEBYTECODE=yes
 	export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
 }
 
@@ -104,6 +103,7 @@ post_install() {
 do_check() {
 	_scripts=$(cd build/scripts* && pwd)
 	export PYTHONPATH=$(cd build/lib* && pwd)
+	export PYTHONDONTWRITEBYTECODE=yes
 
 	# get out of $build_wrksrc, otherwise python picks the wrong sage module
 	cd $(mktemp -dp build)

From dd425214cffdaed6423ddb047a7737eab4a7db1e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Thu, 13 Oct 2022 00:08:32 -0300
Subject: [PATCH 14/14] giac: temporary ci-skip

---
 srcpkgs/giac/template | 1 +
 1 file changed, 1 insertion(+)

diff --git a/srcpkgs/giac/template b/srcpkgs/giac/template
index 31045e9128ee..a0c2f1799710 100644
--- a/srcpkgs/giac/template
+++ b/srcpkgs/giac/template
@@ -15,6 +15,7 @@ homepage="https://www-fourier.ujf-grenoble.fr/~parisse/giac.html"
 changelog="https://www-fourier.ujf-grenoble.fr/~parisse/install_en#new"
 distfiles="https://www-fourier.ujf-grenoble.fr/~parisse/debian/dists/stable/main/source/giac_${version%.*}-${version##*.}.tar.gz"
 checksum=120cd16f2e033817302d2a03a22bd413dc1d85df8b225ba4f76b93a7805b07fe
+make_check=ci-skip # temporary, there's one test failure (TODO: FIX)
 
 # need more than 4*65536 stack, see try_parse() in gen.cc line 11812
 LDFLAGS="-Wl,-z,stack-size=2097152"

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PR PATCH] [Updated] DRAFT: sagemath update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (12 preceding siblings ...)
  2022-10-13  3:15 ` [PR PATCH] [Updated] " tornaria
@ 2022-10-13 14:03 ` tornaria
  2022-10-14 20:11 ` tornaria
                   ` (18 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: tornaria @ 2022-10-13 14:03 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1883 bytes --]

There is an updated pull request by tornaria against master on the void-packages repository

https://github.com/tornaria/void-packages sagemath-update
https://github.com/void-linux/void-packages/pull/39876

DRAFT: sagemath update to 9.7
This includes #39838, #39840, #39846, #39872, #39866, also update eclib-20220621.

For now I'm reverting python3-matplotlib to 3.5.3_1 since 3.6.0_1 gives a lot of problems (#39857 adds python3-contourpy which will solve some, but I think there are more issues).

I want to make sure everything works ok and the full testsuite passes as is. Then I'll just move matplotlib back to 3.6.0_1 and try to see if it's feasible to fix or workaround the issues (sagemath-the-distro is still on matplotlib 3.5.2 and I didn't find anything about the update to 3.6.0)

<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: currently running the testsuite in --long after the update of singular.

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/39876.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-sagemath-update-39876.patch --]
[-- Type: text/x-diff, Size: 221881 bytes --]

From 9ad60ff9115f585ba2d0689941159603ed8606aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 19:14:02 -0300
Subject: [PATCH 01/13] flintlib: update to 2.9.0.

---
 common/shlibs             | 2 +-
 srcpkgs/flintlib/template | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index de0428d0987d..f220c136eced 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4014,7 +4014,7 @@ libgtkdatabox.so.1 gtkdatabox3-1.0.0_1
 libxcvt.so.0 libxcvt-0.1.1_1
 libgf2x.so.3 gf2x-1.3.0_1
 libntl.so.44 ntl-11.5.1_1
-libflint.so.16 flintlib-2.8.0_1
+libflint.so.17 flintlib-2.9.0_1
 libarb.so.2 arb-2.20.0_1
 libec.so.8 eclib-20210625_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index 968dbcb525c2..27f202b4434c 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,6 +1,6 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.8.5
+version=2.9.0
 revision=1
 wrksrc="flint-${version}"
 build_style=configure
@@ -14,11 +14,10 @@ license="LGPL-2.1-or-later"
 homepage="https://flintlib.org"
 changelog="https://raw.githubusercontent.com/wbhart/flint2/trunk/NEWS"
 distfiles="https://flintlib.org/flint-${version}.tar.gz"
-checksum=5911fedff911100f15781f35e3a4fa934fe60e4aea02a8c10cc8918101c1eed8
+checksum=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
-build_options_default=""
 
 if [ -z "$CROSS_BUILD" ]; then
 	build_options_default+=" ntl"

From 971c79460386610d784541041aeb7314613ca4ec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 19:16:18 -0300
Subject: [PATCH 02/13] arb: update to 2.23.0.

---
 srcpkgs/arb/template | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
index 52f11ef83c90..84a62c7ffdba 100644
--- a/srcpkgs/arb/template
+++ b/srcpkgs/arb/template
@@ -1,6 +1,6 @@
 # Template file for 'arb'
 pkgname=arb
-version=2.22.1
+version=2.23.0
 revision=1
 build_style=configure
 configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
@@ -11,9 +11,7 @@ license="LGPL-2.1-or-later"
 homepage="https://arblib.org"
 changelog="https://raw.githubusercontent.com/fredrik-johansson/arb/master/doc/source/history.rst"
 distfiles="https://github.com/fredrik-johansson/arb/archive/${version}.tar.gz"
-checksum=1ef85518eee04885e8a90196498bc75e4e2410621d4184f2bc01d46b7080a243
-
-CFLAGS="-D_GNU_SOURCE" # needed for cpu_set_t
+checksum=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
 
 arb-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"

From b1d5a6e10c48f98ca8d37e5c2c693c8d5c739cd1 Mon Sep 17 00:00:00 2001
From: dkwo <nicolopiazzalunga@gmail.com>
Date: Mon, 10 Oct 2022 10:14:06 -0400
Subject: [PATCH 03/13] singular: update to 4.3.1p2 (fix gcc 12 build)

---
 common/shlibs             | 10 +++++-----
 srcpkgs/singular/template | 26 ++++++++++++++------------
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index f220c136eced..af06967e6133 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4056,11 +4056,11 @@ libumfpack.so.5 SuiteSparse-5.10.1_1
 libecl.so.21.2 ecl-21.2.1_1
 libecm.so.1 ecm-7.0.4_3
 libcliquer.so.1 cliquer-1.22_1
-libSingular-4.3.0.so singular-4.3.0_1
-libfactory-4.3.0.so singular-4.3.0_1
-libpolys-4.3.0.so singular-4.3.0_1
-libomalloc-0.9.6.so singular-4.3.0_1
-libsingular_resources-4.3.0.so singular-4.3.0_1
+libSingular-4.3.1.so singular-4.3.1p2_1
+libfactory-4.3.1.so singular-4.3.1p2_1
+libpolys-4.3.1.so singular-4.3.1p2_1
+libomalloc-0.9.6.so singular-4.3.1p2_1
+libsingular_resources-4.3.1.so singular-4.3.1p2_1
 libbrial.so.3 brial-1.2.10_1
 libbrial_groebner.so.3 brial-1.2.10_1
 libm4ri-0.0.20200125.so m4ri-20200125_1
diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index f23659ef5d83..a30beef915d2 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,25 +1,27 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.0
+version=4.3.1p2
 revision=1
+_majver=${version%p*}
+wrksrc=singular-${_majver}
 build_style=gnu-configure
 configure_args="--with-readline=ncurses
-	--enable-gfanlib
-	--enable-Singular
-	--enable-factory
-	--disable-doc
-	--disable-polymake
-	--without-python
-	--with-libparse
-	ac_cv_lib_cddgmp_dd_free_global_constants=yes"
+ --enable-gfanlib
+ --enable-Singular
+ --enable-factory
+ --disable-doc
+ --disable-polymake
+ --without-python
+ --with-libparse
+ ac_cv_lib_cddgmp_dd_free_global_constants=yes"
 hostmakedepends="perl tar doxygen"
 makedepends="flintlib-devel cddlib-devel readline-devel graphviz"
 short_desc="Computer algebra system for polynomial computations"
-maintainer="dkwo <nicolopiazzalunga@gmail.com>"
+maintainer="dkwo <npiazza@disroot.org>"
 license="GPL-2.0-or-later"
 homepage="https://www.singular.uni-kl.de"
-distfiles="https://www.singular.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${version//./-}/singular-${version}.tar.gz"
-checksum=74f38288203720e3f280256f2f8deb94030dd032b4237d844652aff0faab36e7
+distfiles="https://www.singular.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${_majver//./-}/singular-${version}.tar.gz"
+checksum=95814bba0f0bd0290cd9799ec1d2ecc6f4c8a4e6429d9a02eb7f9c4e5649682a
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From 26577736c7a517b0855d5af807e170d371ae2334 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 19:59:20 -0300
Subject: [PATCH 04/13] pari: update to 2.15.0.

---
 common/shlibs         | 3 +--
 srcpkgs/pari/template | 7 ++++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index af06967e6133..106f76574252 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4005,8 +4005,7 @@ libsimavrparts.so.1 simavr-1.6_2
 libsword-1.8.1.so libsword-1.8.1_6
 libgivaro.so.9 givaro-4.1.1_1
 liblinbox.so.0 linbox-1.6.3_1
-libpari-gmp.so.7 pari-2.13.0_1
-libpari-gmp-tls.so.7 pari-2.13.2_1
+libpari-gmp-tls.so.8 pari-2.15.0_1
 libtree-sitter.so.0 tree-sitter-0.19.0_1
 libplanarity.so.0 planarity-3.0.1.1_1
 libgap.so.0 gap-4.11.1_1
diff --git a/srcpkgs/pari/template b/srcpkgs/pari/template
index 8bac1e0343f8..873cddb4946f 100644
--- a/srcpkgs/pari/template
+++ b/srcpkgs/pari/template
@@ -1,6 +1,6 @@
 # Template file for 'pari'
 pkgname=pari
-version=2.13.4
+version=2.15.0
 revision=1
 build_style=configure
 build_helper=qemu
@@ -11,14 +11,15 @@ make_check_target=statest-all
 make_install_target="install install-lib-sta install-lib-dyn"
 hostmakedepends="perl texlive"
 makedepends="gmp-devel readline-devel $(vopt_if x11 libX11-devel)"
-checkdepends="pari-elldata-small pari-galdata pari-galpol-small pari-seadata-small"
+checkdepends="pari-elldata-small pari-galdata pari-galpol-small
+ pari-seadata-small pari-nflistdata"
 short_desc="Fast computations library in number theory"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="https://pari.math.u-bordeaux.fr"
 changelog="https://pari.math.u-bordeaux.fr/cgi-bin/gitweb.cgi?p=pari.git;a=blob_plain;f=CHANGES;hb=refs/heads/pari-${version%.*}"
 distfiles="https://pari.math.u-bordeaux.fr/pub/pari/unix/${pkgname}-${version}.tar.gz"
-checksum=bcde9eceae1592814381c1697cdb7063567b6504201b1be47bb58920f3bce185
+checksum=e474851e0d16d4e4f9a0d9612c746a2ae7c9a1ec185d04c440b1c74a85755685
 
 build_options="x11 pthreads"
 build_options_default="x11 pthreads"

From 6fba693fb719ad8cf9cb03373626bd6ac99bfe8a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 20:33:23 -0300
Subject: [PATCH 05/13] gp2c: update to 0.0.13.

---
 srcpkgs/gp2c/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gp2c/template b/srcpkgs/gp2c/template
index f82cf95c2d90..9cf0f6fdce6e 100644
--- a/srcpkgs/gp2c/template
+++ b/srcpkgs/gp2c/template
@@ -1,6 +1,6 @@
 # Template file for 'gp2c'
 pkgname=gp2c
-version=0.0.12pl1
+version=0.0.13
 revision=1
 build_style=gnu-configure
 hostmakedepends="perl"
@@ -12,4 +12,4 @@ license="GPL-2.0-or-later"
 homepage="http://pari.math.u-bordeaux.fr/"
 changelog="http://pari.math.u-bordeaux.fr/cgi-bin/gitweb.cgi?p=gp2c.git;a=blob_plain;f=ChangeLog;hb=HEAD"
 distfiles="${homepage}pub/pari/GP2C/${pkgname}-${version}.tar.gz"
-checksum=79a8c46f7ad3331e4d8ae6af6b496c4742fd73a73b996b3ca7ead61452ca6e8d
+checksum=261374eca73ebd76c112a9593dca28b64812aa762561fda5a4b2c2cd79a69d36

From e39fce94fb9942439d91fb777c10bc073cedd8c9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Fri, 23 Sep 2022 16:42:40 -0300
Subject: [PATCH 06/13] eclib: update to 20220621.

---
 common/shlibs          | 2 +-
 srcpkgs/eclib/template | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 106f76574252..f21ccacd6477 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4015,7 +4015,7 @@ libgf2x.so.3 gf2x-1.3.0_1
 libntl.so.44 ntl-11.5.1_1
 libflint.so.17 flintlib-2.9.0_1
 libarb.so.2 arb-2.20.0_1
-libec.so.8 eclib-20210625_1
+libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
 liblrcalc.so.2 lrcalc-2.1_1
diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 694a39ed4068..31a3a01921fa 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
-version=20210625
-revision=2
+version=20221012
+revision=1
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 hostmakedepends="automake autoconf-archive libtool"
@@ -11,7 +11,7 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="https://github.com/JohnCremona/eclib"
 distfiles="https://github.com/JohnCremona/eclib/archive/refs/tags/${version}.tar.gz"
-checksum=00333fd36afd237c9e6e410c7ab98536ddcd7fdc430e6837fe293247b835c572
+checksum=bd6f0191876c1426ca57db851ce06ef79ea1755f01e81dd747358d1b76b5e932
 
 pre_configure() {
 	autoreconf -fi

From d21e7dcb5cc8afb72cc75f4003274438d37239a0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:20 -0300
Subject: [PATCH 07/13] giac: update to 1.9.0.21.

---
 srcpkgs/giac/patches/giac-pari-2.15.patch | 20 ++++++++++++++++++++
 srcpkgs/giac/template                     |  4 ++--
 2 files changed, 22 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/giac/patches/giac-pari-2.15.patch

diff --git a/srcpkgs/giac/patches/giac-pari-2.15.patch b/srcpkgs/giac/patches/giac-pari-2.15.patch
new file mode 100644
index 000000000000..be409be38f53
--- /dev/null
+++ b/srcpkgs/giac/patches/giac-pari-2.15.patch
@@ -0,0 +1,20 @@
+ANYARG patch
+
+diff --git a/src/pari.cc b/src/pari.cc
+index 76ce8e1..50d08ab 100644
+--- a/src/pari.cc
++++ b/src/pari.cc
+@@ -40,6 +40,13 @@ using namespace std;
+ 
+ #ifdef HAVE_LIBPARI
+ 
++// Anyarg disappeared from PARI 2.15.0
++#ifdef __cplusplus
++#  define ANYARG ...
++#else
++#  define ANYARG
++#endif
++
+ #ifdef HAVE_PTHREAD_H
+ #include <pthread.h>
+ #endif
diff --git a/srcpkgs/giac/template b/srcpkgs/giac/template
index e892c8bf7506..31045e9128ee 100644
--- a/srcpkgs/giac/template
+++ b/srcpkgs/giac/template
@@ -1,6 +1,6 @@
 # Template file for 'giac'
 pkgname=giac
-version=1.9.0.7
+version=1.9.0.21
 revision=1
 wrksrc="giac-${version%.*}"
 build_style=gnu-configure
@@ -14,7 +14,7 @@ license="GPL-3.0-or-later"
 homepage="https://www-fourier.ujf-grenoble.fr/~parisse/giac.html"
 changelog="https://www-fourier.ujf-grenoble.fr/~parisse/install_en#new"
 distfiles="https://www-fourier.ujf-grenoble.fr/~parisse/debian/dists/stable/main/source/giac_${version%.*}-${version##*.}.tar.gz"
-checksum=72016988b7180e9b630ecabecc60969213e7b61418c2598c91acbaec139fd740
+checksum=120cd16f2e033817302d2a03a22bd413dc1d85df8b225ba4f76b93a7805b07fe
 
 # need more than 4*65536 stack, see try_parse() in gen.cc line 11812
 LDFLAGS="-Wl,-z,stack-size=2097152"

From 76d7a1f8f5c3df30ea88472b94a6ca49455f18b2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 12 Oct 2022 23:59:37 -0300
Subject: [PATCH 08/13] gap: update to 4.12.0.

---
 common/shlibs                          |  2 +-
 srcpkgs/gap/patches/c57a07a3.patch     | 23 +++++++++++++++++++++++
 srcpkgs/gap/patches/dce6fa96.patch     | 24 ++++++++++++++++++++++++
 srcpkgs/gap/patches/fix-atlasrep.patch | 11 +++++++++++
 srcpkgs/gap/template                   | 12 +++++-------
 5 files changed, 64 insertions(+), 8 deletions(-)
 create mode 100644 srcpkgs/gap/patches/c57a07a3.patch
 create mode 100644 srcpkgs/gap/patches/dce6fa96.patch
 create mode 100644 srcpkgs/gap/patches/fix-atlasrep.patch

diff --git a/common/shlibs b/common/shlibs
index f21ccacd6477..48b61abc836d 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4008,7 +4008,7 @@ liblinbox.so.0 linbox-1.6.3_1
 libpari-gmp-tls.so.8 pari-2.15.0_1
 libtree-sitter.so.0 tree-sitter-0.19.0_1
 libplanarity.so.0 planarity-3.0.1.1_1
-libgap.so.0 gap-4.11.1_1
+libgap.so.8 gap-4.12.0_1
 libgtkdatabox.so.1 gtkdatabox3-1.0.0_1
 libxcvt.so.0 libxcvt-0.1.1_1
 libgf2x.so.3 gf2x-1.3.0_1
diff --git a/srcpkgs/gap/patches/c57a07a3.patch b/srcpkgs/gap/patches/c57a07a3.patch
new file mode 100644
index 000000000000..27fd657666a6
--- /dev/null
+++ b/srcpkgs/gap/patches/c57a07a3.patch
@@ -0,0 +1,23 @@
+From c57a07a341e7bb713e74d60c259777b1a8645451 Mon Sep 17 00:00:00 2001
+From: Max Horn <max@quendi.de>
+Date: Fri, 7 Oct 2022 01:31:45 +0200
+Subject: [PATCH] Don't attempt to install the 'dev' manual...
+
+... as it is not contained in release tarballs!
+---
+ Makefile.rules | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile.rules b/Makefile.rules
+index d9dc2899df..de1dbc4823 100644
+--- a/Makefile.rules
++++ b/Makefile.rules
+@@ -597,7 +597,7 @@ install-doc:
+ 	# TODO: should this depend on the 'doc' target? but that target is phony
+ 	# and will re-run each time it is invoked, which is not really what we want.
+ 	$(INSTALL) -d -m 0755 $(DESTDIR)$(datarootdir)/gap/doc
+-	for book in ref tut hpc dev ; do \
++	for book in ref tut hpc ; do \
+ 		$(INSTALL) -d -m 0755 $(DESTDIR)$(datarootdir)/gap/doc/$$book ; \
+ 		for ext in css html js txt pdf six lab; do \
+ 			$(INSTALL) -m 0644  $(srcdir)/doc/$$book/*.$$ext $(DESTDIR)$(datarootdir)/gap/doc/$$book/ ; \
diff --git a/srcpkgs/gap/patches/dce6fa96.patch b/srcpkgs/gap/patches/dce6fa96.patch
new file mode 100644
index 000000000000..bc29c0eaaeb1
--- /dev/null
+++ b/srcpkgs/gap/patches/dce6fa96.patch
@@ -0,0 +1,24 @@
+From dce6fa9637a3c61c3a891cc809371eaa67a589c6 Mon Sep 17 00:00:00 2001
+From: Max Horn <max@quendi.de>
+Date: Sun, 2 Oct 2022 23:31:03 +0200
+Subject: [PATCH] kernel: if no GC is selected, default to GASMAN
+
+---
+ src/common.h | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/common.h b/src/common.h
+index e7c10b8d0b..95e6f3d609 100644
+--- a/src/common.h
++++ b/src/common.h
+@@ -35,6 +35,10 @@
+ // compiled with the wrong ABI
+ GAP_STATIC_ASSERT(sizeof(void *) == SIZEOF_VOID_P, "sizeof(void *) is wrong");
+ 
++// if no GC is selected explicitly, default to GASMAN
++#if !defined(USE_BOEHM_GC) && !defined(USE_JULIA_GC) && !defined(USE_GASMAN)
++#define USE_GASMAN 1
++#endif
+ 
+ // check for cygwin
+ #if defined(__CYGWIN__) || defined(__CYGWIN32__)
diff --git a/srcpkgs/gap/patches/fix-atlasrep.patch b/srcpkgs/gap/patches/fix-atlasrep.patch
new file mode 100644
index 000000000000..ccb9ae587d4b
--- /dev/null
+++ b/srcpkgs/gap/patches/fix-atlasrep.patch
@@ -0,0 +1,11 @@
+--- a/pkg/atlasrep/gap/access.gi.orig	2022-08-05 19:11:16.000000000 -0300
++++ b/pkg/atlasrep/gap/access.gi	2022-10-12 23:40:48.816642751 -0300
+@@ -3156,7 +3156,7 @@
+         uri:= url{ [ p .. Length( url ) ] };
+         body:= AtlasOfGroupRepresentationsTransferFile( domain, uri, fail,
+                                                         fail );
+-        if body = fail then
++        if body = false then
+           Info( InfoAtlasRep, 1,
+                 "AtlasOfGroupRepresentationsNotifyData:\n",
+                 "#I  cannot read '", url, "'" );
diff --git a/srcpkgs/gap/template b/srcpkgs/gap/template
index 7bc7d13ace20..88831e636c08 100644
--- a/srcpkgs/gap/template
+++ b/srcpkgs/gap/template
@@ -1,17 +1,17 @@
 # Template file for 'gap'
 pkgname=gap
-version=4.11.1
+version=4.12.0
 revision=1
 build_style=gnu-configure
-make_install_target="install-bin install-gaproot install-headers install-libgap"
 makedepends="gmp-devel zlib-devel readline-devel"
 checkdepends="perl"
 short_desc="Groups, Algorithms, Programming - computational discrete algebra"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="http://www.gap-system.org/"
+changelog="https://raw.githubusercontent.com/gap-system/gap/master/CHANGES.md"
 distfiles="https://github.com/gap-system/gap/releases/download/v${version}/gap-${version}.tar.gz"
-checksum=6635c5da7d82755f8339486b9cac33766f58712f297e8234fba40818902ea304
+checksum=6005d0c0316fe8803d84681f30be64eace83a9542f975f5cb3dedfadd4391849
 
 if [ "$XBPS_CHECK_PKGS" = full ]; then
 	# not sure about this -- takes about 25 minutes
@@ -21,10 +21,10 @@ fi
 _GAPROOT=/usr/share/gap/
 
 # minimal required packages
-_GAPPKGS="GAPDoc primgrp SmallGrp transgrp"
+_GAPPKGS="gapdoc primgrp smallgrp transgrp"
 
 # other expected packages
-_GAPPKGS+=" atlasrep autpgrp alnuth crisp ctbllib FactInt fga irredsol laguna
+_GAPPKGS+=" atlasrep autpgrp alnuth crisp ctbllib factint fga irredsol laguna
  polenta polycyclic resclasses sophus tomlib"
 
 post_install() {
@@ -33,8 +33,6 @@ post_install() {
 		[ -d pkg/$p ] || p="$p-*"
 		vcopy "pkg/$p" ${_GAPROOT}/pkg
 	done
-	# not handled by make install-headers
-	vcopy gen/config.h /usr/include/gap
 }
 
 gap-devel_package() {

From b10877d97f6636d14068778580936278fff5f036 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:19 -0300
Subject: [PATCH 09/13] lcalc: revbump for pari 2.15.0

---
 srcpkgs/lcalc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lcalc/template b/srcpkgs/lcalc/template
index 270078df9a54..3c6be5fcbc28 100644
--- a/srcpkgs/lcalc/template
+++ b/srcpkgs/lcalc/template
@@ -1,7 +1,7 @@
 # Template file for 'lcalc'
 pkgname=lcalc
 version=2.0.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--with-pari"
 hostmakedepends="automake libtool pkg-config gengetopt"

From 3d9190e26f2e9ac02579599a2f53d2a2d7b1ceb7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:21 -0300
Subject: [PATCH 10/13] python3-cysignals: revbump for pari 2.15.0

---
 srcpkgs/python3-cysignals/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/python3-cysignals/template b/srcpkgs/python3-cysignals/template
index 4655eead2a9c..08d1010976ff 100644
--- a/srcpkgs/python3-cysignals/template
+++ b/srcpkgs/python3-cysignals/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-cysignals'
 pkgname=python3-cysignals
 version=1.11.2
-revision=1
+revision=2
 wrksrc="cysignals-${version}"
 build_style=python3-module
 hostmakedepends="python3-setuptools python3-Cython autoconf"

From 1eed7bf9c35499dbf59fb863b86cea2643a9b90d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:58:16 -0300
Subject: [PATCH 11/13] python3-cypari2: revbump for pari 2.15.0

---
 srcpkgs/python3-cypari2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/python3-cypari2/template b/srcpkgs/python3-cypari2/template
index 9ded61101e8e..9db3070a087c 100644
--- a/srcpkgs/python3-cypari2/template
+++ b/srcpkgs/python3-cypari2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-cypari2'
 pkgname=python3-cypari2
 version=2.1.2
-revision=1
+revision=2
 wrksrc=cypari2-${version}
 build_style=python3-module
 hostmakedepends="python3-setuptools python3-Cython pari perl"

From 3f31991a80336c6a5b25e48e39e0ecd0f7748357 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 00:49:01 -0300
Subject: [PATCH 12/13] sagemath: update to 9.7.

---
 .../patches/01-dont_link_ratpoints.patch      |   10 -
 ...2-fix_get_shared_lib_path--see_29644.patch |   13 -
 .../patches/03-doctest_have_program.patch     |   20 -
 .../patches/04-doctest_sage_getfile.patch     |   22 -
 .../patches/05-fix_sage_getfile.patch         |   16 -
 .../sagemath/patches/07-ignore_warning.patch  |   15 -
 .../08-dont_run_pytest--see_31924.patch       |   27 -
 ...y_slow_doctest-polynomial_zmod_flint.patch |   14 -
 ...ry_slow_doctest-isogeny_small_degree.patch |  106 -
 ...fix_very_slow_doctest-function_field.patch |   97 -
 srcpkgs/sagemath/patches/matplotlib-3.6.patch |   72 +
 srcpkgs/sagemath/patches/python-3.11.patch    |   45 +
 .../sagemath/patches/sagemath-pari-2.15.patch | 1750 +++++++++++++++++
 .../patches/sagemath-pari-2.15b.patch         |   29 +
 .../trac-31355-upgrade_lrcalc_to_2.1.patch    |  670 -------
 .../trac-33170-fix_doctest_ipython_8.patch    |   40 -
 .../trac-33170b-fix_doctest_ipython_8.1.patch |   13 -
 ...2ddd4e2dc92469c1590ebf0c40f8f69bf579.patch |  126 --
 ...2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch |   40 -
 .../trac-33336-fix_doctest_scipy_1.8.patch    |   19 -
 ...cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch |   53 +
 ...d9deaeaa6380ab2f0d50276d911233c00a04.patch |   99 -
 ...ff347454ac7f07e5918470b20e97b8f2357e.patch |   29 -
 ...0a0b14f67f4804e7113c3db41bbcf8a58296.patch |   26 -
 ...d4e56243c609f44afc1f21c112b026f9e1fe.patch |   42 +
 ...75f90d3bfd36758cb0e9d1ccbcd72f32d496.patch |  526 +++++
 ...1318f032caf8dc1c0de9489346d894409091.patch |   19 +
 .../zzz-loadable_module_extension.patch       |   14 -
 srcpkgs/sagemath/template                     |   12 +-
 29 files changed, 2542 insertions(+), 1422 deletions(-)
 delete mode 100644 srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
 delete mode 100644 srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
 delete mode 100644 srcpkgs/sagemath/patches/03-doctest_have_program.patch
 delete mode 100644 srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
 delete mode 100644 srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
 delete mode 100644 srcpkgs/sagemath/patches/07-ignore_warning.patch
 delete mode 100644 srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
 delete mode 100644 srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
 delete mode 100644 srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
 delete mode 100644 srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
 create mode 100644 srcpkgs/sagemath/patches/matplotlib-3.6.patch
 create mode 100644 srcpkgs/sagemath/patches/python-3.11.patch
 create mode 100644 srcpkgs/sagemath/patches/sagemath-pari-2.15.patch
 create mode 100644 srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
 delete mode 100644 srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch

diff --git a/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch b/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
deleted file mode 100644
index e5c3f5776aa2..000000000000
--- a/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
+++ /dev/null
@@ -1,10 +0,0 @@
- - do not link ratpoints where it's not used
-
---- a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
-+++ b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
-@@ -1,5 +1,3 @@
--# distutils: libraries = ratpoints
--
- r"""
- Descent on elliptic curves over `\QQ` with a 2-isogeny
- """
diff --git a/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch b/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
deleted file mode 100644
index d3672b094c1c..000000000000
--- a/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
+++ /dev/null
@@ -1,13 +0,0 @@
- - fix _get_shared_lib_path() so we don't need to configure GAP_SO
-
---- a/src/sage/env.py
-+++ b/src/sage/env.py
-@@ -293,7 +293,7 @@ def _get_shared_lib_path(*libnames: str) -> Optional[str]:
-             if sys.platform == 'darwin':
-                 ext = 'dylib'
-             else:
--                ext = 'so'
-+                ext = 'so*'
- 
-             if SAGE_LOCAL:
-                 search_directories.append(Path(SAGE_LOCAL) / 'lib')
diff --git a/srcpkgs/sagemath/patches/03-doctest_have_program.patch b/srcpkgs/sagemath/patches/03-doctest_have_program.patch
deleted file mode 100644
index 27ba3776470c..000000000000
--- a/srcpkgs/sagemath/patches/03-doctest_have_program.patch
+++ /dev/null
@@ -1,20 +0,0 @@
- - we don't know `SAGE_VENV/bin` contains `sage`, but `sys.argv[0]` should
-   be the full path to `sage-ipython` and the same directory should have `sage`
-
---- a/src/sage/misc/sage_ostools.pyx
-+++ b/src/sage/misc/sage_ostools.pyx
-@@ -32,12 +32,11 @@ def have_program(program, path=None):
-         True
-         sage: have_program('there_is_not_a_program_with_this_name')
-         False
--        sage: from sage.env import SAGE_VENV
--        sage: have_program('sage', os.path.join(SAGE_VENV, 'bin'))
-+        sage: have_program('sage', os.path.dirname(sys.argv[0]))
-         True
-         sage: have_program('sage', '/there_is_not_a_path_with_this_name')
-         False
--        sage: have_program('there_is_not_a_program_with_this_name', os.path.join(SAGE_VENV, 'bin'))
-+        sage: have_program('there_is_not_a_program_with_this_name', "/bin")
-         False
-     """
-     if path is None:
diff --git a/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch b/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
deleted file mode 100644
index 95bce107f854..000000000000
--- a/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
+++ /dev/null
@@ -1,22 +0,0 @@
- - add one doctest for coverage
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -1341,10 +1342,12 @@ def sage_getfile(obj):
-     EXAMPLES::
- 
-         sage: from sage.misc.sageinspect import sage_getfile
--        sage: sage_getfile(sage.rings.rational)[-23:]
--        'sage/rings/rational.pyx'
--        sage: sage_getfile(Sq)[-42:]
--        'sage/algebras/steenrod/steenrod_algebra.py'
-+        sage: sage_getfile(sage.rings.rational)
-+        '...sage/rings/rational.pyx'
-+        sage: sage_getfile(Sq)
-+        '...sage/algebras/steenrod/steenrod_algebra.py'
-+        sage: sage_getfile(x)
-+        '...sage/symbolic/expression.pyx'
- 
-     The following tests against some bugs fixed in :trac:`9976`::
- 
-
diff --git a/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch b/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
deleted file mode 100644
index 56c58078f319..000000000000
--- a/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
+++ /dev/null
@@ -1,16 +0,0 @@
- - fix sage_getfile() by checking all possible EXTENSION_SUFFIXES
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -1400,8 +1403,9 @@ def sage_getfile(obj):
-         sourcefile = inspect.getabsfile(obj)
-     except TypeError: # this happens for Python builtins
-         return ''
--    if sourcefile.endswith(loadable_module_extension()):
--        return sourcefile[:-len(loadable_module_extension())]+os.path.extsep+'pyx'
-+    for suffix in import_machinery.EXTENSION_SUFFIXES:
-+        if sourcefile.endswith(suffix):
-+            return sourcefile[:-len(suffix)]+os.path.extsep+'pyx'
-     return sourcefile
- 
- 
diff --git a/srcpkgs/sagemath/patches/07-ignore_warning.patch b/srcpkgs/sagemath/patches/07-ignore_warning.patch
deleted file mode 100644
index 69668678a40b..000000000000
--- a/srcpkgs/sagemath/patches/07-ignore_warning.patch
+++ /dev/null
@@ -1,15 +0,0 @@
- - this ignores a warning caused by old notebook
-
---- a/src/sage/all.py
-+++ b/src/sage/all.py
-@@ -100,6 +100,9 @@ warnings.filterwarnings('ignore', category=DeprecationWarning,
-                         message='The distutils(.sysconfig module| package) is deprecated',
-                         module='Cython|distutils|numpy|sage.env|sage.features')
- 
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"invalid escape sequence '\\s'")
-+
- ################ end setup warnings ###############################
- 
- 
-
diff --git a/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch b/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
deleted file mode 100644
index 06bd2ccae6fb..000000000000
--- a/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
+++ /dev/null
@@ -1,27 +0,0 @@
- - using pytest is broken, see #31924
-
---- a/src/bin/sage-runtests
-+++ b/src/bin/sage-runtests
-@@ -154,21 +154,4 @@ if __name__ == "__main__":
-     DC = DocTestController(args, args.filenames)
-     err = DC.run()
- 
--    try:
--        exit_code_pytest = 0
--        import pytest
--        pytest_options = ["--import-mode", "importlib"]
--        if args.verbose:
--            pytest_options.append("-v")
--        exit_code_pytest = pytest.main(pytest_options + args.filenames)
--        if exit_code_pytest == 5:
--            # Exit code 5 means there were no test files, pass in this case
--            exit_code_pytest = 0
--
--    except ModuleNotFoundError:
--        print("Pytest is not installed, skip checking tests that rely on it.")
--
--    if err == 0:
--        sys.exit(exit_code_pytest)
--    else:
--        sys.exit(err)
-+    sys.exit(err)
diff --git a/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch b/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
deleted file mode 100644
index bae8387cf94a..000000000000
--- a/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
-+++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
-@@ -237,8 +237,9 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
- 
-             sage: a = ZZ['x'](range(100000))
-             sage: R = Integers(3)['x']
--            sage: R(a)  # long time (7s on sage.math, 2013)
--            2*x^99998 + ... + x
-+            sage: p = R(a)
-+            sage: p.truncate(10)  # testing the whole poly is VERY SLOW
-+            2*x^8 + x^7 + 2*x^5 + x^4 + 2*x^2 + x
-         """
-         sig_on()
-         fmpz_poly_get_nmod_poly(&self.x, x)
diff --git a/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch b/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
deleted file mode 100644
index f3da5bbb555e..000000000000
--- a/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
+++ /dev/null
@@ -1,106 +0,0 @@
-diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-index 43727346269..9d3ccd475cd 100644
---- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-+++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-@@ -186,7 +186,7 @@ def Psi(l, use_stored=True):
-         sage: assert Psi(3, use_stored=True) == Psi(3, use_stored=False)
-         sage: assert Psi(5, use_stored=True) == Psi(5, use_stored=False)
-         sage: assert Psi(7, use_stored=True) == Psi(7, use_stored=False)
--        sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False) # not tested (very long time)
-+        sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False)  # long time (2s)
-     """
-     if l not in [2, 3, 5, 7, 13]:
-         raise ValueError("Genus zero primes are 2, 3, 5, 7 or 13.")
-@@ -1207,7 +1207,7 @@ def isogenies_13_0(E, minimal_models=True):
-         sage: K.<a> = NumberField(f)
-         sage: E = EllipticCurve(j=K(0)); E.ainvs()
-         (0, 0, 0, 0, 1)
--        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]
-+        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]  # long time (4s)
-         [(0,
-           0,
-           20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
-@@ -1325,7 +1325,7 @@ def isogenies_13_1728(E, minimal_models=True):
-         sage: f = x^12 + 1092*x^10 - 432432*x^8 + 6641024*x^6 - 282896640*x^4 - 149879808*x^2 - 349360128
-         sage: K.<a> = NumberField(f)
-         sage: E = EllipticCurve(K, [1,0])
--        sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]
-+        sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]  # long time (3s)
-         [(0,
-         0,
-         0,
-@@ -1550,8 +1550,11 @@ def Psi2(l):
-         sage: from sage.schemes.elliptic_curves.isogeny_small_degree import Psi2
-         sage: Psi2(11)
-         x^5 - 55*x^4*u + 994*x^3*u^2 - 8774*x^2*u^3 + 41453*x*u^4 - 928945/11*u^5 + 33*x^4 + 276*x^3*u - 7794*x^2*u^2 + 4452*x*u^3 + 1319331/11*u^4 + 216*x^3*v - 4536*x^2*u*v + 31752*x*u^2*v - 842616/11*u^3*v + 162*x^3 + 38718*x^2*u - 610578*x*u^2 + 33434694/11*u^3 - 4536*x^2*v + 73872*x*u*v - 2745576/11*u^2*v - 16470*x^2 + 580068*x*u - 67821354/11*u^2 - 185976*x*v + 14143896/11*u*v + 7533*x - 20437029/11*u - 12389112/11*v + 19964151/11
--        sage: Psi2(71)  # long time (1 second)
--        -2209380711722505179506258739515288584116147237393815266468076436521/71*u^210 + ... - 14790739586438315394567393301990769678157425619440464678252277649/71
-+        sage: f = Psi2(71)
-+        sage: f.coefficient([0, 210, 0])
-+        -2209380711722505179506258739515288584116147237393815266468076436521/71
-+        sage: f.coefficient([0, 0, 0])
-+        -14790739586438315394567393301990769678157425619440464678252277649/71
- 
-     TESTS::
- 
-@@ -1665,17 +1668,17 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True):
-         sage: K = QuadraticField(5,'a')
-         sage: a = K.gen()
-         sage: E = EllipticCurve_from_j(184068066743177379840*a - 411588709724712960000)
--        sage: isogenies_prime_degree_genus_plus_0(E, 47) # long time (4.3s)
-+        sage: isogenies_prime_degree_genus_plus_0(E, 47)  # long time (2s)
-         [Isogeny of degree 47 from Elliptic Curve defined by y^2 = x^3 + (454562028554080355857852049849975895490560*a-1016431595837124114668689286176511361024000)*x + (-249456798429896080881440540950393713303830363999480904280965120*a+557802358738710443451273320227578156598454035482869042774016000) over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790? to Elliptic Curve defined by y^2 = x^3 + (39533118442361013730577638493616965245992960*a-88398740199669828340617478832005245173760000)*x + (214030321479466610282320528611562368963830105830555363061803253760*a-478586348074220699687616322532666163722004497458452316582576128000) over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790?]
- 
-         sage: K = QuadraticField(-66827,'a')
-         sage: a = K.gen()
-         sage: E = EllipticCurve_from_j(-98669236224000*a + 4401720074240000)
--        sage: isogenies_prime_degree_genus_plus_0(E, 59)   # long time (25s, 2012)
-+        sage: isogenies_prime_degree_genus_plus_0(E, 59)   # long time (5s)
-         [Isogeny of degree 59 from Elliptic Curve defined by y^2 = x^3 + (2605886146782144762297974784000*a+1893681048912773634944634716160000)*x + (-116918454256410782232296183198067568744071168000*a+17012043538294664027185882358514011304812871680000) over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I to Elliptic Curve defined by y^2 = x^3 + (-19387084027159786821400775098368000*a-4882059104868154225052787156713472000)*x + (-25659862010101415428713331477227179429538847260672000*a-2596038148441293485938798119003462972840818381946880000) over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I]
- 
-         sage: E = EllipticCurve_from_j(GF(13)(5))
--        sage: isogenies_prime_degree_genus_plus_0(E, 71) # long time
-+        sage: isogenies_prime_degree_genus_plus_0(E, 71)
-         [Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13, Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13]
- 
-         sage: E = EllipticCurve(GF(13),[0,1,1,1,0])
-@@ -2117,11 +2120,11 @@ def isogenies_prime_degree_general(E, l, minimal_models=True):
-         sage: isogenies_prime_degree_general(E, 19)
-         [Isogeny of degree 19 from Elliptic Curve defined by y^2 + y = x^3 - 1862*x - 30956 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - 672182*x + 212325489 over Rational Field]
-         sage: E = EllipticCurve([0, -1, 0, -6288, 211072])
--        sage: isogenies_prime_degree_general(E, 37)  # long time (10s)
-+        sage: isogenies_prime_degree_general(E, 37)  # long time (2s)
-         [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 - x^2 - 6288*x + 211072 over Rational Field to Elliptic Curve defined by y^2 = x^3 - x^2 - 163137088*x - 801950801728 over Rational Field]
- 
-         sage: E = EllipticCurve([-3440, 77658])
--        sage: isogenies_prime_degree_general(E, 43)  # long time (16s)
-+        sage: isogenies_prime_degree_general(E, 43)  # long time (2s)
-         [Isogeny of degree 43 from Elliptic Curve defined by y^2 = x^3 - 3440*x + 77658 over Rational Field to Elliptic Curve defined by y^2 = x^3 - 6360560*x - 6174354606 over Rational Field]
- 
-     Isogenies of degree equal to the characteristic are computed (but
-@@ -2175,7 +2178,7 @@ def isogenies_prime_degree_general(E, l, minimal_models=True):
- 
-         sage: K.<i> = QuadraticField(-1)
-         sage: E = EllipticCurve(K,[0,0,0,1,0])
--        sage: [phi.codomain().ainvs() for phi in E.isogenies_prime_degree(37)] # long time
-+        sage: [phi.codomain().ainvs() for phi in E.isogenies_prime_degree(37)]  # long time (6s)
-         [(0, 0, 0, -840*i + 1081, 0), (0, 0, 0, 840*i + 1081, 0)]
-     """
-     if not l.is_prime():
-@@ -2329,14 +2332,14 @@ def isogenies_prime_degree(E, l, minimal_models=True):
-         sage: E = EllipticCurve(GF(101), [-3440, 77658])
-         sage: E.isogenies_prime_degree(71) # fast
-         []
--        sage: E.isogenies_prime_degree(73) # slower (2s)
-+        sage: E.isogenies_prime_degree(73)  # long time (2s)
-         []
- 
-     Test that :trac:`32269` is fixed::
- 
-         sage: K = QuadraticField(-11)
-         sage: E = EllipticCurve(K, [0,1,0,-117,-541])
--        sage: E.isogenies_prime_degree(37)
-+        sage: E.isogenies_prime_degree(37)  # long time (9s)
-         [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I to Elliptic Curve defined by y^2 = x^3 + x^2 + (30800*a+123963)*x + (3931312*a-21805005) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I,
-          Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I to Elliptic Curve defined by y^2 = x^3 + x^2 + (-30800*a+123963)*x + (-3931312*a-21805005) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I]
- 
diff --git a/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch b/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
deleted file mode 100644
index 3b7b1ea843df..000000000000
--- a/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
+++ /dev/null
@@ -1,97 +0,0 @@
---- a/src/sage/rings/function_field/function_field.py
-+++ b/src/sage/rings/function_field/function_field.py
-@@ -111,22 +111,21 @@ Function fields over the algebraic field are supported::
-     sage: m = L.completion(pl, prec=5)
-     sage: m(x)
-     I + s + O(s^5)
--    sage: m(y)
-+    sage: m(y)                             # long time (4s)
-     -2*s + (-4 - I)*s^2 + (-15 - 4*I)*s^3 + (-75 - 23*I)*s^4 + (-413 - 154*I)*s^5 + O(s^6)
--    sage: m(y)^2 + m(y) + m(x) + 1/m(x)
-+    sage: m(y)^2 + m(y) + m(x) + 1/m(x)    # long time (8s)
-     O(s^5)
- 
- TESTS::
- 
-     sage: TestSuite(J).run()
--    sage: TestSuite(K).run(max_runs=1024) # long time (5s)
--    sage: TestSuite(L).run(max_runs=64)   # long time (10s)
--    sage: TestSuite(M).run(max_runs=32)   # long time (30s)
--    sage: TestSuite(N).run(max_runs=64, skip = '_test_derivation')  # long time (8s)
--    sage: TestSuite(O).run(max_runs=128, skip = '_test_derivation') # long time (8s)
--
-+    sage: TestSuite(K).run(max_runs=256)   # long time (10s)
-+    sage: TestSuite(L).run(max_runs=8)     # long time (25s)
-+    sage: TestSuite(M).run(max_runs=8)     # long time (35s)
-+    sage: TestSuite(N).run(max_runs=8, skip = '_test_derivation')    # long time (15s)
-+    sage: TestSuite(O).run()
-     sage: TestSuite(R).run()
--    sage: TestSuite(S).run() # long time (3s)
-+    sage: TestSuite(S).run()               # long time (4s)
- 
- Global function fields
- ----------------------
-@@ -287,7 +286,7 @@ class FunctionField(Field):
-         TESTS::
- 
-             sage: K.<x> = FunctionField(QQ)
--            sage: TestSuite(K).run()
-+            sage: TestSuite(K).run()               # long time (3s)
-         """
-         Field.__init__(self, base_field, names=names, category=category)
- 
-@@ -729,7 +728,7 @@ class FunctionField(Field):
-         EXAMPLES::
- 
-             sage: K.<x> = FunctionField(QQ)
--            sage: TestSuite(K).run() # indirect doctest
-+            sage: TestSuite(K).run()    # indirect doctest, long time (3s)
-         """
-         tester = self._tester(**options)
-         S = tester.some_elements()
-@@ -1209,7 +1208,7 @@ class FunctionField_polymod(FunctionField):
-             sage: K.<x> = FunctionField(QQ); R.<y> = K[]
-             sage: L = K.extension(y^5 - x^3 - 3*x + x*y); L
-             Function field in y defined by y^5 + x*y - x^3 - 3*x
--            sage: TestSuite(L).run()  # long time
-+            sage: TestSuite(L).run(max_runs=512)   # long time (15s)
- 
-         We can set the variable name, which doesn't have to be y::
- 
-@@ -2888,7 +2887,8 @@ class FunctionField_simple(FunctionField_polymod):
-             sage: F.<y> = K.extension(Y^3 - x^2*(x^2 + x + 1)^2)
-             sage: O = K.maximal_order()
-             sage: pls = [O.ideal(x-QQbar(sqrt(c))).place() for c in [-2, -1, 0, 1, 2]]
--            sage: all(q.place_below() == p for p in pls for q in F.places_above(p))
-+            sage: all(q.place_below() == p         # long time (4s)
-+            ....:     for p in pls for q in F.places_above(p))
-             True
-         """
-         R = self.base_field()
-@@ -3091,7 +3091,7 @@ class FunctionField_global(FunctionField_simple):
- 
-         sage: K.<x> = FunctionField(GF(4)); _.<Y> = K[]
-         sage: L.<y> = K.extension((1 - x)*Y^7 - x^3)
--        sage: L.gaps()
-+        sage: L.gaps()                         # long time (6s)
-         [1, 2, 3]
- 
-     or may define a trivial extension::
-@@ -3111,7 +3111,7 @@ class FunctionField_global(FunctionField_simple):
- 
-             sage: K.<x> = FunctionField(GF(5)); _.<Y> = K[]
-             sage: L.<y> = K.extension(Y^3 - (x^3 - 1)/(x^3 - 2))
--            sage: TestSuite(L).run()
-+            sage: TestSuite(L).run()               # long time (7s)
-         """
-         FunctionField_polymod.__init__(self, polynomial, names)
- 
-@@ -3807,7 +3807,7 @@ class RationalFunctionField(FunctionField):
- 
-             sage: K.<t> = FunctionField(CC); K
-             Rational function field in t over Complex Field with 53 bits of precision
--            sage: TestSuite(K).run()
-+            sage: TestSuite(K).run()               # long time (5s)
- 
-             sage: FunctionField(QQ[I], 'alpha')
-             Rational function field in alpha over Number Field in I with defining polynomial x^2 + 1 with I = 1*I
diff --git a/srcpkgs/sagemath/patches/matplotlib-3.6.patch b/srcpkgs/sagemath/patches/matplotlib-3.6.patch
new file mode 100644
index 000000000000..6afaf1b7162f
--- /dev/null
+++ b/srcpkgs/sagemath/patches/matplotlib-3.6.patch
@@ -0,0 +1,72 @@
+commit 5501e0de0dca1cff0355326dd42bd8c7e5749568
+Author: Gonzalo Tornaría <tornaria@cmat.edu.uy>
+Date:   Tue Oct 11 17:25:04 2022 -0300
+
+    Support matplotlib 3.6
+
+diff --git a/src/sage/plot/arc.py b/src/sage/plot/arc.py
+index bb834763afc..f65973bcbd5 100644
+--- a/src/sage/plot/arc.py
++++ b/src/sage/plot/arc.py
+@@ -273,9 +273,9 @@ class Arc(GraphicPrimitive):
+         p = patches.Arc((self.x, self.y),
+                         2. * self.r1,
+                         2. * self.r2,
+-                        fmod(self.angle, 2 * pi) * (180. / pi),
+-                        self.s1 * (180. / pi),
+-                        self.s2 * (180. / pi))
++                        angle=fmod(self.angle, 2 * pi) * (180. / pi),
++                        theta1=self.s1 * (180. / pi),
++                        theta2=self.s2 * (180. / pi))
+         return p
+ 
+     def bezier_path(self):
+diff --git a/src/sage/plot/ellipse.py b/src/sage/plot/ellipse.py
+index a77e6fe640a..c35bed574ef 100644
+--- a/src/sage/plot/ellipse.py
++++ b/src/sage/plot/ellipse.py
+@@ -192,7 +192,8 @@ class Ellipse(GraphicPrimitive):
+         options = self.options()
+         p = patches.Ellipse(
+                 (self.x,self.y),
+-                self.r1*2.,self.r2*2.,self.angle/pi*180.)
++                self.r1*2.,self.r2*2.,
++                angle=self.angle/pi*180.)
+         p.set_linewidth(float(options['thickness']))
+         p.set_fill(options['fill'])
+         a = float(options['alpha'])
+diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
+index e779e1210e3..8d620b5c625 100644
+--- a/src/sage/plot/graphics.py
++++ b/src/sage/plot/graphics.py
+@@ -2007,7 +2007,7 @@ class Graphics(WithEqualityById, SageObject):
+         We can also do custom formatting if you need it.  See above for full
+         details::
+ 
+-            sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex")
++            sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex") # not tested (broken with matplotlib 3.6)
+             Graphics object consisting of 1 graphics primitive
+ 
+         This is particularly useful when setting custom ticks in multiples
+@@ -2341,7 +2341,7 @@ class Graphics(WithEqualityById, SageObject):
+             sage: subplot = Figure().add_subplot(111)
+             sage: p._objects[0]._render_on_subplot(subplot)
+             sage: p._matplotlib_tick_formatter(subplot, **d)
+-            (<AxesSubplot:>,
++            (<AxesSubplot:...>,
+             <matplotlib.ticker.MaxNLocator object at ...>,
+             <matplotlib.ticker.MaxNLocator object at ...>,
+             <matplotlib.ticker.ScalarFormatter object at ...>,
+diff --git a/src/sage/plot/plot.py b/src/sage/plot/plot.py
+index b36ee57227c..5301a05c3dc 100644
+--- a/src/sage/plot/plot.py
++++ b/src/sage/plot/plot.py
+@@ -1741,7 +1741,7 @@ def plot(funcs, *args, **kwds):
+ 
+     ::
+ 
+-        sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex")
++        sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex") # not tested (broken with matplotlib 3.6)
+         Graphics object consisting of 1 graphics primitive
+ 
+     .. PLOT::
diff --git a/srcpkgs/sagemath/patches/python-3.11.patch b/srcpkgs/sagemath/patches/python-3.11.patch
new file mode 100644
index 000000000000..eafe76bfb794
--- /dev/null
+++ b/srcpkgs/sagemath/patches/python-3.11.patch
@@ -0,0 +1,45 @@
+--- a/src/sage/cpython/cython_metaclass.h
++++ b/src/sage/cpython/cython_metaclass.h
+@@ -66,7 +66,7 @@
+         }
+ 
+         /* Now, set t.__class__ to metaclass */
+-        Py_TYPE(t) = metaclass;
++        Py_SET_TYPE(t, metaclass);
+         PyType_Modified(t);
+     }
+     else
+--- a/src/sage/symbolic/ginac/numeric.cpp
++++ b/src/sage/symbolic/ginac/numeric.cpp
+@@ -52,7 +52,6 @@
+ #define register
+ #define PY_SSIZE_T_CLEAN
+ #include <Python.h>
+-#include <longintrepr.h>
+ #include "flint/fmpz.h"
+ #include "flint/fmpz_factor.h"
+ 
+--- a/src/sage/libs/gmp/pylong.pyx
++++ b/src/sage/libs/gmp/pylong.pyx
+@@ -32,7 +32,7 @@
+ from .mpz cimport *
+ 
+ cdef extern from *:
+-    Py_ssize_t* Py_SIZE_PTR "&Py_SIZE"(object)
++    void Py_SET_SIZE(object, Py_ssize_t)
+     int hash_bits """
+         #ifdef _PyHASH_BITS
+         _PyHASH_BITS         /* Python 3 */
+@@ -57,10 +57,8 @@
+     mpz_export(L.ob_digit, NULL,
+             -1, sizeof(digit), 0, PyLong_nails, z)
+     if mpz_sgn(z) < 0:
+-        # Set correct size (use a pointer to hack around Cython's
+-        # non-support for lvalues).
+-        sizeptr = Py_SIZE_PTR(L)
+-        sizeptr[0] = -pylong_size
++        # Set correct size
++        Py_SET_SIZE(L, -pylong_size)
+     return L
+ 
+ 
diff --git a/srcpkgs/sagemath/patches/sagemath-pari-2.15.patch b/srcpkgs/sagemath/patches/sagemath-pari-2.15.patch
new file mode 100644
index 000000000000..ccafad5070c4
--- /dev/null
+++ b/srcpkgs/sagemath/patches/sagemath-pari-2.15.patch
@@ -0,0 +1,1750 @@
+diff --git a/build/pkgs/giac/patches/pari_2_15.patch b/build/pkgs/giac/patches/pari_2_15.patch
+new file mode 100644
+index 0000000000..d2900a5ffc
+--- /dev/null
++++ b/build/pkgs/giac/patches/pari_2_15.patch
+@@ -0,0 +1,21 @@
++ANYARG patch
++
++diff --git a/src/pari.cc b/src/pari.cc
++index 76ce8e1..50d08ab 100644
++--- a/src/pari.cc
+++++ b/src/pari.cc
++@@ -40,6 +40,13 @@ using namespace std;
++ 
++ #ifdef HAVE_LIBPARI
++ 
+++// Anyarg disappeared from PARI 2.15.0
+++#ifdef __cplusplus
+++#  define ANYARG ...
+++#else
+++#  define ANYARG
+++#endif
+++
++ #ifdef HAVE_PTHREAD_H
++ #include <pthread.h>
++ #endif
++
+diff --git a/build/pkgs/pari/checksums.ini b/build/pkgs/pari/checksums.ini
+index b736feed31..bafd0f36f4 100644
+--- a/build/pkgs/pari/checksums.ini
++++ b/build/pkgs/pari/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=pari-VERSION.tar.gz
+-sha1=e01647aab7e96a8cb4922cf26a4f224337c6647f
+-md5=922f740fcdf8630b30d63dc76b58f756
+-cksum=297133525
++sha1=cba9b279f67d5efe2fbbccf3be6e9725f816cf07
++md5=76d430f1bea1b07fa2ad9712deeaa736
++cksum=1990743897
+ upstream_url=https://pari.math.u-bordeaux.fr/pub/pari/unix/pari-VERSION.tar.gz
+diff --git a/build/pkgs/pari/package-version.txt b/build/pkgs/pari/package-version.txt
+index a1a4224dd5..68e69e405e 100644
+--- a/build/pkgs/pari/package-version.txt
++++ b/build/pkgs/pari/package-version.txt
+@@ -1 +1 @@
+-2.13.3
++2.15.0
+diff --git a/src/doc/de/tutorial/tour_numtheory.rst b/src/doc/de/tutorial/tour_numtheory.rst
+index a012234c99..e3149fe949 100644
+--- a/src/doc/de/tutorial/tour_numtheory.rst
++++ b/src/doc/de/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ implementiert.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/en/tutorial/tour_numtheory.rst b/src/doc/en/tutorial/tour_numtheory.rst
+index 3064d100e2..075e0ac0ad 100644
+--- a/src/doc/en/tutorial/tour_numtheory.rst
++++ b/src/doc/en/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ NumberField class.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/es/tutorial/tour_numtheory.rst b/src/doc/es/tutorial/tour_numtheory.rst
+index a1f7d1a87b..48e5376cfe 100644
+--- a/src/doc/es/tutorial/tour_numtheory.rst
++++ b/src/doc/es/tutorial/tour_numtheory.rst
+@@ -140,7 +140,7 @@ Varios métodos relacionados están implementados en la clase ``NumberField``::
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/fr/tutorial/tour_numtheory.rst b/src/doc/fr/tutorial/tour_numtheory.rst
+index 871092f5fa..d1b2fee883 100644
+--- a/src/doc/fr/tutorial/tour_numtheory.rst
++++ b/src/doc/fr/tutorial/tour_numtheory.rst
+@@ -159,7 +159,7 @@ dans la classe NumberField.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/ja/tutorial/tour_numtheory.rst b/src/doc/ja/tutorial/tour_numtheory.rst
+index 47af68c862..4d4ed52d50 100644
+--- a/src/doc/ja/tutorial/tour_numtheory.rst
++++ b/src/doc/ja/tutorial/tour_numtheory.rst
+@@ -161,7 +161,7 @@ Sageには :math:`p` \-進数体も組込まれている.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/pt/tutorial/tour_numtheory.rst b/src/doc/pt/tutorial/tour_numtheory.rst
+index 6371b491ea..a3dc973a93 100644
+--- a/src/doc/pt/tutorial/tour_numtheory.rst
++++ b/src/doc/pt/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ NumberField.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus 
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/ru/tutorial/tour_numtheory.rst b/src/doc/ru/tutorial/tour_numtheory.rst
+index 652abfbc99..a985d49fbd 100644
+--- a/src/doc/ru/tutorial/tour_numtheory.rst
++++ b/src/doc/ru/tutorial/tour_numtheory.rst
+@@ -150,7 +150,7 @@ Sage содержит стандартные функции теории чис
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py
+index e57076646f..fec75d07c1 100644
+--- a/src/sage/arith/misc.py
++++ b/src/sage/arith/misc.py
+@@ -1465,13 +1465,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)]
++        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::
+ 
+@@ -2569,7 +2569,7 @@ def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds):
+ 
+         sage: K.<i> = QuadraticField(-1)
+         sage: factor(122 - 454*i)
+-        (-3*i - 2) * (-i - 2)^3 * (i + 1)^3 * (i + 4)
++        (-i) * (-i - 2)^3 * (i + 1)^3 * (-2*i + 3) * (i + 4)
+ 
+     To access the data in a factorization::
+ 
+diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
+index cdfc11a9e5..b6e1280d6e 100644
+--- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
++++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
+@@ -7825,9 +7825,9 @@ class DynamicalSystem_projective_field(DynamicalSystem_projective,
+             sage: f = DynamicalSystem_projective([x^2 + QQbar(sqrt(3))*y^2, y^2, QQbar(sqrt(2))*z^2])
+             sage: f.reduce_base_field()
+             Dynamical System of Projective Space of dimension 2 over Number Field in a with
+-            defining polynomial y^4 - 4*y^2 + 1 with a = 1.931851652578137?
++            defining polynomial y^4 - 4*y^2 + 1 with a = -0.5176380902050415?
+               Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x^2 + (a^2 - 2)*y^2 : y^2 : (a^3 - 3*a)*z^2)
++                    (x^2 + (-a^2 + 2)*y^2 : y^2 : (a^3 - 3*a)*z^2)
+ 
+         ::
+ 
+diff --git a/src/sage/ext_data/pari/simon/ellQ.gp b/src/sage/ext_data/pari/simon/ellQ.gp
+index 420af8f6a2..65e8386779 100644
+--- a/src/sage/ext_data/pari/simon/ellQ.gp
++++ b/src/sage/ext_data/pari/simon/ellQ.gp
+@@ -40,7 +40,7 @@
+   gp > \r ellcommon.gp
+   gp > \r ellQ.gp
+ 
+-  The main function is ellrank(), which takes as an argument
++  The main function is ellQ_ellrank(), which takes as an argument
+   any elliptic curve in the form [a1,a2,a3,a4,a6]
+   the result is a vector [r,s,v], where
+     r is a lower bound for the rank,
+@@ -50,7 +50,7 @@
+   Example:
+ 
+   gp > ell = [1,2,3,4,5];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+   %1 = [1, 1, [[1,2]]
+   In this example, the rank is exactly 1, and [1,2] has infinite order.
+ 
+@@ -92,7 +92,7 @@
+   \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+ 
+   Explications succintes :
+-  La fonction ellrank() accepte toutes les courbes sous la forme
++  La fonction ellQ_ellrank() accepte toutes les courbes sous la forme
+   [a1,a2,a3,a4,a6]
+   Les coefficients peuvent etre entiers ou non.
+   L'algorithme utilise est celui de la 2-descente.
+@@ -100,7 +100,7 @@
+   Il suffit de taper : 
+ 
+   gp > ell = [a1,a2,a3,a4,a6];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+ 
+   Retourne un vecteur [r,s,v] ou
+     r est le rang probable (c'est toujours une minoration du rang),
+@@ -110,7 +110,7 @@
+   Exemple :
+ 
+   gp > ell = [1,2,3,4,5];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+   %1 = [1, 1, [[1,2]]
+   Ici, le rang est exactement 1, et le point [1,2] est d'ordre infini.
+ 
+@@ -1571,12 +1571,12 @@ if( DEBUGLEVEL_ell >= 4, print("    end of ell2descent_gen"));
+     print("rank(E/Q)    >= ",m1)
+   );
+ }
+-{ellrank(ell,help=[]) =
++{ellQ_ellrank(ell,help=[]) =
+ \\ Algorithm of 2-descent on the elliptic curve ell.
+ \\ help is a list of known points on ell.
+ my(urst,urst1,den,eqell,tors2,bnf,rang,time1);
+ 
+-if( DEBUGLEVEL_ell >= 3, print("   starting ellrank"));
++if( DEBUGLEVEL_ell >= 3, print("   starting ellQ_ellrank"));
+   if( #ell < 13, ell = ellinit(ell));
+ 
+ \\ kill the coefficients a1 and a3
+@@ -1630,7 +1630,7 @@ if( DEBUGLEVEL_ell >= 1, print(" Elliptic curve: Y^2 = ",eqell));
+   ));
+ 
+   rang[3] = ellchangepoint(rang[3],ellinverturst(urst));
+-if( DEBUGLEVEL_ell >= 3, print("   end of ellrank"));
++if( DEBUGLEVEL_ell >= 3, print("   end of ellQ_ellrank"));
+ 
+   return(rang);
+ }
+@@ -2106,13 +2106,13 @@ if( DEBUGLEVEL_ell >= 3, print("   end of ell2descent_viaisog"));
+ {
+ \\                  functions for elliptic curves
+   addhelp(ell2descent_complete,
+-    "ell2descent_complete(e1,e2,e3): Performs a complete 2-descent on the elliptic curve y^2 = (x-e1)*(x-e2)*(x-e3). See ?ellrank for the format of the output.");
++    "ell2descent_complete(e1,e2,e3): Performs a complete 2-descent on the elliptic curve y^2 = (x-e1)*(x-e2)*(x-e3). See ?ellQ_ellrank for the format of the output.");
+   addhelp(ell2descent_gen,
+-    "ell2descent_gen((E,bnf,k=1,help=[]): E is a vector of the form [0,A,0,B,C], (or the result of ellinit of such a vector) A,B,C integers such that x^3+A*x^2+B*x+C; bnf is the corresponding bnfinit(,1); Performs 2-descent on the elliptic curve Ek: k*y^2=x^3+A*x^2+B*x+C. See ?ellrank for the format of the output.");
++    "ell2descent_gen((E,bnf,k=1,help=[]): E is a vector of the form [0,A,0,B,C], (or the result of ellinit of such a vector) A,B,C integers such that x^3+A*x^2+B*x+C; bnf is the corresponding bnfinit(,1); Performs 2-descent on the elliptic curve Ek: k*y^2=x^3+A*x^2+B*x+C. See ?ellQ_ellrank for the format of the output.");
+   addhelp(ell2descent_viaisog,
+-    "ell2descent_viaisog(E,help=[]): E is an elliptic curve of the form [0,a,0,b,0], with a, b integers. Performs a 2-descent via isogeny on E. See ?ellrank for the format of the output.");
+-  addhelp(ellrank,
+-    "ellrank(E,help=[]): E is any elliptic curve defined over Q. Returns a vector [r,s,v], where r is a lower bound for the rank of E, s is the rank of its 2-Selmer group and v is a list of independant points in E(Q)/2E(Q). If help is a vector of nontrivial points on E, the result might be faster. This function might be used in conjunction with elltors2(E). See also ?default_ellQ");
++    "ell2descent_viaisog(E,help=[]): E is an elliptic curve of the form [0,a,0,b,0], with a, b integers. Performs a 2-descent via isogeny on E. See ?ellQ_ellrank for the format of the output.");
++  addhelp(ellQ_ellrank,
++    "ellQ_ellrank(E,help=[]): E is any elliptic curve defined over Q. Returns a vector [r,s,v], where r is a lower bound for the rank of E, s is the rank of its 2-Selmer group and v is a list of independant points in E(Q)/2E(Q). If help is a vector of nontrivial points on E, the result might be faster. This function might be used in conjunction with elltors2(E). See also ?default_ellQ");
+   addhelp(ellhalf,
+     "ellhalf(E,P): returns the vector of all points Q on the elliptic curve E such that 2Q = P");
+   addhelp(ellredgen,
+@@ -2143,7 +2143,7 @@ if( DEBUGLEVEL_ell >= 3, print("   end of ell2descent_viaisog"));
+ 
+ \\                  others
+   addhelp(default_ellQ,
+-    "default_ellQ(DEBUGLEVEL_ell, LIM1, LIM3, LIMTRIV, ELLREDGENFLAG, COMPLETE, MAXPROB, LIMBIGPRIME): set the value of the global variables used for ellrank() and other related functions. DEBUGLEVEL_ell: 0-5: choose the quantity of information printed during the computation (default=0: print nothing); LIM1 (resp LIM3): search limit for easy (resp hard) points on quartics; LIMTRIV: search limit for trivial points on elliptic curves; ELLREDGENFLAG: if != 0, try to reduce the generators at the end; COMPLETE: if != 0 and full 2-torsion, use complete 2-descent, otherwise via 2-isogeny; MAXPROB, LIMBIGPRIME: technical.");
++    "default_ellQ(DEBUGLEVEL_ell, LIM1, LIM3, LIMTRIV, ELLREDGENFLAG, COMPLETE, MAXPROB, LIMBIGPRIME): set the value of the global variables used for ellQ_ellrank() and other related functions. DEBUGLEVEL_ell: 0-5: choose the quantity of information printed during the computation (default=0: print nothing); LIM1 (resp LIM3): search limit for easy (resp hard) points on quartics; LIMTRIV: search limit for trivial points on elliptic curves; ELLREDGENFLAG: if != 0, try to reduce the generators at the end; COMPLETE: if != 0 and full 2-torsion, use complete 2-descent, otherwise via 2-isogeny; MAXPROB, LIMBIGPRIME: technical.");
+ /*  addhelp(DEBUGLEVEL_ell,
+     "DEBUGLEVEL_ell: Choose a higher value of this global variable to have more details of the computations printed during the 2-descent algorithm. 0 = don't print anything; 1 = (default) just print the result; 2 = print more details including the Selmer group and the nontrivial quartics.");
+ */
+diff --git a/src/sage/ext_data/pari/simon/qfsolve.gp b/src/sage/ext_data/pari/simon/qfsolve.gp
+index 501fb50828..2107288c1d 100644
+--- a/src/sage/ext_data/pari/simon/qfsolve.gp
++++ b/src/sage/ext_data/pari/simon/qfsolve.gp
+@@ -434,146 +434,6 @@ my(cc);
+ return([U3~*G3*U3,red[2]*U1*U2*U3]);
+ }
+ 
+-\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+-\\        QUADRATIC FORMS MINIMIZATION         \\
+-\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+-
+-\\ Minimization of the quadratic form G, with nonzero determinant.
+-\\ of dimension n>=2.
+-\\ G must by symmetric and have integral coefficients.
+-\\ Returns [G',U,factd] with U in GLn(Q) such that G'=U~*G*U*constant
+-\\ is integral and has minimal determinant.
+-\\ In dimension 3 or 4, may return a prime p
+-\\ if the reduction at p is impossible because of the local non solvability.
+-\\ If given, factdetG must be equal to factor(abs(det(G))).
+-{qfminimize(G,factdetG) =
+-my(factd,U,Ker,Ker2,sol,aux,di);
+-my(p);
+-my(n,lf,i,vp,dimKer,dimKer2,m);
+-
+-  n = length(G);
+-  factd = matrix(0,2);
+-  if( !factdetG, factdetG = factor(matdet(G)));
+-
+-  lf = length(factdetG[,1]);
+-  i = 1; U = matid(n);
+-
+-  while(i <= lf,
+-    vp = factdetG[i,2];
+-    if( vp == 0, i++; next);
+-    p = factdetG[i,1];
+-    if( p == -1, i++; next);
+-if( DEBUGLEVEL_qfsolve >= 4, print("    p = ",p,"^",vp));
+-
+-\\ The case vp = 1 can be minimized only if n is odd.
+-    if( vp == 1 && n%2 == 0,
+-      factd = concat(factd~, Mat([p,1])~)~;
+-      i++; next
+-    );
+-    Ker = kermodp(G,p); dimKer = Ker[1]; Ker = Ker[2];
+-
+-\\ Rem: we must have dimKer <= vp
+-if( DEBUGLEVEL_qfsolve >= 4, print("    dimKer = ",dimKer));
+-\\ trivial case: dimKer = n
+-    if( dimKer == n, 
+-if( DEBUGLEVEL_qfsolve >= 4, print("     case 0: dimKer = n"));
+-      G /= p;
+-      factdetG[i,2] -= n;
+-      next
+-    );
+-    G = Ker~*G*Ker;
+-    U = U*Ker;
+-
+-\\ 1st case: dimKer < vp
+-\\ then the kernel mod p contains a kernel mod p^2
+-    if( dimKer < vp,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 1: dimker < vp"));
+-      if( dimKer == 1,
+-\\        G[,1] /= p; G[1,] /= p;
+-        G[,1] /= p; G[1,] = G[1,]/p;
+-        U[,1] /= p;
+-        factdetG[i,2] -= 2
+-      , 
+-        Ker2 = kermodp(matrix(dimKer,dimKer,j,k,G[j,k]/p),p);
+-        dimKer2 = Ker2[1]; Ker2 = Ker2[2];
+-        for( j = 1, dimKer2, Ker2[,j] /= p);
+-        Ker2 = matdiagonalblock([Ker2,matid(n-dimKer)]);
+-        G = Ker2~*G*Ker2;
+-        U = U*Ker2;
+-        factdetG[i,2] -= 2*dimKer2
+-);
+-
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 1"));
+-      next
+-    );
+-
+-\\ Now, we have vp = dimKer 
+-\\ 2nd case: the dimension of the kernel is >=2
+-\\ and contains an element of norm 0 mod p^2
+-
+-\\ search for an element of norm p^2... in the kernel
+-    if( dimKer > 2 || 
+-       (dimKer == 2 && issquare( di = Mod((G[1,2]^2-G[1,1]*G[2,2])/p^2,p))),
+-      if( dimKer > 2,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 2.1"));
+-        dimKer = 3;
+-        sol = qfsolvemodp(matrix(3,3,j,k,G[j,k]/p),p)
+-      ,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 2.2"));
+-        if( G[1,1]%p^2 == 0, 
+-          sol = [1,0]~
+-        , sol = [-G[1,2]/p+sqrt(di),Mod(G[1,1]/p,p)]~
+-        )
+-      );
+-      sol = centerlift(sol);
+-      sol /= content(sol);
+-if( DEBUGLEVEL_qfsolve >= 4, print("    sol = ",sol));
+-      Ker = vectorv(n, j, if( j<= dimKer, sol[j], 0)); \\ fill with 0's
+-      Ker = completebasis(Ker,1);
+-      Ker[,n] /= p;
+-      G = Ker~*G*Ker;
+-      U = U*Ker;
+-      factdetG[i,2] -= 2;
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 2"));
+-      next
+-    );
+-
+-\\ Now, we have vp = dimKer <= 2 
+-\\   and the kernel contains no vector with norm p^2...
+-
+-\\ In some cases, exchanging the kernel and the image
+-\\ makes the minimization easy.
+-
+-    m = (n-1)\2-1;
+-    if( ( vp == 1 && issquare(Mod(-(-1)^m*matdet(G)/G[1,1],p)))
+-     || ( vp == 2 && n%2 == 1 && n >= 5)
+-     || ( vp == 2 && n%2 == 0 && !issquare(Mod((-1)^m*matdet(G)/p^2,p)))
+-    , 
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 3"));
+-      Ker = matid(n);
+-      for( j = dimKer+1, n, Ker[j,j] = p);
+-      G = Ker~*G*Ker/p;
+-      U = U*Ker;
+-      factdetG[i,2] -= 2*dimKer-n;
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 3"));
+-      next
+-    );
+-
+-\\ Minimization was not possible se far.
+-\\ If n == 3 or 4, this proves the local non-solubility at p.
+-    if( n == 3 || n == 4, 
+-if( DEBUGLEVEL_qfsolve >= 1, print(" no local solution at ",p));
+-      return(p));
+-
+-if( DEBUGLEVEL_qfsolve >= 4, print("    prime ",p," finished"));
+-    factd = concat(factd~,Mat([p,vp])~)~;
+-    i++
+-  );
+-\\ apply LLL to avoid coefficients explosion
+-  aux = qflll(U/content(U));
+-return([aux~*G*aux,U*aux,factd]);
+-}
+-
+ \\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+ \\          CLASS GROUP COMPUTATIONS           \\
+ \\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+diff --git a/src/sage/geometry/polyhedron/backend_field.py b/src/sage/geometry/polyhedron/backend_field.py
+index 6b921d23a6..2f32c58b1e 100644
+--- a/src/sage/geometry/polyhedron/backend_field.py
++++ b/src/sage/geometry/polyhedron/backend_field.py
+@@ -265,7 +265,7 @@ class Polyhedron_field(Polyhedron_base):
+              An inequality (-0.1419794359520263?, -1.698172434277148?) x + 1.200789243901438? >= 0,
+              An inequality (0.3001973109753594?, 0.600394621950719?) x - 0.4245431085692869? >= 0)
+             sage: p.Vrepresentation()                                           # optional - sage.rings.number_field
+-            (A vertex at (0.?e-15, 0.707106781186548?),
++            (A vertex at (0.?e-16, 0.7071067811865475?),
+              A vertex at (1.414213562373095?, 0),
+              A vertex at (4.000000000000000?, 0.372677996249965?))
+         """
+@@ -308,7 +308,7 @@ class Polyhedron_field(Polyhedron_base):
+              An inequality (-0.1419794359520263?, -1.698172434277148?) x + 1.200789243901438? >= 0,
+              An inequality (0.3001973109753594?, 0.600394621950719?) x - 0.4245431085692869? >= 0)
+             sage: p.Vrepresentation()                                           # optional - sage.rings.number_field
+-            (A vertex at (0.?e-15, 0.707106781186548?),
++            (A vertex at (0.?e-16, 0.7071067811865475?),
+              A vertex at (1.414213562373095?, 0),
+              A vertex at (4.000000000000000?, 0.372677996249965?))
+         """
+diff --git a/src/sage/geometry/polyhedron/backend_normaliz.py b/src/sage/geometry/polyhedron/backend_normaliz.py
+index 86b89632a5..ca8a43b248 100644
+--- a/src/sage/geometry/polyhedron/backend_normaliz.py
++++ b/src/sage/geometry/polyhedron/backend_normaliz.py
+@@ -53,7 +53,7 @@ def _number_field_elements_from_algebraics_list_of_lists_of_lists(listss, **kwds
+         1.732050807568878?
+         sage: from sage.geometry.polyhedron.backend_normaliz import _number_field_elements_from_algebraics_list_of_lists_of_lists
+         sage: K, results, hom = _number_field_elements_from_algebraics_list_of_lists_of_lists([[[rt2], [1]], [[rt3]], [[1], []]]); results  # optional - sage.rings.number_field
+-        [[[-a^3 + 3*a], [1]], [[-a^2 + 2]], [[1], []]]
++        [[[-a^3 + 3*a], [1]], [[a^2 - 2]], [[1], []]]
+     """
+     from sage.rings.qqbar import number_field_elements_from_algebraics
+     numbers = []
+diff --git a/src/sage/groups/matrix_gps/isometries.py b/src/sage/groups/matrix_gps/isometries.py
+index f9111a2c92..cca45e7175 100644
+--- a/src/sage/groups/matrix_gps/isometries.py
++++ b/src/sage/groups/matrix_gps/isometries.py
+@@ -11,11 +11,11 @@ EXAMPLES::
+     sage: L = IntegralLattice("D4")
+     sage: O = L.orthogonal_group()
+     sage: O
+-    Group of isometries with 5 generators (
+-    [-1  0  0  0]  [0 0 0 1]  [-1 -1 -1 -1]  [ 1  1  0  0]  [ 1  0  0  0]
+-    [ 0 -1  0  0]  [0 1 0 0]  [ 0  0  1  0]  [ 0  0  1  0]  [-1 -1 -1 -1]
+-    [ 0  0 -1  0]  [0 0 1 0]  [ 0  1  0  1]  [ 0  1  0  1]  [ 0  0  1  0]
+-    [ 0  0  0 -1], [1 0 0 0], [ 0 -1 -1  0], [ 0 -1 -1  0], [ 0  0  0  1]
++    Group of isometries with 3 generators (
++    [0 0 0 1]  [ 1  1  0  0]  [ 1  0  0  0]
++    [0 1 0 0]  [ 0  0  1  0]  [-1 -1 -1 -1]
++    [0 0 1 0]  [ 0  1  0  1]  [ 0  0  1  0]
++    [1 0 0 0], [ 0 -1 -1  0], [ 0  0  0  1]
+     )
+ 
+ Basic functionality is provided by GAP::
+diff --git a/src/sage/interfaces/genus2reduction.py b/src/sage/interfaces/genus2reduction.py
+index 56ae04b235..7a4794daf2 100644
+--- a/src/sage/interfaces/genus2reduction.py
++++ b/src/sage/interfaces/genus2reduction.py
+@@ -143,31 +143,31 @@ class ReductionData(SageObject):
+        sur un corps de valuation discrète", Trans. AMS 348 (1996),
+        4577-4610, Section 7.2, Proposition 4).
+     """
+-    def __init__(self, pari_result, P, Q, minimal_equation, minimal_disc,
+-                 local_data, conductor, prime_to_2_conductor_only):
++    def __init__(self, pari_result, P, Q, Pmin, Qmin, minimal_disc,
++                 local_data, conductor):
+         self.pari_result = pari_result
+         self.P = P
+         self.Q = Q
+-        self.minimal_equation = minimal_equation
++        self.Pmin = Pmin
++        self.Qmin = Qmin
+         self.minimal_disc = minimal_disc
+         self.local_data = local_data
+         self.conductor = conductor
+-        self.prime_to_2_conductor_only = prime_to_2_conductor_only
+ 
+     def _repr_(self):
+-        if self.prime_to_2_conductor_only:
+-            ex = ' (away from 2)'
+-        else:
+-            ex = ''
+         if self.Q == 0:
+             yterm = ''
+         else:
+             yterm = '+ (%s)*y '%self.Q
++
+         s = 'Reduction data about this proper smooth genus 2 curve:\n'
+         s += '\ty^2 %s= %s\n'%(yterm, self.P)
+-        s += 'A Minimal Equation (away from 2):\n\ty^2 = %s\n'%self.minimal_equation
+-        s += 'Minimal Discriminant (away from 2):  %s\n'%self.minimal_disc
+-        s += 'Conductor%s: %s\n'%(ex, self.conductor)
++        if self.Qmin:
++            s += 'A Minimal Equation:\n\ty^2 + (%s)y = %s\n'%(self.Qmin, self.Pmin)
++        else:
++            s += 'A Minimal Equation:\n\ty^2 = %s\n'%self.Pmin
++        s += 'Minimal Discriminant: %s\n'%self.minimal_disc
++        s += 'Conductor: %s\n'%self.conductor
+         s += 'Local Data:\n%s'%self._local_data_str()
+         return s
+ 
+@@ -242,17 +242,7 @@ class Genus2reduction(SageObject):
+         sage: factor(R.conductor)
+         5^4 * 2267
+ 
+-    This means that only the odd part of the conductor is known.
+-
+-    ::
+-
+-        sage: R.prime_to_2_conductor_only
+-        True
+-
+-    The discriminant is always minimal away from 2, but possibly not at
+-    2.
+-
+-    ::
++    The discriminant is always minimal::
+ 
+         sage: factor(R.minimal_disc)
+         2^3 * 5^5 * 2267
+@@ -264,10 +254,10 @@ class Genus2reduction(SageObject):
+         sage: R
+         Reduction data about this proper smooth genus 2 curve:
+             y^2 + (x^3 - 2*x^2 - 2*x + 1)*y = -5*x^5
+-        A Minimal Equation (away from 2):
+-            y^2 = x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855
+-        Minimal Discriminant (away from 2):  56675000
+-        Conductor (away from 2): 1416875
++        A Minimal Equation:
++            y^2 ...
++        Minimal Discriminant: 56675000
++        Conductor: 1416875
+         Local Data:
+             p=2
+             (potential) stable reduction:  (II), j=1
+@@ -293,10 +283,10 @@ class Genus2reduction(SageObject):
+         sage: genus2reduction(0, x^6 + 3*x^3 + 63)
+         Reduction data about this proper smooth genus 2 curve:
+                 y^2 = x^6 + 3*x^3 + 63
+-        A Minimal Equation (away from 2):
+-                y^2 = x^6 + 3*x^3 + 63
+-        Minimal Discriminant (away from 2):  10628388316852992
+-        Conductor (away from 2): 2893401
++        A Minimal Equation:
++                y^2 ...
++        Minimal Discriminant: -10628388316852992
++        Conductor: 2893401
+         Local Data:
+                 p=2
+                 (potential) stable reduction:  (V), j1+j2=0, j1*j2=0
+@@ -327,9 +317,9 @@ class Genus2reduction(SageObject):
+         sage: genus2reduction(x^3-x^2-1, x^2 - x)
+         Reduction data about this proper smooth genus 2 curve:
+                 y^2 + (x^3 - x^2 - 1)*y = x^2 - x
+-        A Minimal Equation (away from 2):
+-                y^2 = x^6 + 58*x^5 + 1401*x^4 + 18038*x^3 + 130546*x^2 + 503516*x + 808561
+-        Minimal Discriminant (away from 2):  169
++        A Minimal Equation:
++                y^2 ...
++        Minimal Discriminant: -169
+         Conductor: 169
+         Local Data:
+                 p=13
+@@ -370,10 +360,10 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^3 - 2*x^2 - 2*x + 1, -5*x^5)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^3 - 2*x^2 - 2*x + 1)*y = -5*x^5
+-            A Minimal Equation (away from 2):
+-                    y^2 = x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855
+-            Minimal Discriminant (away from 2):  56675000
+-            Conductor (away from 2): 1416875
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 56675000
++            Conductor: 1416875
+             Local Data:
+                     p=2
+                     (potential) stable reduction:  (II), j=1
+@@ -389,9 +379,9 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^2 + 1, -5*x^5)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^2 + 1)*y = -5*x^5
+-            A Minimal Equation (away from 2):
+-                    y^2 = -20*x^5 + x^4 + 2*x^2 + 1
+-            Minimal Discriminant (away from 2):  48838125
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 48838125
+             Conductor: 32025
+             Local Data:
+                     p=3
+@@ -412,9 +402,9 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^3 + x^2 + x,-2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^3 + x^2 + x)*y = -2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2
+-            A Minimal Equation (away from 2):
+-                    y^2 = x^6 + 18*x^3 + 36*x^2 - 27
+-            Minimal Discriminant (away from 2):  1520984142
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 1520984142
+             Conductor: 954
+             Local Data:
+                     p=2
+@@ -436,18 +426,10 @@ class Genus2reduction(SageObject):
+             raise ValueError("Q (=%s) must have degree at most 3" % Q)
+ 
+         res = pari.genus2red([P, Q])
+-
+         conductor = ZZ(res[0])
+-        minimal_equation = R(res[2])
+-
+-        minimal_disc = QQ(res[2].poldisc()).abs()
+-        if minimal_equation.degree() == 5:
+-            minimal_disc *= minimal_equation[5]**2
+-        # Multiply with suitable power of 2 of the form 2^(2*(d-1) - 12)
+-        b = 2 * (minimal_equation.degree() - 1)
+-        k = QQ((12 - minimal_disc.valuation(2), b)).ceil()
+-        minimal_disc >>= 12 - b*k
+-        minimal_disc = ZZ(minimal_disc)
++        Pmin = R(res[2][0])
++        Qmin = R(res[2][1])
++        minimal_disc = ZZ(pari.hyperelldisc(res[2]))
+ 
+         local_data = {}
+         for red in res[3]:
+@@ -468,9 +450,7 @@ class Genus2reduction(SageObject):
+ 
+             local_data[p] = data
+ 
+-        prime_to_2_conductor_only = (-1 in res[1].component(2))
+-        return ReductionData(res, P, Q, minimal_equation, minimal_disc, local_data,
+-                             conductor, prime_to_2_conductor_only)
++        return ReductionData(res, P, Q, Pmin, Qmin, minimal_disc, local_data, conductor)
+ 
+     def __reduce__(self):
+         return _reduce_load_genus2reduction, tuple([])
+diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
+index fec450d7bc..236402c293 100644
+--- a/src/sage/lfunctions/dokchitser.py
++++ b/src/sage/lfunctions/dokchitser.py
+@@ -337,6 +337,7 @@ class Dokchitser(SageObject):
+             # After init_coeffs is called, future calls to this method should
+             # return the full output for further parsing
+             raise RuntimeError("unable to create L-series, due to precision or other limits in PARI")
++        t = t.replace("  *** _^_: Warning: normalizing a series with 0 leading term.\n", "")
+         return t
+ 
+     def __check_init(self):
+diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
+index d2b20f1891..6c31efe239 100644
+--- a/src/sage/lfunctions/pari.py
++++ b/src/sage/lfunctions/pari.py
+@@ -339,7 +339,7 @@ def lfun_eta_quotient(scalings, exponents):
+         0.0374412812685155
+ 
+         sage: lfun_eta_quotient([6],[4])
+-        [[Vecsmall([7]), [Vecsmall([6]), Vecsmall([4])]], 0, [0, 1], 2, 36, 1]
++        [[Vecsmall([7]), [Vecsmall([6]), Vecsmall([4]), 0]], 0, [0, 1], 2, 36, 1]
+ 
+         sage: lfun_eta_quotient([2,1,4], [5,-2,-2])
+         Traceback (most recent call last):
+diff --git a/src/sage/libs/pari/tests.py b/src/sage/libs/pari/tests.py
+index e5a2aa2517..0efcb15de0 100644
+--- a/src/sage/libs/pari/tests.py
++++ b/src/sage/libs/pari/tests.py
+@@ -356,7 +356,7 @@ Constructors::
+     [2, 4]~*x + [1, 3]~
+ 
+     sage: pari(3).Qfb(7, 1)
+-    Qfb(3, 7, 1, 0.E-19)
++    Qfb(3, 7, 1)
+     sage: pari(3).Qfb(7, 2)
+     Traceback (most recent call last):
+     ...
+@@ -512,7 +512,7 @@ Basic functions::
+     sage: pari('sqrt(-2)').frac()
+     Traceback (most recent call last):
+     ...
+-    PariError: incorrect type in gfloor (t_COMPLEX)
++    PariError: incorrect type in gfrac (t_COMPLEX)
+ 
+     sage: pari('1+2*I').imag()
+     2
+diff --git a/src/sage/modular/cusps_nf.py b/src/sage/modular/cusps_nf.py
+index 25d93cac92..157ebabe29 100644
+--- a/src/sage/modular/cusps_nf.py
++++ b/src/sage/modular/cusps_nf.py
+@@ -1220,7 +1220,7 @@ def units_mod_ideal(I):
+         sage: I = k.ideal(5, a + 1)
+         sage: units_mod_ideal(I)
+         [1,
+-        2*a^2 + 4*a - 1,
++        -2*a^2 - 4*a + 1,
+         ...]
+ 
+     ::
+diff --git a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
+index a881336596..090d1bfaf0 100644
+--- a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
++++ b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
+@@ -43,7 +43,7 @@ def coerce_AA(p):
+         sage: AA(p)._exact_field()
+         Number Field in a with defining polynomial y^8 ... with a in ...
+         sage: coerce_AA(p)._exact_field()
+-        Number Field in a with defining polynomial y^4 - 1910*y^2 - 3924*y + 681058 with a in 39.710518724...?
++        Number Field in a with defining polynomial y^4 - 1910*y^2 - 3924*y + 681058 with a in ...?
+     """
+     el = AA(p)
+     el.simplify()
+diff --git a/src/sage/modular/modsym/p1list_nf.py b/src/sage/modular/modsym/p1list_nf.py
+index 222caacca8..f9d969732c 100644
+--- a/src/sage/modular/modsym/p1list_nf.py
++++ b/src/sage/modular/modsym/p1list_nf.py
+@@ -58,7 +58,7 @@ Lift an MSymbol to a matrix in `SL(2, R)`:
+ 
+     sage: alpha = MSymbol(N, a + 2, 3*a^2)
+     sage: alpha.lift_to_sl2_Ok()
+-    [-3*a^2 + a + 12, 25*a^2 - 50*a + 100, a + 2, a^2 - 3*a + 3]
++    [-1, 4*a^2 - 13*a + 23, a + 2, 5*a^2 + 3*a - 3]
+     sage: Ok = k.ring_of_integers()
+     sage: M = Matrix(Ok, 2, alpha.lift_to_sl2_Ok())
+     sage: det(M)
+@@ -945,11 +945,11 @@ class P1NFList(SageObject):
+             sage: N = k.ideal(5, a + 1)
+             sage: P = P1NFList(N)
+             sage: u = k.unit_group().gens_values(); u
+-            [-1, 2*a^2 + 4*a - 1]
++            [-1, -2*a^2 - 4*a + 1]
+             sage: P.apply_J_epsilon(4, -1)
+             2
+             sage: P.apply_J_epsilon(4, u[0], u[1])
+-            1
++            5
+ 
+         ::
+ 
+diff --git a/src/sage/modules/free_quadratic_module_integer_symmetric.py b/src/sage/modules/free_quadratic_module_integer_symmetric.py
+index a206f0c721..aeb19ab669 100644
+--- a/src/sage/modules/free_quadratic_module_integer_symmetric.py
++++ b/src/sage/modules/free_quadratic_module_integer_symmetric.py
+@@ -1168,11 +1168,11 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+             sage: A4 = IntegralLattice("A4")
+             sage: Aut = A4.orthogonal_group()
+             sage: Aut
+-            Group of isometries with 5 generators (
+-            [-1  0  0  0]  [0 0 0 1]  [-1 -1 -1  0]  [ 1  0  0  0]  [ 1  0  0  0]
+-            [ 0 -1  0  0]  [0 0 1 0]  [ 0  0  0 -1]  [-1 -1 -1 -1]  [ 0  1  0  0]
+-            [ 0  0 -1  0]  [0 1 0 0]  [ 0  0  1  1]  [ 0  0  0  1]  [ 0  0  1  1]
+-            [ 0  0  0 -1], [1 0 0 0], [ 0  1  0  0], [ 0  0  1  0], [ 0  0  0 -1]
++            Group of isometries with 4 generators (
++            [0 0 0 1]  [-1 -1 -1  0]  [ 1  0  0  0]  [ 1  0  0  0]
++            [0 0 1 0]  [ 0  0  0 -1]  [-1 -1 -1 -1]  [ 0  1  0  0]
++            [0 1 0 0]  [ 0  0  1  1]  [ 0  0  0  1]  [ 0  0  1  1]
++            [1 0 0 0], [ 0  1  0  0], [ 0  0  1  0], [ 0  0  0 -1]
+             )
+ 
+         The group acts from the right on the lattice and its discriminant group::
+@@ -1180,19 +1180,19 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+             sage: x = A4.an_element()
+             sage: g = Aut.an_element()
+             sage: g
+-            [ 1  1  1  0]
+-            [ 0  0 -1  0]
+-            [ 0  0  1  1]
+-            [ 0 -1 -1 -1]
++            [-1 -1 -1  0]
++            [ 0  0  1  0]
++            [ 0  0 -1 -1]
++            [ 0  1  1  1]
+             sage: x*g
+-            (1, 1, 1, 0)
++            (-1, -1, -1, 0)
+             sage: (x*g).parent()==A4
+             True
+             sage: (g*x).parent()
+             Vector space of dimension 4 over Rational Field
+             sage: y = A4.discriminant_group().an_element()
+             sage: y*g
+-            (1)
++            (4)
+ 
+         If the group is finite we can compute the usual things::
+ 
+@@ -1208,10 +1208,10 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+ 
+             sage: A2 = IntegralLattice(matrix.identity(3),Matrix(ZZ,2,3,[1,-1,0,0,1,-1]))
+             sage: A2.orthogonal_group()
+-            Group of isometries with 3 generators (
+-            [-1/3  2/3  2/3]  [ 2/3  2/3 -1/3]  [1 0 0]
+-            [ 2/3 -1/3  2/3]  [ 2/3 -1/3  2/3]  [0 0 1]
+-            [ 2/3  2/3 -1/3], [-1/3  2/3  2/3], [0 1 0]
++            Group of isometries with 2 generators (
++            [ 2/3  2/3 -1/3]  [1 0 0]
++            [ 2/3 -1/3  2/3]  [0 0 1]
++            [-1/3  2/3  2/3], [0 1 0]
+             )
+ 
+         It can be negative definite as well::
+diff --git a/src/sage/quadratic_forms/binary_qf.py b/src/sage/quadratic_forms/binary_qf.py
+index cfa3ada73e..5ac823bc6c 100755
+--- a/src/sage/quadratic_forms/binary_qf.py
++++ b/src/sage/quadratic_forms/binary_qf.py
+@@ -141,7 +141,7 @@ class BinaryQF(SageObject):
+                   and a.degree() == 2 and a.parent().ngens() == 2):
+                 x, y = a.parent().gens()
+                 a, b, c = [a.monomial_coefficient(mon) for mon in [x**2, x*y, y**2]]
+-            elif isinstance(a, pari_gen) and a.type() in ('t_QFI', 't_QFR'):
++            elif isinstance(a, pari_gen) and a.type() in ('t_QFI', 't_QFR', 't_QFB'):
+                 # a has 3 or 4 components
+                 a, b, c = a[0], a[1], a[2]
+         try:
+diff --git a/src/sage/quadratic_forms/genera/genus.py b/src/sage/quadratic_forms/genera/genus.py
+index 8290b6c4fa..0fc43f33c6 100644
+--- a/src/sage/quadratic_forms/genera/genus.py
++++ b/src/sage/quadratic_forms/genera/genus.py
+@@ -3088,8 +3088,8 @@ class GenusSymbol_global_ring():
+             sage: G = Genus(matrix(ZZ, 3, [6,3,0, 3,6,0, 0,0,2]))
+             sage: G.representatives()
+             (
+-            [2 0 0]  [ 2 -1  0]
+-            [0 6 3]  [-1  2  0]
++            [2 0 0]  [ 2  1  0]
++            [0 6 3]  [ 1  2  0]
+             [0 3 6], [ 0  0 18]
+             )
+ 
+diff --git a/src/sage/quadratic_forms/qfsolve.py b/src/sage/quadratic_forms/qfsolve.py
+index ddde95e04f..d5e15d9f83 100644
+--- a/src/sage/quadratic_forms/qfsolve.py
++++ b/src/sage/quadratic_forms/qfsolve.py
+@@ -70,7 +70,7 @@ def qfsolve(G):
+ 
+         sage: M = Matrix(QQ, [[3, 0, 0, 0], [0, 5, 0, 0], [0, 0, -7, 0], [0, 0, 0, -11]])
+         sage: qfsolve(M)
+-        (3, -4, -3, -2)
++        (3, 4, -3, -2)
+     """
+     ret = G.__pari__().qfsolve()
+     if ret.type() == 't_COL':
+diff --git a/src/sage/quadratic_forms/quadratic_form__automorphisms.py b/src/sage/quadratic_forms/quadratic_form__automorphisms.py
+index c36c667e3b..3d72cf3be1 100644
+--- a/src/sage/quadratic_forms/quadratic_form__automorphisms.py
++++ b/src/sage/quadratic_forms/quadratic_form__automorphisms.py
+@@ -300,9 +300,9 @@ def automorphism_group(self):
+         sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1])
+         sage: Q.automorphism_group()
+         Matrix group over Rational Field with 3 generators (
+-        [-1  0  0]  [0 0 1]  [ 0  0  1]
+-        [ 0 -1  0]  [0 1 0]  [-1  0  0]
+-        [ 0  0 -1], [1 0 0], [ 0  1  0]
++        [ 0  0  1]  [1 0 0]  [ 1  0  0]
++        [-1  0  0]  [0 0 1]  [ 0 -1  0]
++        [ 0  1  0], [0 1 0], [ 0  0  1]
+         )
+ 
+     ::
+diff --git a/src/sage/rings/finite_rings/finite_field_prime_modn.py b/src/sage/rings/finite_rings/finite_field_prime_modn.py
+index 9129ecb56a..d5a4cb8f22 100644
+--- a/src/sage/rings/finite_rings/finite_field_prime_modn.py
++++ b/src/sage/rings/finite_rings/finite_field_prime_modn.py
+@@ -111,7 +111,7 @@ class FiniteField_prime_modn(FiniteField_generic, integer_mod_ring.IntegerModRin
+             sage: RF13 = K.residue_field(pp)
+             sage: RF13.hom([GF(13)(1)])
+             Ring morphism:
+-             From: Residue field of Fractional ideal (w + 18)
++             From: Residue field of Fractional ideal (-w - 18)
+              To:   Finite Field of size 13
+              Defn: 1 |--> 1
+ 
+diff --git a/src/sage/rings/finite_rings/residue_field.pyx b/src/sage/rings/finite_rings/residue_field.pyx
+index 7596f2a302..1e1869f1b1 100644
+--- a/src/sage/rings/finite_rings/residue_field.pyx
++++ b/src/sage/rings/finite_rings/residue_field.pyx
+@@ -20,13 +20,13 @@ monogenic (i.e., 2 is an essential discriminant divisor)::
+ 
+     sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8)
+     sage: F = K.factor(2); F
+-    (Fractional ideal (1/2*a^2 - 1/2*a + 1)) * (Fractional ideal (-a^2 + 2*a - 3)) * (Fractional ideal (-3/2*a^2 + 5/2*a - 4))
++    (Fractional ideal (-1/2*a^2 + 1/2*a - 1)) * (Fractional ideal (-a^2 + 2*a - 3)) * (Fractional ideal (3/2*a^2 - 5/2*a + 4))
+     sage: F[0][0].residue_field()
+-    Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++    Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+     sage: F[1][0].residue_field()
+     Residue field of Fractional ideal (-a^2 + 2*a - 3)
+     sage: F[2][0].residue_field()
+-    Residue field of Fractional ideal (-3/2*a^2 + 5/2*a - 4)
++    Residue field of Fractional ideal (3/2*a^2 - 5/2*a + 4)
+ 
+ We can also form residue fields from `\ZZ`::
+ 
+@@ -258,9 +258,9 @@ class ResidueFieldFactory(UniqueFactory):
+     the index of ``ZZ[a]`` in the maximal order for all ``a``::
+ 
+         sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8); P = K.ideal(2).factor()[0][0]; P
+-        Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F = K.residue_field(P); F
+-        Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F(a)
+         0
+         sage: B = K.maximal_order().basis(); B
+@@ -270,7 +270,7 @@ class ResidueFieldFactory(UniqueFactory):
+         sage: F(B[2])
+         0
+         sage: F
+-        Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F.degree()
+         1
+ 
+@@ -730,15 +730,15 @@ class ResidueField_generic(Field):
+         EXAMPLES::
+ 
+             sage: I = QQ[3^(1/3)].factor(5)[1][0]; I
+-            Fractional ideal (-a + 2)
++            Fractional ideal (a - 2)
+             sage: k = I.residue_field(); k
+-            Residue field of Fractional ideal (-a + 2)
++            Residue field of Fractional ideal (a - 2)
+             sage: f = k.lift_map(); f
+             Lifting map:
+-              From: Residue field of Fractional ideal (-a + 2)
++              From: Residue field of Fractional ideal (a - 2)
+               To:   Maximal Order in Number Field in a with defining polynomial x^3 - 3 with a = 1.442249570307409?
+             sage: f.domain()
+-            Residue field of Fractional ideal (-a + 2)
++            Residue field of Fractional ideal (a - 2)
+             sage: f.codomain()
+             Maximal Order in Number Field in a with defining polynomial x^3 - 3 with a = 1.442249570307409?
+             sage: f(k.0)
+@@ -768,7 +768,7 @@ class ResidueField_generic(Field):
+ 
+             sage: K.<a> = NumberField(x^3-11)
+             sage: F = K.ideal(37).factor(); F
+-            (Fractional ideal (37, a + 9)) * (Fractional ideal (37, a + 12)) * (Fractional ideal (2*a - 5))
++            (Fractional ideal (37, a + 9)) * (Fractional ideal (37, a + 12)) * (Fractional ideal (-2*a + 5))
+             sage: k = K.residue_field(F[0][0])
+             sage: l = K.residue_field(F[1][0])
+             sage: k == l
+@@ -846,7 +846,7 @@ cdef class ReductionMap(Map):
+             sage: F.reduction_map()
+             Partially defined reduction map:
+               From: Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
+-              To:   Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++              To:   Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+ 
+             sage: K.<theta_5> = CyclotomicField(5)
+             sage: F = K.factor(7)[0][0].residue_field()
+diff --git a/src/sage/rings/number_field/S_unit_solver.py b/src/sage/rings/number_field/S_unit_solver.py
+index e99dff850f..759cbfb334 100644
+--- a/src/sage/rings/number_field/S_unit_solver.py
++++ b/src/sage/rings/number_field/S_unit_solver.py
+@@ -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 (xi - 3),
+-         Fractional ideal (-2*xi^2 + 3),
++        (Fractional ideal (-2*xi^2 + 3),
++         Fractional ideal (-xi + 3),
+          Fractional ideal (2*xi + 1))
+ 
+         sage: sieve_data[1]
+-        (Residue field of Fractional ideal (xi - 3),
+-         Residue field of Fractional ideal (-2*xi^2 + 3),
++        (Residue field of Fractional ideal (-2*xi^2 + 3),
++         Residue field of Fractional ideal (-xi + 3),
+          Residue field of Fractional ideal (2*xi + 1))
+ 
+         sage: sieve_data[2]
+-        ([18, 7, 16, 4], [18, 9, 12, 8], [18, 3, 10, 10])
++        ([18, 12, 16, 8], [18, 16, 10, 4], [18, 10, 12, 10])
+ 
+         sage: sieve_data[3]
+-        (486, 648, 11664)
++        (648, 2916, 3888)
+     """
+ 
+     K = SUK.number_field()
+diff --git a/src/sage/rings/number_field/bdd_height.py b/src/sage/rings/number_field/bdd_height.py
+index beb047ae02..b7c8c33d0b 100644
+--- a/src/sage/rings/number_field/bdd_height.py
++++ b/src/sage/rings/number_field/bdd_height.py
+@@ -248,7 +248,7 @@ def bdd_norm_pr_ideal_gens(K, norm_list):
+         sage: from sage.rings.number_field.bdd_height import bdd_norm_pr_ideal_gens
+         sage: K.<g> = QuadraticField(123)
+         sage: bdd_norm_pr_ideal_gens(K, range(5))
+-        {0: [0], 1: [1], 2: [-g - 11], 3: [], 4: [2]}
++        {0: [0], 1: [1], 2: [g + 11], 3: [], 4: [2]}
+ 
+     ::
+ 
+diff --git a/src/sage/rings/number_field/class_group.py b/src/sage/rings/number_field/class_group.py
+index 018ff5f5c6..73c0462cd1 100644
+--- a/src/sage/rings/number_field/class_group.py
++++ b/src/sage/rings/number_field/class_group.py
+@@ -221,11 +221,11 @@ class FractionalIdealClass(AbelianGroupWithValuesElement):
+             Class group of order 76 with structure C38 x C2
+             of Number Field in a with defining polynomial x^2 + 20072
+             sage: I = (G.0)^11; I
+-            Fractional ideal class (41, 1/2*a + 5)
++            Fractional ideal class (33, 1/2*a + 8)
+             sage: J = G(I.ideal()^5); J
+-            Fractional ideal class (115856201, 1/2*a + 40407883)
++            Fractional ideal class (39135393, 1/2*a + 13654253)
+             sage: J.reduce()
+-            Fractional ideal class (57, 1/2*a + 44)
++            Fractional ideal class (73, 1/2*a + 47)
+             sage: J == I^5
+             True
+         """
+diff --git a/src/sage/rings/number_field/galois_group.py b/src/sage/rings/number_field/galois_group.py
+index 79acd053bb..e060148e4d 100644
+--- a/src/sage/rings/number_field/galois_group.py
++++ b/src/sage/rings/number_field/galois_group.py
+@@ -944,7 +944,7 @@ class GaloisGroup_v2(GaloisGroup_perm):
+             sage: K.<b> = NumberField(x^4 - 2*x^2 + 2, 'a').galois_closure()
+             sage: G = K.galois_group()
+             sage: [G.artin_symbol(P) for P in K.primes_above(7)]
+-            [(1,5)(2,6)(3,7)(4,8), (1,5)(2,6)(3,7)(4,8), (1,4)(2,3)(5,8)(6,7), (1,4)(2,3)(5,8)(6,7)]
++            [(1,4)(2,3)(5,8)(6,7), (1,4)(2,3)(5,8)(6,7), (1,5)(2,6)(3,7)(4,8), (1,5)(2,6)(3,7)(4,8)]
+             sage: G.artin_symbol(17)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
+index 58463d570d..ff65634e99 100644
+--- a/src/sage/rings/number_field/number_field.py
++++ b/src/sage/rings/number_field/number_field.py
+@@ -3643,7 +3643,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
+ 
+@@ -4227,7 +4227,8 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             (y^2 + 6, Mod(1/6*y, y^2 + 6), Mod(6*y, y^2 + 1/6))
+         """
+         f = self.absolute_polynomial()._pari_with_name('y')
+-        if f.pollead() == f.content().denominator() == 1:
++        f = f * f.content().denominator()
++        if f.pollead() == 1:
+             g = f
+             alpha = beta = g.variable().Mod(g)
+         else:
+@@ -4821,7 +4822,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+ 
+             sage: K.<a> = NumberField(2*x^2 - 1/3)
+             sage: K._S_class_group_and_units(tuple(K.primes_above(2) + K.primes_above(3)))
+-            ([-6*a + 2, 6*a + 3, -1, 12*a + 5], [])
++            ([6*a + 2, 6*a + 3, -1, -12*a + 5], [])
+         """
+         K_pari = self.pari_bnf(proof=proof)
+         S_pari = [p.pari_prime() for p in sorted(set(S))]
+@@ -5166,7 +5167,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+ 
+             sage: [K.ideal(g).factor() for g in gens]
+             [(Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1)),
+-            Fractional ideal (-a),
++            Fractional ideal (a),
+             (Fractional ideal (2, a + 1))^2,
+             1]
+ 
+@@ -5751,7 +5752,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: K.elements_of_norm(3)
+             []
+             sage: K.elements_of_norm(50)
+-            [-7*a + 1, 5*a - 5, 7*a + 1]
++            [-a - 7, 5*a - 5, 7*a + 1]
+ 
+         TESTS:
+ 
+@@ -5863,7 +5864,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: K.factor(1+a)
+             Fractional ideal (a + 1)
+             sage: K.factor(1+a/5)
+-            (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1 * (Fractional ideal (-3*a - 2))
++            (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1 * (Fractional ideal (-2*a + 3))
+ 
+         An example over a relative number field::
+ 
+@@ -6460,9 +6461,9 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: new_basis = k.reduced_basis(prec=120)
+             sage: [c.minpoly() for c in new_basis]
+             [x - 1,
+-             x^2 - x + 1,
++             x^2 + x + 1,
++             x^6 + 3*x^5 - 102*x^4 - 103*x^3 + 10572*x^2 - 59919*x + 127657,
+              x^6 + 3*x^5 - 102*x^4 - 103*x^3 + 10572*x^2 - 59919*x + 127657,
+-             x^6 - 3*x^5 - 102*x^4 + 315*x^3 + 10254*x^2 - 80955*x + 198147,
+              x^3 - 171*x + 848,
+              x^6 + 171*x^4 + 1696*x^3 + 29241*x^2 + 145008*x + 719104]
+             sage: R = k.order(new_basis)
+@@ -7058,7 +7059,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+              -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)
++             2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7)
+ 
+         TESTS:
+ 
+@@ -7067,7 +7068,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)
+ 
+@@ -7146,7 +7147,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^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]
++            [-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, 2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7]
+         """
+         proof = proof_flag(proof)
+ 
+diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx
+index 784c239dc1..aa740069dc 100644
+--- a/src/sage/rings/number_field/number_field_element.pyx
++++ b/src/sage/rings/number_field/number_field_element.pyx
+@@ -4446,7 +4446,7 @@ cdef class NumberFieldElement(FieldElement):
+             sage: f = Qi.embeddings(K)[0]
+             sage: a = f(2+3*i) * (2-zeta)^2
+             sage: a.descend_mod_power(Qi,2)
+-            [-3*i - 2, -2*i + 3]
++            [-2*i + 3, 3*i + 2]
+ 
+         An absolute example::
+ 
+@@ -5124,7 +5124,7 @@ cdef class NumberFieldElement_relative(NumberFieldElement):
+         EXAMPLES::
+ 
+             sage: K.<a, b, c> = NumberField([x^2 - 2, x^2 - 3, x^2 - 5])
+-            sage: P = K.prime_factors(5)[0]
++            sage: P = K.prime_factors(5)[1]
+             sage: (2*a + b - c).valuation(P)
+             1
+         """
+diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
+index 5f587556a4..33481fead0 100644
+--- a/src/sage/rings/number_field/number_field_ideal.py
++++ b/src/sage/rings/number_field/number_field_ideal.py
+@@ -3355,7 +3355,7 @@ def quotient_char_p(I, p):
+         []
+ 
+         sage: I = K.factor(13)[0][0]; I
+-        Fractional ideal (-3*i - 2)
++        Fractional ideal (-2*i + 3)
+         sage: I.residue_class_degree()
+         1
+         sage: quotient_char_p(I, 13)[0]
+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 bae36d4b9c..f64bd5b761 100644
+--- a/src/sage/rings/number_field/number_field_ideal_rel.py
++++ b/src/sage/rings/number_field/number_field_ideal_rel.py
+@@ -272,7 +272,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.gens_reduced()
+-            (2, 15*a*b + 3*a + 1)
++            (2, -15*a*b + 3*a + 1)
+         """
+         try:
+             # Compute the single generator, if it exists
+@@ -401,7 +401,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.relative_norm()
+-            Fractional ideal (-6*a + 2)
++            Fractional ideal (6*a + 2)
+         """
+         L = self.number_field()
+         K = L.base_field()
+@@ -518,7 +518,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.ideal_below()
+-            Fractional ideal (-6*a + 2)
++            Fractional ideal (6*a + 2)
+         """
+         L = self.number_field()
+         K = L.base_field()
+diff --git a/src/sage/rings/number_field/number_field_rel.py b/src/sage/rings/number_field/number_field_rel.py
+index d33980c4b1..50e846b205 100644
+--- a/src/sage/rings/number_field/number_field_rel.py
++++ b/src/sage/rings/number_field/number_field_rel.py
+@@ -213,14 +213,14 @@ class NumberField_relative(NumberField_generic):
+             sage: l.<b> = k.extension(5*x^2 + 3); l
+             Number Field in b with defining polynomial 5*x^2 + 3 over its base field
+             sage: l.pari_rnf()
+-            [x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4), ..., y^4 + 6*y^2 + 1, x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4)], [0, 0]]
++            [x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4), ..., y^4 + 6*y^2 + 1, x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4)], [0, 0]]
+             sage: b
+             b
+ 
+             sage: l.<b> = k.extension(x^2 + 3/5); l
+             Number Field in b with defining polynomial x^2 + 3/5 over its base field
+             sage: l.pari_rnf()
+-            [x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4), ..., y^4 + 6*y^2 + 1, x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4)], [0, 0]]
++            [x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4), ..., y^4 + 6*y^2 + 1, x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4)], [0, 0]]
+             sage: b
+             b
+ 
+diff --git a/src/sage/rings/number_field/order.py b/src/sage/rings/number_field/order.py
+index 6eca89ed8d..78ef4c3b33 100644
+--- a/src/sage/rings/number_field/order.py
++++ b/src/sage/rings/number_field/order.py
+@@ -520,7 +520,7 @@ class Order(IntegralDomain, sage.rings.abc.Order):
+             sage: k.<a> = NumberField(x^2 + 5077); G = k.class_group(); G
+             Class group of order 22 with structure C22 of Number Field in a with defining polynomial x^2 + 5077
+             sage: G.0 ^ -9
+-            Fractional ideal class (11, a + 7)
++            Fractional ideal class (43, a + 13)
+             sage: Ok = k.maximal_order(); Ok
+             Maximal Order in Number Field in a with defining polynomial x^2 + 5077
+             sage: Ok * (11, a + 7)
+diff --git a/src/sage/rings/number_field/selmer_group.py b/src/sage/rings/number_field/selmer_group.py
+index c534aaa9f6..6bc67565d2 100644
+--- a/src/sage/rings/number_field/selmer_group.py
++++ b/src/sage/rings/number_field/selmer_group.py
+@@ -491,7 +491,7 @@ def pSelmerGroup(K, S, p, proof=None, debug=False):
+ 
+         sage: [K.ideal(g).factor() for g in gens]
+         [(Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1)),
+-        Fractional ideal (-a),
++        Fractional ideal (a),
+         (Fractional ideal (2, a + 1))^2,
+         1]
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
+index bb5d8356be..8a7e5fa66f 100644
+--- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
++++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
+@@ -1791,7 +1791,7 @@ class PolynomialQuotientRing_generic(CommutativeRing):
+             sage: D.selmer_generators([K.ideal(2, -a+1), K.ideal(3, a+1)], 3)
+             [2, a + 1]
+             sage: D.selmer_generators([K.ideal(2, -a+1), K.ideal(3, a+1), K.ideal(a)], 3)
+-            [2, a + 1, a]
++            [2, a + 1, -a]
+ 
+         """
+         fields, isos, iso_classes = self._S_decomposition(tuple(S))
+diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py
+index 704b77ce5f..83ee4549e4 100644
+--- a/src/sage/rings/qqbar.py
++++ b/src/sage/rings/qqbar.py
+@@ -312,8 +312,8 @@ and we get a way to produce the number directly::
+     True
+     sage: sage_input(n)
+     R.<y> = QQ[]
+-    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(RR(0.51763809020504148), RR(0.51763809020504159)))
+-    -109*v^3 - 89*v^2 + 327*v + 178
++    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(-RR(1.9318516525781366), -RR(1.9318516525781364)))
++    -109*v^3 + 89*v^2 + 327*v - 178
+ 
+ We can also see that some computations (basically, those which are
+ easy to perform exactly) are performed directly, instead of storing
+@@ -362,7 +362,7 @@ algorithms in :trac:`10255`::
+     # Verified
+     R1.<x> = QQbar[]
+     R2.<y> = QQ[]
+-    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(RR(0.51763809020504148), RR(0.51763809020504159)))
++    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(-RR(1.9318516525781366), -RR(1.9318516525781364)))
+     AA.polynomial_root(AA.common_polynomial(x^4 + QQbar(v^3 - 3*v - 1)*x^3 + QQbar(-v^3 + 3*v - 3)*x^2 + QQbar(-3*v^3 + 9*v + 3)*x + QQbar(3*v^3 - 9*v)), RIF(RR(0.99999999999999989), RR(1.0000000000000002)))
+     sage: one
+     1
+@@ -2310,7 +2310,7 @@ def do_polred(poly, threshold=32):
+     cost = 2 * bitsize.nbits() + 5 * poly.degree().nbits()
+     if cost > threshold:
+         return parent.gen(), parent.gen(), poly
+-    new_poly, elt_back = poly.__pari__().polredbest(flag=1)
++    new_poly, elt_back = poly.numerator().__pari__().polredbest(flag=1)
+     elt_fwd = elt_back.modreverse()
+     return parent(elt_fwd.lift()), parent(elt_back.lift()), parent(new_poly)
+ 
+@@ -2542,10 +2542,10 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+            Defn: a |--> 1.414213562373095?)
+ 
+         sage: number_field_elements_from_algebraics((rt2,rt3))
+-        (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, [-a^3 + 3*a, -a^2 + 2], Ring morphism:
++        (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, [-a^3 + 3*a, a^2 - 2], Ring morphism:
+             From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+             To:   Algebraic Real Field
+-            Defn: a |--> 0.5176380902050415?)
++            Defn: a |--> -1.931851652578137?)
+ 
+     ``rt3a`` is a real number in ``QQbar``.  Ordinarily, we'd get a homomorphism
+     to ``AA`` (because all elements are real), but if we specify ``same_field=True``,
+@@ -2570,7 +2570,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, -a^3 + 3*a, Ring morphism:
+             From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+             To:   Algebraic Real Field
+-            Defn: a |--> 0.5176380902050415?)
++            Defn: a |--> -1.931851652578137?)
+ 
+     We can specify ``minimal=True`` if we want the smallest number field::
+ 
+@@ -2618,7 +2618,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         sage: nfI^2
+         -1
+         sage: sum = nfrt2 + nfrt3 + nfI + nfz3; sum
+-        2*a^6 + a^5 - a^4 - a^3 - 2*a^2 - a
++        a^5 + a^4 - a^3 + 2*a^2 - a - 1
+         sage: hom(sum)
+         2.646264369941973? + 1.866025403784439?*I
+         sage: hom(sum) == rt2 + rt3 + qqI + z3
+@@ -2658,7 +2658,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         sage: nf, nums, hom = number_field_elements_from_algebraics(elems, embedded=True)
+         sage: nf
+         Number Field in a with defining polynomial y^24 - 6*y^23 ...- 9*y^2 + 1
+-          with a = 0.2598678911433438? + 0.0572892247058457?*I
++          with a = 0.2598679? + 0.0572892?*I
+         sage: list(map(QQbar, nums)) == elems == list(map(hom, nums))
+         True
+ 
+@@ -2725,7 +2725,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+                          sqrt(2), AA.polynomial_root(x^3-3, RIF(0,3)), 11/9, 1]
+         sage: res = number_field_elements_from_algebraics(my_nums, embedded=True)
+         sage: res[0]
+-        Number Field in a with defining polynomial y^24 - 107010*y^22 - 24*y^21 + ... + 250678447193040618624307096815048024318853254384 with a = -95.5053039433554?
++        Number Field in a with defining polynomial y^24 - 107010*y^22 - 24*y^21 + ... + 250678447193040618624307096815048024318853254384 with a = 93.32530798172420?
+     """
+     gen = qq_generator
+ 
+@@ -3129,7 +3129,7 @@ class AlgebraicGenerator(SageObject):
+             sage: root = ANRoot(x^2 - x - 1, RIF(1, 2))
+             sage: gen = AlgebraicGenerator(nf, root)
+             sage: gen.pari_field()
+-             [y^2 - y - 1, [2, 0], ...]
++            [[y^2 - y - 1, [2, 0], ...]
+         """
+         if self.is_trivial():
+             raise ValueError("No PARI field attached to trivial generator")
+@@ -3213,7 +3213,7 @@ class AlgebraicGenerator(SageObject):
+             sage: qq_generator.union(gen3) is gen3
+             True
+             sage: gen2.union(gen3)
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+         """
+         if self._trivial:
+             return other
+@@ -3306,13 +3306,13 @@ class AlgebraicGenerator(SageObject):
+             Number Field in a with defining polynomial y^2 - 3 with a in 1.732050807568878?
+             sage: gen2_3 = gen2.union(gen3)
+             sage: gen2_3
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+             sage: qq_generator.super_poly(gen2) is None
+             True
+             sage: gen2.super_poly(gen2_3)
+             -a^3 + 3*a
+             sage: gen3.super_poly(gen2_3)
+-            -a^2 + 2
++            a^2 - 2
+ 
+         """
+         if checked is None:
+@@ -3360,13 +3360,13 @@ class AlgebraicGenerator(SageObject):
+             sage: sqrt3 = ANExtensionElement(gen3, nf3.gen())
+             sage: gen2_3 = gen2.union(gen3)
+             sage: gen2_3
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+             sage: gen2_3(sqrt2)
+             -a^3 + 3*a
+             sage: gen2_3(ANRational(1/7))
+             1/7
+             sage: gen2_3(sqrt3)
+-            -a^2 + 2
++            a^2 - 2
+         """
+         if self._trivial:
+             return elt._value
+@@ -4336,10 +4336,10 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: rt3 = AA(sqrt(3))
+             sage: rt3b = rt2 + rt3 - rt2
+             sage: rt3b.as_number_field_element()
+-            (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, -a^2 + 2, Ring morphism:
++            (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, a^2 - 2, Ring morphism:
+                 From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+                 To:   Algebraic Real Field
+-                Defn: a |--> 0.5176380902050415?)
++                Defn: a |--> -1.931851652578137?)
+             sage: rt3b.as_number_field_element(minimal=True)
+             (Number Field in a with defining polynomial y^2 - 3, a, Ring morphism:
+                From: Number Field in a with defining polynomial y^2 - 3
+@@ -4401,7 +4401,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: rt2b = rt3 + rt2 - rt3
+             sage: rt2b.exactify()
+             sage: rt2b._exact_value()
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b.simplify()
+             sage: rt2b._exact_value()
+             a where a^2 - 2 = 0 and a in 1.414213562373095?
+@@ -4422,7 +4422,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: QQbar(2)._exact_field()
+             Trivial generator
+             sage: (sqrt(QQbar(2)) + sqrt(QQbar(19)))._exact_field()
+-            Number Field in a with defining polynomial y^4 - 20*y^2 + 81 with a in 2.375100220297941?
++            Number Field in a with defining polynomial y^4 - 20*y^2 + 81 with a in -3.789313782671036?
+             sage: (QQbar(7)^(3/5))._exact_field()
+             Number Field in a with defining polynomial y^5 - 2*y^4 - 18*y^3 + 38*y^2 + 82*y - 181 with a in 2.554256611698490?
+         """
+@@ -4442,7 +4442,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: QQbar(2)._exact_value()
+             2
+             sage: (sqrt(QQbar(2)) + sqrt(QQbar(19)))._exact_value()
+-            -1/9*a^3 - a^2 + 11/9*a + 10 where a^4 - 20*a^2 + 81 = 0 and a in 2.375100220297941?
++            -1/9*a^3 + a^2 + 11/9*a - 10 where a^4 - 20*a^2 + 81 = 0 and a in -3.789313782671036?
+             sage: (QQbar(7)^(3/5))._exact_value()
+             2*a^4 + 2*a^3 - 34*a^2 - 17*a + 150 where a^5 - 2*a^4 - 18*a^3 + 38*a^2 + 82*a - 181 = 0 and a in 2.554256611698490?
+         """
+@@ -6857,7 +6857,7 @@ class AlgebraicPolynomialTracker(SageObject):
+             sage: p = sqrt(AA(2)) * x^2 - sqrt(AA(3))
+             sage: cp = AA.common_polynomial(p)
+             sage: cp.generator()
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 1.931851652578137?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -0.5176380902050415?
+         """
+         self.exactify()
+         return self._gen
+@@ -7706,7 +7706,7 @@ class ANExtensionElement(ANDescr):
+ 
+             sage: rt2b.exactify()
+             sage: rt2b._descr
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b._descr.is_simple()
+             False
+         """
+@@ -7791,7 +7791,7 @@ class ANExtensionElement(ANDescr):
+             sage: rt2b = rt3 + rt2 - rt3
+             sage: rt2b.exactify()
+             sage: rt2b._descr
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b._descr.simplify(rt2b)
+             a where a^2 - 2 = 0 and a in 1.414213562373095?
+         """
+@@ -7830,9 +7830,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.neg(a)
+-            1/3*a^3 - 2/3*a^2 + 4/3*a - 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -1/3*a^3 + 1/3*a^2 - a - 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+             sage: b.neg("ham spam and eggs")
+-            1/3*a^3 - 2/3*a^2 + 4/3*a - 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -1/3*a^3 + 1/3*a^2 - a - 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+         """
+         return ANExtensionElement(self._generator, -self._value)
+ 
+@@ -7848,9 +7848,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.invert(a)
+-            7/3*a^3 - 2/3*a^2 + 4/3*a - 12 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -7/3*a^3 + 19/3*a^2 - 7*a - 9 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+             sage: b.invert("ham spam and eggs")
+-            7/3*a^3 - 2/3*a^2 + 4/3*a - 12 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -7/3*a^3 + 19/3*a^2 - 7*a - 9 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+         """
+         return ANExtensionElement(self._generator, ~self._value)
+ 
+@@ -7866,9 +7866,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.conjugate(a)
+-            -1/3*a^3 + 2/3*a^2 - 4/3*a + 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? + 1.573132184970987?*I
++            1/3*a^3 - 1/3*a^2 + a + 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? - 1.573132184970987?*I
+             sage: b.conjugate("ham spam and eggs")
+-            -1/3*a^3 + 2/3*a^2 - 4/3*a + 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? + 1.573132184970987?*I
++            1/3*a^3 - 1/3*a^2 + a + 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? - 1.573132184970987?*I
+         """
+         if self._exactly_real:
+             return self
+@@ -8501,7 +8501,7 @@ def an_binop_expr(a, b, op):
+         sage: x = an_binop_expr(a, b, operator.add); x
+         <sage.rings.qqbar.ANBinaryExpr object at ...>
+         sage: x.exactify()
+-        -6/7*a^7 + 2/7*a^6 + 71/7*a^5 - 26/7*a^4 - 125/7*a^3 + 72/7*a^2 + 43/7*a - 47/7 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in 3.12580...?
++        6/7*a^7 - 2/7*a^6 - 71/7*a^5 + 26/7*a^4 + 125/7*a^3 - 72/7*a^2 - 43/7*a + 47/7 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in -0.3199179336182997?
+ 
+         sage: a = QQbar(sqrt(2)) + QQbar(sqrt(3))
+         sage: b = QQbar(sqrt(3)) + QQbar(sqrt(5))
+@@ -8510,7 +8510,7 @@ def an_binop_expr(a, b, op):
+         sage: x = an_binop_expr(a, b, operator.mul); x
+         <sage.rings.qqbar.ANBinaryExpr object at ...>
+         sage: x.exactify()
+-        2*a^7 - a^6 - 24*a^5 + 12*a^4 + 46*a^3 - 22*a^2 - 22*a + 9 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in 3.1258...?
++        2*a^7 - a^6 - 24*a^5 + 12*a^4 + 46*a^3 - 22*a^2 - 22*a + 9 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in -0.3199179336182997?
+     """
+     return ANBinaryExpr(a, b, op)
+ 
+diff --git a/src/sage/schemes/affine/affine_morphism.py b/src/sage/schemes/affine/affine_morphism.py
+index 1c4f2dff18..32c2e47e49 100644
+--- a/src/sage/schemes/affine/affine_morphism.py
++++ b/src/sage/schemes/affine/affine_morphism.py
+@@ -1148,9 +1148,9 @@ class SchemeMorphism_polynomial_affine_space_field(SchemeMorphism_polynomial_aff
+             sage: H = End(A)
+             sage: f = H([(QQbar(sqrt(2))*x^2 + 1/QQbar(sqrt(3))) / (5*x)])
+             sage: f.reduce_base_field()
+-            Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a = 1.931851652578137?
++            Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a = ...?
+               Defn: Defined on coordinates by sending (x) to
+-                    (((a^3 - 3*a)*x^2 + (1/3*a^2 - 2/3))/(5*x))
++                    (((a^3 - 3*a)*x^2 + (-1/3*a^2 + 2/3))/(5*x))
+ 
+         ::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_field.py b/src/sage/schemes/elliptic_curves/ell_field.py
+index 68b8375dae..48f358ea6a 100644
+--- a/src/sage/schemes/elliptic_curves/ell_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_field.py
+@@ -845,7 +845,7 @@ class EllipticCurve_field(ell_generic.EllipticCurve_generic, ProjectivePlaneCurv
+             sage: E = E.base_extend(G).quadratic_twist(c); E
+             Elliptic Curve defined by y^2 = x^3 + 5*a0*x^2 + (-200*a0^2)*x + (-42000*a0^2+42000*a0+126000) over Number Field in a0 with defining polynomial x^3 - 3*x^2 + 3*x + 9
+             sage: K.<b> = E.division_field(3, simplify_all=True); K
+-            Number Field in b with defining polynomial x^12 - 10*x^10 + 55*x^8 - 60*x^6 + 75*x^4 + 1350*x^2 + 2025
++            Number Field in b with defining polynomial x^12 + 5*x^10 + 40*x^8 + 315*x^6 + 750*x^4 + 675*x^2 + 2025
+ 
+         Some higher-degree examples::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_generic.py b/src/sage/schemes/elliptic_curves/ell_generic.py
+index 926ae310ea..3bae819fb0 100644
+--- a/src/sage/schemes/elliptic_curves/ell_generic.py
++++ b/src/sage/schemes/elliptic_curves/ell_generic.py
+@@ -3324,8 +3324,8 @@ 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),
++            [0, 0, 0, Mod(1, y^2 - 2),
++            Mod(y, y^2 - 2), 0, 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;
+diff --git a/src/sage/schemes/elliptic_curves/ell_number_field.py b/src/sage/schemes/elliptic_curves/ell_number_field.py
+index edbd196090..c44c803aa8 100644
+--- a/src/sage/schemes/elliptic_curves/ell_number_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_number_field.py
+@@ -218,7 +218,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: E == loads(dumps(E))
+             True
+             sage: E.simon_two_descent()
+-            (2, 2, [(0 : 0 : 1)])
++            (2, 2, [(0 : 0 : 1), (1/18*a + 7/18 : -5/54*a - 17/54 : 1)])
+             sage: E.simon_two_descent(lim1=5, lim3=5, limtriv=10, maxprob=7, limbigprime=10)
+             (2, 2, [(-1 : 0 : 1), (-2 : -1/2*a - 1/2 : 1)])
+ 
+@@ -274,7 +274,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: E.simon_two_descent()  # long time (4s on sage.math, 2013)
+             (3,
+              3,
+-             [(5/8*zeta43_0^2 + 17/8*zeta43_0 - 9/4 : -27/16*zeta43_0^2 - 103/16*zeta43_0 + 39/8 : 1),
++             [(1/8*zeta43_0^2 - 3/8*zeta43_0 - 1/4 : -5/16*zeta43_0^2 + 7/16*zeta43_0 + 1/8 : 1),
+               (0 : 0 : 1)])
+         """
+         verbose = int(verbose)
+@@ -865,7 +865,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             Conductor exponent: 1
+             Kodaira Symbol: I1
+             Tamagawa Number: 1,
+-            Local data at Fractional ideal (-3*i - 2):
++            Local data at Fractional ideal (-2*i + 3):
+             Reduction type: bad split multiplicative
+             Local minimal model: Elliptic Curve defined by y^2 + (i+1)*x*y + y = x^3 over Number Field in i with defining polynomial x^2 + 1
+             Minimal discriminant valuation: 2
+@@ -2645,12 +2645,12 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             [-92, -23, -23]
+ 
+             sage: C.matrix()  # long time
+-            [1 2 2 4 2 4]
+-            [2 1 2 2 4 4]
+-            [2 2 1 4 4 2]
+-            [4 2 4 1 3 3]
+-            [2 4 4 3 1 3]
+-            [4 4 2 3 3 1]
++            [1 2 2 4 4 2]
++            [2 1 2 4 2 4]
++            [2 2 1 2 4 4]
++            [4 4 2 1 3 3]
++            [4 2 4 3 1 3]
++            [2 4 4 3 3 1]
+ 
+         The graph of this isogeny class has a shape which does not
+         occur over `\QQ`: a triangular prism.  Note that for curves
+@@ -2677,12 +2677,12 @@ class EllipticCurve_number_field(EllipticCurve_field):
+ 
+             sage: G = C.graph()  # long time
+             sage: G.adjacency_matrix()  # long time
+-            [0 1 1 0 1 0]
+-            [1 0 1 1 0 0]
+-            [1 1 0 0 0 1]
+-            [0 1 0 0 1 1]
+-            [1 0 0 1 0 1]
+-            [0 0 1 1 1 0]
++            [0 1 1 0 0 1]
++            [1 0 1 0 1 0]
++            [1 1 0 1 0 0]
++            [0 0 1 0 1 1]
++            [0 1 0 1 0 1]
++            [1 0 0 1 1 0]
+ 
+         To display the graph without any edge labels::
+ 
+@@ -3316,7 +3316,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: points = [E.lift_x(x) for x in xi]
+             sage: newpoints, U = E.lll_reduce(points)  # long time (35s on sage.math, 2011)
+             sage: [P[0] for P in newpoints]            # long time
+-            [6823803569166584943, 5949539878899294213, 2005024558054813068, 5864879778877955778, 23955263915878682727/4, 5922188321411938518, 5286988283823825378, 175620639884534615751/25, -11451575907286171572, 3502708072571012181, 1500143935183238709184/225, 27180522378120223419/4, -5811874164190604461581/625, 26807786527159569093, 7404442636649562303, 475656155255883588, 265757454726766017891/49, 7272142121019825303, 50628679173833693415/4, 6951643522366348968, 6842515151518070703, 111593750389650846885/16, 2607467890531740394315/9, -1829928525835506297]
++            [6823803569166584943, 5949539878899294213, 2005024558054813068, 5864879778877955778, 23955263915878682727/4, 5922188321411938518, 5286988283823825378, 11465667352242779838, -11451575907286171572, 3502708072571012181, 1500143935183238709184/225, 27180522378120223419/4, -5811874164190604461581/625, 26807786527159569093, 7041412654828066743, 475656155255883588, 265757454726766017891/49, 7272142121019825303, 50628679173833693415/4, 6951643522366348968, 6842515151518070703, 111593750389650846885/16, 2607467890531740394315/9, -1829928525835506297]
+ 
+         An example to show the explicit use of the height pairing matrix::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_rational_field.py b/src/sage/schemes/elliptic_curves/ell_rational_field.py
+index 3808822812..a75290ea35 100644
+--- a/src/sage/schemes/elliptic_curves/ell_rational_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_rational_field.py
+@@ -1827,7 +1827,7 @@ class EllipticCurve_rational_field(EllipticCurve_number_field):
+             sage: E = EllipticCurve('389a1')
+             sage: E._known_points = []  # clear cached points
+             sage: E.simon_two_descent()
+-            (2, 2, [(1 : 0 : 1), (-11/9 : 28/27 : 1)])
++            (2, 2, [(5/4 : 5/8 : 1), (-3/4 : 7/8 : 1)])
+             sage: E = EllipticCurve('5077a1')
+             sage: E.simon_two_descent()
+             (3, 3, [(1 : 0 : 1), (2 : 0 : 1), (0 : 2 : 1)])
+diff --git a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
+index 81ad295160..d484a4a18b 100644
+--- a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
++++ b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
+@@ -780,12 +780,12 @@ def deg_one_primes_iter(K, principal_only=False):
+         [Fractional ideal (2, a + 1),
+          Fractional ideal (3, a + 1),
+          Fractional ideal (3, a + 2),
+-         Fractional ideal (-a),
++         Fractional ideal (a),
+          Fractional ideal (7, a + 3),
+          Fractional ideal (7, a + 4)]
+         sage: it = deg_one_primes_iter(K, True)
+         sage: [next(it) for _ in range(6)]
+-        [Fractional ideal (-a),
++        [Fractional ideal (a),
+          Fractional ideal (-2*a + 3),
+          Fractional ideal (2*a + 3),
+          Fractional ideal (a + 6),
+diff --git a/src/sage/schemes/elliptic_curves/gp_simon.py b/src/sage/schemes/elliptic_curves/gp_simon.py
+index 28b97f34af..9f7d1b6020 100644
+--- a/src/sage/schemes/elliptic_curves/gp_simon.py
++++ b/src/sage/schemes/elliptic_curves/gp_simon.py
+@@ -56,7 +56,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+         sage: import sage.schemes.elliptic_curves.gp_simon
+         sage: E=EllipticCurve('389a1')
+         sage: sage.schemes.elliptic_curves.gp_simon.simon_two_descent(E)
+-        (2, 2, [(1 : 0 : 1), (-11/9 : 28/27 : 1)])
++        (2, 2, [(5/4 : 5/8 : 1), (-3/4 : 7/8 : 1)])
+ 
+     TESTS::
+ 
+@@ -117,7 +117,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+     # The block below mimics the defaults in Simon's scripts, and needs to be changed
+     # when these are updated.
+     if K is QQ:
+-        cmd = 'ellrank(%s, %s);' % (list(E.ainvs()), [P.__pari__() for P in known_points])
++        cmd = 'ellQ_ellrank(%s, %s);' % (list(E.ainvs()), [P.__pari__() for P in known_points])
+         if lim1 is None:
+             lim1 = 5
+         if lim3 is None:
+@@ -144,7 +144,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+     if verbose > 0:
+         print(s)
+     v = gp.eval('ans')
+-    if v=='ans': # then the call to ellrank() or bnfellrank() failed
++    if v=='ans': # then the call to ellQ_ellrank() or bnfellrank() failed
+         raise RuntimeError("An error occurred while running Simon's 2-descent program")
+     if verbose >= 2:
+         print("v = %s" % v)
+diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
+index a936deb74f..dc19254d8c 100644
+--- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
++++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
+@@ -1208,14 +1208,14 @@ def isogenies_13_0(E, minimal_models=True):
+         sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]  # long time (4s)
+         [(0,
+           0,
+-          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
++          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 + 1887439/1146978983704320*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 + 1030632647/7965131831280*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 - 43618899433/204234149520*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 2535050171/1418292705,
+           -139861295/2650795873449984*a^11 - 3455957/5664093746688*a^10 - 345310571/50976843720192*a^9 - 500530795/118001953056*a^8 - 12860048113/265504394376*a^7 - 25007420461/44250732396*a^6 + 458134176455/1416023436672*a^5 + 16701880631/9077073312*a^4 + 155941666417/9077073312*a^3 + 3499310115/378211388*a^2 - 736774863/94552847*a - 21954102381/94552847,
+-          579363345221/13763747804451840*a^11 + 371192377511/860234237778240*a^10 + 8855090365657/1146978983704320*a^9 + 5367261541663/1633873196160*a^8 + 614883554332193/15930263662560*a^7 + 30485197378483/68078049840*a^6 - 131000897588387/2450809794240*a^5 - 203628705777949/306351224280*a^4 - 1587619388190379/204234149520*a^3 + 14435069706551/11346341640*a^2 + 7537273048614/472764235*a + 89198980034806/472764235),
++          8342795944891/198197968384106496*a^11 + 8908625263589/20645621706677760*a^10 + 53130542636623/6881873902225920*a^9 + 376780111042213/114697898370432*a^8 + 614884052146333/15930263662560*a^7 + 3566768133324359/7965131831280*a^6 - 1885593809102545/35291661037056*a^5 - 2443732172026523/3676214691360*a^4 - 9525729503937541/1225404897120*a^3 + 51990274442321/40846829904*a^2 + 67834019370596/4254878115*a + 267603083706812/1418292705),
+          (0,
+           0,
+-          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
++          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 + 1887439/1146978983704320*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 + 1030632647/7965131831280*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 - 43618899433/204234149520*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 2535050171/1418292705,
+           -6465569317/1325397936724992*a^11 - 112132307/1960647835392*a^10 - 17075412917/25488421860096*a^9 - 207832519229/531008788752*a^8 - 1218275067617/265504394376*a^7 - 9513766502551/177002929584*a^6 + 4297077855437/708011718336*a^5 + 354485975837/4538536656*a^4 + 4199379308059/4538536656*a^3 - 30841577919/189105694*a^2 - 181916484042/94552847*a - 2135779171614/94552847,
+-          -132601797212627/3440936951112960*a^11 - 6212467020502021/13763747804451840*a^10 - 1515926454902497/286744745926080*a^9 - 15154913741799637/4901619588480*a^8 - 576888119803859263/15930263662560*a^7 - 86626751639648671/204234149520*a^6 + 16436657569218427/306351224280*a^5 + 1540027900265659087/2450809794240*a^4 + 375782662805915809/51058537380*a^3 - 14831920924677883/11346341640*a^2 - 7237947774817724/472764235*a - 84773764066089509/472764235)]
++          -1316873026840277/34172063514501120*a^11 - 18637401045099413/41291243413355520*a^10 - 36382234917217247/6881873902225920*a^9 - 61142238484016213/19775499719040*a^8 - 576888119306045123/15930263662560*a^7 - 3378443313906256321/7965131831280*a^6 + 326466167429333279/6084769144320*a^5 + 4620083325391594991/7352429382720*a^4 + 9018783894167184149/1225404897120*a^3 - 9206015742300283/7042556880*a^2 - 65141531411426446/4254878115*a - 254321286054666133/1418292705)]
+     """
+     if E.j_invariant()!=0:
+         raise ValueError("j-invariant must be 0.")
diff --git a/srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch b/srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch
new file mode 100644
index 000000000000..762bb2612632
--- /dev/null
+++ b/srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch
@@ -0,0 +1,29 @@
+From f0365f30834b6890313790b3845c647d0160fa6a Mon Sep 17 00:00:00 2001
+From: Vincent Delecroix <20100.delecroix@gmail.com*>
+Date: Fri, 30 Sep 2022 16:31:08 +0200
+Subject: fix doctest if fqf_orthogonal
+
+---
+ src/sage/groups/fqf_orthogonal.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/sage/groups/fqf_orthogonal.py b/src/sage/groups/fqf_orthogonal.py
+index 75de408..7fc4dbe 100644
+--- a/src/sage/groups/fqf_orthogonal.py
++++ b/src/sage/groups/fqf_orthogonal.py
+@@ -245,10 +245,10 @@ class FqfOrthogonalGroup(AbelianGroupAutomorphismGroup_subgroup):
+             sage: all(x*f==x*fbar for x in q.gens())
+             True
+             sage: L = IntegralLattice("A2").twist(3)
+-            sage: q = L.discriminant_group()
+             sage: OL = L.orthogonal_group()
++            sage: assert OL(OL.0.matrix()) == OL.0
++            sage: q = L.discriminant_group()
+             sage: Oq = q.orthogonal_group()
+-            sage: assert Oq(OL.0) == Oq(OL.0.matrix())
+             sage: assert Oq(Oq.0.matrix()) == Oq.0
+         """
+         from sage.libs.gap.element import GapElement
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch b/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
deleted file mode 100644
index 4bd6f4f4e2dc..000000000000
--- a/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
+++ /dev/null
@@ -1,670 +0,0 @@
-As produced by `git diff 9.5 9.6.beta3 -- src/sage/libs/lrcalc`
-
-diff --git a/src/sage/libs/lrcalc/lrcalc.pxd b/src/sage/libs/lrcalc/lrcalc.pxd
-deleted file mode 100644
-index 10b88db93f2..00000000000
---- a/src/sage/libs/lrcalc/lrcalc.pxd
-+++ /dev/null
-@@ -1,77 +0,0 @@
--# distutils: libraries = lrcalc
--
--cdef extern from "lrcalc/hashtab.h":
--    ctypedef struct hashtab:
--        pass
--
--    ctypedef struct hash_itr:
--        pass
--
--    ctypedef unsigned long hashkey_t
--    ctypedef int (*cmp_t) (void* a, void* b)
--    ctypedef hashkey_t (*hash_t) (void* a)
--
--    hashtab* hash_new(cmp_t cm, hash_t hsh)
--    void hash_free(hashtab *ht)
--
--    void* hash_lookup(hashtab *ht, void *key)
--    void* hash_insert(hashtab *ht, void *key, void *value)
--
--    bint hash_good(hash_itr)
--    void hash_first(hashtab* s, hash_itr itr)
--    void hash_next(hash_itr itr)
--    void* hash_key(hash_itr itr)
--    void* hash_value(hash_itr itr)
--    int hash_intvalue(hash_itr itr)
--
--cdef extern from "lrcalc/vector.h":
--    ctypedef struct vector:
--        size_t length
--        int* array
--
--    vector* v_new(int length)
--    void v_free(vector* v)
--    void v_print(vector *v)
--    int v_length(vector* v)
--    int v_elem(vector* v, int i)
--
--    ctypedef struct vecpair:
--        vector *first
--        vector *second
--
--    vector* vp_first(vecpair* vp)
--    vector* vp_second(vecpair* vp)
--
--cdef extern from "lrcalc/list.h":
--    cdef struct _list:
--        void **array
--        size_t allocated
--        size_t length
--    void l_free(_list *lst)
--
--cdef extern from "lrcalc/symfcn.h":
--    long long lrcoef_c "lrcoef"(vector* outer, vector* inner1, vector* inner2)
--    hashtab* mult_c "mult"(vector *sh1, vector *sh2, int maxrows)
--    hashtab* skew_c "skew"(vector *outer, vector *inner, int maxrows)
--    hashtab* coprod_c "coprod"(vector *part, int all)
--    void fusion_reduce_c "fusion_reduce"(hashtab* ht, int rows, int cols, int opt_zero)
--    _list *quantum_reduce_c "quantum_reduce"(hashtab* ht, int rows, int col)
--
--    ctypedef struct skewtab:
--        vector *outer
--        vector *inner
--        vector *conts
--        int maxrows
--        vector *conjugate
--        int rows
--        int cols
--        int matrix[1]
--
--    skewtab *st_new(vector *outer, vector *inner, vector *conts, int maxrows)
--    int st_next(skewtab *st)
--    void st_print(skewtab *st)
--    void st_free(skewtab *st)
--
--
--cdef extern from "lrcalc/schublib.h":
--    hashtab* mult_schubert_c "mult_schubert"(vector *sh1, vector *sh2, int rank)
-diff --git a/src/sage/libs/lrcalc/lrcalc.pyx b/src/sage/libs/lrcalc/lrcalc.py
-similarity index 60%
-rename from src/sage/libs/lrcalc/lrcalc.pyx
-rename to src/sage/libs/lrcalc/lrcalc.py
-index b591081ec4c..b541bfacd89 100644
---- a/src/sage/libs/lrcalc/lrcalc.pyx
-+++ b/src/sage/libs/lrcalc/lrcalc.py
-@@ -10,7 +10,8 @@ fusion products. All of the above are achieved by counting LR
- appropriate shape and content by iterating through them.
- Additionally, ``lrcalc`` handles products of Schubert polynomials.
- 
--The web page of ``lrcalc`` is `<http://sites.math.rutgers.edu/~asbuch/lrcalc/>`_.
-+The web page of ``lrcalc`` is
-+`<http://sites.math.rutgers.edu/~asbuch/lrcalc/>`_.
- 
- The following describes the Sage interface to this library.
- 
-@@ -36,12 +37,13 @@ Schur expansion::
-      [4, 2]: 1}
- 
- Same product, but include only partitions with at most 3 rows.  This
--corresponds to computing in the representation ring of gl(3)::
-+corresponds to computing in the representation ring of `\mathfrak{gl}(3)`::
- 
-     sage: lrcalc.mult([2,1], [2,1], 3)
-     {[2, 2, 2]: 1, [3, 2, 1]: 2, [3, 3]: 1, [4, 1, 1]: 1, [4, 2]: 1}
- 
--We can also compute the fusion product, here for sl(3) and level 2::
-+We can also compute the fusion product, here for `\mathfrak{sl}(3)`
-+and level 2::
- 
-     sage: lrcalc.mult([3,2,1], [3,2,1], 3,2)
-     {[4, 4, 4]: 1, [5, 4, 3]: 1}
-@@ -77,42 +79,38 @@ Multiply two Schubert polynomials::
-      [6, 2, 1, 4, 3, 5]: 1}
- 
- Same product, but include only permutations of 5 elements in the result.
--This corresponds to computing in the cohomology ring of Fl(5)::
-+This corresponds to computing in the cohomology ring of `Fl(5)`::
- 
-     sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3], 5)
-     {[4, 5, 1, 3, 2]: 1, [5, 3, 1, 4, 2]: 1, [5, 4, 1, 2, 3]: 1}
- 
- List all Littlewood-Richardson tableaux of skew shape `\mu/\nu`; in
- this example `\mu=[3,2,1]` and `\nu=[2,1]`. Specifying a third entry
--`maxrows` restricts the alphabet to `\{1,2,\ldots,maxrows\}`::
-+`M' = ``maxrows`` restricts the alphabet to `\{1,2,\ldots,M\}`::
- 
-     sage: list(lrcalc.lrskew([3,2,1],[2,1]))
-     [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
-     [[None, None, 1], [None, 2], [1]], [[None, None, 1], [None, 2], [3]]]
- 
-     sage: list(lrcalc.lrskew([3,2,1],[2,1],maxrows=2))
--    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]], [[None, None, 1], [None, 2], [1]]]
-+    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
-+     [[None, None, 1], [None, 2], [1]]]
- 
- .. TODO::
- 
--    use this library in the :class:`SymmetricFunctions` code, to
-+    Use this library in the :class:`SymmetricFunctions` code, to
-     make it easy to apply it to linear combinations of Schur functions.
- 
- .. SEEALSO::
- 
-     - :func:`lrcoef`
--
-     - :func:`mult`
--
-     - :func:`coprod`
--
-     - :func:`skew`
--
-     - :func:`lrskew`
--
-     - :func:`mult_schubert`
- 
--.. rubric:: Underlying algorithmic in lrcalc
-+.. RUBRIC:: Underlying algorithmic in lrcalc
- 
- Here is some additional information regarding the main low-level
- C-functions in `lrcalc`. Given two partitions ``outer`` and ``inner``
-@@ -187,180 +185,24 @@ AUTHORS:
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from sage.rings.integer cimport Integer
--from sage.structure.parent cimport Parent
- from sage.combinat.partition import _Partitions
- from sage.combinat.permutation import Permutation
--from sage.combinat.skew_tableau import SkewTableau
--
--
--cdef vector* iterable_to_vector(it):
--    """
--    Return an lrcalc vector (which is a list of integers) from a Python iterable.
--
--    TESTS::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector(Partition([3,2,1])); x   #indirect doctest
--        [3, 2, 1]
--    """
--    cdef vector* v
--    cdef list itr = list(it)
--    cdef int n = len(itr)
--    cdef int i
--    v = v_new(n)
--    for i in range(n):
--        v.array[i] = int(itr[i])
--    return v
--
--
--cdef list vector_to_list(vector *v):
--    """
--    Converts a lrcalc vector to Python list.
--
--    TESTS::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector([]); x         #indirect doctest
--        []
--    """
--    cdef int i, n
--    n = v_length(v)
--    cdef list result = [None]*n
--    for i in range(n):
--        result[i] = Integer(v_elem(v, i))
--    return result
--
--
--def test_iterable_to_vector(it):
--    """
--    A wrapper function for the cdef function ``iterable_to_vector``
--    and ``vector_to_list``, to test that they are working correctly.
-+from sage.combinat.skew_tableau import SemistandardSkewTableaux
-+from sage.combinat.skew_partition import SkewPartition
-+from sage.rings.integer import Integer
-+import lrcalc
- 
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector([3,2,1]); x
--        [3, 2, 1]
--    """
--    cdef vector *v = iterable_to_vector(it)
--    result = vector_to_list(v)
--    v_free(v)
--    return result
--
--
--cdef skewtab_to_SkewTableau(skewtab *st):
--    """
--    A wrapper function which transforms the data set ``st`` used in
--    ``lrcalc`` to a ``SkewTableau`` in Sage.
-+def _lrcalc_dict_to_sage(result):
-+    r"""
-+    Translate from lrcalc output format to Sage expected format.
- 
-     TESTS::
- 
--        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
--        sage: test_skewtab_to_SkewTableau([],[])
--        []
--    """
--    inner = vector_to_list(st.inner)
--    outer = vector_to_list(st.outer)
--    return SkewTableau(expr=[[inner[y] for y in range(len(outer))],
--                             [[st.matrix[x + y * st.cols] + 1
--                                for x in range(inner[y], outer[y])]
--                              for y in range(len(outer) - 1, -1, -1)]])
--
--
--def test_skewtab_to_SkewTableau(outer, inner):
--    """
--    A wrapper function for the cdef function ``skewtab_to_SkewTableau``
--    for testing purposes.
--
--    It constructs the first LR skew tableau of shape ``outer/inner``
--    as an ``lrcalc`` ``skewtab``, and converts it to a
--    :class:`SkewTableau`.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
--        sage: test_skewtab_to_SkewTableau([3,2,1],[])
--        [[1, 1, 1], [2, 2], [3]]
--        sage: test_skewtab_to_SkewTableau([4,3,2,1],[1,1]).pp()
--        .  1  1  1
--        .  2  2
--        1  3
--        2
--    """
--    cdef vector* o = iterable_to_vector(outer)
--    cdef vector* i = iterable_to_vector(inner+[0]*(len(outer)-len(inner)))
--    cdef skewtab* st = st_new(o, i, NULL, 0)
--    return skewtab_to_SkewTableau(st)
--
--
--cdef dict sf_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary representing a Schur function. The keys are
--    partitions and the values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
-         sage: from sage.libs.lrcalc.lrcalc import mult
--        sage: sorted(mult([1],[1]).items())        #indirect doctest
--        [([1, 1], 1), ([2], 1)]
--        sage: assert isinstance(mult([1],[1]),dict)#indirect doctest
--    """
--    cdef hash_itr itr
--    cdef dict result = {}
--    cdef list p
--    hash_first(ht, itr)
--    while hash_good(itr):
--        p = vector_to_list(<vector*> hash_key(itr))
--        result[_Partitions(p)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
--
--cdef dict schubert_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary corresponding to a Schubert polynomial whose keys
--    are permutations and whose values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import mult_schubert
--        sage: mult_schubert([3,2,1], [1,2,3])      #indirect doctest
--        {[3, 2, 1]: 1}
--    """
--    cdef hash_itr itr
--    cdef dict result = {}
--    hash_first(ht, itr)
--    while hash_good(itr):
--        p = vector_to_list(<vector*> hash_key(itr))
--        result[Permutation(p)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
--
--cdef dict vp_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary corresponding to the coproduct of a Schur function whose keys are
--    pairs of partitions and whose values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import coprod
--        sage: coprod([1])      #indirect doctest
--        {([1], []): 1}
-+        sage: mult([2,1],[3,2,1],3) # indirect doctest
-+        {[3, 3, 3]: 1, [4, 3, 2]: 2, [4, 4, 1]: 1, [5, 2, 2]: 1, [5, 3, 1]: 1}
-     """
--    cdef hash_itr itr
--    cdef vecpair* vp
--    cdef dict result = {}
--    hash_first(ht, itr)
--    while hash_good(itr):
--        vp = <vecpair*> hash_key(itr)
--        p1 = _Partitions(vector_to_list(vp_first(vp)))
--        p2 = _Partitions(vector_to_list(vp_second(vp)))
--        result[(p1, p2)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
-+    return {_Partitions(la): Integer(k) for la, k in result.items()}
- 
- def lrcoef_unsafe(outer, inner1, inner2):
-     r"""
-@@ -371,13 +213,11 @@ def lrcoef_unsafe(outer, inner1, inner2):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
--
--    - ``inner1`` -- a partition.
-+    - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
-+    - ``inner1`` -- a partition
-+    - ``inner2`` -- a partition
- 
--    - ``inner2`` -- a partition.
--
--    .. warning::
-+    .. WARNING::
- 
-        This function does not do any check on its input.  If you want
-        to use a safer version, use :func:`lrcoef`.
-@@ -392,18 +232,7 @@ def lrcoef_unsafe(outer, inner1, inner2):
-         sage: lrcoef_unsafe([2,1,1,1,1], [2,1], [2,1])
-         0
-     """
--    cdef long long result
--    cdef vector *o
--    cdef vector *i1
--    cdef vector *i2
--    o = iterable_to_vector(outer)
--    i1 = iterable_to_vector(inner1)
--    i2 = iterable_to_vector(inner2)
--    result = lrcoef_c(o, i1, i2)
--    v_free(o)
--    v_free(i1)
--    v_free(i2)
--    return Integer(result)
-+    return Integer(lrcalc.lrcoef(outer, inner1, inner2))
- 
- 
- def lrcoef(outer, inner1, inner2):
-@@ -415,11 +244,9 @@ def lrcoef(outer, inner1, inner2):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
--
--    - ``inner1`` -- a partition.
--
--    - ``inner2`` -- a partition.
-+    - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
-+    - ``inner1`` -- a partition
-+    - ``inner2`` -- a partition
- 
-     .. NOTE::
- 
-@@ -436,7 +263,6 @@ def lrcoef(outer, inner1, inner2):
-         1
-         sage: lrcoef([2,1,1,1,1], [2,1], [2,1])
-         0
--
-     """
-     return lrcoef_unsafe(_Partitions(outer), _Partitions(inner1), _Partitions(inner2))
- 
-@@ -451,13 +277,9 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-     INPUT:
- 
-     - ``part1`` -- a partition
--
-     - ``part2`` -- a partition
--
-     - ``maxrows`` -- (optional) an integer
--
-     - ``level`` -- (optional) an integer
--
-     - ``quantum`` -- (optional) an element of a ring
- 
-     If ``maxrows`` is specified, then only partitions with at most
-@@ -479,7 +301,8 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-         sage: sorted(mult([2],[2]).items())
-         [([2, 2], 1), ([3, 1], 1), ([4], 1)]
-         sage: sorted(mult([2,1],[2,1]).items())
--        [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1), ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
-+        [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1),
-+         ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
-         sage: sorted(mult([2,1],[2,1],maxrows=2).items())
-         [([3, 3], 1), ([4, 2], 1)]
-         sage: mult([2,1],[3,2,1],3)
-@@ -510,44 +333,24 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-     if quantum is not None and (level is None or maxrows is None):
-         raise ValueError('missing parameters maxrows or level')
- 
--    cdef vector* v1 = iterable_to_vector(part1)
--    cdef vector* v2 = iterable_to_vector(part2)
--    if maxrows is None:
--        maxrows = 0
--    cdef hashtab* ht = mult_c(v1, v2, int(maxrows))
--    cdef hashtab* tab
--    cdef dict result
--
-     if quantum is None:
-         if level is not None:
--            fusion_reduce_c(ht, int(maxrows), int(level), int(0))
--        result = sf_hashtab_to_dict(ht)
--        v_free(v1)
--        v_free(v2)
--        hash_free(ht)
--        return result
-+            return _lrcalc_dict_to_sage(lrcalc.mult_fusion(part1, part2, maxrows, level))
-+        if maxrows is None:
-+            maxrows = -1
-+        return _lrcalc_dict_to_sage(lrcalc.mult(part1, part2, maxrows))
- 
-     # Otherwise do quantum multiplication
--    cdef _list *qlist
--    cdef dict temp
--    qlist = quantum_reduce_c(ht, int(maxrows), int(level))
--    # The above call frees the memory associated with ht
--    v_free(v1)
--    v_free(v2)
--
--    cdef Parent P = quantum.parent()
--    result = {}
--    for i in range(qlist.length):
--        tab = <hashtab*>(qlist.array[i])
--        temp = sf_hashtab_to_dict(tab)
--        for k in temp:
--            result[k] = result.get(k, P.zero()) + quantum**i * temp[k]
--        hash_free(tab)
--    l_free(qlist)
--    return result
--
--
--def skew(outer, inner, maxrows=0):
-+    result = lrcalc.mult_quantum(part1, part2, maxrows, level, degrees=True)
-+    P = quantum.parent()
-+    output = {}
-+    for i,k in result.items():
-+        la = _Partitions(i[0])
-+        output[la] = output.get(la, P.zero()) + k * quantum**(i[1])
-+    return output
-+
-+
-+def skew(outer, inner, maxrows=-1):
-     """
-     Compute the Schur expansion of a skew Schur function.
- 
-@@ -557,11 +360,9 @@ def skew(outer, inner, maxrows=0):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition.
--
--    - ``inner`` -- a partition.
--
--    - ``maxrows`` -- an integer or ``None``.
-+    - ``outer`` -- a partition
-+    - ``inner`` -- a partition
-+    - ``maxrows`` -- an integer or ``None``
- 
-     If ``maxrows`` is specified, then only partitions with at most
-     this number of rows are included in the result.
-@@ -572,14 +373,7 @@ def skew(outer, inner, maxrows=0):
-         sage: sorted(skew([2,1],[1]).items())
-         [([1, 1], 1), ([2], 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(outer)
--    cdef vector* v2 = iterable_to_vector(inner)
--    cdef hashtab* ht = skew_c(v1, v2, int(maxrows))
--    result = sf_hashtab_to_dict(ht)
--    v_free(v1)
--    v_free(v2)
--    hash_free(ht)
--    return result
-+    return _lrcalc_dict_to_sage(lrcalc.skew(outer, inner, maxrows))
- 
- 
- def coprod(part, all=0):
-@@ -592,9 +386,8 @@ def coprod(part, all=0):
- 
-     INPUT:
- 
--    - ``part`` -- a partition.
--
--    - ``all`` -- an integer.
-+    - ``part`` -- a partition
-+    - ``all`` -- an integer
- 
-     If ``all`` is non-zero then all terms are included in the result.
-     If ``all`` is zero, then only pairs of partitions ``(part1,
-@@ -609,12 +402,9 @@ def coprod(part, all=0):
-         sage: sorted(coprod([2,1]).items())
-         [(([1, 1], [1]), 1), (([2], [1]), 1), (([2, 1], []), 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(part)
--    cdef hashtab* ht = coprod_c(v1, int(all))
--    result = vp_hashtab_to_dict(ht)
--    v_free(v1)
--    hash_free(ht)
--    return result
-+    result = lrcalc.coprod(part, all)
-+    return {tuple([_Partitions(mu) for mu in la]): Integer(k)
-+            for la, k in result.items()}
- 
- 
- def mult_schubert(w1, w2, rank=0):
-@@ -627,11 +417,9 @@ def mult_schubert(w1, w2, rank=0):
- 
-     INPUT:
- 
--    - ``w1`` -- a permutation.
--
--    - ``w2`` -- a permutation.
--
--    - ``rank`` -- an integer.
-+    - ``w1`` -- a permutation
-+    - ``w2`` -- a permutation
-+    - ``rank`` -- an integer
- 
-     If ``rank`` is non-zero, then only permutations from the symmetric
-     group `S(\mathrm{rank})` are included in the result.
-@@ -646,33 +434,24 @@ def mult_schubert(w1, w2, rank=0):
-          ([6, 4, 3, 1, 2, 5], 1), ([6, 5, 2, 1, 3, 4], 1),
-          ([7, 3, 4, 1, 2, 5, 6], 1), ([7, 4, 2, 1, 3, 5, 6], 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(w1)
--    cdef vector* v2 = iterable_to_vector(w2)
--    cdef hashtab* ht = mult_schubert_c(v1, v2, int(rank))
--    result = schubert_hashtab_to_dict(ht)
--    v_free(v1)
--    v_free(v2)
--    hash_free(ht)
--    return result
-+    result = lrcalc.schubmult(w1, w2, rank)
-+    return {Permutation(list(la)):Integer(k) for la,k in result.items()}
- 
- 
--def lrskew(outer, inner, weight=None, maxrows=0):
-+def lrskew(outer, inner, weight=None, maxrows=-1):
-     r"""
-     Iterate over the skew LR tableaux of shape ``outer / inner``.
- 
-     INPUT:
- 
-     - ``outer`` -- a partition
--
-     - ``inner`` -- a partition
--
-     - ``weight`` -- a partition (optional)
--
--    - ``maxrows`` -- an integer (optional)
-+    - ``maxrows`` -- a positive integer (optional)
- 
-     OUTPUT: an iterator of :class:`SkewTableau`
- 
--    Specifying ``maxrows`` restricts the alphabet to `\{1,2,\ldots,maxrows\}`.
-+    Specifying ``maxrows`` = `M` restricts the alphabet to `\{1,2,\ldots,M\}`.
- 
-     Specifying ``weight`` returns only those tableaux of given content/weight.
- 
-@@ -702,22 +481,40 @@ def lrskew(outer, inner, weight=None, maxrows=0):
- 
-         sage: list(lrskew([3,2,1],[2], weight=[3,1]))
-         [[[None, None, 1], [1, 1], [2]]]
-+
-+    TESTS::
-+
-+        sage: from sage.libs.lrcalc.lrcalc import lrskew
-+        sage: list(lrskew([3,2,1],[2], weight=[]))
-+        []
-+        sage: list(lrskew([3,2,1],[2], weight=[0]))
-+        []
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[]))
-+        [[[None, None, None], [None, None], [None]]]
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[0]))
-+        [[[None, None, None], [None, None], [None]]]
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[1]))
-+        []
-     """
--    cdef vector* o = iterable_to_vector(outer)
--    cdef vector* i = iterable_to_vector(inner + [0]*(len(outer) - len(inner)))
--    cdef skewtab* st = st_new(o, i, NULL, int(maxrows))
-+    iterator = lrcalc.lr_iterator(outer, inner, maxrows)
-+    shape = SkewPartition([outer, inner])
- 
-     if weight is None:
--        yield skewtab_to_SkewTableau(st)
--        while st_next(st):
--            yield skewtab_to_SkewTableau(st)
-+        ST = SemistandardSkewTableaux(shape)
-+        for data in iterator:
-+            yield ST.from_shape_and_word(shape, [i+1 for i in data])
-     else:
-         wt = _Partitions(weight)
--        r = skewtab_to_SkewTableau(st)
--        if r.weight() == wt:
--            yield r
--        while st_next(st):
--            r = skewtab_to_SkewTableau(st)
--            if r.weight() == wt:
--                yield r
--    st_free(st)
-+        ST = SemistandardSkewTableaux(shape, wt)
-+        m = len(wt)
-+        for data in iterator:
-+            w = [0] * m
-+            for j in data:
-+                if j >= m:
-+                    # We know they are not equal, so make the check below quick
-+                    w = None
-+                    break
-+                w[j] += 1
-+            if w == wt:
-+                yield ST.from_shape_and_word(shape, [i+1 for i in data])
-+
diff --git a/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch b/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
deleted file mode 100644
index 1e2e0ba90742..000000000000
--- a/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-As produced by `git diff a90a3146{^^,}`
-
-diff --git a/src/sage/repl/interface_magic.py b/src/sage/repl/interface_magic.py
-index 8a455b69b0e..a93e1c9e04c 100644
---- a/src/sage/repl/interface_magic.py
-+++ b/src/sage/repl/interface_magic.py
-@@ -260,7 +260,7 @@ class InterfaceMagic(object):
-             2
-             120
-             sage: shell.run_cell('%%gap foo\n1+1;\n')
--            ...File "<string>", line unknown
-+            ...File...<string>...
-             SyntaxError: Interface magics have no options, got "foo"
-             <BLANKLINE>
-             sage: shell.run_cell('%%gap?')
-diff --git a/src/sage/repl/interpreter.py b/src/sage/repl/interpreter.py
-index 7468afe52d7..06c47b7374a 100644
---- a/src/sage/repl/interpreter.py
-+++ b/src/sage/repl/interpreter.py
-@@ -78,9 +78,9 @@ Check that Cython source code appears in tracebacks::
-     dummy line
-     ...
-     ZeroDivisionError...Traceback (most recent call last)
--    <ipython-input-...> in <module>...
-+    ...in <module>...
-     ----> 1 Integer(1)/Integer(0)
--    .../sage/rings/integer.pyx in sage.rings.integer.Integer...div...
-+    .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
-     ...
-     -> ...                  raise ZeroDivisionError("rational division by zero")
-        ....:            x = <Rational> Rational.__new__(Rational)
-@@ -423,7 +423,7 @@ def SagePreparseTransformer(lines):
-         sage: from sage.repl.interpreter import get_test_shell
-         sage: shell = get_test_shell()
-         sage: shell.run_cell(bad_syntax)
--          File "<string>", line unknown
-+          File...<string>...
-         SyntaxError: Mismatched ']'
-         <BLANKLINE>
-         sage: shell.quit()
diff --git a/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch b/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
deleted file mode 100644
index 853813b0f5bd..000000000000
--- a/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Fix for ipython 8.1
-
---- a/src/sage/repl/interpreter.py
-+++ b/src/sage/repl/interpreter.py
-@@ -78,7 +78,7 @@ Check that Cython source code appears in tracebacks::
-     dummy line
-     ...
-     ZeroDivisionError...Traceback (most recent call last)
--    ...in <module>...
-+    ...
-     ----> 1 Integer(1)/Integer(0)
-     .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
-     ...
diff --git a/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch b/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
deleted file mode 100644
index b861af7ec982..000000000000
--- a/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
+++ /dev/null
@@ -1,126 +0,0 @@
-From 24cc94b1988a90f3bd22a2368ec30c086283af13 Mon Sep 17 00:00:00 2001
-From: Antonio Rojas <arojas@archlinux.org>
-Date: Sun, 16 Jan 2022 11:55:04 +0100
-Subject: Add abs tol to some arb tests
-
----
- src/sage/functions/error.py    |  2 +-
- src/sage/rings/complex_arb.pyx |  6 +++---
- src/sage/rings/real_arb.pyx    | 10 +++++-----
- 3 files changed, 9 insertions(+), 9 deletions(-)
-
-diff --git a/src/sage/functions/error.py b/src/sage/functions/error.py
-index f48d04f..06f0b24 100644
---- a/src/sage/functions/error.py
-+++ b/src/sage/functions/error.py
-@@ -267,7 +267,7 @@ class Function_erf(BuiltinFunction):
- 
-         Check that real ball evaluation is fixed :trac:`28061`::
- 
--            sage: RealBallField(128)(erf(5))
-+            sage: RealBallField(128)(erf(5)) # abs tol 1e-38
-             [0.99999999999846254020557196514981165651 +/- 7.33e-39]
-         """
-         R = parent or s_parent(x)
-diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
-index f986970..93ff565 100644
---- a/src/sage/rings/complex_arb.pyx
-+++ b/src/sage/rings/complex_arb.pyx
-@@ -3974,8 +3974,8 @@ cdef class ComplexBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: CBF(20).erfc()
--            [5.39586561160790e-176 +/- ...e-191]
-+            sage: CBF(20).erfc() # abs tol 1e-190
-+            [5.39586561160790e-176 +/- 6.73e-191]
-             sage: CBF(100, 100).erfc()
-             [0.00065234366376858 +/- ...e-18] + [-0.00393572636292141 +/- ...e-18]*I
-         """
-@@ -4280,7 +4280,7 @@ cdef class ComplexBall(RingElement):
- 
-         TESTS:
- 
--            sage: CBF(Shi(I))
-+            sage: CBF(Shi(I)) # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]*I
-         """
-         cdef ComplexBall result = self._new()
-diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
-index 4a81784..292bfea 100644
---- a/src/sage/rings/real_arb.pyx
-+++ b/src/sage/rings/real_arb.pyx
-@@ -3506,7 +3506,7 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1/2).erf()
-+            sage: RBF(1/2).erf() # abs tol 1e-16
-             [0.520499877813047 +/- 6.10e-16]
-         """
-         cdef RealBall res = self._new()
-@@ -3556,12 +3556,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Si()
-+            sage: RBF(1).Si() # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]
- 
-         TESTS::
- 
--            sage: RBF(Si(1))
-+            sage: RBF(Si(1)) # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]
-         """
-         cdef RealBall res = self._new()
-@@ -3578,12 +3578,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Ci()  # abs tol 1e-16
-+            sage: RBF(1).Ci()  # abs tol 1e-15
-             [0.337403922900968 +/- 3.25e-16]
- 
-         TESTS::
- 
--            sage: RBF(Ci(1))  # abs tol 1e-16
-+            sage: RBF(Ci(1))  # abs tol 1e-15
-             [0.337403922900968 +/- 3.25e-16]
-         """
-         cdef RealBall res = self._new()
--- 
-cgit v1.0-1-gd88e
-
-
-From 53532ddd4e2dc92469c1590ebf0c40f8f69bf579 Mon Sep 17 00:00:00 2001
-From: Antonio Rojas <arojas@archlinux.org>
-Date: Sun, 16 Jan 2022 14:16:53 +0100
-Subject: Decrease abs tol
-
----
- src/sage/rings/real_arb.pyx | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
-index 292bfea..eb30f7f 100644
---- a/src/sage/rings/real_arb.pyx
-+++ b/src/sage/rings/real_arb.pyx
-@@ -3578,12 +3578,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Ci()  # abs tol 1e-15
-+            sage: RBF(1).Ci()  # abs tol 5e-16
-             [0.337403922900968 +/- 3.25e-16]
- 
-         TESTS::
- 
--            sage: RBF(Ci(1))  # abs tol 1e-15
-+            sage: RBF(Ci(1))  # abs tol 5e-16
-             [0.337403922900968 +/- 3.25e-16]
-         """
-         cdef RealBall res = self._new()
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch b/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
deleted file mode 100644
index d4e8f8be60e3..000000000000
--- a/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From 33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c Mon Sep 17 00:00:00 2001
-From: Michael Orlitzky <michael@orlitzky.com>
-Date: Mon, 24 Jan 2022 09:03:29 -0500
-Subject: Trac #33226: update doctests for giac-1.7.0.45.
-
-We have two failing doctests with giac-1.7.0.45: one is a trivial
-tolerance issue, but the other is a symbolic integration result for
-which giac is no longer willing to return a symbolic answer. We add
-"abs tol" to the numeric test, and drop the symbolic one entirely.
----
- src/sage/functions/min_max.py | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/src/sage/functions/min_max.py b/src/sage/functions/min_max.py
-index fc18373..9b7d6d9 100644
---- a/src/sage/functions/min_max.py
-+++ b/src/sage/functions/min_max.py
-@@ -228,15 +228,15 @@ class MaxSymbolic(MinMax_base):
-             ...
-             TypeError: cannot evaluate symbolic expression numerically
- 
--        ::
-+        We can usually integrate these expressions, but can't
-+        guarantee a symbolic answer in closed form::
- 
-             sage: f = max_symbolic(sin(x), cos(x))
-             sage: r = integral(f, x, 0, 1)
-             ...
--            sage: r
--            sqrt(2) - cos(1)
--            sage: r.n()
-+            sage: r.n()  # abs tol 1e-8
-             0.873911256504955
-+
-         """
-         return max_symbolic(args)
- 
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch b/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
deleted file mode 100644
index 19b69700a4f6..000000000000
--- a/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-commit 9c8235e44ffb509efa8a3ca6cdb55154e2b5066d
-Author: Antonio Rojas <arojas@archlinux.org>
-Date:   Sun Feb 13 19:53:14 2022 +0100
-
-    Fix deprecation warning with scipy 1.8
-
-diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-index e9b60dae5ec..7932167b41d 100644
---- a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-@@ -356,7 +356,7 @@ Sage example in ./linsolve.tex, line 2230::
- 
- Sage example in ./linsolve.tex, line 2609::
- 
--  sage: from scipy.sparse.linalg.dsolve import *
-+  sage: from scipy.sparse.linalg import factorized
-   sage: from scipy.sparse import lil_matrix
-   sage: from numpy import array
-   sage: n = 200
diff --git a/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch b/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
new file mode 100644
index 000000000000..e052e306e7a1
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
@@ -0,0 +1,53 @@
+From 6330cee1a69229b2f5d8ac4a09a73d8152f5e14d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Mon, 28 Feb 2022 23:15:16 -0300
+Subject: trac 33360: avoid factoring in is_prime()
+
+In the added TEST, the ideal norm is product of two primes but factoring
+this product takes about half an hour, so factoring the ideal is slow.
+
+To fix the issue, we only factor the ideal if the norm is a prime power.
+---
+ src/sage/rings/number_field/number_field_ideal.py | 22 ++++++++++++++++++++++
+ 1 file changed, 22 insertions(+)
+
+diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
+index f785f22..10d1f88 100644
+--- a/src/sage/rings/number_field/number_field_ideal.py
++++ b/src/sage/rings/number_field/number_field_ideal.py
+@@ -995,10 +995,32 @@ class NumberFieldIdeal(Ideal_generic):
+             False
+             sage: K.ideal(17).is_prime()  # ramified
+             False
++
++        TESTS::
++
++        Check that we do not factor the norm of the ideal, this used
++        to take half an hour, see :trac:`33360`
++
++           sage: K.<a,b,c> = NumberField([x^2-2,x^2-3,x^2-5])
++           sage: t = (((-2611940*c + 1925290/7653)*b - 1537130/7653*c
++           ....:       + 10130950)*a + (1343014/7653*c - 8349770)*b
++           ....:       + 6477058*c - 2801449990/4002519)
++           sage: t.is_prime()
++           False
++
+         """
+         try:
+             return self._pari_prime is not None
+         except AttributeError:
++            K = self.number_field().pari_nf()
++            I = self.pari_hnf()
++            # This would be better, but it is broken in pari 2.13.3.
++            #   self._pari_prime = K.idealismaximal(I) or None
++            # Instead we factor I, but only if the norm is a prime power
++            n = K.idealnorm(I)
++            if n.denominator() > 1 or not n.isprimepower():
++                self._pari_prime = None
++                return False
+             F = self.factor()  # factorization with caching
+             if len(F) != 1 or F[0][1] != 1:
+                 self._pari_prime = None
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
deleted file mode 100644
index 9ba7ca5a6b7d..000000000000
--- a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
+++ /dev/null
@@ -1,99 +0,0 @@
-From 609dd9deaeaa6380ab2f0d50276d911233c00a04 Mon Sep 17 00:00:00 2001
-From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
-Date: Fri, 4 Mar 2022 16:07:09 -0800
-Subject: sage.manifolds: Update doctests for SymPy 1.10
-
----
- src/sage/manifolds/continuous_map.py              | 3 +--
- src/sage/manifolds/differentiable/diff_form.py    | 4 ++--
- src/sage/manifolds/differentiable/tensorfield.py  | 8 ++++----
- src/sage/manifolds/vector_bundle_fiber_element.py | 2 +-
- 4 files changed, 8 insertions(+), 9 deletions(-)
-
-diff --git a/src/sage/manifolds/continuous_map.py b/src/sage/manifolds/continuous_map.py
-index a6356e7..f6f9b6d 100644
---- a/src/sage/manifolds/continuous_map.py
-+++ b/src/sage/manifolds/continuous_map.py
-@@ -1357,8 +1357,7 @@ class ContinuousMap(Morphism):
-             sage: Phi.coord_functions(c_uv, c_xyz)
-             Coordinate functions (u*v, u/v, u + v) on the Chart (M, (u, v))
-             sage: Phi.coord_functions(c_UV, c_xyz)
--            Coordinate functions (-U**2/4 + V**2/4, -(U + V)/(U - V), V)
--             on the Chart (M, (U, V))
-+            Coordinate functions (-U**2/4 + V**2/4, (-U - V)/(U - V), V) on the Chart (M, (U, V))
-             sage: Phi.coord_functions(c_UV, c_XYZ)
-             Coordinate functions ((-U**3 + U**2*V + U*V**2 + 2*U*V + 6*U - V**3
-              - 2*V**2 + 6*V)/(2*(U - V)), (U**3/4 - U**2*V/4 - U*V**2/4 + U*V
-diff --git a/src/sage/manifolds/differentiable/diff_form.py b/src/sage/manifolds/differentiable/diff_form.py
-index 70dd8fb..0aa3469 100644
---- a/src/sage/manifolds/differentiable/diff_form.py
-+++ b/src/sage/manifolds/differentiable/diff_form.py
-@@ -266,7 +266,7 @@ class DiffForm(TensorField):
- 
-         sage: s = a.wedge(b)
-         sage: s.display(eU)
--        a∧b = -x*(2*x*y + 1) dx∧dy
-+        a∧b = x*(-2*x*y - 1) dx∧dy
-         sage: s.display(eV)
-         a∧b = (u**3/8 + u**2*v/8 - u*v**2/8 + u/4 - v**3/8 + v/4) du∧dv
- 
-@@ -275,7 +275,7 @@ class DiffForm(TensorField):
-         sage: f = M.scalar_field({c_xy: (x+y)^2, c_uv: u^2}, name='f')
-         sage: s = f*a
-         sage: s.display(eU)
--        f*a = -y*(x**2 + 2*x*y + y**2) dx + x*(x**2 + 2*x*y + y**2) dy
-+        f*a = y*(-x**2 - 2*x*y - y**2) dx + x*(x**2 + 2*x*y + y**2) dy
-         sage: s.display(eV)
-         f*a = u**2*v/2 du - u**3/2 dv
- 
-diff --git a/src/sage/manifolds/differentiable/tensorfield.py b/src/sage/manifolds/differentiable/tensorfield.py
-index 2775be9..6bc5c50 100644
---- a/src/sage/manifolds/differentiable/tensorfield.py
-+++ b/src/sage/manifolds/differentiable/tensorfield.py
-@@ -334,7 +334,7 @@ class TensorField(ModuleElementWithMutability):
-         sage: f.display()  # long time
-         t(a,b): S^2 → ℝ
-         on U: (x, y) ↦ -2*x*y - 3*x - y**2
--        on V: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+        on V: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
- 
-     The vectors can be defined only on subsets of `S^2`, the domain of the
-     result is then the common subset::
-@@ -343,12 +343,12 @@ class TensorField(ModuleElementWithMutability):
-         sage: s.display()  # long time
-         t(a,b): U → ℝ
-            (x, y) ↦ -2*x*y - 3*x - y**2
--        on W: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+        on W: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
-         sage: s = t(a.restrict(U), b.restrict(W))  # long time
-         sage: s.display()  # long time
-         t(a,b): W → ℝ
-            (x, y) ↦ -2*x*y - 3*x - y**2
--           (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+           (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
- 
-     The tensor itself can be defined only on some open subset of `S^2`,
-     yielding a result whose domain is this subset::
-@@ -356,7 +356,7 @@ class TensorField(ModuleElementWithMutability):
-         sage: s = t.restrict(V)(a,b)  # long time
-         sage: s.display()  # long time
-         t(a,b): V → ℝ
--           (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+           (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
-         on W: (x, y) ↦ -2*x*y - 3*x - y**2
- 
-     Tests regarding the multiplication by a scalar field::
-diff --git a/src/sage/manifolds/vector_bundle_fiber_element.py b/src/sage/manifolds/vector_bundle_fiber_element.py
-index 29ee81d..048275a 100644
---- a/src/sage/manifolds/vector_bundle_fiber_element.py
-+++ b/src/sage/manifolds/vector_bundle_fiber_element.py
-@@ -110,4 +110,4 @@ class VectorBundleFiberElement(FiniteRankFreeModuleElement):
-             desc += str(self._name) + " "
-         desc += "in the fiber of {} at {}".format(self._vbundle._name,
-                                                   self._point)
--        return desc
-\ No newline at end of file
-+        return desc
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
deleted file mode 100644
index f5ac180baa90..000000000000
--- a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From c49eff347454ac7f07e5918470b20e97b8f2357e Mon Sep 17 00:00:00 2001
-From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
-Date: Fri, 4 Mar 2022 15:14:43 -0800
-Subject: src/sage/calculus/calculus.py: Update laplace doctest for sympy 1.10
-
----
- src/sage/calculus/calculus.py | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/src/sage/calculus/calculus.py b/src/sage/calculus/calculus.py
-index 9c2f226..b335093 100644
---- a/src/sage/calculus/calculus.py
-+++ b/src/sage/calculus/calculus.py
-@@ -1639,9 +1639,9 @@ def laplace(ex, t, s, algorithm='maxima'):
-         sage: laplace(dirac_delta(t), t, s)
-         1
-         sage: F, a, cond = laplace(dirac_delta(t), t, s, algorithm='sympy')
--        sage: a, cond
--        (-oo, True)
--        sage: F       # random - sympy <1.9 includes undefined heaviside(0) in answer
-+        sage: a, cond  # random - sympy <1.10 gives (-oo, True)
-+        (0, True)
-+        sage: F        # random - sympy <1.9 includes undefined heaviside(0) in answer
-         1
-         sage: laplace(dirac_delta(t), t, s, algorithm='giac')
-         1
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch b/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
deleted file mode 100644
index 8e7bb64f5b01..000000000000
--- a/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From a04a0a0b14f67f4804e7113c3db41bbcf8a58296 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
-Date: Mon, 28 Mar 2022 20:39:59 -0300
-Subject: Trac #33585: fix doctest when dochtml is missing...
-
-...but sphinx is available in PYTHONPATH.
----
- src/sage/misc/sagedoc.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/sage/misc/sagedoc.py b/src/sage/misc/sagedoc.py
-index 4b3853f..08c4225 100644
---- a/src/sage/misc/sagedoc.py
-+++ b/src/sage/misc/sagedoc.py
-@@ -1401,7 +1401,7 @@ class _sage_doc:
-             "...**File:**...**Type:**...**Definition:** identity_matrix..."
-             sage: identity_matrix.__doc__ in browse_sage_doc(identity_matrix, 'rst')
-             True
--            sage: browse_sage_doc(identity_matrix, 'html', False)             # optional - sphinx
-+            sage: browse_sage_doc(identity_matrix, 'html', False)             # optional - sphinx sagemath_doc_html
-             '...div...File:...Type:...Definition:...identity_matrix...'
- 
-         In the 'text' version, double colons have been replaced with
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch b/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
new file mode 100644
index 000000000000..977a42400e59
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
@@ -0,0 +1,42 @@
+commit 5db5d4e56243c609f44afc1f21c112b026f9e1fe
+Author: Oscar Benjamin <oscar.j.benjamin@gmail.com>
+Date:   Mon Jul 11 21:24:01 2022 +0100
+
+    Update doctests for SymPy 1.11
+    
+    Doctests related to SymPy's rsolve function are updated in:
+    
+    src/sage/calculus/test_sympy.py
+    src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+    
+    The form of the output from SymPy has changed since
+    
+    https://github.com/sympy/sympy/pull/23567
+
+diff --git a/src/sage/calculus/test_sympy.py b/src/sage/calculus/test_sympy.py
+index 7cf7f3f6bfd..927e6ee4fb6 100644
+--- a/src/sage/calculus/test_sympy.py
++++ b/src/sage/calculus/test_sympy.py
+@@ -193,7 +193,7 @@ This was fixed in Sympy, see :trac:`14437`::
+     sage: u = Function('u')
+     sage: n = Symbol('n', integer=True)
+     sage: f = u(n+2) - u(n+1) + u(n)/4
+-    sage: 2**n * rsolve(f,u(n))
+-    C1*n + C0
++    sage: expand(2**n * rsolve(f,u(n)))
++    2*C1*n + C0
+ 
+ """
+diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+index 1062f4f7e8c..f53f813d793 100644
+--- a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
++++ b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+@@ -382,7 +382,7 @@ Sage example in ./recequadiff.tex, line 1798::
+   sage: from sympy import rsolve_hyper
+   sage: from sympy.abc import n
+   sage: rsolve_hyper([-2,1],2**(n+2),n)
+-  2**n*C0 + 2**(n + 2)*(C0 + n/2)
++  2**n*C0 + 2**(n + 1)*n
+ 
+ """
+ 
diff --git a/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch b/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch
new file mode 100644
index 000000000000..b544a3eef7dd
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch
@@ -0,0 +1,526 @@
+From aeff992d53a65a705dca5cd5216bcb97c218dce7 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:14:03 +0200
+Subject: Adapt to API changes in OpenOutputStream and CloseOutput
+
+---
+ src/sage/libs/gap/element.pyx      | 5 +++--
+ src/sage/libs/gap/gap_includes.pxd | 6 ++++--
+ 2 files changed, 7 insertions(+), 4 deletions(-)
+
+diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
+index be43c4c..e268116 100644
+--- a/src/sage/libs/gap/element.pyx
++++ b/src/sage/libs/gap/element.pyx
+@@ -130,6 +130,7 @@ cdef char *capture_stdout(Obj func, Obj obj):
+     """
+     cdef Obj s, stream, output_text_string
+     cdef UInt res
++    cdef TypOutputFile output
+     # The only way to get a string representation of an object that is truly
+     # consistent with how it would be represented at the GAP REPL is to call
+     # ViewObj on it.  Unfortunately, ViewObj *prints* to the output stream,
+@@ -145,12 +146,12 @@ cdef char *capture_stdout(Obj func, Obj obj):
+         output_text_string = GAP_ValueGlobalVariable("OutputTextString")
+         stream = CALL_2ARGS(output_text_string, s, GAP_True)
+ 
+-        if not OpenOutputStream(stream):
++        if not OpenOutputStream(&output, stream):
+             raise GAPError("failed to open output capture stream for "
+                            "representing GAP object")
+ 
+         CALL_1ARGS(func, obj)
+-        CloseOutput()
++        CloseOutput(&output)
+         return CSTR_STRING(s)
+     finally:
+         GAP_Leave()
+diff --git a/src/sage/libs/gap/gap_includes.pxd b/src/sage/libs/gap/gap_includes.pxd
+index 5a9ab48..34035fe 100644
+--- a/src/sage/libs/gap/gap_includes.pxd
++++ b/src/sage/libs/gap/gap_includes.pxd
+@@ -76,8 +76,10 @@ cdef extern from "gap/intobj.h" nogil:
+ 
+ 
+ cdef extern from "gap/io.h" nogil:
+-    UInt OpenOutputStream(Obj stream)
+-    UInt CloseOutput()
++    ctypedef struct TypOutputFile:
++        pass
++    UInt OpenOutputStream(TypOutputFile* output, Obj stream)
++    UInt CloseOutput(TypOutputFile* output)
+ 
+ 
+ cdef extern from "gap/libgap-api.h" nogil:
+-- 
+cgit v1.0-1-gd88e
+
+
+From c3367b4290981e5e93b7a30c48b02f1ae3770dc8 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:14:53 +0200
+Subject: Disable colored prompt as it breaks the pexpect interface
+
+---
+ src/sage/interfaces/gap.py | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/src/sage/interfaces/gap.py b/src/sage/interfaces/gap.py
+index c34fe53..569caa2 100644
+--- a/src/sage/interfaces/gap.py
++++ b/src/sage/interfaces/gap.py
+@@ -1512,6 +1512,8 @@ def gap_reset_workspace(max_workspace_size=None, verbose=False):
+     """
+     # Create new workspace with filename WORKSPACE
+     g = Gap(use_workspace_cache=False, max_workspace_size=None)
++    g.eval('ColorPrompt(false)')
++    g.eval('SetUserPreference("UseColorPrompt", false)')
+     g.eval('SetUserPreference("HistoryMaxLines", 30)')
+     from sage.tests.gap_packages import all_installed_packages
+     for pkg in all_installed_packages(gap=g):
+-- 
+cgit v1.0-1-gd88e
+
+
+From 3b63e998e4d6118fc86b13b940c8f3d3b8307a50 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:16:03 +0200
+Subject: Port NaturalHomomorphism uses
+
+---
+ src/sage/groups/abelian_gps/abelian_group_gap.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/sage/groups/abelian_gps/abelian_group_gap.py b/src/sage/groups/abelian_gps/abelian_group_gap.py
+index a4b0471..86090b4 100644
+--- a/src/sage/groups/abelian_gps/abelian_group_gap.py
++++ b/src/sage/groups/abelian_gps/abelian_group_gap.py
+@@ -338,7 +338,7 @@ class AbelianGroup_gap(UniqueRepresentation, GroupMixinLibGAP, ParentLibGAP, Abe
+         if isinstance(x, AbelianGroupElement_gap):
+             try:
+                 if x in self._cover:
+-                    x = self.gap().NaturalHomomorphism().Image(x.gap())
++                    x = self._cover.gap().NaturalHomomorphismByNormalSubgroup(self._relations).Image(x.gap())
+                 else:
+                     x = x.gap()
+             except AttributeError:
+@@ -1043,7 +1043,7 @@ class AbelianGroupQuotient_gap(AbelianGroup_gap):
+             From: Abelian group with gap, generator orders (4,)
+             To:   Quotient abelian group with generator orders (2,)
+         """
+-        phi = self.gap().NaturalHomomorphism()
++        phi = self._cover.gap().NaturalHomomorphismByNormalSubgroup(self._relations)
+         Hom = self._cover.Hom(self)
+         return Hom(phi)
+ 
+-- 
+cgit v1.0-1-gd88e
+
+
+From bc40764be044653e06f2da3497e1e05da08251f7 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:17:36 +0200
+Subject: Fix tests with GAP 4.12
+
+---
+ src/doc/en/thematic_tutorials/lie/weyl_groups.rst  | 12 ++++++------
+ src/sage/coding/codecan/autgroup_can_label.pyx     |  2 +-
+ src/sage/coding/linear_code.py                     | 22 +++++++++++-----------
+ .../root_system/hecke_algebra_representation.py    |  2 +-
+ src/sage/combinat/symmetric_group_algebra.py       |  2 +-
+ src/sage/groups/finitely_presented.py              |  6 +++---
+ src/sage/groups/fqf_orthogonal.py                  |  2 +-
+ src/sage/groups/libgap_wrapper.pyx                 |  6 +++---
+ .../perm_gps/partn_ref2/refinement_generic.pyx     |  2 +-
+ src/sage/groups/perm_gps/permgroup.py              |  8 ++++----
+ src/sage/libs/gap/libgap.pyx                       |  2 +-
+ src/sage/libs/gap/util.pyx                         |  8 +-------
+ src/sage/tests/gap_packages.py                     |  2 +-
+ 13 files changed, 35 insertions(+), 41 deletions(-)
+
+diff --git a/src/doc/en/thematic_tutorials/lie/weyl_groups.rst b/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
+index c917338..182e74a 100644
+--- a/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
++++ b/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
+@@ -139,12 +139,12 @@ string, which you can print::
+     X.1      1  1  1  1  1  1  1  1  1  1  1  1  1
+     X.2      1 -1  1  1 -1  1  1 -1 -1 -1  1  1  1
+     X.3      2  .  2 -1  .  2  2  .  .  . -1  2  2
+-    X.4      3 -1 -1  .  1 -1  3 -1  1 -1  . -1  3
+-    X.5      3 -1 -1  .  1  3 -1 -1 -1  1  . -1  3
+-    X.6      3  1 -1  . -1 -1  3  1 -1  1  . -1  3
+-    X.7      3  1 -1  . -1  3 -1  1  1 -1  . -1  3
+-    X.8      3 -1  3  . -1 -1 -1 -1  1  1  . -1  3
+-    X.9      3  1  3  .  1 -1 -1  1 -1 -1  . -1  3
++    X.4      3 -1 -1  .  1  3 -1 -1 -1  1  . -1  3
++    X.5      3  1 -1  . -1  3 -1  1  1 -1  . -1  3
++    X.6      3 -1  3  . -1 -1 -1 -1  1  1  . -1  3
++    X.7      3 -1 -1  .  1 -1  3 -1  1 -1  . -1  3
++    X.8      3  1  3  .  1 -1 -1  1 -1 -1  . -1  3
++    X.9      3  1 -1  . -1 -1  3  1 -1  1  . -1  3
+     X.10     4 -2  . -1  .  .  .  2  .  .  1  . -4
+     X.11     4  2  . -1  .  .  . -2  .  .  1  . -4
+     X.12     6  . -2  .  . -2 -2  .  .  .  .  2  6
+diff --git a/src/sage/coding/codecan/autgroup_can_label.pyx b/src/sage/coding/codecan/autgroup_can_label.pyx
+index de5db98..c83b926 100644
+--- a/src/sage/coding/codecan/autgroup_can_label.pyx
++++ b/src/sage/coding/codecan/autgroup_can_label.pyx
+@@ -76,7 +76,7 @@ columns do share the same coloring::
+     ((1,),
+      (2,),
+      (3, 5, 4),
+-     (6, 19, 16, 9, 21, 10, 8, 15, 14, 11, 20, 13, 12, 7, 17, 18))
++     (6, 19, 16, 21, 9, 10, 15, 8, 20, 11, 14, 13, 7, 12, 18, 17))
+ 
+ We can also restrict the group action to linear isometries::
+ 
+diff --git a/src/sage/coding/linear_code.py b/src/sage/coding/linear_code.py
+index e8e32f8..9d45160 100644
+--- a/src/sage/coding/linear_code.py
++++ b/src/sage/coding/linear_code.py
+@@ -466,27 +466,27 @@ class AbstractLinearCode(AbstractLinearCodeNoMetric):
+             0
+             sage: C = codes.HammingCode(GF(4, 'z'), 3)
+             sage: C.automorphism_group_gens()
+-            ([((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
++            ([((1, 1, 1, z, z + 1, 1, 1, 1, 1, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z); (1,13,14,20)(2,21,8,18,7,16,19,15)(3,10,5,12,17,9,6,4), Ring endomorphism of Finite Field in z of size 2^2
++                Defn: z |--> z + 1),
++              ((z, 1, z, z, z, z + 1, z, z, z, z, z, z, z + 1, z, z, z, z, z + 1, z, z, z); (1,11,5,12,3,19)(2,8)(6,18,13)(7,17,15)(9,10,14,16,20,21), 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 + 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
++            ([((z, 1, z + 1, z + 1, 1, z + 1, z, 1, z + 1, z + 1, 1, z, 1, z + 1, z, 1, z, 1, z + 1, 1, 1); (1,12,11,10,6,8,9,20,13,21,5,14,3,16,17,19,7,4,2,15,18), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+-              ((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
++              ((z + 1, z + 1, z + 1, z, 1, 1, z, z, 1, z + 1, z, 1, 1, z, 1, z + 1, z, z + 1, z + 1, 1, z); (1,3,18,2,17,6,19)(4,15,13,20,7,14,16)(5,11,8,21,12,9,10), 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)],
+              181440)
+             sage: C.automorphism_group_gens(equivalence="permutational")
+-            ([((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,19)(3,17)(4,21)(5,20)(7,14)(9,12)(10,16)(11,15), Ring endomorphism of Finite Field in z of size 2^2
++            ([((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,11)(3,10)(4,9)(5,7)(12,21)(14,20)(15,19)(16,17), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+-              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,11)(3,10)(4,9)(5,7)(12,21)(14,20)(15,19)(16,17), Ring endomorphism of Finite Field in z of size 2^2
++              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (2,18)(3,19)(4,10)(5,16)(8,13)(9,14)(11,21)(15,20), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+-              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,17)(2,8)(3,14)(4,10)(7,12)(9,19)(13,18)(15,20), Ring endomorphism of Finite Field in z of size 2^2
++              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,19)(3,17)(4,21)(5,20)(7,14)(9,12)(10,16)(11,15), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+               ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (2,13)(3,14)(4,20)(5,11)(8,18)(9,19)(10,15)(16,21), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z)],
+@@ -692,10 +692,10 @@ class AbstractLinearCode(AbstractLinearCodeNoMetric):
+             sage: C_iso == aut_group_can_label.get_canonical_form()
+             True
+             sage: aut_group_can_label.get_autom_gens()
+-            [((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
++            [((1, 1, 1, z, z + 1, 1, 1, 1, 1, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z); (1,13,14,20)(2,21,8,18,7,16,19,15)(3,10,5,12,17,9,6,4), Ring endomorphism of Finite Field in z of size 2^2
++               Defn: z |--> z + 1),
++             ((z, 1, z, z, z, z + 1, z, z, z, z, z, z, z + 1, z, z, z, z, z + 1, z, z, z); (1,11,5,12,3,19)(2,8)(6,18,13)(7,17,15)(9,10,14,16,20,21), 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/root_system/hecke_algebra_representation.py b/src/sage/combinat/root_system/hecke_algebra_representation.py
+index bde2823..bffcc85 100644
+--- a/src/sage/combinat/root_system/hecke_algebra_representation.py
++++ b/src/sage/combinat/root_system/hecke_algebra_representation.py
+@@ -355,7 +355,7 @@ class HeckeAlgebraRepresentation(WithEqualityById, SageObject):
+             sage: q1, q2 = K.gens()
+             sage: KW = W.algebra(K)
+             sage: x = KW.an_element(); x
+-            123 + 3*32 + 2*3 + e
++            123 + 3*2312 + 2*31 + e
+ 
+             sage: T = KW.demazure_lusztig_operators(q1,q2)
+             sage: T12 = T.Tw( (1,2) )
+diff --git a/src/sage/combinat/symmetric_group_algebra.py b/src/sage/combinat/symmetric_group_algebra.py
+index c3d6755..da953d2 100644
+--- a/src/sage/combinat/symmetric_group_algebra.py
++++ b/src/sage/combinat/symmetric_group_algebra.py
+@@ -101,7 +101,7 @@ def SymmetricGroupAlgebra(R, W, category=None):
+         sage: SGA.group()
+         Weyl Group of type ['A', 3] (as a matrix group acting on the ambient space)
+         sage: SGA.an_element()
+-        s1*s2*s3 + 3*s3*s2 + 2*s3 + 1
++        s1*s2*s3 + 3*s2*s3*s1*s2 + 2*s3*s1 + 1
+ 
+     The preferred way to construct the symmetric group algebra is to
+     go through the usual ``algebra`` method::
+diff --git a/src/sage/groups/finitely_presented.py b/src/sage/groups/finitely_presented.py
+index 2a61bbf..d26891a 100644
+--- a/src/sage/groups/finitely_presented.py
++++ b/src/sage/groups/finitely_presented.py
+@@ -596,9 +596,9 @@ class RewritingSystem():
+             sage: k = G.rewriting_system()
+             sage: k.gap()
+             Knuth Bendix Rewriting System for Monoid( [ a, A, b, B ] ) with rules
+-            [ [ a^2, <identity ...> ], [ a*A, <identity ...> ],
+-              [ A*a, <identity ...> ], [ b^2, <identity ...> ],
+-              [ b*B, <identity ...> ], [ B*b, <identity ...> ] ]
++            [ [ a*A, <identity ...> ], [ A*a, <identity ...> ],
++              [ b*B, <identity ...> ], [ B*b, <identity ...> ],
++              [ a^2, <identity ...> ], [ b^2, <identity ...> ] ]
+         """
+         return self._gap
+ 
+diff --git a/src/sage/groups/fqf_orthogonal.py b/src/sage/groups/fqf_orthogonal.py
+index 75de408..dd7d84d 100644
+--- a/src/sage/groups/fqf_orthogonal.py
++++ b/src/sage/groups/fqf_orthogonal.py
+@@ -143,7 +143,7 @@ class FqfOrthogonalGroup(AbelianGroupAutomorphismGroup_subgroup):
+         [2/3   0   0]
+         [  0 2/3   0]
+         [  0   0 4/3]
+-        generated by 2 elements
++        generated by 3 elements
+         sage: q = matrix.diagonal(QQ, [3/2, 1/4, 1/4])
+         sage: T = TorsionQuadraticForm(q)
+         sage: T.orthogonal_group().order()
+diff --git a/src/sage/groups/libgap_wrapper.pyx b/src/sage/groups/libgap_wrapper.pyx
+index a76afc2..9340c0d 100644
+--- a/src/sage/groups/libgap_wrapper.pyx
++++ b/src/sage/groups/libgap_wrapper.pyx
+@@ -25,7 +25,7 @@ Note how we call the constructor of both superclasses to initialize
+ its output via LibGAP::
+ 
+     sage: FooGroup()
+-    <pc group of size 3 with 1 generators>
++    <pc group of size 3 with 1 generator>
+     sage: type(FooGroup().gap())
+     <class 'sage.libs.gap.element.GapElement'>
+ 
+@@ -106,7 +106,7 @@ class ParentLibGAP(SageObject):
+         ....:         ParentLibGAP.__init__(self, lg)
+         ....:         Group.__init__(self)
+         sage: FooGroup()
+-        <pc group of size 3 with 1 generators>
++        <pc group of size 3 with 1 generator>
+     """
+ 
+     def __init__(self, libgap_parent, ambient=None):
+@@ -461,7 +461,7 @@ cdef class ElementLibGAP(MultiplicativeGroupElement):
+         ....:         ParentLibGAP.__init__(self, lg)
+         ....:         Group.__init__(self)
+         sage: FooGroup()
+-        <pc group of size 3 with 1 generators>
++        <pc group of size 3 with 1 generator>
+         sage: FooGroup().gens()
+         (f1,)
+     """
+diff --git a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
+index 2fcb036..ca73c6b 100644
+--- a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
++++ b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
+@@ -427,7 +427,7 @@ cdef class LabelledBranching:
+             sage: from sage.groups.perm_gps.partn_ref2.refinement_generic import LabelledBranching
+             sage: L = LabelledBranching(3)
+             sage: L.small_generating_set()
+-            []
++            [()]
+             sage: L.add_gen(libgap.eval('(1,2,3)'))
+             sage: L.small_generating_set()
+             [(1,2,3)]
+diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
+index 4908934..34ba0cc 100644
+--- a/src/sage/groups/perm_gps/permgroup.py
++++ b/src/sage/groups/perm_gps/permgroup.py
+@@ -913,7 +913,7 @@ class PermutationGroup_generic(FiniteGroup):
+            sage: f = PG._coerce_map_from_(MG)
+            sage: mg = MG.an_element()
+            sage: p = f(mg); p
+-           (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)
++           (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(p._gap_()) == p
+            True
+ 
+@@ -959,12 +959,12 @@ class PermutationGroup_generic(FiniteGroup):
+             sage: P = G.as_permutation_group(algorithm='smaller', seed=5)
+             sage: P1 = G.as_permutation_group()
+             sage: P == P1
+-            False
++            True
+             sage: g1, g2, g3 = G.gens()
+             sage: P(g1*g2)
+-            (1,3,7,12)(2,4,8,10)(5,11)(6,9)
++            (1,4,13,11)(2,5,14,18)(3,15,8,16)(6,7)(9,20,19,12)(10,17)
+             sage: P1(g1*g2)
+-            (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)
++            (1,4,13,11)(2,5,14,18)(3,15,8,16)(6,7)(9,20,19,12)(10,17)
+ 
+         Another check for :trac:`5583`::
+ 
+diff --git a/src/sage/libs/gap/libgap.pyx b/src/sage/libs/gap/libgap.pyx
+index b1a64e5..6a36613 100644
+--- a/src/sage/libs/gap/libgap.pyx
++++ b/src/sage/libs/gap/libgap.pyx
+@@ -695,7 +695,7 @@ class Gap(Parent):
+             sage: libgap.List
+             <Gap function "List">
+             sage: libgap.GlobalRandomSource
+-            <RandomSource in IsGlobalRandomSource>
++            <RandomSource in IsGAPRandomSource>
+         """
+         if name in dir(self.__class__):
+             return getattr(self.__class__, name)
+diff --git a/src/sage/libs/gap/util.pyx b/src/sage/libs/gap/util.pyx
+index 344ab88..6350987 100644
+--- a/src/sage/libs/gap/util.pyx
++++ b/src/sage/libs/gap/util.pyx
+@@ -362,15 +362,9 @@ cdef Obj gap_eval(str gap_string) except? NULL:
+         GAPError: Error, Variable: 'Complex' must have a value
+         Syntax error: ; expected in stream:1
+         Complex Field with 53 bits of precision;;
+-         ^^^^^^^^^^^^
++                ^^^^^
+         Error, Variable: 'with' must have a value
+-        Syntax error: ; expected in stream:1
+-        Complex Field with 53 bits of precision;;
+-         ^^^^^^^^^^^^^^^^^^^^
+         Error, Variable: 'bits' must have a value
+-        Syntax error: ; expected in stream:1
+-        Complex Field with 53 bits of precision;;
+-         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+         Error, Variable: 'precision' must have a value
+ 
+     Test that on a subsequent attempt we get the same message (no garbage was
+diff --git a/src/sage/tests/gap_packages.py b/src/sage/tests/gap_packages.py
+index 2e4518c..c302b16 100644
+--- a/src/sage/tests/gap_packages.py
++++ b/src/sage/tests/gap_packages.py
+@@ -103,7 +103,7 @@ def all_installed_packages(ignore_dot_gap=False, gap=None):
+ 
+         sage: from sage.tests.gap_packages import all_installed_packages
+         sage: all_installed_packages()
+-        (...'GAPDoc'...)
++        (...'gapdoc'...)
+         sage: all_installed_packages(ignore_dot_gap=True) == all_installed_packages(gap=gap, ignore_dot_gap=True)
+         True
+     """
+-- 
+cgit v1.0-1-gd88e
+
+
+From cbc902a79ff9ec01d4d4eb9a767a1c661fb5dda7 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Fri, 30 Sep 2022 19:17:42 +0200
+Subject: Adapt test to new is_transitive and is_primitive behavior
+
+---
+ src/sage/groups/perm_gps/permgroup.py | 22 ++++++++++++++++------
+ 1 file changed, 16 insertions(+), 6 deletions(-)
+
+diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
+index 34ba0cc..5832b98 100644
+--- a/src/sage/groups/perm_gps/permgroup.py
++++ b/src/sage/groups/perm_gps/permgroup.py
+@@ -4359,17 +4359,23 @@ class PermutationGroup_generic(FiniteGroup):
+ 
+         ::
+ 
+-            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)]]) #S_5 on [1..5]
+-            sage: G.is_transitive([1,4,5])
++            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)],[(6,7)]])
++            sage: G.is_transitive([1,2,3,4,5])
+             True
+-            sage: G.is_transitive([2..6])
++            sage: G.is_transitive([1..7])
+             False
+             sage: G.is_transitive(G.non_fixed_points())
+-            True
++            False
+             sage: H = PermutationGroup([[(1,2,3)],[(4,5,6)]])
+             sage: H.is_transitive(H.non_fixed_points())
+             False
+ 
++        If `G` does not act on the domain, it always returns ``False``::
++
++            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)]]) #S_5 on [1..5]
++            sage: G.is_transitive([1,4,5])
++            False
++
+         Note that this differs from the definition in GAP, where
+         ``IsTransitive`` returns whether the group is transitive on the
+         set of points moved by the group.
+@@ -4425,12 +4431,16 @@ class PermutationGroup_generic(FiniteGroup):
+             sage: G = PermutationGroup([[(1,2,3,4)],[(2,4)]])
+             sage: G.is_primitive([1..4])
+             False
+-            sage: G.is_primitive([1,2,3])
+-            True
+             sage: G = PermutationGroup([[(3,4,5,6)],[(3,4)]]) #S_4 on [3..6]
+             sage: G.is_primitive(G.non_fixed_points())
+             True
+ 
++        If `G` does not act on the domain, it always returns ``False``::
++
++            sage: G = PermutationGroup([[(1,2,3,4)],[(2,4)]])
++            sage: G.is_primitive([1,2,3])
++            False
++
+         """
+         #If the domain is not a subset of self.domain(), then the
+         #action isn't primitive.
+-- 
+cgit v1.0-1-gd88e
+
+
+From 80dd6b338236f170efca1fc3545df18ce8d8795c Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Fri, 30 Sep 2022 19:18:06 +0200
+Subject: Mark test as random. With gap 4.12 on x86_64 it is no longer 2
+
+---
+ src/sage/groups/perm_gps/permgroup.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
+index 5832b98..c1230a3 100644
+--- a/src/sage/groups/perm_gps/permgroup.py
++++ b/src/sage/groups/perm_gps/permgroup.py
+@@ -1287,7 +1287,7 @@ class PermutationGroup_generic(FiniteGroup):
+             sage: G.gens_small() # random
+             [('b','c'), ('a','c','b')] ## (on 64-bit Linux)
+             [('a','b'), ('a','c','b')] ## (on Solaris)
+-            sage: len(G.gens_small()) == 2
++            sage: len(G.gens_small()) == 2 # random
+             True
+         """
+         gens = self._libgap_().SmallGeneratingSet()
+-- 
+cgit v1.0-1-gd88e
+
+
+From a6c293d67cfcdf8fba7bc6aa7899e2086d42cc7e Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Fri, 30 Sep 2022 19:18:30 +0200
+Subject: Remove test that is now redundant, all seeds give the same answer
+
+---
+ src/sage/groups/matrix_gps/finitely_generated.py | 3 ---
+ 1 file changed, 3 deletions(-)
+
+diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
+index a6d3dc0..63956ad 100644
+--- a/src/sage/groups/matrix_gps/finitely_generated.py
++++ b/src/sage/groups/matrix_gps/finitely_generated.py
+@@ -563,9 +563,6 @@ class FinitelyGeneratedMatrixGroup_gap(MatrixGroup_gap):
+             21499084800
+             sage: P = G.as_permutation_group()
+             sage: Psmaller = G.as_permutation_group(algorithm="smaller", seed=6)
+-            sage: P == Psmaller  # see the note below
+-            True
+-            sage: Psmaller = G.as_permutation_group(algorithm="smaller")
+             sage: P == Psmaller
+             False
+             sage: P.cardinality()
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch b/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
new file mode 100644
index 000000000000..8fedcb78cf71
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
@@ -0,0 +1,19 @@
+commit 04971318f032caf8dc1c0de9489346d894409091
+Author: John H. Palmieri <jhpalmieri64@gmail.com>
+Date:   Wed Aug 31 14:22:26 2022 -0700
+
+    trac 34465: fix invalid escape sequence in functions/special.py
+
+diff --git a/src/sage/functions/special.py b/src/sage/functions/special.py
+index 02596e49620..901f02f9bee 100644
+--- a/src/sage/functions/special.py
++++ b/src/sage/functions/special.py
+@@ -849,7 +849,7 @@ class EllipticF(BuiltinFunction):
+     - :wikipedia:`Elliptic_integral#Incomplete_elliptic_integral_of_the_first_kind`
+     """
+     def __init__(self):
+-        """
++        r"""
+         EXAMPLES::
+ 
+             sage: loads(dumps(elliptic_f))
diff --git a/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch b/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch
deleted file mode 100644
index f3eb0aad2cca..000000000000
--- a/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch
+++ /dev/null
@@ -1,14 +0,0 @@
- - this is not a proper fix... should fix sage_getfile() instead
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -187,7 +187,8 @@ def loadable_module_extension():
-         True
-     """
-     # Return the full platform-specific extension module suffix
--    return import_machinery.EXTENSION_SUFFIXES[0]
-+    # PATCHED for void linux, we use the shortest extension (.so)
-+    return import_machinery.EXTENSION_SUFFIXES[-1]
- 
- 
- def isclassinstance(obj):
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 0d793262d572..8df50e4e13b6 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,7 +1,7 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=9.5
-revision=2
+version=9.7
+revision=1
 wrksrc=sage-$version
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
@@ -33,12 +33,9 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="http://sagemath.org/"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=8d70a3b26080802c5b2e33dda4c23795d494d8216a0c2ecfcd608ebab0e64ff6
+checksum=9f26f14aa322e3cf38a71835b12ac34b23026b467f74d54b064c5d025e76fbfd
 
 post_patch() {
-	# these are unused and nothing else uses ratpoints
-	rm sage/libs/ratpoints.{pyx,pxd}
-
 	# git tree needs bootstrapping
 	pushd $wrksrc/build/pkgs/sagelib
 	PATH=../../bin:$PATH BOOTSTRAP_QUIET=no ./bootstrap
@@ -65,6 +62,7 @@ do_configure() {
 
 pre_build() {
 	export PYTHONPATH=../sage-setup
+	export PYTHONDONTWRITEBYTECODE=yes
 	export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
 }
 
@@ -77,6 +75,7 @@ post_build() {
 
 pre_install() {
 	export PYTHONPATH=../sage-setup
+	export PYTHONDONTWRITEBYTECODE=yes
 	export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
 }
 
@@ -104,6 +103,7 @@ post_install() {
 do_check() {
 	_scripts=$(cd build/scripts* && pwd)
 	export PYTHONPATH=$(cd build/lib* && pwd)
+	export PYTHONDONTWRITEBYTECODE=yes
 
 	# get out of $build_wrksrc, otherwise python picks the wrong sage module
 	cd $(mktemp -dp build)

From b2bbfa77245790b2104e3f11b6143d6f96d86eb0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Thu, 13 Oct 2022 00:08:32 -0300
Subject: [PATCH 13/13] giac: temporary ci-skip

---
 srcpkgs/giac/template | 1 +
 1 file changed, 1 insertion(+)

diff --git a/srcpkgs/giac/template b/srcpkgs/giac/template
index 31045e9128ee..a0c2f1799710 100644
--- a/srcpkgs/giac/template
+++ b/srcpkgs/giac/template
@@ -15,6 +15,7 @@ homepage="https://www-fourier.ujf-grenoble.fr/~parisse/giac.html"
 changelog="https://www-fourier.ujf-grenoble.fr/~parisse/install_en#new"
 distfiles="https://www-fourier.ujf-grenoble.fr/~parisse/debian/dists/stable/main/source/giac_${version%.*}-${version##*.}.tar.gz"
 checksum=120cd16f2e033817302d2a03a22bd413dc1d85df8b225ba4f76b93a7805b07fe
+make_check=ci-skip # temporary, there's one test failure (TODO: FIX)
 
 # need more than 4*65536 stack, see try_parse() in gen.cc line 11812
 LDFLAGS="-Wl,-z,stack-size=2097152"

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PR PATCH] [Updated] DRAFT: sagemath update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (13 preceding siblings ...)
  2022-10-13 14:03 ` tornaria
@ 2022-10-14 20:11 ` tornaria
  2022-10-16  1:52 ` tornaria
                   ` (17 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: tornaria @ 2022-10-14 20:11 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1883 bytes --]

There is an updated pull request by tornaria against master on the void-packages repository

https://github.com/tornaria/void-packages sagemath-update
https://github.com/void-linux/void-packages/pull/39876

DRAFT: sagemath update to 9.7
This includes #39838, #39840, #39846, #39872, #39866, also update eclib-20220621.

For now I'm reverting python3-matplotlib to 3.5.3_1 since 3.6.0_1 gives a lot of problems (#39857 adds python3-contourpy which will solve some, but I think there are more issues).

I want to make sure everything works ok and the full testsuite passes as is. Then I'll just move matplotlib back to 3.6.0_1 and try to see if it's feasible to fix or workaround the issues (sagemath-the-distro is still on matplotlib 3.5.2 and I didn't find anything about the update to 3.6.0)

<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: currently running the testsuite in --long after the update of singular.

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/39876.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-sagemath-update-39876.patch --]
[-- Type: text/x-diff, Size: 223572 bytes --]

From f3c5362b127a30ad192429af99691fa3c4a6da14 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 19:14:02 -0300
Subject: [PATCH 01/13] flintlib: update to 2.9.0.

---
 common/shlibs             | 2 +-
 srcpkgs/flintlib/template | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 925fea2868d9..e1f362c2c314 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4013,7 +4013,7 @@ libgtkdatabox.so.1 gtkdatabox3-1.0.0_1
 libxcvt.so.0 libxcvt-0.1.1_1
 libgf2x.so.3 gf2x-1.3.0_1
 libntl.so.44 ntl-11.5.1_1
-libflint.so.16 flintlib-2.8.0_1
+libflint.so.17 flintlib-2.9.0_1
 libarb.so.2 arb-2.20.0_1
 libec.so.8 eclib-20210625_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index 968dbcb525c2..27f202b4434c 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,6 +1,6 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.8.5
+version=2.9.0
 revision=1
 wrksrc="flint-${version}"
 build_style=configure
@@ -14,11 +14,10 @@ license="LGPL-2.1-or-later"
 homepage="https://flintlib.org"
 changelog="https://raw.githubusercontent.com/wbhart/flint2/trunk/NEWS"
 distfiles="https://flintlib.org/flint-${version}.tar.gz"
-checksum=5911fedff911100f15781f35e3a4fa934fe60e4aea02a8c10cc8918101c1eed8
+checksum=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
-build_options_default=""
 
 if [ -z "$CROSS_BUILD" ]; then
 	build_options_default+=" ntl"

From 0e1e5c30bf012930b44edff03a7d0b1af0bfd6b2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 19:16:18 -0300
Subject: [PATCH 02/13] arb: update to 2.23.0.

---
 srcpkgs/arb/template | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
index 52f11ef83c90..84a62c7ffdba 100644
--- a/srcpkgs/arb/template
+++ b/srcpkgs/arb/template
@@ -1,6 +1,6 @@
 # Template file for 'arb'
 pkgname=arb
-version=2.22.1
+version=2.23.0
 revision=1
 build_style=configure
 configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
@@ -11,9 +11,7 @@ license="LGPL-2.1-or-later"
 homepage="https://arblib.org"
 changelog="https://raw.githubusercontent.com/fredrik-johansson/arb/master/doc/source/history.rst"
 distfiles="https://github.com/fredrik-johansson/arb/archive/${version}.tar.gz"
-checksum=1ef85518eee04885e8a90196498bc75e4e2410621d4184f2bc01d46b7080a243
-
-CFLAGS="-D_GNU_SOURCE" # needed for cpu_set_t
+checksum=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
 
 arb-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"

From 565682aaf4321ac16f12e3e80c6ae869fb841fd3 Mon Sep 17 00:00:00 2001
From: dkwo <nicolopiazzalunga@gmail.com>
Date: Mon, 10 Oct 2022 10:14:06 -0400
Subject: [PATCH 03/13] singular: update to 4.3.1p2 (fix gcc 12 build)

---
 common/shlibs             | 10 +++++-----
 srcpkgs/singular/template | 26 ++++++++++++++------------
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index e1f362c2c314..427e0ef1c997 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4055,11 +4055,11 @@ libumfpack.so.5 SuiteSparse-5.10.1_1
 libecl.so.21.2 ecl-21.2.1_1
 libecm.so.1 ecm-7.0.4_3
 libcliquer.so.1 cliquer-1.22_1
-libSingular-4.3.0.so singular-4.3.0_1
-libfactory-4.3.0.so singular-4.3.0_1
-libpolys-4.3.0.so singular-4.3.0_1
-libomalloc-0.9.6.so singular-4.3.0_1
-libsingular_resources-4.3.0.so singular-4.3.0_1
+libSingular-4.3.1.so singular-4.3.1p2_1
+libfactory-4.3.1.so singular-4.3.1p2_1
+libpolys-4.3.1.so singular-4.3.1p2_1
+libomalloc-0.9.6.so singular-4.3.1p2_1
+libsingular_resources-4.3.1.so singular-4.3.1p2_1
 libbrial.so.3 brial-1.2.10_1
 libbrial_groebner.so.3 brial-1.2.10_1
 libm4ri-0.0.20200125.so m4ri-20200125_1
diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index f23659ef5d83..a30beef915d2 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,25 +1,27 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.0
+version=4.3.1p2
 revision=1
+_majver=${version%p*}
+wrksrc=singular-${_majver}
 build_style=gnu-configure
 configure_args="--with-readline=ncurses
-	--enable-gfanlib
-	--enable-Singular
-	--enable-factory
-	--disable-doc
-	--disable-polymake
-	--without-python
-	--with-libparse
-	ac_cv_lib_cddgmp_dd_free_global_constants=yes"
+ --enable-gfanlib
+ --enable-Singular
+ --enable-factory
+ --disable-doc
+ --disable-polymake
+ --without-python
+ --with-libparse
+ ac_cv_lib_cddgmp_dd_free_global_constants=yes"
 hostmakedepends="perl tar doxygen"
 makedepends="flintlib-devel cddlib-devel readline-devel graphviz"
 short_desc="Computer algebra system for polynomial computations"
-maintainer="dkwo <nicolopiazzalunga@gmail.com>"
+maintainer="dkwo <npiazza@disroot.org>"
 license="GPL-2.0-or-later"
 homepage="https://www.singular.uni-kl.de"
-distfiles="https://www.singular.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${version//./-}/singular-${version}.tar.gz"
-checksum=74f38288203720e3f280256f2f8deb94030dd032b4237d844652aff0faab36e7
+distfiles="https://www.singular.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${_majver//./-}/singular-${version}.tar.gz"
+checksum=95814bba0f0bd0290cd9799ec1d2ecc6f4c8a4e6429d9a02eb7f9c4e5649682a
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From 2c57e27f80b62452c5280304c97ad050f0a419f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 19:59:20 -0300
Subject: [PATCH 04/13] pari: update to 2.15.0.

---
 common/shlibs                      |  3 +-
 srcpkgs/pari/patches/float32.patch | 48 ++++++++++++++++++++++++++++++
 srcpkgs/pari/template              |  7 +++--
 3 files changed, 53 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/pari/patches/float32.patch

diff --git a/common/shlibs b/common/shlibs
index 427e0ef1c997..6289582d11a9 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4004,8 +4004,7 @@ libsimavrparts.so.1 simavr-1.6_2
 libsword-1.8.1.so libsword-1.8.1_6
 libgivaro.so.9 givaro-4.1.1_1
 liblinbox.so.0 linbox-1.6.3_1
-libpari-gmp.so.7 pari-2.13.0_1
-libpari-gmp-tls.so.7 pari-2.13.2_1
+libpari-gmp-tls.so.8 pari-2.15.0_1
 libtree-sitter.so.0 tree-sitter-0.19.0_1
 libplanarity.so.0 planarity-3.0.1.1_1
 libgap.so.0 gap-4.11.1_1
diff --git a/srcpkgs/pari/patches/float32.patch b/srcpkgs/pari/patches/float32.patch
new file mode 100644
index 000000000000..311dd6bf5a07
--- /dev/null
+++ b/srcpkgs/pari/patches/float32.patch
@@ -0,0 +1,48 @@
+Author: Gonzalo Tornaría <tornaria@cmat.edu.uy>
+Date:   Fri Oct 14 17:00:46 2022 -0300
+
+    Revert "x86 (32bit): force -mpc64 on compilers that supports it."
+    
+    This reverts commit ca61b6391cf95ac8af15669236e2ec5839d2ad91.
+
+
+This causes problems with floating point precision on i686:
+```
+$ cat exp40.c
+#include <math.h>
+#include <stdio.h>
+int main() {
+	volatile int a=40; /* do not optimize away the call to exp(a) */
+	printf("%f\n", exp(a));
+}
+$ cc -Wall exp40.c -lm && ./a.out
+235385266837020000.000000
+$ cc -Wall exp40.c -lm -mpc64 && ./a.out
+235385266837020448.000000
+```
+
+Note that when pari is built using -mpc64, just *linking* with -lpari
+causes the problem!!!
+```
+$ cc -Wall exp40.c -lm -lpari && ./a.out
+235385266837020448.000000
+```
+
+diff --git a/config/get_cc b/config/get_cc
+index 3cfaa88bb7..2d61d3871f 100644
+--- a/config/get_cc
++++ b/config/get_cc
+@@ -110,13 +110,6 @@ if test -n "$__gnuc__"; then
+   # Specific optimisations for some architectures
+   case "$arch" in
+     sparcv8*) cflags=-mv8;;
+-    i?86)
+-      cmd="$CC $CFLAGS $extraflag -mpc64 -fno-strict-aliasing -o $exe gnu.c"
+-      . log_cmd
+-      if test -s $exe; then
+-        cflags="-mpc64"
+-      fi
+-      . cleanup_exe;;
+   esac
+   # problems on some architectures
+   case "$osname" in
diff --git a/srcpkgs/pari/template b/srcpkgs/pari/template
index 8bac1e0343f8..873cddb4946f 100644
--- a/srcpkgs/pari/template
+++ b/srcpkgs/pari/template
@@ -1,6 +1,6 @@
 # Template file for 'pari'
 pkgname=pari
-version=2.13.4
+version=2.15.0
 revision=1
 build_style=configure
 build_helper=qemu
@@ -11,14 +11,15 @@ make_check_target=statest-all
 make_install_target="install install-lib-sta install-lib-dyn"
 hostmakedepends="perl texlive"
 makedepends="gmp-devel readline-devel $(vopt_if x11 libX11-devel)"
-checkdepends="pari-elldata-small pari-galdata pari-galpol-small pari-seadata-small"
+checkdepends="pari-elldata-small pari-galdata pari-galpol-small
+ pari-seadata-small pari-nflistdata"
 short_desc="Fast computations library in number theory"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="https://pari.math.u-bordeaux.fr"
 changelog="https://pari.math.u-bordeaux.fr/cgi-bin/gitweb.cgi?p=pari.git;a=blob_plain;f=CHANGES;hb=refs/heads/pari-${version%.*}"
 distfiles="https://pari.math.u-bordeaux.fr/pub/pari/unix/${pkgname}-${version}.tar.gz"
-checksum=bcde9eceae1592814381c1697cdb7063567b6504201b1be47bb58920f3bce185
+checksum=e474851e0d16d4e4f9a0d9612c746a2ae7c9a1ec185d04c440b1c74a85755685
 
 build_options="x11 pthreads"
 build_options_default="x11 pthreads"

From f66b531059ac5110413ff394e51e725acce57151 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 20:33:23 -0300
Subject: [PATCH 05/13] gp2c: update to 0.0.13.

---
 srcpkgs/gp2c/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gp2c/template b/srcpkgs/gp2c/template
index f82cf95c2d90..9cf0f6fdce6e 100644
--- a/srcpkgs/gp2c/template
+++ b/srcpkgs/gp2c/template
@@ -1,6 +1,6 @@
 # Template file for 'gp2c'
 pkgname=gp2c
-version=0.0.12pl1
+version=0.0.13
 revision=1
 build_style=gnu-configure
 hostmakedepends="perl"
@@ -12,4 +12,4 @@ license="GPL-2.0-or-later"
 homepage="http://pari.math.u-bordeaux.fr/"
 changelog="http://pari.math.u-bordeaux.fr/cgi-bin/gitweb.cgi?p=gp2c.git;a=blob_plain;f=ChangeLog;hb=HEAD"
 distfiles="${homepage}pub/pari/GP2C/${pkgname}-${version}.tar.gz"
-checksum=79a8c46f7ad3331e4d8ae6af6b496c4742fd73a73b996b3ca7ead61452ca6e8d
+checksum=261374eca73ebd76c112a9593dca28b64812aa762561fda5a4b2c2cd79a69d36

From 6bfa542f9cbd1fabdfde8c595a7235ba82cb69f6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Fri, 23 Sep 2022 16:42:40 -0300
Subject: [PATCH 06/13] eclib: update to 20221012.

---
 common/shlibs          | 2 +-
 srcpkgs/eclib/template | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 6289582d11a9..a1fb327ae755 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4014,7 +4014,7 @@ libgf2x.so.3 gf2x-1.3.0_1
 libntl.so.44 ntl-11.5.1_1
 libflint.so.17 flintlib-2.9.0_1
 libarb.so.2 arb-2.20.0_1
-libec.so.8 eclib-20210625_1
+libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
 liblrcalc.so.2 lrcalc-2.1_1
diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 694a39ed4068..31a3a01921fa 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
-version=20210625
-revision=2
+version=20221012
+revision=1
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 hostmakedepends="automake autoconf-archive libtool"
@@ -11,7 +11,7 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="https://github.com/JohnCremona/eclib"
 distfiles="https://github.com/JohnCremona/eclib/archive/refs/tags/${version}.tar.gz"
-checksum=00333fd36afd237c9e6e410c7ab98536ddcd7fdc430e6837fe293247b835c572
+checksum=bd6f0191876c1426ca57db851ce06ef79ea1755f01e81dd747358d1b76b5e932
 
 pre_configure() {
 	autoreconf -fi

From fb37bc9fa46f5656c45e30a0abebcbd6affe807c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:20 -0300
Subject: [PATCH 07/13] giac: update to 1.9.0.21.

---
 srcpkgs/giac/patches/giac-pari-2.15.patch | 20 ++++++++++++++++++++
 srcpkgs/giac/template                     |  4 ++--
 2 files changed, 22 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/giac/patches/giac-pari-2.15.patch

diff --git a/srcpkgs/giac/patches/giac-pari-2.15.patch b/srcpkgs/giac/patches/giac-pari-2.15.patch
new file mode 100644
index 000000000000..be409be38f53
--- /dev/null
+++ b/srcpkgs/giac/patches/giac-pari-2.15.patch
@@ -0,0 +1,20 @@
+ANYARG patch
+
+diff --git a/src/pari.cc b/src/pari.cc
+index 76ce8e1..50d08ab 100644
+--- a/src/pari.cc
++++ b/src/pari.cc
+@@ -40,6 +40,13 @@ using namespace std;
+ 
+ #ifdef HAVE_LIBPARI
+ 
++// Anyarg disappeared from PARI 2.15.0
++#ifdef __cplusplus
++#  define ANYARG ...
++#else
++#  define ANYARG
++#endif
++
+ #ifdef HAVE_PTHREAD_H
+ #include <pthread.h>
+ #endif
diff --git a/srcpkgs/giac/template b/srcpkgs/giac/template
index e892c8bf7506..31045e9128ee 100644
--- a/srcpkgs/giac/template
+++ b/srcpkgs/giac/template
@@ -1,6 +1,6 @@
 # Template file for 'giac'
 pkgname=giac
-version=1.9.0.7
+version=1.9.0.21
 revision=1
 wrksrc="giac-${version%.*}"
 build_style=gnu-configure
@@ -14,7 +14,7 @@ license="GPL-3.0-or-later"
 homepage="https://www-fourier.ujf-grenoble.fr/~parisse/giac.html"
 changelog="https://www-fourier.ujf-grenoble.fr/~parisse/install_en#new"
 distfiles="https://www-fourier.ujf-grenoble.fr/~parisse/debian/dists/stable/main/source/giac_${version%.*}-${version##*.}.tar.gz"
-checksum=72016988b7180e9b630ecabecc60969213e7b61418c2598c91acbaec139fd740
+checksum=120cd16f2e033817302d2a03a22bd413dc1d85df8b225ba4f76b93a7805b07fe
 
 # need more than 4*65536 stack, see try_parse() in gen.cc line 11812
 LDFLAGS="-Wl,-z,stack-size=2097152"

From 278e767ce9eff21ace57d23e4f345b01a7de6f83 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 12 Oct 2022 23:59:37 -0300
Subject: [PATCH 08/13] gap: update to 4.12.0.

---
 common/shlibs                          |  2 +-
 srcpkgs/gap/patches/c57a07a3.patch     | 23 +++++++++++++++++++++++
 srcpkgs/gap/patches/dce6fa96.patch     | 24 ++++++++++++++++++++++++
 srcpkgs/gap/patches/fix-atlasrep.patch | 11 +++++++++++
 srcpkgs/gap/template                   | 12 +++++-------
 5 files changed, 64 insertions(+), 8 deletions(-)
 create mode 100644 srcpkgs/gap/patches/c57a07a3.patch
 create mode 100644 srcpkgs/gap/patches/dce6fa96.patch
 create mode 100644 srcpkgs/gap/patches/fix-atlasrep.patch

diff --git a/common/shlibs b/common/shlibs
index a1fb327ae755..bbdcd9d98ba0 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4007,7 +4007,7 @@ liblinbox.so.0 linbox-1.6.3_1
 libpari-gmp-tls.so.8 pari-2.15.0_1
 libtree-sitter.so.0 tree-sitter-0.19.0_1
 libplanarity.so.0 planarity-3.0.1.1_1
-libgap.so.0 gap-4.11.1_1
+libgap.so.8 gap-4.12.0_1
 libgtkdatabox.so.1 gtkdatabox3-1.0.0_1
 libxcvt.so.0 libxcvt-0.1.1_1
 libgf2x.so.3 gf2x-1.3.0_1
diff --git a/srcpkgs/gap/patches/c57a07a3.patch b/srcpkgs/gap/patches/c57a07a3.patch
new file mode 100644
index 000000000000..27fd657666a6
--- /dev/null
+++ b/srcpkgs/gap/patches/c57a07a3.patch
@@ -0,0 +1,23 @@
+From c57a07a341e7bb713e74d60c259777b1a8645451 Mon Sep 17 00:00:00 2001
+From: Max Horn <max@quendi.de>
+Date: Fri, 7 Oct 2022 01:31:45 +0200
+Subject: [PATCH] Don't attempt to install the 'dev' manual...
+
+... as it is not contained in release tarballs!
+---
+ Makefile.rules | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile.rules b/Makefile.rules
+index d9dc2899df..de1dbc4823 100644
+--- a/Makefile.rules
++++ b/Makefile.rules
+@@ -597,7 +597,7 @@ install-doc:
+ 	# TODO: should this depend on the 'doc' target? but that target is phony
+ 	# and will re-run each time it is invoked, which is not really what we want.
+ 	$(INSTALL) -d -m 0755 $(DESTDIR)$(datarootdir)/gap/doc
+-	for book in ref tut hpc dev ; do \
++	for book in ref tut hpc ; do \
+ 		$(INSTALL) -d -m 0755 $(DESTDIR)$(datarootdir)/gap/doc/$$book ; \
+ 		for ext in css html js txt pdf six lab; do \
+ 			$(INSTALL) -m 0644  $(srcdir)/doc/$$book/*.$$ext $(DESTDIR)$(datarootdir)/gap/doc/$$book/ ; \
diff --git a/srcpkgs/gap/patches/dce6fa96.patch b/srcpkgs/gap/patches/dce6fa96.patch
new file mode 100644
index 000000000000..bc29c0eaaeb1
--- /dev/null
+++ b/srcpkgs/gap/patches/dce6fa96.patch
@@ -0,0 +1,24 @@
+From dce6fa9637a3c61c3a891cc809371eaa67a589c6 Mon Sep 17 00:00:00 2001
+From: Max Horn <max@quendi.de>
+Date: Sun, 2 Oct 2022 23:31:03 +0200
+Subject: [PATCH] kernel: if no GC is selected, default to GASMAN
+
+---
+ src/common.h | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/common.h b/src/common.h
+index e7c10b8d0b..95e6f3d609 100644
+--- a/src/common.h
++++ b/src/common.h
+@@ -35,6 +35,10 @@
+ // compiled with the wrong ABI
+ GAP_STATIC_ASSERT(sizeof(void *) == SIZEOF_VOID_P, "sizeof(void *) is wrong");
+ 
++// if no GC is selected explicitly, default to GASMAN
++#if !defined(USE_BOEHM_GC) && !defined(USE_JULIA_GC) && !defined(USE_GASMAN)
++#define USE_GASMAN 1
++#endif
+ 
+ // check for cygwin
+ #if defined(__CYGWIN__) || defined(__CYGWIN32__)
diff --git a/srcpkgs/gap/patches/fix-atlasrep.patch b/srcpkgs/gap/patches/fix-atlasrep.patch
new file mode 100644
index 000000000000..ccb9ae587d4b
--- /dev/null
+++ b/srcpkgs/gap/patches/fix-atlasrep.patch
@@ -0,0 +1,11 @@
+--- a/pkg/atlasrep/gap/access.gi.orig	2022-08-05 19:11:16.000000000 -0300
++++ b/pkg/atlasrep/gap/access.gi	2022-10-12 23:40:48.816642751 -0300
+@@ -3156,7 +3156,7 @@
+         uri:= url{ [ p .. Length( url ) ] };
+         body:= AtlasOfGroupRepresentationsTransferFile( domain, uri, fail,
+                                                         fail );
+-        if body = fail then
++        if body = false then
+           Info( InfoAtlasRep, 1,
+                 "AtlasOfGroupRepresentationsNotifyData:\n",
+                 "#I  cannot read '", url, "'" );
diff --git a/srcpkgs/gap/template b/srcpkgs/gap/template
index 7bc7d13ace20..88831e636c08 100644
--- a/srcpkgs/gap/template
+++ b/srcpkgs/gap/template
@@ -1,17 +1,17 @@
 # Template file for 'gap'
 pkgname=gap
-version=4.11.1
+version=4.12.0
 revision=1
 build_style=gnu-configure
-make_install_target="install-bin install-gaproot install-headers install-libgap"
 makedepends="gmp-devel zlib-devel readline-devel"
 checkdepends="perl"
 short_desc="Groups, Algorithms, Programming - computational discrete algebra"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="http://www.gap-system.org/"
+changelog="https://raw.githubusercontent.com/gap-system/gap/master/CHANGES.md"
 distfiles="https://github.com/gap-system/gap/releases/download/v${version}/gap-${version}.tar.gz"
-checksum=6635c5da7d82755f8339486b9cac33766f58712f297e8234fba40818902ea304
+checksum=6005d0c0316fe8803d84681f30be64eace83a9542f975f5cb3dedfadd4391849
 
 if [ "$XBPS_CHECK_PKGS" = full ]; then
 	# not sure about this -- takes about 25 minutes
@@ -21,10 +21,10 @@ fi
 _GAPROOT=/usr/share/gap/
 
 # minimal required packages
-_GAPPKGS="GAPDoc primgrp SmallGrp transgrp"
+_GAPPKGS="gapdoc primgrp smallgrp transgrp"
 
 # other expected packages
-_GAPPKGS+=" atlasrep autpgrp alnuth crisp ctbllib FactInt fga irredsol laguna
+_GAPPKGS+=" atlasrep autpgrp alnuth crisp ctbllib factint fga irredsol laguna
  polenta polycyclic resclasses sophus tomlib"
 
 post_install() {
@@ -33,8 +33,6 @@ post_install() {
 		[ -d pkg/$p ] || p="$p-*"
 		vcopy "pkg/$p" ${_GAPROOT}/pkg
 	done
-	# not handled by make install-headers
-	vcopy gen/config.h /usr/include/gap
 }
 
 gap-devel_package() {

From ba2b4973da78682764b5f9b8734e19f816eef63e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:19 -0300
Subject: [PATCH 09/13] lcalc: revbump for pari 2.15.0

---
 srcpkgs/lcalc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lcalc/template b/srcpkgs/lcalc/template
index 270078df9a54..3c6be5fcbc28 100644
--- a/srcpkgs/lcalc/template
+++ b/srcpkgs/lcalc/template
@@ -1,7 +1,7 @@
 # Template file for 'lcalc'
 pkgname=lcalc
 version=2.0.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--with-pari"
 hostmakedepends="automake libtool pkg-config gengetopt"

From 144b635fe74aa08c2f59e29746c41d9cd6f2ba50 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:21 -0300
Subject: [PATCH 10/13] python3-cysignals: revbump for pari 2.15.0

---
 srcpkgs/python3-cysignals/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/python3-cysignals/template b/srcpkgs/python3-cysignals/template
index 4655eead2a9c..08d1010976ff 100644
--- a/srcpkgs/python3-cysignals/template
+++ b/srcpkgs/python3-cysignals/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-cysignals'
 pkgname=python3-cysignals
 version=1.11.2
-revision=1
+revision=2
 wrksrc="cysignals-${version}"
 build_style=python3-module
 hostmakedepends="python3-setuptools python3-Cython autoconf"

From d00eca82bf5dba1b1d157f824e133c729e467417 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:58:16 -0300
Subject: [PATCH 11/13] python3-cypari2: revbump for pari 2.15.0

---
 srcpkgs/python3-cypari2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/python3-cypari2/template b/srcpkgs/python3-cypari2/template
index 9ded61101e8e..9db3070a087c 100644
--- a/srcpkgs/python3-cypari2/template
+++ b/srcpkgs/python3-cypari2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-cypari2'
 pkgname=python3-cypari2
 version=2.1.2
-revision=1
+revision=2
 wrksrc=cypari2-${version}
 build_style=python3-module
 hostmakedepends="python3-setuptools python3-Cython pari perl"

From 3dc72f24165d49482af0fb40c3ab71a38d659bf5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 00:49:01 -0300
Subject: [PATCH 12/13] sagemath: update to 9.7.

---
 .../patches/01-dont_link_ratpoints.patch      |   10 -
 ...2-fix_get_shared_lib_path--see_29644.patch |   13 -
 .../patches/03-doctest_have_program.patch     |   20 -
 .../patches/04-doctest_sage_getfile.patch     |   22 -
 .../patches/05-fix_sage_getfile.patch         |   16 -
 .../sagemath/patches/07-ignore_warning.patch  |   15 -
 .../08-dont_run_pytest--see_31924.patch       |   27 -
 ...y_slow_doctest-polynomial_zmod_flint.patch |   14 -
 ...ry_slow_doctest-isogeny_small_degree.patch |  106 -
 ...fix_very_slow_doctest-function_field.patch |   97 -
 srcpkgs/sagemath/patches/matplotlib-3.6.patch |   72 +
 srcpkgs/sagemath/patches/python-3.11.patch    |   45 +
 .../sagemath/patches/sagemath-pari-2.15.patch | 1750 +++++++++++++++++
 .../patches/sagemath-pari-2.15b.patch         |   29 +
 .../trac-31355-upgrade_lrcalc_to_2.1.patch    |  670 -------
 .../trac-33170-fix_doctest_ipython_8.patch    |   40 -
 .../trac-33170b-fix_doctest_ipython_8.1.patch |   13 -
 ...2ddd4e2dc92469c1590ebf0c40f8f69bf579.patch |  126 --
 ...2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch |   40 -
 .../trac-33336-fix_doctest_scipy_1.8.patch    |   19 -
 ...cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch |   53 +
 ...d9deaeaa6380ab2f0d50276d911233c00a04.patch |   99 -
 ...ff347454ac7f07e5918470b20e97b8f2357e.patch |   29 -
 ...0a0b14f67f4804e7113c3db41bbcf8a58296.patch |   26 -
 ...d4e56243c609f44afc1f21c112b026f9e1fe.patch |   42 +
 ...75f90d3bfd36758cb0e9d1ccbcd72f32d496.patch |  526 +++++
 ...1318f032caf8dc1c0de9489346d894409091.patch |   19 +
 .../zzz-loadable_module_extension.patch       |   14 -
 srcpkgs/sagemath/template                     |   12 +-
 29 files changed, 2542 insertions(+), 1422 deletions(-)
 delete mode 100644 srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
 delete mode 100644 srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
 delete mode 100644 srcpkgs/sagemath/patches/03-doctest_have_program.patch
 delete mode 100644 srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
 delete mode 100644 srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
 delete mode 100644 srcpkgs/sagemath/patches/07-ignore_warning.patch
 delete mode 100644 srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
 delete mode 100644 srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
 delete mode 100644 srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
 delete mode 100644 srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
 create mode 100644 srcpkgs/sagemath/patches/matplotlib-3.6.patch
 create mode 100644 srcpkgs/sagemath/patches/python-3.11.patch
 create mode 100644 srcpkgs/sagemath/patches/sagemath-pari-2.15.patch
 create mode 100644 srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
 delete mode 100644 srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch

diff --git a/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch b/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
deleted file mode 100644
index e5c3f5776aa2..000000000000
--- a/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
+++ /dev/null
@@ -1,10 +0,0 @@
- - do not link ratpoints where it's not used
-
---- a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
-+++ b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
-@@ -1,5 +1,3 @@
--# distutils: libraries = ratpoints
--
- r"""
- Descent on elliptic curves over `\QQ` with a 2-isogeny
- """
diff --git a/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch b/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
deleted file mode 100644
index d3672b094c1c..000000000000
--- a/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
+++ /dev/null
@@ -1,13 +0,0 @@
- - fix _get_shared_lib_path() so we don't need to configure GAP_SO
-
---- a/src/sage/env.py
-+++ b/src/sage/env.py
-@@ -293,7 +293,7 @@ def _get_shared_lib_path(*libnames: str) -> Optional[str]:
-             if sys.platform == 'darwin':
-                 ext = 'dylib'
-             else:
--                ext = 'so'
-+                ext = 'so*'
- 
-             if SAGE_LOCAL:
-                 search_directories.append(Path(SAGE_LOCAL) / 'lib')
diff --git a/srcpkgs/sagemath/patches/03-doctest_have_program.patch b/srcpkgs/sagemath/patches/03-doctest_have_program.patch
deleted file mode 100644
index 27ba3776470c..000000000000
--- a/srcpkgs/sagemath/patches/03-doctest_have_program.patch
+++ /dev/null
@@ -1,20 +0,0 @@
- - we don't know `SAGE_VENV/bin` contains `sage`, but `sys.argv[0]` should
-   be the full path to `sage-ipython` and the same directory should have `sage`
-
---- a/src/sage/misc/sage_ostools.pyx
-+++ b/src/sage/misc/sage_ostools.pyx
-@@ -32,12 +32,11 @@ def have_program(program, path=None):
-         True
-         sage: have_program('there_is_not_a_program_with_this_name')
-         False
--        sage: from sage.env import SAGE_VENV
--        sage: have_program('sage', os.path.join(SAGE_VENV, 'bin'))
-+        sage: have_program('sage', os.path.dirname(sys.argv[0]))
-         True
-         sage: have_program('sage', '/there_is_not_a_path_with_this_name')
-         False
--        sage: have_program('there_is_not_a_program_with_this_name', os.path.join(SAGE_VENV, 'bin'))
-+        sage: have_program('there_is_not_a_program_with_this_name', "/bin")
-         False
-     """
-     if path is None:
diff --git a/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch b/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
deleted file mode 100644
index 95bce107f854..000000000000
--- a/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
+++ /dev/null
@@ -1,22 +0,0 @@
- - add one doctest for coverage
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -1341,10 +1342,12 @@ def sage_getfile(obj):
-     EXAMPLES::
- 
-         sage: from sage.misc.sageinspect import sage_getfile
--        sage: sage_getfile(sage.rings.rational)[-23:]
--        'sage/rings/rational.pyx'
--        sage: sage_getfile(Sq)[-42:]
--        'sage/algebras/steenrod/steenrod_algebra.py'
-+        sage: sage_getfile(sage.rings.rational)
-+        '...sage/rings/rational.pyx'
-+        sage: sage_getfile(Sq)
-+        '...sage/algebras/steenrod/steenrod_algebra.py'
-+        sage: sage_getfile(x)
-+        '...sage/symbolic/expression.pyx'
- 
-     The following tests against some bugs fixed in :trac:`9976`::
- 
-
diff --git a/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch b/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
deleted file mode 100644
index 56c58078f319..000000000000
--- a/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
+++ /dev/null
@@ -1,16 +0,0 @@
- - fix sage_getfile() by checking all possible EXTENSION_SUFFIXES
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -1400,8 +1403,9 @@ def sage_getfile(obj):
-         sourcefile = inspect.getabsfile(obj)
-     except TypeError: # this happens for Python builtins
-         return ''
--    if sourcefile.endswith(loadable_module_extension()):
--        return sourcefile[:-len(loadable_module_extension())]+os.path.extsep+'pyx'
-+    for suffix in import_machinery.EXTENSION_SUFFIXES:
-+        if sourcefile.endswith(suffix):
-+            return sourcefile[:-len(suffix)]+os.path.extsep+'pyx'
-     return sourcefile
- 
- 
diff --git a/srcpkgs/sagemath/patches/07-ignore_warning.patch b/srcpkgs/sagemath/patches/07-ignore_warning.patch
deleted file mode 100644
index 69668678a40b..000000000000
--- a/srcpkgs/sagemath/patches/07-ignore_warning.patch
+++ /dev/null
@@ -1,15 +0,0 @@
- - this ignores a warning caused by old notebook
-
---- a/src/sage/all.py
-+++ b/src/sage/all.py
-@@ -100,6 +100,9 @@ warnings.filterwarnings('ignore', category=DeprecationWarning,
-                         message='The distutils(.sysconfig module| package) is deprecated',
-                         module='Cython|distutils|numpy|sage.env|sage.features')
- 
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"invalid escape sequence '\\s'")
-+
- ################ end setup warnings ###############################
- 
- 
-
diff --git a/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch b/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
deleted file mode 100644
index 06bd2ccae6fb..000000000000
--- a/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
+++ /dev/null
@@ -1,27 +0,0 @@
- - using pytest is broken, see #31924
-
---- a/src/bin/sage-runtests
-+++ b/src/bin/sage-runtests
-@@ -154,21 +154,4 @@ if __name__ == "__main__":
-     DC = DocTestController(args, args.filenames)
-     err = DC.run()
- 
--    try:
--        exit_code_pytest = 0
--        import pytest
--        pytest_options = ["--import-mode", "importlib"]
--        if args.verbose:
--            pytest_options.append("-v")
--        exit_code_pytest = pytest.main(pytest_options + args.filenames)
--        if exit_code_pytest == 5:
--            # Exit code 5 means there were no test files, pass in this case
--            exit_code_pytest = 0
--
--    except ModuleNotFoundError:
--        print("Pytest is not installed, skip checking tests that rely on it.")
--
--    if err == 0:
--        sys.exit(exit_code_pytest)
--    else:
--        sys.exit(err)
-+    sys.exit(err)
diff --git a/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch b/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
deleted file mode 100644
index bae8387cf94a..000000000000
--- a/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
-+++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
-@@ -237,8 +237,9 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
- 
-             sage: a = ZZ['x'](range(100000))
-             sage: R = Integers(3)['x']
--            sage: R(a)  # long time (7s on sage.math, 2013)
--            2*x^99998 + ... + x
-+            sage: p = R(a)
-+            sage: p.truncate(10)  # testing the whole poly is VERY SLOW
-+            2*x^8 + x^7 + 2*x^5 + x^4 + 2*x^2 + x
-         """
-         sig_on()
-         fmpz_poly_get_nmod_poly(&self.x, x)
diff --git a/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch b/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
deleted file mode 100644
index f3da5bbb555e..000000000000
--- a/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
+++ /dev/null
@@ -1,106 +0,0 @@
-diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-index 43727346269..9d3ccd475cd 100644
---- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-+++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-@@ -186,7 +186,7 @@ def Psi(l, use_stored=True):
-         sage: assert Psi(3, use_stored=True) == Psi(3, use_stored=False)
-         sage: assert Psi(5, use_stored=True) == Psi(5, use_stored=False)
-         sage: assert Psi(7, use_stored=True) == Psi(7, use_stored=False)
--        sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False) # not tested (very long time)
-+        sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False)  # long time (2s)
-     """
-     if l not in [2, 3, 5, 7, 13]:
-         raise ValueError("Genus zero primes are 2, 3, 5, 7 or 13.")
-@@ -1207,7 +1207,7 @@ def isogenies_13_0(E, minimal_models=True):
-         sage: K.<a> = NumberField(f)
-         sage: E = EllipticCurve(j=K(0)); E.ainvs()
-         (0, 0, 0, 0, 1)
--        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]
-+        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]  # long time (4s)
-         [(0,
-           0,
-           20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
-@@ -1325,7 +1325,7 @@ def isogenies_13_1728(E, minimal_models=True):
-         sage: f = x^12 + 1092*x^10 - 432432*x^8 + 6641024*x^6 - 282896640*x^4 - 149879808*x^2 - 349360128
-         sage: K.<a> = NumberField(f)
-         sage: E = EllipticCurve(K, [1,0])
--        sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]
-+        sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]  # long time (3s)
-         [(0,
-         0,
-         0,
-@@ -1550,8 +1550,11 @@ def Psi2(l):
-         sage: from sage.schemes.elliptic_curves.isogeny_small_degree import Psi2
-         sage: Psi2(11)
-         x^5 - 55*x^4*u + 994*x^3*u^2 - 8774*x^2*u^3 + 41453*x*u^4 - 928945/11*u^5 + 33*x^4 + 276*x^3*u - 7794*x^2*u^2 + 4452*x*u^3 + 1319331/11*u^4 + 216*x^3*v - 4536*x^2*u*v + 31752*x*u^2*v - 842616/11*u^3*v + 162*x^3 + 38718*x^2*u - 610578*x*u^2 + 33434694/11*u^3 - 4536*x^2*v + 73872*x*u*v - 2745576/11*u^2*v - 16470*x^2 + 580068*x*u - 67821354/11*u^2 - 185976*x*v + 14143896/11*u*v + 7533*x - 20437029/11*u - 12389112/11*v + 19964151/11
--        sage: Psi2(71)  # long time (1 second)
--        -2209380711722505179506258739515288584116147237393815266468076436521/71*u^210 + ... - 14790739586438315394567393301990769678157425619440464678252277649/71
-+        sage: f = Psi2(71)
-+        sage: f.coefficient([0, 210, 0])
-+        -2209380711722505179506258739515288584116147237393815266468076436521/71
-+        sage: f.coefficient([0, 0, 0])
-+        -14790739586438315394567393301990769678157425619440464678252277649/71
- 
-     TESTS::
- 
-@@ -1665,17 +1668,17 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True):
-         sage: K = QuadraticField(5,'a')
-         sage: a = K.gen()
-         sage: E = EllipticCurve_from_j(184068066743177379840*a - 411588709724712960000)
--        sage: isogenies_prime_degree_genus_plus_0(E, 47) # long time (4.3s)
-+        sage: isogenies_prime_degree_genus_plus_0(E, 47)  # long time (2s)
-         [Isogeny of degree 47 from Elliptic Curve defined by y^2 = x^3 + (454562028554080355857852049849975895490560*a-1016431595837124114668689286176511361024000)*x + (-249456798429896080881440540950393713303830363999480904280965120*a+557802358738710443451273320227578156598454035482869042774016000) over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790? to Elliptic Curve defined by y^2 = x^3 + (39533118442361013730577638493616965245992960*a-88398740199669828340617478832005245173760000)*x + (214030321479466610282320528611562368963830105830555363061803253760*a-478586348074220699687616322532666163722004497458452316582576128000) over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790?]
- 
-         sage: K = QuadraticField(-66827,'a')
-         sage: a = K.gen()
-         sage: E = EllipticCurve_from_j(-98669236224000*a + 4401720074240000)
--        sage: isogenies_prime_degree_genus_plus_0(E, 59)   # long time (25s, 2012)
-+        sage: isogenies_prime_degree_genus_plus_0(E, 59)   # long time (5s)
-         [Isogeny of degree 59 from Elliptic Curve defined by y^2 = x^3 + (2605886146782144762297974784000*a+1893681048912773634944634716160000)*x + (-116918454256410782232296183198067568744071168000*a+17012043538294664027185882358514011304812871680000) over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I to Elliptic Curve defined by y^2 = x^3 + (-19387084027159786821400775098368000*a-4882059104868154225052787156713472000)*x + (-25659862010101415428713331477227179429538847260672000*a-2596038148441293485938798119003462972840818381946880000) over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I]
- 
-         sage: E = EllipticCurve_from_j(GF(13)(5))
--        sage: isogenies_prime_degree_genus_plus_0(E, 71) # long time
-+        sage: isogenies_prime_degree_genus_plus_0(E, 71)
-         [Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13, Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13]
- 
-         sage: E = EllipticCurve(GF(13),[0,1,1,1,0])
-@@ -2117,11 +2120,11 @@ def isogenies_prime_degree_general(E, l, minimal_models=True):
-         sage: isogenies_prime_degree_general(E, 19)
-         [Isogeny of degree 19 from Elliptic Curve defined by y^2 + y = x^3 - 1862*x - 30956 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - 672182*x + 212325489 over Rational Field]
-         sage: E = EllipticCurve([0, -1, 0, -6288, 211072])
--        sage: isogenies_prime_degree_general(E, 37)  # long time (10s)
-+        sage: isogenies_prime_degree_general(E, 37)  # long time (2s)
-         [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 - x^2 - 6288*x + 211072 over Rational Field to Elliptic Curve defined by y^2 = x^3 - x^2 - 163137088*x - 801950801728 over Rational Field]
- 
-         sage: E = EllipticCurve([-3440, 77658])
--        sage: isogenies_prime_degree_general(E, 43)  # long time (16s)
-+        sage: isogenies_prime_degree_general(E, 43)  # long time (2s)
-         [Isogeny of degree 43 from Elliptic Curve defined by y^2 = x^3 - 3440*x + 77658 over Rational Field to Elliptic Curve defined by y^2 = x^3 - 6360560*x - 6174354606 over Rational Field]
- 
-     Isogenies of degree equal to the characteristic are computed (but
-@@ -2175,7 +2178,7 @@ def isogenies_prime_degree_general(E, l, minimal_models=True):
- 
-         sage: K.<i> = QuadraticField(-1)
-         sage: E = EllipticCurve(K,[0,0,0,1,0])
--        sage: [phi.codomain().ainvs() for phi in E.isogenies_prime_degree(37)] # long time
-+        sage: [phi.codomain().ainvs() for phi in E.isogenies_prime_degree(37)]  # long time (6s)
-         [(0, 0, 0, -840*i + 1081, 0), (0, 0, 0, 840*i + 1081, 0)]
-     """
-     if not l.is_prime():
-@@ -2329,14 +2332,14 @@ def isogenies_prime_degree(E, l, minimal_models=True):
-         sage: E = EllipticCurve(GF(101), [-3440, 77658])
-         sage: E.isogenies_prime_degree(71) # fast
-         []
--        sage: E.isogenies_prime_degree(73) # slower (2s)
-+        sage: E.isogenies_prime_degree(73)  # long time (2s)
-         []
- 
-     Test that :trac:`32269` is fixed::
- 
-         sage: K = QuadraticField(-11)
-         sage: E = EllipticCurve(K, [0,1,0,-117,-541])
--        sage: E.isogenies_prime_degree(37)
-+        sage: E.isogenies_prime_degree(37)  # long time (9s)
-         [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I to Elliptic Curve defined by y^2 = x^3 + x^2 + (30800*a+123963)*x + (3931312*a-21805005) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I,
-          Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I to Elliptic Curve defined by y^2 = x^3 + x^2 + (-30800*a+123963)*x + (-3931312*a-21805005) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I]
- 
diff --git a/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch b/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
deleted file mode 100644
index 3b7b1ea843df..000000000000
--- a/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
+++ /dev/null
@@ -1,97 +0,0 @@
---- a/src/sage/rings/function_field/function_field.py
-+++ b/src/sage/rings/function_field/function_field.py
-@@ -111,22 +111,21 @@ Function fields over the algebraic field are supported::
-     sage: m = L.completion(pl, prec=5)
-     sage: m(x)
-     I + s + O(s^5)
--    sage: m(y)
-+    sage: m(y)                             # long time (4s)
-     -2*s + (-4 - I)*s^2 + (-15 - 4*I)*s^3 + (-75 - 23*I)*s^4 + (-413 - 154*I)*s^5 + O(s^6)
--    sage: m(y)^2 + m(y) + m(x) + 1/m(x)
-+    sage: m(y)^2 + m(y) + m(x) + 1/m(x)    # long time (8s)
-     O(s^5)
- 
- TESTS::
- 
-     sage: TestSuite(J).run()
--    sage: TestSuite(K).run(max_runs=1024) # long time (5s)
--    sage: TestSuite(L).run(max_runs=64)   # long time (10s)
--    sage: TestSuite(M).run(max_runs=32)   # long time (30s)
--    sage: TestSuite(N).run(max_runs=64, skip = '_test_derivation')  # long time (8s)
--    sage: TestSuite(O).run(max_runs=128, skip = '_test_derivation') # long time (8s)
--
-+    sage: TestSuite(K).run(max_runs=256)   # long time (10s)
-+    sage: TestSuite(L).run(max_runs=8)     # long time (25s)
-+    sage: TestSuite(M).run(max_runs=8)     # long time (35s)
-+    sage: TestSuite(N).run(max_runs=8, skip = '_test_derivation')    # long time (15s)
-+    sage: TestSuite(O).run()
-     sage: TestSuite(R).run()
--    sage: TestSuite(S).run() # long time (3s)
-+    sage: TestSuite(S).run()               # long time (4s)
- 
- Global function fields
- ----------------------
-@@ -287,7 +286,7 @@ class FunctionField(Field):
-         TESTS::
- 
-             sage: K.<x> = FunctionField(QQ)
--            sage: TestSuite(K).run()
-+            sage: TestSuite(K).run()               # long time (3s)
-         """
-         Field.__init__(self, base_field, names=names, category=category)
- 
-@@ -729,7 +728,7 @@ class FunctionField(Field):
-         EXAMPLES::
- 
-             sage: K.<x> = FunctionField(QQ)
--            sage: TestSuite(K).run() # indirect doctest
-+            sage: TestSuite(K).run()    # indirect doctest, long time (3s)
-         """
-         tester = self._tester(**options)
-         S = tester.some_elements()
-@@ -1209,7 +1208,7 @@ class FunctionField_polymod(FunctionField):
-             sage: K.<x> = FunctionField(QQ); R.<y> = K[]
-             sage: L = K.extension(y^5 - x^3 - 3*x + x*y); L
-             Function field in y defined by y^5 + x*y - x^3 - 3*x
--            sage: TestSuite(L).run()  # long time
-+            sage: TestSuite(L).run(max_runs=512)   # long time (15s)
- 
-         We can set the variable name, which doesn't have to be y::
- 
-@@ -2888,7 +2887,8 @@ class FunctionField_simple(FunctionField_polymod):
-             sage: F.<y> = K.extension(Y^3 - x^2*(x^2 + x + 1)^2)
-             sage: O = K.maximal_order()
-             sage: pls = [O.ideal(x-QQbar(sqrt(c))).place() for c in [-2, -1, 0, 1, 2]]
--            sage: all(q.place_below() == p for p in pls for q in F.places_above(p))
-+            sage: all(q.place_below() == p         # long time (4s)
-+            ....:     for p in pls for q in F.places_above(p))
-             True
-         """
-         R = self.base_field()
-@@ -3091,7 +3091,7 @@ class FunctionField_global(FunctionField_simple):
- 
-         sage: K.<x> = FunctionField(GF(4)); _.<Y> = K[]
-         sage: L.<y> = K.extension((1 - x)*Y^7 - x^3)
--        sage: L.gaps()
-+        sage: L.gaps()                         # long time (6s)
-         [1, 2, 3]
- 
-     or may define a trivial extension::
-@@ -3111,7 +3111,7 @@ class FunctionField_global(FunctionField_simple):
- 
-             sage: K.<x> = FunctionField(GF(5)); _.<Y> = K[]
-             sage: L.<y> = K.extension(Y^3 - (x^3 - 1)/(x^3 - 2))
--            sage: TestSuite(L).run()
-+            sage: TestSuite(L).run()               # long time (7s)
-         """
-         FunctionField_polymod.__init__(self, polynomial, names)
- 
-@@ -3807,7 +3807,7 @@ class RationalFunctionField(FunctionField):
- 
-             sage: K.<t> = FunctionField(CC); K
-             Rational function field in t over Complex Field with 53 bits of precision
--            sage: TestSuite(K).run()
-+            sage: TestSuite(K).run()               # long time (5s)
- 
-             sage: FunctionField(QQ[I], 'alpha')
-             Rational function field in alpha over Number Field in I with defining polynomial x^2 + 1 with I = 1*I
diff --git a/srcpkgs/sagemath/patches/matplotlib-3.6.patch b/srcpkgs/sagemath/patches/matplotlib-3.6.patch
new file mode 100644
index 000000000000..6afaf1b7162f
--- /dev/null
+++ b/srcpkgs/sagemath/patches/matplotlib-3.6.patch
@@ -0,0 +1,72 @@
+commit 5501e0de0dca1cff0355326dd42bd8c7e5749568
+Author: Gonzalo Tornaría <tornaria@cmat.edu.uy>
+Date:   Tue Oct 11 17:25:04 2022 -0300
+
+    Support matplotlib 3.6
+
+diff --git a/src/sage/plot/arc.py b/src/sage/plot/arc.py
+index bb834763afc..f65973bcbd5 100644
+--- a/src/sage/plot/arc.py
++++ b/src/sage/plot/arc.py
+@@ -273,9 +273,9 @@ class Arc(GraphicPrimitive):
+         p = patches.Arc((self.x, self.y),
+                         2. * self.r1,
+                         2. * self.r2,
+-                        fmod(self.angle, 2 * pi) * (180. / pi),
+-                        self.s1 * (180. / pi),
+-                        self.s2 * (180. / pi))
++                        angle=fmod(self.angle, 2 * pi) * (180. / pi),
++                        theta1=self.s1 * (180. / pi),
++                        theta2=self.s2 * (180. / pi))
+         return p
+ 
+     def bezier_path(self):
+diff --git a/src/sage/plot/ellipse.py b/src/sage/plot/ellipse.py
+index a77e6fe640a..c35bed574ef 100644
+--- a/src/sage/plot/ellipse.py
++++ b/src/sage/plot/ellipse.py
+@@ -192,7 +192,8 @@ class Ellipse(GraphicPrimitive):
+         options = self.options()
+         p = patches.Ellipse(
+                 (self.x,self.y),
+-                self.r1*2.,self.r2*2.,self.angle/pi*180.)
++                self.r1*2.,self.r2*2.,
++                angle=self.angle/pi*180.)
+         p.set_linewidth(float(options['thickness']))
+         p.set_fill(options['fill'])
+         a = float(options['alpha'])
+diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
+index e779e1210e3..8d620b5c625 100644
+--- a/src/sage/plot/graphics.py
++++ b/src/sage/plot/graphics.py
+@@ -2007,7 +2007,7 @@ class Graphics(WithEqualityById, SageObject):
+         We can also do custom formatting if you need it.  See above for full
+         details::
+ 
+-            sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex")
++            sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex") # not tested (broken with matplotlib 3.6)
+             Graphics object consisting of 1 graphics primitive
+ 
+         This is particularly useful when setting custom ticks in multiples
+@@ -2341,7 +2341,7 @@ class Graphics(WithEqualityById, SageObject):
+             sage: subplot = Figure().add_subplot(111)
+             sage: p._objects[0]._render_on_subplot(subplot)
+             sage: p._matplotlib_tick_formatter(subplot, **d)
+-            (<AxesSubplot:>,
++            (<AxesSubplot:...>,
+             <matplotlib.ticker.MaxNLocator object at ...>,
+             <matplotlib.ticker.MaxNLocator object at ...>,
+             <matplotlib.ticker.ScalarFormatter object at ...>,
+diff --git a/src/sage/plot/plot.py b/src/sage/plot/plot.py
+index b36ee57227c..5301a05c3dc 100644
+--- a/src/sage/plot/plot.py
++++ b/src/sage/plot/plot.py
+@@ -1741,7 +1741,7 @@ def plot(funcs, *args, **kwds):
+ 
+     ::
+ 
+-        sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex")
++        sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex") # not tested (broken with matplotlib 3.6)
+         Graphics object consisting of 1 graphics primitive
+ 
+     .. PLOT::
diff --git a/srcpkgs/sagemath/patches/python-3.11.patch b/srcpkgs/sagemath/patches/python-3.11.patch
new file mode 100644
index 000000000000..eafe76bfb794
--- /dev/null
+++ b/srcpkgs/sagemath/patches/python-3.11.patch
@@ -0,0 +1,45 @@
+--- a/src/sage/cpython/cython_metaclass.h
++++ b/src/sage/cpython/cython_metaclass.h
+@@ -66,7 +66,7 @@
+         }
+ 
+         /* Now, set t.__class__ to metaclass */
+-        Py_TYPE(t) = metaclass;
++        Py_SET_TYPE(t, metaclass);
+         PyType_Modified(t);
+     }
+     else
+--- a/src/sage/symbolic/ginac/numeric.cpp
++++ b/src/sage/symbolic/ginac/numeric.cpp
+@@ -52,7 +52,6 @@
+ #define register
+ #define PY_SSIZE_T_CLEAN
+ #include <Python.h>
+-#include <longintrepr.h>
+ #include "flint/fmpz.h"
+ #include "flint/fmpz_factor.h"
+ 
+--- a/src/sage/libs/gmp/pylong.pyx
++++ b/src/sage/libs/gmp/pylong.pyx
+@@ -32,7 +32,7 @@
+ from .mpz cimport *
+ 
+ cdef extern from *:
+-    Py_ssize_t* Py_SIZE_PTR "&Py_SIZE"(object)
++    void Py_SET_SIZE(object, Py_ssize_t)
+     int hash_bits """
+         #ifdef _PyHASH_BITS
+         _PyHASH_BITS         /* Python 3 */
+@@ -57,10 +57,8 @@
+     mpz_export(L.ob_digit, NULL,
+             -1, sizeof(digit), 0, PyLong_nails, z)
+     if mpz_sgn(z) < 0:
+-        # Set correct size (use a pointer to hack around Cython's
+-        # non-support for lvalues).
+-        sizeptr = Py_SIZE_PTR(L)
+-        sizeptr[0] = -pylong_size
++        # Set correct size
++        Py_SET_SIZE(L, -pylong_size)
+     return L
+ 
+ 
diff --git a/srcpkgs/sagemath/patches/sagemath-pari-2.15.patch b/srcpkgs/sagemath/patches/sagemath-pari-2.15.patch
new file mode 100644
index 000000000000..ccafad5070c4
--- /dev/null
+++ b/srcpkgs/sagemath/patches/sagemath-pari-2.15.patch
@@ -0,0 +1,1750 @@
+diff --git a/build/pkgs/giac/patches/pari_2_15.patch b/build/pkgs/giac/patches/pari_2_15.patch
+new file mode 100644
+index 0000000000..d2900a5ffc
+--- /dev/null
++++ b/build/pkgs/giac/patches/pari_2_15.patch
+@@ -0,0 +1,21 @@
++ANYARG patch
++
++diff --git a/src/pari.cc b/src/pari.cc
++index 76ce8e1..50d08ab 100644
++--- a/src/pari.cc
+++++ b/src/pari.cc
++@@ -40,6 +40,13 @@ using namespace std;
++ 
++ #ifdef HAVE_LIBPARI
++ 
+++// Anyarg disappeared from PARI 2.15.0
+++#ifdef __cplusplus
+++#  define ANYARG ...
+++#else
+++#  define ANYARG
+++#endif
+++
++ #ifdef HAVE_PTHREAD_H
++ #include <pthread.h>
++ #endif
++
+diff --git a/build/pkgs/pari/checksums.ini b/build/pkgs/pari/checksums.ini
+index b736feed31..bafd0f36f4 100644
+--- a/build/pkgs/pari/checksums.ini
++++ b/build/pkgs/pari/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=pari-VERSION.tar.gz
+-sha1=e01647aab7e96a8cb4922cf26a4f224337c6647f
+-md5=922f740fcdf8630b30d63dc76b58f756
+-cksum=297133525
++sha1=cba9b279f67d5efe2fbbccf3be6e9725f816cf07
++md5=76d430f1bea1b07fa2ad9712deeaa736
++cksum=1990743897
+ upstream_url=https://pari.math.u-bordeaux.fr/pub/pari/unix/pari-VERSION.tar.gz
+diff --git a/build/pkgs/pari/package-version.txt b/build/pkgs/pari/package-version.txt
+index a1a4224dd5..68e69e405e 100644
+--- a/build/pkgs/pari/package-version.txt
++++ b/build/pkgs/pari/package-version.txt
+@@ -1 +1 @@
+-2.13.3
++2.15.0
+diff --git a/src/doc/de/tutorial/tour_numtheory.rst b/src/doc/de/tutorial/tour_numtheory.rst
+index a012234c99..e3149fe949 100644
+--- a/src/doc/de/tutorial/tour_numtheory.rst
++++ b/src/doc/de/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ implementiert.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/en/tutorial/tour_numtheory.rst b/src/doc/en/tutorial/tour_numtheory.rst
+index 3064d100e2..075e0ac0ad 100644
+--- a/src/doc/en/tutorial/tour_numtheory.rst
++++ b/src/doc/en/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ NumberField class.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/es/tutorial/tour_numtheory.rst b/src/doc/es/tutorial/tour_numtheory.rst
+index a1f7d1a87b..48e5376cfe 100644
+--- a/src/doc/es/tutorial/tour_numtheory.rst
++++ b/src/doc/es/tutorial/tour_numtheory.rst
+@@ -140,7 +140,7 @@ Varios métodos relacionados están implementados en la clase ``NumberField``::
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/fr/tutorial/tour_numtheory.rst b/src/doc/fr/tutorial/tour_numtheory.rst
+index 871092f5fa..d1b2fee883 100644
+--- a/src/doc/fr/tutorial/tour_numtheory.rst
++++ b/src/doc/fr/tutorial/tour_numtheory.rst
+@@ -159,7 +159,7 @@ dans la classe NumberField.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/ja/tutorial/tour_numtheory.rst b/src/doc/ja/tutorial/tour_numtheory.rst
+index 47af68c862..4d4ed52d50 100644
+--- a/src/doc/ja/tutorial/tour_numtheory.rst
++++ b/src/doc/ja/tutorial/tour_numtheory.rst
+@@ -161,7 +161,7 @@ Sageには :math:`p` \-進数体も組込まれている.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/pt/tutorial/tour_numtheory.rst b/src/doc/pt/tutorial/tour_numtheory.rst
+index 6371b491ea..a3dc973a93 100644
+--- a/src/doc/pt/tutorial/tour_numtheory.rst
++++ b/src/doc/pt/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ NumberField.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus 
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/ru/tutorial/tour_numtheory.rst b/src/doc/ru/tutorial/tour_numtheory.rst
+index 652abfbc99..a985d49fbd 100644
+--- a/src/doc/ru/tutorial/tour_numtheory.rst
++++ b/src/doc/ru/tutorial/tour_numtheory.rst
+@@ -150,7 +150,7 @@ Sage содержит стандартные функции теории чис
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py
+index e57076646f..fec75d07c1 100644
+--- a/src/sage/arith/misc.py
++++ b/src/sage/arith/misc.py
+@@ -1465,13 +1465,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)]
++        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::
+ 
+@@ -2569,7 +2569,7 @@ def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds):
+ 
+         sage: K.<i> = QuadraticField(-1)
+         sage: factor(122 - 454*i)
+-        (-3*i - 2) * (-i - 2)^3 * (i + 1)^3 * (i + 4)
++        (-i) * (-i - 2)^3 * (i + 1)^3 * (-2*i + 3) * (i + 4)
+ 
+     To access the data in a factorization::
+ 
+diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
+index cdfc11a9e5..b6e1280d6e 100644
+--- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
++++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
+@@ -7825,9 +7825,9 @@ class DynamicalSystem_projective_field(DynamicalSystem_projective,
+             sage: f = DynamicalSystem_projective([x^2 + QQbar(sqrt(3))*y^2, y^2, QQbar(sqrt(2))*z^2])
+             sage: f.reduce_base_field()
+             Dynamical System of Projective Space of dimension 2 over Number Field in a with
+-            defining polynomial y^4 - 4*y^2 + 1 with a = 1.931851652578137?
++            defining polynomial y^4 - 4*y^2 + 1 with a = -0.5176380902050415?
+               Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x^2 + (a^2 - 2)*y^2 : y^2 : (a^3 - 3*a)*z^2)
++                    (x^2 + (-a^2 + 2)*y^2 : y^2 : (a^3 - 3*a)*z^2)
+ 
+         ::
+ 
+diff --git a/src/sage/ext_data/pari/simon/ellQ.gp b/src/sage/ext_data/pari/simon/ellQ.gp
+index 420af8f6a2..65e8386779 100644
+--- a/src/sage/ext_data/pari/simon/ellQ.gp
++++ b/src/sage/ext_data/pari/simon/ellQ.gp
+@@ -40,7 +40,7 @@
+   gp > \r ellcommon.gp
+   gp > \r ellQ.gp
+ 
+-  The main function is ellrank(), which takes as an argument
++  The main function is ellQ_ellrank(), which takes as an argument
+   any elliptic curve in the form [a1,a2,a3,a4,a6]
+   the result is a vector [r,s,v], where
+     r is a lower bound for the rank,
+@@ -50,7 +50,7 @@
+   Example:
+ 
+   gp > ell = [1,2,3,4,5];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+   %1 = [1, 1, [[1,2]]
+   In this example, the rank is exactly 1, and [1,2] has infinite order.
+ 
+@@ -92,7 +92,7 @@
+   \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+ 
+   Explications succintes :
+-  La fonction ellrank() accepte toutes les courbes sous la forme
++  La fonction ellQ_ellrank() accepte toutes les courbes sous la forme
+   [a1,a2,a3,a4,a6]
+   Les coefficients peuvent etre entiers ou non.
+   L'algorithme utilise est celui de la 2-descente.
+@@ -100,7 +100,7 @@
+   Il suffit de taper : 
+ 
+   gp > ell = [a1,a2,a3,a4,a6];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+ 
+   Retourne un vecteur [r,s,v] ou
+     r est le rang probable (c'est toujours une minoration du rang),
+@@ -110,7 +110,7 @@
+   Exemple :
+ 
+   gp > ell = [1,2,3,4,5];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+   %1 = [1, 1, [[1,2]]
+   Ici, le rang est exactement 1, et le point [1,2] est d'ordre infini.
+ 
+@@ -1571,12 +1571,12 @@ if( DEBUGLEVEL_ell >= 4, print("    end of ell2descent_gen"));
+     print("rank(E/Q)    >= ",m1)
+   );
+ }
+-{ellrank(ell,help=[]) =
++{ellQ_ellrank(ell,help=[]) =
+ \\ Algorithm of 2-descent on the elliptic curve ell.
+ \\ help is a list of known points on ell.
+ my(urst,urst1,den,eqell,tors2,bnf,rang,time1);
+ 
+-if( DEBUGLEVEL_ell >= 3, print("   starting ellrank"));
++if( DEBUGLEVEL_ell >= 3, print("   starting ellQ_ellrank"));
+   if( #ell < 13, ell = ellinit(ell));
+ 
+ \\ kill the coefficients a1 and a3
+@@ -1630,7 +1630,7 @@ if( DEBUGLEVEL_ell >= 1, print(" Elliptic curve: Y^2 = ",eqell));
+   ));
+ 
+   rang[3] = ellchangepoint(rang[3],ellinverturst(urst));
+-if( DEBUGLEVEL_ell >= 3, print("   end of ellrank"));
++if( DEBUGLEVEL_ell >= 3, print("   end of ellQ_ellrank"));
+ 
+   return(rang);
+ }
+@@ -2106,13 +2106,13 @@ if( DEBUGLEVEL_ell >= 3, print("   end of ell2descent_viaisog"));
+ {
+ \\                  functions for elliptic curves
+   addhelp(ell2descent_complete,
+-    "ell2descent_complete(e1,e2,e3): Performs a complete 2-descent on the elliptic curve y^2 = (x-e1)*(x-e2)*(x-e3). See ?ellrank for the format of the output.");
++    "ell2descent_complete(e1,e2,e3): Performs a complete 2-descent on the elliptic curve y^2 = (x-e1)*(x-e2)*(x-e3). See ?ellQ_ellrank for the format of the output.");
+   addhelp(ell2descent_gen,
+-    "ell2descent_gen((E,bnf,k=1,help=[]): E is a vector of the form [0,A,0,B,C], (or the result of ellinit of such a vector) A,B,C integers such that x^3+A*x^2+B*x+C; bnf is the corresponding bnfinit(,1); Performs 2-descent on the elliptic curve Ek: k*y^2=x^3+A*x^2+B*x+C. See ?ellrank for the format of the output.");
++    "ell2descent_gen((E,bnf,k=1,help=[]): E is a vector of the form [0,A,0,B,C], (or the result of ellinit of such a vector) A,B,C integers such that x^3+A*x^2+B*x+C; bnf is the corresponding bnfinit(,1); Performs 2-descent on the elliptic curve Ek: k*y^2=x^3+A*x^2+B*x+C. See ?ellQ_ellrank for the format of the output.");
+   addhelp(ell2descent_viaisog,
+-    "ell2descent_viaisog(E,help=[]): E is an elliptic curve of the form [0,a,0,b,0], with a, b integers. Performs a 2-descent via isogeny on E. See ?ellrank for the format of the output.");
+-  addhelp(ellrank,
+-    "ellrank(E,help=[]): E is any elliptic curve defined over Q. Returns a vector [r,s,v], where r is a lower bound for the rank of E, s is the rank of its 2-Selmer group and v is a list of independant points in E(Q)/2E(Q). If help is a vector of nontrivial points on E, the result might be faster. This function might be used in conjunction with elltors2(E). See also ?default_ellQ");
++    "ell2descent_viaisog(E,help=[]): E is an elliptic curve of the form [0,a,0,b,0], with a, b integers. Performs a 2-descent via isogeny on E. See ?ellQ_ellrank for the format of the output.");
++  addhelp(ellQ_ellrank,
++    "ellQ_ellrank(E,help=[]): E is any elliptic curve defined over Q. Returns a vector [r,s,v], where r is a lower bound for the rank of E, s is the rank of its 2-Selmer group and v is a list of independant points in E(Q)/2E(Q). If help is a vector of nontrivial points on E, the result might be faster. This function might be used in conjunction with elltors2(E). See also ?default_ellQ");
+   addhelp(ellhalf,
+     "ellhalf(E,P): returns the vector of all points Q on the elliptic curve E such that 2Q = P");
+   addhelp(ellredgen,
+@@ -2143,7 +2143,7 @@ if( DEBUGLEVEL_ell >= 3, print("   end of ell2descent_viaisog"));
+ 
+ \\                  others
+   addhelp(default_ellQ,
+-    "default_ellQ(DEBUGLEVEL_ell, LIM1, LIM3, LIMTRIV, ELLREDGENFLAG, COMPLETE, MAXPROB, LIMBIGPRIME): set the value of the global variables used for ellrank() and other related functions. DEBUGLEVEL_ell: 0-5: choose the quantity of information printed during the computation (default=0: print nothing); LIM1 (resp LIM3): search limit for easy (resp hard) points on quartics; LIMTRIV: search limit for trivial points on elliptic curves; ELLREDGENFLAG: if != 0, try to reduce the generators at the end; COMPLETE: if != 0 and full 2-torsion, use complete 2-descent, otherwise via 2-isogeny; MAXPROB, LIMBIGPRIME: technical.");
++    "default_ellQ(DEBUGLEVEL_ell, LIM1, LIM3, LIMTRIV, ELLREDGENFLAG, COMPLETE, MAXPROB, LIMBIGPRIME): set the value of the global variables used for ellQ_ellrank() and other related functions. DEBUGLEVEL_ell: 0-5: choose the quantity of information printed during the computation (default=0: print nothing); LIM1 (resp LIM3): search limit for easy (resp hard) points on quartics; LIMTRIV: search limit for trivial points on elliptic curves; ELLREDGENFLAG: if != 0, try to reduce the generators at the end; COMPLETE: if != 0 and full 2-torsion, use complete 2-descent, otherwise via 2-isogeny; MAXPROB, LIMBIGPRIME: technical.");
+ /*  addhelp(DEBUGLEVEL_ell,
+     "DEBUGLEVEL_ell: Choose a higher value of this global variable to have more details of the computations printed during the 2-descent algorithm. 0 = don't print anything; 1 = (default) just print the result; 2 = print more details including the Selmer group and the nontrivial quartics.");
+ */
+diff --git a/src/sage/ext_data/pari/simon/qfsolve.gp b/src/sage/ext_data/pari/simon/qfsolve.gp
+index 501fb50828..2107288c1d 100644
+--- a/src/sage/ext_data/pari/simon/qfsolve.gp
++++ b/src/sage/ext_data/pari/simon/qfsolve.gp
+@@ -434,146 +434,6 @@ my(cc);
+ return([U3~*G3*U3,red[2]*U1*U2*U3]);
+ }
+ 
+-\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+-\\        QUADRATIC FORMS MINIMIZATION         \\
+-\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+-
+-\\ Minimization of the quadratic form G, with nonzero determinant.
+-\\ of dimension n>=2.
+-\\ G must by symmetric and have integral coefficients.
+-\\ Returns [G',U,factd] with U in GLn(Q) such that G'=U~*G*U*constant
+-\\ is integral and has minimal determinant.
+-\\ In dimension 3 or 4, may return a prime p
+-\\ if the reduction at p is impossible because of the local non solvability.
+-\\ If given, factdetG must be equal to factor(abs(det(G))).
+-{qfminimize(G,factdetG) =
+-my(factd,U,Ker,Ker2,sol,aux,di);
+-my(p);
+-my(n,lf,i,vp,dimKer,dimKer2,m);
+-
+-  n = length(G);
+-  factd = matrix(0,2);
+-  if( !factdetG, factdetG = factor(matdet(G)));
+-
+-  lf = length(factdetG[,1]);
+-  i = 1; U = matid(n);
+-
+-  while(i <= lf,
+-    vp = factdetG[i,2];
+-    if( vp == 0, i++; next);
+-    p = factdetG[i,1];
+-    if( p == -1, i++; next);
+-if( DEBUGLEVEL_qfsolve >= 4, print("    p = ",p,"^",vp));
+-
+-\\ The case vp = 1 can be minimized only if n is odd.
+-    if( vp == 1 && n%2 == 0,
+-      factd = concat(factd~, Mat([p,1])~)~;
+-      i++; next
+-    );
+-    Ker = kermodp(G,p); dimKer = Ker[1]; Ker = Ker[2];
+-
+-\\ Rem: we must have dimKer <= vp
+-if( DEBUGLEVEL_qfsolve >= 4, print("    dimKer = ",dimKer));
+-\\ trivial case: dimKer = n
+-    if( dimKer == n, 
+-if( DEBUGLEVEL_qfsolve >= 4, print("     case 0: dimKer = n"));
+-      G /= p;
+-      factdetG[i,2] -= n;
+-      next
+-    );
+-    G = Ker~*G*Ker;
+-    U = U*Ker;
+-
+-\\ 1st case: dimKer < vp
+-\\ then the kernel mod p contains a kernel mod p^2
+-    if( dimKer < vp,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 1: dimker < vp"));
+-      if( dimKer == 1,
+-\\        G[,1] /= p; G[1,] /= p;
+-        G[,1] /= p; G[1,] = G[1,]/p;
+-        U[,1] /= p;
+-        factdetG[i,2] -= 2
+-      , 
+-        Ker2 = kermodp(matrix(dimKer,dimKer,j,k,G[j,k]/p),p);
+-        dimKer2 = Ker2[1]; Ker2 = Ker2[2];
+-        for( j = 1, dimKer2, Ker2[,j] /= p);
+-        Ker2 = matdiagonalblock([Ker2,matid(n-dimKer)]);
+-        G = Ker2~*G*Ker2;
+-        U = U*Ker2;
+-        factdetG[i,2] -= 2*dimKer2
+-);
+-
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 1"));
+-      next
+-    );
+-
+-\\ Now, we have vp = dimKer 
+-\\ 2nd case: the dimension of the kernel is >=2
+-\\ and contains an element of norm 0 mod p^2
+-
+-\\ search for an element of norm p^2... in the kernel
+-    if( dimKer > 2 || 
+-       (dimKer == 2 && issquare( di = Mod((G[1,2]^2-G[1,1]*G[2,2])/p^2,p))),
+-      if( dimKer > 2,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 2.1"));
+-        dimKer = 3;
+-        sol = qfsolvemodp(matrix(3,3,j,k,G[j,k]/p),p)
+-      ,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 2.2"));
+-        if( G[1,1]%p^2 == 0, 
+-          sol = [1,0]~
+-        , sol = [-G[1,2]/p+sqrt(di),Mod(G[1,1]/p,p)]~
+-        )
+-      );
+-      sol = centerlift(sol);
+-      sol /= content(sol);
+-if( DEBUGLEVEL_qfsolve >= 4, print("    sol = ",sol));
+-      Ker = vectorv(n, j, if( j<= dimKer, sol[j], 0)); \\ fill with 0's
+-      Ker = completebasis(Ker,1);
+-      Ker[,n] /= p;
+-      G = Ker~*G*Ker;
+-      U = U*Ker;
+-      factdetG[i,2] -= 2;
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 2"));
+-      next
+-    );
+-
+-\\ Now, we have vp = dimKer <= 2 
+-\\   and the kernel contains no vector with norm p^2...
+-
+-\\ In some cases, exchanging the kernel and the image
+-\\ makes the minimization easy.
+-
+-    m = (n-1)\2-1;
+-    if( ( vp == 1 && issquare(Mod(-(-1)^m*matdet(G)/G[1,1],p)))
+-     || ( vp == 2 && n%2 == 1 && n >= 5)
+-     || ( vp == 2 && n%2 == 0 && !issquare(Mod((-1)^m*matdet(G)/p^2,p)))
+-    , 
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 3"));
+-      Ker = matid(n);
+-      for( j = dimKer+1, n, Ker[j,j] = p);
+-      G = Ker~*G*Ker/p;
+-      U = U*Ker;
+-      factdetG[i,2] -= 2*dimKer-n;
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 3"));
+-      next
+-    );
+-
+-\\ Minimization was not possible se far.
+-\\ If n == 3 or 4, this proves the local non-solubility at p.
+-    if( n == 3 || n == 4, 
+-if( DEBUGLEVEL_qfsolve >= 1, print(" no local solution at ",p));
+-      return(p));
+-
+-if( DEBUGLEVEL_qfsolve >= 4, print("    prime ",p," finished"));
+-    factd = concat(factd~,Mat([p,vp])~)~;
+-    i++
+-  );
+-\\ apply LLL to avoid coefficients explosion
+-  aux = qflll(U/content(U));
+-return([aux~*G*aux,U*aux,factd]);
+-}
+-
+ \\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+ \\          CLASS GROUP COMPUTATIONS           \\
+ \\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+diff --git a/src/sage/geometry/polyhedron/backend_field.py b/src/sage/geometry/polyhedron/backend_field.py
+index 6b921d23a6..2f32c58b1e 100644
+--- a/src/sage/geometry/polyhedron/backend_field.py
++++ b/src/sage/geometry/polyhedron/backend_field.py
+@@ -265,7 +265,7 @@ class Polyhedron_field(Polyhedron_base):
+              An inequality (-0.1419794359520263?, -1.698172434277148?) x + 1.200789243901438? >= 0,
+              An inequality (0.3001973109753594?, 0.600394621950719?) x - 0.4245431085692869? >= 0)
+             sage: p.Vrepresentation()                                           # optional - sage.rings.number_field
+-            (A vertex at (0.?e-15, 0.707106781186548?),
++            (A vertex at (0.?e-16, 0.7071067811865475?),
+              A vertex at (1.414213562373095?, 0),
+              A vertex at (4.000000000000000?, 0.372677996249965?))
+         """
+@@ -308,7 +308,7 @@ class Polyhedron_field(Polyhedron_base):
+              An inequality (-0.1419794359520263?, -1.698172434277148?) x + 1.200789243901438? >= 0,
+              An inequality (0.3001973109753594?, 0.600394621950719?) x - 0.4245431085692869? >= 0)
+             sage: p.Vrepresentation()                                           # optional - sage.rings.number_field
+-            (A vertex at (0.?e-15, 0.707106781186548?),
++            (A vertex at (0.?e-16, 0.7071067811865475?),
+              A vertex at (1.414213562373095?, 0),
+              A vertex at (4.000000000000000?, 0.372677996249965?))
+         """
+diff --git a/src/sage/geometry/polyhedron/backend_normaliz.py b/src/sage/geometry/polyhedron/backend_normaliz.py
+index 86b89632a5..ca8a43b248 100644
+--- a/src/sage/geometry/polyhedron/backend_normaliz.py
++++ b/src/sage/geometry/polyhedron/backend_normaliz.py
+@@ -53,7 +53,7 @@ def _number_field_elements_from_algebraics_list_of_lists_of_lists(listss, **kwds
+         1.732050807568878?
+         sage: from sage.geometry.polyhedron.backend_normaliz import _number_field_elements_from_algebraics_list_of_lists_of_lists
+         sage: K, results, hom = _number_field_elements_from_algebraics_list_of_lists_of_lists([[[rt2], [1]], [[rt3]], [[1], []]]); results  # optional - sage.rings.number_field
+-        [[[-a^3 + 3*a], [1]], [[-a^2 + 2]], [[1], []]]
++        [[[-a^3 + 3*a], [1]], [[a^2 - 2]], [[1], []]]
+     """
+     from sage.rings.qqbar import number_field_elements_from_algebraics
+     numbers = []
+diff --git a/src/sage/groups/matrix_gps/isometries.py b/src/sage/groups/matrix_gps/isometries.py
+index f9111a2c92..cca45e7175 100644
+--- a/src/sage/groups/matrix_gps/isometries.py
++++ b/src/sage/groups/matrix_gps/isometries.py
+@@ -11,11 +11,11 @@ EXAMPLES::
+     sage: L = IntegralLattice("D4")
+     sage: O = L.orthogonal_group()
+     sage: O
+-    Group of isometries with 5 generators (
+-    [-1  0  0  0]  [0 0 0 1]  [-1 -1 -1 -1]  [ 1  1  0  0]  [ 1  0  0  0]
+-    [ 0 -1  0  0]  [0 1 0 0]  [ 0  0  1  0]  [ 0  0  1  0]  [-1 -1 -1 -1]
+-    [ 0  0 -1  0]  [0 0 1 0]  [ 0  1  0  1]  [ 0  1  0  1]  [ 0  0  1  0]
+-    [ 0  0  0 -1], [1 0 0 0], [ 0 -1 -1  0], [ 0 -1 -1  0], [ 0  0  0  1]
++    Group of isometries with 3 generators (
++    [0 0 0 1]  [ 1  1  0  0]  [ 1  0  0  0]
++    [0 1 0 0]  [ 0  0  1  0]  [-1 -1 -1 -1]
++    [0 0 1 0]  [ 0  1  0  1]  [ 0  0  1  0]
++    [1 0 0 0], [ 0 -1 -1  0], [ 0  0  0  1]
+     )
+ 
+ Basic functionality is provided by GAP::
+diff --git a/src/sage/interfaces/genus2reduction.py b/src/sage/interfaces/genus2reduction.py
+index 56ae04b235..7a4794daf2 100644
+--- a/src/sage/interfaces/genus2reduction.py
++++ b/src/sage/interfaces/genus2reduction.py
+@@ -143,31 +143,31 @@ class ReductionData(SageObject):
+        sur un corps de valuation discrète", Trans. AMS 348 (1996),
+        4577-4610, Section 7.2, Proposition 4).
+     """
+-    def __init__(self, pari_result, P, Q, minimal_equation, minimal_disc,
+-                 local_data, conductor, prime_to_2_conductor_only):
++    def __init__(self, pari_result, P, Q, Pmin, Qmin, minimal_disc,
++                 local_data, conductor):
+         self.pari_result = pari_result
+         self.P = P
+         self.Q = Q
+-        self.minimal_equation = minimal_equation
++        self.Pmin = Pmin
++        self.Qmin = Qmin
+         self.minimal_disc = minimal_disc
+         self.local_data = local_data
+         self.conductor = conductor
+-        self.prime_to_2_conductor_only = prime_to_2_conductor_only
+ 
+     def _repr_(self):
+-        if self.prime_to_2_conductor_only:
+-            ex = ' (away from 2)'
+-        else:
+-            ex = ''
+         if self.Q == 0:
+             yterm = ''
+         else:
+             yterm = '+ (%s)*y '%self.Q
++
+         s = 'Reduction data about this proper smooth genus 2 curve:\n'
+         s += '\ty^2 %s= %s\n'%(yterm, self.P)
+-        s += 'A Minimal Equation (away from 2):\n\ty^2 = %s\n'%self.minimal_equation
+-        s += 'Minimal Discriminant (away from 2):  %s\n'%self.minimal_disc
+-        s += 'Conductor%s: %s\n'%(ex, self.conductor)
++        if self.Qmin:
++            s += 'A Minimal Equation:\n\ty^2 + (%s)y = %s\n'%(self.Qmin, self.Pmin)
++        else:
++            s += 'A Minimal Equation:\n\ty^2 = %s\n'%self.Pmin
++        s += 'Minimal Discriminant: %s\n'%self.minimal_disc
++        s += 'Conductor: %s\n'%self.conductor
+         s += 'Local Data:\n%s'%self._local_data_str()
+         return s
+ 
+@@ -242,17 +242,7 @@ class Genus2reduction(SageObject):
+         sage: factor(R.conductor)
+         5^4 * 2267
+ 
+-    This means that only the odd part of the conductor is known.
+-
+-    ::
+-
+-        sage: R.prime_to_2_conductor_only
+-        True
+-
+-    The discriminant is always minimal away from 2, but possibly not at
+-    2.
+-
+-    ::
++    The discriminant is always minimal::
+ 
+         sage: factor(R.minimal_disc)
+         2^3 * 5^5 * 2267
+@@ -264,10 +254,10 @@ class Genus2reduction(SageObject):
+         sage: R
+         Reduction data about this proper smooth genus 2 curve:
+             y^2 + (x^3 - 2*x^2 - 2*x + 1)*y = -5*x^5
+-        A Minimal Equation (away from 2):
+-            y^2 = x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855
+-        Minimal Discriminant (away from 2):  56675000
+-        Conductor (away from 2): 1416875
++        A Minimal Equation:
++            y^2 ...
++        Minimal Discriminant: 56675000
++        Conductor: 1416875
+         Local Data:
+             p=2
+             (potential) stable reduction:  (II), j=1
+@@ -293,10 +283,10 @@ class Genus2reduction(SageObject):
+         sage: genus2reduction(0, x^6 + 3*x^3 + 63)
+         Reduction data about this proper smooth genus 2 curve:
+                 y^2 = x^6 + 3*x^3 + 63
+-        A Minimal Equation (away from 2):
+-                y^2 = x^6 + 3*x^3 + 63
+-        Minimal Discriminant (away from 2):  10628388316852992
+-        Conductor (away from 2): 2893401
++        A Minimal Equation:
++                y^2 ...
++        Minimal Discriminant: -10628388316852992
++        Conductor: 2893401
+         Local Data:
+                 p=2
+                 (potential) stable reduction:  (V), j1+j2=0, j1*j2=0
+@@ -327,9 +317,9 @@ class Genus2reduction(SageObject):
+         sage: genus2reduction(x^3-x^2-1, x^2 - x)
+         Reduction data about this proper smooth genus 2 curve:
+                 y^2 + (x^3 - x^2 - 1)*y = x^2 - x
+-        A Minimal Equation (away from 2):
+-                y^2 = x^6 + 58*x^5 + 1401*x^4 + 18038*x^3 + 130546*x^2 + 503516*x + 808561
+-        Minimal Discriminant (away from 2):  169
++        A Minimal Equation:
++                y^2 ...
++        Minimal Discriminant: -169
+         Conductor: 169
+         Local Data:
+                 p=13
+@@ -370,10 +360,10 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^3 - 2*x^2 - 2*x + 1, -5*x^5)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^3 - 2*x^2 - 2*x + 1)*y = -5*x^5
+-            A Minimal Equation (away from 2):
+-                    y^2 = x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855
+-            Minimal Discriminant (away from 2):  56675000
+-            Conductor (away from 2): 1416875
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 56675000
++            Conductor: 1416875
+             Local Data:
+                     p=2
+                     (potential) stable reduction:  (II), j=1
+@@ -389,9 +379,9 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^2 + 1, -5*x^5)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^2 + 1)*y = -5*x^5
+-            A Minimal Equation (away from 2):
+-                    y^2 = -20*x^5 + x^4 + 2*x^2 + 1
+-            Minimal Discriminant (away from 2):  48838125
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 48838125
+             Conductor: 32025
+             Local Data:
+                     p=3
+@@ -412,9 +402,9 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^3 + x^2 + x,-2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^3 + x^2 + x)*y = -2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2
+-            A Minimal Equation (away from 2):
+-                    y^2 = x^6 + 18*x^3 + 36*x^2 - 27
+-            Minimal Discriminant (away from 2):  1520984142
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 1520984142
+             Conductor: 954
+             Local Data:
+                     p=2
+@@ -436,18 +426,10 @@ class Genus2reduction(SageObject):
+             raise ValueError("Q (=%s) must have degree at most 3" % Q)
+ 
+         res = pari.genus2red([P, Q])
+-
+         conductor = ZZ(res[0])
+-        minimal_equation = R(res[2])
+-
+-        minimal_disc = QQ(res[2].poldisc()).abs()
+-        if minimal_equation.degree() == 5:
+-            minimal_disc *= minimal_equation[5]**2
+-        # Multiply with suitable power of 2 of the form 2^(2*(d-1) - 12)
+-        b = 2 * (minimal_equation.degree() - 1)
+-        k = QQ((12 - minimal_disc.valuation(2), b)).ceil()
+-        minimal_disc >>= 12 - b*k
+-        minimal_disc = ZZ(minimal_disc)
++        Pmin = R(res[2][0])
++        Qmin = R(res[2][1])
++        minimal_disc = ZZ(pari.hyperelldisc(res[2]))
+ 
+         local_data = {}
+         for red in res[3]:
+@@ -468,9 +450,7 @@ class Genus2reduction(SageObject):
+ 
+             local_data[p] = data
+ 
+-        prime_to_2_conductor_only = (-1 in res[1].component(2))
+-        return ReductionData(res, P, Q, minimal_equation, minimal_disc, local_data,
+-                             conductor, prime_to_2_conductor_only)
++        return ReductionData(res, P, Q, Pmin, Qmin, minimal_disc, local_data, conductor)
+ 
+     def __reduce__(self):
+         return _reduce_load_genus2reduction, tuple([])
+diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
+index fec450d7bc..236402c293 100644
+--- a/src/sage/lfunctions/dokchitser.py
++++ b/src/sage/lfunctions/dokchitser.py
+@@ -337,6 +337,7 @@ class Dokchitser(SageObject):
+             # After init_coeffs is called, future calls to this method should
+             # return the full output for further parsing
+             raise RuntimeError("unable to create L-series, due to precision or other limits in PARI")
++        t = t.replace("  *** _^_: Warning: normalizing a series with 0 leading term.\n", "")
+         return t
+ 
+     def __check_init(self):
+diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
+index d2b20f1891..6c31efe239 100644
+--- a/src/sage/lfunctions/pari.py
++++ b/src/sage/lfunctions/pari.py
+@@ -339,7 +339,7 @@ def lfun_eta_quotient(scalings, exponents):
+         0.0374412812685155
+ 
+         sage: lfun_eta_quotient([6],[4])
+-        [[Vecsmall([7]), [Vecsmall([6]), Vecsmall([4])]], 0, [0, 1], 2, 36, 1]
++        [[Vecsmall([7]), [Vecsmall([6]), Vecsmall([4]), 0]], 0, [0, 1], 2, 36, 1]
+ 
+         sage: lfun_eta_quotient([2,1,4], [5,-2,-2])
+         Traceback (most recent call last):
+diff --git a/src/sage/libs/pari/tests.py b/src/sage/libs/pari/tests.py
+index e5a2aa2517..0efcb15de0 100644
+--- a/src/sage/libs/pari/tests.py
++++ b/src/sage/libs/pari/tests.py
+@@ -356,7 +356,7 @@ Constructors::
+     [2, 4]~*x + [1, 3]~
+ 
+     sage: pari(3).Qfb(7, 1)
+-    Qfb(3, 7, 1, 0.E-19)
++    Qfb(3, 7, 1)
+     sage: pari(3).Qfb(7, 2)
+     Traceback (most recent call last):
+     ...
+@@ -512,7 +512,7 @@ Basic functions::
+     sage: pari('sqrt(-2)').frac()
+     Traceback (most recent call last):
+     ...
+-    PariError: incorrect type in gfloor (t_COMPLEX)
++    PariError: incorrect type in gfrac (t_COMPLEX)
+ 
+     sage: pari('1+2*I').imag()
+     2
+diff --git a/src/sage/modular/cusps_nf.py b/src/sage/modular/cusps_nf.py
+index 25d93cac92..157ebabe29 100644
+--- a/src/sage/modular/cusps_nf.py
++++ b/src/sage/modular/cusps_nf.py
+@@ -1220,7 +1220,7 @@ def units_mod_ideal(I):
+         sage: I = k.ideal(5, a + 1)
+         sage: units_mod_ideal(I)
+         [1,
+-        2*a^2 + 4*a - 1,
++        -2*a^2 - 4*a + 1,
+         ...]
+ 
+     ::
+diff --git a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
+index a881336596..090d1bfaf0 100644
+--- a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
++++ b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
+@@ -43,7 +43,7 @@ def coerce_AA(p):
+         sage: AA(p)._exact_field()
+         Number Field in a with defining polynomial y^8 ... with a in ...
+         sage: coerce_AA(p)._exact_field()
+-        Number Field in a with defining polynomial y^4 - 1910*y^2 - 3924*y + 681058 with a in 39.710518724...?
++        Number Field in a with defining polynomial y^4 - 1910*y^2 - 3924*y + 681058 with a in ...?
+     """
+     el = AA(p)
+     el.simplify()
+diff --git a/src/sage/modular/modsym/p1list_nf.py b/src/sage/modular/modsym/p1list_nf.py
+index 222caacca8..f9d969732c 100644
+--- a/src/sage/modular/modsym/p1list_nf.py
++++ b/src/sage/modular/modsym/p1list_nf.py
+@@ -58,7 +58,7 @@ Lift an MSymbol to a matrix in `SL(2, R)`:
+ 
+     sage: alpha = MSymbol(N, a + 2, 3*a^2)
+     sage: alpha.lift_to_sl2_Ok()
+-    [-3*a^2 + a + 12, 25*a^2 - 50*a + 100, a + 2, a^2 - 3*a + 3]
++    [-1, 4*a^2 - 13*a + 23, a + 2, 5*a^2 + 3*a - 3]
+     sage: Ok = k.ring_of_integers()
+     sage: M = Matrix(Ok, 2, alpha.lift_to_sl2_Ok())
+     sage: det(M)
+@@ -945,11 +945,11 @@ class P1NFList(SageObject):
+             sage: N = k.ideal(5, a + 1)
+             sage: P = P1NFList(N)
+             sage: u = k.unit_group().gens_values(); u
+-            [-1, 2*a^2 + 4*a - 1]
++            [-1, -2*a^2 - 4*a + 1]
+             sage: P.apply_J_epsilon(4, -1)
+             2
+             sage: P.apply_J_epsilon(4, u[0], u[1])
+-            1
++            5
+ 
+         ::
+ 
+diff --git a/src/sage/modules/free_quadratic_module_integer_symmetric.py b/src/sage/modules/free_quadratic_module_integer_symmetric.py
+index a206f0c721..aeb19ab669 100644
+--- a/src/sage/modules/free_quadratic_module_integer_symmetric.py
++++ b/src/sage/modules/free_quadratic_module_integer_symmetric.py
+@@ -1168,11 +1168,11 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+             sage: A4 = IntegralLattice("A4")
+             sage: Aut = A4.orthogonal_group()
+             sage: Aut
+-            Group of isometries with 5 generators (
+-            [-1  0  0  0]  [0 0 0 1]  [-1 -1 -1  0]  [ 1  0  0  0]  [ 1  0  0  0]
+-            [ 0 -1  0  0]  [0 0 1 0]  [ 0  0  0 -1]  [-1 -1 -1 -1]  [ 0  1  0  0]
+-            [ 0  0 -1  0]  [0 1 0 0]  [ 0  0  1  1]  [ 0  0  0  1]  [ 0  0  1  1]
+-            [ 0  0  0 -1], [1 0 0 0], [ 0  1  0  0], [ 0  0  1  0], [ 0  0  0 -1]
++            Group of isometries with 4 generators (
++            [0 0 0 1]  [-1 -1 -1  0]  [ 1  0  0  0]  [ 1  0  0  0]
++            [0 0 1 0]  [ 0  0  0 -1]  [-1 -1 -1 -1]  [ 0  1  0  0]
++            [0 1 0 0]  [ 0  0  1  1]  [ 0  0  0  1]  [ 0  0  1  1]
++            [1 0 0 0], [ 0  1  0  0], [ 0  0  1  0], [ 0  0  0 -1]
+             )
+ 
+         The group acts from the right on the lattice and its discriminant group::
+@@ -1180,19 +1180,19 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+             sage: x = A4.an_element()
+             sage: g = Aut.an_element()
+             sage: g
+-            [ 1  1  1  0]
+-            [ 0  0 -1  0]
+-            [ 0  0  1  1]
+-            [ 0 -1 -1 -1]
++            [-1 -1 -1  0]
++            [ 0  0  1  0]
++            [ 0  0 -1 -1]
++            [ 0  1  1  1]
+             sage: x*g
+-            (1, 1, 1, 0)
++            (-1, -1, -1, 0)
+             sage: (x*g).parent()==A4
+             True
+             sage: (g*x).parent()
+             Vector space of dimension 4 over Rational Field
+             sage: y = A4.discriminant_group().an_element()
+             sage: y*g
+-            (1)
++            (4)
+ 
+         If the group is finite we can compute the usual things::
+ 
+@@ -1208,10 +1208,10 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+ 
+             sage: A2 = IntegralLattice(matrix.identity(3),Matrix(ZZ,2,3,[1,-1,0,0,1,-1]))
+             sage: A2.orthogonal_group()
+-            Group of isometries with 3 generators (
+-            [-1/3  2/3  2/3]  [ 2/3  2/3 -1/3]  [1 0 0]
+-            [ 2/3 -1/3  2/3]  [ 2/3 -1/3  2/3]  [0 0 1]
+-            [ 2/3  2/3 -1/3], [-1/3  2/3  2/3], [0 1 0]
++            Group of isometries with 2 generators (
++            [ 2/3  2/3 -1/3]  [1 0 0]
++            [ 2/3 -1/3  2/3]  [0 0 1]
++            [-1/3  2/3  2/3], [0 1 0]
+             )
+ 
+         It can be negative definite as well::
+diff --git a/src/sage/quadratic_forms/binary_qf.py b/src/sage/quadratic_forms/binary_qf.py
+index cfa3ada73e..5ac823bc6c 100755
+--- a/src/sage/quadratic_forms/binary_qf.py
++++ b/src/sage/quadratic_forms/binary_qf.py
+@@ -141,7 +141,7 @@ class BinaryQF(SageObject):
+                   and a.degree() == 2 and a.parent().ngens() == 2):
+                 x, y = a.parent().gens()
+                 a, b, c = [a.monomial_coefficient(mon) for mon in [x**2, x*y, y**2]]
+-            elif isinstance(a, pari_gen) and a.type() in ('t_QFI', 't_QFR'):
++            elif isinstance(a, pari_gen) and a.type() in ('t_QFI', 't_QFR', 't_QFB'):
+                 # a has 3 or 4 components
+                 a, b, c = a[0], a[1], a[2]
+         try:
+diff --git a/src/sage/quadratic_forms/genera/genus.py b/src/sage/quadratic_forms/genera/genus.py
+index 8290b6c4fa..0fc43f33c6 100644
+--- a/src/sage/quadratic_forms/genera/genus.py
++++ b/src/sage/quadratic_forms/genera/genus.py
+@@ -3088,8 +3088,8 @@ class GenusSymbol_global_ring():
+             sage: G = Genus(matrix(ZZ, 3, [6,3,0, 3,6,0, 0,0,2]))
+             sage: G.representatives()
+             (
+-            [2 0 0]  [ 2 -1  0]
+-            [0 6 3]  [-1  2  0]
++            [2 0 0]  [ 2  1  0]
++            [0 6 3]  [ 1  2  0]
+             [0 3 6], [ 0  0 18]
+             )
+ 
+diff --git a/src/sage/quadratic_forms/qfsolve.py b/src/sage/quadratic_forms/qfsolve.py
+index ddde95e04f..d5e15d9f83 100644
+--- a/src/sage/quadratic_forms/qfsolve.py
++++ b/src/sage/quadratic_forms/qfsolve.py
+@@ -70,7 +70,7 @@ def qfsolve(G):
+ 
+         sage: M = Matrix(QQ, [[3, 0, 0, 0], [0, 5, 0, 0], [0, 0, -7, 0], [0, 0, 0, -11]])
+         sage: qfsolve(M)
+-        (3, -4, -3, -2)
++        (3, 4, -3, -2)
+     """
+     ret = G.__pari__().qfsolve()
+     if ret.type() == 't_COL':
+diff --git a/src/sage/quadratic_forms/quadratic_form__automorphisms.py b/src/sage/quadratic_forms/quadratic_form__automorphisms.py
+index c36c667e3b..3d72cf3be1 100644
+--- a/src/sage/quadratic_forms/quadratic_form__automorphisms.py
++++ b/src/sage/quadratic_forms/quadratic_form__automorphisms.py
+@@ -300,9 +300,9 @@ def automorphism_group(self):
+         sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1])
+         sage: Q.automorphism_group()
+         Matrix group over Rational Field with 3 generators (
+-        [-1  0  0]  [0 0 1]  [ 0  0  1]
+-        [ 0 -1  0]  [0 1 0]  [-1  0  0]
+-        [ 0  0 -1], [1 0 0], [ 0  1  0]
++        [ 0  0  1]  [1 0 0]  [ 1  0  0]
++        [-1  0  0]  [0 0 1]  [ 0 -1  0]
++        [ 0  1  0], [0 1 0], [ 0  0  1]
+         )
+ 
+     ::
+diff --git a/src/sage/rings/finite_rings/finite_field_prime_modn.py b/src/sage/rings/finite_rings/finite_field_prime_modn.py
+index 9129ecb56a..d5a4cb8f22 100644
+--- a/src/sage/rings/finite_rings/finite_field_prime_modn.py
++++ b/src/sage/rings/finite_rings/finite_field_prime_modn.py
+@@ -111,7 +111,7 @@ class FiniteField_prime_modn(FiniteField_generic, integer_mod_ring.IntegerModRin
+             sage: RF13 = K.residue_field(pp)
+             sage: RF13.hom([GF(13)(1)])
+             Ring morphism:
+-             From: Residue field of Fractional ideal (w + 18)
++             From: Residue field of Fractional ideal (-w - 18)
+              To:   Finite Field of size 13
+              Defn: 1 |--> 1
+ 
+diff --git a/src/sage/rings/finite_rings/residue_field.pyx b/src/sage/rings/finite_rings/residue_field.pyx
+index 7596f2a302..1e1869f1b1 100644
+--- a/src/sage/rings/finite_rings/residue_field.pyx
++++ b/src/sage/rings/finite_rings/residue_field.pyx
+@@ -20,13 +20,13 @@ monogenic (i.e., 2 is an essential discriminant divisor)::
+ 
+     sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8)
+     sage: F = K.factor(2); F
+-    (Fractional ideal (1/2*a^2 - 1/2*a + 1)) * (Fractional ideal (-a^2 + 2*a - 3)) * (Fractional ideal (-3/2*a^2 + 5/2*a - 4))
++    (Fractional ideal (-1/2*a^2 + 1/2*a - 1)) * (Fractional ideal (-a^2 + 2*a - 3)) * (Fractional ideal (3/2*a^2 - 5/2*a + 4))
+     sage: F[0][0].residue_field()
+-    Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++    Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+     sage: F[1][0].residue_field()
+     Residue field of Fractional ideal (-a^2 + 2*a - 3)
+     sage: F[2][0].residue_field()
+-    Residue field of Fractional ideal (-3/2*a^2 + 5/2*a - 4)
++    Residue field of Fractional ideal (3/2*a^2 - 5/2*a + 4)
+ 
+ We can also form residue fields from `\ZZ`::
+ 
+@@ -258,9 +258,9 @@ class ResidueFieldFactory(UniqueFactory):
+     the index of ``ZZ[a]`` in the maximal order for all ``a``::
+ 
+         sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8); P = K.ideal(2).factor()[0][0]; P
+-        Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F = K.residue_field(P); F
+-        Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F(a)
+         0
+         sage: B = K.maximal_order().basis(); B
+@@ -270,7 +270,7 @@ class ResidueFieldFactory(UniqueFactory):
+         sage: F(B[2])
+         0
+         sage: F
+-        Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F.degree()
+         1
+ 
+@@ -730,15 +730,15 @@ class ResidueField_generic(Field):
+         EXAMPLES::
+ 
+             sage: I = QQ[3^(1/3)].factor(5)[1][0]; I
+-            Fractional ideal (-a + 2)
++            Fractional ideal (a - 2)
+             sage: k = I.residue_field(); k
+-            Residue field of Fractional ideal (-a + 2)
++            Residue field of Fractional ideal (a - 2)
+             sage: f = k.lift_map(); f
+             Lifting map:
+-              From: Residue field of Fractional ideal (-a + 2)
++              From: Residue field of Fractional ideal (a - 2)
+               To:   Maximal Order in Number Field in a with defining polynomial x^3 - 3 with a = 1.442249570307409?
+             sage: f.domain()
+-            Residue field of Fractional ideal (-a + 2)
++            Residue field of Fractional ideal (a - 2)
+             sage: f.codomain()
+             Maximal Order in Number Field in a with defining polynomial x^3 - 3 with a = 1.442249570307409?
+             sage: f(k.0)
+@@ -768,7 +768,7 @@ class ResidueField_generic(Field):
+ 
+             sage: K.<a> = NumberField(x^3-11)
+             sage: F = K.ideal(37).factor(); F
+-            (Fractional ideal (37, a + 9)) * (Fractional ideal (37, a + 12)) * (Fractional ideal (2*a - 5))
++            (Fractional ideal (37, a + 9)) * (Fractional ideal (37, a + 12)) * (Fractional ideal (-2*a + 5))
+             sage: k = K.residue_field(F[0][0])
+             sage: l = K.residue_field(F[1][0])
+             sage: k == l
+@@ -846,7 +846,7 @@ cdef class ReductionMap(Map):
+             sage: F.reduction_map()
+             Partially defined reduction map:
+               From: Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
+-              To:   Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++              To:   Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+ 
+             sage: K.<theta_5> = CyclotomicField(5)
+             sage: F = K.factor(7)[0][0].residue_field()
+diff --git a/src/sage/rings/number_field/S_unit_solver.py b/src/sage/rings/number_field/S_unit_solver.py
+index e99dff850f..759cbfb334 100644
+--- a/src/sage/rings/number_field/S_unit_solver.py
++++ b/src/sage/rings/number_field/S_unit_solver.py
+@@ -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 (xi - 3),
+-         Fractional ideal (-2*xi^2 + 3),
++        (Fractional ideal (-2*xi^2 + 3),
++         Fractional ideal (-xi + 3),
+          Fractional ideal (2*xi + 1))
+ 
+         sage: sieve_data[1]
+-        (Residue field of Fractional ideal (xi - 3),
+-         Residue field of Fractional ideal (-2*xi^2 + 3),
++        (Residue field of Fractional ideal (-2*xi^2 + 3),
++         Residue field of Fractional ideal (-xi + 3),
+          Residue field of Fractional ideal (2*xi + 1))
+ 
+         sage: sieve_data[2]
+-        ([18, 7, 16, 4], [18, 9, 12, 8], [18, 3, 10, 10])
++        ([18, 12, 16, 8], [18, 16, 10, 4], [18, 10, 12, 10])
+ 
+         sage: sieve_data[3]
+-        (486, 648, 11664)
++        (648, 2916, 3888)
+     """
+ 
+     K = SUK.number_field()
+diff --git a/src/sage/rings/number_field/bdd_height.py b/src/sage/rings/number_field/bdd_height.py
+index beb047ae02..b7c8c33d0b 100644
+--- a/src/sage/rings/number_field/bdd_height.py
++++ b/src/sage/rings/number_field/bdd_height.py
+@@ -248,7 +248,7 @@ def bdd_norm_pr_ideal_gens(K, norm_list):
+         sage: from sage.rings.number_field.bdd_height import bdd_norm_pr_ideal_gens
+         sage: K.<g> = QuadraticField(123)
+         sage: bdd_norm_pr_ideal_gens(K, range(5))
+-        {0: [0], 1: [1], 2: [-g - 11], 3: [], 4: [2]}
++        {0: [0], 1: [1], 2: [g + 11], 3: [], 4: [2]}
+ 
+     ::
+ 
+diff --git a/src/sage/rings/number_field/class_group.py b/src/sage/rings/number_field/class_group.py
+index 018ff5f5c6..73c0462cd1 100644
+--- a/src/sage/rings/number_field/class_group.py
++++ b/src/sage/rings/number_field/class_group.py
+@@ -221,11 +221,11 @@ class FractionalIdealClass(AbelianGroupWithValuesElement):
+             Class group of order 76 with structure C38 x C2
+             of Number Field in a with defining polynomial x^2 + 20072
+             sage: I = (G.0)^11; I
+-            Fractional ideal class (41, 1/2*a + 5)
++            Fractional ideal class (33, 1/2*a + 8)
+             sage: J = G(I.ideal()^5); J
+-            Fractional ideal class (115856201, 1/2*a + 40407883)
++            Fractional ideal class (39135393, 1/2*a + 13654253)
+             sage: J.reduce()
+-            Fractional ideal class (57, 1/2*a + 44)
++            Fractional ideal class (73, 1/2*a + 47)
+             sage: J == I^5
+             True
+         """
+diff --git a/src/sage/rings/number_field/galois_group.py b/src/sage/rings/number_field/galois_group.py
+index 79acd053bb..e060148e4d 100644
+--- a/src/sage/rings/number_field/galois_group.py
++++ b/src/sage/rings/number_field/galois_group.py
+@@ -944,7 +944,7 @@ class GaloisGroup_v2(GaloisGroup_perm):
+             sage: K.<b> = NumberField(x^4 - 2*x^2 + 2, 'a').galois_closure()
+             sage: G = K.galois_group()
+             sage: [G.artin_symbol(P) for P in K.primes_above(7)]
+-            [(1,5)(2,6)(3,7)(4,8), (1,5)(2,6)(3,7)(4,8), (1,4)(2,3)(5,8)(6,7), (1,4)(2,3)(5,8)(6,7)]
++            [(1,4)(2,3)(5,8)(6,7), (1,4)(2,3)(5,8)(6,7), (1,5)(2,6)(3,7)(4,8), (1,5)(2,6)(3,7)(4,8)]
+             sage: G.artin_symbol(17)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
+index 58463d570d..ff65634e99 100644
+--- a/src/sage/rings/number_field/number_field.py
++++ b/src/sage/rings/number_field/number_field.py
+@@ -3643,7 +3643,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
+ 
+@@ -4227,7 +4227,8 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             (y^2 + 6, Mod(1/6*y, y^2 + 6), Mod(6*y, y^2 + 1/6))
+         """
+         f = self.absolute_polynomial()._pari_with_name('y')
+-        if f.pollead() == f.content().denominator() == 1:
++        f = f * f.content().denominator()
++        if f.pollead() == 1:
+             g = f
+             alpha = beta = g.variable().Mod(g)
+         else:
+@@ -4821,7 +4822,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+ 
+             sage: K.<a> = NumberField(2*x^2 - 1/3)
+             sage: K._S_class_group_and_units(tuple(K.primes_above(2) + K.primes_above(3)))
+-            ([-6*a + 2, 6*a + 3, -1, 12*a + 5], [])
++            ([6*a + 2, 6*a + 3, -1, -12*a + 5], [])
+         """
+         K_pari = self.pari_bnf(proof=proof)
+         S_pari = [p.pari_prime() for p in sorted(set(S))]
+@@ -5166,7 +5167,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+ 
+             sage: [K.ideal(g).factor() for g in gens]
+             [(Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1)),
+-            Fractional ideal (-a),
++            Fractional ideal (a),
+             (Fractional ideal (2, a + 1))^2,
+             1]
+ 
+@@ -5751,7 +5752,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: K.elements_of_norm(3)
+             []
+             sage: K.elements_of_norm(50)
+-            [-7*a + 1, 5*a - 5, 7*a + 1]
++            [-a - 7, 5*a - 5, 7*a + 1]
+ 
+         TESTS:
+ 
+@@ -5863,7 +5864,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: K.factor(1+a)
+             Fractional ideal (a + 1)
+             sage: K.factor(1+a/5)
+-            (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1 * (Fractional ideal (-3*a - 2))
++            (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1 * (Fractional ideal (-2*a + 3))
+ 
+         An example over a relative number field::
+ 
+@@ -6460,9 +6461,9 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: new_basis = k.reduced_basis(prec=120)
+             sage: [c.minpoly() for c in new_basis]
+             [x - 1,
+-             x^2 - x + 1,
++             x^2 + x + 1,
++             x^6 + 3*x^5 - 102*x^4 - 103*x^3 + 10572*x^2 - 59919*x + 127657,
+              x^6 + 3*x^5 - 102*x^4 - 103*x^3 + 10572*x^2 - 59919*x + 127657,
+-             x^6 - 3*x^5 - 102*x^4 + 315*x^3 + 10254*x^2 - 80955*x + 198147,
+              x^3 - 171*x + 848,
+              x^6 + 171*x^4 + 1696*x^3 + 29241*x^2 + 145008*x + 719104]
+             sage: R = k.order(new_basis)
+@@ -7058,7 +7059,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+              -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)
++             2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7)
+ 
+         TESTS:
+ 
+@@ -7067,7 +7068,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)
+ 
+@@ -7146,7 +7147,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^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]
++            [-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, 2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7]
+         """
+         proof = proof_flag(proof)
+ 
+diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx
+index 784c239dc1..aa740069dc 100644
+--- a/src/sage/rings/number_field/number_field_element.pyx
++++ b/src/sage/rings/number_field/number_field_element.pyx
+@@ -4446,7 +4446,7 @@ cdef class NumberFieldElement(FieldElement):
+             sage: f = Qi.embeddings(K)[0]
+             sage: a = f(2+3*i) * (2-zeta)^2
+             sage: a.descend_mod_power(Qi,2)
+-            [-3*i - 2, -2*i + 3]
++            [-2*i + 3, 3*i + 2]
+ 
+         An absolute example::
+ 
+@@ -5124,7 +5124,7 @@ cdef class NumberFieldElement_relative(NumberFieldElement):
+         EXAMPLES::
+ 
+             sage: K.<a, b, c> = NumberField([x^2 - 2, x^2 - 3, x^2 - 5])
+-            sage: P = K.prime_factors(5)[0]
++            sage: P = K.prime_factors(5)[1]
+             sage: (2*a + b - c).valuation(P)
+             1
+         """
+diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
+index 5f587556a4..33481fead0 100644
+--- a/src/sage/rings/number_field/number_field_ideal.py
++++ b/src/sage/rings/number_field/number_field_ideal.py
+@@ -3355,7 +3355,7 @@ def quotient_char_p(I, p):
+         []
+ 
+         sage: I = K.factor(13)[0][0]; I
+-        Fractional ideal (-3*i - 2)
++        Fractional ideal (-2*i + 3)
+         sage: I.residue_class_degree()
+         1
+         sage: quotient_char_p(I, 13)[0]
+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 bae36d4b9c..f64bd5b761 100644
+--- a/src/sage/rings/number_field/number_field_ideal_rel.py
++++ b/src/sage/rings/number_field/number_field_ideal_rel.py
+@@ -272,7 +272,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.gens_reduced()
+-            (2, 15*a*b + 3*a + 1)
++            (2, -15*a*b + 3*a + 1)
+         """
+         try:
+             # Compute the single generator, if it exists
+@@ -401,7 +401,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.relative_norm()
+-            Fractional ideal (-6*a + 2)
++            Fractional ideal (6*a + 2)
+         """
+         L = self.number_field()
+         K = L.base_field()
+@@ -518,7 +518,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.ideal_below()
+-            Fractional ideal (-6*a + 2)
++            Fractional ideal (6*a + 2)
+         """
+         L = self.number_field()
+         K = L.base_field()
+diff --git a/src/sage/rings/number_field/number_field_rel.py b/src/sage/rings/number_field/number_field_rel.py
+index d33980c4b1..50e846b205 100644
+--- a/src/sage/rings/number_field/number_field_rel.py
++++ b/src/sage/rings/number_field/number_field_rel.py
+@@ -213,14 +213,14 @@ class NumberField_relative(NumberField_generic):
+             sage: l.<b> = k.extension(5*x^2 + 3); l
+             Number Field in b with defining polynomial 5*x^2 + 3 over its base field
+             sage: l.pari_rnf()
+-            [x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4), ..., y^4 + 6*y^2 + 1, x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4)], [0, 0]]
++            [x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4), ..., y^4 + 6*y^2 + 1, x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4)], [0, 0]]
+             sage: b
+             b
+ 
+             sage: l.<b> = k.extension(x^2 + 3/5); l
+             Number Field in b with defining polynomial x^2 + 3/5 over its base field
+             sage: l.pari_rnf()
+-            [x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4), ..., y^4 + 6*y^2 + 1, x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4)], [0, 0]]
++            [x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4), ..., y^4 + 6*y^2 + 1, x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4)], [0, 0]]
+             sage: b
+             b
+ 
+diff --git a/src/sage/rings/number_field/order.py b/src/sage/rings/number_field/order.py
+index 6eca89ed8d..78ef4c3b33 100644
+--- a/src/sage/rings/number_field/order.py
++++ b/src/sage/rings/number_field/order.py
+@@ -520,7 +520,7 @@ class Order(IntegralDomain, sage.rings.abc.Order):
+             sage: k.<a> = NumberField(x^2 + 5077); G = k.class_group(); G
+             Class group of order 22 with structure C22 of Number Field in a with defining polynomial x^2 + 5077
+             sage: G.0 ^ -9
+-            Fractional ideal class (11, a + 7)
++            Fractional ideal class (43, a + 13)
+             sage: Ok = k.maximal_order(); Ok
+             Maximal Order in Number Field in a with defining polynomial x^2 + 5077
+             sage: Ok * (11, a + 7)
+diff --git a/src/sage/rings/number_field/selmer_group.py b/src/sage/rings/number_field/selmer_group.py
+index c534aaa9f6..6bc67565d2 100644
+--- a/src/sage/rings/number_field/selmer_group.py
++++ b/src/sage/rings/number_field/selmer_group.py
+@@ -491,7 +491,7 @@ def pSelmerGroup(K, S, p, proof=None, debug=False):
+ 
+         sage: [K.ideal(g).factor() for g in gens]
+         [(Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1)),
+-        Fractional ideal (-a),
++        Fractional ideal (a),
+         (Fractional ideal (2, a + 1))^2,
+         1]
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
+index bb5d8356be..8a7e5fa66f 100644
+--- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
++++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
+@@ -1791,7 +1791,7 @@ class PolynomialQuotientRing_generic(CommutativeRing):
+             sage: D.selmer_generators([K.ideal(2, -a+1), K.ideal(3, a+1)], 3)
+             [2, a + 1]
+             sage: D.selmer_generators([K.ideal(2, -a+1), K.ideal(3, a+1), K.ideal(a)], 3)
+-            [2, a + 1, a]
++            [2, a + 1, -a]
+ 
+         """
+         fields, isos, iso_classes = self._S_decomposition(tuple(S))
+diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py
+index 704b77ce5f..83ee4549e4 100644
+--- a/src/sage/rings/qqbar.py
++++ b/src/sage/rings/qqbar.py
+@@ -312,8 +312,8 @@ and we get a way to produce the number directly::
+     True
+     sage: sage_input(n)
+     R.<y> = QQ[]
+-    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(RR(0.51763809020504148), RR(0.51763809020504159)))
+-    -109*v^3 - 89*v^2 + 327*v + 178
++    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(-RR(1.9318516525781366), -RR(1.9318516525781364)))
++    -109*v^3 + 89*v^2 + 327*v - 178
+ 
+ We can also see that some computations (basically, those which are
+ easy to perform exactly) are performed directly, instead of storing
+@@ -362,7 +362,7 @@ algorithms in :trac:`10255`::
+     # Verified
+     R1.<x> = QQbar[]
+     R2.<y> = QQ[]
+-    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(RR(0.51763809020504148), RR(0.51763809020504159)))
++    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(-RR(1.9318516525781366), -RR(1.9318516525781364)))
+     AA.polynomial_root(AA.common_polynomial(x^4 + QQbar(v^3 - 3*v - 1)*x^3 + QQbar(-v^3 + 3*v - 3)*x^2 + QQbar(-3*v^3 + 9*v + 3)*x + QQbar(3*v^3 - 9*v)), RIF(RR(0.99999999999999989), RR(1.0000000000000002)))
+     sage: one
+     1
+@@ -2310,7 +2310,7 @@ def do_polred(poly, threshold=32):
+     cost = 2 * bitsize.nbits() + 5 * poly.degree().nbits()
+     if cost > threshold:
+         return parent.gen(), parent.gen(), poly
+-    new_poly, elt_back = poly.__pari__().polredbest(flag=1)
++    new_poly, elt_back = poly.numerator().__pari__().polredbest(flag=1)
+     elt_fwd = elt_back.modreverse()
+     return parent(elt_fwd.lift()), parent(elt_back.lift()), parent(new_poly)
+ 
+@@ -2542,10 +2542,10 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+            Defn: a |--> 1.414213562373095?)
+ 
+         sage: number_field_elements_from_algebraics((rt2,rt3))
+-        (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, [-a^3 + 3*a, -a^2 + 2], Ring morphism:
++        (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, [-a^3 + 3*a, a^2 - 2], Ring morphism:
+             From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+             To:   Algebraic Real Field
+-            Defn: a |--> 0.5176380902050415?)
++            Defn: a |--> -1.931851652578137?)
+ 
+     ``rt3a`` is a real number in ``QQbar``.  Ordinarily, we'd get a homomorphism
+     to ``AA`` (because all elements are real), but if we specify ``same_field=True``,
+@@ -2570,7 +2570,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, -a^3 + 3*a, Ring morphism:
+             From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+             To:   Algebraic Real Field
+-            Defn: a |--> 0.5176380902050415?)
++            Defn: a |--> -1.931851652578137?)
+ 
+     We can specify ``minimal=True`` if we want the smallest number field::
+ 
+@@ -2618,7 +2618,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         sage: nfI^2
+         -1
+         sage: sum = nfrt2 + nfrt3 + nfI + nfz3; sum
+-        2*a^6 + a^5 - a^4 - a^3 - 2*a^2 - a
++        a^5 + a^4 - a^3 + 2*a^2 - a - 1
+         sage: hom(sum)
+         2.646264369941973? + 1.866025403784439?*I
+         sage: hom(sum) == rt2 + rt3 + qqI + z3
+@@ -2658,7 +2658,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         sage: nf, nums, hom = number_field_elements_from_algebraics(elems, embedded=True)
+         sage: nf
+         Number Field in a with defining polynomial y^24 - 6*y^23 ...- 9*y^2 + 1
+-          with a = 0.2598678911433438? + 0.0572892247058457?*I
++          with a = 0.2598679? + 0.0572892?*I
+         sage: list(map(QQbar, nums)) == elems == list(map(hom, nums))
+         True
+ 
+@@ -2725,7 +2725,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+                          sqrt(2), AA.polynomial_root(x^3-3, RIF(0,3)), 11/9, 1]
+         sage: res = number_field_elements_from_algebraics(my_nums, embedded=True)
+         sage: res[0]
+-        Number Field in a with defining polynomial y^24 - 107010*y^22 - 24*y^21 + ... + 250678447193040618624307096815048024318853254384 with a = -95.5053039433554?
++        Number Field in a with defining polynomial y^24 - 107010*y^22 - 24*y^21 + ... + 250678447193040618624307096815048024318853254384 with a = 93.32530798172420?
+     """
+     gen = qq_generator
+ 
+@@ -3129,7 +3129,7 @@ class AlgebraicGenerator(SageObject):
+             sage: root = ANRoot(x^2 - x - 1, RIF(1, 2))
+             sage: gen = AlgebraicGenerator(nf, root)
+             sage: gen.pari_field()
+-             [y^2 - y - 1, [2, 0], ...]
++            [[y^2 - y - 1, [2, 0], ...]
+         """
+         if self.is_trivial():
+             raise ValueError("No PARI field attached to trivial generator")
+@@ -3213,7 +3213,7 @@ class AlgebraicGenerator(SageObject):
+             sage: qq_generator.union(gen3) is gen3
+             True
+             sage: gen2.union(gen3)
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+         """
+         if self._trivial:
+             return other
+@@ -3306,13 +3306,13 @@ class AlgebraicGenerator(SageObject):
+             Number Field in a with defining polynomial y^2 - 3 with a in 1.732050807568878?
+             sage: gen2_3 = gen2.union(gen3)
+             sage: gen2_3
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+             sage: qq_generator.super_poly(gen2) is None
+             True
+             sage: gen2.super_poly(gen2_3)
+             -a^3 + 3*a
+             sage: gen3.super_poly(gen2_3)
+-            -a^2 + 2
++            a^2 - 2
+ 
+         """
+         if checked is None:
+@@ -3360,13 +3360,13 @@ class AlgebraicGenerator(SageObject):
+             sage: sqrt3 = ANExtensionElement(gen3, nf3.gen())
+             sage: gen2_3 = gen2.union(gen3)
+             sage: gen2_3
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+             sage: gen2_3(sqrt2)
+             -a^3 + 3*a
+             sage: gen2_3(ANRational(1/7))
+             1/7
+             sage: gen2_3(sqrt3)
+-            -a^2 + 2
++            a^2 - 2
+         """
+         if self._trivial:
+             return elt._value
+@@ -4336,10 +4336,10 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: rt3 = AA(sqrt(3))
+             sage: rt3b = rt2 + rt3 - rt2
+             sage: rt3b.as_number_field_element()
+-            (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, -a^2 + 2, Ring morphism:
++            (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, a^2 - 2, Ring morphism:
+                 From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+                 To:   Algebraic Real Field
+-                Defn: a |--> 0.5176380902050415?)
++                Defn: a |--> -1.931851652578137?)
+             sage: rt3b.as_number_field_element(minimal=True)
+             (Number Field in a with defining polynomial y^2 - 3, a, Ring morphism:
+                From: Number Field in a with defining polynomial y^2 - 3
+@@ -4401,7 +4401,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: rt2b = rt3 + rt2 - rt3
+             sage: rt2b.exactify()
+             sage: rt2b._exact_value()
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b.simplify()
+             sage: rt2b._exact_value()
+             a where a^2 - 2 = 0 and a in 1.414213562373095?
+@@ -4422,7 +4422,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: QQbar(2)._exact_field()
+             Trivial generator
+             sage: (sqrt(QQbar(2)) + sqrt(QQbar(19)))._exact_field()
+-            Number Field in a with defining polynomial y^4 - 20*y^2 + 81 with a in 2.375100220297941?
++            Number Field in a with defining polynomial y^4 - 20*y^2 + 81 with a in -3.789313782671036?
+             sage: (QQbar(7)^(3/5))._exact_field()
+             Number Field in a with defining polynomial y^5 - 2*y^4 - 18*y^3 + 38*y^2 + 82*y - 181 with a in 2.554256611698490?
+         """
+@@ -4442,7 +4442,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: QQbar(2)._exact_value()
+             2
+             sage: (sqrt(QQbar(2)) + sqrt(QQbar(19)))._exact_value()
+-            -1/9*a^3 - a^2 + 11/9*a + 10 where a^4 - 20*a^2 + 81 = 0 and a in 2.375100220297941?
++            -1/9*a^3 + a^2 + 11/9*a - 10 where a^4 - 20*a^2 + 81 = 0 and a in -3.789313782671036?
+             sage: (QQbar(7)^(3/5))._exact_value()
+             2*a^4 + 2*a^3 - 34*a^2 - 17*a + 150 where a^5 - 2*a^4 - 18*a^3 + 38*a^2 + 82*a - 181 = 0 and a in 2.554256611698490?
+         """
+@@ -6857,7 +6857,7 @@ class AlgebraicPolynomialTracker(SageObject):
+             sage: p = sqrt(AA(2)) * x^2 - sqrt(AA(3))
+             sage: cp = AA.common_polynomial(p)
+             sage: cp.generator()
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 1.931851652578137?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -0.5176380902050415?
+         """
+         self.exactify()
+         return self._gen
+@@ -7706,7 +7706,7 @@ class ANExtensionElement(ANDescr):
+ 
+             sage: rt2b.exactify()
+             sage: rt2b._descr
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b._descr.is_simple()
+             False
+         """
+@@ -7791,7 +7791,7 @@ class ANExtensionElement(ANDescr):
+             sage: rt2b = rt3 + rt2 - rt3
+             sage: rt2b.exactify()
+             sage: rt2b._descr
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b._descr.simplify(rt2b)
+             a where a^2 - 2 = 0 and a in 1.414213562373095?
+         """
+@@ -7830,9 +7830,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.neg(a)
+-            1/3*a^3 - 2/3*a^2 + 4/3*a - 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -1/3*a^3 + 1/3*a^2 - a - 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+             sage: b.neg("ham spam and eggs")
+-            1/3*a^3 - 2/3*a^2 + 4/3*a - 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -1/3*a^3 + 1/3*a^2 - a - 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+         """
+         return ANExtensionElement(self._generator, -self._value)
+ 
+@@ -7848,9 +7848,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.invert(a)
+-            7/3*a^3 - 2/3*a^2 + 4/3*a - 12 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -7/3*a^3 + 19/3*a^2 - 7*a - 9 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+             sage: b.invert("ham spam and eggs")
+-            7/3*a^3 - 2/3*a^2 + 4/3*a - 12 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -7/3*a^3 + 19/3*a^2 - 7*a - 9 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+         """
+         return ANExtensionElement(self._generator, ~self._value)
+ 
+@@ -7866,9 +7866,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.conjugate(a)
+-            -1/3*a^3 + 2/3*a^2 - 4/3*a + 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? + 1.573132184970987?*I
++            1/3*a^3 - 1/3*a^2 + a + 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? - 1.573132184970987?*I
+             sage: b.conjugate("ham spam and eggs")
+-            -1/3*a^3 + 2/3*a^2 - 4/3*a + 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? + 1.573132184970987?*I
++            1/3*a^3 - 1/3*a^2 + a + 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? - 1.573132184970987?*I
+         """
+         if self._exactly_real:
+             return self
+@@ -8501,7 +8501,7 @@ def an_binop_expr(a, b, op):
+         sage: x = an_binop_expr(a, b, operator.add); x
+         <sage.rings.qqbar.ANBinaryExpr object at ...>
+         sage: x.exactify()
+-        -6/7*a^7 + 2/7*a^6 + 71/7*a^5 - 26/7*a^4 - 125/7*a^3 + 72/7*a^2 + 43/7*a - 47/7 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in 3.12580...?
++        6/7*a^7 - 2/7*a^6 - 71/7*a^5 + 26/7*a^4 + 125/7*a^3 - 72/7*a^2 - 43/7*a + 47/7 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in -0.3199179336182997?
+ 
+         sage: a = QQbar(sqrt(2)) + QQbar(sqrt(3))
+         sage: b = QQbar(sqrt(3)) + QQbar(sqrt(5))
+@@ -8510,7 +8510,7 @@ def an_binop_expr(a, b, op):
+         sage: x = an_binop_expr(a, b, operator.mul); x
+         <sage.rings.qqbar.ANBinaryExpr object at ...>
+         sage: x.exactify()
+-        2*a^7 - a^6 - 24*a^5 + 12*a^4 + 46*a^3 - 22*a^2 - 22*a + 9 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in 3.1258...?
++        2*a^7 - a^6 - 24*a^5 + 12*a^4 + 46*a^3 - 22*a^2 - 22*a + 9 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in -0.3199179336182997?
+     """
+     return ANBinaryExpr(a, b, op)
+ 
+diff --git a/src/sage/schemes/affine/affine_morphism.py b/src/sage/schemes/affine/affine_morphism.py
+index 1c4f2dff18..32c2e47e49 100644
+--- a/src/sage/schemes/affine/affine_morphism.py
++++ b/src/sage/schemes/affine/affine_morphism.py
+@@ -1148,9 +1148,9 @@ class SchemeMorphism_polynomial_affine_space_field(SchemeMorphism_polynomial_aff
+             sage: H = End(A)
+             sage: f = H([(QQbar(sqrt(2))*x^2 + 1/QQbar(sqrt(3))) / (5*x)])
+             sage: f.reduce_base_field()
+-            Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a = 1.931851652578137?
++            Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a = ...?
+               Defn: Defined on coordinates by sending (x) to
+-                    (((a^3 - 3*a)*x^2 + (1/3*a^2 - 2/3))/(5*x))
++                    (((a^3 - 3*a)*x^2 + (-1/3*a^2 + 2/3))/(5*x))
+ 
+         ::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_field.py b/src/sage/schemes/elliptic_curves/ell_field.py
+index 68b8375dae..48f358ea6a 100644
+--- a/src/sage/schemes/elliptic_curves/ell_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_field.py
+@@ -845,7 +845,7 @@ class EllipticCurve_field(ell_generic.EllipticCurve_generic, ProjectivePlaneCurv
+             sage: E = E.base_extend(G).quadratic_twist(c); E
+             Elliptic Curve defined by y^2 = x^3 + 5*a0*x^2 + (-200*a0^2)*x + (-42000*a0^2+42000*a0+126000) over Number Field in a0 with defining polynomial x^3 - 3*x^2 + 3*x + 9
+             sage: K.<b> = E.division_field(3, simplify_all=True); K
+-            Number Field in b with defining polynomial x^12 - 10*x^10 + 55*x^8 - 60*x^6 + 75*x^4 + 1350*x^2 + 2025
++            Number Field in b with defining polynomial x^12 + 5*x^10 + 40*x^8 + 315*x^6 + 750*x^4 + 675*x^2 + 2025
+ 
+         Some higher-degree examples::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_generic.py b/src/sage/schemes/elliptic_curves/ell_generic.py
+index 926ae310ea..3bae819fb0 100644
+--- a/src/sage/schemes/elliptic_curves/ell_generic.py
++++ b/src/sage/schemes/elliptic_curves/ell_generic.py
+@@ -3324,8 +3324,8 @@ 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),
++            [0, 0, 0, Mod(1, y^2 - 2),
++            Mod(y, y^2 - 2), 0, 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;
+diff --git a/src/sage/schemes/elliptic_curves/ell_number_field.py b/src/sage/schemes/elliptic_curves/ell_number_field.py
+index edbd196090..c44c803aa8 100644
+--- a/src/sage/schemes/elliptic_curves/ell_number_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_number_field.py
+@@ -218,7 +218,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: E == loads(dumps(E))
+             True
+             sage: E.simon_two_descent()
+-            (2, 2, [(0 : 0 : 1)])
++            (2, 2, [(0 : 0 : 1), (1/18*a + 7/18 : -5/54*a - 17/54 : 1)])
+             sage: E.simon_two_descent(lim1=5, lim3=5, limtriv=10, maxprob=7, limbigprime=10)
+             (2, 2, [(-1 : 0 : 1), (-2 : -1/2*a - 1/2 : 1)])
+ 
+@@ -274,7 +274,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: E.simon_two_descent()  # long time (4s on sage.math, 2013)
+             (3,
+              3,
+-             [(5/8*zeta43_0^2 + 17/8*zeta43_0 - 9/4 : -27/16*zeta43_0^2 - 103/16*zeta43_0 + 39/8 : 1),
++             [(1/8*zeta43_0^2 - 3/8*zeta43_0 - 1/4 : -5/16*zeta43_0^2 + 7/16*zeta43_0 + 1/8 : 1),
+               (0 : 0 : 1)])
+         """
+         verbose = int(verbose)
+@@ -865,7 +865,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             Conductor exponent: 1
+             Kodaira Symbol: I1
+             Tamagawa Number: 1,
+-            Local data at Fractional ideal (-3*i - 2):
++            Local data at Fractional ideal (-2*i + 3):
+             Reduction type: bad split multiplicative
+             Local minimal model: Elliptic Curve defined by y^2 + (i+1)*x*y + y = x^3 over Number Field in i with defining polynomial x^2 + 1
+             Minimal discriminant valuation: 2
+@@ -2645,12 +2645,12 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             [-92, -23, -23]
+ 
+             sage: C.matrix()  # long time
+-            [1 2 2 4 2 4]
+-            [2 1 2 2 4 4]
+-            [2 2 1 4 4 2]
+-            [4 2 4 1 3 3]
+-            [2 4 4 3 1 3]
+-            [4 4 2 3 3 1]
++            [1 2 2 4 4 2]
++            [2 1 2 4 2 4]
++            [2 2 1 2 4 4]
++            [4 4 2 1 3 3]
++            [4 2 4 3 1 3]
++            [2 4 4 3 3 1]
+ 
+         The graph of this isogeny class has a shape which does not
+         occur over `\QQ`: a triangular prism.  Note that for curves
+@@ -2677,12 +2677,12 @@ class EllipticCurve_number_field(EllipticCurve_field):
+ 
+             sage: G = C.graph()  # long time
+             sage: G.adjacency_matrix()  # long time
+-            [0 1 1 0 1 0]
+-            [1 0 1 1 0 0]
+-            [1 1 0 0 0 1]
+-            [0 1 0 0 1 1]
+-            [1 0 0 1 0 1]
+-            [0 0 1 1 1 0]
++            [0 1 1 0 0 1]
++            [1 0 1 0 1 0]
++            [1 1 0 1 0 0]
++            [0 0 1 0 1 1]
++            [0 1 0 1 0 1]
++            [1 0 0 1 1 0]
+ 
+         To display the graph without any edge labels::
+ 
+@@ -3316,7 +3316,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: points = [E.lift_x(x) for x in xi]
+             sage: newpoints, U = E.lll_reduce(points)  # long time (35s on sage.math, 2011)
+             sage: [P[0] for P in newpoints]            # long time
+-            [6823803569166584943, 5949539878899294213, 2005024558054813068, 5864879778877955778, 23955263915878682727/4, 5922188321411938518, 5286988283823825378, 175620639884534615751/25, -11451575907286171572, 3502708072571012181, 1500143935183238709184/225, 27180522378120223419/4, -5811874164190604461581/625, 26807786527159569093, 7404442636649562303, 475656155255883588, 265757454726766017891/49, 7272142121019825303, 50628679173833693415/4, 6951643522366348968, 6842515151518070703, 111593750389650846885/16, 2607467890531740394315/9, -1829928525835506297]
++            [6823803569166584943, 5949539878899294213, 2005024558054813068, 5864879778877955778, 23955263915878682727/4, 5922188321411938518, 5286988283823825378, 11465667352242779838, -11451575907286171572, 3502708072571012181, 1500143935183238709184/225, 27180522378120223419/4, -5811874164190604461581/625, 26807786527159569093, 7041412654828066743, 475656155255883588, 265757454726766017891/49, 7272142121019825303, 50628679173833693415/4, 6951643522366348968, 6842515151518070703, 111593750389650846885/16, 2607467890531740394315/9, -1829928525835506297]
+ 
+         An example to show the explicit use of the height pairing matrix::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_rational_field.py b/src/sage/schemes/elliptic_curves/ell_rational_field.py
+index 3808822812..a75290ea35 100644
+--- a/src/sage/schemes/elliptic_curves/ell_rational_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_rational_field.py
+@@ -1827,7 +1827,7 @@ class EllipticCurve_rational_field(EllipticCurve_number_field):
+             sage: E = EllipticCurve('389a1')
+             sage: E._known_points = []  # clear cached points
+             sage: E.simon_two_descent()
+-            (2, 2, [(1 : 0 : 1), (-11/9 : 28/27 : 1)])
++            (2, 2, [(5/4 : 5/8 : 1), (-3/4 : 7/8 : 1)])
+             sage: E = EllipticCurve('5077a1')
+             sage: E.simon_two_descent()
+             (3, 3, [(1 : 0 : 1), (2 : 0 : 1), (0 : 2 : 1)])
+diff --git a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
+index 81ad295160..d484a4a18b 100644
+--- a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
++++ b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
+@@ -780,12 +780,12 @@ def deg_one_primes_iter(K, principal_only=False):
+         [Fractional ideal (2, a + 1),
+          Fractional ideal (3, a + 1),
+          Fractional ideal (3, a + 2),
+-         Fractional ideal (-a),
++         Fractional ideal (a),
+          Fractional ideal (7, a + 3),
+          Fractional ideal (7, a + 4)]
+         sage: it = deg_one_primes_iter(K, True)
+         sage: [next(it) for _ in range(6)]
+-        [Fractional ideal (-a),
++        [Fractional ideal (a),
+          Fractional ideal (-2*a + 3),
+          Fractional ideal (2*a + 3),
+          Fractional ideal (a + 6),
+diff --git a/src/sage/schemes/elliptic_curves/gp_simon.py b/src/sage/schemes/elliptic_curves/gp_simon.py
+index 28b97f34af..9f7d1b6020 100644
+--- a/src/sage/schemes/elliptic_curves/gp_simon.py
++++ b/src/sage/schemes/elliptic_curves/gp_simon.py
+@@ -56,7 +56,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+         sage: import sage.schemes.elliptic_curves.gp_simon
+         sage: E=EllipticCurve('389a1')
+         sage: sage.schemes.elliptic_curves.gp_simon.simon_two_descent(E)
+-        (2, 2, [(1 : 0 : 1), (-11/9 : 28/27 : 1)])
++        (2, 2, [(5/4 : 5/8 : 1), (-3/4 : 7/8 : 1)])
+ 
+     TESTS::
+ 
+@@ -117,7 +117,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+     # The block below mimics the defaults in Simon's scripts, and needs to be changed
+     # when these are updated.
+     if K is QQ:
+-        cmd = 'ellrank(%s, %s);' % (list(E.ainvs()), [P.__pari__() for P in known_points])
++        cmd = 'ellQ_ellrank(%s, %s);' % (list(E.ainvs()), [P.__pari__() for P in known_points])
+         if lim1 is None:
+             lim1 = 5
+         if lim3 is None:
+@@ -144,7 +144,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+     if verbose > 0:
+         print(s)
+     v = gp.eval('ans')
+-    if v=='ans': # then the call to ellrank() or bnfellrank() failed
++    if v=='ans': # then the call to ellQ_ellrank() or bnfellrank() failed
+         raise RuntimeError("An error occurred while running Simon's 2-descent program")
+     if verbose >= 2:
+         print("v = %s" % v)
+diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
+index a936deb74f..dc19254d8c 100644
+--- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
++++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
+@@ -1208,14 +1208,14 @@ def isogenies_13_0(E, minimal_models=True):
+         sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]  # long time (4s)
+         [(0,
+           0,
+-          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
++          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 + 1887439/1146978983704320*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 + 1030632647/7965131831280*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 - 43618899433/204234149520*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 2535050171/1418292705,
+           -139861295/2650795873449984*a^11 - 3455957/5664093746688*a^10 - 345310571/50976843720192*a^9 - 500530795/118001953056*a^8 - 12860048113/265504394376*a^7 - 25007420461/44250732396*a^6 + 458134176455/1416023436672*a^5 + 16701880631/9077073312*a^4 + 155941666417/9077073312*a^3 + 3499310115/378211388*a^2 - 736774863/94552847*a - 21954102381/94552847,
+-          579363345221/13763747804451840*a^11 + 371192377511/860234237778240*a^10 + 8855090365657/1146978983704320*a^9 + 5367261541663/1633873196160*a^8 + 614883554332193/15930263662560*a^7 + 30485197378483/68078049840*a^6 - 131000897588387/2450809794240*a^5 - 203628705777949/306351224280*a^4 - 1587619388190379/204234149520*a^3 + 14435069706551/11346341640*a^2 + 7537273048614/472764235*a + 89198980034806/472764235),
++          8342795944891/198197968384106496*a^11 + 8908625263589/20645621706677760*a^10 + 53130542636623/6881873902225920*a^9 + 376780111042213/114697898370432*a^8 + 614884052146333/15930263662560*a^7 + 3566768133324359/7965131831280*a^6 - 1885593809102545/35291661037056*a^5 - 2443732172026523/3676214691360*a^4 - 9525729503937541/1225404897120*a^3 + 51990274442321/40846829904*a^2 + 67834019370596/4254878115*a + 267603083706812/1418292705),
+          (0,
+           0,
+-          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
++          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 + 1887439/1146978983704320*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 + 1030632647/7965131831280*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 - 43618899433/204234149520*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 2535050171/1418292705,
+           -6465569317/1325397936724992*a^11 - 112132307/1960647835392*a^10 - 17075412917/25488421860096*a^9 - 207832519229/531008788752*a^8 - 1218275067617/265504394376*a^7 - 9513766502551/177002929584*a^6 + 4297077855437/708011718336*a^5 + 354485975837/4538536656*a^4 + 4199379308059/4538536656*a^3 - 30841577919/189105694*a^2 - 181916484042/94552847*a - 2135779171614/94552847,
+-          -132601797212627/3440936951112960*a^11 - 6212467020502021/13763747804451840*a^10 - 1515926454902497/286744745926080*a^9 - 15154913741799637/4901619588480*a^8 - 576888119803859263/15930263662560*a^7 - 86626751639648671/204234149520*a^6 + 16436657569218427/306351224280*a^5 + 1540027900265659087/2450809794240*a^4 + 375782662805915809/51058537380*a^3 - 14831920924677883/11346341640*a^2 - 7237947774817724/472764235*a - 84773764066089509/472764235)]
++          -1316873026840277/34172063514501120*a^11 - 18637401045099413/41291243413355520*a^10 - 36382234917217247/6881873902225920*a^9 - 61142238484016213/19775499719040*a^8 - 576888119306045123/15930263662560*a^7 - 3378443313906256321/7965131831280*a^6 + 326466167429333279/6084769144320*a^5 + 4620083325391594991/7352429382720*a^4 + 9018783894167184149/1225404897120*a^3 - 9206015742300283/7042556880*a^2 - 65141531411426446/4254878115*a - 254321286054666133/1418292705)]
+     """
+     if E.j_invariant()!=0:
+         raise ValueError("j-invariant must be 0.")
diff --git a/srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch b/srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch
new file mode 100644
index 000000000000..762bb2612632
--- /dev/null
+++ b/srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch
@@ -0,0 +1,29 @@
+From f0365f30834b6890313790b3845c647d0160fa6a Mon Sep 17 00:00:00 2001
+From: Vincent Delecroix <20100.delecroix@gmail.com*>
+Date: Fri, 30 Sep 2022 16:31:08 +0200
+Subject: fix doctest if fqf_orthogonal
+
+---
+ src/sage/groups/fqf_orthogonal.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/sage/groups/fqf_orthogonal.py b/src/sage/groups/fqf_orthogonal.py
+index 75de408..7fc4dbe 100644
+--- a/src/sage/groups/fqf_orthogonal.py
++++ b/src/sage/groups/fqf_orthogonal.py
+@@ -245,10 +245,10 @@ class FqfOrthogonalGroup(AbelianGroupAutomorphismGroup_subgroup):
+             sage: all(x*f==x*fbar for x in q.gens())
+             True
+             sage: L = IntegralLattice("A2").twist(3)
+-            sage: q = L.discriminant_group()
+             sage: OL = L.orthogonal_group()
++            sage: assert OL(OL.0.matrix()) == OL.0
++            sage: q = L.discriminant_group()
+             sage: Oq = q.orthogonal_group()
+-            sage: assert Oq(OL.0) == Oq(OL.0.matrix())
+             sage: assert Oq(Oq.0.matrix()) == Oq.0
+         """
+         from sage.libs.gap.element import GapElement
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch b/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
deleted file mode 100644
index 4bd6f4f4e2dc..000000000000
--- a/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
+++ /dev/null
@@ -1,670 +0,0 @@
-As produced by `git diff 9.5 9.6.beta3 -- src/sage/libs/lrcalc`
-
-diff --git a/src/sage/libs/lrcalc/lrcalc.pxd b/src/sage/libs/lrcalc/lrcalc.pxd
-deleted file mode 100644
-index 10b88db93f2..00000000000
---- a/src/sage/libs/lrcalc/lrcalc.pxd
-+++ /dev/null
-@@ -1,77 +0,0 @@
--# distutils: libraries = lrcalc
--
--cdef extern from "lrcalc/hashtab.h":
--    ctypedef struct hashtab:
--        pass
--
--    ctypedef struct hash_itr:
--        pass
--
--    ctypedef unsigned long hashkey_t
--    ctypedef int (*cmp_t) (void* a, void* b)
--    ctypedef hashkey_t (*hash_t) (void* a)
--
--    hashtab* hash_new(cmp_t cm, hash_t hsh)
--    void hash_free(hashtab *ht)
--
--    void* hash_lookup(hashtab *ht, void *key)
--    void* hash_insert(hashtab *ht, void *key, void *value)
--
--    bint hash_good(hash_itr)
--    void hash_first(hashtab* s, hash_itr itr)
--    void hash_next(hash_itr itr)
--    void* hash_key(hash_itr itr)
--    void* hash_value(hash_itr itr)
--    int hash_intvalue(hash_itr itr)
--
--cdef extern from "lrcalc/vector.h":
--    ctypedef struct vector:
--        size_t length
--        int* array
--
--    vector* v_new(int length)
--    void v_free(vector* v)
--    void v_print(vector *v)
--    int v_length(vector* v)
--    int v_elem(vector* v, int i)
--
--    ctypedef struct vecpair:
--        vector *first
--        vector *second
--
--    vector* vp_first(vecpair* vp)
--    vector* vp_second(vecpair* vp)
--
--cdef extern from "lrcalc/list.h":
--    cdef struct _list:
--        void **array
--        size_t allocated
--        size_t length
--    void l_free(_list *lst)
--
--cdef extern from "lrcalc/symfcn.h":
--    long long lrcoef_c "lrcoef"(vector* outer, vector* inner1, vector* inner2)
--    hashtab* mult_c "mult"(vector *sh1, vector *sh2, int maxrows)
--    hashtab* skew_c "skew"(vector *outer, vector *inner, int maxrows)
--    hashtab* coprod_c "coprod"(vector *part, int all)
--    void fusion_reduce_c "fusion_reduce"(hashtab* ht, int rows, int cols, int opt_zero)
--    _list *quantum_reduce_c "quantum_reduce"(hashtab* ht, int rows, int col)
--
--    ctypedef struct skewtab:
--        vector *outer
--        vector *inner
--        vector *conts
--        int maxrows
--        vector *conjugate
--        int rows
--        int cols
--        int matrix[1]
--
--    skewtab *st_new(vector *outer, vector *inner, vector *conts, int maxrows)
--    int st_next(skewtab *st)
--    void st_print(skewtab *st)
--    void st_free(skewtab *st)
--
--
--cdef extern from "lrcalc/schublib.h":
--    hashtab* mult_schubert_c "mult_schubert"(vector *sh1, vector *sh2, int rank)
-diff --git a/src/sage/libs/lrcalc/lrcalc.pyx b/src/sage/libs/lrcalc/lrcalc.py
-similarity index 60%
-rename from src/sage/libs/lrcalc/lrcalc.pyx
-rename to src/sage/libs/lrcalc/lrcalc.py
-index b591081ec4c..b541bfacd89 100644
---- a/src/sage/libs/lrcalc/lrcalc.pyx
-+++ b/src/sage/libs/lrcalc/lrcalc.py
-@@ -10,7 +10,8 @@ fusion products. All of the above are achieved by counting LR
- appropriate shape and content by iterating through them.
- Additionally, ``lrcalc`` handles products of Schubert polynomials.
- 
--The web page of ``lrcalc`` is `<http://sites.math.rutgers.edu/~asbuch/lrcalc/>`_.
-+The web page of ``lrcalc`` is
-+`<http://sites.math.rutgers.edu/~asbuch/lrcalc/>`_.
- 
- The following describes the Sage interface to this library.
- 
-@@ -36,12 +37,13 @@ Schur expansion::
-      [4, 2]: 1}
- 
- Same product, but include only partitions with at most 3 rows.  This
--corresponds to computing in the representation ring of gl(3)::
-+corresponds to computing in the representation ring of `\mathfrak{gl}(3)`::
- 
-     sage: lrcalc.mult([2,1], [2,1], 3)
-     {[2, 2, 2]: 1, [3, 2, 1]: 2, [3, 3]: 1, [4, 1, 1]: 1, [4, 2]: 1}
- 
--We can also compute the fusion product, here for sl(3) and level 2::
-+We can also compute the fusion product, here for `\mathfrak{sl}(3)`
-+and level 2::
- 
-     sage: lrcalc.mult([3,2,1], [3,2,1], 3,2)
-     {[4, 4, 4]: 1, [5, 4, 3]: 1}
-@@ -77,42 +79,38 @@ Multiply two Schubert polynomials::
-      [6, 2, 1, 4, 3, 5]: 1}
- 
- Same product, but include only permutations of 5 elements in the result.
--This corresponds to computing in the cohomology ring of Fl(5)::
-+This corresponds to computing in the cohomology ring of `Fl(5)`::
- 
-     sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3], 5)
-     {[4, 5, 1, 3, 2]: 1, [5, 3, 1, 4, 2]: 1, [5, 4, 1, 2, 3]: 1}
- 
- List all Littlewood-Richardson tableaux of skew shape `\mu/\nu`; in
- this example `\mu=[3,2,1]` and `\nu=[2,1]`. Specifying a third entry
--`maxrows` restricts the alphabet to `\{1,2,\ldots,maxrows\}`::
-+`M' = ``maxrows`` restricts the alphabet to `\{1,2,\ldots,M\}`::
- 
-     sage: list(lrcalc.lrskew([3,2,1],[2,1]))
-     [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
-     [[None, None, 1], [None, 2], [1]], [[None, None, 1], [None, 2], [3]]]
- 
-     sage: list(lrcalc.lrskew([3,2,1],[2,1],maxrows=2))
--    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]], [[None, None, 1], [None, 2], [1]]]
-+    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
-+     [[None, None, 1], [None, 2], [1]]]
- 
- .. TODO::
- 
--    use this library in the :class:`SymmetricFunctions` code, to
-+    Use this library in the :class:`SymmetricFunctions` code, to
-     make it easy to apply it to linear combinations of Schur functions.
- 
- .. SEEALSO::
- 
-     - :func:`lrcoef`
--
-     - :func:`mult`
--
-     - :func:`coprod`
--
-     - :func:`skew`
--
-     - :func:`lrskew`
--
-     - :func:`mult_schubert`
- 
--.. rubric:: Underlying algorithmic in lrcalc
-+.. RUBRIC:: Underlying algorithmic in lrcalc
- 
- Here is some additional information regarding the main low-level
- C-functions in `lrcalc`. Given two partitions ``outer`` and ``inner``
-@@ -187,180 +185,24 @@ AUTHORS:
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from sage.rings.integer cimport Integer
--from sage.structure.parent cimport Parent
- from sage.combinat.partition import _Partitions
- from sage.combinat.permutation import Permutation
--from sage.combinat.skew_tableau import SkewTableau
--
--
--cdef vector* iterable_to_vector(it):
--    """
--    Return an lrcalc vector (which is a list of integers) from a Python iterable.
--
--    TESTS::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector(Partition([3,2,1])); x   #indirect doctest
--        [3, 2, 1]
--    """
--    cdef vector* v
--    cdef list itr = list(it)
--    cdef int n = len(itr)
--    cdef int i
--    v = v_new(n)
--    for i in range(n):
--        v.array[i] = int(itr[i])
--    return v
--
--
--cdef list vector_to_list(vector *v):
--    """
--    Converts a lrcalc vector to Python list.
--
--    TESTS::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector([]); x         #indirect doctest
--        []
--    """
--    cdef int i, n
--    n = v_length(v)
--    cdef list result = [None]*n
--    for i in range(n):
--        result[i] = Integer(v_elem(v, i))
--    return result
--
--
--def test_iterable_to_vector(it):
--    """
--    A wrapper function for the cdef function ``iterable_to_vector``
--    and ``vector_to_list``, to test that they are working correctly.
-+from sage.combinat.skew_tableau import SemistandardSkewTableaux
-+from sage.combinat.skew_partition import SkewPartition
-+from sage.rings.integer import Integer
-+import lrcalc
- 
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector([3,2,1]); x
--        [3, 2, 1]
--    """
--    cdef vector *v = iterable_to_vector(it)
--    result = vector_to_list(v)
--    v_free(v)
--    return result
--
--
--cdef skewtab_to_SkewTableau(skewtab *st):
--    """
--    A wrapper function which transforms the data set ``st`` used in
--    ``lrcalc`` to a ``SkewTableau`` in Sage.
-+def _lrcalc_dict_to_sage(result):
-+    r"""
-+    Translate from lrcalc output format to Sage expected format.
- 
-     TESTS::
- 
--        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
--        sage: test_skewtab_to_SkewTableau([],[])
--        []
--    """
--    inner = vector_to_list(st.inner)
--    outer = vector_to_list(st.outer)
--    return SkewTableau(expr=[[inner[y] for y in range(len(outer))],
--                             [[st.matrix[x + y * st.cols] + 1
--                                for x in range(inner[y], outer[y])]
--                              for y in range(len(outer) - 1, -1, -1)]])
--
--
--def test_skewtab_to_SkewTableau(outer, inner):
--    """
--    A wrapper function for the cdef function ``skewtab_to_SkewTableau``
--    for testing purposes.
--
--    It constructs the first LR skew tableau of shape ``outer/inner``
--    as an ``lrcalc`` ``skewtab``, and converts it to a
--    :class:`SkewTableau`.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
--        sage: test_skewtab_to_SkewTableau([3,2,1],[])
--        [[1, 1, 1], [2, 2], [3]]
--        sage: test_skewtab_to_SkewTableau([4,3,2,1],[1,1]).pp()
--        .  1  1  1
--        .  2  2
--        1  3
--        2
--    """
--    cdef vector* o = iterable_to_vector(outer)
--    cdef vector* i = iterable_to_vector(inner+[0]*(len(outer)-len(inner)))
--    cdef skewtab* st = st_new(o, i, NULL, 0)
--    return skewtab_to_SkewTableau(st)
--
--
--cdef dict sf_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary representing a Schur function. The keys are
--    partitions and the values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
-         sage: from sage.libs.lrcalc.lrcalc import mult
--        sage: sorted(mult([1],[1]).items())        #indirect doctest
--        [([1, 1], 1), ([2], 1)]
--        sage: assert isinstance(mult([1],[1]),dict)#indirect doctest
--    """
--    cdef hash_itr itr
--    cdef dict result = {}
--    cdef list p
--    hash_first(ht, itr)
--    while hash_good(itr):
--        p = vector_to_list(<vector*> hash_key(itr))
--        result[_Partitions(p)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
--
--cdef dict schubert_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary corresponding to a Schubert polynomial whose keys
--    are permutations and whose values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import mult_schubert
--        sage: mult_schubert([3,2,1], [1,2,3])      #indirect doctest
--        {[3, 2, 1]: 1}
--    """
--    cdef hash_itr itr
--    cdef dict result = {}
--    hash_first(ht, itr)
--    while hash_good(itr):
--        p = vector_to_list(<vector*> hash_key(itr))
--        result[Permutation(p)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
--
--cdef dict vp_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary corresponding to the coproduct of a Schur function whose keys are
--    pairs of partitions and whose values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import coprod
--        sage: coprod([1])      #indirect doctest
--        {([1], []): 1}
-+        sage: mult([2,1],[3,2,1],3) # indirect doctest
-+        {[3, 3, 3]: 1, [4, 3, 2]: 2, [4, 4, 1]: 1, [5, 2, 2]: 1, [5, 3, 1]: 1}
-     """
--    cdef hash_itr itr
--    cdef vecpair* vp
--    cdef dict result = {}
--    hash_first(ht, itr)
--    while hash_good(itr):
--        vp = <vecpair*> hash_key(itr)
--        p1 = _Partitions(vector_to_list(vp_first(vp)))
--        p2 = _Partitions(vector_to_list(vp_second(vp)))
--        result[(p1, p2)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
-+    return {_Partitions(la): Integer(k) for la, k in result.items()}
- 
- def lrcoef_unsafe(outer, inner1, inner2):
-     r"""
-@@ -371,13 +213,11 @@ def lrcoef_unsafe(outer, inner1, inner2):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
--
--    - ``inner1`` -- a partition.
-+    - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
-+    - ``inner1`` -- a partition
-+    - ``inner2`` -- a partition
- 
--    - ``inner2`` -- a partition.
--
--    .. warning::
-+    .. WARNING::
- 
-        This function does not do any check on its input.  If you want
-        to use a safer version, use :func:`lrcoef`.
-@@ -392,18 +232,7 @@ def lrcoef_unsafe(outer, inner1, inner2):
-         sage: lrcoef_unsafe([2,1,1,1,1], [2,1], [2,1])
-         0
-     """
--    cdef long long result
--    cdef vector *o
--    cdef vector *i1
--    cdef vector *i2
--    o = iterable_to_vector(outer)
--    i1 = iterable_to_vector(inner1)
--    i2 = iterable_to_vector(inner2)
--    result = lrcoef_c(o, i1, i2)
--    v_free(o)
--    v_free(i1)
--    v_free(i2)
--    return Integer(result)
-+    return Integer(lrcalc.lrcoef(outer, inner1, inner2))
- 
- 
- def lrcoef(outer, inner1, inner2):
-@@ -415,11 +244,9 @@ def lrcoef(outer, inner1, inner2):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
--
--    - ``inner1`` -- a partition.
--
--    - ``inner2`` -- a partition.
-+    - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
-+    - ``inner1`` -- a partition
-+    - ``inner2`` -- a partition
- 
-     .. NOTE::
- 
-@@ -436,7 +263,6 @@ def lrcoef(outer, inner1, inner2):
-         1
-         sage: lrcoef([2,1,1,1,1], [2,1], [2,1])
-         0
--
-     """
-     return lrcoef_unsafe(_Partitions(outer), _Partitions(inner1), _Partitions(inner2))
- 
-@@ -451,13 +277,9 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-     INPUT:
- 
-     - ``part1`` -- a partition
--
-     - ``part2`` -- a partition
--
-     - ``maxrows`` -- (optional) an integer
--
-     - ``level`` -- (optional) an integer
--
-     - ``quantum`` -- (optional) an element of a ring
- 
-     If ``maxrows`` is specified, then only partitions with at most
-@@ -479,7 +301,8 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-         sage: sorted(mult([2],[2]).items())
-         [([2, 2], 1), ([3, 1], 1), ([4], 1)]
-         sage: sorted(mult([2,1],[2,1]).items())
--        [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1), ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
-+        [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1),
-+         ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
-         sage: sorted(mult([2,1],[2,1],maxrows=2).items())
-         [([3, 3], 1), ([4, 2], 1)]
-         sage: mult([2,1],[3,2,1],3)
-@@ -510,44 +333,24 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-     if quantum is not None and (level is None or maxrows is None):
-         raise ValueError('missing parameters maxrows or level')
- 
--    cdef vector* v1 = iterable_to_vector(part1)
--    cdef vector* v2 = iterable_to_vector(part2)
--    if maxrows is None:
--        maxrows = 0
--    cdef hashtab* ht = mult_c(v1, v2, int(maxrows))
--    cdef hashtab* tab
--    cdef dict result
--
-     if quantum is None:
-         if level is not None:
--            fusion_reduce_c(ht, int(maxrows), int(level), int(0))
--        result = sf_hashtab_to_dict(ht)
--        v_free(v1)
--        v_free(v2)
--        hash_free(ht)
--        return result
-+            return _lrcalc_dict_to_sage(lrcalc.mult_fusion(part1, part2, maxrows, level))
-+        if maxrows is None:
-+            maxrows = -1
-+        return _lrcalc_dict_to_sage(lrcalc.mult(part1, part2, maxrows))
- 
-     # Otherwise do quantum multiplication
--    cdef _list *qlist
--    cdef dict temp
--    qlist = quantum_reduce_c(ht, int(maxrows), int(level))
--    # The above call frees the memory associated with ht
--    v_free(v1)
--    v_free(v2)
--
--    cdef Parent P = quantum.parent()
--    result = {}
--    for i in range(qlist.length):
--        tab = <hashtab*>(qlist.array[i])
--        temp = sf_hashtab_to_dict(tab)
--        for k in temp:
--            result[k] = result.get(k, P.zero()) + quantum**i * temp[k]
--        hash_free(tab)
--    l_free(qlist)
--    return result
--
--
--def skew(outer, inner, maxrows=0):
-+    result = lrcalc.mult_quantum(part1, part2, maxrows, level, degrees=True)
-+    P = quantum.parent()
-+    output = {}
-+    for i,k in result.items():
-+        la = _Partitions(i[0])
-+        output[la] = output.get(la, P.zero()) + k * quantum**(i[1])
-+    return output
-+
-+
-+def skew(outer, inner, maxrows=-1):
-     """
-     Compute the Schur expansion of a skew Schur function.
- 
-@@ -557,11 +360,9 @@ def skew(outer, inner, maxrows=0):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition.
--
--    - ``inner`` -- a partition.
--
--    - ``maxrows`` -- an integer or ``None``.
-+    - ``outer`` -- a partition
-+    - ``inner`` -- a partition
-+    - ``maxrows`` -- an integer or ``None``
- 
-     If ``maxrows`` is specified, then only partitions with at most
-     this number of rows are included in the result.
-@@ -572,14 +373,7 @@ def skew(outer, inner, maxrows=0):
-         sage: sorted(skew([2,1],[1]).items())
-         [([1, 1], 1), ([2], 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(outer)
--    cdef vector* v2 = iterable_to_vector(inner)
--    cdef hashtab* ht = skew_c(v1, v2, int(maxrows))
--    result = sf_hashtab_to_dict(ht)
--    v_free(v1)
--    v_free(v2)
--    hash_free(ht)
--    return result
-+    return _lrcalc_dict_to_sage(lrcalc.skew(outer, inner, maxrows))
- 
- 
- def coprod(part, all=0):
-@@ -592,9 +386,8 @@ def coprod(part, all=0):
- 
-     INPUT:
- 
--    - ``part`` -- a partition.
--
--    - ``all`` -- an integer.
-+    - ``part`` -- a partition
-+    - ``all`` -- an integer
- 
-     If ``all`` is non-zero then all terms are included in the result.
-     If ``all`` is zero, then only pairs of partitions ``(part1,
-@@ -609,12 +402,9 @@ def coprod(part, all=0):
-         sage: sorted(coprod([2,1]).items())
-         [(([1, 1], [1]), 1), (([2], [1]), 1), (([2, 1], []), 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(part)
--    cdef hashtab* ht = coprod_c(v1, int(all))
--    result = vp_hashtab_to_dict(ht)
--    v_free(v1)
--    hash_free(ht)
--    return result
-+    result = lrcalc.coprod(part, all)
-+    return {tuple([_Partitions(mu) for mu in la]): Integer(k)
-+            for la, k in result.items()}
- 
- 
- def mult_schubert(w1, w2, rank=0):
-@@ -627,11 +417,9 @@ def mult_schubert(w1, w2, rank=0):
- 
-     INPUT:
- 
--    - ``w1`` -- a permutation.
--
--    - ``w2`` -- a permutation.
--
--    - ``rank`` -- an integer.
-+    - ``w1`` -- a permutation
-+    - ``w2`` -- a permutation
-+    - ``rank`` -- an integer
- 
-     If ``rank`` is non-zero, then only permutations from the symmetric
-     group `S(\mathrm{rank})` are included in the result.
-@@ -646,33 +434,24 @@ def mult_schubert(w1, w2, rank=0):
-          ([6, 4, 3, 1, 2, 5], 1), ([6, 5, 2, 1, 3, 4], 1),
-          ([7, 3, 4, 1, 2, 5, 6], 1), ([7, 4, 2, 1, 3, 5, 6], 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(w1)
--    cdef vector* v2 = iterable_to_vector(w2)
--    cdef hashtab* ht = mult_schubert_c(v1, v2, int(rank))
--    result = schubert_hashtab_to_dict(ht)
--    v_free(v1)
--    v_free(v2)
--    hash_free(ht)
--    return result
-+    result = lrcalc.schubmult(w1, w2, rank)
-+    return {Permutation(list(la)):Integer(k) for la,k in result.items()}
- 
- 
--def lrskew(outer, inner, weight=None, maxrows=0):
-+def lrskew(outer, inner, weight=None, maxrows=-1):
-     r"""
-     Iterate over the skew LR tableaux of shape ``outer / inner``.
- 
-     INPUT:
- 
-     - ``outer`` -- a partition
--
-     - ``inner`` -- a partition
--
-     - ``weight`` -- a partition (optional)
--
--    - ``maxrows`` -- an integer (optional)
-+    - ``maxrows`` -- a positive integer (optional)
- 
-     OUTPUT: an iterator of :class:`SkewTableau`
- 
--    Specifying ``maxrows`` restricts the alphabet to `\{1,2,\ldots,maxrows\}`.
-+    Specifying ``maxrows`` = `M` restricts the alphabet to `\{1,2,\ldots,M\}`.
- 
-     Specifying ``weight`` returns only those tableaux of given content/weight.
- 
-@@ -702,22 +481,40 @@ def lrskew(outer, inner, weight=None, maxrows=0):
- 
-         sage: list(lrskew([3,2,1],[2], weight=[3,1]))
-         [[[None, None, 1], [1, 1], [2]]]
-+
-+    TESTS::
-+
-+        sage: from sage.libs.lrcalc.lrcalc import lrskew
-+        sage: list(lrskew([3,2,1],[2], weight=[]))
-+        []
-+        sage: list(lrskew([3,2,1],[2], weight=[0]))
-+        []
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[]))
-+        [[[None, None, None], [None, None], [None]]]
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[0]))
-+        [[[None, None, None], [None, None], [None]]]
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[1]))
-+        []
-     """
--    cdef vector* o = iterable_to_vector(outer)
--    cdef vector* i = iterable_to_vector(inner + [0]*(len(outer) - len(inner)))
--    cdef skewtab* st = st_new(o, i, NULL, int(maxrows))
-+    iterator = lrcalc.lr_iterator(outer, inner, maxrows)
-+    shape = SkewPartition([outer, inner])
- 
-     if weight is None:
--        yield skewtab_to_SkewTableau(st)
--        while st_next(st):
--            yield skewtab_to_SkewTableau(st)
-+        ST = SemistandardSkewTableaux(shape)
-+        for data in iterator:
-+            yield ST.from_shape_and_word(shape, [i+1 for i in data])
-     else:
-         wt = _Partitions(weight)
--        r = skewtab_to_SkewTableau(st)
--        if r.weight() == wt:
--            yield r
--        while st_next(st):
--            r = skewtab_to_SkewTableau(st)
--            if r.weight() == wt:
--                yield r
--    st_free(st)
-+        ST = SemistandardSkewTableaux(shape, wt)
-+        m = len(wt)
-+        for data in iterator:
-+            w = [0] * m
-+            for j in data:
-+                if j >= m:
-+                    # We know they are not equal, so make the check below quick
-+                    w = None
-+                    break
-+                w[j] += 1
-+            if w == wt:
-+                yield ST.from_shape_and_word(shape, [i+1 for i in data])
-+
diff --git a/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch b/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
deleted file mode 100644
index 1e2e0ba90742..000000000000
--- a/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-As produced by `git diff a90a3146{^^,}`
-
-diff --git a/src/sage/repl/interface_magic.py b/src/sage/repl/interface_magic.py
-index 8a455b69b0e..a93e1c9e04c 100644
---- a/src/sage/repl/interface_magic.py
-+++ b/src/sage/repl/interface_magic.py
-@@ -260,7 +260,7 @@ class InterfaceMagic(object):
-             2
-             120
-             sage: shell.run_cell('%%gap foo\n1+1;\n')
--            ...File "<string>", line unknown
-+            ...File...<string>...
-             SyntaxError: Interface magics have no options, got "foo"
-             <BLANKLINE>
-             sage: shell.run_cell('%%gap?')
-diff --git a/src/sage/repl/interpreter.py b/src/sage/repl/interpreter.py
-index 7468afe52d7..06c47b7374a 100644
---- a/src/sage/repl/interpreter.py
-+++ b/src/sage/repl/interpreter.py
-@@ -78,9 +78,9 @@ Check that Cython source code appears in tracebacks::
-     dummy line
-     ...
-     ZeroDivisionError...Traceback (most recent call last)
--    <ipython-input-...> in <module>...
-+    ...in <module>...
-     ----> 1 Integer(1)/Integer(0)
--    .../sage/rings/integer.pyx in sage.rings.integer.Integer...div...
-+    .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
-     ...
-     -> ...                  raise ZeroDivisionError("rational division by zero")
-        ....:            x = <Rational> Rational.__new__(Rational)
-@@ -423,7 +423,7 @@ def SagePreparseTransformer(lines):
-         sage: from sage.repl.interpreter import get_test_shell
-         sage: shell = get_test_shell()
-         sage: shell.run_cell(bad_syntax)
--          File "<string>", line unknown
-+          File...<string>...
-         SyntaxError: Mismatched ']'
-         <BLANKLINE>
-         sage: shell.quit()
diff --git a/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch b/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
deleted file mode 100644
index 853813b0f5bd..000000000000
--- a/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Fix for ipython 8.1
-
---- a/src/sage/repl/interpreter.py
-+++ b/src/sage/repl/interpreter.py
-@@ -78,7 +78,7 @@ Check that Cython source code appears in tracebacks::
-     dummy line
-     ...
-     ZeroDivisionError...Traceback (most recent call last)
--    ...in <module>...
-+    ...
-     ----> 1 Integer(1)/Integer(0)
-     .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
-     ...
diff --git a/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch b/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
deleted file mode 100644
index b861af7ec982..000000000000
--- a/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
+++ /dev/null
@@ -1,126 +0,0 @@
-From 24cc94b1988a90f3bd22a2368ec30c086283af13 Mon Sep 17 00:00:00 2001
-From: Antonio Rojas <arojas@archlinux.org>
-Date: Sun, 16 Jan 2022 11:55:04 +0100
-Subject: Add abs tol to some arb tests
-
----
- src/sage/functions/error.py    |  2 +-
- src/sage/rings/complex_arb.pyx |  6 +++---
- src/sage/rings/real_arb.pyx    | 10 +++++-----
- 3 files changed, 9 insertions(+), 9 deletions(-)
-
-diff --git a/src/sage/functions/error.py b/src/sage/functions/error.py
-index f48d04f..06f0b24 100644
---- a/src/sage/functions/error.py
-+++ b/src/sage/functions/error.py
-@@ -267,7 +267,7 @@ class Function_erf(BuiltinFunction):
- 
-         Check that real ball evaluation is fixed :trac:`28061`::
- 
--            sage: RealBallField(128)(erf(5))
-+            sage: RealBallField(128)(erf(5)) # abs tol 1e-38
-             [0.99999999999846254020557196514981165651 +/- 7.33e-39]
-         """
-         R = parent or s_parent(x)
-diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
-index f986970..93ff565 100644
---- a/src/sage/rings/complex_arb.pyx
-+++ b/src/sage/rings/complex_arb.pyx
-@@ -3974,8 +3974,8 @@ cdef class ComplexBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: CBF(20).erfc()
--            [5.39586561160790e-176 +/- ...e-191]
-+            sage: CBF(20).erfc() # abs tol 1e-190
-+            [5.39586561160790e-176 +/- 6.73e-191]
-             sage: CBF(100, 100).erfc()
-             [0.00065234366376858 +/- ...e-18] + [-0.00393572636292141 +/- ...e-18]*I
-         """
-@@ -4280,7 +4280,7 @@ cdef class ComplexBall(RingElement):
- 
-         TESTS:
- 
--            sage: CBF(Shi(I))
-+            sage: CBF(Shi(I)) # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]*I
-         """
-         cdef ComplexBall result = self._new()
-diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
-index 4a81784..292bfea 100644
---- a/src/sage/rings/real_arb.pyx
-+++ b/src/sage/rings/real_arb.pyx
-@@ -3506,7 +3506,7 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1/2).erf()
-+            sage: RBF(1/2).erf() # abs tol 1e-16
-             [0.520499877813047 +/- 6.10e-16]
-         """
-         cdef RealBall res = self._new()
-@@ -3556,12 +3556,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Si()
-+            sage: RBF(1).Si() # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]
- 
-         TESTS::
- 
--            sage: RBF(Si(1))
-+            sage: RBF(Si(1)) # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]
-         """
-         cdef RealBall res = self._new()
-@@ -3578,12 +3578,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Ci()  # abs tol 1e-16
-+            sage: RBF(1).Ci()  # abs tol 1e-15
-             [0.337403922900968 +/- 3.25e-16]
- 
-         TESTS::
- 
--            sage: RBF(Ci(1))  # abs tol 1e-16
-+            sage: RBF(Ci(1))  # abs tol 1e-15
-             [0.337403922900968 +/- 3.25e-16]
-         """
-         cdef RealBall res = self._new()
--- 
-cgit v1.0-1-gd88e
-
-
-From 53532ddd4e2dc92469c1590ebf0c40f8f69bf579 Mon Sep 17 00:00:00 2001
-From: Antonio Rojas <arojas@archlinux.org>
-Date: Sun, 16 Jan 2022 14:16:53 +0100
-Subject: Decrease abs tol
-
----
- src/sage/rings/real_arb.pyx | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
-index 292bfea..eb30f7f 100644
---- a/src/sage/rings/real_arb.pyx
-+++ b/src/sage/rings/real_arb.pyx
-@@ -3578,12 +3578,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Ci()  # abs tol 1e-15
-+            sage: RBF(1).Ci()  # abs tol 5e-16
-             [0.337403922900968 +/- 3.25e-16]
- 
-         TESTS::
- 
--            sage: RBF(Ci(1))  # abs tol 1e-15
-+            sage: RBF(Ci(1))  # abs tol 5e-16
-             [0.337403922900968 +/- 3.25e-16]
-         """
-         cdef RealBall res = self._new()
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch b/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
deleted file mode 100644
index d4e8f8be60e3..000000000000
--- a/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From 33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c Mon Sep 17 00:00:00 2001
-From: Michael Orlitzky <michael@orlitzky.com>
-Date: Mon, 24 Jan 2022 09:03:29 -0500
-Subject: Trac #33226: update doctests for giac-1.7.0.45.
-
-We have two failing doctests with giac-1.7.0.45: one is a trivial
-tolerance issue, but the other is a symbolic integration result for
-which giac is no longer willing to return a symbolic answer. We add
-"abs tol" to the numeric test, and drop the symbolic one entirely.
----
- src/sage/functions/min_max.py | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/src/sage/functions/min_max.py b/src/sage/functions/min_max.py
-index fc18373..9b7d6d9 100644
---- a/src/sage/functions/min_max.py
-+++ b/src/sage/functions/min_max.py
-@@ -228,15 +228,15 @@ class MaxSymbolic(MinMax_base):
-             ...
-             TypeError: cannot evaluate symbolic expression numerically
- 
--        ::
-+        We can usually integrate these expressions, but can't
-+        guarantee a symbolic answer in closed form::
- 
-             sage: f = max_symbolic(sin(x), cos(x))
-             sage: r = integral(f, x, 0, 1)
-             ...
--            sage: r
--            sqrt(2) - cos(1)
--            sage: r.n()
-+            sage: r.n()  # abs tol 1e-8
-             0.873911256504955
-+
-         """
-         return max_symbolic(args)
- 
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch b/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
deleted file mode 100644
index 19b69700a4f6..000000000000
--- a/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-commit 9c8235e44ffb509efa8a3ca6cdb55154e2b5066d
-Author: Antonio Rojas <arojas@archlinux.org>
-Date:   Sun Feb 13 19:53:14 2022 +0100
-
-    Fix deprecation warning with scipy 1.8
-
-diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-index e9b60dae5ec..7932167b41d 100644
---- a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-@@ -356,7 +356,7 @@ Sage example in ./linsolve.tex, line 2230::
- 
- Sage example in ./linsolve.tex, line 2609::
- 
--  sage: from scipy.sparse.linalg.dsolve import *
-+  sage: from scipy.sparse.linalg import factorized
-   sage: from scipy.sparse import lil_matrix
-   sage: from numpy import array
-   sage: n = 200
diff --git a/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch b/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
new file mode 100644
index 000000000000..e052e306e7a1
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
@@ -0,0 +1,53 @@
+From 6330cee1a69229b2f5d8ac4a09a73d8152f5e14d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Mon, 28 Feb 2022 23:15:16 -0300
+Subject: trac 33360: avoid factoring in is_prime()
+
+In the added TEST, the ideal norm is product of two primes but factoring
+this product takes about half an hour, so factoring the ideal is slow.
+
+To fix the issue, we only factor the ideal if the norm is a prime power.
+---
+ src/sage/rings/number_field/number_field_ideal.py | 22 ++++++++++++++++++++++
+ 1 file changed, 22 insertions(+)
+
+diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
+index f785f22..10d1f88 100644
+--- a/src/sage/rings/number_field/number_field_ideal.py
++++ b/src/sage/rings/number_field/number_field_ideal.py
+@@ -995,10 +995,32 @@ class NumberFieldIdeal(Ideal_generic):
+             False
+             sage: K.ideal(17).is_prime()  # ramified
+             False
++
++        TESTS::
++
++        Check that we do not factor the norm of the ideal, this used
++        to take half an hour, see :trac:`33360`
++
++           sage: K.<a,b,c> = NumberField([x^2-2,x^2-3,x^2-5])
++           sage: t = (((-2611940*c + 1925290/7653)*b - 1537130/7653*c
++           ....:       + 10130950)*a + (1343014/7653*c - 8349770)*b
++           ....:       + 6477058*c - 2801449990/4002519)
++           sage: t.is_prime()
++           False
++
+         """
+         try:
+             return self._pari_prime is not None
+         except AttributeError:
++            K = self.number_field().pari_nf()
++            I = self.pari_hnf()
++            # This would be better, but it is broken in pari 2.13.3.
++            #   self._pari_prime = K.idealismaximal(I) or None
++            # Instead we factor I, but only if the norm is a prime power
++            n = K.idealnorm(I)
++            if n.denominator() > 1 or not n.isprimepower():
++                self._pari_prime = None
++                return False
+             F = self.factor()  # factorization with caching
+             if len(F) != 1 or F[0][1] != 1:
+                 self._pari_prime = None
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
deleted file mode 100644
index 9ba7ca5a6b7d..000000000000
--- a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
+++ /dev/null
@@ -1,99 +0,0 @@
-From 609dd9deaeaa6380ab2f0d50276d911233c00a04 Mon Sep 17 00:00:00 2001
-From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
-Date: Fri, 4 Mar 2022 16:07:09 -0800
-Subject: sage.manifolds: Update doctests for SymPy 1.10
-
----
- src/sage/manifolds/continuous_map.py              | 3 +--
- src/sage/manifolds/differentiable/diff_form.py    | 4 ++--
- src/sage/manifolds/differentiable/tensorfield.py  | 8 ++++----
- src/sage/manifolds/vector_bundle_fiber_element.py | 2 +-
- 4 files changed, 8 insertions(+), 9 deletions(-)
-
-diff --git a/src/sage/manifolds/continuous_map.py b/src/sage/manifolds/continuous_map.py
-index a6356e7..f6f9b6d 100644
---- a/src/sage/manifolds/continuous_map.py
-+++ b/src/sage/manifolds/continuous_map.py
-@@ -1357,8 +1357,7 @@ class ContinuousMap(Morphism):
-             sage: Phi.coord_functions(c_uv, c_xyz)
-             Coordinate functions (u*v, u/v, u + v) on the Chart (M, (u, v))
-             sage: Phi.coord_functions(c_UV, c_xyz)
--            Coordinate functions (-U**2/4 + V**2/4, -(U + V)/(U - V), V)
--             on the Chart (M, (U, V))
-+            Coordinate functions (-U**2/4 + V**2/4, (-U - V)/(U - V), V) on the Chart (M, (U, V))
-             sage: Phi.coord_functions(c_UV, c_XYZ)
-             Coordinate functions ((-U**3 + U**2*V + U*V**2 + 2*U*V + 6*U - V**3
-              - 2*V**2 + 6*V)/(2*(U - V)), (U**3/4 - U**2*V/4 - U*V**2/4 + U*V
-diff --git a/src/sage/manifolds/differentiable/diff_form.py b/src/sage/manifolds/differentiable/diff_form.py
-index 70dd8fb..0aa3469 100644
---- a/src/sage/manifolds/differentiable/diff_form.py
-+++ b/src/sage/manifolds/differentiable/diff_form.py
-@@ -266,7 +266,7 @@ class DiffForm(TensorField):
- 
-         sage: s = a.wedge(b)
-         sage: s.display(eU)
--        a∧b = -x*(2*x*y + 1) dx∧dy
-+        a∧b = x*(-2*x*y - 1) dx∧dy
-         sage: s.display(eV)
-         a∧b = (u**3/8 + u**2*v/8 - u*v**2/8 + u/4 - v**3/8 + v/4) du∧dv
- 
-@@ -275,7 +275,7 @@ class DiffForm(TensorField):
-         sage: f = M.scalar_field({c_xy: (x+y)^2, c_uv: u^2}, name='f')
-         sage: s = f*a
-         sage: s.display(eU)
--        f*a = -y*(x**2 + 2*x*y + y**2) dx + x*(x**2 + 2*x*y + y**2) dy
-+        f*a = y*(-x**2 - 2*x*y - y**2) dx + x*(x**2 + 2*x*y + y**2) dy
-         sage: s.display(eV)
-         f*a = u**2*v/2 du - u**3/2 dv
- 
-diff --git a/src/sage/manifolds/differentiable/tensorfield.py b/src/sage/manifolds/differentiable/tensorfield.py
-index 2775be9..6bc5c50 100644
---- a/src/sage/manifolds/differentiable/tensorfield.py
-+++ b/src/sage/manifolds/differentiable/tensorfield.py
-@@ -334,7 +334,7 @@ class TensorField(ModuleElementWithMutability):
-         sage: f.display()  # long time
-         t(a,b): S^2 → ℝ
-         on U: (x, y) ↦ -2*x*y - 3*x - y**2
--        on V: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+        on V: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
- 
-     The vectors can be defined only on subsets of `S^2`, the domain of the
-     result is then the common subset::
-@@ -343,12 +343,12 @@ class TensorField(ModuleElementWithMutability):
-         sage: s.display()  # long time
-         t(a,b): U → ℝ
-            (x, y) ↦ -2*x*y - 3*x - y**2
--        on W: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+        on W: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
-         sage: s = t(a.restrict(U), b.restrict(W))  # long time
-         sage: s.display()  # long time
-         t(a,b): W → ℝ
-            (x, y) ↦ -2*x*y - 3*x - y**2
--           (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+           (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
- 
-     The tensor itself can be defined only on some open subset of `S^2`,
-     yielding a result whose domain is this subset::
-@@ -356,7 +356,7 @@ class TensorField(ModuleElementWithMutability):
-         sage: s = t.restrict(V)(a,b)  # long time
-         sage: s.display()  # long time
-         t(a,b): V → ℝ
--           (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+           (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
-         on W: (x, y) ↦ -2*x*y - 3*x - y**2
- 
-     Tests regarding the multiplication by a scalar field::
-diff --git a/src/sage/manifolds/vector_bundle_fiber_element.py b/src/sage/manifolds/vector_bundle_fiber_element.py
-index 29ee81d..048275a 100644
---- a/src/sage/manifolds/vector_bundle_fiber_element.py
-+++ b/src/sage/manifolds/vector_bundle_fiber_element.py
-@@ -110,4 +110,4 @@ class VectorBundleFiberElement(FiniteRankFreeModuleElement):
-             desc += str(self._name) + " "
-         desc += "in the fiber of {} at {}".format(self._vbundle._name,
-                                                   self._point)
--        return desc
-\ No newline at end of file
-+        return desc
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
deleted file mode 100644
index f5ac180baa90..000000000000
--- a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From c49eff347454ac7f07e5918470b20e97b8f2357e Mon Sep 17 00:00:00 2001
-From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
-Date: Fri, 4 Mar 2022 15:14:43 -0800
-Subject: src/sage/calculus/calculus.py: Update laplace doctest for sympy 1.10
-
----
- src/sage/calculus/calculus.py | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/src/sage/calculus/calculus.py b/src/sage/calculus/calculus.py
-index 9c2f226..b335093 100644
---- a/src/sage/calculus/calculus.py
-+++ b/src/sage/calculus/calculus.py
-@@ -1639,9 +1639,9 @@ def laplace(ex, t, s, algorithm='maxima'):
-         sage: laplace(dirac_delta(t), t, s)
-         1
-         sage: F, a, cond = laplace(dirac_delta(t), t, s, algorithm='sympy')
--        sage: a, cond
--        (-oo, True)
--        sage: F       # random - sympy <1.9 includes undefined heaviside(0) in answer
-+        sage: a, cond  # random - sympy <1.10 gives (-oo, True)
-+        (0, True)
-+        sage: F        # random - sympy <1.9 includes undefined heaviside(0) in answer
-         1
-         sage: laplace(dirac_delta(t), t, s, algorithm='giac')
-         1
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch b/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
deleted file mode 100644
index 8e7bb64f5b01..000000000000
--- a/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From a04a0a0b14f67f4804e7113c3db41bbcf8a58296 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
-Date: Mon, 28 Mar 2022 20:39:59 -0300
-Subject: Trac #33585: fix doctest when dochtml is missing...
-
-...but sphinx is available in PYTHONPATH.
----
- src/sage/misc/sagedoc.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/sage/misc/sagedoc.py b/src/sage/misc/sagedoc.py
-index 4b3853f..08c4225 100644
---- a/src/sage/misc/sagedoc.py
-+++ b/src/sage/misc/sagedoc.py
-@@ -1401,7 +1401,7 @@ class _sage_doc:
-             "...**File:**...**Type:**...**Definition:** identity_matrix..."
-             sage: identity_matrix.__doc__ in browse_sage_doc(identity_matrix, 'rst')
-             True
--            sage: browse_sage_doc(identity_matrix, 'html', False)             # optional - sphinx
-+            sage: browse_sage_doc(identity_matrix, 'html', False)             # optional - sphinx sagemath_doc_html
-             '...div...File:...Type:...Definition:...identity_matrix...'
- 
-         In the 'text' version, double colons have been replaced with
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch b/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
new file mode 100644
index 000000000000..977a42400e59
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
@@ -0,0 +1,42 @@
+commit 5db5d4e56243c609f44afc1f21c112b026f9e1fe
+Author: Oscar Benjamin <oscar.j.benjamin@gmail.com>
+Date:   Mon Jul 11 21:24:01 2022 +0100
+
+    Update doctests for SymPy 1.11
+    
+    Doctests related to SymPy's rsolve function are updated in:
+    
+    src/sage/calculus/test_sympy.py
+    src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+    
+    The form of the output from SymPy has changed since
+    
+    https://github.com/sympy/sympy/pull/23567
+
+diff --git a/src/sage/calculus/test_sympy.py b/src/sage/calculus/test_sympy.py
+index 7cf7f3f6bfd..927e6ee4fb6 100644
+--- a/src/sage/calculus/test_sympy.py
++++ b/src/sage/calculus/test_sympy.py
+@@ -193,7 +193,7 @@ This was fixed in Sympy, see :trac:`14437`::
+     sage: u = Function('u')
+     sage: n = Symbol('n', integer=True)
+     sage: f = u(n+2) - u(n+1) + u(n)/4
+-    sage: 2**n * rsolve(f,u(n))
+-    C1*n + C0
++    sage: expand(2**n * rsolve(f,u(n)))
++    2*C1*n + C0
+ 
+ """
+diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+index 1062f4f7e8c..f53f813d793 100644
+--- a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
++++ b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+@@ -382,7 +382,7 @@ Sage example in ./recequadiff.tex, line 1798::
+   sage: from sympy import rsolve_hyper
+   sage: from sympy.abc import n
+   sage: rsolve_hyper([-2,1],2**(n+2),n)
+-  2**n*C0 + 2**(n + 2)*(C0 + n/2)
++  2**n*C0 + 2**(n + 1)*n
+ 
+ """
+ 
diff --git a/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch b/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch
new file mode 100644
index 000000000000..b544a3eef7dd
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch
@@ -0,0 +1,526 @@
+From aeff992d53a65a705dca5cd5216bcb97c218dce7 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:14:03 +0200
+Subject: Adapt to API changes in OpenOutputStream and CloseOutput
+
+---
+ src/sage/libs/gap/element.pyx      | 5 +++--
+ src/sage/libs/gap/gap_includes.pxd | 6 ++++--
+ 2 files changed, 7 insertions(+), 4 deletions(-)
+
+diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
+index be43c4c..e268116 100644
+--- a/src/sage/libs/gap/element.pyx
++++ b/src/sage/libs/gap/element.pyx
+@@ -130,6 +130,7 @@ cdef char *capture_stdout(Obj func, Obj obj):
+     """
+     cdef Obj s, stream, output_text_string
+     cdef UInt res
++    cdef TypOutputFile output
+     # The only way to get a string representation of an object that is truly
+     # consistent with how it would be represented at the GAP REPL is to call
+     # ViewObj on it.  Unfortunately, ViewObj *prints* to the output stream,
+@@ -145,12 +146,12 @@ cdef char *capture_stdout(Obj func, Obj obj):
+         output_text_string = GAP_ValueGlobalVariable("OutputTextString")
+         stream = CALL_2ARGS(output_text_string, s, GAP_True)
+ 
+-        if not OpenOutputStream(stream):
++        if not OpenOutputStream(&output, stream):
+             raise GAPError("failed to open output capture stream for "
+                            "representing GAP object")
+ 
+         CALL_1ARGS(func, obj)
+-        CloseOutput()
++        CloseOutput(&output)
+         return CSTR_STRING(s)
+     finally:
+         GAP_Leave()
+diff --git a/src/sage/libs/gap/gap_includes.pxd b/src/sage/libs/gap/gap_includes.pxd
+index 5a9ab48..34035fe 100644
+--- a/src/sage/libs/gap/gap_includes.pxd
++++ b/src/sage/libs/gap/gap_includes.pxd
+@@ -76,8 +76,10 @@ cdef extern from "gap/intobj.h" nogil:
+ 
+ 
+ cdef extern from "gap/io.h" nogil:
+-    UInt OpenOutputStream(Obj stream)
+-    UInt CloseOutput()
++    ctypedef struct TypOutputFile:
++        pass
++    UInt OpenOutputStream(TypOutputFile* output, Obj stream)
++    UInt CloseOutput(TypOutputFile* output)
+ 
+ 
+ cdef extern from "gap/libgap-api.h" nogil:
+-- 
+cgit v1.0-1-gd88e
+
+
+From c3367b4290981e5e93b7a30c48b02f1ae3770dc8 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:14:53 +0200
+Subject: Disable colored prompt as it breaks the pexpect interface
+
+---
+ src/sage/interfaces/gap.py | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/src/sage/interfaces/gap.py b/src/sage/interfaces/gap.py
+index c34fe53..569caa2 100644
+--- a/src/sage/interfaces/gap.py
++++ b/src/sage/interfaces/gap.py
+@@ -1512,6 +1512,8 @@ def gap_reset_workspace(max_workspace_size=None, verbose=False):
+     """
+     # Create new workspace with filename WORKSPACE
+     g = Gap(use_workspace_cache=False, max_workspace_size=None)
++    g.eval('ColorPrompt(false)')
++    g.eval('SetUserPreference("UseColorPrompt", false)')
+     g.eval('SetUserPreference("HistoryMaxLines", 30)')
+     from sage.tests.gap_packages import all_installed_packages
+     for pkg in all_installed_packages(gap=g):
+-- 
+cgit v1.0-1-gd88e
+
+
+From 3b63e998e4d6118fc86b13b940c8f3d3b8307a50 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:16:03 +0200
+Subject: Port NaturalHomomorphism uses
+
+---
+ src/sage/groups/abelian_gps/abelian_group_gap.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/sage/groups/abelian_gps/abelian_group_gap.py b/src/sage/groups/abelian_gps/abelian_group_gap.py
+index a4b0471..86090b4 100644
+--- a/src/sage/groups/abelian_gps/abelian_group_gap.py
++++ b/src/sage/groups/abelian_gps/abelian_group_gap.py
+@@ -338,7 +338,7 @@ class AbelianGroup_gap(UniqueRepresentation, GroupMixinLibGAP, ParentLibGAP, Abe
+         if isinstance(x, AbelianGroupElement_gap):
+             try:
+                 if x in self._cover:
+-                    x = self.gap().NaturalHomomorphism().Image(x.gap())
++                    x = self._cover.gap().NaturalHomomorphismByNormalSubgroup(self._relations).Image(x.gap())
+                 else:
+                     x = x.gap()
+             except AttributeError:
+@@ -1043,7 +1043,7 @@ class AbelianGroupQuotient_gap(AbelianGroup_gap):
+             From: Abelian group with gap, generator orders (4,)
+             To:   Quotient abelian group with generator orders (2,)
+         """
+-        phi = self.gap().NaturalHomomorphism()
++        phi = self._cover.gap().NaturalHomomorphismByNormalSubgroup(self._relations)
+         Hom = self._cover.Hom(self)
+         return Hom(phi)
+ 
+-- 
+cgit v1.0-1-gd88e
+
+
+From bc40764be044653e06f2da3497e1e05da08251f7 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:17:36 +0200
+Subject: Fix tests with GAP 4.12
+
+---
+ src/doc/en/thematic_tutorials/lie/weyl_groups.rst  | 12 ++++++------
+ src/sage/coding/codecan/autgroup_can_label.pyx     |  2 +-
+ src/sage/coding/linear_code.py                     | 22 +++++++++++-----------
+ .../root_system/hecke_algebra_representation.py    |  2 +-
+ src/sage/combinat/symmetric_group_algebra.py       |  2 +-
+ src/sage/groups/finitely_presented.py              |  6 +++---
+ src/sage/groups/fqf_orthogonal.py                  |  2 +-
+ src/sage/groups/libgap_wrapper.pyx                 |  6 +++---
+ .../perm_gps/partn_ref2/refinement_generic.pyx     |  2 +-
+ src/sage/groups/perm_gps/permgroup.py              |  8 ++++----
+ src/sage/libs/gap/libgap.pyx                       |  2 +-
+ src/sage/libs/gap/util.pyx                         |  8 +-------
+ src/sage/tests/gap_packages.py                     |  2 +-
+ 13 files changed, 35 insertions(+), 41 deletions(-)
+
+diff --git a/src/doc/en/thematic_tutorials/lie/weyl_groups.rst b/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
+index c917338..182e74a 100644
+--- a/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
++++ b/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
+@@ -139,12 +139,12 @@ string, which you can print::
+     X.1      1  1  1  1  1  1  1  1  1  1  1  1  1
+     X.2      1 -1  1  1 -1  1  1 -1 -1 -1  1  1  1
+     X.3      2  .  2 -1  .  2  2  .  .  . -1  2  2
+-    X.4      3 -1 -1  .  1 -1  3 -1  1 -1  . -1  3
+-    X.5      3 -1 -1  .  1  3 -1 -1 -1  1  . -1  3
+-    X.6      3  1 -1  . -1 -1  3  1 -1  1  . -1  3
+-    X.7      3  1 -1  . -1  3 -1  1  1 -1  . -1  3
+-    X.8      3 -1  3  . -1 -1 -1 -1  1  1  . -1  3
+-    X.9      3  1  3  .  1 -1 -1  1 -1 -1  . -1  3
++    X.4      3 -1 -1  .  1  3 -1 -1 -1  1  . -1  3
++    X.5      3  1 -1  . -1  3 -1  1  1 -1  . -1  3
++    X.6      3 -1  3  . -1 -1 -1 -1  1  1  . -1  3
++    X.7      3 -1 -1  .  1 -1  3 -1  1 -1  . -1  3
++    X.8      3  1  3  .  1 -1 -1  1 -1 -1  . -1  3
++    X.9      3  1 -1  . -1 -1  3  1 -1  1  . -1  3
+     X.10     4 -2  . -1  .  .  .  2  .  .  1  . -4
+     X.11     4  2  . -1  .  .  . -2  .  .  1  . -4
+     X.12     6  . -2  .  . -2 -2  .  .  .  .  2  6
+diff --git a/src/sage/coding/codecan/autgroup_can_label.pyx b/src/sage/coding/codecan/autgroup_can_label.pyx
+index de5db98..c83b926 100644
+--- a/src/sage/coding/codecan/autgroup_can_label.pyx
++++ b/src/sage/coding/codecan/autgroup_can_label.pyx
+@@ -76,7 +76,7 @@ columns do share the same coloring::
+     ((1,),
+      (2,),
+      (3, 5, 4),
+-     (6, 19, 16, 9, 21, 10, 8, 15, 14, 11, 20, 13, 12, 7, 17, 18))
++     (6, 19, 16, 21, 9, 10, 15, 8, 20, 11, 14, 13, 7, 12, 18, 17))
+ 
+ We can also restrict the group action to linear isometries::
+ 
+diff --git a/src/sage/coding/linear_code.py b/src/sage/coding/linear_code.py
+index e8e32f8..9d45160 100644
+--- a/src/sage/coding/linear_code.py
++++ b/src/sage/coding/linear_code.py
+@@ -466,27 +466,27 @@ class AbstractLinearCode(AbstractLinearCodeNoMetric):
+             0
+             sage: C = codes.HammingCode(GF(4, 'z'), 3)
+             sage: C.automorphism_group_gens()
+-            ([((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
++            ([((1, 1, 1, z, z + 1, 1, 1, 1, 1, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z); (1,13,14,20)(2,21,8,18,7,16,19,15)(3,10,5,12,17,9,6,4), Ring endomorphism of Finite Field in z of size 2^2
++                Defn: z |--> z + 1),
++              ((z, 1, z, z, z, z + 1, z, z, z, z, z, z, z + 1, z, z, z, z, z + 1, z, z, z); (1,11,5,12,3,19)(2,8)(6,18,13)(7,17,15)(9,10,14,16,20,21), 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 + 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
++            ([((z, 1, z + 1, z + 1, 1, z + 1, z, 1, z + 1, z + 1, 1, z, 1, z + 1, z, 1, z, 1, z + 1, 1, 1); (1,12,11,10,6,8,9,20,13,21,5,14,3,16,17,19,7,4,2,15,18), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+-              ((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
++              ((z + 1, z + 1, z + 1, z, 1, 1, z, z, 1, z + 1, z, 1, 1, z, 1, z + 1, z, z + 1, z + 1, 1, z); (1,3,18,2,17,6,19)(4,15,13,20,7,14,16)(5,11,8,21,12,9,10), 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)],
+              181440)
+             sage: C.automorphism_group_gens(equivalence="permutational")
+-            ([((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,19)(3,17)(4,21)(5,20)(7,14)(9,12)(10,16)(11,15), Ring endomorphism of Finite Field in z of size 2^2
++            ([((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,11)(3,10)(4,9)(5,7)(12,21)(14,20)(15,19)(16,17), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+-              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,11)(3,10)(4,9)(5,7)(12,21)(14,20)(15,19)(16,17), Ring endomorphism of Finite Field in z of size 2^2
++              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (2,18)(3,19)(4,10)(5,16)(8,13)(9,14)(11,21)(15,20), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+-              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,17)(2,8)(3,14)(4,10)(7,12)(9,19)(13,18)(15,20), Ring endomorphism of Finite Field in z of size 2^2
++              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,19)(3,17)(4,21)(5,20)(7,14)(9,12)(10,16)(11,15), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+               ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (2,13)(3,14)(4,20)(5,11)(8,18)(9,19)(10,15)(16,21), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z)],
+@@ -692,10 +692,10 @@ class AbstractLinearCode(AbstractLinearCodeNoMetric):
+             sage: C_iso == aut_group_can_label.get_canonical_form()
+             True
+             sage: aut_group_can_label.get_autom_gens()
+-            [((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
++            [((1, 1, 1, z, z + 1, 1, 1, 1, 1, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z); (1,13,14,20)(2,21,8,18,7,16,19,15)(3,10,5,12,17,9,6,4), Ring endomorphism of Finite Field in z of size 2^2
++               Defn: z |--> z + 1),
++             ((z, 1, z, z, z, z + 1, z, z, z, z, z, z, z + 1, z, z, z, z, z + 1, z, z, z); (1,11,5,12,3,19)(2,8)(6,18,13)(7,17,15)(9,10,14,16,20,21), 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/root_system/hecke_algebra_representation.py b/src/sage/combinat/root_system/hecke_algebra_representation.py
+index bde2823..bffcc85 100644
+--- a/src/sage/combinat/root_system/hecke_algebra_representation.py
++++ b/src/sage/combinat/root_system/hecke_algebra_representation.py
+@@ -355,7 +355,7 @@ class HeckeAlgebraRepresentation(WithEqualityById, SageObject):
+             sage: q1, q2 = K.gens()
+             sage: KW = W.algebra(K)
+             sage: x = KW.an_element(); x
+-            123 + 3*32 + 2*3 + e
++            123 + 3*2312 + 2*31 + e
+ 
+             sage: T = KW.demazure_lusztig_operators(q1,q2)
+             sage: T12 = T.Tw( (1,2) )
+diff --git a/src/sage/combinat/symmetric_group_algebra.py b/src/sage/combinat/symmetric_group_algebra.py
+index c3d6755..da953d2 100644
+--- a/src/sage/combinat/symmetric_group_algebra.py
++++ b/src/sage/combinat/symmetric_group_algebra.py
+@@ -101,7 +101,7 @@ def SymmetricGroupAlgebra(R, W, category=None):
+         sage: SGA.group()
+         Weyl Group of type ['A', 3] (as a matrix group acting on the ambient space)
+         sage: SGA.an_element()
+-        s1*s2*s3 + 3*s3*s2 + 2*s3 + 1
++        s1*s2*s3 + 3*s2*s3*s1*s2 + 2*s3*s1 + 1
+ 
+     The preferred way to construct the symmetric group algebra is to
+     go through the usual ``algebra`` method::
+diff --git a/src/sage/groups/finitely_presented.py b/src/sage/groups/finitely_presented.py
+index 2a61bbf..d26891a 100644
+--- a/src/sage/groups/finitely_presented.py
++++ b/src/sage/groups/finitely_presented.py
+@@ -596,9 +596,9 @@ class RewritingSystem():
+             sage: k = G.rewriting_system()
+             sage: k.gap()
+             Knuth Bendix Rewriting System for Monoid( [ a, A, b, B ] ) with rules
+-            [ [ a^2, <identity ...> ], [ a*A, <identity ...> ],
+-              [ A*a, <identity ...> ], [ b^2, <identity ...> ],
+-              [ b*B, <identity ...> ], [ B*b, <identity ...> ] ]
++            [ [ a*A, <identity ...> ], [ A*a, <identity ...> ],
++              [ b*B, <identity ...> ], [ B*b, <identity ...> ],
++              [ a^2, <identity ...> ], [ b^2, <identity ...> ] ]
+         """
+         return self._gap
+ 
+diff --git a/src/sage/groups/fqf_orthogonal.py b/src/sage/groups/fqf_orthogonal.py
+index 75de408..dd7d84d 100644
+--- a/src/sage/groups/fqf_orthogonal.py
++++ b/src/sage/groups/fqf_orthogonal.py
+@@ -143,7 +143,7 @@ class FqfOrthogonalGroup(AbelianGroupAutomorphismGroup_subgroup):
+         [2/3   0   0]
+         [  0 2/3   0]
+         [  0   0 4/3]
+-        generated by 2 elements
++        generated by 3 elements
+         sage: q = matrix.diagonal(QQ, [3/2, 1/4, 1/4])
+         sage: T = TorsionQuadraticForm(q)
+         sage: T.orthogonal_group().order()
+diff --git a/src/sage/groups/libgap_wrapper.pyx b/src/sage/groups/libgap_wrapper.pyx
+index a76afc2..9340c0d 100644
+--- a/src/sage/groups/libgap_wrapper.pyx
++++ b/src/sage/groups/libgap_wrapper.pyx
+@@ -25,7 +25,7 @@ Note how we call the constructor of both superclasses to initialize
+ its output via LibGAP::
+ 
+     sage: FooGroup()
+-    <pc group of size 3 with 1 generators>
++    <pc group of size 3 with 1 generator>
+     sage: type(FooGroup().gap())
+     <class 'sage.libs.gap.element.GapElement'>
+ 
+@@ -106,7 +106,7 @@ class ParentLibGAP(SageObject):
+         ....:         ParentLibGAP.__init__(self, lg)
+         ....:         Group.__init__(self)
+         sage: FooGroup()
+-        <pc group of size 3 with 1 generators>
++        <pc group of size 3 with 1 generator>
+     """
+ 
+     def __init__(self, libgap_parent, ambient=None):
+@@ -461,7 +461,7 @@ cdef class ElementLibGAP(MultiplicativeGroupElement):
+         ....:         ParentLibGAP.__init__(self, lg)
+         ....:         Group.__init__(self)
+         sage: FooGroup()
+-        <pc group of size 3 with 1 generators>
++        <pc group of size 3 with 1 generator>
+         sage: FooGroup().gens()
+         (f1,)
+     """
+diff --git a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
+index 2fcb036..ca73c6b 100644
+--- a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
++++ b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
+@@ -427,7 +427,7 @@ cdef class LabelledBranching:
+             sage: from sage.groups.perm_gps.partn_ref2.refinement_generic import LabelledBranching
+             sage: L = LabelledBranching(3)
+             sage: L.small_generating_set()
+-            []
++            [()]
+             sage: L.add_gen(libgap.eval('(1,2,3)'))
+             sage: L.small_generating_set()
+             [(1,2,3)]
+diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
+index 4908934..34ba0cc 100644
+--- a/src/sage/groups/perm_gps/permgroup.py
++++ b/src/sage/groups/perm_gps/permgroup.py
+@@ -913,7 +913,7 @@ class PermutationGroup_generic(FiniteGroup):
+            sage: f = PG._coerce_map_from_(MG)
+            sage: mg = MG.an_element()
+            sage: p = f(mg); p
+-           (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)
++           (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(p._gap_()) == p
+            True
+ 
+@@ -959,12 +959,12 @@ class PermutationGroup_generic(FiniteGroup):
+             sage: P = G.as_permutation_group(algorithm='smaller', seed=5)
+             sage: P1 = G.as_permutation_group()
+             sage: P == P1
+-            False
++            True
+             sage: g1, g2, g3 = G.gens()
+             sage: P(g1*g2)
+-            (1,3,7,12)(2,4,8,10)(5,11)(6,9)
++            (1,4,13,11)(2,5,14,18)(3,15,8,16)(6,7)(9,20,19,12)(10,17)
+             sage: P1(g1*g2)
+-            (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)
++            (1,4,13,11)(2,5,14,18)(3,15,8,16)(6,7)(9,20,19,12)(10,17)
+ 
+         Another check for :trac:`5583`::
+ 
+diff --git a/src/sage/libs/gap/libgap.pyx b/src/sage/libs/gap/libgap.pyx
+index b1a64e5..6a36613 100644
+--- a/src/sage/libs/gap/libgap.pyx
++++ b/src/sage/libs/gap/libgap.pyx
+@@ -695,7 +695,7 @@ class Gap(Parent):
+             sage: libgap.List
+             <Gap function "List">
+             sage: libgap.GlobalRandomSource
+-            <RandomSource in IsGlobalRandomSource>
++            <RandomSource in IsGAPRandomSource>
+         """
+         if name in dir(self.__class__):
+             return getattr(self.__class__, name)
+diff --git a/src/sage/libs/gap/util.pyx b/src/sage/libs/gap/util.pyx
+index 344ab88..6350987 100644
+--- a/src/sage/libs/gap/util.pyx
++++ b/src/sage/libs/gap/util.pyx
+@@ -362,15 +362,9 @@ cdef Obj gap_eval(str gap_string) except? NULL:
+         GAPError: Error, Variable: 'Complex' must have a value
+         Syntax error: ; expected in stream:1
+         Complex Field with 53 bits of precision;;
+-         ^^^^^^^^^^^^
++                ^^^^^
+         Error, Variable: 'with' must have a value
+-        Syntax error: ; expected in stream:1
+-        Complex Field with 53 bits of precision;;
+-         ^^^^^^^^^^^^^^^^^^^^
+         Error, Variable: 'bits' must have a value
+-        Syntax error: ; expected in stream:1
+-        Complex Field with 53 bits of precision;;
+-         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+         Error, Variable: 'precision' must have a value
+ 
+     Test that on a subsequent attempt we get the same message (no garbage was
+diff --git a/src/sage/tests/gap_packages.py b/src/sage/tests/gap_packages.py
+index 2e4518c..c302b16 100644
+--- a/src/sage/tests/gap_packages.py
++++ b/src/sage/tests/gap_packages.py
+@@ -103,7 +103,7 @@ def all_installed_packages(ignore_dot_gap=False, gap=None):
+ 
+         sage: from sage.tests.gap_packages import all_installed_packages
+         sage: all_installed_packages()
+-        (...'GAPDoc'...)
++        (...'gapdoc'...)
+         sage: all_installed_packages(ignore_dot_gap=True) == all_installed_packages(gap=gap, ignore_dot_gap=True)
+         True
+     """
+-- 
+cgit v1.0-1-gd88e
+
+
+From cbc902a79ff9ec01d4d4eb9a767a1c661fb5dda7 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Fri, 30 Sep 2022 19:17:42 +0200
+Subject: Adapt test to new is_transitive and is_primitive behavior
+
+---
+ src/sage/groups/perm_gps/permgroup.py | 22 ++++++++++++++++------
+ 1 file changed, 16 insertions(+), 6 deletions(-)
+
+diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
+index 34ba0cc..5832b98 100644
+--- a/src/sage/groups/perm_gps/permgroup.py
++++ b/src/sage/groups/perm_gps/permgroup.py
+@@ -4359,17 +4359,23 @@ class PermutationGroup_generic(FiniteGroup):
+ 
+         ::
+ 
+-            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)]]) #S_5 on [1..5]
+-            sage: G.is_transitive([1,4,5])
++            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)],[(6,7)]])
++            sage: G.is_transitive([1,2,3,4,5])
+             True
+-            sage: G.is_transitive([2..6])
++            sage: G.is_transitive([1..7])
+             False
+             sage: G.is_transitive(G.non_fixed_points())
+-            True
++            False
+             sage: H = PermutationGroup([[(1,2,3)],[(4,5,6)]])
+             sage: H.is_transitive(H.non_fixed_points())
+             False
+ 
++        If `G` does not act on the domain, it always returns ``False``::
++
++            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)]]) #S_5 on [1..5]
++            sage: G.is_transitive([1,4,5])
++            False
++
+         Note that this differs from the definition in GAP, where
+         ``IsTransitive`` returns whether the group is transitive on the
+         set of points moved by the group.
+@@ -4425,12 +4431,16 @@ class PermutationGroup_generic(FiniteGroup):
+             sage: G = PermutationGroup([[(1,2,3,4)],[(2,4)]])
+             sage: G.is_primitive([1..4])
+             False
+-            sage: G.is_primitive([1,2,3])
+-            True
+             sage: G = PermutationGroup([[(3,4,5,6)],[(3,4)]]) #S_4 on [3..6]
+             sage: G.is_primitive(G.non_fixed_points())
+             True
+ 
++        If `G` does not act on the domain, it always returns ``False``::
++
++            sage: G = PermutationGroup([[(1,2,3,4)],[(2,4)]])
++            sage: G.is_primitive([1,2,3])
++            False
++
+         """
+         #If the domain is not a subset of self.domain(), then the
+         #action isn't primitive.
+-- 
+cgit v1.0-1-gd88e
+
+
+From 80dd6b338236f170efca1fc3545df18ce8d8795c Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Fri, 30 Sep 2022 19:18:06 +0200
+Subject: Mark test as random. With gap 4.12 on x86_64 it is no longer 2
+
+---
+ src/sage/groups/perm_gps/permgroup.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
+index 5832b98..c1230a3 100644
+--- a/src/sage/groups/perm_gps/permgroup.py
++++ b/src/sage/groups/perm_gps/permgroup.py
+@@ -1287,7 +1287,7 @@ class PermutationGroup_generic(FiniteGroup):
+             sage: G.gens_small() # random
+             [('b','c'), ('a','c','b')] ## (on 64-bit Linux)
+             [('a','b'), ('a','c','b')] ## (on Solaris)
+-            sage: len(G.gens_small()) == 2
++            sage: len(G.gens_small()) == 2 # random
+             True
+         """
+         gens = self._libgap_().SmallGeneratingSet()
+-- 
+cgit v1.0-1-gd88e
+
+
+From a6c293d67cfcdf8fba7bc6aa7899e2086d42cc7e Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Fri, 30 Sep 2022 19:18:30 +0200
+Subject: Remove test that is now redundant, all seeds give the same answer
+
+---
+ src/sage/groups/matrix_gps/finitely_generated.py | 3 ---
+ 1 file changed, 3 deletions(-)
+
+diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
+index a6d3dc0..63956ad 100644
+--- a/src/sage/groups/matrix_gps/finitely_generated.py
++++ b/src/sage/groups/matrix_gps/finitely_generated.py
+@@ -563,9 +563,6 @@ class FinitelyGeneratedMatrixGroup_gap(MatrixGroup_gap):
+             21499084800
+             sage: P = G.as_permutation_group()
+             sage: Psmaller = G.as_permutation_group(algorithm="smaller", seed=6)
+-            sage: P == Psmaller  # see the note below
+-            True
+-            sage: Psmaller = G.as_permutation_group(algorithm="smaller")
+             sage: P == Psmaller
+             False
+             sage: P.cardinality()
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch b/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
new file mode 100644
index 000000000000..8fedcb78cf71
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
@@ -0,0 +1,19 @@
+commit 04971318f032caf8dc1c0de9489346d894409091
+Author: John H. Palmieri <jhpalmieri64@gmail.com>
+Date:   Wed Aug 31 14:22:26 2022 -0700
+
+    trac 34465: fix invalid escape sequence in functions/special.py
+
+diff --git a/src/sage/functions/special.py b/src/sage/functions/special.py
+index 02596e49620..901f02f9bee 100644
+--- a/src/sage/functions/special.py
++++ b/src/sage/functions/special.py
+@@ -849,7 +849,7 @@ class EllipticF(BuiltinFunction):
+     - :wikipedia:`Elliptic_integral#Incomplete_elliptic_integral_of_the_first_kind`
+     """
+     def __init__(self):
+-        """
++        r"""
+         EXAMPLES::
+ 
+             sage: loads(dumps(elliptic_f))
diff --git a/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch b/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch
deleted file mode 100644
index f3eb0aad2cca..000000000000
--- a/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch
+++ /dev/null
@@ -1,14 +0,0 @@
- - this is not a proper fix... should fix sage_getfile() instead
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -187,7 +187,8 @@ def loadable_module_extension():
-         True
-     """
-     # Return the full platform-specific extension module suffix
--    return import_machinery.EXTENSION_SUFFIXES[0]
-+    # PATCHED for void linux, we use the shortest extension (.so)
-+    return import_machinery.EXTENSION_SUFFIXES[-1]
- 
- 
- def isclassinstance(obj):
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 0d793262d572..8df50e4e13b6 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,7 +1,7 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=9.5
-revision=2
+version=9.7
+revision=1
 wrksrc=sage-$version
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
@@ -33,12 +33,9 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="http://sagemath.org/"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=8d70a3b26080802c5b2e33dda4c23795d494d8216a0c2ecfcd608ebab0e64ff6
+checksum=9f26f14aa322e3cf38a71835b12ac34b23026b467f74d54b064c5d025e76fbfd
 
 post_patch() {
-	# these are unused and nothing else uses ratpoints
-	rm sage/libs/ratpoints.{pyx,pxd}
-
 	# git tree needs bootstrapping
 	pushd $wrksrc/build/pkgs/sagelib
 	PATH=../../bin:$PATH BOOTSTRAP_QUIET=no ./bootstrap
@@ -65,6 +62,7 @@ do_configure() {
 
 pre_build() {
 	export PYTHONPATH=../sage-setup
+	export PYTHONDONTWRITEBYTECODE=yes
 	export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
 }
 
@@ -77,6 +75,7 @@ post_build() {
 
 pre_install() {
 	export PYTHONPATH=../sage-setup
+	export PYTHONDONTWRITEBYTECODE=yes
 	export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
 }
 
@@ -104,6 +103,7 @@ post_install() {
 do_check() {
 	_scripts=$(cd build/scripts* && pwd)
 	export PYTHONPATH=$(cd build/lib* && pwd)
+	export PYTHONDONTWRITEBYTECODE=yes
 
 	# get out of $build_wrksrc, otherwise python picks the wrong sage module
 	cd $(mktemp -dp build)

From b0447887163d06525a52e7a889f83d5c1cfc3f01 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Thu, 13 Oct 2022 00:08:32 -0300
Subject: [PATCH 13/13] giac: temporary ci-skip

---
 srcpkgs/giac/template | 1 +
 1 file changed, 1 insertion(+)

diff --git a/srcpkgs/giac/template b/srcpkgs/giac/template
index 31045e9128ee..a0c2f1799710 100644
--- a/srcpkgs/giac/template
+++ b/srcpkgs/giac/template
@@ -15,6 +15,7 @@ homepage="https://www-fourier.ujf-grenoble.fr/~parisse/giac.html"
 changelog="https://www-fourier.ujf-grenoble.fr/~parisse/install_en#new"
 distfiles="https://www-fourier.ujf-grenoble.fr/~parisse/debian/dists/stable/main/source/giac_${version%.*}-${version##*.}.tar.gz"
 checksum=120cd16f2e033817302d2a03a22bd413dc1d85df8b225ba4f76b93a7805b07fe
+make_check=ci-skip # temporary, there's one test failure (TODO: FIX)
 
 # need more than 4*65536 stack, see try_parse() in gen.cc line 11812
 LDFLAGS="-Wl,-z,stack-size=2097152"

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PR PATCH] [Updated] DRAFT: sagemath update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (14 preceding siblings ...)
  2022-10-14 20:11 ` tornaria
@ 2022-10-16  1:52 ` tornaria
  2022-10-17  4:51 ` tornaria
                   ` (16 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: tornaria @ 2022-10-16  1:52 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1883 bytes --]

There is an updated pull request by tornaria against master on the void-packages repository

https://github.com/tornaria/void-packages sagemath-update
https://github.com/void-linux/void-packages/pull/39876

DRAFT: sagemath update to 9.7
This includes #39838, #39840, #39846, #39872, #39866, also update eclib-20220621.

For now I'm reverting python3-matplotlib to 3.5.3_1 since 3.6.0_1 gives a lot of problems (#39857 adds python3-contourpy which will solve some, but I think there are more issues).

I want to make sure everything works ok and the full testsuite passes as is. Then I'll just move matplotlib back to 3.6.0_1 and try to see if it's feasible to fix or workaround the issues (sagemath-the-distro is still on matplotlib 3.5.2 and I didn't find anything about the update to 3.6.0)

<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: currently running the testsuite in --long after the update of singular.

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/39876.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-sagemath-update-39876.patch --]
[-- Type: text/x-diff, Size: 223673 bytes --]

From 7207409500d5603f92f9022c1f32be5a52e810ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 19:14:02 -0300
Subject: [PATCH 01/12] flintlib: update to 2.9.0.

---
 common/shlibs             | 2 +-
 srcpkgs/flintlib/template | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 02780902e137..1e76b257070b 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4015,7 +4015,7 @@ libgtkdatabox.so.1 gtkdatabox3-1.0.0_1
 libxcvt.so.0 libxcvt-0.1.1_1
 libgf2x.so.3 gf2x-1.3.0_1
 libntl.so.44 ntl-11.5.1_1
-libflint.so.16 flintlib-2.8.0_1
+libflint.so.17 flintlib-2.9.0_1
 libarb.so.2 arb-2.20.0_1
 libec.so.8 eclib-20210625_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index 968dbcb525c2..27f202b4434c 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,6 +1,6 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.8.5
+version=2.9.0
 revision=1
 wrksrc="flint-${version}"
 build_style=configure
@@ -14,11 +14,10 @@ license="LGPL-2.1-or-later"
 homepage="https://flintlib.org"
 changelog="https://raw.githubusercontent.com/wbhart/flint2/trunk/NEWS"
 distfiles="https://flintlib.org/flint-${version}.tar.gz"
-checksum=5911fedff911100f15781f35e3a4fa934fe60e4aea02a8c10cc8918101c1eed8
+checksum=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
-build_options_default=""
 
 if [ -z "$CROSS_BUILD" ]; then
 	build_options_default+=" ntl"

From 4b5011279fa5b2e510573a162b66e42224334fe0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 19:16:18 -0300
Subject: [PATCH 02/12] arb: update to 2.23.0.

---
 srcpkgs/arb/template | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
index 52f11ef83c90..84a62c7ffdba 100644
--- a/srcpkgs/arb/template
+++ b/srcpkgs/arb/template
@@ -1,6 +1,6 @@
 # Template file for 'arb'
 pkgname=arb
-version=2.22.1
+version=2.23.0
 revision=1
 build_style=configure
 configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
@@ -11,9 +11,7 @@ license="LGPL-2.1-or-later"
 homepage="https://arblib.org"
 changelog="https://raw.githubusercontent.com/fredrik-johansson/arb/master/doc/source/history.rst"
 distfiles="https://github.com/fredrik-johansson/arb/archive/${version}.tar.gz"
-checksum=1ef85518eee04885e8a90196498bc75e4e2410621d4184f2bc01d46b7080a243
-
-CFLAGS="-D_GNU_SOURCE" # needed for cpu_set_t
+checksum=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
 
 arb-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"

From 4f9dfb93c17f0332486ed6b552c29b5b37798736 Mon Sep 17 00:00:00 2001
From: dkwo <nicolopiazzalunga@gmail.com>
Date: Mon, 10 Oct 2022 10:14:06 -0400
Subject: [PATCH 03/12] singular: update to 4.3.1p2 (fix gcc 12 build)

---
 common/shlibs             | 10 +++++-----
 srcpkgs/singular/template | 26 ++++++++++++++------------
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 1e76b257070b..054b8e86dee0 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4057,11 +4057,11 @@ libumfpack.so.5 SuiteSparse-5.10.1_1
 libecl.so.21.2 ecl-21.2.1_1
 libecm.so.1 ecm-7.0.4_3
 libcliquer.so.1 cliquer-1.22_1
-libSingular-4.3.0.so singular-4.3.0_1
-libfactory-4.3.0.so singular-4.3.0_1
-libpolys-4.3.0.so singular-4.3.0_1
-libomalloc-0.9.6.so singular-4.3.0_1
-libsingular_resources-4.3.0.so singular-4.3.0_1
+libSingular-4.3.1.so singular-4.3.1p2_1
+libfactory-4.3.1.so singular-4.3.1p2_1
+libpolys-4.3.1.so singular-4.3.1p2_1
+libomalloc-0.9.6.so singular-4.3.1p2_1
+libsingular_resources-4.3.1.so singular-4.3.1p2_1
 libbrial.so.3 brial-1.2.10_1
 libbrial_groebner.so.3 brial-1.2.10_1
 libm4ri-0.0.20200125.so m4ri-20200125_1
diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index f23659ef5d83..a30beef915d2 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,25 +1,27 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.0
+version=4.3.1p2
 revision=1
+_majver=${version%p*}
+wrksrc=singular-${_majver}
 build_style=gnu-configure
 configure_args="--with-readline=ncurses
-	--enable-gfanlib
-	--enable-Singular
-	--enable-factory
-	--disable-doc
-	--disable-polymake
-	--without-python
-	--with-libparse
-	ac_cv_lib_cddgmp_dd_free_global_constants=yes"
+ --enable-gfanlib
+ --enable-Singular
+ --enable-factory
+ --disable-doc
+ --disable-polymake
+ --without-python
+ --with-libparse
+ ac_cv_lib_cddgmp_dd_free_global_constants=yes"
 hostmakedepends="perl tar doxygen"
 makedepends="flintlib-devel cddlib-devel readline-devel graphviz"
 short_desc="Computer algebra system for polynomial computations"
-maintainer="dkwo <nicolopiazzalunga@gmail.com>"
+maintainer="dkwo <npiazza@disroot.org>"
 license="GPL-2.0-or-later"
 homepage="https://www.singular.uni-kl.de"
-distfiles="https://www.singular.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${version//./-}/singular-${version}.tar.gz"
-checksum=74f38288203720e3f280256f2f8deb94030dd032b4237d844652aff0faab36e7
+distfiles="https://www.singular.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${_majver//./-}/singular-${version}.tar.gz"
+checksum=95814bba0f0bd0290cd9799ec1d2ecc6f4c8a4e6429d9a02eb7f9c4e5649682a
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From 49dbdce8741b991fa9a17e9c31ee4a702eaa7221 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 19:59:20 -0300
Subject: [PATCH 04/12] pari: update to 2.15.0.

---
 common/shlibs                      |  3 +-
 srcpkgs/pari/patches/float32.patch | 48 ++++++++++++++++++++++++++++++
 srcpkgs/pari/template              | 12 ++++++--
 3 files changed, 58 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/pari/patches/float32.patch

diff --git a/common/shlibs b/common/shlibs
index 054b8e86dee0..2900edc46908 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4006,8 +4006,7 @@ libsimavrparts.so.1 simavr-1.6_2
 libsword-1.8.1.so libsword-1.8.1_6
 libgivaro.so.9 givaro-4.1.1_1
 liblinbox.so.0 linbox-1.6.3_1
-libpari-gmp.so.7 pari-2.13.0_1
-libpari-gmp-tls.so.7 pari-2.13.2_1
+libpari-gmp-tls.so.8 pari-2.15.0_1
 libtree-sitter.so.0 tree-sitter-0.19.0_1
 libplanarity.so.0 planarity-3.0.1.1_1
 libgap.so.0 gap-4.11.1_1
diff --git a/srcpkgs/pari/patches/float32.patch b/srcpkgs/pari/patches/float32.patch
new file mode 100644
index 000000000000..311dd6bf5a07
--- /dev/null
+++ b/srcpkgs/pari/patches/float32.patch
@@ -0,0 +1,48 @@
+Author: Gonzalo Tornaría <tornaria@cmat.edu.uy>
+Date:   Fri Oct 14 17:00:46 2022 -0300
+
+    Revert "x86 (32bit): force -mpc64 on compilers that supports it."
+    
+    This reverts commit ca61b6391cf95ac8af15669236e2ec5839d2ad91.
+
+
+This causes problems with floating point precision on i686:
+```
+$ cat exp40.c
+#include <math.h>
+#include <stdio.h>
+int main() {
+	volatile int a=40; /* do not optimize away the call to exp(a) */
+	printf("%f\n", exp(a));
+}
+$ cc -Wall exp40.c -lm && ./a.out
+235385266837020000.000000
+$ cc -Wall exp40.c -lm -mpc64 && ./a.out
+235385266837020448.000000
+```
+
+Note that when pari is built using -mpc64, just *linking* with -lpari
+causes the problem!!!
+```
+$ cc -Wall exp40.c -lm -lpari && ./a.out
+235385266837020448.000000
+```
+
+diff --git a/config/get_cc b/config/get_cc
+index 3cfaa88bb7..2d61d3871f 100644
+--- a/config/get_cc
++++ b/config/get_cc
+@@ -110,13 +110,6 @@ if test -n "$__gnuc__"; then
+   # Specific optimisations for some architectures
+   case "$arch" in
+     sparcv8*) cflags=-mv8;;
+-    i?86)
+-      cmd="$CC $CFLAGS $extraflag -mpc64 -fno-strict-aliasing -o $exe gnu.c"
+-      . log_cmd
+-      if test -s $exe; then
+-        cflags="-mpc64"
+-      fi
+-      . cleanup_exe;;
+   esac
+   # problems on some architectures
+   case "$osname" in
diff --git a/srcpkgs/pari/template b/srcpkgs/pari/template
index 8bac1e0343f8..811826a1ee14 100644
--- a/srcpkgs/pari/template
+++ b/srcpkgs/pari/template
@@ -1,6 +1,6 @@
 # Template file for 'pari'
 pkgname=pari
-version=2.13.4
+version=2.15.0
 revision=1
 build_style=configure
 build_helper=qemu
@@ -11,14 +11,15 @@ make_check_target=statest-all
 make_install_target="install install-lib-sta install-lib-dyn"
 hostmakedepends="perl texlive"
 makedepends="gmp-devel readline-devel $(vopt_if x11 libX11-devel)"
-checkdepends="pari-elldata-small pari-galdata pari-galpol-small pari-seadata-small"
+checkdepends="pari-elldata-small pari-galdata pari-galpol-small
+ pari-seadata-small pari-nflistdata"
 short_desc="Fast computations library in number theory"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="https://pari.math.u-bordeaux.fr"
 changelog="https://pari.math.u-bordeaux.fr/cgi-bin/gitweb.cgi?p=pari.git;a=blob_plain;f=CHANGES;hb=refs/heads/pari-${version%.*}"
 distfiles="https://pari.math.u-bordeaux.fr/pub/pari/unix/${pkgname}-${version}.tar.gz"
-checksum=bcde9eceae1592814381c1697cdb7063567b6504201b1be47bb58920f3bce185
+checksum=e474851e0d16d4e4f9a0d9612c746a2ae7c9a1ec185d04c440b1c74a85755685
 
 build_options="x11 pthreads"
 build_options_default="x11 pthreads"
@@ -27,6 +28,11 @@ desc_option_pthreads="Enable support for pthreads"
 # reduce speed losses due to pthreads
 CFLAGS="-flto -fno-semantic-interposition"
 
+case $XBPS_TARGET_MACHINE in
+	# avoid numerical noise caused by extended-precision of registers
+	i686*) CFLAGS+=" -ffloat-store" ;;
+esac
+
 post_patch() {
 	# sse2 is not available on all i686
 	# and it's available on all x86_64

From 719b656e3c72e07385e73e071f498addeac43566 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 20:33:23 -0300
Subject: [PATCH 05/12] gp2c: update to 0.0.13.

---
 srcpkgs/gp2c/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gp2c/template b/srcpkgs/gp2c/template
index f82cf95c2d90..9cf0f6fdce6e 100644
--- a/srcpkgs/gp2c/template
+++ b/srcpkgs/gp2c/template
@@ -1,6 +1,6 @@
 # Template file for 'gp2c'
 pkgname=gp2c
-version=0.0.12pl1
+version=0.0.13
 revision=1
 build_style=gnu-configure
 hostmakedepends="perl"
@@ -12,4 +12,4 @@ license="GPL-2.0-or-later"
 homepage="http://pari.math.u-bordeaux.fr/"
 changelog="http://pari.math.u-bordeaux.fr/cgi-bin/gitweb.cgi?p=gp2c.git;a=blob_plain;f=ChangeLog;hb=HEAD"
 distfiles="${homepage}pub/pari/GP2C/${pkgname}-${version}.tar.gz"
-checksum=79a8c46f7ad3331e4d8ae6af6b496c4742fd73a73b996b3ca7ead61452ca6e8d
+checksum=261374eca73ebd76c112a9593dca28b64812aa762561fda5a4b2c2cd79a69d36

From 64f0fa5154c726c4079298facea7a8ef5335d40a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Fri, 23 Sep 2022 16:42:40 -0300
Subject: [PATCH 06/12] eclib: update to 20221012.

---
 common/shlibs          | 2 +-
 srcpkgs/eclib/template | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 2900edc46908..2f9f022b57e7 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4016,7 +4016,7 @@ libgf2x.so.3 gf2x-1.3.0_1
 libntl.so.44 ntl-11.5.1_1
 libflint.so.17 flintlib-2.9.0_1
 libarb.so.2 arb-2.20.0_1
-libec.so.8 eclib-20210625_1
+libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
 liblrcalc.so.2 lrcalc-2.1_1
diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 694a39ed4068..31a3a01921fa 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
-version=20210625
-revision=2
+version=20221012
+revision=1
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 hostmakedepends="automake autoconf-archive libtool"
@@ -11,7 +11,7 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="https://github.com/JohnCremona/eclib"
 distfiles="https://github.com/JohnCremona/eclib/archive/refs/tags/${version}.tar.gz"
-checksum=00333fd36afd237c9e6e410c7ab98536ddcd7fdc430e6837fe293247b835c572
+checksum=bd6f0191876c1426ca57db851ce06ef79ea1755f01e81dd747358d1b76b5e932
 
 pre_configure() {
 	autoreconf -fi

From 912bd59019c198e45229efde19a89bd5308eaf9e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:20 -0300
Subject: [PATCH 07/12] giac: update to 1.9.0.21.

---
 .../giac/patches/giac-pari-2.15-test.patch    | 10 ++++++++++
 srcpkgs/giac/patches/giac-pari-2.15.patch     | 20 +++++++++++++++++++
 srcpkgs/giac/template                         |  4 ++--
 3 files changed, 32 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/giac/patches/giac-pari-2.15-test.patch
 create mode 100644 srcpkgs/giac/patches/giac-pari-2.15.patch

diff --git a/srcpkgs/giac/patches/giac-pari-2.15-test.patch b/srcpkgs/giac/patches/giac-pari-2.15-test.patch
new file mode 100644
index 000000000000..1f1929571a46
--- /dev/null
+++ b/srcpkgs/giac/patches/giac-pari-2.15-test.patch
@@ -0,0 +1,10 @@
+Fix a failing test due to thread stack overflow
+
+--- a/check/chk_fhan4	2018-03-13 15:27:11.000000000 -0300
++++ b/check/chk_fhan4	2022-10-14 18:51:12.604731890 -0300
+@@ -1,4 +1,5 @@
+ #! /bin/sh
+ unset LANG
++export PARI_SIZE=2048000
+ ../src/icas TP04-sol.cas > TP04.tst
+ diff TP04.tst TP04-sol.cas.out1
diff --git a/srcpkgs/giac/patches/giac-pari-2.15.patch b/srcpkgs/giac/patches/giac-pari-2.15.patch
new file mode 100644
index 000000000000..be409be38f53
--- /dev/null
+++ b/srcpkgs/giac/patches/giac-pari-2.15.patch
@@ -0,0 +1,20 @@
+ANYARG patch
+
+diff --git a/src/pari.cc b/src/pari.cc
+index 76ce8e1..50d08ab 100644
+--- a/src/pari.cc
++++ b/src/pari.cc
+@@ -40,6 +40,13 @@ using namespace std;
+ 
+ #ifdef HAVE_LIBPARI
+ 
++// Anyarg disappeared from PARI 2.15.0
++#ifdef __cplusplus
++#  define ANYARG ...
++#else
++#  define ANYARG
++#endif
++
+ #ifdef HAVE_PTHREAD_H
+ #include <pthread.h>
+ #endif
diff --git a/srcpkgs/giac/template b/srcpkgs/giac/template
index e892c8bf7506..31045e9128ee 100644
--- a/srcpkgs/giac/template
+++ b/srcpkgs/giac/template
@@ -1,6 +1,6 @@
 # Template file for 'giac'
 pkgname=giac
-version=1.9.0.7
+version=1.9.0.21
 revision=1
 wrksrc="giac-${version%.*}"
 build_style=gnu-configure
@@ -14,7 +14,7 @@ license="GPL-3.0-or-later"
 homepage="https://www-fourier.ujf-grenoble.fr/~parisse/giac.html"
 changelog="https://www-fourier.ujf-grenoble.fr/~parisse/install_en#new"
 distfiles="https://www-fourier.ujf-grenoble.fr/~parisse/debian/dists/stable/main/source/giac_${version%.*}-${version##*.}.tar.gz"
-checksum=72016988b7180e9b630ecabecc60969213e7b61418c2598c91acbaec139fd740
+checksum=120cd16f2e033817302d2a03a22bd413dc1d85df8b225ba4f76b93a7805b07fe
 
 # need more than 4*65536 stack, see try_parse() in gen.cc line 11812
 LDFLAGS="-Wl,-z,stack-size=2097152"

From ed7862591d1ff3a617b58ecbe2efdbb5343d508b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 12 Oct 2022 23:59:37 -0300
Subject: [PATCH 08/12] gap: update to 4.12.0.

---
 common/shlibs                          |  2 +-
 srcpkgs/gap/patches/c57a07a3.patch     | 23 +++++++++++++++++++++++
 srcpkgs/gap/patches/dce6fa96.patch     | 24 ++++++++++++++++++++++++
 srcpkgs/gap/patches/fix-atlasrep.patch | 11 +++++++++++
 srcpkgs/gap/template                   | 12 +++++-------
 5 files changed, 64 insertions(+), 8 deletions(-)
 create mode 100644 srcpkgs/gap/patches/c57a07a3.patch
 create mode 100644 srcpkgs/gap/patches/dce6fa96.patch
 create mode 100644 srcpkgs/gap/patches/fix-atlasrep.patch

diff --git a/common/shlibs b/common/shlibs
index 2f9f022b57e7..9630b60d4889 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4009,7 +4009,7 @@ liblinbox.so.0 linbox-1.6.3_1
 libpari-gmp-tls.so.8 pari-2.15.0_1
 libtree-sitter.so.0 tree-sitter-0.19.0_1
 libplanarity.so.0 planarity-3.0.1.1_1
-libgap.so.0 gap-4.11.1_1
+libgap.so.8 gap-4.12.0_1
 libgtkdatabox.so.1 gtkdatabox3-1.0.0_1
 libxcvt.so.0 libxcvt-0.1.1_1
 libgf2x.so.3 gf2x-1.3.0_1
diff --git a/srcpkgs/gap/patches/c57a07a3.patch b/srcpkgs/gap/patches/c57a07a3.patch
new file mode 100644
index 000000000000..27fd657666a6
--- /dev/null
+++ b/srcpkgs/gap/patches/c57a07a3.patch
@@ -0,0 +1,23 @@
+From c57a07a341e7bb713e74d60c259777b1a8645451 Mon Sep 17 00:00:00 2001
+From: Max Horn <max@quendi.de>
+Date: Fri, 7 Oct 2022 01:31:45 +0200
+Subject: [PATCH] Don't attempt to install the 'dev' manual...
+
+... as it is not contained in release tarballs!
+---
+ Makefile.rules | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile.rules b/Makefile.rules
+index d9dc2899df..de1dbc4823 100644
+--- a/Makefile.rules
++++ b/Makefile.rules
+@@ -597,7 +597,7 @@ install-doc:
+ 	# TODO: should this depend on the 'doc' target? but that target is phony
+ 	# and will re-run each time it is invoked, which is not really what we want.
+ 	$(INSTALL) -d -m 0755 $(DESTDIR)$(datarootdir)/gap/doc
+-	for book in ref tut hpc dev ; do \
++	for book in ref tut hpc ; do \
+ 		$(INSTALL) -d -m 0755 $(DESTDIR)$(datarootdir)/gap/doc/$$book ; \
+ 		for ext in css html js txt pdf six lab; do \
+ 			$(INSTALL) -m 0644  $(srcdir)/doc/$$book/*.$$ext $(DESTDIR)$(datarootdir)/gap/doc/$$book/ ; \
diff --git a/srcpkgs/gap/patches/dce6fa96.patch b/srcpkgs/gap/patches/dce6fa96.patch
new file mode 100644
index 000000000000..bc29c0eaaeb1
--- /dev/null
+++ b/srcpkgs/gap/patches/dce6fa96.patch
@@ -0,0 +1,24 @@
+From dce6fa9637a3c61c3a891cc809371eaa67a589c6 Mon Sep 17 00:00:00 2001
+From: Max Horn <max@quendi.de>
+Date: Sun, 2 Oct 2022 23:31:03 +0200
+Subject: [PATCH] kernel: if no GC is selected, default to GASMAN
+
+---
+ src/common.h | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/common.h b/src/common.h
+index e7c10b8d0b..95e6f3d609 100644
+--- a/src/common.h
++++ b/src/common.h
+@@ -35,6 +35,10 @@
+ // compiled with the wrong ABI
+ GAP_STATIC_ASSERT(sizeof(void *) == SIZEOF_VOID_P, "sizeof(void *) is wrong");
+ 
++// if no GC is selected explicitly, default to GASMAN
++#if !defined(USE_BOEHM_GC) && !defined(USE_JULIA_GC) && !defined(USE_GASMAN)
++#define USE_GASMAN 1
++#endif
+ 
+ // check for cygwin
+ #if defined(__CYGWIN__) || defined(__CYGWIN32__)
diff --git a/srcpkgs/gap/patches/fix-atlasrep.patch b/srcpkgs/gap/patches/fix-atlasrep.patch
new file mode 100644
index 000000000000..ccb9ae587d4b
--- /dev/null
+++ b/srcpkgs/gap/patches/fix-atlasrep.patch
@@ -0,0 +1,11 @@
+--- a/pkg/atlasrep/gap/access.gi.orig	2022-08-05 19:11:16.000000000 -0300
++++ b/pkg/atlasrep/gap/access.gi	2022-10-12 23:40:48.816642751 -0300
+@@ -3156,7 +3156,7 @@
+         uri:= url{ [ p .. Length( url ) ] };
+         body:= AtlasOfGroupRepresentationsTransferFile( domain, uri, fail,
+                                                         fail );
+-        if body = fail then
++        if body = false then
+           Info( InfoAtlasRep, 1,
+                 "AtlasOfGroupRepresentationsNotifyData:\n",
+                 "#I  cannot read '", url, "'" );
diff --git a/srcpkgs/gap/template b/srcpkgs/gap/template
index 7bc7d13ace20..88831e636c08 100644
--- a/srcpkgs/gap/template
+++ b/srcpkgs/gap/template
@@ -1,17 +1,17 @@
 # Template file for 'gap'
 pkgname=gap
-version=4.11.1
+version=4.12.0
 revision=1
 build_style=gnu-configure
-make_install_target="install-bin install-gaproot install-headers install-libgap"
 makedepends="gmp-devel zlib-devel readline-devel"
 checkdepends="perl"
 short_desc="Groups, Algorithms, Programming - computational discrete algebra"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="http://www.gap-system.org/"
+changelog="https://raw.githubusercontent.com/gap-system/gap/master/CHANGES.md"
 distfiles="https://github.com/gap-system/gap/releases/download/v${version}/gap-${version}.tar.gz"
-checksum=6635c5da7d82755f8339486b9cac33766f58712f297e8234fba40818902ea304
+checksum=6005d0c0316fe8803d84681f30be64eace83a9542f975f5cb3dedfadd4391849
 
 if [ "$XBPS_CHECK_PKGS" = full ]; then
 	# not sure about this -- takes about 25 minutes
@@ -21,10 +21,10 @@ fi
 _GAPROOT=/usr/share/gap/
 
 # minimal required packages
-_GAPPKGS="GAPDoc primgrp SmallGrp transgrp"
+_GAPPKGS="gapdoc primgrp smallgrp transgrp"
 
 # other expected packages
-_GAPPKGS+=" atlasrep autpgrp alnuth crisp ctbllib FactInt fga irredsol laguna
+_GAPPKGS+=" atlasrep autpgrp alnuth crisp ctbllib factint fga irredsol laguna
  polenta polycyclic resclasses sophus tomlib"
 
 post_install() {
@@ -33,8 +33,6 @@ post_install() {
 		[ -d pkg/$p ] || p="$p-*"
 		vcopy "pkg/$p" ${_GAPROOT}/pkg
 	done
-	# not handled by make install-headers
-	vcopy gen/config.h /usr/include/gap
 }
 
 gap-devel_package() {

From bc5240cb97a08c6a6f4e23a36e80c17bd8d5b58d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:19 -0300
Subject: [PATCH 09/12] lcalc: revbump for pari 2.15.0

---
 srcpkgs/lcalc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lcalc/template b/srcpkgs/lcalc/template
index 270078df9a54..3c6be5fcbc28 100644
--- a/srcpkgs/lcalc/template
+++ b/srcpkgs/lcalc/template
@@ -1,7 +1,7 @@
 # Template file for 'lcalc'
 pkgname=lcalc
 version=2.0.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--with-pari"
 hostmakedepends="automake libtool pkg-config gengetopt"

From 279b754fbd405c93c20520ffee1ce5d804bdf09c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:21 -0300
Subject: [PATCH 10/12] python3-cysignals: revbump for pari 2.15.0

---
 srcpkgs/python3-cysignals/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/python3-cysignals/template b/srcpkgs/python3-cysignals/template
index 4655eead2a9c..08d1010976ff 100644
--- a/srcpkgs/python3-cysignals/template
+++ b/srcpkgs/python3-cysignals/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-cysignals'
 pkgname=python3-cysignals
 version=1.11.2
-revision=1
+revision=2
 wrksrc="cysignals-${version}"
 build_style=python3-module
 hostmakedepends="python3-setuptools python3-Cython autoconf"

From b2d85fc27d22a326a87eeb2e6b5058db4f3c0942 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:58:16 -0300
Subject: [PATCH 11/12] python3-cypari2: revbump for pari 2.15.0

---
 srcpkgs/python3-cypari2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/python3-cypari2/template b/srcpkgs/python3-cypari2/template
index 9ded61101e8e..9db3070a087c 100644
--- a/srcpkgs/python3-cypari2/template
+++ b/srcpkgs/python3-cypari2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-cypari2'
 pkgname=python3-cypari2
 version=2.1.2
-revision=1
+revision=2
 wrksrc=cypari2-${version}
 build_style=python3-module
 hostmakedepends="python3-setuptools python3-Cython pari perl"

From fb78a5d9ddd4bef5f6af0f9253361f97dae914f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 00:49:01 -0300
Subject: [PATCH 12/12] sagemath: update to 9.7.

---
 .../patches/01-dont_link_ratpoints.patch      |   10 -
 ...2-fix_get_shared_lib_path--see_29644.patch |   13 -
 .../patches/03-doctest_have_program.patch     |   20 -
 .../patches/04-doctest_sage_getfile.patch     |   22 -
 .../patches/05-fix_sage_getfile.patch         |   16 -
 .../sagemath/patches/07-ignore_warning.patch  |   15 -
 .../08-dont_run_pytest--see_31924.patch       |   27 -
 ...y_slow_doctest-polynomial_zmod_flint.patch |   14 -
 ...ry_slow_doctest-isogeny_small_degree.patch |  106 -
 ...fix_very_slow_doctest-function_field.patch |   97 -
 srcpkgs/sagemath/patches/matplotlib-3.6.patch |   72 +
 srcpkgs/sagemath/patches/python-3.11.patch    |   45 +
 .../sagemath/patches/sagemath-pari-2.15.patch | 1750 +++++++++++++++++
 .../patches/sagemath-pari-2.15b.patch         |   29 +
 .../trac-31355-upgrade_lrcalc_to_2.1.patch    |  670 -------
 .../trac-33170-fix_doctest_ipython_8.patch    |   40 -
 .../trac-33170b-fix_doctest_ipython_8.1.patch |   13 -
 ...2ddd4e2dc92469c1590ebf0c40f8f69bf579.patch |  126 --
 ...2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch |   40 -
 .../trac-33336-fix_doctest_scipy_1.8.patch    |   19 -
 ...cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch |   53 +
 ...d9deaeaa6380ab2f0d50276d911233c00a04.patch |   99 -
 ...ff347454ac7f07e5918470b20e97b8f2357e.patch |   29 -
 ...0a0b14f67f4804e7113c3db41bbcf8a58296.patch |   26 -
 ...d4e56243c609f44afc1f21c112b026f9e1fe.patch |   42 +
 ...75f90d3bfd36758cb0e9d1ccbcd72f32d496.patch |  526 +++++
 ...1318f032caf8dc1c0de9489346d894409091.patch |   19 +
 .../zzz-loadable_module_extension.patch       |   14 -
 srcpkgs/sagemath/template                     |   12 +-
 29 files changed, 2542 insertions(+), 1422 deletions(-)
 delete mode 100644 srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
 delete mode 100644 srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
 delete mode 100644 srcpkgs/sagemath/patches/03-doctest_have_program.patch
 delete mode 100644 srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
 delete mode 100644 srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
 delete mode 100644 srcpkgs/sagemath/patches/07-ignore_warning.patch
 delete mode 100644 srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
 delete mode 100644 srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
 delete mode 100644 srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
 delete mode 100644 srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
 create mode 100644 srcpkgs/sagemath/patches/matplotlib-3.6.patch
 create mode 100644 srcpkgs/sagemath/patches/python-3.11.patch
 create mode 100644 srcpkgs/sagemath/patches/sagemath-pari-2.15.patch
 create mode 100644 srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
 delete mode 100644 srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch

diff --git a/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch b/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
deleted file mode 100644
index e5c3f5776aa2..000000000000
--- a/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
+++ /dev/null
@@ -1,10 +0,0 @@
- - do not link ratpoints where it's not used
-
---- a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
-+++ b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
-@@ -1,5 +1,3 @@
--# distutils: libraries = ratpoints
--
- r"""
- Descent on elliptic curves over `\QQ` with a 2-isogeny
- """
diff --git a/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch b/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
deleted file mode 100644
index d3672b094c1c..000000000000
--- a/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
+++ /dev/null
@@ -1,13 +0,0 @@
- - fix _get_shared_lib_path() so we don't need to configure GAP_SO
-
---- a/src/sage/env.py
-+++ b/src/sage/env.py
-@@ -293,7 +293,7 @@ def _get_shared_lib_path(*libnames: str) -> Optional[str]:
-             if sys.platform == 'darwin':
-                 ext = 'dylib'
-             else:
--                ext = 'so'
-+                ext = 'so*'
- 
-             if SAGE_LOCAL:
-                 search_directories.append(Path(SAGE_LOCAL) / 'lib')
diff --git a/srcpkgs/sagemath/patches/03-doctest_have_program.patch b/srcpkgs/sagemath/patches/03-doctest_have_program.patch
deleted file mode 100644
index 27ba3776470c..000000000000
--- a/srcpkgs/sagemath/patches/03-doctest_have_program.patch
+++ /dev/null
@@ -1,20 +0,0 @@
- - we don't know `SAGE_VENV/bin` contains `sage`, but `sys.argv[0]` should
-   be the full path to `sage-ipython` and the same directory should have `sage`
-
---- a/src/sage/misc/sage_ostools.pyx
-+++ b/src/sage/misc/sage_ostools.pyx
-@@ -32,12 +32,11 @@ def have_program(program, path=None):
-         True
-         sage: have_program('there_is_not_a_program_with_this_name')
-         False
--        sage: from sage.env import SAGE_VENV
--        sage: have_program('sage', os.path.join(SAGE_VENV, 'bin'))
-+        sage: have_program('sage', os.path.dirname(sys.argv[0]))
-         True
-         sage: have_program('sage', '/there_is_not_a_path_with_this_name')
-         False
--        sage: have_program('there_is_not_a_program_with_this_name', os.path.join(SAGE_VENV, 'bin'))
-+        sage: have_program('there_is_not_a_program_with_this_name', "/bin")
-         False
-     """
-     if path is None:
diff --git a/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch b/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
deleted file mode 100644
index 95bce107f854..000000000000
--- a/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
+++ /dev/null
@@ -1,22 +0,0 @@
- - add one doctest for coverage
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -1341,10 +1342,12 @@ def sage_getfile(obj):
-     EXAMPLES::
- 
-         sage: from sage.misc.sageinspect import sage_getfile
--        sage: sage_getfile(sage.rings.rational)[-23:]
--        'sage/rings/rational.pyx'
--        sage: sage_getfile(Sq)[-42:]
--        'sage/algebras/steenrod/steenrod_algebra.py'
-+        sage: sage_getfile(sage.rings.rational)
-+        '...sage/rings/rational.pyx'
-+        sage: sage_getfile(Sq)
-+        '...sage/algebras/steenrod/steenrod_algebra.py'
-+        sage: sage_getfile(x)
-+        '...sage/symbolic/expression.pyx'
- 
-     The following tests against some bugs fixed in :trac:`9976`::
- 
-
diff --git a/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch b/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
deleted file mode 100644
index 56c58078f319..000000000000
--- a/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
+++ /dev/null
@@ -1,16 +0,0 @@
- - fix sage_getfile() by checking all possible EXTENSION_SUFFIXES
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -1400,8 +1403,9 @@ def sage_getfile(obj):
-         sourcefile = inspect.getabsfile(obj)
-     except TypeError: # this happens for Python builtins
-         return ''
--    if sourcefile.endswith(loadable_module_extension()):
--        return sourcefile[:-len(loadable_module_extension())]+os.path.extsep+'pyx'
-+    for suffix in import_machinery.EXTENSION_SUFFIXES:
-+        if sourcefile.endswith(suffix):
-+            return sourcefile[:-len(suffix)]+os.path.extsep+'pyx'
-     return sourcefile
- 
- 
diff --git a/srcpkgs/sagemath/patches/07-ignore_warning.patch b/srcpkgs/sagemath/patches/07-ignore_warning.patch
deleted file mode 100644
index 69668678a40b..000000000000
--- a/srcpkgs/sagemath/patches/07-ignore_warning.patch
+++ /dev/null
@@ -1,15 +0,0 @@
- - this ignores a warning caused by old notebook
-
---- a/src/sage/all.py
-+++ b/src/sage/all.py
-@@ -100,6 +100,9 @@ warnings.filterwarnings('ignore', category=DeprecationWarning,
-                         message='The distutils(.sysconfig module| package) is deprecated',
-                         module='Cython|distutils|numpy|sage.env|sage.features')
- 
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"invalid escape sequence '\\s'")
-+
- ################ end setup warnings ###############################
- 
- 
-
diff --git a/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch b/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
deleted file mode 100644
index 06bd2ccae6fb..000000000000
--- a/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
+++ /dev/null
@@ -1,27 +0,0 @@
- - using pytest is broken, see #31924
-
---- a/src/bin/sage-runtests
-+++ b/src/bin/sage-runtests
-@@ -154,21 +154,4 @@ if __name__ == "__main__":
-     DC = DocTestController(args, args.filenames)
-     err = DC.run()
- 
--    try:
--        exit_code_pytest = 0
--        import pytest
--        pytest_options = ["--import-mode", "importlib"]
--        if args.verbose:
--            pytest_options.append("-v")
--        exit_code_pytest = pytest.main(pytest_options + args.filenames)
--        if exit_code_pytest == 5:
--            # Exit code 5 means there were no test files, pass in this case
--            exit_code_pytest = 0
--
--    except ModuleNotFoundError:
--        print("Pytest is not installed, skip checking tests that rely on it.")
--
--    if err == 0:
--        sys.exit(exit_code_pytest)
--    else:
--        sys.exit(err)
-+    sys.exit(err)
diff --git a/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch b/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
deleted file mode 100644
index bae8387cf94a..000000000000
--- a/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
-+++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
-@@ -237,8 +237,9 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
- 
-             sage: a = ZZ['x'](range(100000))
-             sage: R = Integers(3)['x']
--            sage: R(a)  # long time (7s on sage.math, 2013)
--            2*x^99998 + ... + x
-+            sage: p = R(a)
-+            sage: p.truncate(10)  # testing the whole poly is VERY SLOW
-+            2*x^8 + x^7 + 2*x^5 + x^4 + 2*x^2 + x
-         """
-         sig_on()
-         fmpz_poly_get_nmod_poly(&self.x, x)
diff --git a/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch b/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
deleted file mode 100644
index f3da5bbb555e..000000000000
--- a/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
+++ /dev/null
@@ -1,106 +0,0 @@
-diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-index 43727346269..9d3ccd475cd 100644
---- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-+++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-@@ -186,7 +186,7 @@ def Psi(l, use_stored=True):
-         sage: assert Psi(3, use_stored=True) == Psi(3, use_stored=False)
-         sage: assert Psi(5, use_stored=True) == Psi(5, use_stored=False)
-         sage: assert Psi(7, use_stored=True) == Psi(7, use_stored=False)
--        sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False) # not tested (very long time)
-+        sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False)  # long time (2s)
-     """
-     if l not in [2, 3, 5, 7, 13]:
-         raise ValueError("Genus zero primes are 2, 3, 5, 7 or 13.")
-@@ -1207,7 +1207,7 @@ def isogenies_13_0(E, minimal_models=True):
-         sage: K.<a> = NumberField(f)
-         sage: E = EllipticCurve(j=K(0)); E.ainvs()
-         (0, 0, 0, 0, 1)
--        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]
-+        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]  # long time (4s)
-         [(0,
-           0,
-           20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
-@@ -1325,7 +1325,7 @@ def isogenies_13_1728(E, minimal_models=True):
-         sage: f = x^12 + 1092*x^10 - 432432*x^8 + 6641024*x^6 - 282896640*x^4 - 149879808*x^2 - 349360128
-         sage: K.<a> = NumberField(f)
-         sage: E = EllipticCurve(K, [1,0])
--        sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]
-+        sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]  # long time (3s)
-         [(0,
-         0,
-         0,
-@@ -1550,8 +1550,11 @@ def Psi2(l):
-         sage: from sage.schemes.elliptic_curves.isogeny_small_degree import Psi2
-         sage: Psi2(11)
-         x^5 - 55*x^4*u + 994*x^3*u^2 - 8774*x^2*u^3 + 41453*x*u^4 - 928945/11*u^5 + 33*x^4 + 276*x^3*u - 7794*x^2*u^2 + 4452*x*u^3 + 1319331/11*u^4 + 216*x^3*v - 4536*x^2*u*v + 31752*x*u^2*v - 842616/11*u^3*v + 162*x^3 + 38718*x^2*u - 610578*x*u^2 + 33434694/11*u^3 - 4536*x^2*v + 73872*x*u*v - 2745576/11*u^2*v - 16470*x^2 + 580068*x*u - 67821354/11*u^2 - 185976*x*v + 14143896/11*u*v + 7533*x - 20437029/11*u - 12389112/11*v + 19964151/11
--        sage: Psi2(71)  # long time (1 second)
--        -2209380711722505179506258739515288584116147237393815266468076436521/71*u^210 + ... - 14790739586438315394567393301990769678157425619440464678252277649/71
-+        sage: f = Psi2(71)
-+        sage: f.coefficient([0, 210, 0])
-+        -2209380711722505179506258739515288584116147237393815266468076436521/71
-+        sage: f.coefficient([0, 0, 0])
-+        -14790739586438315394567393301990769678157425619440464678252277649/71
- 
-     TESTS::
- 
-@@ -1665,17 +1668,17 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True):
-         sage: K = QuadraticField(5,'a')
-         sage: a = K.gen()
-         sage: E = EllipticCurve_from_j(184068066743177379840*a - 411588709724712960000)
--        sage: isogenies_prime_degree_genus_plus_0(E, 47) # long time (4.3s)
-+        sage: isogenies_prime_degree_genus_plus_0(E, 47)  # long time (2s)
-         [Isogeny of degree 47 from Elliptic Curve defined by y^2 = x^3 + (454562028554080355857852049849975895490560*a-1016431595837124114668689286176511361024000)*x + (-249456798429896080881440540950393713303830363999480904280965120*a+557802358738710443451273320227578156598454035482869042774016000) over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790? to Elliptic Curve defined by y^2 = x^3 + (39533118442361013730577638493616965245992960*a-88398740199669828340617478832005245173760000)*x + (214030321479466610282320528611562368963830105830555363061803253760*a-478586348074220699687616322532666163722004497458452316582576128000) over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790?]
- 
-         sage: K = QuadraticField(-66827,'a')
-         sage: a = K.gen()
-         sage: E = EllipticCurve_from_j(-98669236224000*a + 4401720074240000)
--        sage: isogenies_prime_degree_genus_plus_0(E, 59)   # long time (25s, 2012)
-+        sage: isogenies_prime_degree_genus_plus_0(E, 59)   # long time (5s)
-         [Isogeny of degree 59 from Elliptic Curve defined by y^2 = x^3 + (2605886146782144762297974784000*a+1893681048912773634944634716160000)*x + (-116918454256410782232296183198067568744071168000*a+17012043538294664027185882358514011304812871680000) over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I to Elliptic Curve defined by y^2 = x^3 + (-19387084027159786821400775098368000*a-4882059104868154225052787156713472000)*x + (-25659862010101415428713331477227179429538847260672000*a-2596038148441293485938798119003462972840818381946880000) over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I]
- 
-         sage: E = EllipticCurve_from_j(GF(13)(5))
--        sage: isogenies_prime_degree_genus_plus_0(E, 71) # long time
-+        sage: isogenies_prime_degree_genus_plus_0(E, 71)
-         [Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13, Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13]
- 
-         sage: E = EllipticCurve(GF(13),[0,1,1,1,0])
-@@ -2117,11 +2120,11 @@ def isogenies_prime_degree_general(E, l, minimal_models=True):
-         sage: isogenies_prime_degree_general(E, 19)
-         [Isogeny of degree 19 from Elliptic Curve defined by y^2 + y = x^3 - 1862*x - 30956 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - 672182*x + 212325489 over Rational Field]
-         sage: E = EllipticCurve([0, -1, 0, -6288, 211072])
--        sage: isogenies_prime_degree_general(E, 37)  # long time (10s)
-+        sage: isogenies_prime_degree_general(E, 37)  # long time (2s)
-         [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 - x^2 - 6288*x + 211072 over Rational Field to Elliptic Curve defined by y^2 = x^3 - x^2 - 163137088*x - 801950801728 over Rational Field]
- 
-         sage: E = EllipticCurve([-3440, 77658])
--        sage: isogenies_prime_degree_general(E, 43)  # long time (16s)
-+        sage: isogenies_prime_degree_general(E, 43)  # long time (2s)
-         [Isogeny of degree 43 from Elliptic Curve defined by y^2 = x^3 - 3440*x + 77658 over Rational Field to Elliptic Curve defined by y^2 = x^3 - 6360560*x - 6174354606 over Rational Field]
- 
-     Isogenies of degree equal to the characteristic are computed (but
-@@ -2175,7 +2178,7 @@ def isogenies_prime_degree_general(E, l, minimal_models=True):
- 
-         sage: K.<i> = QuadraticField(-1)
-         sage: E = EllipticCurve(K,[0,0,0,1,0])
--        sage: [phi.codomain().ainvs() for phi in E.isogenies_prime_degree(37)] # long time
-+        sage: [phi.codomain().ainvs() for phi in E.isogenies_prime_degree(37)]  # long time (6s)
-         [(0, 0, 0, -840*i + 1081, 0), (0, 0, 0, 840*i + 1081, 0)]
-     """
-     if not l.is_prime():
-@@ -2329,14 +2332,14 @@ def isogenies_prime_degree(E, l, minimal_models=True):
-         sage: E = EllipticCurve(GF(101), [-3440, 77658])
-         sage: E.isogenies_prime_degree(71) # fast
-         []
--        sage: E.isogenies_prime_degree(73) # slower (2s)
-+        sage: E.isogenies_prime_degree(73)  # long time (2s)
-         []
- 
-     Test that :trac:`32269` is fixed::
- 
-         sage: K = QuadraticField(-11)
-         sage: E = EllipticCurve(K, [0,1,0,-117,-541])
--        sage: E.isogenies_prime_degree(37)
-+        sage: E.isogenies_prime_degree(37)  # long time (9s)
-         [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I to Elliptic Curve defined by y^2 = x^3 + x^2 + (30800*a+123963)*x + (3931312*a-21805005) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I,
-          Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I to Elliptic Curve defined by y^2 = x^3 + x^2 + (-30800*a+123963)*x + (-3931312*a-21805005) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I]
- 
diff --git a/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch b/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
deleted file mode 100644
index 3b7b1ea843df..000000000000
--- a/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
+++ /dev/null
@@ -1,97 +0,0 @@
---- a/src/sage/rings/function_field/function_field.py
-+++ b/src/sage/rings/function_field/function_field.py
-@@ -111,22 +111,21 @@ Function fields over the algebraic field are supported::
-     sage: m = L.completion(pl, prec=5)
-     sage: m(x)
-     I + s + O(s^5)
--    sage: m(y)
-+    sage: m(y)                             # long time (4s)
-     -2*s + (-4 - I)*s^2 + (-15 - 4*I)*s^3 + (-75 - 23*I)*s^4 + (-413 - 154*I)*s^5 + O(s^6)
--    sage: m(y)^2 + m(y) + m(x) + 1/m(x)
-+    sage: m(y)^2 + m(y) + m(x) + 1/m(x)    # long time (8s)
-     O(s^5)
- 
- TESTS::
- 
-     sage: TestSuite(J).run()
--    sage: TestSuite(K).run(max_runs=1024) # long time (5s)
--    sage: TestSuite(L).run(max_runs=64)   # long time (10s)
--    sage: TestSuite(M).run(max_runs=32)   # long time (30s)
--    sage: TestSuite(N).run(max_runs=64, skip = '_test_derivation')  # long time (8s)
--    sage: TestSuite(O).run(max_runs=128, skip = '_test_derivation') # long time (8s)
--
-+    sage: TestSuite(K).run(max_runs=256)   # long time (10s)
-+    sage: TestSuite(L).run(max_runs=8)     # long time (25s)
-+    sage: TestSuite(M).run(max_runs=8)     # long time (35s)
-+    sage: TestSuite(N).run(max_runs=8, skip = '_test_derivation')    # long time (15s)
-+    sage: TestSuite(O).run()
-     sage: TestSuite(R).run()
--    sage: TestSuite(S).run() # long time (3s)
-+    sage: TestSuite(S).run()               # long time (4s)
- 
- Global function fields
- ----------------------
-@@ -287,7 +286,7 @@ class FunctionField(Field):
-         TESTS::
- 
-             sage: K.<x> = FunctionField(QQ)
--            sage: TestSuite(K).run()
-+            sage: TestSuite(K).run()               # long time (3s)
-         """
-         Field.__init__(self, base_field, names=names, category=category)
- 
-@@ -729,7 +728,7 @@ class FunctionField(Field):
-         EXAMPLES::
- 
-             sage: K.<x> = FunctionField(QQ)
--            sage: TestSuite(K).run() # indirect doctest
-+            sage: TestSuite(K).run()    # indirect doctest, long time (3s)
-         """
-         tester = self._tester(**options)
-         S = tester.some_elements()
-@@ -1209,7 +1208,7 @@ class FunctionField_polymod(FunctionField):
-             sage: K.<x> = FunctionField(QQ); R.<y> = K[]
-             sage: L = K.extension(y^5 - x^3 - 3*x + x*y); L
-             Function field in y defined by y^5 + x*y - x^3 - 3*x
--            sage: TestSuite(L).run()  # long time
-+            sage: TestSuite(L).run(max_runs=512)   # long time (15s)
- 
-         We can set the variable name, which doesn't have to be y::
- 
-@@ -2888,7 +2887,8 @@ class FunctionField_simple(FunctionField_polymod):
-             sage: F.<y> = K.extension(Y^3 - x^2*(x^2 + x + 1)^2)
-             sage: O = K.maximal_order()
-             sage: pls = [O.ideal(x-QQbar(sqrt(c))).place() for c in [-2, -1, 0, 1, 2]]
--            sage: all(q.place_below() == p for p in pls for q in F.places_above(p))
-+            sage: all(q.place_below() == p         # long time (4s)
-+            ....:     for p in pls for q in F.places_above(p))
-             True
-         """
-         R = self.base_field()
-@@ -3091,7 +3091,7 @@ class FunctionField_global(FunctionField_simple):
- 
-         sage: K.<x> = FunctionField(GF(4)); _.<Y> = K[]
-         sage: L.<y> = K.extension((1 - x)*Y^7 - x^3)
--        sage: L.gaps()
-+        sage: L.gaps()                         # long time (6s)
-         [1, 2, 3]
- 
-     or may define a trivial extension::
-@@ -3111,7 +3111,7 @@ class FunctionField_global(FunctionField_simple):
- 
-             sage: K.<x> = FunctionField(GF(5)); _.<Y> = K[]
-             sage: L.<y> = K.extension(Y^3 - (x^3 - 1)/(x^3 - 2))
--            sage: TestSuite(L).run()
-+            sage: TestSuite(L).run()               # long time (7s)
-         """
-         FunctionField_polymod.__init__(self, polynomial, names)
- 
-@@ -3807,7 +3807,7 @@ class RationalFunctionField(FunctionField):
- 
-             sage: K.<t> = FunctionField(CC); K
-             Rational function field in t over Complex Field with 53 bits of precision
--            sage: TestSuite(K).run()
-+            sage: TestSuite(K).run()               # long time (5s)
- 
-             sage: FunctionField(QQ[I], 'alpha')
-             Rational function field in alpha over Number Field in I with defining polynomial x^2 + 1 with I = 1*I
diff --git a/srcpkgs/sagemath/patches/matplotlib-3.6.patch b/srcpkgs/sagemath/patches/matplotlib-3.6.patch
new file mode 100644
index 000000000000..6afaf1b7162f
--- /dev/null
+++ b/srcpkgs/sagemath/patches/matplotlib-3.6.patch
@@ -0,0 +1,72 @@
+commit 5501e0de0dca1cff0355326dd42bd8c7e5749568
+Author: Gonzalo Tornaría <tornaria@cmat.edu.uy>
+Date:   Tue Oct 11 17:25:04 2022 -0300
+
+    Support matplotlib 3.6
+
+diff --git a/src/sage/plot/arc.py b/src/sage/plot/arc.py
+index bb834763afc..f65973bcbd5 100644
+--- a/src/sage/plot/arc.py
++++ b/src/sage/plot/arc.py
+@@ -273,9 +273,9 @@ class Arc(GraphicPrimitive):
+         p = patches.Arc((self.x, self.y),
+                         2. * self.r1,
+                         2. * self.r2,
+-                        fmod(self.angle, 2 * pi) * (180. / pi),
+-                        self.s1 * (180. / pi),
+-                        self.s2 * (180. / pi))
++                        angle=fmod(self.angle, 2 * pi) * (180. / pi),
++                        theta1=self.s1 * (180. / pi),
++                        theta2=self.s2 * (180. / pi))
+         return p
+ 
+     def bezier_path(self):
+diff --git a/src/sage/plot/ellipse.py b/src/sage/plot/ellipse.py
+index a77e6fe640a..c35bed574ef 100644
+--- a/src/sage/plot/ellipse.py
++++ b/src/sage/plot/ellipse.py
+@@ -192,7 +192,8 @@ class Ellipse(GraphicPrimitive):
+         options = self.options()
+         p = patches.Ellipse(
+                 (self.x,self.y),
+-                self.r1*2.,self.r2*2.,self.angle/pi*180.)
++                self.r1*2.,self.r2*2.,
++                angle=self.angle/pi*180.)
+         p.set_linewidth(float(options['thickness']))
+         p.set_fill(options['fill'])
+         a = float(options['alpha'])
+diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
+index e779e1210e3..8d620b5c625 100644
+--- a/src/sage/plot/graphics.py
++++ b/src/sage/plot/graphics.py
+@@ -2007,7 +2007,7 @@ class Graphics(WithEqualityById, SageObject):
+         We can also do custom formatting if you need it.  See above for full
+         details::
+ 
+-            sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex")
++            sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex") # not tested (broken with matplotlib 3.6)
+             Graphics object consisting of 1 graphics primitive
+ 
+         This is particularly useful when setting custom ticks in multiples
+@@ -2341,7 +2341,7 @@ class Graphics(WithEqualityById, SageObject):
+             sage: subplot = Figure().add_subplot(111)
+             sage: p._objects[0]._render_on_subplot(subplot)
+             sage: p._matplotlib_tick_formatter(subplot, **d)
+-            (<AxesSubplot:>,
++            (<AxesSubplot:...>,
+             <matplotlib.ticker.MaxNLocator object at ...>,
+             <matplotlib.ticker.MaxNLocator object at ...>,
+             <matplotlib.ticker.ScalarFormatter object at ...>,
+diff --git a/src/sage/plot/plot.py b/src/sage/plot/plot.py
+index b36ee57227c..5301a05c3dc 100644
+--- a/src/sage/plot/plot.py
++++ b/src/sage/plot/plot.py
+@@ -1741,7 +1741,7 @@ def plot(funcs, *args, **kwds):
+ 
+     ::
+ 
+-        sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex")
++        sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex") # not tested (broken with matplotlib 3.6)
+         Graphics object consisting of 1 graphics primitive
+ 
+     .. PLOT::
diff --git a/srcpkgs/sagemath/patches/python-3.11.patch b/srcpkgs/sagemath/patches/python-3.11.patch
new file mode 100644
index 000000000000..eafe76bfb794
--- /dev/null
+++ b/srcpkgs/sagemath/patches/python-3.11.patch
@@ -0,0 +1,45 @@
+--- a/src/sage/cpython/cython_metaclass.h
++++ b/src/sage/cpython/cython_metaclass.h
+@@ -66,7 +66,7 @@
+         }
+ 
+         /* Now, set t.__class__ to metaclass */
+-        Py_TYPE(t) = metaclass;
++        Py_SET_TYPE(t, metaclass);
+         PyType_Modified(t);
+     }
+     else
+--- a/src/sage/symbolic/ginac/numeric.cpp
++++ b/src/sage/symbolic/ginac/numeric.cpp
+@@ -52,7 +52,6 @@
+ #define register
+ #define PY_SSIZE_T_CLEAN
+ #include <Python.h>
+-#include <longintrepr.h>
+ #include "flint/fmpz.h"
+ #include "flint/fmpz_factor.h"
+ 
+--- a/src/sage/libs/gmp/pylong.pyx
++++ b/src/sage/libs/gmp/pylong.pyx
+@@ -32,7 +32,7 @@
+ from .mpz cimport *
+ 
+ cdef extern from *:
+-    Py_ssize_t* Py_SIZE_PTR "&Py_SIZE"(object)
++    void Py_SET_SIZE(object, Py_ssize_t)
+     int hash_bits """
+         #ifdef _PyHASH_BITS
+         _PyHASH_BITS         /* Python 3 */
+@@ -57,10 +57,8 @@
+     mpz_export(L.ob_digit, NULL,
+             -1, sizeof(digit), 0, PyLong_nails, z)
+     if mpz_sgn(z) < 0:
+-        # Set correct size (use a pointer to hack around Cython's
+-        # non-support for lvalues).
+-        sizeptr = Py_SIZE_PTR(L)
+-        sizeptr[0] = -pylong_size
++        # Set correct size
++        Py_SET_SIZE(L, -pylong_size)
+     return L
+ 
+ 
diff --git a/srcpkgs/sagemath/patches/sagemath-pari-2.15.patch b/srcpkgs/sagemath/patches/sagemath-pari-2.15.patch
new file mode 100644
index 000000000000..ccafad5070c4
--- /dev/null
+++ b/srcpkgs/sagemath/patches/sagemath-pari-2.15.patch
@@ -0,0 +1,1750 @@
+diff --git a/build/pkgs/giac/patches/pari_2_15.patch b/build/pkgs/giac/patches/pari_2_15.patch
+new file mode 100644
+index 0000000000..d2900a5ffc
+--- /dev/null
++++ b/build/pkgs/giac/patches/pari_2_15.patch
+@@ -0,0 +1,21 @@
++ANYARG patch
++
++diff --git a/src/pari.cc b/src/pari.cc
++index 76ce8e1..50d08ab 100644
++--- a/src/pari.cc
+++++ b/src/pari.cc
++@@ -40,6 +40,13 @@ using namespace std;
++ 
++ #ifdef HAVE_LIBPARI
++ 
+++// Anyarg disappeared from PARI 2.15.0
+++#ifdef __cplusplus
+++#  define ANYARG ...
+++#else
+++#  define ANYARG
+++#endif
+++
++ #ifdef HAVE_PTHREAD_H
++ #include <pthread.h>
++ #endif
++
+diff --git a/build/pkgs/pari/checksums.ini b/build/pkgs/pari/checksums.ini
+index b736feed31..bafd0f36f4 100644
+--- a/build/pkgs/pari/checksums.ini
++++ b/build/pkgs/pari/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=pari-VERSION.tar.gz
+-sha1=e01647aab7e96a8cb4922cf26a4f224337c6647f
+-md5=922f740fcdf8630b30d63dc76b58f756
+-cksum=297133525
++sha1=cba9b279f67d5efe2fbbccf3be6e9725f816cf07
++md5=76d430f1bea1b07fa2ad9712deeaa736
++cksum=1990743897
+ upstream_url=https://pari.math.u-bordeaux.fr/pub/pari/unix/pari-VERSION.tar.gz
+diff --git a/build/pkgs/pari/package-version.txt b/build/pkgs/pari/package-version.txt
+index a1a4224dd5..68e69e405e 100644
+--- a/build/pkgs/pari/package-version.txt
++++ b/build/pkgs/pari/package-version.txt
+@@ -1 +1 @@
+-2.13.3
++2.15.0
+diff --git a/src/doc/de/tutorial/tour_numtheory.rst b/src/doc/de/tutorial/tour_numtheory.rst
+index a012234c99..e3149fe949 100644
+--- a/src/doc/de/tutorial/tour_numtheory.rst
++++ b/src/doc/de/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ implementiert.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/en/tutorial/tour_numtheory.rst b/src/doc/en/tutorial/tour_numtheory.rst
+index 3064d100e2..075e0ac0ad 100644
+--- a/src/doc/en/tutorial/tour_numtheory.rst
++++ b/src/doc/en/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ NumberField class.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/es/tutorial/tour_numtheory.rst b/src/doc/es/tutorial/tour_numtheory.rst
+index a1f7d1a87b..48e5376cfe 100644
+--- a/src/doc/es/tutorial/tour_numtheory.rst
++++ b/src/doc/es/tutorial/tour_numtheory.rst
+@@ -140,7 +140,7 @@ Varios métodos relacionados están implementados en la clase ``NumberField``::
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/fr/tutorial/tour_numtheory.rst b/src/doc/fr/tutorial/tour_numtheory.rst
+index 871092f5fa..d1b2fee883 100644
+--- a/src/doc/fr/tutorial/tour_numtheory.rst
++++ b/src/doc/fr/tutorial/tour_numtheory.rst
+@@ -159,7 +159,7 @@ dans la classe NumberField.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/ja/tutorial/tour_numtheory.rst b/src/doc/ja/tutorial/tour_numtheory.rst
+index 47af68c862..4d4ed52d50 100644
+--- a/src/doc/ja/tutorial/tour_numtheory.rst
++++ b/src/doc/ja/tutorial/tour_numtheory.rst
+@@ -161,7 +161,7 @@ Sageには :math:`p` \-進数体も組込まれている.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/pt/tutorial/tour_numtheory.rst b/src/doc/pt/tutorial/tour_numtheory.rst
+index 6371b491ea..a3dc973a93 100644
+--- a/src/doc/pt/tutorial/tour_numtheory.rst
++++ b/src/doc/pt/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ NumberField.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus 
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/ru/tutorial/tour_numtheory.rst b/src/doc/ru/tutorial/tour_numtheory.rst
+index 652abfbc99..a985d49fbd 100644
+--- a/src/doc/ru/tutorial/tour_numtheory.rst
++++ b/src/doc/ru/tutorial/tour_numtheory.rst
+@@ -150,7 +150,7 @@ Sage содержит стандартные функции теории чис
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py
+index e57076646f..fec75d07c1 100644
+--- a/src/sage/arith/misc.py
++++ b/src/sage/arith/misc.py
+@@ -1465,13 +1465,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)]
++        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::
+ 
+@@ -2569,7 +2569,7 @@ def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds):
+ 
+         sage: K.<i> = QuadraticField(-1)
+         sage: factor(122 - 454*i)
+-        (-3*i - 2) * (-i - 2)^3 * (i + 1)^3 * (i + 4)
++        (-i) * (-i - 2)^3 * (i + 1)^3 * (-2*i + 3) * (i + 4)
+ 
+     To access the data in a factorization::
+ 
+diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
+index cdfc11a9e5..b6e1280d6e 100644
+--- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
++++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
+@@ -7825,9 +7825,9 @@ class DynamicalSystem_projective_field(DynamicalSystem_projective,
+             sage: f = DynamicalSystem_projective([x^2 + QQbar(sqrt(3))*y^2, y^2, QQbar(sqrt(2))*z^2])
+             sage: f.reduce_base_field()
+             Dynamical System of Projective Space of dimension 2 over Number Field in a with
+-            defining polynomial y^4 - 4*y^2 + 1 with a = 1.931851652578137?
++            defining polynomial y^4 - 4*y^2 + 1 with a = -0.5176380902050415?
+               Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x^2 + (a^2 - 2)*y^2 : y^2 : (a^3 - 3*a)*z^2)
++                    (x^2 + (-a^2 + 2)*y^2 : y^2 : (a^3 - 3*a)*z^2)
+ 
+         ::
+ 
+diff --git a/src/sage/ext_data/pari/simon/ellQ.gp b/src/sage/ext_data/pari/simon/ellQ.gp
+index 420af8f6a2..65e8386779 100644
+--- a/src/sage/ext_data/pari/simon/ellQ.gp
++++ b/src/sage/ext_data/pari/simon/ellQ.gp
+@@ -40,7 +40,7 @@
+   gp > \r ellcommon.gp
+   gp > \r ellQ.gp
+ 
+-  The main function is ellrank(), which takes as an argument
++  The main function is ellQ_ellrank(), which takes as an argument
+   any elliptic curve in the form [a1,a2,a3,a4,a6]
+   the result is a vector [r,s,v], where
+     r is a lower bound for the rank,
+@@ -50,7 +50,7 @@
+   Example:
+ 
+   gp > ell = [1,2,3,4,5];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+   %1 = [1, 1, [[1,2]]
+   In this example, the rank is exactly 1, and [1,2] has infinite order.
+ 
+@@ -92,7 +92,7 @@
+   \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+ 
+   Explications succintes :
+-  La fonction ellrank() accepte toutes les courbes sous la forme
++  La fonction ellQ_ellrank() accepte toutes les courbes sous la forme
+   [a1,a2,a3,a4,a6]
+   Les coefficients peuvent etre entiers ou non.
+   L'algorithme utilise est celui de la 2-descente.
+@@ -100,7 +100,7 @@
+   Il suffit de taper : 
+ 
+   gp > ell = [a1,a2,a3,a4,a6];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+ 
+   Retourne un vecteur [r,s,v] ou
+     r est le rang probable (c'est toujours une minoration du rang),
+@@ -110,7 +110,7 @@
+   Exemple :
+ 
+   gp > ell = [1,2,3,4,5];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+   %1 = [1, 1, [[1,2]]
+   Ici, le rang est exactement 1, et le point [1,2] est d'ordre infini.
+ 
+@@ -1571,12 +1571,12 @@ if( DEBUGLEVEL_ell >= 4, print("    end of ell2descent_gen"));
+     print("rank(E/Q)    >= ",m1)
+   );
+ }
+-{ellrank(ell,help=[]) =
++{ellQ_ellrank(ell,help=[]) =
+ \\ Algorithm of 2-descent on the elliptic curve ell.
+ \\ help is a list of known points on ell.
+ my(urst,urst1,den,eqell,tors2,bnf,rang,time1);
+ 
+-if( DEBUGLEVEL_ell >= 3, print("   starting ellrank"));
++if( DEBUGLEVEL_ell >= 3, print("   starting ellQ_ellrank"));
+   if( #ell < 13, ell = ellinit(ell));
+ 
+ \\ kill the coefficients a1 and a3
+@@ -1630,7 +1630,7 @@ if( DEBUGLEVEL_ell >= 1, print(" Elliptic curve: Y^2 = ",eqell));
+   ));
+ 
+   rang[3] = ellchangepoint(rang[3],ellinverturst(urst));
+-if( DEBUGLEVEL_ell >= 3, print("   end of ellrank"));
++if( DEBUGLEVEL_ell >= 3, print("   end of ellQ_ellrank"));
+ 
+   return(rang);
+ }
+@@ -2106,13 +2106,13 @@ if( DEBUGLEVEL_ell >= 3, print("   end of ell2descent_viaisog"));
+ {
+ \\                  functions for elliptic curves
+   addhelp(ell2descent_complete,
+-    "ell2descent_complete(e1,e2,e3): Performs a complete 2-descent on the elliptic curve y^2 = (x-e1)*(x-e2)*(x-e3). See ?ellrank for the format of the output.");
++    "ell2descent_complete(e1,e2,e3): Performs a complete 2-descent on the elliptic curve y^2 = (x-e1)*(x-e2)*(x-e3). See ?ellQ_ellrank for the format of the output.");
+   addhelp(ell2descent_gen,
+-    "ell2descent_gen((E,bnf,k=1,help=[]): E is a vector of the form [0,A,0,B,C], (or the result of ellinit of such a vector) A,B,C integers such that x^3+A*x^2+B*x+C; bnf is the corresponding bnfinit(,1); Performs 2-descent on the elliptic curve Ek: k*y^2=x^3+A*x^2+B*x+C. See ?ellrank for the format of the output.");
++    "ell2descent_gen((E,bnf,k=1,help=[]): E is a vector of the form [0,A,0,B,C], (or the result of ellinit of such a vector) A,B,C integers such that x^3+A*x^2+B*x+C; bnf is the corresponding bnfinit(,1); Performs 2-descent on the elliptic curve Ek: k*y^2=x^3+A*x^2+B*x+C. See ?ellQ_ellrank for the format of the output.");
+   addhelp(ell2descent_viaisog,
+-    "ell2descent_viaisog(E,help=[]): E is an elliptic curve of the form [0,a,0,b,0], with a, b integers. Performs a 2-descent via isogeny on E. See ?ellrank for the format of the output.");
+-  addhelp(ellrank,
+-    "ellrank(E,help=[]): E is any elliptic curve defined over Q. Returns a vector [r,s,v], where r is a lower bound for the rank of E, s is the rank of its 2-Selmer group and v is a list of independant points in E(Q)/2E(Q). If help is a vector of nontrivial points on E, the result might be faster. This function might be used in conjunction with elltors2(E). See also ?default_ellQ");
++    "ell2descent_viaisog(E,help=[]): E is an elliptic curve of the form [0,a,0,b,0], with a, b integers. Performs a 2-descent via isogeny on E. See ?ellQ_ellrank for the format of the output.");
++  addhelp(ellQ_ellrank,
++    "ellQ_ellrank(E,help=[]): E is any elliptic curve defined over Q. Returns a vector [r,s,v], where r is a lower bound for the rank of E, s is the rank of its 2-Selmer group and v is a list of independant points in E(Q)/2E(Q). If help is a vector of nontrivial points on E, the result might be faster. This function might be used in conjunction with elltors2(E). See also ?default_ellQ");
+   addhelp(ellhalf,
+     "ellhalf(E,P): returns the vector of all points Q on the elliptic curve E such that 2Q = P");
+   addhelp(ellredgen,
+@@ -2143,7 +2143,7 @@ if( DEBUGLEVEL_ell >= 3, print("   end of ell2descent_viaisog"));
+ 
+ \\                  others
+   addhelp(default_ellQ,
+-    "default_ellQ(DEBUGLEVEL_ell, LIM1, LIM3, LIMTRIV, ELLREDGENFLAG, COMPLETE, MAXPROB, LIMBIGPRIME): set the value of the global variables used for ellrank() and other related functions. DEBUGLEVEL_ell: 0-5: choose the quantity of information printed during the computation (default=0: print nothing); LIM1 (resp LIM3): search limit for easy (resp hard) points on quartics; LIMTRIV: search limit for trivial points on elliptic curves; ELLREDGENFLAG: if != 0, try to reduce the generators at the end; COMPLETE: if != 0 and full 2-torsion, use complete 2-descent, otherwise via 2-isogeny; MAXPROB, LIMBIGPRIME: technical.");
++    "default_ellQ(DEBUGLEVEL_ell, LIM1, LIM3, LIMTRIV, ELLREDGENFLAG, COMPLETE, MAXPROB, LIMBIGPRIME): set the value of the global variables used for ellQ_ellrank() and other related functions. DEBUGLEVEL_ell: 0-5: choose the quantity of information printed during the computation (default=0: print nothing); LIM1 (resp LIM3): search limit for easy (resp hard) points on quartics; LIMTRIV: search limit for trivial points on elliptic curves; ELLREDGENFLAG: if != 0, try to reduce the generators at the end; COMPLETE: if != 0 and full 2-torsion, use complete 2-descent, otherwise via 2-isogeny; MAXPROB, LIMBIGPRIME: technical.");
+ /*  addhelp(DEBUGLEVEL_ell,
+     "DEBUGLEVEL_ell: Choose a higher value of this global variable to have more details of the computations printed during the 2-descent algorithm. 0 = don't print anything; 1 = (default) just print the result; 2 = print more details including the Selmer group and the nontrivial quartics.");
+ */
+diff --git a/src/sage/ext_data/pari/simon/qfsolve.gp b/src/sage/ext_data/pari/simon/qfsolve.gp
+index 501fb50828..2107288c1d 100644
+--- a/src/sage/ext_data/pari/simon/qfsolve.gp
++++ b/src/sage/ext_data/pari/simon/qfsolve.gp
+@@ -434,146 +434,6 @@ my(cc);
+ return([U3~*G3*U3,red[2]*U1*U2*U3]);
+ }
+ 
+-\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+-\\        QUADRATIC FORMS MINIMIZATION         \\
+-\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+-
+-\\ Minimization of the quadratic form G, with nonzero determinant.
+-\\ of dimension n>=2.
+-\\ G must by symmetric and have integral coefficients.
+-\\ Returns [G',U,factd] with U in GLn(Q) such that G'=U~*G*U*constant
+-\\ is integral and has minimal determinant.
+-\\ In dimension 3 or 4, may return a prime p
+-\\ if the reduction at p is impossible because of the local non solvability.
+-\\ If given, factdetG must be equal to factor(abs(det(G))).
+-{qfminimize(G,factdetG) =
+-my(factd,U,Ker,Ker2,sol,aux,di);
+-my(p);
+-my(n,lf,i,vp,dimKer,dimKer2,m);
+-
+-  n = length(G);
+-  factd = matrix(0,2);
+-  if( !factdetG, factdetG = factor(matdet(G)));
+-
+-  lf = length(factdetG[,1]);
+-  i = 1; U = matid(n);
+-
+-  while(i <= lf,
+-    vp = factdetG[i,2];
+-    if( vp == 0, i++; next);
+-    p = factdetG[i,1];
+-    if( p == -1, i++; next);
+-if( DEBUGLEVEL_qfsolve >= 4, print("    p = ",p,"^",vp));
+-
+-\\ The case vp = 1 can be minimized only if n is odd.
+-    if( vp == 1 && n%2 == 0,
+-      factd = concat(factd~, Mat([p,1])~)~;
+-      i++; next
+-    );
+-    Ker = kermodp(G,p); dimKer = Ker[1]; Ker = Ker[2];
+-
+-\\ Rem: we must have dimKer <= vp
+-if( DEBUGLEVEL_qfsolve >= 4, print("    dimKer = ",dimKer));
+-\\ trivial case: dimKer = n
+-    if( dimKer == n, 
+-if( DEBUGLEVEL_qfsolve >= 4, print("     case 0: dimKer = n"));
+-      G /= p;
+-      factdetG[i,2] -= n;
+-      next
+-    );
+-    G = Ker~*G*Ker;
+-    U = U*Ker;
+-
+-\\ 1st case: dimKer < vp
+-\\ then the kernel mod p contains a kernel mod p^2
+-    if( dimKer < vp,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 1: dimker < vp"));
+-      if( dimKer == 1,
+-\\        G[,1] /= p; G[1,] /= p;
+-        G[,1] /= p; G[1,] = G[1,]/p;
+-        U[,1] /= p;
+-        factdetG[i,2] -= 2
+-      , 
+-        Ker2 = kermodp(matrix(dimKer,dimKer,j,k,G[j,k]/p),p);
+-        dimKer2 = Ker2[1]; Ker2 = Ker2[2];
+-        for( j = 1, dimKer2, Ker2[,j] /= p);
+-        Ker2 = matdiagonalblock([Ker2,matid(n-dimKer)]);
+-        G = Ker2~*G*Ker2;
+-        U = U*Ker2;
+-        factdetG[i,2] -= 2*dimKer2
+-);
+-
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 1"));
+-      next
+-    );
+-
+-\\ Now, we have vp = dimKer 
+-\\ 2nd case: the dimension of the kernel is >=2
+-\\ and contains an element of norm 0 mod p^2
+-
+-\\ search for an element of norm p^2... in the kernel
+-    if( dimKer > 2 || 
+-       (dimKer == 2 && issquare( di = Mod((G[1,2]^2-G[1,1]*G[2,2])/p^2,p))),
+-      if( dimKer > 2,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 2.1"));
+-        dimKer = 3;
+-        sol = qfsolvemodp(matrix(3,3,j,k,G[j,k]/p),p)
+-      ,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 2.2"));
+-        if( G[1,1]%p^2 == 0, 
+-          sol = [1,0]~
+-        , sol = [-G[1,2]/p+sqrt(di),Mod(G[1,1]/p,p)]~
+-        )
+-      );
+-      sol = centerlift(sol);
+-      sol /= content(sol);
+-if( DEBUGLEVEL_qfsolve >= 4, print("    sol = ",sol));
+-      Ker = vectorv(n, j, if( j<= dimKer, sol[j], 0)); \\ fill with 0's
+-      Ker = completebasis(Ker,1);
+-      Ker[,n] /= p;
+-      G = Ker~*G*Ker;
+-      U = U*Ker;
+-      factdetG[i,2] -= 2;
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 2"));
+-      next
+-    );
+-
+-\\ Now, we have vp = dimKer <= 2 
+-\\   and the kernel contains no vector with norm p^2...
+-
+-\\ In some cases, exchanging the kernel and the image
+-\\ makes the minimization easy.
+-
+-    m = (n-1)\2-1;
+-    if( ( vp == 1 && issquare(Mod(-(-1)^m*matdet(G)/G[1,1],p)))
+-     || ( vp == 2 && n%2 == 1 && n >= 5)
+-     || ( vp == 2 && n%2 == 0 && !issquare(Mod((-1)^m*matdet(G)/p^2,p)))
+-    , 
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 3"));
+-      Ker = matid(n);
+-      for( j = dimKer+1, n, Ker[j,j] = p);
+-      G = Ker~*G*Ker/p;
+-      U = U*Ker;
+-      factdetG[i,2] -= 2*dimKer-n;
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 3"));
+-      next
+-    );
+-
+-\\ Minimization was not possible se far.
+-\\ If n == 3 or 4, this proves the local non-solubility at p.
+-    if( n == 3 || n == 4, 
+-if( DEBUGLEVEL_qfsolve >= 1, print(" no local solution at ",p));
+-      return(p));
+-
+-if( DEBUGLEVEL_qfsolve >= 4, print("    prime ",p," finished"));
+-    factd = concat(factd~,Mat([p,vp])~)~;
+-    i++
+-  );
+-\\ apply LLL to avoid coefficients explosion
+-  aux = qflll(U/content(U));
+-return([aux~*G*aux,U*aux,factd]);
+-}
+-
+ \\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+ \\          CLASS GROUP COMPUTATIONS           \\
+ \\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+diff --git a/src/sage/geometry/polyhedron/backend_field.py b/src/sage/geometry/polyhedron/backend_field.py
+index 6b921d23a6..2f32c58b1e 100644
+--- a/src/sage/geometry/polyhedron/backend_field.py
++++ b/src/sage/geometry/polyhedron/backend_field.py
+@@ -265,7 +265,7 @@ class Polyhedron_field(Polyhedron_base):
+              An inequality (-0.1419794359520263?, -1.698172434277148?) x + 1.200789243901438? >= 0,
+              An inequality (0.3001973109753594?, 0.600394621950719?) x - 0.4245431085692869? >= 0)
+             sage: p.Vrepresentation()                                           # optional - sage.rings.number_field
+-            (A vertex at (0.?e-15, 0.707106781186548?),
++            (A vertex at (0.?e-16, 0.7071067811865475?),
+              A vertex at (1.414213562373095?, 0),
+              A vertex at (4.000000000000000?, 0.372677996249965?))
+         """
+@@ -308,7 +308,7 @@ class Polyhedron_field(Polyhedron_base):
+              An inequality (-0.1419794359520263?, -1.698172434277148?) x + 1.200789243901438? >= 0,
+              An inequality (0.3001973109753594?, 0.600394621950719?) x - 0.4245431085692869? >= 0)
+             sage: p.Vrepresentation()                                           # optional - sage.rings.number_field
+-            (A vertex at (0.?e-15, 0.707106781186548?),
++            (A vertex at (0.?e-16, 0.7071067811865475?),
+              A vertex at (1.414213562373095?, 0),
+              A vertex at (4.000000000000000?, 0.372677996249965?))
+         """
+diff --git a/src/sage/geometry/polyhedron/backend_normaliz.py b/src/sage/geometry/polyhedron/backend_normaliz.py
+index 86b89632a5..ca8a43b248 100644
+--- a/src/sage/geometry/polyhedron/backend_normaliz.py
++++ b/src/sage/geometry/polyhedron/backend_normaliz.py
+@@ -53,7 +53,7 @@ def _number_field_elements_from_algebraics_list_of_lists_of_lists(listss, **kwds
+         1.732050807568878?
+         sage: from sage.geometry.polyhedron.backend_normaliz import _number_field_elements_from_algebraics_list_of_lists_of_lists
+         sage: K, results, hom = _number_field_elements_from_algebraics_list_of_lists_of_lists([[[rt2], [1]], [[rt3]], [[1], []]]); results  # optional - sage.rings.number_field
+-        [[[-a^3 + 3*a], [1]], [[-a^2 + 2]], [[1], []]]
++        [[[-a^3 + 3*a], [1]], [[a^2 - 2]], [[1], []]]
+     """
+     from sage.rings.qqbar import number_field_elements_from_algebraics
+     numbers = []
+diff --git a/src/sage/groups/matrix_gps/isometries.py b/src/sage/groups/matrix_gps/isometries.py
+index f9111a2c92..cca45e7175 100644
+--- a/src/sage/groups/matrix_gps/isometries.py
++++ b/src/sage/groups/matrix_gps/isometries.py
+@@ -11,11 +11,11 @@ EXAMPLES::
+     sage: L = IntegralLattice("D4")
+     sage: O = L.orthogonal_group()
+     sage: O
+-    Group of isometries with 5 generators (
+-    [-1  0  0  0]  [0 0 0 1]  [-1 -1 -1 -1]  [ 1  1  0  0]  [ 1  0  0  0]
+-    [ 0 -1  0  0]  [0 1 0 0]  [ 0  0  1  0]  [ 0  0  1  0]  [-1 -1 -1 -1]
+-    [ 0  0 -1  0]  [0 0 1 0]  [ 0  1  0  1]  [ 0  1  0  1]  [ 0  0  1  0]
+-    [ 0  0  0 -1], [1 0 0 0], [ 0 -1 -1  0], [ 0 -1 -1  0], [ 0  0  0  1]
++    Group of isometries with 3 generators (
++    [0 0 0 1]  [ 1  1  0  0]  [ 1  0  0  0]
++    [0 1 0 0]  [ 0  0  1  0]  [-1 -1 -1 -1]
++    [0 0 1 0]  [ 0  1  0  1]  [ 0  0  1  0]
++    [1 0 0 0], [ 0 -1 -1  0], [ 0  0  0  1]
+     )
+ 
+ Basic functionality is provided by GAP::
+diff --git a/src/sage/interfaces/genus2reduction.py b/src/sage/interfaces/genus2reduction.py
+index 56ae04b235..7a4794daf2 100644
+--- a/src/sage/interfaces/genus2reduction.py
++++ b/src/sage/interfaces/genus2reduction.py
+@@ -143,31 +143,31 @@ class ReductionData(SageObject):
+        sur un corps de valuation discrète", Trans. AMS 348 (1996),
+        4577-4610, Section 7.2, Proposition 4).
+     """
+-    def __init__(self, pari_result, P, Q, minimal_equation, minimal_disc,
+-                 local_data, conductor, prime_to_2_conductor_only):
++    def __init__(self, pari_result, P, Q, Pmin, Qmin, minimal_disc,
++                 local_data, conductor):
+         self.pari_result = pari_result
+         self.P = P
+         self.Q = Q
+-        self.minimal_equation = minimal_equation
++        self.Pmin = Pmin
++        self.Qmin = Qmin
+         self.minimal_disc = minimal_disc
+         self.local_data = local_data
+         self.conductor = conductor
+-        self.prime_to_2_conductor_only = prime_to_2_conductor_only
+ 
+     def _repr_(self):
+-        if self.prime_to_2_conductor_only:
+-            ex = ' (away from 2)'
+-        else:
+-            ex = ''
+         if self.Q == 0:
+             yterm = ''
+         else:
+             yterm = '+ (%s)*y '%self.Q
++
+         s = 'Reduction data about this proper smooth genus 2 curve:\n'
+         s += '\ty^2 %s= %s\n'%(yterm, self.P)
+-        s += 'A Minimal Equation (away from 2):\n\ty^2 = %s\n'%self.minimal_equation
+-        s += 'Minimal Discriminant (away from 2):  %s\n'%self.minimal_disc
+-        s += 'Conductor%s: %s\n'%(ex, self.conductor)
++        if self.Qmin:
++            s += 'A Minimal Equation:\n\ty^2 + (%s)y = %s\n'%(self.Qmin, self.Pmin)
++        else:
++            s += 'A Minimal Equation:\n\ty^2 = %s\n'%self.Pmin
++        s += 'Minimal Discriminant: %s\n'%self.minimal_disc
++        s += 'Conductor: %s\n'%self.conductor
+         s += 'Local Data:\n%s'%self._local_data_str()
+         return s
+ 
+@@ -242,17 +242,7 @@ class Genus2reduction(SageObject):
+         sage: factor(R.conductor)
+         5^4 * 2267
+ 
+-    This means that only the odd part of the conductor is known.
+-
+-    ::
+-
+-        sage: R.prime_to_2_conductor_only
+-        True
+-
+-    The discriminant is always minimal away from 2, but possibly not at
+-    2.
+-
+-    ::
++    The discriminant is always minimal::
+ 
+         sage: factor(R.minimal_disc)
+         2^3 * 5^5 * 2267
+@@ -264,10 +254,10 @@ class Genus2reduction(SageObject):
+         sage: R
+         Reduction data about this proper smooth genus 2 curve:
+             y^2 + (x^3 - 2*x^2 - 2*x + 1)*y = -5*x^5
+-        A Minimal Equation (away from 2):
+-            y^2 = x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855
+-        Minimal Discriminant (away from 2):  56675000
+-        Conductor (away from 2): 1416875
++        A Minimal Equation:
++            y^2 ...
++        Minimal Discriminant: 56675000
++        Conductor: 1416875
+         Local Data:
+             p=2
+             (potential) stable reduction:  (II), j=1
+@@ -293,10 +283,10 @@ class Genus2reduction(SageObject):
+         sage: genus2reduction(0, x^6 + 3*x^3 + 63)
+         Reduction data about this proper smooth genus 2 curve:
+                 y^2 = x^6 + 3*x^3 + 63
+-        A Minimal Equation (away from 2):
+-                y^2 = x^6 + 3*x^3 + 63
+-        Minimal Discriminant (away from 2):  10628388316852992
+-        Conductor (away from 2): 2893401
++        A Minimal Equation:
++                y^2 ...
++        Minimal Discriminant: -10628388316852992
++        Conductor: 2893401
+         Local Data:
+                 p=2
+                 (potential) stable reduction:  (V), j1+j2=0, j1*j2=0
+@@ -327,9 +317,9 @@ class Genus2reduction(SageObject):
+         sage: genus2reduction(x^3-x^2-1, x^2 - x)
+         Reduction data about this proper smooth genus 2 curve:
+                 y^2 + (x^3 - x^2 - 1)*y = x^2 - x
+-        A Minimal Equation (away from 2):
+-                y^2 = x^6 + 58*x^5 + 1401*x^4 + 18038*x^3 + 130546*x^2 + 503516*x + 808561
+-        Minimal Discriminant (away from 2):  169
++        A Minimal Equation:
++                y^2 ...
++        Minimal Discriminant: -169
+         Conductor: 169
+         Local Data:
+                 p=13
+@@ -370,10 +360,10 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^3 - 2*x^2 - 2*x + 1, -5*x^5)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^3 - 2*x^2 - 2*x + 1)*y = -5*x^5
+-            A Minimal Equation (away from 2):
+-                    y^2 = x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855
+-            Minimal Discriminant (away from 2):  56675000
+-            Conductor (away from 2): 1416875
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 56675000
++            Conductor: 1416875
+             Local Data:
+                     p=2
+                     (potential) stable reduction:  (II), j=1
+@@ -389,9 +379,9 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^2 + 1, -5*x^5)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^2 + 1)*y = -5*x^5
+-            A Minimal Equation (away from 2):
+-                    y^2 = -20*x^5 + x^4 + 2*x^2 + 1
+-            Minimal Discriminant (away from 2):  48838125
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 48838125
+             Conductor: 32025
+             Local Data:
+                     p=3
+@@ -412,9 +402,9 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^3 + x^2 + x,-2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^3 + x^2 + x)*y = -2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2
+-            A Minimal Equation (away from 2):
+-                    y^2 = x^6 + 18*x^3 + 36*x^2 - 27
+-            Minimal Discriminant (away from 2):  1520984142
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 1520984142
+             Conductor: 954
+             Local Data:
+                     p=2
+@@ -436,18 +426,10 @@ class Genus2reduction(SageObject):
+             raise ValueError("Q (=%s) must have degree at most 3" % Q)
+ 
+         res = pari.genus2red([P, Q])
+-
+         conductor = ZZ(res[0])
+-        minimal_equation = R(res[2])
+-
+-        minimal_disc = QQ(res[2].poldisc()).abs()
+-        if minimal_equation.degree() == 5:
+-            minimal_disc *= minimal_equation[5]**2
+-        # Multiply with suitable power of 2 of the form 2^(2*(d-1) - 12)
+-        b = 2 * (minimal_equation.degree() - 1)
+-        k = QQ((12 - minimal_disc.valuation(2), b)).ceil()
+-        minimal_disc >>= 12 - b*k
+-        minimal_disc = ZZ(minimal_disc)
++        Pmin = R(res[2][0])
++        Qmin = R(res[2][1])
++        minimal_disc = ZZ(pari.hyperelldisc(res[2]))
+ 
+         local_data = {}
+         for red in res[3]:
+@@ -468,9 +450,7 @@ class Genus2reduction(SageObject):
+ 
+             local_data[p] = data
+ 
+-        prime_to_2_conductor_only = (-1 in res[1].component(2))
+-        return ReductionData(res, P, Q, minimal_equation, minimal_disc, local_data,
+-                             conductor, prime_to_2_conductor_only)
++        return ReductionData(res, P, Q, Pmin, Qmin, minimal_disc, local_data, conductor)
+ 
+     def __reduce__(self):
+         return _reduce_load_genus2reduction, tuple([])
+diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
+index fec450d7bc..236402c293 100644
+--- a/src/sage/lfunctions/dokchitser.py
++++ b/src/sage/lfunctions/dokchitser.py
+@@ -337,6 +337,7 @@ class Dokchitser(SageObject):
+             # After init_coeffs is called, future calls to this method should
+             # return the full output for further parsing
+             raise RuntimeError("unable to create L-series, due to precision or other limits in PARI")
++        t = t.replace("  *** _^_: Warning: normalizing a series with 0 leading term.\n", "")
+         return t
+ 
+     def __check_init(self):
+diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
+index d2b20f1891..6c31efe239 100644
+--- a/src/sage/lfunctions/pari.py
++++ b/src/sage/lfunctions/pari.py
+@@ -339,7 +339,7 @@ def lfun_eta_quotient(scalings, exponents):
+         0.0374412812685155
+ 
+         sage: lfun_eta_quotient([6],[4])
+-        [[Vecsmall([7]), [Vecsmall([6]), Vecsmall([4])]], 0, [0, 1], 2, 36, 1]
++        [[Vecsmall([7]), [Vecsmall([6]), Vecsmall([4]), 0]], 0, [0, 1], 2, 36, 1]
+ 
+         sage: lfun_eta_quotient([2,1,4], [5,-2,-2])
+         Traceback (most recent call last):
+diff --git a/src/sage/libs/pari/tests.py b/src/sage/libs/pari/tests.py
+index e5a2aa2517..0efcb15de0 100644
+--- a/src/sage/libs/pari/tests.py
++++ b/src/sage/libs/pari/tests.py
+@@ -356,7 +356,7 @@ Constructors::
+     [2, 4]~*x + [1, 3]~
+ 
+     sage: pari(3).Qfb(7, 1)
+-    Qfb(3, 7, 1, 0.E-19)
++    Qfb(3, 7, 1)
+     sage: pari(3).Qfb(7, 2)
+     Traceback (most recent call last):
+     ...
+@@ -512,7 +512,7 @@ Basic functions::
+     sage: pari('sqrt(-2)').frac()
+     Traceback (most recent call last):
+     ...
+-    PariError: incorrect type in gfloor (t_COMPLEX)
++    PariError: incorrect type in gfrac (t_COMPLEX)
+ 
+     sage: pari('1+2*I').imag()
+     2
+diff --git a/src/sage/modular/cusps_nf.py b/src/sage/modular/cusps_nf.py
+index 25d93cac92..157ebabe29 100644
+--- a/src/sage/modular/cusps_nf.py
++++ b/src/sage/modular/cusps_nf.py
+@@ -1220,7 +1220,7 @@ def units_mod_ideal(I):
+         sage: I = k.ideal(5, a + 1)
+         sage: units_mod_ideal(I)
+         [1,
+-        2*a^2 + 4*a - 1,
++        -2*a^2 - 4*a + 1,
+         ...]
+ 
+     ::
+diff --git a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
+index a881336596..090d1bfaf0 100644
+--- a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
++++ b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
+@@ -43,7 +43,7 @@ def coerce_AA(p):
+         sage: AA(p)._exact_field()
+         Number Field in a with defining polynomial y^8 ... with a in ...
+         sage: coerce_AA(p)._exact_field()
+-        Number Field in a with defining polynomial y^4 - 1910*y^2 - 3924*y + 681058 with a in 39.710518724...?
++        Number Field in a with defining polynomial y^4 - 1910*y^2 - 3924*y + 681058 with a in ...?
+     """
+     el = AA(p)
+     el.simplify()
+diff --git a/src/sage/modular/modsym/p1list_nf.py b/src/sage/modular/modsym/p1list_nf.py
+index 222caacca8..f9d969732c 100644
+--- a/src/sage/modular/modsym/p1list_nf.py
++++ b/src/sage/modular/modsym/p1list_nf.py
+@@ -58,7 +58,7 @@ Lift an MSymbol to a matrix in `SL(2, R)`:
+ 
+     sage: alpha = MSymbol(N, a + 2, 3*a^2)
+     sage: alpha.lift_to_sl2_Ok()
+-    [-3*a^2 + a + 12, 25*a^2 - 50*a + 100, a + 2, a^2 - 3*a + 3]
++    [-1, 4*a^2 - 13*a + 23, a + 2, 5*a^2 + 3*a - 3]
+     sage: Ok = k.ring_of_integers()
+     sage: M = Matrix(Ok, 2, alpha.lift_to_sl2_Ok())
+     sage: det(M)
+@@ -945,11 +945,11 @@ class P1NFList(SageObject):
+             sage: N = k.ideal(5, a + 1)
+             sage: P = P1NFList(N)
+             sage: u = k.unit_group().gens_values(); u
+-            [-1, 2*a^2 + 4*a - 1]
++            [-1, -2*a^2 - 4*a + 1]
+             sage: P.apply_J_epsilon(4, -1)
+             2
+             sage: P.apply_J_epsilon(4, u[0], u[1])
+-            1
++            5
+ 
+         ::
+ 
+diff --git a/src/sage/modules/free_quadratic_module_integer_symmetric.py b/src/sage/modules/free_quadratic_module_integer_symmetric.py
+index a206f0c721..aeb19ab669 100644
+--- a/src/sage/modules/free_quadratic_module_integer_symmetric.py
++++ b/src/sage/modules/free_quadratic_module_integer_symmetric.py
+@@ -1168,11 +1168,11 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+             sage: A4 = IntegralLattice("A4")
+             sage: Aut = A4.orthogonal_group()
+             sage: Aut
+-            Group of isometries with 5 generators (
+-            [-1  0  0  0]  [0 0 0 1]  [-1 -1 -1  0]  [ 1  0  0  0]  [ 1  0  0  0]
+-            [ 0 -1  0  0]  [0 0 1 0]  [ 0  0  0 -1]  [-1 -1 -1 -1]  [ 0  1  0  0]
+-            [ 0  0 -1  0]  [0 1 0 0]  [ 0  0  1  1]  [ 0  0  0  1]  [ 0  0  1  1]
+-            [ 0  0  0 -1], [1 0 0 0], [ 0  1  0  0], [ 0  0  1  0], [ 0  0  0 -1]
++            Group of isometries with 4 generators (
++            [0 0 0 1]  [-1 -1 -1  0]  [ 1  0  0  0]  [ 1  0  0  0]
++            [0 0 1 0]  [ 0  0  0 -1]  [-1 -1 -1 -1]  [ 0  1  0  0]
++            [0 1 0 0]  [ 0  0  1  1]  [ 0  0  0  1]  [ 0  0  1  1]
++            [1 0 0 0], [ 0  1  0  0], [ 0  0  1  0], [ 0  0  0 -1]
+             )
+ 
+         The group acts from the right on the lattice and its discriminant group::
+@@ -1180,19 +1180,19 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+             sage: x = A4.an_element()
+             sage: g = Aut.an_element()
+             sage: g
+-            [ 1  1  1  0]
+-            [ 0  0 -1  0]
+-            [ 0  0  1  1]
+-            [ 0 -1 -1 -1]
++            [-1 -1 -1  0]
++            [ 0  0  1  0]
++            [ 0  0 -1 -1]
++            [ 0  1  1  1]
+             sage: x*g
+-            (1, 1, 1, 0)
++            (-1, -1, -1, 0)
+             sage: (x*g).parent()==A4
+             True
+             sage: (g*x).parent()
+             Vector space of dimension 4 over Rational Field
+             sage: y = A4.discriminant_group().an_element()
+             sage: y*g
+-            (1)
++            (4)
+ 
+         If the group is finite we can compute the usual things::
+ 
+@@ -1208,10 +1208,10 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+ 
+             sage: A2 = IntegralLattice(matrix.identity(3),Matrix(ZZ,2,3,[1,-1,0,0,1,-1]))
+             sage: A2.orthogonal_group()
+-            Group of isometries with 3 generators (
+-            [-1/3  2/3  2/3]  [ 2/3  2/3 -1/3]  [1 0 0]
+-            [ 2/3 -1/3  2/3]  [ 2/3 -1/3  2/3]  [0 0 1]
+-            [ 2/3  2/3 -1/3], [-1/3  2/3  2/3], [0 1 0]
++            Group of isometries with 2 generators (
++            [ 2/3  2/3 -1/3]  [1 0 0]
++            [ 2/3 -1/3  2/3]  [0 0 1]
++            [-1/3  2/3  2/3], [0 1 0]
+             )
+ 
+         It can be negative definite as well::
+diff --git a/src/sage/quadratic_forms/binary_qf.py b/src/sage/quadratic_forms/binary_qf.py
+index cfa3ada73e..5ac823bc6c 100755
+--- a/src/sage/quadratic_forms/binary_qf.py
++++ b/src/sage/quadratic_forms/binary_qf.py
+@@ -141,7 +141,7 @@ class BinaryQF(SageObject):
+                   and a.degree() == 2 and a.parent().ngens() == 2):
+                 x, y = a.parent().gens()
+                 a, b, c = [a.monomial_coefficient(mon) for mon in [x**2, x*y, y**2]]
+-            elif isinstance(a, pari_gen) and a.type() in ('t_QFI', 't_QFR'):
++            elif isinstance(a, pari_gen) and a.type() in ('t_QFI', 't_QFR', 't_QFB'):
+                 # a has 3 or 4 components
+                 a, b, c = a[0], a[1], a[2]
+         try:
+diff --git a/src/sage/quadratic_forms/genera/genus.py b/src/sage/quadratic_forms/genera/genus.py
+index 8290b6c4fa..0fc43f33c6 100644
+--- a/src/sage/quadratic_forms/genera/genus.py
++++ b/src/sage/quadratic_forms/genera/genus.py
+@@ -3088,8 +3088,8 @@ class GenusSymbol_global_ring():
+             sage: G = Genus(matrix(ZZ, 3, [6,3,0, 3,6,0, 0,0,2]))
+             sage: G.representatives()
+             (
+-            [2 0 0]  [ 2 -1  0]
+-            [0 6 3]  [-1  2  0]
++            [2 0 0]  [ 2  1  0]
++            [0 6 3]  [ 1  2  0]
+             [0 3 6], [ 0  0 18]
+             )
+ 
+diff --git a/src/sage/quadratic_forms/qfsolve.py b/src/sage/quadratic_forms/qfsolve.py
+index ddde95e04f..d5e15d9f83 100644
+--- a/src/sage/quadratic_forms/qfsolve.py
++++ b/src/sage/quadratic_forms/qfsolve.py
+@@ -70,7 +70,7 @@ def qfsolve(G):
+ 
+         sage: M = Matrix(QQ, [[3, 0, 0, 0], [0, 5, 0, 0], [0, 0, -7, 0], [0, 0, 0, -11]])
+         sage: qfsolve(M)
+-        (3, -4, -3, -2)
++        (3, 4, -3, -2)
+     """
+     ret = G.__pari__().qfsolve()
+     if ret.type() == 't_COL':
+diff --git a/src/sage/quadratic_forms/quadratic_form__automorphisms.py b/src/sage/quadratic_forms/quadratic_form__automorphisms.py
+index c36c667e3b..3d72cf3be1 100644
+--- a/src/sage/quadratic_forms/quadratic_form__automorphisms.py
++++ b/src/sage/quadratic_forms/quadratic_form__automorphisms.py
+@@ -300,9 +300,9 @@ def automorphism_group(self):
+         sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1])
+         sage: Q.automorphism_group()
+         Matrix group over Rational Field with 3 generators (
+-        [-1  0  0]  [0 0 1]  [ 0  0  1]
+-        [ 0 -1  0]  [0 1 0]  [-1  0  0]
+-        [ 0  0 -1], [1 0 0], [ 0  1  0]
++        [ 0  0  1]  [1 0 0]  [ 1  0  0]
++        [-1  0  0]  [0 0 1]  [ 0 -1  0]
++        [ 0  1  0], [0 1 0], [ 0  0  1]
+         )
+ 
+     ::
+diff --git a/src/sage/rings/finite_rings/finite_field_prime_modn.py b/src/sage/rings/finite_rings/finite_field_prime_modn.py
+index 9129ecb56a..d5a4cb8f22 100644
+--- a/src/sage/rings/finite_rings/finite_field_prime_modn.py
++++ b/src/sage/rings/finite_rings/finite_field_prime_modn.py
+@@ -111,7 +111,7 @@ class FiniteField_prime_modn(FiniteField_generic, integer_mod_ring.IntegerModRin
+             sage: RF13 = K.residue_field(pp)
+             sage: RF13.hom([GF(13)(1)])
+             Ring morphism:
+-             From: Residue field of Fractional ideal (w + 18)
++             From: Residue field of Fractional ideal (-w - 18)
+              To:   Finite Field of size 13
+              Defn: 1 |--> 1
+ 
+diff --git a/src/sage/rings/finite_rings/residue_field.pyx b/src/sage/rings/finite_rings/residue_field.pyx
+index 7596f2a302..1e1869f1b1 100644
+--- a/src/sage/rings/finite_rings/residue_field.pyx
++++ b/src/sage/rings/finite_rings/residue_field.pyx
+@@ -20,13 +20,13 @@ monogenic (i.e., 2 is an essential discriminant divisor)::
+ 
+     sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8)
+     sage: F = K.factor(2); F
+-    (Fractional ideal (1/2*a^2 - 1/2*a + 1)) * (Fractional ideal (-a^2 + 2*a - 3)) * (Fractional ideal (-3/2*a^2 + 5/2*a - 4))
++    (Fractional ideal (-1/2*a^2 + 1/2*a - 1)) * (Fractional ideal (-a^2 + 2*a - 3)) * (Fractional ideal (3/2*a^2 - 5/2*a + 4))
+     sage: F[0][0].residue_field()
+-    Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++    Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+     sage: F[1][0].residue_field()
+     Residue field of Fractional ideal (-a^2 + 2*a - 3)
+     sage: F[2][0].residue_field()
+-    Residue field of Fractional ideal (-3/2*a^2 + 5/2*a - 4)
++    Residue field of Fractional ideal (3/2*a^2 - 5/2*a + 4)
+ 
+ We can also form residue fields from `\ZZ`::
+ 
+@@ -258,9 +258,9 @@ class ResidueFieldFactory(UniqueFactory):
+     the index of ``ZZ[a]`` in the maximal order for all ``a``::
+ 
+         sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8); P = K.ideal(2).factor()[0][0]; P
+-        Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F = K.residue_field(P); F
+-        Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F(a)
+         0
+         sage: B = K.maximal_order().basis(); B
+@@ -270,7 +270,7 @@ class ResidueFieldFactory(UniqueFactory):
+         sage: F(B[2])
+         0
+         sage: F
+-        Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F.degree()
+         1
+ 
+@@ -730,15 +730,15 @@ class ResidueField_generic(Field):
+         EXAMPLES::
+ 
+             sage: I = QQ[3^(1/3)].factor(5)[1][0]; I
+-            Fractional ideal (-a + 2)
++            Fractional ideal (a - 2)
+             sage: k = I.residue_field(); k
+-            Residue field of Fractional ideal (-a + 2)
++            Residue field of Fractional ideal (a - 2)
+             sage: f = k.lift_map(); f
+             Lifting map:
+-              From: Residue field of Fractional ideal (-a + 2)
++              From: Residue field of Fractional ideal (a - 2)
+               To:   Maximal Order in Number Field in a with defining polynomial x^3 - 3 with a = 1.442249570307409?
+             sage: f.domain()
+-            Residue field of Fractional ideal (-a + 2)
++            Residue field of Fractional ideal (a - 2)
+             sage: f.codomain()
+             Maximal Order in Number Field in a with defining polynomial x^3 - 3 with a = 1.442249570307409?
+             sage: f(k.0)
+@@ -768,7 +768,7 @@ class ResidueField_generic(Field):
+ 
+             sage: K.<a> = NumberField(x^3-11)
+             sage: F = K.ideal(37).factor(); F
+-            (Fractional ideal (37, a + 9)) * (Fractional ideal (37, a + 12)) * (Fractional ideal (2*a - 5))
++            (Fractional ideal (37, a + 9)) * (Fractional ideal (37, a + 12)) * (Fractional ideal (-2*a + 5))
+             sage: k = K.residue_field(F[0][0])
+             sage: l = K.residue_field(F[1][0])
+             sage: k == l
+@@ -846,7 +846,7 @@ cdef class ReductionMap(Map):
+             sage: F.reduction_map()
+             Partially defined reduction map:
+               From: Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
+-              To:   Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++              To:   Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+ 
+             sage: K.<theta_5> = CyclotomicField(5)
+             sage: F = K.factor(7)[0][0].residue_field()
+diff --git a/src/sage/rings/number_field/S_unit_solver.py b/src/sage/rings/number_field/S_unit_solver.py
+index e99dff850f..759cbfb334 100644
+--- a/src/sage/rings/number_field/S_unit_solver.py
++++ b/src/sage/rings/number_field/S_unit_solver.py
+@@ -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 (xi - 3),
+-         Fractional ideal (-2*xi^2 + 3),
++        (Fractional ideal (-2*xi^2 + 3),
++         Fractional ideal (-xi + 3),
+          Fractional ideal (2*xi + 1))
+ 
+         sage: sieve_data[1]
+-        (Residue field of Fractional ideal (xi - 3),
+-         Residue field of Fractional ideal (-2*xi^2 + 3),
++        (Residue field of Fractional ideal (-2*xi^2 + 3),
++         Residue field of Fractional ideal (-xi + 3),
+          Residue field of Fractional ideal (2*xi + 1))
+ 
+         sage: sieve_data[2]
+-        ([18, 7, 16, 4], [18, 9, 12, 8], [18, 3, 10, 10])
++        ([18, 12, 16, 8], [18, 16, 10, 4], [18, 10, 12, 10])
+ 
+         sage: sieve_data[3]
+-        (486, 648, 11664)
++        (648, 2916, 3888)
+     """
+ 
+     K = SUK.number_field()
+diff --git a/src/sage/rings/number_field/bdd_height.py b/src/sage/rings/number_field/bdd_height.py
+index beb047ae02..b7c8c33d0b 100644
+--- a/src/sage/rings/number_field/bdd_height.py
++++ b/src/sage/rings/number_field/bdd_height.py
+@@ -248,7 +248,7 @@ def bdd_norm_pr_ideal_gens(K, norm_list):
+         sage: from sage.rings.number_field.bdd_height import bdd_norm_pr_ideal_gens
+         sage: K.<g> = QuadraticField(123)
+         sage: bdd_norm_pr_ideal_gens(K, range(5))
+-        {0: [0], 1: [1], 2: [-g - 11], 3: [], 4: [2]}
++        {0: [0], 1: [1], 2: [g + 11], 3: [], 4: [2]}
+ 
+     ::
+ 
+diff --git a/src/sage/rings/number_field/class_group.py b/src/sage/rings/number_field/class_group.py
+index 018ff5f5c6..73c0462cd1 100644
+--- a/src/sage/rings/number_field/class_group.py
++++ b/src/sage/rings/number_field/class_group.py
+@@ -221,11 +221,11 @@ class FractionalIdealClass(AbelianGroupWithValuesElement):
+             Class group of order 76 with structure C38 x C2
+             of Number Field in a with defining polynomial x^2 + 20072
+             sage: I = (G.0)^11; I
+-            Fractional ideal class (41, 1/2*a + 5)
++            Fractional ideal class (33, 1/2*a + 8)
+             sage: J = G(I.ideal()^5); J
+-            Fractional ideal class (115856201, 1/2*a + 40407883)
++            Fractional ideal class (39135393, 1/2*a + 13654253)
+             sage: J.reduce()
+-            Fractional ideal class (57, 1/2*a + 44)
++            Fractional ideal class (73, 1/2*a + 47)
+             sage: J == I^5
+             True
+         """
+diff --git a/src/sage/rings/number_field/galois_group.py b/src/sage/rings/number_field/galois_group.py
+index 79acd053bb..e060148e4d 100644
+--- a/src/sage/rings/number_field/galois_group.py
++++ b/src/sage/rings/number_field/galois_group.py
+@@ -944,7 +944,7 @@ class GaloisGroup_v2(GaloisGroup_perm):
+             sage: K.<b> = NumberField(x^4 - 2*x^2 + 2, 'a').galois_closure()
+             sage: G = K.galois_group()
+             sage: [G.artin_symbol(P) for P in K.primes_above(7)]
+-            [(1,5)(2,6)(3,7)(4,8), (1,5)(2,6)(3,7)(4,8), (1,4)(2,3)(5,8)(6,7), (1,4)(2,3)(5,8)(6,7)]
++            [(1,4)(2,3)(5,8)(6,7), (1,4)(2,3)(5,8)(6,7), (1,5)(2,6)(3,7)(4,8), (1,5)(2,6)(3,7)(4,8)]
+             sage: G.artin_symbol(17)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
+index 58463d570d..ff65634e99 100644
+--- a/src/sage/rings/number_field/number_field.py
++++ b/src/sage/rings/number_field/number_field.py
+@@ -3643,7 +3643,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
+ 
+@@ -4227,7 +4227,8 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             (y^2 + 6, Mod(1/6*y, y^2 + 6), Mod(6*y, y^2 + 1/6))
+         """
+         f = self.absolute_polynomial()._pari_with_name('y')
+-        if f.pollead() == f.content().denominator() == 1:
++        f = f * f.content().denominator()
++        if f.pollead() == 1:
+             g = f
+             alpha = beta = g.variable().Mod(g)
+         else:
+@@ -4821,7 +4822,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+ 
+             sage: K.<a> = NumberField(2*x^2 - 1/3)
+             sage: K._S_class_group_and_units(tuple(K.primes_above(2) + K.primes_above(3)))
+-            ([-6*a + 2, 6*a + 3, -1, 12*a + 5], [])
++            ([6*a + 2, 6*a + 3, -1, -12*a + 5], [])
+         """
+         K_pari = self.pari_bnf(proof=proof)
+         S_pari = [p.pari_prime() for p in sorted(set(S))]
+@@ -5166,7 +5167,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+ 
+             sage: [K.ideal(g).factor() for g in gens]
+             [(Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1)),
+-            Fractional ideal (-a),
++            Fractional ideal (a),
+             (Fractional ideal (2, a + 1))^2,
+             1]
+ 
+@@ -5751,7 +5752,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: K.elements_of_norm(3)
+             []
+             sage: K.elements_of_norm(50)
+-            [-7*a + 1, 5*a - 5, 7*a + 1]
++            [-a - 7, 5*a - 5, 7*a + 1]
+ 
+         TESTS:
+ 
+@@ -5863,7 +5864,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: K.factor(1+a)
+             Fractional ideal (a + 1)
+             sage: K.factor(1+a/5)
+-            (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1 * (Fractional ideal (-3*a - 2))
++            (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1 * (Fractional ideal (-2*a + 3))
+ 
+         An example over a relative number field::
+ 
+@@ -6460,9 +6461,9 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: new_basis = k.reduced_basis(prec=120)
+             sage: [c.minpoly() for c in new_basis]
+             [x - 1,
+-             x^2 - x + 1,
++             x^2 + x + 1,
++             x^6 + 3*x^5 - 102*x^4 - 103*x^3 + 10572*x^2 - 59919*x + 127657,
+              x^6 + 3*x^5 - 102*x^4 - 103*x^3 + 10572*x^2 - 59919*x + 127657,
+-             x^6 - 3*x^5 - 102*x^4 + 315*x^3 + 10254*x^2 - 80955*x + 198147,
+              x^3 - 171*x + 848,
+              x^6 + 171*x^4 + 1696*x^3 + 29241*x^2 + 145008*x + 719104]
+             sage: R = k.order(new_basis)
+@@ -7058,7 +7059,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+              -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)
++             2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7)
+ 
+         TESTS:
+ 
+@@ -7067,7 +7068,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)
+ 
+@@ -7146,7 +7147,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^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]
++            [-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, 2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7]
+         """
+         proof = proof_flag(proof)
+ 
+diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx
+index 784c239dc1..aa740069dc 100644
+--- a/src/sage/rings/number_field/number_field_element.pyx
++++ b/src/sage/rings/number_field/number_field_element.pyx
+@@ -4446,7 +4446,7 @@ cdef class NumberFieldElement(FieldElement):
+             sage: f = Qi.embeddings(K)[0]
+             sage: a = f(2+3*i) * (2-zeta)^2
+             sage: a.descend_mod_power(Qi,2)
+-            [-3*i - 2, -2*i + 3]
++            [-2*i + 3, 3*i + 2]
+ 
+         An absolute example::
+ 
+@@ -5124,7 +5124,7 @@ cdef class NumberFieldElement_relative(NumberFieldElement):
+         EXAMPLES::
+ 
+             sage: K.<a, b, c> = NumberField([x^2 - 2, x^2 - 3, x^2 - 5])
+-            sage: P = K.prime_factors(5)[0]
++            sage: P = K.prime_factors(5)[1]
+             sage: (2*a + b - c).valuation(P)
+             1
+         """
+diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
+index 5f587556a4..33481fead0 100644
+--- a/src/sage/rings/number_field/number_field_ideal.py
++++ b/src/sage/rings/number_field/number_field_ideal.py
+@@ -3355,7 +3355,7 @@ def quotient_char_p(I, p):
+         []
+ 
+         sage: I = K.factor(13)[0][0]; I
+-        Fractional ideal (-3*i - 2)
++        Fractional ideal (-2*i + 3)
+         sage: I.residue_class_degree()
+         1
+         sage: quotient_char_p(I, 13)[0]
+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 bae36d4b9c..f64bd5b761 100644
+--- a/src/sage/rings/number_field/number_field_ideal_rel.py
++++ b/src/sage/rings/number_field/number_field_ideal_rel.py
+@@ -272,7 +272,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.gens_reduced()
+-            (2, 15*a*b + 3*a + 1)
++            (2, -15*a*b + 3*a + 1)
+         """
+         try:
+             # Compute the single generator, if it exists
+@@ -401,7 +401,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.relative_norm()
+-            Fractional ideal (-6*a + 2)
++            Fractional ideal (6*a + 2)
+         """
+         L = self.number_field()
+         K = L.base_field()
+@@ -518,7 +518,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.ideal_below()
+-            Fractional ideal (-6*a + 2)
++            Fractional ideal (6*a + 2)
+         """
+         L = self.number_field()
+         K = L.base_field()
+diff --git a/src/sage/rings/number_field/number_field_rel.py b/src/sage/rings/number_field/number_field_rel.py
+index d33980c4b1..50e846b205 100644
+--- a/src/sage/rings/number_field/number_field_rel.py
++++ b/src/sage/rings/number_field/number_field_rel.py
+@@ -213,14 +213,14 @@ class NumberField_relative(NumberField_generic):
+             sage: l.<b> = k.extension(5*x^2 + 3); l
+             Number Field in b with defining polynomial 5*x^2 + 3 over its base field
+             sage: l.pari_rnf()
+-            [x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4), ..., y^4 + 6*y^2 + 1, x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4)], [0, 0]]
++            [x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4), ..., y^4 + 6*y^2 + 1, x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4)], [0, 0]]
+             sage: b
+             b
+ 
+             sage: l.<b> = k.extension(x^2 + 3/5); l
+             Number Field in b with defining polynomial x^2 + 3/5 over its base field
+             sage: l.pari_rnf()
+-            [x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4), ..., y^4 + 6*y^2 + 1, x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4)], [0, 0]]
++            [x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4), ..., y^4 + 6*y^2 + 1, x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4)], [0, 0]]
+             sage: b
+             b
+ 
+diff --git a/src/sage/rings/number_field/order.py b/src/sage/rings/number_field/order.py
+index 6eca89ed8d..78ef4c3b33 100644
+--- a/src/sage/rings/number_field/order.py
++++ b/src/sage/rings/number_field/order.py
+@@ -520,7 +520,7 @@ class Order(IntegralDomain, sage.rings.abc.Order):
+             sage: k.<a> = NumberField(x^2 + 5077); G = k.class_group(); G
+             Class group of order 22 with structure C22 of Number Field in a with defining polynomial x^2 + 5077
+             sage: G.0 ^ -9
+-            Fractional ideal class (11, a + 7)
++            Fractional ideal class (43, a + 13)
+             sage: Ok = k.maximal_order(); Ok
+             Maximal Order in Number Field in a with defining polynomial x^2 + 5077
+             sage: Ok * (11, a + 7)
+diff --git a/src/sage/rings/number_field/selmer_group.py b/src/sage/rings/number_field/selmer_group.py
+index c534aaa9f6..6bc67565d2 100644
+--- a/src/sage/rings/number_field/selmer_group.py
++++ b/src/sage/rings/number_field/selmer_group.py
+@@ -491,7 +491,7 @@ def pSelmerGroup(K, S, p, proof=None, debug=False):
+ 
+         sage: [K.ideal(g).factor() for g in gens]
+         [(Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1)),
+-        Fractional ideal (-a),
++        Fractional ideal (a),
+         (Fractional ideal (2, a + 1))^2,
+         1]
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
+index bb5d8356be..8a7e5fa66f 100644
+--- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
++++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
+@@ -1791,7 +1791,7 @@ class PolynomialQuotientRing_generic(CommutativeRing):
+             sage: D.selmer_generators([K.ideal(2, -a+1), K.ideal(3, a+1)], 3)
+             [2, a + 1]
+             sage: D.selmer_generators([K.ideal(2, -a+1), K.ideal(3, a+1), K.ideal(a)], 3)
+-            [2, a + 1, a]
++            [2, a + 1, -a]
+ 
+         """
+         fields, isos, iso_classes = self._S_decomposition(tuple(S))
+diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py
+index 704b77ce5f..83ee4549e4 100644
+--- a/src/sage/rings/qqbar.py
++++ b/src/sage/rings/qqbar.py
+@@ -312,8 +312,8 @@ and we get a way to produce the number directly::
+     True
+     sage: sage_input(n)
+     R.<y> = QQ[]
+-    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(RR(0.51763809020504148), RR(0.51763809020504159)))
+-    -109*v^3 - 89*v^2 + 327*v + 178
++    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(-RR(1.9318516525781366), -RR(1.9318516525781364)))
++    -109*v^3 + 89*v^2 + 327*v - 178
+ 
+ We can also see that some computations (basically, those which are
+ easy to perform exactly) are performed directly, instead of storing
+@@ -362,7 +362,7 @@ algorithms in :trac:`10255`::
+     # Verified
+     R1.<x> = QQbar[]
+     R2.<y> = QQ[]
+-    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(RR(0.51763809020504148), RR(0.51763809020504159)))
++    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(-RR(1.9318516525781366), -RR(1.9318516525781364)))
+     AA.polynomial_root(AA.common_polynomial(x^4 + QQbar(v^3 - 3*v - 1)*x^3 + QQbar(-v^3 + 3*v - 3)*x^2 + QQbar(-3*v^3 + 9*v + 3)*x + QQbar(3*v^3 - 9*v)), RIF(RR(0.99999999999999989), RR(1.0000000000000002)))
+     sage: one
+     1
+@@ -2310,7 +2310,7 @@ def do_polred(poly, threshold=32):
+     cost = 2 * bitsize.nbits() + 5 * poly.degree().nbits()
+     if cost > threshold:
+         return parent.gen(), parent.gen(), poly
+-    new_poly, elt_back = poly.__pari__().polredbest(flag=1)
++    new_poly, elt_back = poly.numerator().__pari__().polredbest(flag=1)
+     elt_fwd = elt_back.modreverse()
+     return parent(elt_fwd.lift()), parent(elt_back.lift()), parent(new_poly)
+ 
+@@ -2542,10 +2542,10 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+            Defn: a |--> 1.414213562373095?)
+ 
+         sage: number_field_elements_from_algebraics((rt2,rt3))
+-        (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, [-a^3 + 3*a, -a^2 + 2], Ring morphism:
++        (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, [-a^3 + 3*a, a^2 - 2], Ring morphism:
+             From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+             To:   Algebraic Real Field
+-            Defn: a |--> 0.5176380902050415?)
++            Defn: a |--> -1.931851652578137?)
+ 
+     ``rt3a`` is a real number in ``QQbar``.  Ordinarily, we'd get a homomorphism
+     to ``AA`` (because all elements are real), but if we specify ``same_field=True``,
+@@ -2570,7 +2570,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, -a^3 + 3*a, Ring morphism:
+             From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+             To:   Algebraic Real Field
+-            Defn: a |--> 0.5176380902050415?)
++            Defn: a |--> -1.931851652578137?)
+ 
+     We can specify ``minimal=True`` if we want the smallest number field::
+ 
+@@ -2618,7 +2618,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         sage: nfI^2
+         -1
+         sage: sum = nfrt2 + nfrt3 + nfI + nfz3; sum
+-        2*a^6 + a^5 - a^4 - a^3 - 2*a^2 - a
++        a^5 + a^4 - a^3 + 2*a^2 - a - 1
+         sage: hom(sum)
+         2.646264369941973? + 1.866025403784439?*I
+         sage: hom(sum) == rt2 + rt3 + qqI + z3
+@@ -2658,7 +2658,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         sage: nf, nums, hom = number_field_elements_from_algebraics(elems, embedded=True)
+         sage: nf
+         Number Field in a with defining polynomial y^24 - 6*y^23 ...- 9*y^2 + 1
+-          with a = 0.2598678911433438? + 0.0572892247058457?*I
++          with a = 0.2598679? + 0.0572892?*I
+         sage: list(map(QQbar, nums)) == elems == list(map(hom, nums))
+         True
+ 
+@@ -2725,7 +2725,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+                          sqrt(2), AA.polynomial_root(x^3-3, RIF(0,3)), 11/9, 1]
+         sage: res = number_field_elements_from_algebraics(my_nums, embedded=True)
+         sage: res[0]
+-        Number Field in a with defining polynomial y^24 - 107010*y^22 - 24*y^21 + ... + 250678447193040618624307096815048024318853254384 with a = -95.5053039433554?
++        Number Field in a with defining polynomial y^24 - 107010*y^22 - 24*y^21 + ... + 250678447193040618624307096815048024318853254384 with a = 93.32530798172420?
+     """
+     gen = qq_generator
+ 
+@@ -3129,7 +3129,7 @@ class AlgebraicGenerator(SageObject):
+             sage: root = ANRoot(x^2 - x - 1, RIF(1, 2))
+             sage: gen = AlgebraicGenerator(nf, root)
+             sage: gen.pari_field()
+-             [y^2 - y - 1, [2, 0], ...]
++            [[y^2 - y - 1, [2, 0], ...]
+         """
+         if self.is_trivial():
+             raise ValueError("No PARI field attached to trivial generator")
+@@ -3213,7 +3213,7 @@ class AlgebraicGenerator(SageObject):
+             sage: qq_generator.union(gen3) is gen3
+             True
+             sage: gen2.union(gen3)
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+         """
+         if self._trivial:
+             return other
+@@ -3306,13 +3306,13 @@ class AlgebraicGenerator(SageObject):
+             Number Field in a with defining polynomial y^2 - 3 with a in 1.732050807568878?
+             sage: gen2_3 = gen2.union(gen3)
+             sage: gen2_3
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+             sage: qq_generator.super_poly(gen2) is None
+             True
+             sage: gen2.super_poly(gen2_3)
+             -a^3 + 3*a
+             sage: gen3.super_poly(gen2_3)
+-            -a^2 + 2
++            a^2 - 2
+ 
+         """
+         if checked is None:
+@@ -3360,13 +3360,13 @@ class AlgebraicGenerator(SageObject):
+             sage: sqrt3 = ANExtensionElement(gen3, nf3.gen())
+             sage: gen2_3 = gen2.union(gen3)
+             sage: gen2_3
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+             sage: gen2_3(sqrt2)
+             -a^3 + 3*a
+             sage: gen2_3(ANRational(1/7))
+             1/7
+             sage: gen2_3(sqrt3)
+-            -a^2 + 2
++            a^2 - 2
+         """
+         if self._trivial:
+             return elt._value
+@@ -4336,10 +4336,10 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: rt3 = AA(sqrt(3))
+             sage: rt3b = rt2 + rt3 - rt2
+             sage: rt3b.as_number_field_element()
+-            (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, -a^2 + 2, Ring morphism:
++            (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, a^2 - 2, Ring morphism:
+                 From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+                 To:   Algebraic Real Field
+-                Defn: a |--> 0.5176380902050415?)
++                Defn: a |--> -1.931851652578137?)
+             sage: rt3b.as_number_field_element(minimal=True)
+             (Number Field in a with defining polynomial y^2 - 3, a, Ring morphism:
+                From: Number Field in a with defining polynomial y^2 - 3
+@@ -4401,7 +4401,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: rt2b = rt3 + rt2 - rt3
+             sage: rt2b.exactify()
+             sage: rt2b._exact_value()
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b.simplify()
+             sage: rt2b._exact_value()
+             a where a^2 - 2 = 0 and a in 1.414213562373095?
+@@ -4422,7 +4422,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: QQbar(2)._exact_field()
+             Trivial generator
+             sage: (sqrt(QQbar(2)) + sqrt(QQbar(19)))._exact_field()
+-            Number Field in a with defining polynomial y^4 - 20*y^2 + 81 with a in 2.375100220297941?
++            Number Field in a with defining polynomial y^4 - 20*y^2 + 81 with a in -3.789313782671036?
+             sage: (QQbar(7)^(3/5))._exact_field()
+             Number Field in a with defining polynomial y^5 - 2*y^4 - 18*y^3 + 38*y^2 + 82*y - 181 with a in 2.554256611698490?
+         """
+@@ -4442,7 +4442,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: QQbar(2)._exact_value()
+             2
+             sage: (sqrt(QQbar(2)) + sqrt(QQbar(19)))._exact_value()
+-            -1/9*a^3 - a^2 + 11/9*a + 10 where a^4 - 20*a^2 + 81 = 0 and a in 2.375100220297941?
++            -1/9*a^3 + a^2 + 11/9*a - 10 where a^4 - 20*a^2 + 81 = 0 and a in -3.789313782671036?
+             sage: (QQbar(7)^(3/5))._exact_value()
+             2*a^4 + 2*a^3 - 34*a^2 - 17*a + 150 where a^5 - 2*a^4 - 18*a^3 + 38*a^2 + 82*a - 181 = 0 and a in 2.554256611698490?
+         """
+@@ -6857,7 +6857,7 @@ class AlgebraicPolynomialTracker(SageObject):
+             sage: p = sqrt(AA(2)) * x^2 - sqrt(AA(3))
+             sage: cp = AA.common_polynomial(p)
+             sage: cp.generator()
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 1.931851652578137?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -0.5176380902050415?
+         """
+         self.exactify()
+         return self._gen
+@@ -7706,7 +7706,7 @@ class ANExtensionElement(ANDescr):
+ 
+             sage: rt2b.exactify()
+             sage: rt2b._descr
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b._descr.is_simple()
+             False
+         """
+@@ -7791,7 +7791,7 @@ class ANExtensionElement(ANDescr):
+             sage: rt2b = rt3 + rt2 - rt3
+             sage: rt2b.exactify()
+             sage: rt2b._descr
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b._descr.simplify(rt2b)
+             a where a^2 - 2 = 0 and a in 1.414213562373095?
+         """
+@@ -7830,9 +7830,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.neg(a)
+-            1/3*a^3 - 2/3*a^2 + 4/3*a - 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -1/3*a^3 + 1/3*a^2 - a - 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+             sage: b.neg("ham spam and eggs")
+-            1/3*a^3 - 2/3*a^2 + 4/3*a - 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -1/3*a^3 + 1/3*a^2 - a - 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+         """
+         return ANExtensionElement(self._generator, -self._value)
+ 
+@@ -7848,9 +7848,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.invert(a)
+-            7/3*a^3 - 2/3*a^2 + 4/3*a - 12 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -7/3*a^3 + 19/3*a^2 - 7*a - 9 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+             sage: b.invert("ham spam and eggs")
+-            7/3*a^3 - 2/3*a^2 + 4/3*a - 12 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -7/3*a^3 + 19/3*a^2 - 7*a - 9 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+         """
+         return ANExtensionElement(self._generator, ~self._value)
+ 
+@@ -7866,9 +7866,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.conjugate(a)
+-            -1/3*a^3 + 2/3*a^2 - 4/3*a + 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? + 1.573132184970987?*I
++            1/3*a^3 - 1/3*a^2 + a + 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? - 1.573132184970987?*I
+             sage: b.conjugate("ham spam and eggs")
+-            -1/3*a^3 + 2/3*a^2 - 4/3*a + 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? + 1.573132184970987?*I
++            1/3*a^3 - 1/3*a^2 + a + 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? - 1.573132184970987?*I
+         """
+         if self._exactly_real:
+             return self
+@@ -8501,7 +8501,7 @@ def an_binop_expr(a, b, op):
+         sage: x = an_binop_expr(a, b, operator.add); x
+         <sage.rings.qqbar.ANBinaryExpr object at ...>
+         sage: x.exactify()
+-        -6/7*a^7 + 2/7*a^6 + 71/7*a^5 - 26/7*a^4 - 125/7*a^3 + 72/7*a^2 + 43/7*a - 47/7 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in 3.12580...?
++        6/7*a^7 - 2/7*a^6 - 71/7*a^5 + 26/7*a^4 + 125/7*a^3 - 72/7*a^2 - 43/7*a + 47/7 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in -0.3199179336182997?
+ 
+         sage: a = QQbar(sqrt(2)) + QQbar(sqrt(3))
+         sage: b = QQbar(sqrt(3)) + QQbar(sqrt(5))
+@@ -8510,7 +8510,7 @@ def an_binop_expr(a, b, op):
+         sage: x = an_binop_expr(a, b, operator.mul); x
+         <sage.rings.qqbar.ANBinaryExpr object at ...>
+         sage: x.exactify()
+-        2*a^7 - a^6 - 24*a^5 + 12*a^4 + 46*a^3 - 22*a^2 - 22*a + 9 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in 3.1258...?
++        2*a^7 - a^6 - 24*a^5 + 12*a^4 + 46*a^3 - 22*a^2 - 22*a + 9 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in -0.3199179336182997?
+     """
+     return ANBinaryExpr(a, b, op)
+ 
+diff --git a/src/sage/schemes/affine/affine_morphism.py b/src/sage/schemes/affine/affine_morphism.py
+index 1c4f2dff18..32c2e47e49 100644
+--- a/src/sage/schemes/affine/affine_morphism.py
++++ b/src/sage/schemes/affine/affine_morphism.py
+@@ -1148,9 +1148,9 @@ class SchemeMorphism_polynomial_affine_space_field(SchemeMorphism_polynomial_aff
+             sage: H = End(A)
+             sage: f = H([(QQbar(sqrt(2))*x^2 + 1/QQbar(sqrt(3))) / (5*x)])
+             sage: f.reduce_base_field()
+-            Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a = 1.931851652578137?
++            Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a = ...?
+               Defn: Defined on coordinates by sending (x) to
+-                    (((a^3 - 3*a)*x^2 + (1/3*a^2 - 2/3))/(5*x))
++                    (((a^3 - 3*a)*x^2 + (-1/3*a^2 + 2/3))/(5*x))
+ 
+         ::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_field.py b/src/sage/schemes/elliptic_curves/ell_field.py
+index 68b8375dae..48f358ea6a 100644
+--- a/src/sage/schemes/elliptic_curves/ell_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_field.py
+@@ -845,7 +845,7 @@ class EllipticCurve_field(ell_generic.EllipticCurve_generic, ProjectivePlaneCurv
+             sage: E = E.base_extend(G).quadratic_twist(c); E
+             Elliptic Curve defined by y^2 = x^3 + 5*a0*x^2 + (-200*a0^2)*x + (-42000*a0^2+42000*a0+126000) over Number Field in a0 with defining polynomial x^3 - 3*x^2 + 3*x + 9
+             sage: K.<b> = E.division_field(3, simplify_all=True); K
+-            Number Field in b with defining polynomial x^12 - 10*x^10 + 55*x^8 - 60*x^6 + 75*x^4 + 1350*x^2 + 2025
++            Number Field in b with defining polynomial x^12 + 5*x^10 + 40*x^8 + 315*x^6 + 750*x^4 + 675*x^2 + 2025
+ 
+         Some higher-degree examples::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_generic.py b/src/sage/schemes/elliptic_curves/ell_generic.py
+index 926ae310ea..3bae819fb0 100644
+--- a/src/sage/schemes/elliptic_curves/ell_generic.py
++++ b/src/sage/schemes/elliptic_curves/ell_generic.py
+@@ -3324,8 +3324,8 @@ 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),
++            [0, 0, 0, Mod(1, y^2 - 2),
++            Mod(y, y^2 - 2), 0, 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;
+diff --git a/src/sage/schemes/elliptic_curves/ell_number_field.py b/src/sage/schemes/elliptic_curves/ell_number_field.py
+index edbd196090..c44c803aa8 100644
+--- a/src/sage/schemes/elliptic_curves/ell_number_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_number_field.py
+@@ -218,7 +218,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: E == loads(dumps(E))
+             True
+             sage: E.simon_two_descent()
+-            (2, 2, [(0 : 0 : 1)])
++            (2, 2, [(0 : 0 : 1), (1/18*a + 7/18 : -5/54*a - 17/54 : 1)])
+             sage: E.simon_two_descent(lim1=5, lim3=5, limtriv=10, maxprob=7, limbigprime=10)
+             (2, 2, [(-1 : 0 : 1), (-2 : -1/2*a - 1/2 : 1)])
+ 
+@@ -274,7 +274,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: E.simon_two_descent()  # long time (4s on sage.math, 2013)
+             (3,
+              3,
+-             [(5/8*zeta43_0^2 + 17/8*zeta43_0 - 9/4 : -27/16*zeta43_0^2 - 103/16*zeta43_0 + 39/8 : 1),
++             [(1/8*zeta43_0^2 - 3/8*zeta43_0 - 1/4 : -5/16*zeta43_0^2 + 7/16*zeta43_0 + 1/8 : 1),
+               (0 : 0 : 1)])
+         """
+         verbose = int(verbose)
+@@ -865,7 +865,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             Conductor exponent: 1
+             Kodaira Symbol: I1
+             Tamagawa Number: 1,
+-            Local data at Fractional ideal (-3*i - 2):
++            Local data at Fractional ideal (-2*i + 3):
+             Reduction type: bad split multiplicative
+             Local minimal model: Elliptic Curve defined by y^2 + (i+1)*x*y + y = x^3 over Number Field in i with defining polynomial x^2 + 1
+             Minimal discriminant valuation: 2
+@@ -2645,12 +2645,12 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             [-92, -23, -23]
+ 
+             sage: C.matrix()  # long time
+-            [1 2 2 4 2 4]
+-            [2 1 2 2 4 4]
+-            [2 2 1 4 4 2]
+-            [4 2 4 1 3 3]
+-            [2 4 4 3 1 3]
+-            [4 4 2 3 3 1]
++            [1 2 2 4 4 2]
++            [2 1 2 4 2 4]
++            [2 2 1 2 4 4]
++            [4 4 2 1 3 3]
++            [4 2 4 3 1 3]
++            [2 4 4 3 3 1]
+ 
+         The graph of this isogeny class has a shape which does not
+         occur over `\QQ`: a triangular prism.  Note that for curves
+@@ -2677,12 +2677,12 @@ class EllipticCurve_number_field(EllipticCurve_field):
+ 
+             sage: G = C.graph()  # long time
+             sage: G.adjacency_matrix()  # long time
+-            [0 1 1 0 1 0]
+-            [1 0 1 1 0 0]
+-            [1 1 0 0 0 1]
+-            [0 1 0 0 1 1]
+-            [1 0 0 1 0 1]
+-            [0 0 1 1 1 0]
++            [0 1 1 0 0 1]
++            [1 0 1 0 1 0]
++            [1 1 0 1 0 0]
++            [0 0 1 0 1 1]
++            [0 1 0 1 0 1]
++            [1 0 0 1 1 0]
+ 
+         To display the graph without any edge labels::
+ 
+@@ -3316,7 +3316,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: points = [E.lift_x(x) for x in xi]
+             sage: newpoints, U = E.lll_reduce(points)  # long time (35s on sage.math, 2011)
+             sage: [P[0] for P in newpoints]            # long time
+-            [6823803569166584943, 5949539878899294213, 2005024558054813068, 5864879778877955778, 23955263915878682727/4, 5922188321411938518, 5286988283823825378, 175620639884534615751/25, -11451575907286171572, 3502708072571012181, 1500143935183238709184/225, 27180522378120223419/4, -5811874164190604461581/625, 26807786527159569093, 7404442636649562303, 475656155255883588, 265757454726766017891/49, 7272142121019825303, 50628679173833693415/4, 6951643522366348968, 6842515151518070703, 111593750389650846885/16, 2607467890531740394315/9, -1829928525835506297]
++            [6823803569166584943, 5949539878899294213, 2005024558054813068, 5864879778877955778, 23955263915878682727/4, 5922188321411938518, 5286988283823825378, 11465667352242779838, -11451575907286171572, 3502708072571012181, 1500143935183238709184/225, 27180522378120223419/4, -5811874164190604461581/625, 26807786527159569093, 7041412654828066743, 475656155255883588, 265757454726766017891/49, 7272142121019825303, 50628679173833693415/4, 6951643522366348968, 6842515151518070703, 111593750389650846885/16, 2607467890531740394315/9, -1829928525835506297]
+ 
+         An example to show the explicit use of the height pairing matrix::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_rational_field.py b/src/sage/schemes/elliptic_curves/ell_rational_field.py
+index 3808822812..a75290ea35 100644
+--- a/src/sage/schemes/elliptic_curves/ell_rational_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_rational_field.py
+@@ -1827,7 +1827,7 @@ class EllipticCurve_rational_field(EllipticCurve_number_field):
+             sage: E = EllipticCurve('389a1')
+             sage: E._known_points = []  # clear cached points
+             sage: E.simon_two_descent()
+-            (2, 2, [(1 : 0 : 1), (-11/9 : 28/27 : 1)])
++            (2, 2, [(5/4 : 5/8 : 1), (-3/4 : 7/8 : 1)])
+             sage: E = EllipticCurve('5077a1')
+             sage: E.simon_two_descent()
+             (3, 3, [(1 : 0 : 1), (2 : 0 : 1), (0 : 2 : 1)])
+diff --git a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
+index 81ad295160..d484a4a18b 100644
+--- a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
++++ b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
+@@ -780,12 +780,12 @@ def deg_one_primes_iter(K, principal_only=False):
+         [Fractional ideal (2, a + 1),
+          Fractional ideal (3, a + 1),
+          Fractional ideal (3, a + 2),
+-         Fractional ideal (-a),
++         Fractional ideal (a),
+          Fractional ideal (7, a + 3),
+          Fractional ideal (7, a + 4)]
+         sage: it = deg_one_primes_iter(K, True)
+         sage: [next(it) for _ in range(6)]
+-        [Fractional ideal (-a),
++        [Fractional ideal (a),
+          Fractional ideal (-2*a + 3),
+          Fractional ideal (2*a + 3),
+          Fractional ideal (a + 6),
+diff --git a/src/sage/schemes/elliptic_curves/gp_simon.py b/src/sage/schemes/elliptic_curves/gp_simon.py
+index 28b97f34af..9f7d1b6020 100644
+--- a/src/sage/schemes/elliptic_curves/gp_simon.py
++++ b/src/sage/schemes/elliptic_curves/gp_simon.py
+@@ -56,7 +56,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+         sage: import sage.schemes.elliptic_curves.gp_simon
+         sage: E=EllipticCurve('389a1')
+         sage: sage.schemes.elliptic_curves.gp_simon.simon_two_descent(E)
+-        (2, 2, [(1 : 0 : 1), (-11/9 : 28/27 : 1)])
++        (2, 2, [(5/4 : 5/8 : 1), (-3/4 : 7/8 : 1)])
+ 
+     TESTS::
+ 
+@@ -117,7 +117,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+     # The block below mimics the defaults in Simon's scripts, and needs to be changed
+     # when these are updated.
+     if K is QQ:
+-        cmd = 'ellrank(%s, %s);' % (list(E.ainvs()), [P.__pari__() for P in known_points])
++        cmd = 'ellQ_ellrank(%s, %s);' % (list(E.ainvs()), [P.__pari__() for P in known_points])
+         if lim1 is None:
+             lim1 = 5
+         if lim3 is None:
+@@ -144,7 +144,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+     if verbose > 0:
+         print(s)
+     v = gp.eval('ans')
+-    if v=='ans': # then the call to ellrank() or bnfellrank() failed
++    if v=='ans': # then the call to ellQ_ellrank() or bnfellrank() failed
+         raise RuntimeError("An error occurred while running Simon's 2-descent program")
+     if verbose >= 2:
+         print("v = %s" % v)
+diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
+index a936deb74f..dc19254d8c 100644
+--- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
++++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
+@@ -1208,14 +1208,14 @@ def isogenies_13_0(E, minimal_models=True):
+         sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]  # long time (4s)
+         [(0,
+           0,
+-          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
++          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 + 1887439/1146978983704320*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 + 1030632647/7965131831280*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 - 43618899433/204234149520*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 2535050171/1418292705,
+           -139861295/2650795873449984*a^11 - 3455957/5664093746688*a^10 - 345310571/50976843720192*a^9 - 500530795/118001953056*a^8 - 12860048113/265504394376*a^7 - 25007420461/44250732396*a^6 + 458134176455/1416023436672*a^5 + 16701880631/9077073312*a^4 + 155941666417/9077073312*a^3 + 3499310115/378211388*a^2 - 736774863/94552847*a - 21954102381/94552847,
+-          579363345221/13763747804451840*a^11 + 371192377511/860234237778240*a^10 + 8855090365657/1146978983704320*a^9 + 5367261541663/1633873196160*a^8 + 614883554332193/15930263662560*a^7 + 30485197378483/68078049840*a^6 - 131000897588387/2450809794240*a^5 - 203628705777949/306351224280*a^4 - 1587619388190379/204234149520*a^3 + 14435069706551/11346341640*a^2 + 7537273048614/472764235*a + 89198980034806/472764235),
++          8342795944891/198197968384106496*a^11 + 8908625263589/20645621706677760*a^10 + 53130542636623/6881873902225920*a^9 + 376780111042213/114697898370432*a^8 + 614884052146333/15930263662560*a^7 + 3566768133324359/7965131831280*a^6 - 1885593809102545/35291661037056*a^5 - 2443732172026523/3676214691360*a^4 - 9525729503937541/1225404897120*a^3 + 51990274442321/40846829904*a^2 + 67834019370596/4254878115*a + 267603083706812/1418292705),
+          (0,
+           0,
+-          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
++          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 + 1887439/1146978983704320*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 + 1030632647/7965131831280*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 - 43618899433/204234149520*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 2535050171/1418292705,
+           -6465569317/1325397936724992*a^11 - 112132307/1960647835392*a^10 - 17075412917/25488421860096*a^9 - 207832519229/531008788752*a^8 - 1218275067617/265504394376*a^7 - 9513766502551/177002929584*a^6 + 4297077855437/708011718336*a^5 + 354485975837/4538536656*a^4 + 4199379308059/4538536656*a^3 - 30841577919/189105694*a^2 - 181916484042/94552847*a - 2135779171614/94552847,
+-          -132601797212627/3440936951112960*a^11 - 6212467020502021/13763747804451840*a^10 - 1515926454902497/286744745926080*a^9 - 15154913741799637/4901619588480*a^8 - 576888119803859263/15930263662560*a^7 - 86626751639648671/204234149520*a^6 + 16436657569218427/306351224280*a^5 + 1540027900265659087/2450809794240*a^4 + 375782662805915809/51058537380*a^3 - 14831920924677883/11346341640*a^2 - 7237947774817724/472764235*a - 84773764066089509/472764235)]
++          -1316873026840277/34172063514501120*a^11 - 18637401045099413/41291243413355520*a^10 - 36382234917217247/6881873902225920*a^9 - 61142238484016213/19775499719040*a^8 - 576888119306045123/15930263662560*a^7 - 3378443313906256321/7965131831280*a^6 + 326466167429333279/6084769144320*a^5 + 4620083325391594991/7352429382720*a^4 + 9018783894167184149/1225404897120*a^3 - 9206015742300283/7042556880*a^2 - 65141531411426446/4254878115*a - 254321286054666133/1418292705)]
+     """
+     if E.j_invariant()!=0:
+         raise ValueError("j-invariant must be 0.")
diff --git a/srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch b/srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch
new file mode 100644
index 000000000000..762bb2612632
--- /dev/null
+++ b/srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch
@@ -0,0 +1,29 @@
+From f0365f30834b6890313790b3845c647d0160fa6a Mon Sep 17 00:00:00 2001
+From: Vincent Delecroix <20100.delecroix@gmail.com*>
+Date: Fri, 30 Sep 2022 16:31:08 +0200
+Subject: fix doctest if fqf_orthogonal
+
+---
+ src/sage/groups/fqf_orthogonal.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/sage/groups/fqf_orthogonal.py b/src/sage/groups/fqf_orthogonal.py
+index 75de408..7fc4dbe 100644
+--- a/src/sage/groups/fqf_orthogonal.py
++++ b/src/sage/groups/fqf_orthogonal.py
+@@ -245,10 +245,10 @@ class FqfOrthogonalGroup(AbelianGroupAutomorphismGroup_subgroup):
+             sage: all(x*f==x*fbar for x in q.gens())
+             True
+             sage: L = IntegralLattice("A2").twist(3)
+-            sage: q = L.discriminant_group()
+             sage: OL = L.orthogonal_group()
++            sage: assert OL(OL.0.matrix()) == OL.0
++            sage: q = L.discriminant_group()
+             sage: Oq = q.orthogonal_group()
+-            sage: assert Oq(OL.0) == Oq(OL.0.matrix())
+             sage: assert Oq(Oq.0.matrix()) == Oq.0
+         """
+         from sage.libs.gap.element import GapElement
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch b/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
deleted file mode 100644
index 4bd6f4f4e2dc..000000000000
--- a/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
+++ /dev/null
@@ -1,670 +0,0 @@
-As produced by `git diff 9.5 9.6.beta3 -- src/sage/libs/lrcalc`
-
-diff --git a/src/sage/libs/lrcalc/lrcalc.pxd b/src/sage/libs/lrcalc/lrcalc.pxd
-deleted file mode 100644
-index 10b88db93f2..00000000000
---- a/src/sage/libs/lrcalc/lrcalc.pxd
-+++ /dev/null
-@@ -1,77 +0,0 @@
--# distutils: libraries = lrcalc
--
--cdef extern from "lrcalc/hashtab.h":
--    ctypedef struct hashtab:
--        pass
--
--    ctypedef struct hash_itr:
--        pass
--
--    ctypedef unsigned long hashkey_t
--    ctypedef int (*cmp_t) (void* a, void* b)
--    ctypedef hashkey_t (*hash_t) (void* a)
--
--    hashtab* hash_new(cmp_t cm, hash_t hsh)
--    void hash_free(hashtab *ht)
--
--    void* hash_lookup(hashtab *ht, void *key)
--    void* hash_insert(hashtab *ht, void *key, void *value)
--
--    bint hash_good(hash_itr)
--    void hash_first(hashtab* s, hash_itr itr)
--    void hash_next(hash_itr itr)
--    void* hash_key(hash_itr itr)
--    void* hash_value(hash_itr itr)
--    int hash_intvalue(hash_itr itr)
--
--cdef extern from "lrcalc/vector.h":
--    ctypedef struct vector:
--        size_t length
--        int* array
--
--    vector* v_new(int length)
--    void v_free(vector* v)
--    void v_print(vector *v)
--    int v_length(vector* v)
--    int v_elem(vector* v, int i)
--
--    ctypedef struct vecpair:
--        vector *first
--        vector *second
--
--    vector* vp_first(vecpair* vp)
--    vector* vp_second(vecpair* vp)
--
--cdef extern from "lrcalc/list.h":
--    cdef struct _list:
--        void **array
--        size_t allocated
--        size_t length
--    void l_free(_list *lst)
--
--cdef extern from "lrcalc/symfcn.h":
--    long long lrcoef_c "lrcoef"(vector* outer, vector* inner1, vector* inner2)
--    hashtab* mult_c "mult"(vector *sh1, vector *sh2, int maxrows)
--    hashtab* skew_c "skew"(vector *outer, vector *inner, int maxrows)
--    hashtab* coprod_c "coprod"(vector *part, int all)
--    void fusion_reduce_c "fusion_reduce"(hashtab* ht, int rows, int cols, int opt_zero)
--    _list *quantum_reduce_c "quantum_reduce"(hashtab* ht, int rows, int col)
--
--    ctypedef struct skewtab:
--        vector *outer
--        vector *inner
--        vector *conts
--        int maxrows
--        vector *conjugate
--        int rows
--        int cols
--        int matrix[1]
--
--    skewtab *st_new(vector *outer, vector *inner, vector *conts, int maxrows)
--    int st_next(skewtab *st)
--    void st_print(skewtab *st)
--    void st_free(skewtab *st)
--
--
--cdef extern from "lrcalc/schublib.h":
--    hashtab* mult_schubert_c "mult_schubert"(vector *sh1, vector *sh2, int rank)
-diff --git a/src/sage/libs/lrcalc/lrcalc.pyx b/src/sage/libs/lrcalc/lrcalc.py
-similarity index 60%
-rename from src/sage/libs/lrcalc/lrcalc.pyx
-rename to src/sage/libs/lrcalc/lrcalc.py
-index b591081ec4c..b541bfacd89 100644
---- a/src/sage/libs/lrcalc/lrcalc.pyx
-+++ b/src/sage/libs/lrcalc/lrcalc.py
-@@ -10,7 +10,8 @@ fusion products. All of the above are achieved by counting LR
- appropriate shape and content by iterating through them.
- Additionally, ``lrcalc`` handles products of Schubert polynomials.
- 
--The web page of ``lrcalc`` is `<http://sites.math.rutgers.edu/~asbuch/lrcalc/>`_.
-+The web page of ``lrcalc`` is
-+`<http://sites.math.rutgers.edu/~asbuch/lrcalc/>`_.
- 
- The following describes the Sage interface to this library.
- 
-@@ -36,12 +37,13 @@ Schur expansion::
-      [4, 2]: 1}
- 
- Same product, but include only partitions with at most 3 rows.  This
--corresponds to computing in the representation ring of gl(3)::
-+corresponds to computing in the representation ring of `\mathfrak{gl}(3)`::
- 
-     sage: lrcalc.mult([2,1], [2,1], 3)
-     {[2, 2, 2]: 1, [3, 2, 1]: 2, [3, 3]: 1, [4, 1, 1]: 1, [4, 2]: 1}
- 
--We can also compute the fusion product, here for sl(3) and level 2::
-+We can also compute the fusion product, here for `\mathfrak{sl}(3)`
-+and level 2::
- 
-     sage: lrcalc.mult([3,2,1], [3,2,1], 3,2)
-     {[4, 4, 4]: 1, [5, 4, 3]: 1}
-@@ -77,42 +79,38 @@ Multiply two Schubert polynomials::
-      [6, 2, 1, 4, 3, 5]: 1}
- 
- Same product, but include only permutations of 5 elements in the result.
--This corresponds to computing in the cohomology ring of Fl(5)::
-+This corresponds to computing in the cohomology ring of `Fl(5)`::
- 
-     sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3], 5)
-     {[4, 5, 1, 3, 2]: 1, [5, 3, 1, 4, 2]: 1, [5, 4, 1, 2, 3]: 1}
- 
- List all Littlewood-Richardson tableaux of skew shape `\mu/\nu`; in
- this example `\mu=[3,2,1]` and `\nu=[2,1]`. Specifying a third entry
--`maxrows` restricts the alphabet to `\{1,2,\ldots,maxrows\}`::
-+`M' = ``maxrows`` restricts the alphabet to `\{1,2,\ldots,M\}`::
- 
-     sage: list(lrcalc.lrskew([3,2,1],[2,1]))
-     [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
-     [[None, None, 1], [None, 2], [1]], [[None, None, 1], [None, 2], [3]]]
- 
-     sage: list(lrcalc.lrskew([3,2,1],[2,1],maxrows=2))
--    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]], [[None, None, 1], [None, 2], [1]]]
-+    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
-+     [[None, None, 1], [None, 2], [1]]]
- 
- .. TODO::
- 
--    use this library in the :class:`SymmetricFunctions` code, to
-+    Use this library in the :class:`SymmetricFunctions` code, to
-     make it easy to apply it to linear combinations of Schur functions.
- 
- .. SEEALSO::
- 
-     - :func:`lrcoef`
--
-     - :func:`mult`
--
-     - :func:`coprod`
--
-     - :func:`skew`
--
-     - :func:`lrskew`
--
-     - :func:`mult_schubert`
- 
--.. rubric:: Underlying algorithmic in lrcalc
-+.. RUBRIC:: Underlying algorithmic in lrcalc
- 
- Here is some additional information regarding the main low-level
- C-functions in `lrcalc`. Given two partitions ``outer`` and ``inner``
-@@ -187,180 +185,24 @@ AUTHORS:
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from sage.rings.integer cimport Integer
--from sage.structure.parent cimport Parent
- from sage.combinat.partition import _Partitions
- from sage.combinat.permutation import Permutation
--from sage.combinat.skew_tableau import SkewTableau
--
--
--cdef vector* iterable_to_vector(it):
--    """
--    Return an lrcalc vector (which is a list of integers) from a Python iterable.
--
--    TESTS::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector(Partition([3,2,1])); x   #indirect doctest
--        [3, 2, 1]
--    """
--    cdef vector* v
--    cdef list itr = list(it)
--    cdef int n = len(itr)
--    cdef int i
--    v = v_new(n)
--    for i in range(n):
--        v.array[i] = int(itr[i])
--    return v
--
--
--cdef list vector_to_list(vector *v):
--    """
--    Converts a lrcalc vector to Python list.
--
--    TESTS::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector([]); x         #indirect doctest
--        []
--    """
--    cdef int i, n
--    n = v_length(v)
--    cdef list result = [None]*n
--    for i in range(n):
--        result[i] = Integer(v_elem(v, i))
--    return result
--
--
--def test_iterable_to_vector(it):
--    """
--    A wrapper function for the cdef function ``iterable_to_vector``
--    and ``vector_to_list``, to test that they are working correctly.
-+from sage.combinat.skew_tableau import SemistandardSkewTableaux
-+from sage.combinat.skew_partition import SkewPartition
-+from sage.rings.integer import Integer
-+import lrcalc
- 
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector([3,2,1]); x
--        [3, 2, 1]
--    """
--    cdef vector *v = iterable_to_vector(it)
--    result = vector_to_list(v)
--    v_free(v)
--    return result
--
--
--cdef skewtab_to_SkewTableau(skewtab *st):
--    """
--    A wrapper function which transforms the data set ``st`` used in
--    ``lrcalc`` to a ``SkewTableau`` in Sage.
-+def _lrcalc_dict_to_sage(result):
-+    r"""
-+    Translate from lrcalc output format to Sage expected format.
- 
-     TESTS::
- 
--        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
--        sage: test_skewtab_to_SkewTableau([],[])
--        []
--    """
--    inner = vector_to_list(st.inner)
--    outer = vector_to_list(st.outer)
--    return SkewTableau(expr=[[inner[y] for y in range(len(outer))],
--                             [[st.matrix[x + y * st.cols] + 1
--                                for x in range(inner[y], outer[y])]
--                              for y in range(len(outer) - 1, -1, -1)]])
--
--
--def test_skewtab_to_SkewTableau(outer, inner):
--    """
--    A wrapper function for the cdef function ``skewtab_to_SkewTableau``
--    for testing purposes.
--
--    It constructs the first LR skew tableau of shape ``outer/inner``
--    as an ``lrcalc`` ``skewtab``, and converts it to a
--    :class:`SkewTableau`.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
--        sage: test_skewtab_to_SkewTableau([3,2,1],[])
--        [[1, 1, 1], [2, 2], [3]]
--        sage: test_skewtab_to_SkewTableau([4,3,2,1],[1,1]).pp()
--        .  1  1  1
--        .  2  2
--        1  3
--        2
--    """
--    cdef vector* o = iterable_to_vector(outer)
--    cdef vector* i = iterable_to_vector(inner+[0]*(len(outer)-len(inner)))
--    cdef skewtab* st = st_new(o, i, NULL, 0)
--    return skewtab_to_SkewTableau(st)
--
--
--cdef dict sf_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary representing a Schur function. The keys are
--    partitions and the values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
-         sage: from sage.libs.lrcalc.lrcalc import mult
--        sage: sorted(mult([1],[1]).items())        #indirect doctest
--        [([1, 1], 1), ([2], 1)]
--        sage: assert isinstance(mult([1],[1]),dict)#indirect doctest
--    """
--    cdef hash_itr itr
--    cdef dict result = {}
--    cdef list p
--    hash_first(ht, itr)
--    while hash_good(itr):
--        p = vector_to_list(<vector*> hash_key(itr))
--        result[_Partitions(p)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
--
--cdef dict schubert_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary corresponding to a Schubert polynomial whose keys
--    are permutations and whose values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import mult_schubert
--        sage: mult_schubert([3,2,1], [1,2,3])      #indirect doctest
--        {[3, 2, 1]: 1}
--    """
--    cdef hash_itr itr
--    cdef dict result = {}
--    hash_first(ht, itr)
--    while hash_good(itr):
--        p = vector_to_list(<vector*> hash_key(itr))
--        result[Permutation(p)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
--
--cdef dict vp_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary corresponding to the coproduct of a Schur function whose keys are
--    pairs of partitions and whose values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import coprod
--        sage: coprod([1])      #indirect doctest
--        {([1], []): 1}
-+        sage: mult([2,1],[3,2,1],3) # indirect doctest
-+        {[3, 3, 3]: 1, [4, 3, 2]: 2, [4, 4, 1]: 1, [5, 2, 2]: 1, [5, 3, 1]: 1}
-     """
--    cdef hash_itr itr
--    cdef vecpair* vp
--    cdef dict result = {}
--    hash_first(ht, itr)
--    while hash_good(itr):
--        vp = <vecpair*> hash_key(itr)
--        p1 = _Partitions(vector_to_list(vp_first(vp)))
--        p2 = _Partitions(vector_to_list(vp_second(vp)))
--        result[(p1, p2)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
-+    return {_Partitions(la): Integer(k) for la, k in result.items()}
- 
- def lrcoef_unsafe(outer, inner1, inner2):
-     r"""
-@@ -371,13 +213,11 @@ def lrcoef_unsafe(outer, inner1, inner2):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
--
--    - ``inner1`` -- a partition.
-+    - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
-+    - ``inner1`` -- a partition
-+    - ``inner2`` -- a partition
- 
--    - ``inner2`` -- a partition.
--
--    .. warning::
-+    .. WARNING::
- 
-        This function does not do any check on its input.  If you want
-        to use a safer version, use :func:`lrcoef`.
-@@ -392,18 +232,7 @@ def lrcoef_unsafe(outer, inner1, inner2):
-         sage: lrcoef_unsafe([2,1,1,1,1], [2,1], [2,1])
-         0
-     """
--    cdef long long result
--    cdef vector *o
--    cdef vector *i1
--    cdef vector *i2
--    o = iterable_to_vector(outer)
--    i1 = iterable_to_vector(inner1)
--    i2 = iterable_to_vector(inner2)
--    result = lrcoef_c(o, i1, i2)
--    v_free(o)
--    v_free(i1)
--    v_free(i2)
--    return Integer(result)
-+    return Integer(lrcalc.lrcoef(outer, inner1, inner2))
- 
- 
- def lrcoef(outer, inner1, inner2):
-@@ -415,11 +244,9 @@ def lrcoef(outer, inner1, inner2):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
--
--    - ``inner1`` -- a partition.
--
--    - ``inner2`` -- a partition.
-+    - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
-+    - ``inner1`` -- a partition
-+    - ``inner2`` -- a partition
- 
-     .. NOTE::
- 
-@@ -436,7 +263,6 @@ def lrcoef(outer, inner1, inner2):
-         1
-         sage: lrcoef([2,1,1,1,1], [2,1], [2,1])
-         0
--
-     """
-     return lrcoef_unsafe(_Partitions(outer), _Partitions(inner1), _Partitions(inner2))
- 
-@@ -451,13 +277,9 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-     INPUT:
- 
-     - ``part1`` -- a partition
--
-     - ``part2`` -- a partition
--
-     - ``maxrows`` -- (optional) an integer
--
-     - ``level`` -- (optional) an integer
--
-     - ``quantum`` -- (optional) an element of a ring
- 
-     If ``maxrows`` is specified, then only partitions with at most
-@@ -479,7 +301,8 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-         sage: sorted(mult([2],[2]).items())
-         [([2, 2], 1), ([3, 1], 1), ([4], 1)]
-         sage: sorted(mult([2,1],[2,1]).items())
--        [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1), ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
-+        [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1),
-+         ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
-         sage: sorted(mult([2,1],[2,1],maxrows=2).items())
-         [([3, 3], 1), ([4, 2], 1)]
-         sage: mult([2,1],[3,2,1],3)
-@@ -510,44 +333,24 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-     if quantum is not None and (level is None or maxrows is None):
-         raise ValueError('missing parameters maxrows or level')
- 
--    cdef vector* v1 = iterable_to_vector(part1)
--    cdef vector* v2 = iterable_to_vector(part2)
--    if maxrows is None:
--        maxrows = 0
--    cdef hashtab* ht = mult_c(v1, v2, int(maxrows))
--    cdef hashtab* tab
--    cdef dict result
--
-     if quantum is None:
-         if level is not None:
--            fusion_reduce_c(ht, int(maxrows), int(level), int(0))
--        result = sf_hashtab_to_dict(ht)
--        v_free(v1)
--        v_free(v2)
--        hash_free(ht)
--        return result
-+            return _lrcalc_dict_to_sage(lrcalc.mult_fusion(part1, part2, maxrows, level))
-+        if maxrows is None:
-+            maxrows = -1
-+        return _lrcalc_dict_to_sage(lrcalc.mult(part1, part2, maxrows))
- 
-     # Otherwise do quantum multiplication
--    cdef _list *qlist
--    cdef dict temp
--    qlist = quantum_reduce_c(ht, int(maxrows), int(level))
--    # The above call frees the memory associated with ht
--    v_free(v1)
--    v_free(v2)
--
--    cdef Parent P = quantum.parent()
--    result = {}
--    for i in range(qlist.length):
--        tab = <hashtab*>(qlist.array[i])
--        temp = sf_hashtab_to_dict(tab)
--        for k in temp:
--            result[k] = result.get(k, P.zero()) + quantum**i * temp[k]
--        hash_free(tab)
--    l_free(qlist)
--    return result
--
--
--def skew(outer, inner, maxrows=0):
-+    result = lrcalc.mult_quantum(part1, part2, maxrows, level, degrees=True)
-+    P = quantum.parent()
-+    output = {}
-+    for i,k in result.items():
-+        la = _Partitions(i[0])
-+        output[la] = output.get(la, P.zero()) + k * quantum**(i[1])
-+    return output
-+
-+
-+def skew(outer, inner, maxrows=-1):
-     """
-     Compute the Schur expansion of a skew Schur function.
- 
-@@ -557,11 +360,9 @@ def skew(outer, inner, maxrows=0):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition.
--
--    - ``inner`` -- a partition.
--
--    - ``maxrows`` -- an integer or ``None``.
-+    - ``outer`` -- a partition
-+    - ``inner`` -- a partition
-+    - ``maxrows`` -- an integer or ``None``
- 
-     If ``maxrows`` is specified, then only partitions with at most
-     this number of rows are included in the result.
-@@ -572,14 +373,7 @@ def skew(outer, inner, maxrows=0):
-         sage: sorted(skew([2,1],[1]).items())
-         [([1, 1], 1), ([2], 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(outer)
--    cdef vector* v2 = iterable_to_vector(inner)
--    cdef hashtab* ht = skew_c(v1, v2, int(maxrows))
--    result = sf_hashtab_to_dict(ht)
--    v_free(v1)
--    v_free(v2)
--    hash_free(ht)
--    return result
-+    return _lrcalc_dict_to_sage(lrcalc.skew(outer, inner, maxrows))
- 
- 
- def coprod(part, all=0):
-@@ -592,9 +386,8 @@ def coprod(part, all=0):
- 
-     INPUT:
- 
--    - ``part`` -- a partition.
--
--    - ``all`` -- an integer.
-+    - ``part`` -- a partition
-+    - ``all`` -- an integer
- 
-     If ``all`` is non-zero then all terms are included in the result.
-     If ``all`` is zero, then only pairs of partitions ``(part1,
-@@ -609,12 +402,9 @@ def coprod(part, all=0):
-         sage: sorted(coprod([2,1]).items())
-         [(([1, 1], [1]), 1), (([2], [1]), 1), (([2, 1], []), 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(part)
--    cdef hashtab* ht = coprod_c(v1, int(all))
--    result = vp_hashtab_to_dict(ht)
--    v_free(v1)
--    hash_free(ht)
--    return result
-+    result = lrcalc.coprod(part, all)
-+    return {tuple([_Partitions(mu) for mu in la]): Integer(k)
-+            for la, k in result.items()}
- 
- 
- def mult_schubert(w1, w2, rank=0):
-@@ -627,11 +417,9 @@ def mult_schubert(w1, w2, rank=0):
- 
-     INPUT:
- 
--    - ``w1`` -- a permutation.
--
--    - ``w2`` -- a permutation.
--
--    - ``rank`` -- an integer.
-+    - ``w1`` -- a permutation
-+    - ``w2`` -- a permutation
-+    - ``rank`` -- an integer
- 
-     If ``rank`` is non-zero, then only permutations from the symmetric
-     group `S(\mathrm{rank})` are included in the result.
-@@ -646,33 +434,24 @@ def mult_schubert(w1, w2, rank=0):
-          ([6, 4, 3, 1, 2, 5], 1), ([6, 5, 2, 1, 3, 4], 1),
-          ([7, 3, 4, 1, 2, 5, 6], 1), ([7, 4, 2, 1, 3, 5, 6], 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(w1)
--    cdef vector* v2 = iterable_to_vector(w2)
--    cdef hashtab* ht = mult_schubert_c(v1, v2, int(rank))
--    result = schubert_hashtab_to_dict(ht)
--    v_free(v1)
--    v_free(v2)
--    hash_free(ht)
--    return result
-+    result = lrcalc.schubmult(w1, w2, rank)
-+    return {Permutation(list(la)):Integer(k) for la,k in result.items()}
- 
- 
--def lrskew(outer, inner, weight=None, maxrows=0):
-+def lrskew(outer, inner, weight=None, maxrows=-1):
-     r"""
-     Iterate over the skew LR tableaux of shape ``outer / inner``.
- 
-     INPUT:
- 
-     - ``outer`` -- a partition
--
-     - ``inner`` -- a partition
--
-     - ``weight`` -- a partition (optional)
--
--    - ``maxrows`` -- an integer (optional)
-+    - ``maxrows`` -- a positive integer (optional)
- 
-     OUTPUT: an iterator of :class:`SkewTableau`
- 
--    Specifying ``maxrows`` restricts the alphabet to `\{1,2,\ldots,maxrows\}`.
-+    Specifying ``maxrows`` = `M` restricts the alphabet to `\{1,2,\ldots,M\}`.
- 
-     Specifying ``weight`` returns only those tableaux of given content/weight.
- 
-@@ -702,22 +481,40 @@ def lrskew(outer, inner, weight=None, maxrows=0):
- 
-         sage: list(lrskew([3,2,1],[2], weight=[3,1]))
-         [[[None, None, 1], [1, 1], [2]]]
-+
-+    TESTS::
-+
-+        sage: from sage.libs.lrcalc.lrcalc import lrskew
-+        sage: list(lrskew([3,2,1],[2], weight=[]))
-+        []
-+        sage: list(lrskew([3,2,1],[2], weight=[0]))
-+        []
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[]))
-+        [[[None, None, None], [None, None], [None]]]
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[0]))
-+        [[[None, None, None], [None, None], [None]]]
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[1]))
-+        []
-     """
--    cdef vector* o = iterable_to_vector(outer)
--    cdef vector* i = iterable_to_vector(inner + [0]*(len(outer) - len(inner)))
--    cdef skewtab* st = st_new(o, i, NULL, int(maxrows))
-+    iterator = lrcalc.lr_iterator(outer, inner, maxrows)
-+    shape = SkewPartition([outer, inner])
- 
-     if weight is None:
--        yield skewtab_to_SkewTableau(st)
--        while st_next(st):
--            yield skewtab_to_SkewTableau(st)
-+        ST = SemistandardSkewTableaux(shape)
-+        for data in iterator:
-+            yield ST.from_shape_and_word(shape, [i+1 for i in data])
-     else:
-         wt = _Partitions(weight)
--        r = skewtab_to_SkewTableau(st)
--        if r.weight() == wt:
--            yield r
--        while st_next(st):
--            r = skewtab_to_SkewTableau(st)
--            if r.weight() == wt:
--                yield r
--    st_free(st)
-+        ST = SemistandardSkewTableaux(shape, wt)
-+        m = len(wt)
-+        for data in iterator:
-+            w = [0] * m
-+            for j in data:
-+                if j >= m:
-+                    # We know they are not equal, so make the check below quick
-+                    w = None
-+                    break
-+                w[j] += 1
-+            if w == wt:
-+                yield ST.from_shape_and_word(shape, [i+1 for i in data])
-+
diff --git a/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch b/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
deleted file mode 100644
index 1e2e0ba90742..000000000000
--- a/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-As produced by `git diff a90a3146{^^,}`
-
-diff --git a/src/sage/repl/interface_magic.py b/src/sage/repl/interface_magic.py
-index 8a455b69b0e..a93e1c9e04c 100644
---- a/src/sage/repl/interface_magic.py
-+++ b/src/sage/repl/interface_magic.py
-@@ -260,7 +260,7 @@ class InterfaceMagic(object):
-             2
-             120
-             sage: shell.run_cell('%%gap foo\n1+1;\n')
--            ...File "<string>", line unknown
-+            ...File...<string>...
-             SyntaxError: Interface magics have no options, got "foo"
-             <BLANKLINE>
-             sage: shell.run_cell('%%gap?')
-diff --git a/src/sage/repl/interpreter.py b/src/sage/repl/interpreter.py
-index 7468afe52d7..06c47b7374a 100644
---- a/src/sage/repl/interpreter.py
-+++ b/src/sage/repl/interpreter.py
-@@ -78,9 +78,9 @@ Check that Cython source code appears in tracebacks::
-     dummy line
-     ...
-     ZeroDivisionError...Traceback (most recent call last)
--    <ipython-input-...> in <module>...
-+    ...in <module>...
-     ----> 1 Integer(1)/Integer(0)
--    .../sage/rings/integer.pyx in sage.rings.integer.Integer...div...
-+    .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
-     ...
-     -> ...                  raise ZeroDivisionError("rational division by zero")
-        ....:            x = <Rational> Rational.__new__(Rational)
-@@ -423,7 +423,7 @@ def SagePreparseTransformer(lines):
-         sage: from sage.repl.interpreter import get_test_shell
-         sage: shell = get_test_shell()
-         sage: shell.run_cell(bad_syntax)
--          File "<string>", line unknown
-+          File...<string>...
-         SyntaxError: Mismatched ']'
-         <BLANKLINE>
-         sage: shell.quit()
diff --git a/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch b/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
deleted file mode 100644
index 853813b0f5bd..000000000000
--- a/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Fix for ipython 8.1
-
---- a/src/sage/repl/interpreter.py
-+++ b/src/sage/repl/interpreter.py
-@@ -78,7 +78,7 @@ Check that Cython source code appears in tracebacks::
-     dummy line
-     ...
-     ZeroDivisionError...Traceback (most recent call last)
--    ...in <module>...
-+    ...
-     ----> 1 Integer(1)/Integer(0)
-     .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
-     ...
diff --git a/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch b/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
deleted file mode 100644
index b861af7ec982..000000000000
--- a/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
+++ /dev/null
@@ -1,126 +0,0 @@
-From 24cc94b1988a90f3bd22a2368ec30c086283af13 Mon Sep 17 00:00:00 2001
-From: Antonio Rojas <arojas@archlinux.org>
-Date: Sun, 16 Jan 2022 11:55:04 +0100
-Subject: Add abs tol to some arb tests
-
----
- src/sage/functions/error.py    |  2 +-
- src/sage/rings/complex_arb.pyx |  6 +++---
- src/sage/rings/real_arb.pyx    | 10 +++++-----
- 3 files changed, 9 insertions(+), 9 deletions(-)
-
-diff --git a/src/sage/functions/error.py b/src/sage/functions/error.py
-index f48d04f..06f0b24 100644
---- a/src/sage/functions/error.py
-+++ b/src/sage/functions/error.py
-@@ -267,7 +267,7 @@ class Function_erf(BuiltinFunction):
- 
-         Check that real ball evaluation is fixed :trac:`28061`::
- 
--            sage: RealBallField(128)(erf(5))
-+            sage: RealBallField(128)(erf(5)) # abs tol 1e-38
-             [0.99999999999846254020557196514981165651 +/- 7.33e-39]
-         """
-         R = parent or s_parent(x)
-diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
-index f986970..93ff565 100644
---- a/src/sage/rings/complex_arb.pyx
-+++ b/src/sage/rings/complex_arb.pyx
-@@ -3974,8 +3974,8 @@ cdef class ComplexBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: CBF(20).erfc()
--            [5.39586561160790e-176 +/- ...e-191]
-+            sage: CBF(20).erfc() # abs tol 1e-190
-+            [5.39586561160790e-176 +/- 6.73e-191]
-             sage: CBF(100, 100).erfc()
-             [0.00065234366376858 +/- ...e-18] + [-0.00393572636292141 +/- ...e-18]*I
-         """
-@@ -4280,7 +4280,7 @@ cdef class ComplexBall(RingElement):
- 
-         TESTS:
- 
--            sage: CBF(Shi(I))
-+            sage: CBF(Shi(I)) # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]*I
-         """
-         cdef ComplexBall result = self._new()
-diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
-index 4a81784..292bfea 100644
---- a/src/sage/rings/real_arb.pyx
-+++ b/src/sage/rings/real_arb.pyx
-@@ -3506,7 +3506,7 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1/2).erf()
-+            sage: RBF(1/2).erf() # abs tol 1e-16
-             [0.520499877813047 +/- 6.10e-16]
-         """
-         cdef RealBall res = self._new()
-@@ -3556,12 +3556,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Si()
-+            sage: RBF(1).Si() # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]
- 
-         TESTS::
- 
--            sage: RBF(Si(1))
-+            sage: RBF(Si(1)) # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]
-         """
-         cdef RealBall res = self._new()
-@@ -3578,12 +3578,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Ci()  # abs tol 1e-16
-+            sage: RBF(1).Ci()  # abs tol 1e-15
-             [0.337403922900968 +/- 3.25e-16]
- 
-         TESTS::
- 
--            sage: RBF(Ci(1))  # abs tol 1e-16
-+            sage: RBF(Ci(1))  # abs tol 1e-15
-             [0.337403922900968 +/- 3.25e-16]
-         """
-         cdef RealBall res = self._new()
--- 
-cgit v1.0-1-gd88e
-
-
-From 53532ddd4e2dc92469c1590ebf0c40f8f69bf579 Mon Sep 17 00:00:00 2001
-From: Antonio Rojas <arojas@archlinux.org>
-Date: Sun, 16 Jan 2022 14:16:53 +0100
-Subject: Decrease abs tol
-
----
- src/sage/rings/real_arb.pyx | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
-index 292bfea..eb30f7f 100644
---- a/src/sage/rings/real_arb.pyx
-+++ b/src/sage/rings/real_arb.pyx
-@@ -3578,12 +3578,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Ci()  # abs tol 1e-15
-+            sage: RBF(1).Ci()  # abs tol 5e-16
-             [0.337403922900968 +/- 3.25e-16]
- 
-         TESTS::
- 
--            sage: RBF(Ci(1))  # abs tol 1e-15
-+            sage: RBF(Ci(1))  # abs tol 5e-16
-             [0.337403922900968 +/- 3.25e-16]
-         """
-         cdef RealBall res = self._new()
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch b/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
deleted file mode 100644
index d4e8f8be60e3..000000000000
--- a/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From 33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c Mon Sep 17 00:00:00 2001
-From: Michael Orlitzky <michael@orlitzky.com>
-Date: Mon, 24 Jan 2022 09:03:29 -0500
-Subject: Trac #33226: update doctests for giac-1.7.0.45.
-
-We have two failing doctests with giac-1.7.0.45: one is a trivial
-tolerance issue, but the other is a symbolic integration result for
-which giac is no longer willing to return a symbolic answer. We add
-"abs tol" to the numeric test, and drop the symbolic one entirely.
----
- src/sage/functions/min_max.py | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/src/sage/functions/min_max.py b/src/sage/functions/min_max.py
-index fc18373..9b7d6d9 100644
---- a/src/sage/functions/min_max.py
-+++ b/src/sage/functions/min_max.py
-@@ -228,15 +228,15 @@ class MaxSymbolic(MinMax_base):
-             ...
-             TypeError: cannot evaluate symbolic expression numerically
- 
--        ::
-+        We can usually integrate these expressions, but can't
-+        guarantee a symbolic answer in closed form::
- 
-             sage: f = max_symbolic(sin(x), cos(x))
-             sage: r = integral(f, x, 0, 1)
-             ...
--            sage: r
--            sqrt(2) - cos(1)
--            sage: r.n()
-+            sage: r.n()  # abs tol 1e-8
-             0.873911256504955
-+
-         """
-         return max_symbolic(args)
- 
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch b/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
deleted file mode 100644
index 19b69700a4f6..000000000000
--- a/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-commit 9c8235e44ffb509efa8a3ca6cdb55154e2b5066d
-Author: Antonio Rojas <arojas@archlinux.org>
-Date:   Sun Feb 13 19:53:14 2022 +0100
-
-    Fix deprecation warning with scipy 1.8
-
-diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-index e9b60dae5ec..7932167b41d 100644
---- a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-@@ -356,7 +356,7 @@ Sage example in ./linsolve.tex, line 2230::
- 
- Sage example in ./linsolve.tex, line 2609::
- 
--  sage: from scipy.sparse.linalg.dsolve import *
-+  sage: from scipy.sparse.linalg import factorized
-   sage: from scipy.sparse import lil_matrix
-   sage: from numpy import array
-   sage: n = 200
diff --git a/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch b/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
new file mode 100644
index 000000000000..e052e306e7a1
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
@@ -0,0 +1,53 @@
+From 6330cee1a69229b2f5d8ac4a09a73d8152f5e14d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Mon, 28 Feb 2022 23:15:16 -0300
+Subject: trac 33360: avoid factoring in is_prime()
+
+In the added TEST, the ideal norm is product of two primes but factoring
+this product takes about half an hour, so factoring the ideal is slow.
+
+To fix the issue, we only factor the ideal if the norm is a prime power.
+---
+ src/sage/rings/number_field/number_field_ideal.py | 22 ++++++++++++++++++++++
+ 1 file changed, 22 insertions(+)
+
+diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
+index f785f22..10d1f88 100644
+--- a/src/sage/rings/number_field/number_field_ideal.py
++++ b/src/sage/rings/number_field/number_field_ideal.py
+@@ -995,10 +995,32 @@ class NumberFieldIdeal(Ideal_generic):
+             False
+             sage: K.ideal(17).is_prime()  # ramified
+             False
++
++        TESTS::
++
++        Check that we do not factor the norm of the ideal, this used
++        to take half an hour, see :trac:`33360`
++
++           sage: K.<a,b,c> = NumberField([x^2-2,x^2-3,x^2-5])
++           sage: t = (((-2611940*c + 1925290/7653)*b - 1537130/7653*c
++           ....:       + 10130950)*a + (1343014/7653*c - 8349770)*b
++           ....:       + 6477058*c - 2801449990/4002519)
++           sage: t.is_prime()
++           False
++
+         """
+         try:
+             return self._pari_prime is not None
+         except AttributeError:
++            K = self.number_field().pari_nf()
++            I = self.pari_hnf()
++            # This would be better, but it is broken in pari 2.13.3.
++            #   self._pari_prime = K.idealismaximal(I) or None
++            # Instead we factor I, but only if the norm is a prime power
++            n = K.idealnorm(I)
++            if n.denominator() > 1 or not n.isprimepower():
++                self._pari_prime = None
++                return False
+             F = self.factor()  # factorization with caching
+             if len(F) != 1 or F[0][1] != 1:
+                 self._pari_prime = None
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
deleted file mode 100644
index 9ba7ca5a6b7d..000000000000
--- a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
+++ /dev/null
@@ -1,99 +0,0 @@
-From 609dd9deaeaa6380ab2f0d50276d911233c00a04 Mon Sep 17 00:00:00 2001
-From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
-Date: Fri, 4 Mar 2022 16:07:09 -0800
-Subject: sage.manifolds: Update doctests for SymPy 1.10
-
----
- src/sage/manifolds/continuous_map.py              | 3 +--
- src/sage/manifolds/differentiable/diff_form.py    | 4 ++--
- src/sage/manifolds/differentiable/tensorfield.py  | 8 ++++----
- src/sage/manifolds/vector_bundle_fiber_element.py | 2 +-
- 4 files changed, 8 insertions(+), 9 deletions(-)
-
-diff --git a/src/sage/manifolds/continuous_map.py b/src/sage/manifolds/continuous_map.py
-index a6356e7..f6f9b6d 100644
---- a/src/sage/manifolds/continuous_map.py
-+++ b/src/sage/manifolds/continuous_map.py
-@@ -1357,8 +1357,7 @@ class ContinuousMap(Morphism):
-             sage: Phi.coord_functions(c_uv, c_xyz)
-             Coordinate functions (u*v, u/v, u + v) on the Chart (M, (u, v))
-             sage: Phi.coord_functions(c_UV, c_xyz)
--            Coordinate functions (-U**2/4 + V**2/4, -(U + V)/(U - V), V)
--             on the Chart (M, (U, V))
-+            Coordinate functions (-U**2/4 + V**2/4, (-U - V)/(U - V), V) on the Chart (M, (U, V))
-             sage: Phi.coord_functions(c_UV, c_XYZ)
-             Coordinate functions ((-U**3 + U**2*V + U*V**2 + 2*U*V + 6*U - V**3
-              - 2*V**2 + 6*V)/(2*(U - V)), (U**3/4 - U**2*V/4 - U*V**2/4 + U*V
-diff --git a/src/sage/manifolds/differentiable/diff_form.py b/src/sage/manifolds/differentiable/diff_form.py
-index 70dd8fb..0aa3469 100644
---- a/src/sage/manifolds/differentiable/diff_form.py
-+++ b/src/sage/manifolds/differentiable/diff_form.py
-@@ -266,7 +266,7 @@ class DiffForm(TensorField):
- 
-         sage: s = a.wedge(b)
-         sage: s.display(eU)
--        a∧b = -x*(2*x*y + 1) dx∧dy
-+        a∧b = x*(-2*x*y - 1) dx∧dy
-         sage: s.display(eV)
-         a∧b = (u**3/8 + u**2*v/8 - u*v**2/8 + u/4 - v**3/8 + v/4) du∧dv
- 
-@@ -275,7 +275,7 @@ class DiffForm(TensorField):
-         sage: f = M.scalar_field({c_xy: (x+y)^2, c_uv: u^2}, name='f')
-         sage: s = f*a
-         sage: s.display(eU)
--        f*a = -y*(x**2 + 2*x*y + y**2) dx + x*(x**2 + 2*x*y + y**2) dy
-+        f*a = y*(-x**2 - 2*x*y - y**2) dx + x*(x**2 + 2*x*y + y**2) dy
-         sage: s.display(eV)
-         f*a = u**2*v/2 du - u**3/2 dv
- 
-diff --git a/src/sage/manifolds/differentiable/tensorfield.py b/src/sage/manifolds/differentiable/tensorfield.py
-index 2775be9..6bc5c50 100644
---- a/src/sage/manifolds/differentiable/tensorfield.py
-+++ b/src/sage/manifolds/differentiable/tensorfield.py
-@@ -334,7 +334,7 @@ class TensorField(ModuleElementWithMutability):
-         sage: f.display()  # long time
-         t(a,b): S^2 → ℝ
-         on U: (x, y) ↦ -2*x*y - 3*x - y**2
--        on V: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+        on V: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
- 
-     The vectors can be defined only on subsets of `S^2`, the domain of the
-     result is then the common subset::
-@@ -343,12 +343,12 @@ class TensorField(ModuleElementWithMutability):
-         sage: s.display()  # long time
-         t(a,b): U → ℝ
-            (x, y) ↦ -2*x*y - 3*x - y**2
--        on W: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+        on W: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
-         sage: s = t(a.restrict(U), b.restrict(W))  # long time
-         sage: s.display()  # long time
-         t(a,b): W → ℝ
-            (x, y) ↦ -2*x*y - 3*x - y**2
--           (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+           (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
- 
-     The tensor itself can be defined only on some open subset of `S^2`,
-     yielding a result whose domain is this subset::
-@@ -356,7 +356,7 @@ class TensorField(ModuleElementWithMutability):
-         sage: s = t.restrict(V)(a,b)  # long time
-         sage: s.display()  # long time
-         t(a,b): V → ℝ
--           (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+           (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
-         on W: (x, y) ↦ -2*x*y - 3*x - y**2
- 
-     Tests regarding the multiplication by a scalar field::
-diff --git a/src/sage/manifolds/vector_bundle_fiber_element.py b/src/sage/manifolds/vector_bundle_fiber_element.py
-index 29ee81d..048275a 100644
---- a/src/sage/manifolds/vector_bundle_fiber_element.py
-+++ b/src/sage/manifolds/vector_bundle_fiber_element.py
-@@ -110,4 +110,4 @@ class VectorBundleFiberElement(FiniteRankFreeModuleElement):
-             desc += str(self._name) + " "
-         desc += "in the fiber of {} at {}".format(self._vbundle._name,
-                                                   self._point)
--        return desc
-\ No newline at end of file
-+        return desc
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
deleted file mode 100644
index f5ac180baa90..000000000000
--- a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From c49eff347454ac7f07e5918470b20e97b8f2357e Mon Sep 17 00:00:00 2001
-From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
-Date: Fri, 4 Mar 2022 15:14:43 -0800
-Subject: src/sage/calculus/calculus.py: Update laplace doctest for sympy 1.10
-
----
- src/sage/calculus/calculus.py | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/src/sage/calculus/calculus.py b/src/sage/calculus/calculus.py
-index 9c2f226..b335093 100644
---- a/src/sage/calculus/calculus.py
-+++ b/src/sage/calculus/calculus.py
-@@ -1639,9 +1639,9 @@ def laplace(ex, t, s, algorithm='maxima'):
-         sage: laplace(dirac_delta(t), t, s)
-         1
-         sage: F, a, cond = laplace(dirac_delta(t), t, s, algorithm='sympy')
--        sage: a, cond
--        (-oo, True)
--        sage: F       # random - sympy <1.9 includes undefined heaviside(0) in answer
-+        sage: a, cond  # random - sympy <1.10 gives (-oo, True)
-+        (0, True)
-+        sage: F        # random - sympy <1.9 includes undefined heaviside(0) in answer
-         1
-         sage: laplace(dirac_delta(t), t, s, algorithm='giac')
-         1
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch b/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
deleted file mode 100644
index 8e7bb64f5b01..000000000000
--- a/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From a04a0a0b14f67f4804e7113c3db41bbcf8a58296 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
-Date: Mon, 28 Mar 2022 20:39:59 -0300
-Subject: Trac #33585: fix doctest when dochtml is missing...
-
-...but sphinx is available in PYTHONPATH.
----
- src/sage/misc/sagedoc.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/sage/misc/sagedoc.py b/src/sage/misc/sagedoc.py
-index 4b3853f..08c4225 100644
---- a/src/sage/misc/sagedoc.py
-+++ b/src/sage/misc/sagedoc.py
-@@ -1401,7 +1401,7 @@ class _sage_doc:
-             "...**File:**...**Type:**...**Definition:** identity_matrix..."
-             sage: identity_matrix.__doc__ in browse_sage_doc(identity_matrix, 'rst')
-             True
--            sage: browse_sage_doc(identity_matrix, 'html', False)             # optional - sphinx
-+            sage: browse_sage_doc(identity_matrix, 'html', False)             # optional - sphinx sagemath_doc_html
-             '...div...File:...Type:...Definition:...identity_matrix...'
- 
-         In the 'text' version, double colons have been replaced with
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch b/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
new file mode 100644
index 000000000000..977a42400e59
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
@@ -0,0 +1,42 @@
+commit 5db5d4e56243c609f44afc1f21c112b026f9e1fe
+Author: Oscar Benjamin <oscar.j.benjamin@gmail.com>
+Date:   Mon Jul 11 21:24:01 2022 +0100
+
+    Update doctests for SymPy 1.11
+    
+    Doctests related to SymPy's rsolve function are updated in:
+    
+    src/sage/calculus/test_sympy.py
+    src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+    
+    The form of the output from SymPy has changed since
+    
+    https://github.com/sympy/sympy/pull/23567
+
+diff --git a/src/sage/calculus/test_sympy.py b/src/sage/calculus/test_sympy.py
+index 7cf7f3f6bfd..927e6ee4fb6 100644
+--- a/src/sage/calculus/test_sympy.py
++++ b/src/sage/calculus/test_sympy.py
+@@ -193,7 +193,7 @@ This was fixed in Sympy, see :trac:`14437`::
+     sage: u = Function('u')
+     sage: n = Symbol('n', integer=True)
+     sage: f = u(n+2) - u(n+1) + u(n)/4
+-    sage: 2**n * rsolve(f,u(n))
+-    C1*n + C0
++    sage: expand(2**n * rsolve(f,u(n)))
++    2*C1*n + C0
+ 
+ """
+diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+index 1062f4f7e8c..f53f813d793 100644
+--- a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
++++ b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+@@ -382,7 +382,7 @@ Sage example in ./recequadiff.tex, line 1798::
+   sage: from sympy import rsolve_hyper
+   sage: from sympy.abc import n
+   sage: rsolve_hyper([-2,1],2**(n+2),n)
+-  2**n*C0 + 2**(n + 2)*(C0 + n/2)
++  2**n*C0 + 2**(n + 1)*n
+ 
+ """
+ 
diff --git a/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch b/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch
new file mode 100644
index 000000000000..b544a3eef7dd
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch
@@ -0,0 +1,526 @@
+From aeff992d53a65a705dca5cd5216bcb97c218dce7 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:14:03 +0200
+Subject: Adapt to API changes in OpenOutputStream and CloseOutput
+
+---
+ src/sage/libs/gap/element.pyx      | 5 +++--
+ src/sage/libs/gap/gap_includes.pxd | 6 ++++--
+ 2 files changed, 7 insertions(+), 4 deletions(-)
+
+diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
+index be43c4c..e268116 100644
+--- a/src/sage/libs/gap/element.pyx
++++ b/src/sage/libs/gap/element.pyx
+@@ -130,6 +130,7 @@ cdef char *capture_stdout(Obj func, Obj obj):
+     """
+     cdef Obj s, stream, output_text_string
+     cdef UInt res
++    cdef TypOutputFile output
+     # The only way to get a string representation of an object that is truly
+     # consistent with how it would be represented at the GAP REPL is to call
+     # ViewObj on it.  Unfortunately, ViewObj *prints* to the output stream,
+@@ -145,12 +146,12 @@ cdef char *capture_stdout(Obj func, Obj obj):
+         output_text_string = GAP_ValueGlobalVariable("OutputTextString")
+         stream = CALL_2ARGS(output_text_string, s, GAP_True)
+ 
+-        if not OpenOutputStream(stream):
++        if not OpenOutputStream(&output, stream):
+             raise GAPError("failed to open output capture stream for "
+                            "representing GAP object")
+ 
+         CALL_1ARGS(func, obj)
+-        CloseOutput()
++        CloseOutput(&output)
+         return CSTR_STRING(s)
+     finally:
+         GAP_Leave()
+diff --git a/src/sage/libs/gap/gap_includes.pxd b/src/sage/libs/gap/gap_includes.pxd
+index 5a9ab48..34035fe 100644
+--- a/src/sage/libs/gap/gap_includes.pxd
++++ b/src/sage/libs/gap/gap_includes.pxd
+@@ -76,8 +76,10 @@ cdef extern from "gap/intobj.h" nogil:
+ 
+ 
+ cdef extern from "gap/io.h" nogil:
+-    UInt OpenOutputStream(Obj stream)
+-    UInt CloseOutput()
++    ctypedef struct TypOutputFile:
++        pass
++    UInt OpenOutputStream(TypOutputFile* output, Obj stream)
++    UInt CloseOutput(TypOutputFile* output)
+ 
+ 
+ cdef extern from "gap/libgap-api.h" nogil:
+-- 
+cgit v1.0-1-gd88e
+
+
+From c3367b4290981e5e93b7a30c48b02f1ae3770dc8 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:14:53 +0200
+Subject: Disable colored prompt as it breaks the pexpect interface
+
+---
+ src/sage/interfaces/gap.py | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/src/sage/interfaces/gap.py b/src/sage/interfaces/gap.py
+index c34fe53..569caa2 100644
+--- a/src/sage/interfaces/gap.py
++++ b/src/sage/interfaces/gap.py
+@@ -1512,6 +1512,8 @@ def gap_reset_workspace(max_workspace_size=None, verbose=False):
+     """
+     # Create new workspace with filename WORKSPACE
+     g = Gap(use_workspace_cache=False, max_workspace_size=None)
++    g.eval('ColorPrompt(false)')
++    g.eval('SetUserPreference("UseColorPrompt", false)')
+     g.eval('SetUserPreference("HistoryMaxLines", 30)')
+     from sage.tests.gap_packages import all_installed_packages
+     for pkg in all_installed_packages(gap=g):
+-- 
+cgit v1.0-1-gd88e
+
+
+From 3b63e998e4d6118fc86b13b940c8f3d3b8307a50 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:16:03 +0200
+Subject: Port NaturalHomomorphism uses
+
+---
+ src/sage/groups/abelian_gps/abelian_group_gap.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/sage/groups/abelian_gps/abelian_group_gap.py b/src/sage/groups/abelian_gps/abelian_group_gap.py
+index a4b0471..86090b4 100644
+--- a/src/sage/groups/abelian_gps/abelian_group_gap.py
++++ b/src/sage/groups/abelian_gps/abelian_group_gap.py
+@@ -338,7 +338,7 @@ class AbelianGroup_gap(UniqueRepresentation, GroupMixinLibGAP, ParentLibGAP, Abe
+         if isinstance(x, AbelianGroupElement_gap):
+             try:
+                 if x in self._cover:
+-                    x = self.gap().NaturalHomomorphism().Image(x.gap())
++                    x = self._cover.gap().NaturalHomomorphismByNormalSubgroup(self._relations).Image(x.gap())
+                 else:
+                     x = x.gap()
+             except AttributeError:
+@@ -1043,7 +1043,7 @@ class AbelianGroupQuotient_gap(AbelianGroup_gap):
+             From: Abelian group with gap, generator orders (4,)
+             To:   Quotient abelian group with generator orders (2,)
+         """
+-        phi = self.gap().NaturalHomomorphism()
++        phi = self._cover.gap().NaturalHomomorphismByNormalSubgroup(self._relations)
+         Hom = self._cover.Hom(self)
+         return Hom(phi)
+ 
+-- 
+cgit v1.0-1-gd88e
+
+
+From bc40764be044653e06f2da3497e1e05da08251f7 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:17:36 +0200
+Subject: Fix tests with GAP 4.12
+
+---
+ src/doc/en/thematic_tutorials/lie/weyl_groups.rst  | 12 ++++++------
+ src/sage/coding/codecan/autgroup_can_label.pyx     |  2 +-
+ src/sage/coding/linear_code.py                     | 22 +++++++++++-----------
+ .../root_system/hecke_algebra_representation.py    |  2 +-
+ src/sage/combinat/symmetric_group_algebra.py       |  2 +-
+ src/sage/groups/finitely_presented.py              |  6 +++---
+ src/sage/groups/fqf_orthogonal.py                  |  2 +-
+ src/sage/groups/libgap_wrapper.pyx                 |  6 +++---
+ .../perm_gps/partn_ref2/refinement_generic.pyx     |  2 +-
+ src/sage/groups/perm_gps/permgroup.py              |  8 ++++----
+ src/sage/libs/gap/libgap.pyx                       |  2 +-
+ src/sage/libs/gap/util.pyx                         |  8 +-------
+ src/sage/tests/gap_packages.py                     |  2 +-
+ 13 files changed, 35 insertions(+), 41 deletions(-)
+
+diff --git a/src/doc/en/thematic_tutorials/lie/weyl_groups.rst b/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
+index c917338..182e74a 100644
+--- a/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
++++ b/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
+@@ -139,12 +139,12 @@ string, which you can print::
+     X.1      1  1  1  1  1  1  1  1  1  1  1  1  1
+     X.2      1 -1  1  1 -1  1  1 -1 -1 -1  1  1  1
+     X.3      2  .  2 -1  .  2  2  .  .  . -1  2  2
+-    X.4      3 -1 -1  .  1 -1  3 -1  1 -1  . -1  3
+-    X.5      3 -1 -1  .  1  3 -1 -1 -1  1  . -1  3
+-    X.6      3  1 -1  . -1 -1  3  1 -1  1  . -1  3
+-    X.7      3  1 -1  . -1  3 -1  1  1 -1  . -1  3
+-    X.8      3 -1  3  . -1 -1 -1 -1  1  1  . -1  3
+-    X.9      3  1  3  .  1 -1 -1  1 -1 -1  . -1  3
++    X.4      3 -1 -1  .  1  3 -1 -1 -1  1  . -1  3
++    X.5      3  1 -1  . -1  3 -1  1  1 -1  . -1  3
++    X.6      3 -1  3  . -1 -1 -1 -1  1  1  . -1  3
++    X.7      3 -1 -1  .  1 -1  3 -1  1 -1  . -1  3
++    X.8      3  1  3  .  1 -1 -1  1 -1 -1  . -1  3
++    X.9      3  1 -1  . -1 -1  3  1 -1  1  . -1  3
+     X.10     4 -2  . -1  .  .  .  2  .  .  1  . -4
+     X.11     4  2  . -1  .  .  . -2  .  .  1  . -4
+     X.12     6  . -2  .  . -2 -2  .  .  .  .  2  6
+diff --git a/src/sage/coding/codecan/autgroup_can_label.pyx b/src/sage/coding/codecan/autgroup_can_label.pyx
+index de5db98..c83b926 100644
+--- a/src/sage/coding/codecan/autgroup_can_label.pyx
++++ b/src/sage/coding/codecan/autgroup_can_label.pyx
+@@ -76,7 +76,7 @@ columns do share the same coloring::
+     ((1,),
+      (2,),
+      (3, 5, 4),
+-     (6, 19, 16, 9, 21, 10, 8, 15, 14, 11, 20, 13, 12, 7, 17, 18))
++     (6, 19, 16, 21, 9, 10, 15, 8, 20, 11, 14, 13, 7, 12, 18, 17))
+ 
+ We can also restrict the group action to linear isometries::
+ 
+diff --git a/src/sage/coding/linear_code.py b/src/sage/coding/linear_code.py
+index e8e32f8..9d45160 100644
+--- a/src/sage/coding/linear_code.py
++++ b/src/sage/coding/linear_code.py
+@@ -466,27 +466,27 @@ class AbstractLinearCode(AbstractLinearCodeNoMetric):
+             0
+             sage: C = codes.HammingCode(GF(4, 'z'), 3)
+             sage: C.automorphism_group_gens()
+-            ([((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
++            ([((1, 1, 1, z, z + 1, 1, 1, 1, 1, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z); (1,13,14,20)(2,21,8,18,7,16,19,15)(3,10,5,12,17,9,6,4), Ring endomorphism of Finite Field in z of size 2^2
++                Defn: z |--> z + 1),
++              ((z, 1, z, z, z, z + 1, z, z, z, z, z, z, z + 1, z, z, z, z, z + 1, z, z, z); (1,11,5,12,3,19)(2,8)(6,18,13)(7,17,15)(9,10,14,16,20,21), 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 + 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
++            ([((z, 1, z + 1, z + 1, 1, z + 1, z, 1, z + 1, z + 1, 1, z, 1, z + 1, z, 1, z, 1, z + 1, 1, 1); (1,12,11,10,6,8,9,20,13,21,5,14,3,16,17,19,7,4,2,15,18), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+-              ((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
++              ((z + 1, z + 1, z + 1, z, 1, 1, z, z, 1, z + 1, z, 1, 1, z, 1, z + 1, z, z + 1, z + 1, 1, z); (1,3,18,2,17,6,19)(4,15,13,20,7,14,16)(5,11,8,21,12,9,10), 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)],
+              181440)
+             sage: C.automorphism_group_gens(equivalence="permutational")
+-            ([((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,19)(3,17)(4,21)(5,20)(7,14)(9,12)(10,16)(11,15), Ring endomorphism of Finite Field in z of size 2^2
++            ([((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,11)(3,10)(4,9)(5,7)(12,21)(14,20)(15,19)(16,17), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+-              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,11)(3,10)(4,9)(5,7)(12,21)(14,20)(15,19)(16,17), Ring endomorphism of Finite Field in z of size 2^2
++              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (2,18)(3,19)(4,10)(5,16)(8,13)(9,14)(11,21)(15,20), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+-              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,17)(2,8)(3,14)(4,10)(7,12)(9,19)(13,18)(15,20), Ring endomorphism of Finite Field in z of size 2^2
++              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,19)(3,17)(4,21)(5,20)(7,14)(9,12)(10,16)(11,15), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+               ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (2,13)(3,14)(4,20)(5,11)(8,18)(9,19)(10,15)(16,21), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z)],
+@@ -692,10 +692,10 @@ class AbstractLinearCode(AbstractLinearCodeNoMetric):
+             sage: C_iso == aut_group_can_label.get_canonical_form()
+             True
+             sage: aut_group_can_label.get_autom_gens()
+-            [((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
++            [((1, 1, 1, z, z + 1, 1, 1, 1, 1, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z); (1,13,14,20)(2,21,8,18,7,16,19,15)(3,10,5,12,17,9,6,4), Ring endomorphism of Finite Field in z of size 2^2
++               Defn: z |--> z + 1),
++             ((z, 1, z, z, z, z + 1, z, z, z, z, z, z, z + 1, z, z, z, z, z + 1, z, z, z); (1,11,5,12,3,19)(2,8)(6,18,13)(7,17,15)(9,10,14,16,20,21), 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/root_system/hecke_algebra_representation.py b/src/sage/combinat/root_system/hecke_algebra_representation.py
+index bde2823..bffcc85 100644
+--- a/src/sage/combinat/root_system/hecke_algebra_representation.py
++++ b/src/sage/combinat/root_system/hecke_algebra_representation.py
+@@ -355,7 +355,7 @@ class HeckeAlgebraRepresentation(WithEqualityById, SageObject):
+             sage: q1, q2 = K.gens()
+             sage: KW = W.algebra(K)
+             sage: x = KW.an_element(); x
+-            123 + 3*32 + 2*3 + e
++            123 + 3*2312 + 2*31 + e
+ 
+             sage: T = KW.demazure_lusztig_operators(q1,q2)
+             sage: T12 = T.Tw( (1,2) )
+diff --git a/src/sage/combinat/symmetric_group_algebra.py b/src/sage/combinat/symmetric_group_algebra.py
+index c3d6755..da953d2 100644
+--- a/src/sage/combinat/symmetric_group_algebra.py
++++ b/src/sage/combinat/symmetric_group_algebra.py
+@@ -101,7 +101,7 @@ def SymmetricGroupAlgebra(R, W, category=None):
+         sage: SGA.group()
+         Weyl Group of type ['A', 3] (as a matrix group acting on the ambient space)
+         sage: SGA.an_element()
+-        s1*s2*s3 + 3*s3*s2 + 2*s3 + 1
++        s1*s2*s3 + 3*s2*s3*s1*s2 + 2*s3*s1 + 1
+ 
+     The preferred way to construct the symmetric group algebra is to
+     go through the usual ``algebra`` method::
+diff --git a/src/sage/groups/finitely_presented.py b/src/sage/groups/finitely_presented.py
+index 2a61bbf..d26891a 100644
+--- a/src/sage/groups/finitely_presented.py
++++ b/src/sage/groups/finitely_presented.py
+@@ -596,9 +596,9 @@ class RewritingSystem():
+             sage: k = G.rewriting_system()
+             sage: k.gap()
+             Knuth Bendix Rewriting System for Monoid( [ a, A, b, B ] ) with rules
+-            [ [ a^2, <identity ...> ], [ a*A, <identity ...> ],
+-              [ A*a, <identity ...> ], [ b^2, <identity ...> ],
+-              [ b*B, <identity ...> ], [ B*b, <identity ...> ] ]
++            [ [ a*A, <identity ...> ], [ A*a, <identity ...> ],
++              [ b*B, <identity ...> ], [ B*b, <identity ...> ],
++              [ a^2, <identity ...> ], [ b^2, <identity ...> ] ]
+         """
+         return self._gap
+ 
+diff --git a/src/sage/groups/fqf_orthogonal.py b/src/sage/groups/fqf_orthogonal.py
+index 75de408..dd7d84d 100644
+--- a/src/sage/groups/fqf_orthogonal.py
++++ b/src/sage/groups/fqf_orthogonal.py
+@@ -143,7 +143,7 @@ class FqfOrthogonalGroup(AbelianGroupAutomorphismGroup_subgroup):
+         [2/3   0   0]
+         [  0 2/3   0]
+         [  0   0 4/3]
+-        generated by 2 elements
++        generated by 3 elements
+         sage: q = matrix.diagonal(QQ, [3/2, 1/4, 1/4])
+         sage: T = TorsionQuadraticForm(q)
+         sage: T.orthogonal_group().order()
+diff --git a/src/sage/groups/libgap_wrapper.pyx b/src/sage/groups/libgap_wrapper.pyx
+index a76afc2..9340c0d 100644
+--- a/src/sage/groups/libgap_wrapper.pyx
++++ b/src/sage/groups/libgap_wrapper.pyx
+@@ -25,7 +25,7 @@ Note how we call the constructor of both superclasses to initialize
+ its output via LibGAP::
+ 
+     sage: FooGroup()
+-    <pc group of size 3 with 1 generators>
++    <pc group of size 3 with 1 generator>
+     sage: type(FooGroup().gap())
+     <class 'sage.libs.gap.element.GapElement'>
+ 
+@@ -106,7 +106,7 @@ class ParentLibGAP(SageObject):
+         ....:         ParentLibGAP.__init__(self, lg)
+         ....:         Group.__init__(self)
+         sage: FooGroup()
+-        <pc group of size 3 with 1 generators>
++        <pc group of size 3 with 1 generator>
+     """
+ 
+     def __init__(self, libgap_parent, ambient=None):
+@@ -461,7 +461,7 @@ cdef class ElementLibGAP(MultiplicativeGroupElement):
+         ....:         ParentLibGAP.__init__(self, lg)
+         ....:         Group.__init__(self)
+         sage: FooGroup()
+-        <pc group of size 3 with 1 generators>
++        <pc group of size 3 with 1 generator>
+         sage: FooGroup().gens()
+         (f1,)
+     """
+diff --git a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
+index 2fcb036..ca73c6b 100644
+--- a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
++++ b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
+@@ -427,7 +427,7 @@ cdef class LabelledBranching:
+             sage: from sage.groups.perm_gps.partn_ref2.refinement_generic import LabelledBranching
+             sage: L = LabelledBranching(3)
+             sage: L.small_generating_set()
+-            []
++            [()]
+             sage: L.add_gen(libgap.eval('(1,2,3)'))
+             sage: L.small_generating_set()
+             [(1,2,3)]
+diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
+index 4908934..34ba0cc 100644
+--- a/src/sage/groups/perm_gps/permgroup.py
++++ b/src/sage/groups/perm_gps/permgroup.py
+@@ -913,7 +913,7 @@ class PermutationGroup_generic(FiniteGroup):
+            sage: f = PG._coerce_map_from_(MG)
+            sage: mg = MG.an_element()
+            sage: p = f(mg); p
+-           (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)
++           (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(p._gap_()) == p
+            True
+ 
+@@ -959,12 +959,12 @@ class PermutationGroup_generic(FiniteGroup):
+             sage: P = G.as_permutation_group(algorithm='smaller', seed=5)
+             sage: P1 = G.as_permutation_group()
+             sage: P == P1
+-            False
++            True
+             sage: g1, g2, g3 = G.gens()
+             sage: P(g1*g2)
+-            (1,3,7,12)(2,4,8,10)(5,11)(6,9)
++            (1,4,13,11)(2,5,14,18)(3,15,8,16)(6,7)(9,20,19,12)(10,17)
+             sage: P1(g1*g2)
+-            (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)
++            (1,4,13,11)(2,5,14,18)(3,15,8,16)(6,7)(9,20,19,12)(10,17)
+ 
+         Another check for :trac:`5583`::
+ 
+diff --git a/src/sage/libs/gap/libgap.pyx b/src/sage/libs/gap/libgap.pyx
+index b1a64e5..6a36613 100644
+--- a/src/sage/libs/gap/libgap.pyx
++++ b/src/sage/libs/gap/libgap.pyx
+@@ -695,7 +695,7 @@ class Gap(Parent):
+             sage: libgap.List
+             <Gap function "List">
+             sage: libgap.GlobalRandomSource
+-            <RandomSource in IsGlobalRandomSource>
++            <RandomSource in IsGAPRandomSource>
+         """
+         if name in dir(self.__class__):
+             return getattr(self.__class__, name)
+diff --git a/src/sage/libs/gap/util.pyx b/src/sage/libs/gap/util.pyx
+index 344ab88..6350987 100644
+--- a/src/sage/libs/gap/util.pyx
++++ b/src/sage/libs/gap/util.pyx
+@@ -362,15 +362,9 @@ cdef Obj gap_eval(str gap_string) except? NULL:
+         GAPError: Error, Variable: 'Complex' must have a value
+         Syntax error: ; expected in stream:1
+         Complex Field with 53 bits of precision;;
+-         ^^^^^^^^^^^^
++                ^^^^^
+         Error, Variable: 'with' must have a value
+-        Syntax error: ; expected in stream:1
+-        Complex Field with 53 bits of precision;;
+-         ^^^^^^^^^^^^^^^^^^^^
+         Error, Variable: 'bits' must have a value
+-        Syntax error: ; expected in stream:1
+-        Complex Field with 53 bits of precision;;
+-         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+         Error, Variable: 'precision' must have a value
+ 
+     Test that on a subsequent attempt we get the same message (no garbage was
+diff --git a/src/sage/tests/gap_packages.py b/src/sage/tests/gap_packages.py
+index 2e4518c..c302b16 100644
+--- a/src/sage/tests/gap_packages.py
++++ b/src/sage/tests/gap_packages.py
+@@ -103,7 +103,7 @@ def all_installed_packages(ignore_dot_gap=False, gap=None):
+ 
+         sage: from sage.tests.gap_packages import all_installed_packages
+         sage: all_installed_packages()
+-        (...'GAPDoc'...)
++        (...'gapdoc'...)
+         sage: all_installed_packages(ignore_dot_gap=True) == all_installed_packages(gap=gap, ignore_dot_gap=True)
+         True
+     """
+-- 
+cgit v1.0-1-gd88e
+
+
+From cbc902a79ff9ec01d4d4eb9a767a1c661fb5dda7 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Fri, 30 Sep 2022 19:17:42 +0200
+Subject: Adapt test to new is_transitive and is_primitive behavior
+
+---
+ src/sage/groups/perm_gps/permgroup.py | 22 ++++++++++++++++------
+ 1 file changed, 16 insertions(+), 6 deletions(-)
+
+diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
+index 34ba0cc..5832b98 100644
+--- a/src/sage/groups/perm_gps/permgroup.py
++++ b/src/sage/groups/perm_gps/permgroup.py
+@@ -4359,17 +4359,23 @@ class PermutationGroup_generic(FiniteGroup):
+ 
+         ::
+ 
+-            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)]]) #S_5 on [1..5]
+-            sage: G.is_transitive([1,4,5])
++            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)],[(6,7)]])
++            sage: G.is_transitive([1,2,3,4,5])
+             True
+-            sage: G.is_transitive([2..6])
++            sage: G.is_transitive([1..7])
+             False
+             sage: G.is_transitive(G.non_fixed_points())
+-            True
++            False
+             sage: H = PermutationGroup([[(1,2,3)],[(4,5,6)]])
+             sage: H.is_transitive(H.non_fixed_points())
+             False
+ 
++        If `G` does not act on the domain, it always returns ``False``::
++
++            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)]]) #S_5 on [1..5]
++            sage: G.is_transitive([1,4,5])
++            False
++
+         Note that this differs from the definition in GAP, where
+         ``IsTransitive`` returns whether the group is transitive on the
+         set of points moved by the group.
+@@ -4425,12 +4431,16 @@ class PermutationGroup_generic(FiniteGroup):
+             sage: G = PermutationGroup([[(1,2,3,4)],[(2,4)]])
+             sage: G.is_primitive([1..4])
+             False
+-            sage: G.is_primitive([1,2,3])
+-            True
+             sage: G = PermutationGroup([[(3,4,5,6)],[(3,4)]]) #S_4 on [3..6]
+             sage: G.is_primitive(G.non_fixed_points())
+             True
+ 
++        If `G` does not act on the domain, it always returns ``False``::
++
++            sage: G = PermutationGroup([[(1,2,3,4)],[(2,4)]])
++            sage: G.is_primitive([1,2,3])
++            False
++
+         """
+         #If the domain is not a subset of self.domain(), then the
+         #action isn't primitive.
+-- 
+cgit v1.0-1-gd88e
+
+
+From 80dd6b338236f170efca1fc3545df18ce8d8795c Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Fri, 30 Sep 2022 19:18:06 +0200
+Subject: Mark test as random. With gap 4.12 on x86_64 it is no longer 2
+
+---
+ src/sage/groups/perm_gps/permgroup.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
+index 5832b98..c1230a3 100644
+--- a/src/sage/groups/perm_gps/permgroup.py
++++ b/src/sage/groups/perm_gps/permgroup.py
+@@ -1287,7 +1287,7 @@ class PermutationGroup_generic(FiniteGroup):
+             sage: G.gens_small() # random
+             [('b','c'), ('a','c','b')] ## (on 64-bit Linux)
+             [('a','b'), ('a','c','b')] ## (on Solaris)
+-            sage: len(G.gens_small()) == 2
++            sage: len(G.gens_small()) == 2 # random
+             True
+         """
+         gens = self._libgap_().SmallGeneratingSet()
+-- 
+cgit v1.0-1-gd88e
+
+
+From a6c293d67cfcdf8fba7bc6aa7899e2086d42cc7e Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Fri, 30 Sep 2022 19:18:30 +0200
+Subject: Remove test that is now redundant, all seeds give the same answer
+
+---
+ src/sage/groups/matrix_gps/finitely_generated.py | 3 ---
+ 1 file changed, 3 deletions(-)
+
+diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
+index a6d3dc0..63956ad 100644
+--- a/src/sage/groups/matrix_gps/finitely_generated.py
++++ b/src/sage/groups/matrix_gps/finitely_generated.py
+@@ -563,9 +563,6 @@ class FinitelyGeneratedMatrixGroup_gap(MatrixGroup_gap):
+             21499084800
+             sage: P = G.as_permutation_group()
+             sage: Psmaller = G.as_permutation_group(algorithm="smaller", seed=6)
+-            sage: P == Psmaller  # see the note below
+-            True
+-            sage: Psmaller = G.as_permutation_group(algorithm="smaller")
+             sage: P == Psmaller
+             False
+             sage: P.cardinality()
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch b/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
new file mode 100644
index 000000000000..8fedcb78cf71
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
@@ -0,0 +1,19 @@
+commit 04971318f032caf8dc1c0de9489346d894409091
+Author: John H. Palmieri <jhpalmieri64@gmail.com>
+Date:   Wed Aug 31 14:22:26 2022 -0700
+
+    trac 34465: fix invalid escape sequence in functions/special.py
+
+diff --git a/src/sage/functions/special.py b/src/sage/functions/special.py
+index 02596e49620..901f02f9bee 100644
+--- a/src/sage/functions/special.py
++++ b/src/sage/functions/special.py
+@@ -849,7 +849,7 @@ class EllipticF(BuiltinFunction):
+     - :wikipedia:`Elliptic_integral#Incomplete_elliptic_integral_of_the_first_kind`
+     """
+     def __init__(self):
+-        """
++        r"""
+         EXAMPLES::
+ 
+             sage: loads(dumps(elliptic_f))
diff --git a/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch b/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch
deleted file mode 100644
index f3eb0aad2cca..000000000000
--- a/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch
+++ /dev/null
@@ -1,14 +0,0 @@
- - this is not a proper fix... should fix sage_getfile() instead
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -187,7 +187,8 @@ def loadable_module_extension():
-         True
-     """
-     # Return the full platform-specific extension module suffix
--    return import_machinery.EXTENSION_SUFFIXES[0]
-+    # PATCHED for void linux, we use the shortest extension (.so)
-+    return import_machinery.EXTENSION_SUFFIXES[-1]
- 
- 
- def isclassinstance(obj):
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 0d793262d572..8df50e4e13b6 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,7 +1,7 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=9.5
-revision=2
+version=9.7
+revision=1
 wrksrc=sage-$version
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
@@ -33,12 +33,9 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="http://sagemath.org/"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=8d70a3b26080802c5b2e33dda4c23795d494d8216a0c2ecfcd608ebab0e64ff6
+checksum=9f26f14aa322e3cf38a71835b12ac34b23026b467f74d54b064c5d025e76fbfd
 
 post_patch() {
-	# these are unused and nothing else uses ratpoints
-	rm sage/libs/ratpoints.{pyx,pxd}
-
 	# git tree needs bootstrapping
 	pushd $wrksrc/build/pkgs/sagelib
 	PATH=../../bin:$PATH BOOTSTRAP_QUIET=no ./bootstrap
@@ -65,6 +62,7 @@ do_configure() {
 
 pre_build() {
 	export PYTHONPATH=../sage-setup
+	export PYTHONDONTWRITEBYTECODE=yes
 	export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
 }
 
@@ -77,6 +75,7 @@ post_build() {
 
 pre_install() {
 	export PYTHONPATH=../sage-setup
+	export PYTHONDONTWRITEBYTECODE=yes
 	export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
 }
 
@@ -104,6 +103,7 @@ post_install() {
 do_check() {
 	_scripts=$(cd build/scripts* && pwd)
 	export PYTHONPATH=$(cd build/lib* && pwd)
+	export PYTHONDONTWRITEBYTECODE=yes
 
 	# get out of $build_wrksrc, otherwise python picks the wrong sage module
 	cd $(mktemp -dp build)

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PR PATCH] [Updated] DRAFT: sagemath update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (15 preceding siblings ...)
  2022-10-16  1:52 ` tornaria
@ 2022-10-17  4:51 ` tornaria
  2022-10-29  2:30 ` tornaria
                   ` (15 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: tornaria @ 2022-10-17  4:51 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1883 bytes --]

There is an updated pull request by tornaria against master on the void-packages repository

https://github.com/tornaria/void-packages sagemath-update
https://github.com/void-linux/void-packages/pull/39876

DRAFT: sagemath update to 9.7
This includes #39838, #39840, #39846, #39872, #39866, also update eclib-20220621.

For now I'm reverting python3-matplotlib to 3.5.3_1 since 3.6.0_1 gives a lot of problems (#39857 adds python3-contourpy which will solve some, but I think there are more issues).

I want to make sure everything works ok and the full testsuite passes as is. Then I'll just move matplotlib back to 3.6.0_1 and try to see if it's feasible to fix or workaround the issues (sagemath-the-distro is still on matplotlib 3.5.2 and I didn't find anything about the update to 3.6.0)

<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: currently running the testsuite in --long after the update of singular.

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/39876.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-sagemath-update-39876.patch --]
[-- Type: text/x-diff, Size: 252434 bytes --]

From 7207409500d5603f92f9022c1f32be5a52e810ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 19:14:02 -0300
Subject: [PATCH 01/15] flintlib: update to 2.9.0.

---
 common/shlibs             | 2 +-
 srcpkgs/flintlib/template | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 02780902e137..1e76b257070b 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4015,7 +4015,7 @@ libgtkdatabox.so.1 gtkdatabox3-1.0.0_1
 libxcvt.so.0 libxcvt-0.1.1_1
 libgf2x.so.3 gf2x-1.3.0_1
 libntl.so.44 ntl-11.5.1_1
-libflint.so.16 flintlib-2.8.0_1
+libflint.so.17 flintlib-2.9.0_1
 libarb.so.2 arb-2.20.0_1
 libec.so.8 eclib-20210625_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index 968dbcb525c2..27f202b4434c 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,6 +1,6 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.8.5
+version=2.9.0
 revision=1
 wrksrc="flint-${version}"
 build_style=configure
@@ -14,11 +14,10 @@ license="LGPL-2.1-or-later"
 homepage="https://flintlib.org"
 changelog="https://raw.githubusercontent.com/wbhart/flint2/trunk/NEWS"
 distfiles="https://flintlib.org/flint-${version}.tar.gz"
-checksum=5911fedff911100f15781f35e3a4fa934fe60e4aea02a8c10cc8918101c1eed8
+checksum=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
-build_options_default=""
 
 if [ -z "$CROSS_BUILD" ]; then
 	build_options_default+=" ntl"

From 4b5011279fa5b2e510573a162b66e42224334fe0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 19:16:18 -0300
Subject: [PATCH 02/15] arb: update to 2.23.0.

---
 srcpkgs/arb/template | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
index 52f11ef83c90..84a62c7ffdba 100644
--- a/srcpkgs/arb/template
+++ b/srcpkgs/arb/template
@@ -1,6 +1,6 @@
 # Template file for 'arb'
 pkgname=arb
-version=2.22.1
+version=2.23.0
 revision=1
 build_style=configure
 configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
@@ -11,9 +11,7 @@ license="LGPL-2.1-or-later"
 homepage="https://arblib.org"
 changelog="https://raw.githubusercontent.com/fredrik-johansson/arb/master/doc/source/history.rst"
 distfiles="https://github.com/fredrik-johansson/arb/archive/${version}.tar.gz"
-checksum=1ef85518eee04885e8a90196498bc75e4e2410621d4184f2bc01d46b7080a243
-
-CFLAGS="-D_GNU_SOURCE" # needed for cpu_set_t
+checksum=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
 
 arb-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"

From 4f9dfb93c17f0332486ed6b552c29b5b37798736 Mon Sep 17 00:00:00 2001
From: dkwo <nicolopiazzalunga@gmail.com>
Date: Mon, 10 Oct 2022 10:14:06 -0400
Subject: [PATCH 03/15] singular: update to 4.3.1p2 (fix gcc 12 build)

---
 common/shlibs             | 10 +++++-----
 srcpkgs/singular/template | 26 ++++++++++++++------------
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 1e76b257070b..054b8e86dee0 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4057,11 +4057,11 @@ libumfpack.so.5 SuiteSparse-5.10.1_1
 libecl.so.21.2 ecl-21.2.1_1
 libecm.so.1 ecm-7.0.4_3
 libcliquer.so.1 cliquer-1.22_1
-libSingular-4.3.0.so singular-4.3.0_1
-libfactory-4.3.0.so singular-4.3.0_1
-libpolys-4.3.0.so singular-4.3.0_1
-libomalloc-0.9.6.so singular-4.3.0_1
-libsingular_resources-4.3.0.so singular-4.3.0_1
+libSingular-4.3.1.so singular-4.3.1p2_1
+libfactory-4.3.1.so singular-4.3.1p2_1
+libpolys-4.3.1.so singular-4.3.1p2_1
+libomalloc-0.9.6.so singular-4.3.1p2_1
+libsingular_resources-4.3.1.so singular-4.3.1p2_1
 libbrial.so.3 brial-1.2.10_1
 libbrial_groebner.so.3 brial-1.2.10_1
 libm4ri-0.0.20200125.so m4ri-20200125_1
diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index f23659ef5d83..a30beef915d2 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,25 +1,27 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.0
+version=4.3.1p2
 revision=1
+_majver=${version%p*}
+wrksrc=singular-${_majver}
 build_style=gnu-configure
 configure_args="--with-readline=ncurses
-	--enable-gfanlib
-	--enable-Singular
-	--enable-factory
-	--disable-doc
-	--disable-polymake
-	--without-python
-	--with-libparse
-	ac_cv_lib_cddgmp_dd_free_global_constants=yes"
+ --enable-gfanlib
+ --enable-Singular
+ --enable-factory
+ --disable-doc
+ --disable-polymake
+ --without-python
+ --with-libparse
+ ac_cv_lib_cddgmp_dd_free_global_constants=yes"
 hostmakedepends="perl tar doxygen"
 makedepends="flintlib-devel cddlib-devel readline-devel graphviz"
 short_desc="Computer algebra system for polynomial computations"
-maintainer="dkwo <nicolopiazzalunga@gmail.com>"
+maintainer="dkwo <npiazza@disroot.org>"
 license="GPL-2.0-or-later"
 homepage="https://www.singular.uni-kl.de"
-distfiles="https://www.singular.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${version//./-}/singular-${version}.tar.gz"
-checksum=74f38288203720e3f280256f2f8deb94030dd032b4237d844652aff0faab36e7
+distfiles="https://www.singular.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${_majver//./-}/singular-${version}.tar.gz"
+checksum=95814bba0f0bd0290cd9799ec1d2ecc6f4c8a4e6429d9a02eb7f9c4e5649682a
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From 49dbdce8741b991fa9a17e9c31ee4a702eaa7221 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 19:59:20 -0300
Subject: [PATCH 04/15] pari: update to 2.15.0.

---
 common/shlibs                      |  3 +-
 srcpkgs/pari/patches/float32.patch | 48 ++++++++++++++++++++++++++++++
 srcpkgs/pari/template              | 12 ++++++--
 3 files changed, 58 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/pari/patches/float32.patch

diff --git a/common/shlibs b/common/shlibs
index 054b8e86dee0..2900edc46908 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4006,8 +4006,7 @@ libsimavrparts.so.1 simavr-1.6_2
 libsword-1.8.1.so libsword-1.8.1_6
 libgivaro.so.9 givaro-4.1.1_1
 liblinbox.so.0 linbox-1.6.3_1
-libpari-gmp.so.7 pari-2.13.0_1
-libpari-gmp-tls.so.7 pari-2.13.2_1
+libpari-gmp-tls.so.8 pari-2.15.0_1
 libtree-sitter.so.0 tree-sitter-0.19.0_1
 libplanarity.so.0 planarity-3.0.1.1_1
 libgap.so.0 gap-4.11.1_1
diff --git a/srcpkgs/pari/patches/float32.patch b/srcpkgs/pari/patches/float32.patch
new file mode 100644
index 000000000000..311dd6bf5a07
--- /dev/null
+++ b/srcpkgs/pari/patches/float32.patch
@@ -0,0 +1,48 @@
+Author: Gonzalo Tornaría <tornaria@cmat.edu.uy>
+Date:   Fri Oct 14 17:00:46 2022 -0300
+
+    Revert "x86 (32bit): force -mpc64 on compilers that supports it."
+    
+    This reverts commit ca61b6391cf95ac8af15669236e2ec5839d2ad91.
+
+
+This causes problems with floating point precision on i686:
+```
+$ cat exp40.c
+#include <math.h>
+#include <stdio.h>
+int main() {
+	volatile int a=40; /* do not optimize away the call to exp(a) */
+	printf("%f\n", exp(a));
+}
+$ cc -Wall exp40.c -lm && ./a.out
+235385266837020000.000000
+$ cc -Wall exp40.c -lm -mpc64 && ./a.out
+235385266837020448.000000
+```
+
+Note that when pari is built using -mpc64, just *linking* with -lpari
+causes the problem!!!
+```
+$ cc -Wall exp40.c -lm -lpari && ./a.out
+235385266837020448.000000
+```
+
+diff --git a/config/get_cc b/config/get_cc
+index 3cfaa88bb7..2d61d3871f 100644
+--- a/config/get_cc
++++ b/config/get_cc
+@@ -110,13 +110,6 @@ if test -n "$__gnuc__"; then
+   # Specific optimisations for some architectures
+   case "$arch" in
+     sparcv8*) cflags=-mv8;;
+-    i?86)
+-      cmd="$CC $CFLAGS $extraflag -mpc64 -fno-strict-aliasing -o $exe gnu.c"
+-      . log_cmd
+-      if test -s $exe; then
+-        cflags="-mpc64"
+-      fi
+-      . cleanup_exe;;
+   esac
+   # problems on some architectures
+   case "$osname" in
diff --git a/srcpkgs/pari/template b/srcpkgs/pari/template
index 8bac1e0343f8..811826a1ee14 100644
--- a/srcpkgs/pari/template
+++ b/srcpkgs/pari/template
@@ -1,6 +1,6 @@
 # Template file for 'pari'
 pkgname=pari
-version=2.13.4
+version=2.15.0
 revision=1
 build_style=configure
 build_helper=qemu
@@ -11,14 +11,15 @@ make_check_target=statest-all
 make_install_target="install install-lib-sta install-lib-dyn"
 hostmakedepends="perl texlive"
 makedepends="gmp-devel readline-devel $(vopt_if x11 libX11-devel)"
-checkdepends="pari-elldata-small pari-galdata pari-galpol-small pari-seadata-small"
+checkdepends="pari-elldata-small pari-galdata pari-galpol-small
+ pari-seadata-small pari-nflistdata"
 short_desc="Fast computations library in number theory"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="https://pari.math.u-bordeaux.fr"
 changelog="https://pari.math.u-bordeaux.fr/cgi-bin/gitweb.cgi?p=pari.git;a=blob_plain;f=CHANGES;hb=refs/heads/pari-${version%.*}"
 distfiles="https://pari.math.u-bordeaux.fr/pub/pari/unix/${pkgname}-${version}.tar.gz"
-checksum=bcde9eceae1592814381c1697cdb7063567b6504201b1be47bb58920f3bce185
+checksum=e474851e0d16d4e4f9a0d9612c746a2ae7c9a1ec185d04c440b1c74a85755685
 
 build_options="x11 pthreads"
 build_options_default="x11 pthreads"
@@ -27,6 +28,11 @@ desc_option_pthreads="Enable support for pthreads"
 # reduce speed losses due to pthreads
 CFLAGS="-flto -fno-semantic-interposition"
 
+case $XBPS_TARGET_MACHINE in
+	# avoid numerical noise caused by extended-precision of registers
+	i686*) CFLAGS+=" -ffloat-store" ;;
+esac
+
 post_patch() {
 	# sse2 is not available on all i686
 	# and it's available on all x86_64

From 719b656e3c72e07385e73e071f498addeac43566 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 20:33:23 -0300
Subject: [PATCH 05/15] gp2c: update to 0.0.13.

---
 srcpkgs/gp2c/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gp2c/template b/srcpkgs/gp2c/template
index f82cf95c2d90..9cf0f6fdce6e 100644
--- a/srcpkgs/gp2c/template
+++ b/srcpkgs/gp2c/template
@@ -1,6 +1,6 @@
 # Template file for 'gp2c'
 pkgname=gp2c
-version=0.0.12pl1
+version=0.0.13
 revision=1
 build_style=gnu-configure
 hostmakedepends="perl"
@@ -12,4 +12,4 @@ license="GPL-2.0-or-later"
 homepage="http://pari.math.u-bordeaux.fr/"
 changelog="http://pari.math.u-bordeaux.fr/cgi-bin/gitweb.cgi?p=gp2c.git;a=blob_plain;f=ChangeLog;hb=HEAD"
 distfiles="${homepage}pub/pari/GP2C/${pkgname}-${version}.tar.gz"
-checksum=79a8c46f7ad3331e4d8ae6af6b496c4742fd73a73b996b3ca7ead61452ca6e8d
+checksum=261374eca73ebd76c112a9593dca28b64812aa762561fda5a4b2c2cd79a69d36

From 64f0fa5154c726c4079298facea7a8ef5335d40a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Fri, 23 Sep 2022 16:42:40 -0300
Subject: [PATCH 06/15] eclib: update to 20221012.

---
 common/shlibs          | 2 +-
 srcpkgs/eclib/template | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 2900edc46908..2f9f022b57e7 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4016,7 +4016,7 @@ libgf2x.so.3 gf2x-1.3.0_1
 libntl.so.44 ntl-11.5.1_1
 libflint.so.17 flintlib-2.9.0_1
 libarb.so.2 arb-2.20.0_1
-libec.so.8 eclib-20210625_1
+libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
 liblrcalc.so.2 lrcalc-2.1_1
diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 694a39ed4068..31a3a01921fa 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
-version=20210625
-revision=2
+version=20221012
+revision=1
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 hostmakedepends="automake autoconf-archive libtool"
@@ -11,7 +11,7 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="https://github.com/JohnCremona/eclib"
 distfiles="https://github.com/JohnCremona/eclib/archive/refs/tags/${version}.tar.gz"
-checksum=00333fd36afd237c9e6e410c7ab98536ddcd7fdc430e6837fe293247b835c572
+checksum=bd6f0191876c1426ca57db851ce06ef79ea1755f01e81dd747358d1b76b5e932
 
 pre_configure() {
 	autoreconf -fi

From 912bd59019c198e45229efde19a89bd5308eaf9e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:20 -0300
Subject: [PATCH 07/15] giac: update to 1.9.0.21.

---
 .../giac/patches/giac-pari-2.15-test.patch    | 10 ++++++++++
 srcpkgs/giac/patches/giac-pari-2.15.patch     | 20 +++++++++++++++++++
 srcpkgs/giac/template                         |  4 ++--
 3 files changed, 32 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/giac/patches/giac-pari-2.15-test.patch
 create mode 100644 srcpkgs/giac/patches/giac-pari-2.15.patch

diff --git a/srcpkgs/giac/patches/giac-pari-2.15-test.patch b/srcpkgs/giac/patches/giac-pari-2.15-test.patch
new file mode 100644
index 000000000000..1f1929571a46
--- /dev/null
+++ b/srcpkgs/giac/patches/giac-pari-2.15-test.patch
@@ -0,0 +1,10 @@
+Fix a failing test due to thread stack overflow
+
+--- a/check/chk_fhan4	2018-03-13 15:27:11.000000000 -0300
++++ b/check/chk_fhan4	2022-10-14 18:51:12.604731890 -0300
+@@ -1,4 +1,5 @@
+ #! /bin/sh
+ unset LANG
++export PARI_SIZE=2048000
+ ../src/icas TP04-sol.cas > TP04.tst
+ diff TP04.tst TP04-sol.cas.out1
diff --git a/srcpkgs/giac/patches/giac-pari-2.15.patch b/srcpkgs/giac/patches/giac-pari-2.15.patch
new file mode 100644
index 000000000000..be409be38f53
--- /dev/null
+++ b/srcpkgs/giac/patches/giac-pari-2.15.patch
@@ -0,0 +1,20 @@
+ANYARG patch
+
+diff --git a/src/pari.cc b/src/pari.cc
+index 76ce8e1..50d08ab 100644
+--- a/src/pari.cc
++++ b/src/pari.cc
+@@ -40,6 +40,13 @@ using namespace std;
+ 
+ #ifdef HAVE_LIBPARI
+ 
++// Anyarg disappeared from PARI 2.15.0
++#ifdef __cplusplus
++#  define ANYARG ...
++#else
++#  define ANYARG
++#endif
++
+ #ifdef HAVE_PTHREAD_H
+ #include <pthread.h>
+ #endif
diff --git a/srcpkgs/giac/template b/srcpkgs/giac/template
index e892c8bf7506..31045e9128ee 100644
--- a/srcpkgs/giac/template
+++ b/srcpkgs/giac/template
@@ -1,6 +1,6 @@
 # Template file for 'giac'
 pkgname=giac
-version=1.9.0.7
+version=1.9.0.21
 revision=1
 wrksrc="giac-${version%.*}"
 build_style=gnu-configure
@@ -14,7 +14,7 @@ license="GPL-3.0-or-later"
 homepage="https://www-fourier.ujf-grenoble.fr/~parisse/giac.html"
 changelog="https://www-fourier.ujf-grenoble.fr/~parisse/install_en#new"
 distfiles="https://www-fourier.ujf-grenoble.fr/~parisse/debian/dists/stable/main/source/giac_${version%.*}-${version##*.}.tar.gz"
-checksum=72016988b7180e9b630ecabecc60969213e7b61418c2598c91acbaec139fd740
+checksum=120cd16f2e033817302d2a03a22bd413dc1d85df8b225ba4f76b93a7805b07fe
 
 # need more than 4*65536 stack, see try_parse() in gen.cc line 11812
 LDFLAGS="-Wl,-z,stack-size=2097152"

From ed7862591d1ff3a617b58ecbe2efdbb5343d508b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 12 Oct 2022 23:59:37 -0300
Subject: [PATCH 08/15] gap: update to 4.12.0.

---
 common/shlibs                          |  2 +-
 srcpkgs/gap/patches/c57a07a3.patch     | 23 +++++++++++++++++++++++
 srcpkgs/gap/patches/dce6fa96.patch     | 24 ++++++++++++++++++++++++
 srcpkgs/gap/patches/fix-atlasrep.patch | 11 +++++++++++
 srcpkgs/gap/template                   | 12 +++++-------
 5 files changed, 64 insertions(+), 8 deletions(-)
 create mode 100644 srcpkgs/gap/patches/c57a07a3.patch
 create mode 100644 srcpkgs/gap/patches/dce6fa96.patch
 create mode 100644 srcpkgs/gap/patches/fix-atlasrep.patch

diff --git a/common/shlibs b/common/shlibs
index 2f9f022b57e7..9630b60d4889 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4009,7 +4009,7 @@ liblinbox.so.0 linbox-1.6.3_1
 libpari-gmp-tls.so.8 pari-2.15.0_1
 libtree-sitter.so.0 tree-sitter-0.19.0_1
 libplanarity.so.0 planarity-3.0.1.1_1
-libgap.so.0 gap-4.11.1_1
+libgap.so.8 gap-4.12.0_1
 libgtkdatabox.so.1 gtkdatabox3-1.0.0_1
 libxcvt.so.0 libxcvt-0.1.1_1
 libgf2x.so.3 gf2x-1.3.0_1
diff --git a/srcpkgs/gap/patches/c57a07a3.patch b/srcpkgs/gap/patches/c57a07a3.patch
new file mode 100644
index 000000000000..27fd657666a6
--- /dev/null
+++ b/srcpkgs/gap/patches/c57a07a3.patch
@@ -0,0 +1,23 @@
+From c57a07a341e7bb713e74d60c259777b1a8645451 Mon Sep 17 00:00:00 2001
+From: Max Horn <max@quendi.de>
+Date: Fri, 7 Oct 2022 01:31:45 +0200
+Subject: [PATCH] Don't attempt to install the 'dev' manual...
+
+... as it is not contained in release tarballs!
+---
+ Makefile.rules | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile.rules b/Makefile.rules
+index d9dc2899df..de1dbc4823 100644
+--- a/Makefile.rules
++++ b/Makefile.rules
+@@ -597,7 +597,7 @@ install-doc:
+ 	# TODO: should this depend on the 'doc' target? but that target is phony
+ 	# and will re-run each time it is invoked, which is not really what we want.
+ 	$(INSTALL) -d -m 0755 $(DESTDIR)$(datarootdir)/gap/doc
+-	for book in ref tut hpc dev ; do \
++	for book in ref tut hpc ; do \
+ 		$(INSTALL) -d -m 0755 $(DESTDIR)$(datarootdir)/gap/doc/$$book ; \
+ 		for ext in css html js txt pdf six lab; do \
+ 			$(INSTALL) -m 0644  $(srcdir)/doc/$$book/*.$$ext $(DESTDIR)$(datarootdir)/gap/doc/$$book/ ; \
diff --git a/srcpkgs/gap/patches/dce6fa96.patch b/srcpkgs/gap/patches/dce6fa96.patch
new file mode 100644
index 000000000000..bc29c0eaaeb1
--- /dev/null
+++ b/srcpkgs/gap/patches/dce6fa96.patch
@@ -0,0 +1,24 @@
+From dce6fa9637a3c61c3a891cc809371eaa67a589c6 Mon Sep 17 00:00:00 2001
+From: Max Horn <max@quendi.de>
+Date: Sun, 2 Oct 2022 23:31:03 +0200
+Subject: [PATCH] kernel: if no GC is selected, default to GASMAN
+
+---
+ src/common.h | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/common.h b/src/common.h
+index e7c10b8d0b..95e6f3d609 100644
+--- a/src/common.h
++++ b/src/common.h
+@@ -35,6 +35,10 @@
+ // compiled with the wrong ABI
+ GAP_STATIC_ASSERT(sizeof(void *) == SIZEOF_VOID_P, "sizeof(void *) is wrong");
+ 
++// if no GC is selected explicitly, default to GASMAN
++#if !defined(USE_BOEHM_GC) && !defined(USE_JULIA_GC) && !defined(USE_GASMAN)
++#define USE_GASMAN 1
++#endif
+ 
+ // check for cygwin
+ #if defined(__CYGWIN__) || defined(__CYGWIN32__)
diff --git a/srcpkgs/gap/patches/fix-atlasrep.patch b/srcpkgs/gap/patches/fix-atlasrep.patch
new file mode 100644
index 000000000000..ccb9ae587d4b
--- /dev/null
+++ b/srcpkgs/gap/patches/fix-atlasrep.patch
@@ -0,0 +1,11 @@
+--- a/pkg/atlasrep/gap/access.gi.orig	2022-08-05 19:11:16.000000000 -0300
++++ b/pkg/atlasrep/gap/access.gi	2022-10-12 23:40:48.816642751 -0300
+@@ -3156,7 +3156,7 @@
+         uri:= url{ [ p .. Length( url ) ] };
+         body:= AtlasOfGroupRepresentationsTransferFile( domain, uri, fail,
+                                                         fail );
+-        if body = fail then
++        if body = false then
+           Info( InfoAtlasRep, 1,
+                 "AtlasOfGroupRepresentationsNotifyData:\n",
+                 "#I  cannot read '", url, "'" );
diff --git a/srcpkgs/gap/template b/srcpkgs/gap/template
index 7bc7d13ace20..88831e636c08 100644
--- a/srcpkgs/gap/template
+++ b/srcpkgs/gap/template
@@ -1,17 +1,17 @@
 # Template file for 'gap'
 pkgname=gap
-version=4.11.1
+version=4.12.0
 revision=1
 build_style=gnu-configure
-make_install_target="install-bin install-gaproot install-headers install-libgap"
 makedepends="gmp-devel zlib-devel readline-devel"
 checkdepends="perl"
 short_desc="Groups, Algorithms, Programming - computational discrete algebra"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="http://www.gap-system.org/"
+changelog="https://raw.githubusercontent.com/gap-system/gap/master/CHANGES.md"
 distfiles="https://github.com/gap-system/gap/releases/download/v${version}/gap-${version}.tar.gz"
-checksum=6635c5da7d82755f8339486b9cac33766f58712f297e8234fba40818902ea304
+checksum=6005d0c0316fe8803d84681f30be64eace83a9542f975f5cb3dedfadd4391849
 
 if [ "$XBPS_CHECK_PKGS" = full ]; then
 	# not sure about this -- takes about 25 minutes
@@ -21,10 +21,10 @@ fi
 _GAPROOT=/usr/share/gap/
 
 # minimal required packages
-_GAPPKGS="GAPDoc primgrp SmallGrp transgrp"
+_GAPPKGS="gapdoc primgrp smallgrp transgrp"
 
 # other expected packages
-_GAPPKGS+=" atlasrep autpgrp alnuth crisp ctbllib FactInt fga irredsol laguna
+_GAPPKGS+=" atlasrep autpgrp alnuth crisp ctbllib factint fga irredsol laguna
  polenta polycyclic resclasses sophus tomlib"
 
 post_install() {
@@ -33,8 +33,6 @@ post_install() {
 		[ -d pkg/$p ] || p="$p-*"
 		vcopy "pkg/$p" ${_GAPROOT}/pkg
 	done
-	# not handled by make install-headers
-	vcopy gen/config.h /usr/include/gap
 }
 
 gap-devel_package() {

From bc5240cb97a08c6a6f4e23a36e80c17bd8d5b58d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:19 -0300
Subject: [PATCH 09/15] lcalc: revbump for pari 2.15.0

---
 srcpkgs/lcalc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lcalc/template b/srcpkgs/lcalc/template
index 270078df9a54..3c6be5fcbc28 100644
--- a/srcpkgs/lcalc/template
+++ b/srcpkgs/lcalc/template
@@ -1,7 +1,7 @@
 # Template file for 'lcalc'
 pkgname=lcalc
 version=2.0.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--with-pari"
 hostmakedepends="automake libtool pkg-config gengetopt"

From 279b754fbd405c93c20520ffee1ce5d804bdf09c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:21 -0300
Subject: [PATCH 10/15] python3-cysignals: revbump for pari 2.15.0

---
 srcpkgs/python3-cysignals/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/python3-cysignals/template b/srcpkgs/python3-cysignals/template
index 4655eead2a9c..08d1010976ff 100644
--- a/srcpkgs/python3-cysignals/template
+++ b/srcpkgs/python3-cysignals/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-cysignals'
 pkgname=python3-cysignals
 version=1.11.2
-revision=1
+revision=2
 wrksrc="cysignals-${version}"
 build_style=python3-module
 hostmakedepends="python3-setuptools python3-Cython autoconf"

From b2d85fc27d22a326a87eeb2e6b5058db4f3c0942 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:58:16 -0300
Subject: [PATCH 11/15] python3-cypari2: revbump for pari 2.15.0

---
 srcpkgs/python3-cypari2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/python3-cypari2/template b/srcpkgs/python3-cypari2/template
index 9ded61101e8e..9db3070a087c 100644
--- a/srcpkgs/python3-cypari2/template
+++ b/srcpkgs/python3-cypari2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-cypari2'
 pkgname=python3-cypari2
 version=2.1.2
-revision=1
+revision=2
 wrksrc=cypari2-${version}
 build_style=python3-module
 hostmakedepends="python3-setuptools python3-Cython pari perl"

From fb78a5d9ddd4bef5f6af0f9253361f97dae914f4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 00:49:01 -0300
Subject: [PATCH 12/15] sagemath: update to 9.7.

---
 .../patches/01-dont_link_ratpoints.patch      |   10 -
 ...2-fix_get_shared_lib_path--see_29644.patch |   13 -
 .../patches/03-doctest_have_program.patch     |   20 -
 .../patches/04-doctest_sage_getfile.patch     |   22 -
 .../patches/05-fix_sage_getfile.patch         |   16 -
 .../sagemath/patches/07-ignore_warning.patch  |   15 -
 .../08-dont_run_pytest--see_31924.patch       |   27 -
 ...y_slow_doctest-polynomial_zmod_flint.patch |   14 -
 ...ry_slow_doctest-isogeny_small_degree.patch |  106 -
 ...fix_very_slow_doctest-function_field.patch |   97 -
 srcpkgs/sagemath/patches/matplotlib-3.6.patch |   72 +
 srcpkgs/sagemath/patches/python-3.11.patch    |   45 +
 .../sagemath/patches/sagemath-pari-2.15.patch | 1750 +++++++++++++++++
 .../patches/sagemath-pari-2.15b.patch         |   29 +
 .../trac-31355-upgrade_lrcalc_to_2.1.patch    |  670 -------
 .../trac-33170-fix_doctest_ipython_8.patch    |   40 -
 .../trac-33170b-fix_doctest_ipython_8.1.patch |   13 -
 ...2ddd4e2dc92469c1590ebf0c40f8f69bf579.patch |  126 --
 ...2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch |   40 -
 .../trac-33336-fix_doctest_scipy_1.8.patch    |   19 -
 ...cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch |   53 +
 ...d9deaeaa6380ab2f0d50276d911233c00a04.patch |   99 -
 ...ff347454ac7f07e5918470b20e97b8f2357e.patch |   29 -
 ...0a0b14f67f4804e7113c3db41bbcf8a58296.patch |   26 -
 ...d4e56243c609f44afc1f21c112b026f9e1fe.patch |   42 +
 ...75f90d3bfd36758cb0e9d1ccbcd72f32d496.patch |  526 +++++
 ...1318f032caf8dc1c0de9489346d894409091.patch |   19 +
 .../zzz-loadable_module_extension.patch       |   14 -
 srcpkgs/sagemath/template                     |   12 +-
 29 files changed, 2542 insertions(+), 1422 deletions(-)
 delete mode 100644 srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
 delete mode 100644 srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
 delete mode 100644 srcpkgs/sagemath/patches/03-doctest_have_program.patch
 delete mode 100644 srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
 delete mode 100644 srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
 delete mode 100644 srcpkgs/sagemath/patches/07-ignore_warning.patch
 delete mode 100644 srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
 delete mode 100644 srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
 delete mode 100644 srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
 delete mode 100644 srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
 create mode 100644 srcpkgs/sagemath/patches/matplotlib-3.6.patch
 create mode 100644 srcpkgs/sagemath/patches/python-3.11.patch
 create mode 100644 srcpkgs/sagemath/patches/sagemath-pari-2.15.patch
 create mode 100644 srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
 delete mode 100644 srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch

diff --git a/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch b/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
deleted file mode 100644
index e5c3f5776aa2..000000000000
--- a/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
+++ /dev/null
@@ -1,10 +0,0 @@
- - do not link ratpoints where it's not used
-
---- a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
-+++ b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
-@@ -1,5 +1,3 @@
--# distutils: libraries = ratpoints
--
- r"""
- Descent on elliptic curves over `\QQ` with a 2-isogeny
- """
diff --git a/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch b/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
deleted file mode 100644
index d3672b094c1c..000000000000
--- a/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
+++ /dev/null
@@ -1,13 +0,0 @@
- - fix _get_shared_lib_path() so we don't need to configure GAP_SO
-
---- a/src/sage/env.py
-+++ b/src/sage/env.py
-@@ -293,7 +293,7 @@ def _get_shared_lib_path(*libnames: str) -> Optional[str]:
-             if sys.platform == 'darwin':
-                 ext = 'dylib'
-             else:
--                ext = 'so'
-+                ext = 'so*'
- 
-             if SAGE_LOCAL:
-                 search_directories.append(Path(SAGE_LOCAL) / 'lib')
diff --git a/srcpkgs/sagemath/patches/03-doctest_have_program.patch b/srcpkgs/sagemath/patches/03-doctest_have_program.patch
deleted file mode 100644
index 27ba3776470c..000000000000
--- a/srcpkgs/sagemath/patches/03-doctest_have_program.patch
+++ /dev/null
@@ -1,20 +0,0 @@
- - we don't know `SAGE_VENV/bin` contains `sage`, but `sys.argv[0]` should
-   be the full path to `sage-ipython` and the same directory should have `sage`
-
---- a/src/sage/misc/sage_ostools.pyx
-+++ b/src/sage/misc/sage_ostools.pyx
-@@ -32,12 +32,11 @@ def have_program(program, path=None):
-         True
-         sage: have_program('there_is_not_a_program_with_this_name')
-         False
--        sage: from sage.env import SAGE_VENV
--        sage: have_program('sage', os.path.join(SAGE_VENV, 'bin'))
-+        sage: have_program('sage', os.path.dirname(sys.argv[0]))
-         True
-         sage: have_program('sage', '/there_is_not_a_path_with_this_name')
-         False
--        sage: have_program('there_is_not_a_program_with_this_name', os.path.join(SAGE_VENV, 'bin'))
-+        sage: have_program('there_is_not_a_program_with_this_name', "/bin")
-         False
-     """
-     if path is None:
diff --git a/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch b/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
deleted file mode 100644
index 95bce107f854..000000000000
--- a/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
+++ /dev/null
@@ -1,22 +0,0 @@
- - add one doctest for coverage
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -1341,10 +1342,12 @@ def sage_getfile(obj):
-     EXAMPLES::
- 
-         sage: from sage.misc.sageinspect import sage_getfile
--        sage: sage_getfile(sage.rings.rational)[-23:]
--        'sage/rings/rational.pyx'
--        sage: sage_getfile(Sq)[-42:]
--        'sage/algebras/steenrod/steenrod_algebra.py'
-+        sage: sage_getfile(sage.rings.rational)
-+        '...sage/rings/rational.pyx'
-+        sage: sage_getfile(Sq)
-+        '...sage/algebras/steenrod/steenrod_algebra.py'
-+        sage: sage_getfile(x)
-+        '...sage/symbolic/expression.pyx'
- 
-     The following tests against some bugs fixed in :trac:`9976`::
- 
-
diff --git a/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch b/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
deleted file mode 100644
index 56c58078f319..000000000000
--- a/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
+++ /dev/null
@@ -1,16 +0,0 @@
- - fix sage_getfile() by checking all possible EXTENSION_SUFFIXES
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -1400,8 +1403,9 @@ def sage_getfile(obj):
-         sourcefile = inspect.getabsfile(obj)
-     except TypeError: # this happens for Python builtins
-         return ''
--    if sourcefile.endswith(loadable_module_extension()):
--        return sourcefile[:-len(loadable_module_extension())]+os.path.extsep+'pyx'
-+    for suffix in import_machinery.EXTENSION_SUFFIXES:
-+        if sourcefile.endswith(suffix):
-+            return sourcefile[:-len(suffix)]+os.path.extsep+'pyx'
-     return sourcefile
- 
- 
diff --git a/srcpkgs/sagemath/patches/07-ignore_warning.patch b/srcpkgs/sagemath/patches/07-ignore_warning.patch
deleted file mode 100644
index 69668678a40b..000000000000
--- a/srcpkgs/sagemath/patches/07-ignore_warning.patch
+++ /dev/null
@@ -1,15 +0,0 @@
- - this ignores a warning caused by old notebook
-
---- a/src/sage/all.py
-+++ b/src/sage/all.py
-@@ -100,6 +100,9 @@ warnings.filterwarnings('ignore', category=DeprecationWarning,
-                         message='The distutils(.sysconfig module| package) is deprecated',
-                         module='Cython|distutils|numpy|sage.env|sage.features')
- 
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"invalid escape sequence '\\s'")
-+
- ################ end setup warnings ###############################
- 
- 
-
diff --git a/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch b/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
deleted file mode 100644
index 06bd2ccae6fb..000000000000
--- a/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
+++ /dev/null
@@ -1,27 +0,0 @@
- - using pytest is broken, see #31924
-
---- a/src/bin/sage-runtests
-+++ b/src/bin/sage-runtests
-@@ -154,21 +154,4 @@ if __name__ == "__main__":
-     DC = DocTestController(args, args.filenames)
-     err = DC.run()
- 
--    try:
--        exit_code_pytest = 0
--        import pytest
--        pytest_options = ["--import-mode", "importlib"]
--        if args.verbose:
--            pytest_options.append("-v")
--        exit_code_pytest = pytest.main(pytest_options + args.filenames)
--        if exit_code_pytest == 5:
--            # Exit code 5 means there were no test files, pass in this case
--            exit_code_pytest = 0
--
--    except ModuleNotFoundError:
--        print("Pytest is not installed, skip checking tests that rely on it.")
--
--    if err == 0:
--        sys.exit(exit_code_pytest)
--    else:
--        sys.exit(err)
-+    sys.exit(err)
diff --git a/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch b/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
deleted file mode 100644
index bae8387cf94a..000000000000
--- a/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
-+++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
-@@ -237,8 +237,9 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
- 
-             sage: a = ZZ['x'](range(100000))
-             sage: R = Integers(3)['x']
--            sage: R(a)  # long time (7s on sage.math, 2013)
--            2*x^99998 + ... + x
-+            sage: p = R(a)
-+            sage: p.truncate(10)  # testing the whole poly is VERY SLOW
-+            2*x^8 + x^7 + 2*x^5 + x^4 + 2*x^2 + x
-         """
-         sig_on()
-         fmpz_poly_get_nmod_poly(&self.x, x)
diff --git a/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch b/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
deleted file mode 100644
index f3da5bbb555e..000000000000
--- a/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
+++ /dev/null
@@ -1,106 +0,0 @@
-diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-index 43727346269..9d3ccd475cd 100644
---- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-+++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-@@ -186,7 +186,7 @@ def Psi(l, use_stored=True):
-         sage: assert Psi(3, use_stored=True) == Psi(3, use_stored=False)
-         sage: assert Psi(5, use_stored=True) == Psi(5, use_stored=False)
-         sage: assert Psi(7, use_stored=True) == Psi(7, use_stored=False)
--        sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False) # not tested (very long time)
-+        sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False)  # long time (2s)
-     """
-     if l not in [2, 3, 5, 7, 13]:
-         raise ValueError("Genus zero primes are 2, 3, 5, 7 or 13.")
-@@ -1207,7 +1207,7 @@ def isogenies_13_0(E, minimal_models=True):
-         sage: K.<a> = NumberField(f)
-         sage: E = EllipticCurve(j=K(0)); E.ainvs()
-         (0, 0, 0, 0, 1)
--        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]
-+        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]  # long time (4s)
-         [(0,
-           0,
-           20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
-@@ -1325,7 +1325,7 @@ def isogenies_13_1728(E, minimal_models=True):
-         sage: f = x^12 + 1092*x^10 - 432432*x^8 + 6641024*x^6 - 282896640*x^4 - 149879808*x^2 - 349360128
-         sage: K.<a> = NumberField(f)
-         sage: E = EllipticCurve(K, [1,0])
--        sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]
-+        sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]  # long time (3s)
-         [(0,
-         0,
-         0,
-@@ -1550,8 +1550,11 @@ def Psi2(l):
-         sage: from sage.schemes.elliptic_curves.isogeny_small_degree import Psi2
-         sage: Psi2(11)
-         x^5 - 55*x^4*u + 994*x^3*u^2 - 8774*x^2*u^3 + 41453*x*u^4 - 928945/11*u^5 + 33*x^4 + 276*x^3*u - 7794*x^2*u^2 + 4452*x*u^3 + 1319331/11*u^4 + 216*x^3*v - 4536*x^2*u*v + 31752*x*u^2*v - 842616/11*u^3*v + 162*x^3 + 38718*x^2*u - 610578*x*u^2 + 33434694/11*u^3 - 4536*x^2*v + 73872*x*u*v - 2745576/11*u^2*v - 16470*x^2 + 580068*x*u - 67821354/11*u^2 - 185976*x*v + 14143896/11*u*v + 7533*x - 20437029/11*u - 12389112/11*v + 19964151/11
--        sage: Psi2(71)  # long time (1 second)
--        -2209380711722505179506258739515288584116147237393815266468076436521/71*u^210 + ... - 14790739586438315394567393301990769678157425619440464678252277649/71
-+        sage: f = Psi2(71)
-+        sage: f.coefficient([0, 210, 0])
-+        -2209380711722505179506258739515288584116147237393815266468076436521/71
-+        sage: f.coefficient([0, 0, 0])
-+        -14790739586438315394567393301990769678157425619440464678252277649/71
- 
-     TESTS::
- 
-@@ -1665,17 +1668,17 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True):
-         sage: K = QuadraticField(5,'a')
-         sage: a = K.gen()
-         sage: E = EllipticCurve_from_j(184068066743177379840*a - 411588709724712960000)
--        sage: isogenies_prime_degree_genus_plus_0(E, 47) # long time (4.3s)
-+        sage: isogenies_prime_degree_genus_plus_0(E, 47)  # long time (2s)
-         [Isogeny of degree 47 from Elliptic Curve defined by y^2 = x^3 + (454562028554080355857852049849975895490560*a-1016431595837124114668689286176511361024000)*x + (-249456798429896080881440540950393713303830363999480904280965120*a+557802358738710443451273320227578156598454035482869042774016000) over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790? to Elliptic Curve defined by y^2 = x^3 + (39533118442361013730577638493616965245992960*a-88398740199669828340617478832005245173760000)*x + (214030321479466610282320528611562368963830105830555363061803253760*a-478586348074220699687616322532666163722004497458452316582576128000) over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790?]
- 
-         sage: K = QuadraticField(-66827,'a')
-         sage: a = K.gen()
-         sage: E = EllipticCurve_from_j(-98669236224000*a + 4401720074240000)
--        sage: isogenies_prime_degree_genus_plus_0(E, 59)   # long time (25s, 2012)
-+        sage: isogenies_prime_degree_genus_plus_0(E, 59)   # long time (5s)
-         [Isogeny of degree 59 from Elliptic Curve defined by y^2 = x^3 + (2605886146782144762297974784000*a+1893681048912773634944634716160000)*x + (-116918454256410782232296183198067568744071168000*a+17012043538294664027185882358514011304812871680000) over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I to Elliptic Curve defined by y^2 = x^3 + (-19387084027159786821400775098368000*a-4882059104868154225052787156713472000)*x + (-25659862010101415428713331477227179429538847260672000*a-2596038148441293485938798119003462972840818381946880000) over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I]
- 
-         sage: E = EllipticCurve_from_j(GF(13)(5))
--        sage: isogenies_prime_degree_genus_plus_0(E, 71) # long time
-+        sage: isogenies_prime_degree_genus_plus_0(E, 71)
-         [Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13, Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13]
- 
-         sage: E = EllipticCurve(GF(13),[0,1,1,1,0])
-@@ -2117,11 +2120,11 @@ def isogenies_prime_degree_general(E, l, minimal_models=True):
-         sage: isogenies_prime_degree_general(E, 19)
-         [Isogeny of degree 19 from Elliptic Curve defined by y^2 + y = x^3 - 1862*x - 30956 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - 672182*x + 212325489 over Rational Field]
-         sage: E = EllipticCurve([0, -1, 0, -6288, 211072])
--        sage: isogenies_prime_degree_general(E, 37)  # long time (10s)
-+        sage: isogenies_prime_degree_general(E, 37)  # long time (2s)
-         [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 - x^2 - 6288*x + 211072 over Rational Field to Elliptic Curve defined by y^2 = x^3 - x^2 - 163137088*x - 801950801728 over Rational Field]
- 
-         sage: E = EllipticCurve([-3440, 77658])
--        sage: isogenies_prime_degree_general(E, 43)  # long time (16s)
-+        sage: isogenies_prime_degree_general(E, 43)  # long time (2s)
-         [Isogeny of degree 43 from Elliptic Curve defined by y^2 = x^3 - 3440*x + 77658 over Rational Field to Elliptic Curve defined by y^2 = x^3 - 6360560*x - 6174354606 over Rational Field]
- 
-     Isogenies of degree equal to the characteristic are computed (but
-@@ -2175,7 +2178,7 @@ def isogenies_prime_degree_general(E, l, minimal_models=True):
- 
-         sage: K.<i> = QuadraticField(-1)
-         sage: E = EllipticCurve(K,[0,0,0,1,0])
--        sage: [phi.codomain().ainvs() for phi in E.isogenies_prime_degree(37)] # long time
-+        sage: [phi.codomain().ainvs() for phi in E.isogenies_prime_degree(37)]  # long time (6s)
-         [(0, 0, 0, -840*i + 1081, 0), (0, 0, 0, 840*i + 1081, 0)]
-     """
-     if not l.is_prime():
-@@ -2329,14 +2332,14 @@ def isogenies_prime_degree(E, l, minimal_models=True):
-         sage: E = EllipticCurve(GF(101), [-3440, 77658])
-         sage: E.isogenies_prime_degree(71) # fast
-         []
--        sage: E.isogenies_prime_degree(73) # slower (2s)
-+        sage: E.isogenies_prime_degree(73)  # long time (2s)
-         []
- 
-     Test that :trac:`32269` is fixed::
- 
-         sage: K = QuadraticField(-11)
-         sage: E = EllipticCurve(K, [0,1,0,-117,-541])
--        sage: E.isogenies_prime_degree(37)
-+        sage: E.isogenies_prime_degree(37)  # long time (9s)
-         [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I to Elliptic Curve defined by y^2 = x^3 + x^2 + (30800*a+123963)*x + (3931312*a-21805005) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I,
-          Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I to Elliptic Curve defined by y^2 = x^3 + x^2 + (-30800*a+123963)*x + (-3931312*a-21805005) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I]
- 
diff --git a/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch b/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
deleted file mode 100644
index 3b7b1ea843df..000000000000
--- a/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
+++ /dev/null
@@ -1,97 +0,0 @@
---- a/src/sage/rings/function_field/function_field.py
-+++ b/src/sage/rings/function_field/function_field.py
-@@ -111,22 +111,21 @@ Function fields over the algebraic field are supported::
-     sage: m = L.completion(pl, prec=5)
-     sage: m(x)
-     I + s + O(s^5)
--    sage: m(y)
-+    sage: m(y)                             # long time (4s)
-     -2*s + (-4 - I)*s^2 + (-15 - 4*I)*s^3 + (-75 - 23*I)*s^4 + (-413 - 154*I)*s^5 + O(s^6)
--    sage: m(y)^2 + m(y) + m(x) + 1/m(x)
-+    sage: m(y)^2 + m(y) + m(x) + 1/m(x)    # long time (8s)
-     O(s^5)
- 
- TESTS::
- 
-     sage: TestSuite(J).run()
--    sage: TestSuite(K).run(max_runs=1024) # long time (5s)
--    sage: TestSuite(L).run(max_runs=64)   # long time (10s)
--    sage: TestSuite(M).run(max_runs=32)   # long time (30s)
--    sage: TestSuite(N).run(max_runs=64, skip = '_test_derivation')  # long time (8s)
--    sage: TestSuite(O).run(max_runs=128, skip = '_test_derivation') # long time (8s)
--
-+    sage: TestSuite(K).run(max_runs=256)   # long time (10s)
-+    sage: TestSuite(L).run(max_runs=8)     # long time (25s)
-+    sage: TestSuite(M).run(max_runs=8)     # long time (35s)
-+    sage: TestSuite(N).run(max_runs=8, skip = '_test_derivation')    # long time (15s)
-+    sage: TestSuite(O).run()
-     sage: TestSuite(R).run()
--    sage: TestSuite(S).run() # long time (3s)
-+    sage: TestSuite(S).run()               # long time (4s)
- 
- Global function fields
- ----------------------
-@@ -287,7 +286,7 @@ class FunctionField(Field):
-         TESTS::
- 
-             sage: K.<x> = FunctionField(QQ)
--            sage: TestSuite(K).run()
-+            sage: TestSuite(K).run()               # long time (3s)
-         """
-         Field.__init__(self, base_field, names=names, category=category)
- 
-@@ -729,7 +728,7 @@ class FunctionField(Field):
-         EXAMPLES::
- 
-             sage: K.<x> = FunctionField(QQ)
--            sage: TestSuite(K).run() # indirect doctest
-+            sage: TestSuite(K).run()    # indirect doctest, long time (3s)
-         """
-         tester = self._tester(**options)
-         S = tester.some_elements()
-@@ -1209,7 +1208,7 @@ class FunctionField_polymod(FunctionField):
-             sage: K.<x> = FunctionField(QQ); R.<y> = K[]
-             sage: L = K.extension(y^5 - x^3 - 3*x + x*y); L
-             Function field in y defined by y^5 + x*y - x^3 - 3*x
--            sage: TestSuite(L).run()  # long time
-+            sage: TestSuite(L).run(max_runs=512)   # long time (15s)
- 
-         We can set the variable name, which doesn't have to be y::
- 
-@@ -2888,7 +2887,8 @@ class FunctionField_simple(FunctionField_polymod):
-             sage: F.<y> = K.extension(Y^3 - x^2*(x^2 + x + 1)^2)
-             sage: O = K.maximal_order()
-             sage: pls = [O.ideal(x-QQbar(sqrt(c))).place() for c in [-2, -1, 0, 1, 2]]
--            sage: all(q.place_below() == p for p in pls for q in F.places_above(p))
-+            sage: all(q.place_below() == p         # long time (4s)
-+            ....:     for p in pls for q in F.places_above(p))
-             True
-         """
-         R = self.base_field()
-@@ -3091,7 +3091,7 @@ class FunctionField_global(FunctionField_simple):
- 
-         sage: K.<x> = FunctionField(GF(4)); _.<Y> = K[]
-         sage: L.<y> = K.extension((1 - x)*Y^7 - x^3)
--        sage: L.gaps()
-+        sage: L.gaps()                         # long time (6s)
-         [1, 2, 3]
- 
-     or may define a trivial extension::
-@@ -3111,7 +3111,7 @@ class FunctionField_global(FunctionField_simple):
- 
-             sage: K.<x> = FunctionField(GF(5)); _.<Y> = K[]
-             sage: L.<y> = K.extension(Y^3 - (x^3 - 1)/(x^3 - 2))
--            sage: TestSuite(L).run()
-+            sage: TestSuite(L).run()               # long time (7s)
-         """
-         FunctionField_polymod.__init__(self, polynomial, names)
- 
-@@ -3807,7 +3807,7 @@ class RationalFunctionField(FunctionField):
- 
-             sage: K.<t> = FunctionField(CC); K
-             Rational function field in t over Complex Field with 53 bits of precision
--            sage: TestSuite(K).run()
-+            sage: TestSuite(K).run()               # long time (5s)
- 
-             sage: FunctionField(QQ[I], 'alpha')
-             Rational function field in alpha over Number Field in I with defining polynomial x^2 + 1 with I = 1*I
diff --git a/srcpkgs/sagemath/patches/matplotlib-3.6.patch b/srcpkgs/sagemath/patches/matplotlib-3.6.patch
new file mode 100644
index 000000000000..6afaf1b7162f
--- /dev/null
+++ b/srcpkgs/sagemath/patches/matplotlib-3.6.patch
@@ -0,0 +1,72 @@
+commit 5501e0de0dca1cff0355326dd42bd8c7e5749568
+Author: Gonzalo Tornaría <tornaria@cmat.edu.uy>
+Date:   Tue Oct 11 17:25:04 2022 -0300
+
+    Support matplotlib 3.6
+
+diff --git a/src/sage/plot/arc.py b/src/sage/plot/arc.py
+index bb834763afc..f65973bcbd5 100644
+--- a/src/sage/plot/arc.py
++++ b/src/sage/plot/arc.py
+@@ -273,9 +273,9 @@ class Arc(GraphicPrimitive):
+         p = patches.Arc((self.x, self.y),
+                         2. * self.r1,
+                         2. * self.r2,
+-                        fmod(self.angle, 2 * pi) * (180. / pi),
+-                        self.s1 * (180. / pi),
+-                        self.s2 * (180. / pi))
++                        angle=fmod(self.angle, 2 * pi) * (180. / pi),
++                        theta1=self.s1 * (180. / pi),
++                        theta2=self.s2 * (180. / pi))
+         return p
+ 
+     def bezier_path(self):
+diff --git a/src/sage/plot/ellipse.py b/src/sage/plot/ellipse.py
+index a77e6fe640a..c35bed574ef 100644
+--- a/src/sage/plot/ellipse.py
++++ b/src/sage/plot/ellipse.py
+@@ -192,7 +192,8 @@ class Ellipse(GraphicPrimitive):
+         options = self.options()
+         p = patches.Ellipse(
+                 (self.x,self.y),
+-                self.r1*2.,self.r2*2.,self.angle/pi*180.)
++                self.r1*2.,self.r2*2.,
++                angle=self.angle/pi*180.)
+         p.set_linewidth(float(options['thickness']))
+         p.set_fill(options['fill'])
+         a = float(options['alpha'])
+diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
+index e779e1210e3..8d620b5c625 100644
+--- a/src/sage/plot/graphics.py
++++ b/src/sage/plot/graphics.py
+@@ -2007,7 +2007,7 @@ class Graphics(WithEqualityById, SageObject):
+         We can also do custom formatting if you need it.  See above for full
+         details::
+ 
+-            sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex")
++            sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex") # not tested (broken with matplotlib 3.6)
+             Graphics object consisting of 1 graphics primitive
+ 
+         This is particularly useful when setting custom ticks in multiples
+@@ -2341,7 +2341,7 @@ class Graphics(WithEqualityById, SageObject):
+             sage: subplot = Figure().add_subplot(111)
+             sage: p._objects[0]._render_on_subplot(subplot)
+             sage: p._matplotlib_tick_formatter(subplot, **d)
+-            (<AxesSubplot:>,
++            (<AxesSubplot:...>,
+             <matplotlib.ticker.MaxNLocator object at ...>,
+             <matplotlib.ticker.MaxNLocator object at ...>,
+             <matplotlib.ticker.ScalarFormatter object at ...>,
+diff --git a/src/sage/plot/plot.py b/src/sage/plot/plot.py
+index b36ee57227c..5301a05c3dc 100644
+--- a/src/sage/plot/plot.py
++++ b/src/sage/plot/plot.py
+@@ -1741,7 +1741,7 @@ def plot(funcs, *args, **kwds):
+ 
+     ::
+ 
+-        sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex")
++        sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex") # not tested (broken with matplotlib 3.6)
+         Graphics object consisting of 1 graphics primitive
+ 
+     .. PLOT::
diff --git a/srcpkgs/sagemath/patches/python-3.11.patch b/srcpkgs/sagemath/patches/python-3.11.patch
new file mode 100644
index 000000000000..eafe76bfb794
--- /dev/null
+++ b/srcpkgs/sagemath/patches/python-3.11.patch
@@ -0,0 +1,45 @@
+--- a/src/sage/cpython/cython_metaclass.h
++++ b/src/sage/cpython/cython_metaclass.h
+@@ -66,7 +66,7 @@
+         }
+ 
+         /* Now, set t.__class__ to metaclass */
+-        Py_TYPE(t) = metaclass;
++        Py_SET_TYPE(t, metaclass);
+         PyType_Modified(t);
+     }
+     else
+--- a/src/sage/symbolic/ginac/numeric.cpp
++++ b/src/sage/symbolic/ginac/numeric.cpp
+@@ -52,7 +52,6 @@
+ #define register
+ #define PY_SSIZE_T_CLEAN
+ #include <Python.h>
+-#include <longintrepr.h>
+ #include "flint/fmpz.h"
+ #include "flint/fmpz_factor.h"
+ 
+--- a/src/sage/libs/gmp/pylong.pyx
++++ b/src/sage/libs/gmp/pylong.pyx
+@@ -32,7 +32,7 @@
+ from .mpz cimport *
+ 
+ cdef extern from *:
+-    Py_ssize_t* Py_SIZE_PTR "&Py_SIZE"(object)
++    void Py_SET_SIZE(object, Py_ssize_t)
+     int hash_bits """
+         #ifdef _PyHASH_BITS
+         _PyHASH_BITS         /* Python 3 */
+@@ -57,10 +57,8 @@
+     mpz_export(L.ob_digit, NULL,
+             -1, sizeof(digit), 0, PyLong_nails, z)
+     if mpz_sgn(z) < 0:
+-        # Set correct size (use a pointer to hack around Cython's
+-        # non-support for lvalues).
+-        sizeptr = Py_SIZE_PTR(L)
+-        sizeptr[0] = -pylong_size
++        # Set correct size
++        Py_SET_SIZE(L, -pylong_size)
+     return L
+ 
+ 
diff --git a/srcpkgs/sagemath/patches/sagemath-pari-2.15.patch b/srcpkgs/sagemath/patches/sagemath-pari-2.15.patch
new file mode 100644
index 000000000000..ccafad5070c4
--- /dev/null
+++ b/srcpkgs/sagemath/patches/sagemath-pari-2.15.patch
@@ -0,0 +1,1750 @@
+diff --git a/build/pkgs/giac/patches/pari_2_15.patch b/build/pkgs/giac/patches/pari_2_15.patch
+new file mode 100644
+index 0000000000..d2900a5ffc
+--- /dev/null
++++ b/build/pkgs/giac/patches/pari_2_15.patch
+@@ -0,0 +1,21 @@
++ANYARG patch
++
++diff --git a/src/pari.cc b/src/pari.cc
++index 76ce8e1..50d08ab 100644
++--- a/src/pari.cc
+++++ b/src/pari.cc
++@@ -40,6 +40,13 @@ using namespace std;
++ 
++ #ifdef HAVE_LIBPARI
++ 
+++// Anyarg disappeared from PARI 2.15.0
+++#ifdef __cplusplus
+++#  define ANYARG ...
+++#else
+++#  define ANYARG
+++#endif
+++
++ #ifdef HAVE_PTHREAD_H
++ #include <pthread.h>
++ #endif
++
+diff --git a/build/pkgs/pari/checksums.ini b/build/pkgs/pari/checksums.ini
+index b736feed31..bafd0f36f4 100644
+--- a/build/pkgs/pari/checksums.ini
++++ b/build/pkgs/pari/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=pari-VERSION.tar.gz
+-sha1=e01647aab7e96a8cb4922cf26a4f224337c6647f
+-md5=922f740fcdf8630b30d63dc76b58f756
+-cksum=297133525
++sha1=cba9b279f67d5efe2fbbccf3be6e9725f816cf07
++md5=76d430f1bea1b07fa2ad9712deeaa736
++cksum=1990743897
+ upstream_url=https://pari.math.u-bordeaux.fr/pub/pari/unix/pari-VERSION.tar.gz
+diff --git a/build/pkgs/pari/package-version.txt b/build/pkgs/pari/package-version.txt
+index a1a4224dd5..68e69e405e 100644
+--- a/build/pkgs/pari/package-version.txt
++++ b/build/pkgs/pari/package-version.txt
+@@ -1 +1 @@
+-2.13.3
++2.15.0
+diff --git a/src/doc/de/tutorial/tour_numtheory.rst b/src/doc/de/tutorial/tour_numtheory.rst
+index a012234c99..e3149fe949 100644
+--- a/src/doc/de/tutorial/tour_numtheory.rst
++++ b/src/doc/de/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ implementiert.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/en/tutorial/tour_numtheory.rst b/src/doc/en/tutorial/tour_numtheory.rst
+index 3064d100e2..075e0ac0ad 100644
+--- a/src/doc/en/tutorial/tour_numtheory.rst
++++ b/src/doc/en/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ NumberField class.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/es/tutorial/tour_numtheory.rst b/src/doc/es/tutorial/tour_numtheory.rst
+index a1f7d1a87b..48e5376cfe 100644
+--- a/src/doc/es/tutorial/tour_numtheory.rst
++++ b/src/doc/es/tutorial/tour_numtheory.rst
+@@ -140,7 +140,7 @@ Varios métodos relacionados están implementados en la clase ``NumberField``::
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/fr/tutorial/tour_numtheory.rst b/src/doc/fr/tutorial/tour_numtheory.rst
+index 871092f5fa..d1b2fee883 100644
+--- a/src/doc/fr/tutorial/tour_numtheory.rst
++++ b/src/doc/fr/tutorial/tour_numtheory.rst
+@@ -159,7 +159,7 @@ dans la classe NumberField.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/ja/tutorial/tour_numtheory.rst b/src/doc/ja/tutorial/tour_numtheory.rst
+index 47af68c862..4d4ed52d50 100644
+--- a/src/doc/ja/tutorial/tour_numtheory.rst
++++ b/src/doc/ja/tutorial/tour_numtheory.rst
+@@ -161,7 +161,7 @@ Sageには :math:`p` \-進数体も組込まれている.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/pt/tutorial/tour_numtheory.rst b/src/doc/pt/tutorial/tour_numtheory.rst
+index 6371b491ea..a3dc973a93 100644
+--- a/src/doc/pt/tutorial/tour_numtheory.rst
++++ b/src/doc/pt/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ NumberField.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus 
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/ru/tutorial/tour_numtheory.rst b/src/doc/ru/tutorial/tour_numtheory.rst
+index 652abfbc99..a985d49fbd 100644
+--- a/src/doc/ru/tutorial/tour_numtheory.rst
++++ b/src/doc/ru/tutorial/tour_numtheory.rst
+@@ -150,7 +150,7 @@ Sage содержит стандартные функции теории чис
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py
+index e57076646f..fec75d07c1 100644
+--- a/src/sage/arith/misc.py
++++ b/src/sage/arith/misc.py
+@@ -1465,13 +1465,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)]
++        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::
+ 
+@@ -2569,7 +2569,7 @@ def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds):
+ 
+         sage: K.<i> = QuadraticField(-1)
+         sage: factor(122 - 454*i)
+-        (-3*i - 2) * (-i - 2)^3 * (i + 1)^3 * (i + 4)
++        (-i) * (-i - 2)^3 * (i + 1)^3 * (-2*i + 3) * (i + 4)
+ 
+     To access the data in a factorization::
+ 
+diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
+index cdfc11a9e5..b6e1280d6e 100644
+--- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
++++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
+@@ -7825,9 +7825,9 @@ class DynamicalSystem_projective_field(DynamicalSystem_projective,
+             sage: f = DynamicalSystem_projective([x^2 + QQbar(sqrt(3))*y^2, y^2, QQbar(sqrt(2))*z^2])
+             sage: f.reduce_base_field()
+             Dynamical System of Projective Space of dimension 2 over Number Field in a with
+-            defining polynomial y^4 - 4*y^2 + 1 with a = 1.931851652578137?
++            defining polynomial y^4 - 4*y^2 + 1 with a = -0.5176380902050415?
+               Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x^2 + (a^2 - 2)*y^2 : y^2 : (a^3 - 3*a)*z^2)
++                    (x^2 + (-a^2 + 2)*y^2 : y^2 : (a^3 - 3*a)*z^2)
+ 
+         ::
+ 
+diff --git a/src/sage/ext_data/pari/simon/ellQ.gp b/src/sage/ext_data/pari/simon/ellQ.gp
+index 420af8f6a2..65e8386779 100644
+--- a/src/sage/ext_data/pari/simon/ellQ.gp
++++ b/src/sage/ext_data/pari/simon/ellQ.gp
+@@ -40,7 +40,7 @@
+   gp > \r ellcommon.gp
+   gp > \r ellQ.gp
+ 
+-  The main function is ellrank(), which takes as an argument
++  The main function is ellQ_ellrank(), which takes as an argument
+   any elliptic curve in the form [a1,a2,a3,a4,a6]
+   the result is a vector [r,s,v], where
+     r is a lower bound for the rank,
+@@ -50,7 +50,7 @@
+   Example:
+ 
+   gp > ell = [1,2,3,4,5];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+   %1 = [1, 1, [[1,2]]
+   In this example, the rank is exactly 1, and [1,2] has infinite order.
+ 
+@@ -92,7 +92,7 @@
+   \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+ 
+   Explications succintes :
+-  La fonction ellrank() accepte toutes les courbes sous la forme
++  La fonction ellQ_ellrank() accepte toutes les courbes sous la forme
+   [a1,a2,a3,a4,a6]
+   Les coefficients peuvent etre entiers ou non.
+   L'algorithme utilise est celui de la 2-descente.
+@@ -100,7 +100,7 @@
+   Il suffit de taper : 
+ 
+   gp > ell = [a1,a2,a3,a4,a6];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+ 
+   Retourne un vecteur [r,s,v] ou
+     r est le rang probable (c'est toujours une minoration du rang),
+@@ -110,7 +110,7 @@
+   Exemple :
+ 
+   gp > ell = [1,2,3,4,5];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+   %1 = [1, 1, [[1,2]]
+   Ici, le rang est exactement 1, et le point [1,2] est d'ordre infini.
+ 
+@@ -1571,12 +1571,12 @@ if( DEBUGLEVEL_ell >= 4, print("    end of ell2descent_gen"));
+     print("rank(E/Q)    >= ",m1)
+   );
+ }
+-{ellrank(ell,help=[]) =
++{ellQ_ellrank(ell,help=[]) =
+ \\ Algorithm of 2-descent on the elliptic curve ell.
+ \\ help is a list of known points on ell.
+ my(urst,urst1,den,eqell,tors2,bnf,rang,time1);
+ 
+-if( DEBUGLEVEL_ell >= 3, print("   starting ellrank"));
++if( DEBUGLEVEL_ell >= 3, print("   starting ellQ_ellrank"));
+   if( #ell < 13, ell = ellinit(ell));
+ 
+ \\ kill the coefficients a1 and a3
+@@ -1630,7 +1630,7 @@ if( DEBUGLEVEL_ell >= 1, print(" Elliptic curve: Y^2 = ",eqell));
+   ));
+ 
+   rang[3] = ellchangepoint(rang[3],ellinverturst(urst));
+-if( DEBUGLEVEL_ell >= 3, print("   end of ellrank"));
++if( DEBUGLEVEL_ell >= 3, print("   end of ellQ_ellrank"));
+ 
+   return(rang);
+ }
+@@ -2106,13 +2106,13 @@ if( DEBUGLEVEL_ell >= 3, print("   end of ell2descent_viaisog"));
+ {
+ \\                  functions for elliptic curves
+   addhelp(ell2descent_complete,
+-    "ell2descent_complete(e1,e2,e3): Performs a complete 2-descent on the elliptic curve y^2 = (x-e1)*(x-e2)*(x-e3). See ?ellrank for the format of the output.");
++    "ell2descent_complete(e1,e2,e3): Performs a complete 2-descent on the elliptic curve y^2 = (x-e1)*(x-e2)*(x-e3). See ?ellQ_ellrank for the format of the output.");
+   addhelp(ell2descent_gen,
+-    "ell2descent_gen((E,bnf,k=1,help=[]): E is a vector of the form [0,A,0,B,C], (or the result of ellinit of such a vector) A,B,C integers such that x^3+A*x^2+B*x+C; bnf is the corresponding bnfinit(,1); Performs 2-descent on the elliptic curve Ek: k*y^2=x^3+A*x^2+B*x+C. See ?ellrank for the format of the output.");
++    "ell2descent_gen((E,bnf,k=1,help=[]): E is a vector of the form [0,A,0,B,C], (or the result of ellinit of such a vector) A,B,C integers such that x^3+A*x^2+B*x+C; bnf is the corresponding bnfinit(,1); Performs 2-descent on the elliptic curve Ek: k*y^2=x^3+A*x^2+B*x+C. See ?ellQ_ellrank for the format of the output.");
+   addhelp(ell2descent_viaisog,
+-    "ell2descent_viaisog(E,help=[]): E is an elliptic curve of the form [0,a,0,b,0], with a, b integers. Performs a 2-descent via isogeny on E. See ?ellrank for the format of the output.");
+-  addhelp(ellrank,
+-    "ellrank(E,help=[]): E is any elliptic curve defined over Q. Returns a vector [r,s,v], where r is a lower bound for the rank of E, s is the rank of its 2-Selmer group and v is a list of independant points in E(Q)/2E(Q). If help is a vector of nontrivial points on E, the result might be faster. This function might be used in conjunction with elltors2(E). See also ?default_ellQ");
++    "ell2descent_viaisog(E,help=[]): E is an elliptic curve of the form [0,a,0,b,0], with a, b integers. Performs a 2-descent via isogeny on E. See ?ellQ_ellrank for the format of the output.");
++  addhelp(ellQ_ellrank,
++    "ellQ_ellrank(E,help=[]): E is any elliptic curve defined over Q. Returns a vector [r,s,v], where r is a lower bound for the rank of E, s is the rank of its 2-Selmer group and v is a list of independant points in E(Q)/2E(Q). If help is a vector of nontrivial points on E, the result might be faster. This function might be used in conjunction with elltors2(E). See also ?default_ellQ");
+   addhelp(ellhalf,
+     "ellhalf(E,P): returns the vector of all points Q on the elliptic curve E such that 2Q = P");
+   addhelp(ellredgen,
+@@ -2143,7 +2143,7 @@ if( DEBUGLEVEL_ell >= 3, print("   end of ell2descent_viaisog"));
+ 
+ \\                  others
+   addhelp(default_ellQ,
+-    "default_ellQ(DEBUGLEVEL_ell, LIM1, LIM3, LIMTRIV, ELLREDGENFLAG, COMPLETE, MAXPROB, LIMBIGPRIME): set the value of the global variables used for ellrank() and other related functions. DEBUGLEVEL_ell: 0-5: choose the quantity of information printed during the computation (default=0: print nothing); LIM1 (resp LIM3): search limit for easy (resp hard) points on quartics; LIMTRIV: search limit for trivial points on elliptic curves; ELLREDGENFLAG: if != 0, try to reduce the generators at the end; COMPLETE: if != 0 and full 2-torsion, use complete 2-descent, otherwise via 2-isogeny; MAXPROB, LIMBIGPRIME: technical.");
++    "default_ellQ(DEBUGLEVEL_ell, LIM1, LIM3, LIMTRIV, ELLREDGENFLAG, COMPLETE, MAXPROB, LIMBIGPRIME): set the value of the global variables used for ellQ_ellrank() and other related functions. DEBUGLEVEL_ell: 0-5: choose the quantity of information printed during the computation (default=0: print nothing); LIM1 (resp LIM3): search limit for easy (resp hard) points on quartics; LIMTRIV: search limit for trivial points on elliptic curves; ELLREDGENFLAG: if != 0, try to reduce the generators at the end; COMPLETE: if != 0 and full 2-torsion, use complete 2-descent, otherwise via 2-isogeny; MAXPROB, LIMBIGPRIME: technical.");
+ /*  addhelp(DEBUGLEVEL_ell,
+     "DEBUGLEVEL_ell: Choose a higher value of this global variable to have more details of the computations printed during the 2-descent algorithm. 0 = don't print anything; 1 = (default) just print the result; 2 = print more details including the Selmer group and the nontrivial quartics.");
+ */
+diff --git a/src/sage/ext_data/pari/simon/qfsolve.gp b/src/sage/ext_data/pari/simon/qfsolve.gp
+index 501fb50828..2107288c1d 100644
+--- a/src/sage/ext_data/pari/simon/qfsolve.gp
++++ b/src/sage/ext_data/pari/simon/qfsolve.gp
+@@ -434,146 +434,6 @@ my(cc);
+ return([U3~*G3*U3,red[2]*U1*U2*U3]);
+ }
+ 
+-\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+-\\        QUADRATIC FORMS MINIMIZATION         \\
+-\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+-
+-\\ Minimization of the quadratic form G, with nonzero determinant.
+-\\ of dimension n>=2.
+-\\ G must by symmetric and have integral coefficients.
+-\\ Returns [G',U,factd] with U in GLn(Q) such that G'=U~*G*U*constant
+-\\ is integral and has minimal determinant.
+-\\ In dimension 3 or 4, may return a prime p
+-\\ if the reduction at p is impossible because of the local non solvability.
+-\\ If given, factdetG must be equal to factor(abs(det(G))).
+-{qfminimize(G,factdetG) =
+-my(factd,U,Ker,Ker2,sol,aux,di);
+-my(p);
+-my(n,lf,i,vp,dimKer,dimKer2,m);
+-
+-  n = length(G);
+-  factd = matrix(0,2);
+-  if( !factdetG, factdetG = factor(matdet(G)));
+-
+-  lf = length(factdetG[,1]);
+-  i = 1; U = matid(n);
+-
+-  while(i <= lf,
+-    vp = factdetG[i,2];
+-    if( vp == 0, i++; next);
+-    p = factdetG[i,1];
+-    if( p == -1, i++; next);
+-if( DEBUGLEVEL_qfsolve >= 4, print("    p = ",p,"^",vp));
+-
+-\\ The case vp = 1 can be minimized only if n is odd.
+-    if( vp == 1 && n%2 == 0,
+-      factd = concat(factd~, Mat([p,1])~)~;
+-      i++; next
+-    );
+-    Ker = kermodp(G,p); dimKer = Ker[1]; Ker = Ker[2];
+-
+-\\ Rem: we must have dimKer <= vp
+-if( DEBUGLEVEL_qfsolve >= 4, print("    dimKer = ",dimKer));
+-\\ trivial case: dimKer = n
+-    if( dimKer == n, 
+-if( DEBUGLEVEL_qfsolve >= 4, print("     case 0: dimKer = n"));
+-      G /= p;
+-      factdetG[i,2] -= n;
+-      next
+-    );
+-    G = Ker~*G*Ker;
+-    U = U*Ker;
+-
+-\\ 1st case: dimKer < vp
+-\\ then the kernel mod p contains a kernel mod p^2
+-    if( dimKer < vp,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 1: dimker < vp"));
+-      if( dimKer == 1,
+-\\        G[,1] /= p; G[1,] /= p;
+-        G[,1] /= p; G[1,] = G[1,]/p;
+-        U[,1] /= p;
+-        factdetG[i,2] -= 2
+-      , 
+-        Ker2 = kermodp(matrix(dimKer,dimKer,j,k,G[j,k]/p),p);
+-        dimKer2 = Ker2[1]; Ker2 = Ker2[2];
+-        for( j = 1, dimKer2, Ker2[,j] /= p);
+-        Ker2 = matdiagonalblock([Ker2,matid(n-dimKer)]);
+-        G = Ker2~*G*Ker2;
+-        U = U*Ker2;
+-        factdetG[i,2] -= 2*dimKer2
+-);
+-
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 1"));
+-      next
+-    );
+-
+-\\ Now, we have vp = dimKer 
+-\\ 2nd case: the dimension of the kernel is >=2
+-\\ and contains an element of norm 0 mod p^2
+-
+-\\ search for an element of norm p^2... in the kernel
+-    if( dimKer > 2 || 
+-       (dimKer == 2 && issquare( di = Mod((G[1,2]^2-G[1,1]*G[2,2])/p^2,p))),
+-      if( dimKer > 2,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 2.1"));
+-        dimKer = 3;
+-        sol = qfsolvemodp(matrix(3,3,j,k,G[j,k]/p),p)
+-      ,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 2.2"));
+-        if( G[1,1]%p^2 == 0, 
+-          sol = [1,0]~
+-        , sol = [-G[1,2]/p+sqrt(di),Mod(G[1,1]/p,p)]~
+-        )
+-      );
+-      sol = centerlift(sol);
+-      sol /= content(sol);
+-if( DEBUGLEVEL_qfsolve >= 4, print("    sol = ",sol));
+-      Ker = vectorv(n, j, if( j<= dimKer, sol[j], 0)); \\ fill with 0's
+-      Ker = completebasis(Ker,1);
+-      Ker[,n] /= p;
+-      G = Ker~*G*Ker;
+-      U = U*Ker;
+-      factdetG[i,2] -= 2;
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 2"));
+-      next
+-    );
+-
+-\\ Now, we have vp = dimKer <= 2 
+-\\   and the kernel contains no vector with norm p^2...
+-
+-\\ In some cases, exchanging the kernel and the image
+-\\ makes the minimization easy.
+-
+-    m = (n-1)\2-1;
+-    if( ( vp == 1 && issquare(Mod(-(-1)^m*matdet(G)/G[1,1],p)))
+-     || ( vp == 2 && n%2 == 1 && n >= 5)
+-     || ( vp == 2 && n%2 == 0 && !issquare(Mod((-1)^m*matdet(G)/p^2,p)))
+-    , 
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 3"));
+-      Ker = matid(n);
+-      for( j = dimKer+1, n, Ker[j,j] = p);
+-      G = Ker~*G*Ker/p;
+-      U = U*Ker;
+-      factdetG[i,2] -= 2*dimKer-n;
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 3"));
+-      next
+-    );
+-
+-\\ Minimization was not possible se far.
+-\\ If n == 3 or 4, this proves the local non-solubility at p.
+-    if( n == 3 || n == 4, 
+-if( DEBUGLEVEL_qfsolve >= 1, print(" no local solution at ",p));
+-      return(p));
+-
+-if( DEBUGLEVEL_qfsolve >= 4, print("    prime ",p," finished"));
+-    factd = concat(factd~,Mat([p,vp])~)~;
+-    i++
+-  );
+-\\ apply LLL to avoid coefficients explosion
+-  aux = qflll(U/content(U));
+-return([aux~*G*aux,U*aux,factd]);
+-}
+-
+ \\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+ \\          CLASS GROUP COMPUTATIONS           \\
+ \\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+diff --git a/src/sage/geometry/polyhedron/backend_field.py b/src/sage/geometry/polyhedron/backend_field.py
+index 6b921d23a6..2f32c58b1e 100644
+--- a/src/sage/geometry/polyhedron/backend_field.py
++++ b/src/sage/geometry/polyhedron/backend_field.py
+@@ -265,7 +265,7 @@ class Polyhedron_field(Polyhedron_base):
+              An inequality (-0.1419794359520263?, -1.698172434277148?) x + 1.200789243901438? >= 0,
+              An inequality (0.3001973109753594?, 0.600394621950719?) x - 0.4245431085692869? >= 0)
+             sage: p.Vrepresentation()                                           # optional - sage.rings.number_field
+-            (A vertex at (0.?e-15, 0.707106781186548?),
++            (A vertex at (0.?e-16, 0.7071067811865475?),
+              A vertex at (1.414213562373095?, 0),
+              A vertex at (4.000000000000000?, 0.372677996249965?))
+         """
+@@ -308,7 +308,7 @@ class Polyhedron_field(Polyhedron_base):
+              An inequality (-0.1419794359520263?, -1.698172434277148?) x + 1.200789243901438? >= 0,
+              An inequality (0.3001973109753594?, 0.600394621950719?) x - 0.4245431085692869? >= 0)
+             sage: p.Vrepresentation()                                           # optional - sage.rings.number_field
+-            (A vertex at (0.?e-15, 0.707106781186548?),
++            (A vertex at (0.?e-16, 0.7071067811865475?),
+              A vertex at (1.414213562373095?, 0),
+              A vertex at (4.000000000000000?, 0.372677996249965?))
+         """
+diff --git a/src/sage/geometry/polyhedron/backend_normaliz.py b/src/sage/geometry/polyhedron/backend_normaliz.py
+index 86b89632a5..ca8a43b248 100644
+--- a/src/sage/geometry/polyhedron/backend_normaliz.py
++++ b/src/sage/geometry/polyhedron/backend_normaliz.py
+@@ -53,7 +53,7 @@ def _number_field_elements_from_algebraics_list_of_lists_of_lists(listss, **kwds
+         1.732050807568878?
+         sage: from sage.geometry.polyhedron.backend_normaliz import _number_field_elements_from_algebraics_list_of_lists_of_lists
+         sage: K, results, hom = _number_field_elements_from_algebraics_list_of_lists_of_lists([[[rt2], [1]], [[rt3]], [[1], []]]); results  # optional - sage.rings.number_field
+-        [[[-a^3 + 3*a], [1]], [[-a^2 + 2]], [[1], []]]
++        [[[-a^3 + 3*a], [1]], [[a^2 - 2]], [[1], []]]
+     """
+     from sage.rings.qqbar import number_field_elements_from_algebraics
+     numbers = []
+diff --git a/src/sage/groups/matrix_gps/isometries.py b/src/sage/groups/matrix_gps/isometries.py
+index f9111a2c92..cca45e7175 100644
+--- a/src/sage/groups/matrix_gps/isometries.py
++++ b/src/sage/groups/matrix_gps/isometries.py
+@@ -11,11 +11,11 @@ EXAMPLES::
+     sage: L = IntegralLattice("D4")
+     sage: O = L.orthogonal_group()
+     sage: O
+-    Group of isometries with 5 generators (
+-    [-1  0  0  0]  [0 0 0 1]  [-1 -1 -1 -1]  [ 1  1  0  0]  [ 1  0  0  0]
+-    [ 0 -1  0  0]  [0 1 0 0]  [ 0  0  1  0]  [ 0  0  1  0]  [-1 -1 -1 -1]
+-    [ 0  0 -1  0]  [0 0 1 0]  [ 0  1  0  1]  [ 0  1  0  1]  [ 0  0  1  0]
+-    [ 0  0  0 -1], [1 0 0 0], [ 0 -1 -1  0], [ 0 -1 -1  0], [ 0  0  0  1]
++    Group of isometries with 3 generators (
++    [0 0 0 1]  [ 1  1  0  0]  [ 1  0  0  0]
++    [0 1 0 0]  [ 0  0  1  0]  [-1 -1 -1 -1]
++    [0 0 1 0]  [ 0  1  0  1]  [ 0  0  1  0]
++    [1 0 0 0], [ 0 -1 -1  0], [ 0  0  0  1]
+     )
+ 
+ Basic functionality is provided by GAP::
+diff --git a/src/sage/interfaces/genus2reduction.py b/src/sage/interfaces/genus2reduction.py
+index 56ae04b235..7a4794daf2 100644
+--- a/src/sage/interfaces/genus2reduction.py
++++ b/src/sage/interfaces/genus2reduction.py
+@@ -143,31 +143,31 @@ class ReductionData(SageObject):
+        sur un corps de valuation discrète", Trans. AMS 348 (1996),
+        4577-4610, Section 7.2, Proposition 4).
+     """
+-    def __init__(self, pari_result, P, Q, minimal_equation, minimal_disc,
+-                 local_data, conductor, prime_to_2_conductor_only):
++    def __init__(self, pari_result, P, Q, Pmin, Qmin, minimal_disc,
++                 local_data, conductor):
+         self.pari_result = pari_result
+         self.P = P
+         self.Q = Q
+-        self.minimal_equation = minimal_equation
++        self.Pmin = Pmin
++        self.Qmin = Qmin
+         self.minimal_disc = minimal_disc
+         self.local_data = local_data
+         self.conductor = conductor
+-        self.prime_to_2_conductor_only = prime_to_2_conductor_only
+ 
+     def _repr_(self):
+-        if self.prime_to_2_conductor_only:
+-            ex = ' (away from 2)'
+-        else:
+-            ex = ''
+         if self.Q == 0:
+             yterm = ''
+         else:
+             yterm = '+ (%s)*y '%self.Q
++
+         s = 'Reduction data about this proper smooth genus 2 curve:\n'
+         s += '\ty^2 %s= %s\n'%(yterm, self.P)
+-        s += 'A Minimal Equation (away from 2):\n\ty^2 = %s\n'%self.minimal_equation
+-        s += 'Minimal Discriminant (away from 2):  %s\n'%self.minimal_disc
+-        s += 'Conductor%s: %s\n'%(ex, self.conductor)
++        if self.Qmin:
++            s += 'A Minimal Equation:\n\ty^2 + (%s)y = %s\n'%(self.Qmin, self.Pmin)
++        else:
++            s += 'A Minimal Equation:\n\ty^2 = %s\n'%self.Pmin
++        s += 'Minimal Discriminant: %s\n'%self.minimal_disc
++        s += 'Conductor: %s\n'%self.conductor
+         s += 'Local Data:\n%s'%self._local_data_str()
+         return s
+ 
+@@ -242,17 +242,7 @@ class Genus2reduction(SageObject):
+         sage: factor(R.conductor)
+         5^4 * 2267
+ 
+-    This means that only the odd part of the conductor is known.
+-
+-    ::
+-
+-        sage: R.prime_to_2_conductor_only
+-        True
+-
+-    The discriminant is always minimal away from 2, but possibly not at
+-    2.
+-
+-    ::
++    The discriminant is always minimal::
+ 
+         sage: factor(R.minimal_disc)
+         2^3 * 5^5 * 2267
+@@ -264,10 +254,10 @@ class Genus2reduction(SageObject):
+         sage: R
+         Reduction data about this proper smooth genus 2 curve:
+             y^2 + (x^3 - 2*x^2 - 2*x + 1)*y = -5*x^5
+-        A Minimal Equation (away from 2):
+-            y^2 = x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855
+-        Minimal Discriminant (away from 2):  56675000
+-        Conductor (away from 2): 1416875
++        A Minimal Equation:
++            y^2 ...
++        Minimal Discriminant: 56675000
++        Conductor: 1416875
+         Local Data:
+             p=2
+             (potential) stable reduction:  (II), j=1
+@@ -293,10 +283,10 @@ class Genus2reduction(SageObject):
+         sage: genus2reduction(0, x^6 + 3*x^3 + 63)
+         Reduction data about this proper smooth genus 2 curve:
+                 y^2 = x^6 + 3*x^3 + 63
+-        A Minimal Equation (away from 2):
+-                y^2 = x^6 + 3*x^3 + 63
+-        Minimal Discriminant (away from 2):  10628388316852992
+-        Conductor (away from 2): 2893401
++        A Minimal Equation:
++                y^2 ...
++        Minimal Discriminant: -10628388316852992
++        Conductor: 2893401
+         Local Data:
+                 p=2
+                 (potential) stable reduction:  (V), j1+j2=0, j1*j2=0
+@@ -327,9 +317,9 @@ class Genus2reduction(SageObject):
+         sage: genus2reduction(x^3-x^2-1, x^2 - x)
+         Reduction data about this proper smooth genus 2 curve:
+                 y^2 + (x^3 - x^2 - 1)*y = x^2 - x
+-        A Minimal Equation (away from 2):
+-                y^2 = x^6 + 58*x^5 + 1401*x^4 + 18038*x^3 + 130546*x^2 + 503516*x + 808561
+-        Minimal Discriminant (away from 2):  169
++        A Minimal Equation:
++                y^2 ...
++        Minimal Discriminant: -169
+         Conductor: 169
+         Local Data:
+                 p=13
+@@ -370,10 +360,10 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^3 - 2*x^2 - 2*x + 1, -5*x^5)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^3 - 2*x^2 - 2*x + 1)*y = -5*x^5
+-            A Minimal Equation (away from 2):
+-                    y^2 = x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855
+-            Minimal Discriminant (away from 2):  56675000
+-            Conductor (away from 2): 1416875
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 56675000
++            Conductor: 1416875
+             Local Data:
+                     p=2
+                     (potential) stable reduction:  (II), j=1
+@@ -389,9 +379,9 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^2 + 1, -5*x^5)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^2 + 1)*y = -5*x^5
+-            A Minimal Equation (away from 2):
+-                    y^2 = -20*x^5 + x^4 + 2*x^2 + 1
+-            Minimal Discriminant (away from 2):  48838125
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 48838125
+             Conductor: 32025
+             Local Data:
+                     p=3
+@@ -412,9 +402,9 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^3 + x^2 + x,-2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^3 + x^2 + x)*y = -2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2
+-            A Minimal Equation (away from 2):
+-                    y^2 = x^6 + 18*x^3 + 36*x^2 - 27
+-            Minimal Discriminant (away from 2):  1520984142
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 1520984142
+             Conductor: 954
+             Local Data:
+                     p=2
+@@ -436,18 +426,10 @@ class Genus2reduction(SageObject):
+             raise ValueError("Q (=%s) must have degree at most 3" % Q)
+ 
+         res = pari.genus2red([P, Q])
+-
+         conductor = ZZ(res[0])
+-        minimal_equation = R(res[2])
+-
+-        minimal_disc = QQ(res[2].poldisc()).abs()
+-        if minimal_equation.degree() == 5:
+-            minimal_disc *= minimal_equation[5]**2
+-        # Multiply with suitable power of 2 of the form 2^(2*(d-1) - 12)
+-        b = 2 * (minimal_equation.degree() - 1)
+-        k = QQ((12 - minimal_disc.valuation(2), b)).ceil()
+-        minimal_disc >>= 12 - b*k
+-        minimal_disc = ZZ(minimal_disc)
++        Pmin = R(res[2][0])
++        Qmin = R(res[2][1])
++        minimal_disc = ZZ(pari.hyperelldisc(res[2]))
+ 
+         local_data = {}
+         for red in res[3]:
+@@ -468,9 +450,7 @@ class Genus2reduction(SageObject):
+ 
+             local_data[p] = data
+ 
+-        prime_to_2_conductor_only = (-1 in res[1].component(2))
+-        return ReductionData(res, P, Q, minimal_equation, minimal_disc, local_data,
+-                             conductor, prime_to_2_conductor_only)
++        return ReductionData(res, P, Q, Pmin, Qmin, minimal_disc, local_data, conductor)
+ 
+     def __reduce__(self):
+         return _reduce_load_genus2reduction, tuple([])
+diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
+index fec450d7bc..236402c293 100644
+--- a/src/sage/lfunctions/dokchitser.py
++++ b/src/sage/lfunctions/dokchitser.py
+@@ -337,6 +337,7 @@ class Dokchitser(SageObject):
+             # After init_coeffs is called, future calls to this method should
+             # return the full output for further parsing
+             raise RuntimeError("unable to create L-series, due to precision or other limits in PARI")
++        t = t.replace("  *** _^_: Warning: normalizing a series with 0 leading term.\n", "")
+         return t
+ 
+     def __check_init(self):
+diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
+index d2b20f1891..6c31efe239 100644
+--- a/src/sage/lfunctions/pari.py
++++ b/src/sage/lfunctions/pari.py
+@@ -339,7 +339,7 @@ def lfun_eta_quotient(scalings, exponents):
+         0.0374412812685155
+ 
+         sage: lfun_eta_quotient([6],[4])
+-        [[Vecsmall([7]), [Vecsmall([6]), Vecsmall([4])]], 0, [0, 1], 2, 36, 1]
++        [[Vecsmall([7]), [Vecsmall([6]), Vecsmall([4]), 0]], 0, [0, 1], 2, 36, 1]
+ 
+         sage: lfun_eta_quotient([2,1,4], [5,-2,-2])
+         Traceback (most recent call last):
+diff --git a/src/sage/libs/pari/tests.py b/src/sage/libs/pari/tests.py
+index e5a2aa2517..0efcb15de0 100644
+--- a/src/sage/libs/pari/tests.py
++++ b/src/sage/libs/pari/tests.py
+@@ -356,7 +356,7 @@ Constructors::
+     [2, 4]~*x + [1, 3]~
+ 
+     sage: pari(3).Qfb(7, 1)
+-    Qfb(3, 7, 1, 0.E-19)
++    Qfb(3, 7, 1)
+     sage: pari(3).Qfb(7, 2)
+     Traceback (most recent call last):
+     ...
+@@ -512,7 +512,7 @@ Basic functions::
+     sage: pari('sqrt(-2)').frac()
+     Traceback (most recent call last):
+     ...
+-    PariError: incorrect type in gfloor (t_COMPLEX)
++    PariError: incorrect type in gfrac (t_COMPLEX)
+ 
+     sage: pari('1+2*I').imag()
+     2
+diff --git a/src/sage/modular/cusps_nf.py b/src/sage/modular/cusps_nf.py
+index 25d93cac92..157ebabe29 100644
+--- a/src/sage/modular/cusps_nf.py
++++ b/src/sage/modular/cusps_nf.py
+@@ -1220,7 +1220,7 @@ def units_mod_ideal(I):
+         sage: I = k.ideal(5, a + 1)
+         sage: units_mod_ideal(I)
+         [1,
+-        2*a^2 + 4*a - 1,
++        -2*a^2 - 4*a + 1,
+         ...]
+ 
+     ::
+diff --git a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
+index a881336596..090d1bfaf0 100644
+--- a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
++++ b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
+@@ -43,7 +43,7 @@ def coerce_AA(p):
+         sage: AA(p)._exact_field()
+         Number Field in a with defining polynomial y^8 ... with a in ...
+         sage: coerce_AA(p)._exact_field()
+-        Number Field in a with defining polynomial y^4 - 1910*y^2 - 3924*y + 681058 with a in 39.710518724...?
++        Number Field in a with defining polynomial y^4 - 1910*y^2 - 3924*y + 681058 with a in ...?
+     """
+     el = AA(p)
+     el.simplify()
+diff --git a/src/sage/modular/modsym/p1list_nf.py b/src/sage/modular/modsym/p1list_nf.py
+index 222caacca8..f9d969732c 100644
+--- a/src/sage/modular/modsym/p1list_nf.py
++++ b/src/sage/modular/modsym/p1list_nf.py
+@@ -58,7 +58,7 @@ Lift an MSymbol to a matrix in `SL(2, R)`:
+ 
+     sage: alpha = MSymbol(N, a + 2, 3*a^2)
+     sage: alpha.lift_to_sl2_Ok()
+-    [-3*a^2 + a + 12, 25*a^2 - 50*a + 100, a + 2, a^2 - 3*a + 3]
++    [-1, 4*a^2 - 13*a + 23, a + 2, 5*a^2 + 3*a - 3]
+     sage: Ok = k.ring_of_integers()
+     sage: M = Matrix(Ok, 2, alpha.lift_to_sl2_Ok())
+     sage: det(M)
+@@ -945,11 +945,11 @@ class P1NFList(SageObject):
+             sage: N = k.ideal(5, a + 1)
+             sage: P = P1NFList(N)
+             sage: u = k.unit_group().gens_values(); u
+-            [-1, 2*a^2 + 4*a - 1]
++            [-1, -2*a^2 - 4*a + 1]
+             sage: P.apply_J_epsilon(4, -1)
+             2
+             sage: P.apply_J_epsilon(4, u[0], u[1])
+-            1
++            5
+ 
+         ::
+ 
+diff --git a/src/sage/modules/free_quadratic_module_integer_symmetric.py b/src/sage/modules/free_quadratic_module_integer_symmetric.py
+index a206f0c721..aeb19ab669 100644
+--- a/src/sage/modules/free_quadratic_module_integer_symmetric.py
++++ b/src/sage/modules/free_quadratic_module_integer_symmetric.py
+@@ -1168,11 +1168,11 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+             sage: A4 = IntegralLattice("A4")
+             sage: Aut = A4.orthogonal_group()
+             sage: Aut
+-            Group of isometries with 5 generators (
+-            [-1  0  0  0]  [0 0 0 1]  [-1 -1 -1  0]  [ 1  0  0  0]  [ 1  0  0  0]
+-            [ 0 -1  0  0]  [0 0 1 0]  [ 0  0  0 -1]  [-1 -1 -1 -1]  [ 0  1  0  0]
+-            [ 0  0 -1  0]  [0 1 0 0]  [ 0  0  1  1]  [ 0  0  0  1]  [ 0  0  1  1]
+-            [ 0  0  0 -1], [1 0 0 0], [ 0  1  0  0], [ 0  0  1  0], [ 0  0  0 -1]
++            Group of isometries with 4 generators (
++            [0 0 0 1]  [-1 -1 -1  0]  [ 1  0  0  0]  [ 1  0  0  0]
++            [0 0 1 0]  [ 0  0  0 -1]  [-1 -1 -1 -1]  [ 0  1  0  0]
++            [0 1 0 0]  [ 0  0  1  1]  [ 0  0  0  1]  [ 0  0  1  1]
++            [1 0 0 0], [ 0  1  0  0], [ 0  0  1  0], [ 0  0  0 -1]
+             )
+ 
+         The group acts from the right on the lattice and its discriminant group::
+@@ -1180,19 +1180,19 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+             sage: x = A4.an_element()
+             sage: g = Aut.an_element()
+             sage: g
+-            [ 1  1  1  0]
+-            [ 0  0 -1  0]
+-            [ 0  0  1  1]
+-            [ 0 -1 -1 -1]
++            [-1 -1 -1  0]
++            [ 0  0  1  0]
++            [ 0  0 -1 -1]
++            [ 0  1  1  1]
+             sage: x*g
+-            (1, 1, 1, 0)
++            (-1, -1, -1, 0)
+             sage: (x*g).parent()==A4
+             True
+             sage: (g*x).parent()
+             Vector space of dimension 4 over Rational Field
+             sage: y = A4.discriminant_group().an_element()
+             sage: y*g
+-            (1)
++            (4)
+ 
+         If the group is finite we can compute the usual things::
+ 
+@@ -1208,10 +1208,10 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+ 
+             sage: A2 = IntegralLattice(matrix.identity(3),Matrix(ZZ,2,3,[1,-1,0,0,1,-1]))
+             sage: A2.orthogonal_group()
+-            Group of isometries with 3 generators (
+-            [-1/3  2/3  2/3]  [ 2/3  2/3 -1/3]  [1 0 0]
+-            [ 2/3 -1/3  2/3]  [ 2/3 -1/3  2/3]  [0 0 1]
+-            [ 2/3  2/3 -1/3], [-1/3  2/3  2/3], [0 1 0]
++            Group of isometries with 2 generators (
++            [ 2/3  2/3 -1/3]  [1 0 0]
++            [ 2/3 -1/3  2/3]  [0 0 1]
++            [-1/3  2/3  2/3], [0 1 0]
+             )
+ 
+         It can be negative definite as well::
+diff --git a/src/sage/quadratic_forms/binary_qf.py b/src/sage/quadratic_forms/binary_qf.py
+index cfa3ada73e..5ac823bc6c 100755
+--- a/src/sage/quadratic_forms/binary_qf.py
++++ b/src/sage/quadratic_forms/binary_qf.py
+@@ -141,7 +141,7 @@ class BinaryQF(SageObject):
+                   and a.degree() == 2 and a.parent().ngens() == 2):
+                 x, y = a.parent().gens()
+                 a, b, c = [a.monomial_coefficient(mon) for mon in [x**2, x*y, y**2]]
+-            elif isinstance(a, pari_gen) and a.type() in ('t_QFI', 't_QFR'):
++            elif isinstance(a, pari_gen) and a.type() in ('t_QFI', 't_QFR', 't_QFB'):
+                 # a has 3 or 4 components
+                 a, b, c = a[0], a[1], a[2]
+         try:
+diff --git a/src/sage/quadratic_forms/genera/genus.py b/src/sage/quadratic_forms/genera/genus.py
+index 8290b6c4fa..0fc43f33c6 100644
+--- a/src/sage/quadratic_forms/genera/genus.py
++++ b/src/sage/quadratic_forms/genera/genus.py
+@@ -3088,8 +3088,8 @@ class GenusSymbol_global_ring():
+             sage: G = Genus(matrix(ZZ, 3, [6,3,0, 3,6,0, 0,0,2]))
+             sage: G.representatives()
+             (
+-            [2 0 0]  [ 2 -1  0]
+-            [0 6 3]  [-1  2  0]
++            [2 0 0]  [ 2  1  0]
++            [0 6 3]  [ 1  2  0]
+             [0 3 6], [ 0  0 18]
+             )
+ 
+diff --git a/src/sage/quadratic_forms/qfsolve.py b/src/sage/quadratic_forms/qfsolve.py
+index ddde95e04f..d5e15d9f83 100644
+--- a/src/sage/quadratic_forms/qfsolve.py
++++ b/src/sage/quadratic_forms/qfsolve.py
+@@ -70,7 +70,7 @@ def qfsolve(G):
+ 
+         sage: M = Matrix(QQ, [[3, 0, 0, 0], [0, 5, 0, 0], [0, 0, -7, 0], [0, 0, 0, -11]])
+         sage: qfsolve(M)
+-        (3, -4, -3, -2)
++        (3, 4, -3, -2)
+     """
+     ret = G.__pari__().qfsolve()
+     if ret.type() == 't_COL':
+diff --git a/src/sage/quadratic_forms/quadratic_form__automorphisms.py b/src/sage/quadratic_forms/quadratic_form__automorphisms.py
+index c36c667e3b..3d72cf3be1 100644
+--- a/src/sage/quadratic_forms/quadratic_form__automorphisms.py
++++ b/src/sage/quadratic_forms/quadratic_form__automorphisms.py
+@@ -300,9 +300,9 @@ def automorphism_group(self):
+         sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1])
+         sage: Q.automorphism_group()
+         Matrix group over Rational Field with 3 generators (
+-        [-1  0  0]  [0 0 1]  [ 0  0  1]
+-        [ 0 -1  0]  [0 1 0]  [-1  0  0]
+-        [ 0  0 -1], [1 0 0], [ 0  1  0]
++        [ 0  0  1]  [1 0 0]  [ 1  0  0]
++        [-1  0  0]  [0 0 1]  [ 0 -1  0]
++        [ 0  1  0], [0 1 0], [ 0  0  1]
+         )
+ 
+     ::
+diff --git a/src/sage/rings/finite_rings/finite_field_prime_modn.py b/src/sage/rings/finite_rings/finite_field_prime_modn.py
+index 9129ecb56a..d5a4cb8f22 100644
+--- a/src/sage/rings/finite_rings/finite_field_prime_modn.py
++++ b/src/sage/rings/finite_rings/finite_field_prime_modn.py
+@@ -111,7 +111,7 @@ class FiniteField_prime_modn(FiniteField_generic, integer_mod_ring.IntegerModRin
+             sage: RF13 = K.residue_field(pp)
+             sage: RF13.hom([GF(13)(1)])
+             Ring morphism:
+-             From: Residue field of Fractional ideal (w + 18)
++             From: Residue field of Fractional ideal (-w - 18)
+              To:   Finite Field of size 13
+              Defn: 1 |--> 1
+ 
+diff --git a/src/sage/rings/finite_rings/residue_field.pyx b/src/sage/rings/finite_rings/residue_field.pyx
+index 7596f2a302..1e1869f1b1 100644
+--- a/src/sage/rings/finite_rings/residue_field.pyx
++++ b/src/sage/rings/finite_rings/residue_field.pyx
+@@ -20,13 +20,13 @@ monogenic (i.e., 2 is an essential discriminant divisor)::
+ 
+     sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8)
+     sage: F = K.factor(2); F
+-    (Fractional ideal (1/2*a^2 - 1/2*a + 1)) * (Fractional ideal (-a^2 + 2*a - 3)) * (Fractional ideal (-3/2*a^2 + 5/2*a - 4))
++    (Fractional ideal (-1/2*a^2 + 1/2*a - 1)) * (Fractional ideal (-a^2 + 2*a - 3)) * (Fractional ideal (3/2*a^2 - 5/2*a + 4))
+     sage: F[0][0].residue_field()
+-    Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++    Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+     sage: F[1][0].residue_field()
+     Residue field of Fractional ideal (-a^2 + 2*a - 3)
+     sage: F[2][0].residue_field()
+-    Residue field of Fractional ideal (-3/2*a^2 + 5/2*a - 4)
++    Residue field of Fractional ideal (3/2*a^2 - 5/2*a + 4)
+ 
+ We can also form residue fields from `\ZZ`::
+ 
+@@ -258,9 +258,9 @@ class ResidueFieldFactory(UniqueFactory):
+     the index of ``ZZ[a]`` in the maximal order for all ``a``::
+ 
+         sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8); P = K.ideal(2).factor()[0][0]; P
+-        Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F = K.residue_field(P); F
+-        Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F(a)
+         0
+         sage: B = K.maximal_order().basis(); B
+@@ -270,7 +270,7 @@ class ResidueFieldFactory(UniqueFactory):
+         sage: F(B[2])
+         0
+         sage: F
+-        Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F.degree()
+         1
+ 
+@@ -730,15 +730,15 @@ class ResidueField_generic(Field):
+         EXAMPLES::
+ 
+             sage: I = QQ[3^(1/3)].factor(5)[1][0]; I
+-            Fractional ideal (-a + 2)
++            Fractional ideal (a - 2)
+             sage: k = I.residue_field(); k
+-            Residue field of Fractional ideal (-a + 2)
++            Residue field of Fractional ideal (a - 2)
+             sage: f = k.lift_map(); f
+             Lifting map:
+-              From: Residue field of Fractional ideal (-a + 2)
++              From: Residue field of Fractional ideal (a - 2)
+               To:   Maximal Order in Number Field in a with defining polynomial x^3 - 3 with a = 1.442249570307409?
+             sage: f.domain()
+-            Residue field of Fractional ideal (-a + 2)
++            Residue field of Fractional ideal (a - 2)
+             sage: f.codomain()
+             Maximal Order in Number Field in a with defining polynomial x^3 - 3 with a = 1.442249570307409?
+             sage: f(k.0)
+@@ -768,7 +768,7 @@ class ResidueField_generic(Field):
+ 
+             sage: K.<a> = NumberField(x^3-11)
+             sage: F = K.ideal(37).factor(); F
+-            (Fractional ideal (37, a + 9)) * (Fractional ideal (37, a + 12)) * (Fractional ideal (2*a - 5))
++            (Fractional ideal (37, a + 9)) * (Fractional ideal (37, a + 12)) * (Fractional ideal (-2*a + 5))
+             sage: k = K.residue_field(F[0][0])
+             sage: l = K.residue_field(F[1][0])
+             sage: k == l
+@@ -846,7 +846,7 @@ cdef class ReductionMap(Map):
+             sage: F.reduction_map()
+             Partially defined reduction map:
+               From: Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
+-              To:   Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++              To:   Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+ 
+             sage: K.<theta_5> = CyclotomicField(5)
+             sage: F = K.factor(7)[0][0].residue_field()
+diff --git a/src/sage/rings/number_field/S_unit_solver.py b/src/sage/rings/number_field/S_unit_solver.py
+index e99dff850f..759cbfb334 100644
+--- a/src/sage/rings/number_field/S_unit_solver.py
++++ b/src/sage/rings/number_field/S_unit_solver.py
+@@ -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 (xi - 3),
+-         Fractional ideal (-2*xi^2 + 3),
++        (Fractional ideal (-2*xi^2 + 3),
++         Fractional ideal (-xi + 3),
+          Fractional ideal (2*xi + 1))
+ 
+         sage: sieve_data[1]
+-        (Residue field of Fractional ideal (xi - 3),
+-         Residue field of Fractional ideal (-2*xi^2 + 3),
++        (Residue field of Fractional ideal (-2*xi^2 + 3),
++         Residue field of Fractional ideal (-xi + 3),
+          Residue field of Fractional ideal (2*xi + 1))
+ 
+         sage: sieve_data[2]
+-        ([18, 7, 16, 4], [18, 9, 12, 8], [18, 3, 10, 10])
++        ([18, 12, 16, 8], [18, 16, 10, 4], [18, 10, 12, 10])
+ 
+         sage: sieve_data[3]
+-        (486, 648, 11664)
++        (648, 2916, 3888)
+     """
+ 
+     K = SUK.number_field()
+diff --git a/src/sage/rings/number_field/bdd_height.py b/src/sage/rings/number_field/bdd_height.py
+index beb047ae02..b7c8c33d0b 100644
+--- a/src/sage/rings/number_field/bdd_height.py
++++ b/src/sage/rings/number_field/bdd_height.py
+@@ -248,7 +248,7 @@ def bdd_norm_pr_ideal_gens(K, norm_list):
+         sage: from sage.rings.number_field.bdd_height import bdd_norm_pr_ideal_gens
+         sage: K.<g> = QuadraticField(123)
+         sage: bdd_norm_pr_ideal_gens(K, range(5))
+-        {0: [0], 1: [1], 2: [-g - 11], 3: [], 4: [2]}
++        {0: [0], 1: [1], 2: [g + 11], 3: [], 4: [2]}
+ 
+     ::
+ 
+diff --git a/src/sage/rings/number_field/class_group.py b/src/sage/rings/number_field/class_group.py
+index 018ff5f5c6..73c0462cd1 100644
+--- a/src/sage/rings/number_field/class_group.py
++++ b/src/sage/rings/number_field/class_group.py
+@@ -221,11 +221,11 @@ class FractionalIdealClass(AbelianGroupWithValuesElement):
+             Class group of order 76 with structure C38 x C2
+             of Number Field in a with defining polynomial x^2 + 20072
+             sage: I = (G.0)^11; I
+-            Fractional ideal class (41, 1/2*a + 5)
++            Fractional ideal class (33, 1/2*a + 8)
+             sage: J = G(I.ideal()^5); J
+-            Fractional ideal class (115856201, 1/2*a + 40407883)
++            Fractional ideal class (39135393, 1/2*a + 13654253)
+             sage: J.reduce()
+-            Fractional ideal class (57, 1/2*a + 44)
++            Fractional ideal class (73, 1/2*a + 47)
+             sage: J == I^5
+             True
+         """
+diff --git a/src/sage/rings/number_field/galois_group.py b/src/sage/rings/number_field/galois_group.py
+index 79acd053bb..e060148e4d 100644
+--- a/src/sage/rings/number_field/galois_group.py
++++ b/src/sage/rings/number_field/galois_group.py
+@@ -944,7 +944,7 @@ class GaloisGroup_v2(GaloisGroup_perm):
+             sage: K.<b> = NumberField(x^4 - 2*x^2 + 2, 'a').galois_closure()
+             sage: G = K.galois_group()
+             sage: [G.artin_symbol(P) for P in K.primes_above(7)]
+-            [(1,5)(2,6)(3,7)(4,8), (1,5)(2,6)(3,7)(4,8), (1,4)(2,3)(5,8)(6,7), (1,4)(2,3)(5,8)(6,7)]
++            [(1,4)(2,3)(5,8)(6,7), (1,4)(2,3)(5,8)(6,7), (1,5)(2,6)(3,7)(4,8), (1,5)(2,6)(3,7)(4,8)]
+             sage: G.artin_symbol(17)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
+index 58463d570d..ff65634e99 100644
+--- a/src/sage/rings/number_field/number_field.py
++++ b/src/sage/rings/number_field/number_field.py
+@@ -3643,7 +3643,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
+ 
+@@ -4227,7 +4227,8 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             (y^2 + 6, Mod(1/6*y, y^2 + 6), Mod(6*y, y^2 + 1/6))
+         """
+         f = self.absolute_polynomial()._pari_with_name('y')
+-        if f.pollead() == f.content().denominator() == 1:
++        f = f * f.content().denominator()
++        if f.pollead() == 1:
+             g = f
+             alpha = beta = g.variable().Mod(g)
+         else:
+@@ -4821,7 +4822,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+ 
+             sage: K.<a> = NumberField(2*x^2 - 1/3)
+             sage: K._S_class_group_and_units(tuple(K.primes_above(2) + K.primes_above(3)))
+-            ([-6*a + 2, 6*a + 3, -1, 12*a + 5], [])
++            ([6*a + 2, 6*a + 3, -1, -12*a + 5], [])
+         """
+         K_pari = self.pari_bnf(proof=proof)
+         S_pari = [p.pari_prime() for p in sorted(set(S))]
+@@ -5166,7 +5167,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+ 
+             sage: [K.ideal(g).factor() for g in gens]
+             [(Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1)),
+-            Fractional ideal (-a),
++            Fractional ideal (a),
+             (Fractional ideal (2, a + 1))^2,
+             1]
+ 
+@@ -5751,7 +5752,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: K.elements_of_norm(3)
+             []
+             sage: K.elements_of_norm(50)
+-            [-7*a + 1, 5*a - 5, 7*a + 1]
++            [-a - 7, 5*a - 5, 7*a + 1]
+ 
+         TESTS:
+ 
+@@ -5863,7 +5864,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: K.factor(1+a)
+             Fractional ideal (a + 1)
+             sage: K.factor(1+a/5)
+-            (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1 * (Fractional ideal (-3*a - 2))
++            (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1 * (Fractional ideal (-2*a + 3))
+ 
+         An example over a relative number field::
+ 
+@@ -6460,9 +6461,9 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: new_basis = k.reduced_basis(prec=120)
+             sage: [c.minpoly() for c in new_basis]
+             [x - 1,
+-             x^2 - x + 1,
++             x^2 + x + 1,
++             x^6 + 3*x^5 - 102*x^4 - 103*x^3 + 10572*x^2 - 59919*x + 127657,
+              x^6 + 3*x^5 - 102*x^4 - 103*x^3 + 10572*x^2 - 59919*x + 127657,
+-             x^6 - 3*x^5 - 102*x^4 + 315*x^3 + 10254*x^2 - 80955*x + 198147,
+              x^3 - 171*x + 848,
+              x^6 + 171*x^4 + 1696*x^3 + 29241*x^2 + 145008*x + 719104]
+             sage: R = k.order(new_basis)
+@@ -7058,7 +7059,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+              -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)
++             2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7)
+ 
+         TESTS:
+ 
+@@ -7067,7 +7068,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)
+ 
+@@ -7146,7 +7147,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^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]
++            [-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, 2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7]
+         """
+         proof = proof_flag(proof)
+ 
+diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx
+index 784c239dc1..aa740069dc 100644
+--- a/src/sage/rings/number_field/number_field_element.pyx
++++ b/src/sage/rings/number_field/number_field_element.pyx
+@@ -4446,7 +4446,7 @@ cdef class NumberFieldElement(FieldElement):
+             sage: f = Qi.embeddings(K)[0]
+             sage: a = f(2+3*i) * (2-zeta)^2
+             sage: a.descend_mod_power(Qi,2)
+-            [-3*i - 2, -2*i + 3]
++            [-2*i + 3, 3*i + 2]
+ 
+         An absolute example::
+ 
+@@ -5124,7 +5124,7 @@ cdef class NumberFieldElement_relative(NumberFieldElement):
+         EXAMPLES::
+ 
+             sage: K.<a, b, c> = NumberField([x^2 - 2, x^2 - 3, x^2 - 5])
+-            sage: P = K.prime_factors(5)[0]
++            sage: P = K.prime_factors(5)[1]
+             sage: (2*a + b - c).valuation(P)
+             1
+         """
+diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
+index 5f587556a4..33481fead0 100644
+--- a/src/sage/rings/number_field/number_field_ideal.py
++++ b/src/sage/rings/number_field/number_field_ideal.py
+@@ -3355,7 +3355,7 @@ def quotient_char_p(I, p):
+         []
+ 
+         sage: I = K.factor(13)[0][0]; I
+-        Fractional ideal (-3*i - 2)
++        Fractional ideal (-2*i + 3)
+         sage: I.residue_class_degree()
+         1
+         sage: quotient_char_p(I, 13)[0]
+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 bae36d4b9c..f64bd5b761 100644
+--- a/src/sage/rings/number_field/number_field_ideal_rel.py
++++ b/src/sage/rings/number_field/number_field_ideal_rel.py
+@@ -272,7 +272,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.gens_reduced()
+-            (2, 15*a*b + 3*a + 1)
++            (2, -15*a*b + 3*a + 1)
+         """
+         try:
+             # Compute the single generator, if it exists
+@@ -401,7 +401,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.relative_norm()
+-            Fractional ideal (-6*a + 2)
++            Fractional ideal (6*a + 2)
+         """
+         L = self.number_field()
+         K = L.base_field()
+@@ -518,7 +518,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.ideal_below()
+-            Fractional ideal (-6*a + 2)
++            Fractional ideal (6*a + 2)
+         """
+         L = self.number_field()
+         K = L.base_field()
+diff --git a/src/sage/rings/number_field/number_field_rel.py b/src/sage/rings/number_field/number_field_rel.py
+index d33980c4b1..50e846b205 100644
+--- a/src/sage/rings/number_field/number_field_rel.py
++++ b/src/sage/rings/number_field/number_field_rel.py
+@@ -213,14 +213,14 @@ class NumberField_relative(NumberField_generic):
+             sage: l.<b> = k.extension(5*x^2 + 3); l
+             Number Field in b with defining polynomial 5*x^2 + 3 over its base field
+             sage: l.pari_rnf()
+-            [x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4), ..., y^4 + 6*y^2 + 1, x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4)], [0, 0]]
++            [x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4), ..., y^4 + 6*y^2 + 1, x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4)], [0, 0]]
+             sage: b
+             b
+ 
+             sage: l.<b> = k.extension(x^2 + 3/5); l
+             Number Field in b with defining polynomial x^2 + 3/5 over its base field
+             sage: l.pari_rnf()
+-            [x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4), ..., y^4 + 6*y^2 + 1, x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4)], [0, 0]]
++            [x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4), ..., y^4 + 6*y^2 + 1, x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4)], [0, 0]]
+             sage: b
+             b
+ 
+diff --git a/src/sage/rings/number_field/order.py b/src/sage/rings/number_field/order.py
+index 6eca89ed8d..78ef4c3b33 100644
+--- a/src/sage/rings/number_field/order.py
++++ b/src/sage/rings/number_field/order.py
+@@ -520,7 +520,7 @@ class Order(IntegralDomain, sage.rings.abc.Order):
+             sage: k.<a> = NumberField(x^2 + 5077); G = k.class_group(); G
+             Class group of order 22 with structure C22 of Number Field in a with defining polynomial x^2 + 5077
+             sage: G.0 ^ -9
+-            Fractional ideal class (11, a + 7)
++            Fractional ideal class (43, a + 13)
+             sage: Ok = k.maximal_order(); Ok
+             Maximal Order in Number Field in a with defining polynomial x^2 + 5077
+             sage: Ok * (11, a + 7)
+diff --git a/src/sage/rings/number_field/selmer_group.py b/src/sage/rings/number_field/selmer_group.py
+index c534aaa9f6..6bc67565d2 100644
+--- a/src/sage/rings/number_field/selmer_group.py
++++ b/src/sage/rings/number_field/selmer_group.py
+@@ -491,7 +491,7 @@ def pSelmerGroup(K, S, p, proof=None, debug=False):
+ 
+         sage: [K.ideal(g).factor() for g in gens]
+         [(Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1)),
+-        Fractional ideal (-a),
++        Fractional ideal (a),
+         (Fractional ideal (2, a + 1))^2,
+         1]
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
+index bb5d8356be..8a7e5fa66f 100644
+--- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
++++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
+@@ -1791,7 +1791,7 @@ class PolynomialQuotientRing_generic(CommutativeRing):
+             sage: D.selmer_generators([K.ideal(2, -a+1), K.ideal(3, a+1)], 3)
+             [2, a + 1]
+             sage: D.selmer_generators([K.ideal(2, -a+1), K.ideal(3, a+1), K.ideal(a)], 3)
+-            [2, a + 1, a]
++            [2, a + 1, -a]
+ 
+         """
+         fields, isos, iso_classes = self._S_decomposition(tuple(S))
+diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py
+index 704b77ce5f..83ee4549e4 100644
+--- a/src/sage/rings/qqbar.py
++++ b/src/sage/rings/qqbar.py
+@@ -312,8 +312,8 @@ and we get a way to produce the number directly::
+     True
+     sage: sage_input(n)
+     R.<y> = QQ[]
+-    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(RR(0.51763809020504148), RR(0.51763809020504159)))
+-    -109*v^3 - 89*v^2 + 327*v + 178
++    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(-RR(1.9318516525781366), -RR(1.9318516525781364)))
++    -109*v^3 + 89*v^2 + 327*v - 178
+ 
+ We can also see that some computations (basically, those which are
+ easy to perform exactly) are performed directly, instead of storing
+@@ -362,7 +362,7 @@ algorithms in :trac:`10255`::
+     # Verified
+     R1.<x> = QQbar[]
+     R2.<y> = QQ[]
+-    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(RR(0.51763809020504148), RR(0.51763809020504159)))
++    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(-RR(1.9318516525781366), -RR(1.9318516525781364)))
+     AA.polynomial_root(AA.common_polynomial(x^4 + QQbar(v^3 - 3*v - 1)*x^3 + QQbar(-v^3 + 3*v - 3)*x^2 + QQbar(-3*v^3 + 9*v + 3)*x + QQbar(3*v^3 - 9*v)), RIF(RR(0.99999999999999989), RR(1.0000000000000002)))
+     sage: one
+     1
+@@ -2310,7 +2310,7 @@ def do_polred(poly, threshold=32):
+     cost = 2 * bitsize.nbits() + 5 * poly.degree().nbits()
+     if cost > threshold:
+         return parent.gen(), parent.gen(), poly
+-    new_poly, elt_back = poly.__pari__().polredbest(flag=1)
++    new_poly, elt_back = poly.numerator().__pari__().polredbest(flag=1)
+     elt_fwd = elt_back.modreverse()
+     return parent(elt_fwd.lift()), parent(elt_back.lift()), parent(new_poly)
+ 
+@@ -2542,10 +2542,10 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+            Defn: a |--> 1.414213562373095?)
+ 
+         sage: number_field_elements_from_algebraics((rt2,rt3))
+-        (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, [-a^3 + 3*a, -a^2 + 2], Ring morphism:
++        (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, [-a^3 + 3*a, a^2 - 2], Ring morphism:
+             From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+             To:   Algebraic Real Field
+-            Defn: a |--> 0.5176380902050415?)
++            Defn: a |--> -1.931851652578137?)
+ 
+     ``rt3a`` is a real number in ``QQbar``.  Ordinarily, we'd get a homomorphism
+     to ``AA`` (because all elements are real), but if we specify ``same_field=True``,
+@@ -2570,7 +2570,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, -a^3 + 3*a, Ring morphism:
+             From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+             To:   Algebraic Real Field
+-            Defn: a |--> 0.5176380902050415?)
++            Defn: a |--> -1.931851652578137?)
+ 
+     We can specify ``minimal=True`` if we want the smallest number field::
+ 
+@@ -2618,7 +2618,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         sage: nfI^2
+         -1
+         sage: sum = nfrt2 + nfrt3 + nfI + nfz3; sum
+-        2*a^6 + a^5 - a^4 - a^3 - 2*a^2 - a
++        a^5 + a^4 - a^3 + 2*a^2 - a - 1
+         sage: hom(sum)
+         2.646264369941973? + 1.866025403784439?*I
+         sage: hom(sum) == rt2 + rt3 + qqI + z3
+@@ -2658,7 +2658,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         sage: nf, nums, hom = number_field_elements_from_algebraics(elems, embedded=True)
+         sage: nf
+         Number Field in a with defining polynomial y^24 - 6*y^23 ...- 9*y^2 + 1
+-          with a = 0.2598678911433438? + 0.0572892247058457?*I
++          with a = 0.2598679? + 0.0572892?*I
+         sage: list(map(QQbar, nums)) == elems == list(map(hom, nums))
+         True
+ 
+@@ -2725,7 +2725,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+                          sqrt(2), AA.polynomial_root(x^3-3, RIF(0,3)), 11/9, 1]
+         sage: res = number_field_elements_from_algebraics(my_nums, embedded=True)
+         sage: res[0]
+-        Number Field in a with defining polynomial y^24 - 107010*y^22 - 24*y^21 + ... + 250678447193040618624307096815048024318853254384 with a = -95.5053039433554?
++        Number Field in a with defining polynomial y^24 - 107010*y^22 - 24*y^21 + ... + 250678447193040618624307096815048024318853254384 with a = 93.32530798172420?
+     """
+     gen = qq_generator
+ 
+@@ -3129,7 +3129,7 @@ class AlgebraicGenerator(SageObject):
+             sage: root = ANRoot(x^2 - x - 1, RIF(1, 2))
+             sage: gen = AlgebraicGenerator(nf, root)
+             sage: gen.pari_field()
+-             [y^2 - y - 1, [2, 0], ...]
++            [[y^2 - y - 1, [2, 0], ...]
+         """
+         if self.is_trivial():
+             raise ValueError("No PARI field attached to trivial generator")
+@@ -3213,7 +3213,7 @@ class AlgebraicGenerator(SageObject):
+             sage: qq_generator.union(gen3) is gen3
+             True
+             sage: gen2.union(gen3)
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+         """
+         if self._trivial:
+             return other
+@@ -3306,13 +3306,13 @@ class AlgebraicGenerator(SageObject):
+             Number Field in a with defining polynomial y^2 - 3 with a in 1.732050807568878?
+             sage: gen2_3 = gen2.union(gen3)
+             sage: gen2_3
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+             sage: qq_generator.super_poly(gen2) is None
+             True
+             sage: gen2.super_poly(gen2_3)
+             -a^3 + 3*a
+             sage: gen3.super_poly(gen2_3)
+-            -a^2 + 2
++            a^2 - 2
+ 
+         """
+         if checked is None:
+@@ -3360,13 +3360,13 @@ class AlgebraicGenerator(SageObject):
+             sage: sqrt3 = ANExtensionElement(gen3, nf3.gen())
+             sage: gen2_3 = gen2.union(gen3)
+             sage: gen2_3
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+             sage: gen2_3(sqrt2)
+             -a^3 + 3*a
+             sage: gen2_3(ANRational(1/7))
+             1/7
+             sage: gen2_3(sqrt3)
+-            -a^2 + 2
++            a^2 - 2
+         """
+         if self._trivial:
+             return elt._value
+@@ -4336,10 +4336,10 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: rt3 = AA(sqrt(3))
+             sage: rt3b = rt2 + rt3 - rt2
+             sage: rt3b.as_number_field_element()
+-            (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, -a^2 + 2, Ring morphism:
++            (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, a^2 - 2, Ring morphism:
+                 From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+                 To:   Algebraic Real Field
+-                Defn: a |--> 0.5176380902050415?)
++                Defn: a |--> -1.931851652578137?)
+             sage: rt3b.as_number_field_element(minimal=True)
+             (Number Field in a with defining polynomial y^2 - 3, a, Ring morphism:
+                From: Number Field in a with defining polynomial y^2 - 3
+@@ -4401,7 +4401,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: rt2b = rt3 + rt2 - rt3
+             sage: rt2b.exactify()
+             sage: rt2b._exact_value()
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b.simplify()
+             sage: rt2b._exact_value()
+             a where a^2 - 2 = 0 and a in 1.414213562373095?
+@@ -4422,7 +4422,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: QQbar(2)._exact_field()
+             Trivial generator
+             sage: (sqrt(QQbar(2)) + sqrt(QQbar(19)))._exact_field()
+-            Number Field in a with defining polynomial y^4 - 20*y^2 + 81 with a in 2.375100220297941?
++            Number Field in a with defining polynomial y^4 - 20*y^2 + 81 with a in -3.789313782671036?
+             sage: (QQbar(7)^(3/5))._exact_field()
+             Number Field in a with defining polynomial y^5 - 2*y^4 - 18*y^3 + 38*y^2 + 82*y - 181 with a in 2.554256611698490?
+         """
+@@ -4442,7 +4442,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: QQbar(2)._exact_value()
+             2
+             sage: (sqrt(QQbar(2)) + sqrt(QQbar(19)))._exact_value()
+-            -1/9*a^3 - a^2 + 11/9*a + 10 where a^4 - 20*a^2 + 81 = 0 and a in 2.375100220297941?
++            -1/9*a^3 + a^2 + 11/9*a - 10 where a^4 - 20*a^2 + 81 = 0 and a in -3.789313782671036?
+             sage: (QQbar(7)^(3/5))._exact_value()
+             2*a^4 + 2*a^3 - 34*a^2 - 17*a + 150 where a^5 - 2*a^4 - 18*a^3 + 38*a^2 + 82*a - 181 = 0 and a in 2.554256611698490?
+         """
+@@ -6857,7 +6857,7 @@ class AlgebraicPolynomialTracker(SageObject):
+             sage: p = sqrt(AA(2)) * x^2 - sqrt(AA(3))
+             sage: cp = AA.common_polynomial(p)
+             sage: cp.generator()
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 1.931851652578137?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -0.5176380902050415?
+         """
+         self.exactify()
+         return self._gen
+@@ -7706,7 +7706,7 @@ class ANExtensionElement(ANDescr):
+ 
+             sage: rt2b.exactify()
+             sage: rt2b._descr
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b._descr.is_simple()
+             False
+         """
+@@ -7791,7 +7791,7 @@ class ANExtensionElement(ANDescr):
+             sage: rt2b = rt3 + rt2 - rt3
+             sage: rt2b.exactify()
+             sage: rt2b._descr
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b._descr.simplify(rt2b)
+             a where a^2 - 2 = 0 and a in 1.414213562373095?
+         """
+@@ -7830,9 +7830,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.neg(a)
+-            1/3*a^3 - 2/3*a^2 + 4/3*a - 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -1/3*a^3 + 1/3*a^2 - a - 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+             sage: b.neg("ham spam and eggs")
+-            1/3*a^3 - 2/3*a^2 + 4/3*a - 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -1/3*a^3 + 1/3*a^2 - a - 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+         """
+         return ANExtensionElement(self._generator, -self._value)
+ 
+@@ -7848,9 +7848,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.invert(a)
+-            7/3*a^3 - 2/3*a^2 + 4/3*a - 12 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -7/3*a^3 + 19/3*a^2 - 7*a - 9 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+             sage: b.invert("ham spam and eggs")
+-            7/3*a^3 - 2/3*a^2 + 4/3*a - 12 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -7/3*a^3 + 19/3*a^2 - 7*a - 9 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+         """
+         return ANExtensionElement(self._generator, ~self._value)
+ 
+@@ -7866,9 +7866,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.conjugate(a)
+-            -1/3*a^3 + 2/3*a^2 - 4/3*a + 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? + 1.573132184970987?*I
++            1/3*a^3 - 1/3*a^2 + a + 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? - 1.573132184970987?*I
+             sage: b.conjugate("ham spam and eggs")
+-            -1/3*a^3 + 2/3*a^2 - 4/3*a + 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? + 1.573132184970987?*I
++            1/3*a^3 - 1/3*a^2 + a + 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? - 1.573132184970987?*I
+         """
+         if self._exactly_real:
+             return self
+@@ -8501,7 +8501,7 @@ def an_binop_expr(a, b, op):
+         sage: x = an_binop_expr(a, b, operator.add); x
+         <sage.rings.qqbar.ANBinaryExpr object at ...>
+         sage: x.exactify()
+-        -6/7*a^7 + 2/7*a^6 + 71/7*a^5 - 26/7*a^4 - 125/7*a^3 + 72/7*a^2 + 43/7*a - 47/7 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in 3.12580...?
++        6/7*a^7 - 2/7*a^6 - 71/7*a^5 + 26/7*a^4 + 125/7*a^3 - 72/7*a^2 - 43/7*a + 47/7 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in -0.3199179336182997?
+ 
+         sage: a = QQbar(sqrt(2)) + QQbar(sqrt(3))
+         sage: b = QQbar(sqrt(3)) + QQbar(sqrt(5))
+@@ -8510,7 +8510,7 @@ def an_binop_expr(a, b, op):
+         sage: x = an_binop_expr(a, b, operator.mul); x
+         <sage.rings.qqbar.ANBinaryExpr object at ...>
+         sage: x.exactify()
+-        2*a^7 - a^6 - 24*a^5 + 12*a^4 + 46*a^3 - 22*a^2 - 22*a + 9 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in 3.1258...?
++        2*a^7 - a^6 - 24*a^5 + 12*a^4 + 46*a^3 - 22*a^2 - 22*a + 9 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in -0.3199179336182997?
+     """
+     return ANBinaryExpr(a, b, op)
+ 
+diff --git a/src/sage/schemes/affine/affine_morphism.py b/src/sage/schemes/affine/affine_morphism.py
+index 1c4f2dff18..32c2e47e49 100644
+--- a/src/sage/schemes/affine/affine_morphism.py
++++ b/src/sage/schemes/affine/affine_morphism.py
+@@ -1148,9 +1148,9 @@ class SchemeMorphism_polynomial_affine_space_field(SchemeMorphism_polynomial_aff
+             sage: H = End(A)
+             sage: f = H([(QQbar(sqrt(2))*x^2 + 1/QQbar(sqrt(3))) / (5*x)])
+             sage: f.reduce_base_field()
+-            Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a = 1.931851652578137?
++            Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a = ...?
+               Defn: Defined on coordinates by sending (x) to
+-                    (((a^3 - 3*a)*x^2 + (1/3*a^2 - 2/3))/(5*x))
++                    (((a^3 - 3*a)*x^2 + (-1/3*a^2 + 2/3))/(5*x))
+ 
+         ::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_field.py b/src/sage/schemes/elliptic_curves/ell_field.py
+index 68b8375dae..48f358ea6a 100644
+--- a/src/sage/schemes/elliptic_curves/ell_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_field.py
+@@ -845,7 +845,7 @@ class EllipticCurve_field(ell_generic.EllipticCurve_generic, ProjectivePlaneCurv
+             sage: E = E.base_extend(G).quadratic_twist(c); E
+             Elliptic Curve defined by y^2 = x^3 + 5*a0*x^2 + (-200*a0^2)*x + (-42000*a0^2+42000*a0+126000) over Number Field in a0 with defining polynomial x^3 - 3*x^2 + 3*x + 9
+             sage: K.<b> = E.division_field(3, simplify_all=True); K
+-            Number Field in b with defining polynomial x^12 - 10*x^10 + 55*x^8 - 60*x^6 + 75*x^4 + 1350*x^2 + 2025
++            Number Field in b with defining polynomial x^12 + 5*x^10 + 40*x^8 + 315*x^6 + 750*x^4 + 675*x^2 + 2025
+ 
+         Some higher-degree examples::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_generic.py b/src/sage/schemes/elliptic_curves/ell_generic.py
+index 926ae310ea..3bae819fb0 100644
+--- a/src/sage/schemes/elliptic_curves/ell_generic.py
++++ b/src/sage/schemes/elliptic_curves/ell_generic.py
+@@ -3324,8 +3324,8 @@ 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),
++            [0, 0, 0, Mod(1, y^2 - 2),
++            Mod(y, y^2 - 2), 0, 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;
+diff --git a/src/sage/schemes/elliptic_curves/ell_number_field.py b/src/sage/schemes/elliptic_curves/ell_number_field.py
+index edbd196090..c44c803aa8 100644
+--- a/src/sage/schemes/elliptic_curves/ell_number_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_number_field.py
+@@ -218,7 +218,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: E == loads(dumps(E))
+             True
+             sage: E.simon_two_descent()
+-            (2, 2, [(0 : 0 : 1)])
++            (2, 2, [(0 : 0 : 1), (1/18*a + 7/18 : -5/54*a - 17/54 : 1)])
+             sage: E.simon_two_descent(lim1=5, lim3=5, limtriv=10, maxprob=7, limbigprime=10)
+             (2, 2, [(-1 : 0 : 1), (-2 : -1/2*a - 1/2 : 1)])
+ 
+@@ -274,7 +274,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: E.simon_two_descent()  # long time (4s on sage.math, 2013)
+             (3,
+              3,
+-             [(5/8*zeta43_0^2 + 17/8*zeta43_0 - 9/4 : -27/16*zeta43_0^2 - 103/16*zeta43_0 + 39/8 : 1),
++             [(1/8*zeta43_0^2 - 3/8*zeta43_0 - 1/4 : -5/16*zeta43_0^2 + 7/16*zeta43_0 + 1/8 : 1),
+               (0 : 0 : 1)])
+         """
+         verbose = int(verbose)
+@@ -865,7 +865,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             Conductor exponent: 1
+             Kodaira Symbol: I1
+             Tamagawa Number: 1,
+-            Local data at Fractional ideal (-3*i - 2):
++            Local data at Fractional ideal (-2*i + 3):
+             Reduction type: bad split multiplicative
+             Local minimal model: Elliptic Curve defined by y^2 + (i+1)*x*y + y = x^3 over Number Field in i with defining polynomial x^2 + 1
+             Minimal discriminant valuation: 2
+@@ -2645,12 +2645,12 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             [-92, -23, -23]
+ 
+             sage: C.matrix()  # long time
+-            [1 2 2 4 2 4]
+-            [2 1 2 2 4 4]
+-            [2 2 1 4 4 2]
+-            [4 2 4 1 3 3]
+-            [2 4 4 3 1 3]
+-            [4 4 2 3 3 1]
++            [1 2 2 4 4 2]
++            [2 1 2 4 2 4]
++            [2 2 1 2 4 4]
++            [4 4 2 1 3 3]
++            [4 2 4 3 1 3]
++            [2 4 4 3 3 1]
+ 
+         The graph of this isogeny class has a shape which does not
+         occur over `\QQ`: a triangular prism.  Note that for curves
+@@ -2677,12 +2677,12 @@ class EllipticCurve_number_field(EllipticCurve_field):
+ 
+             sage: G = C.graph()  # long time
+             sage: G.adjacency_matrix()  # long time
+-            [0 1 1 0 1 0]
+-            [1 0 1 1 0 0]
+-            [1 1 0 0 0 1]
+-            [0 1 0 0 1 1]
+-            [1 0 0 1 0 1]
+-            [0 0 1 1 1 0]
++            [0 1 1 0 0 1]
++            [1 0 1 0 1 0]
++            [1 1 0 1 0 0]
++            [0 0 1 0 1 1]
++            [0 1 0 1 0 1]
++            [1 0 0 1 1 0]
+ 
+         To display the graph without any edge labels::
+ 
+@@ -3316,7 +3316,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: points = [E.lift_x(x) for x in xi]
+             sage: newpoints, U = E.lll_reduce(points)  # long time (35s on sage.math, 2011)
+             sage: [P[0] for P in newpoints]            # long time
+-            [6823803569166584943, 5949539878899294213, 2005024558054813068, 5864879778877955778, 23955263915878682727/4, 5922188321411938518, 5286988283823825378, 175620639884534615751/25, -11451575907286171572, 3502708072571012181, 1500143935183238709184/225, 27180522378120223419/4, -5811874164190604461581/625, 26807786527159569093, 7404442636649562303, 475656155255883588, 265757454726766017891/49, 7272142121019825303, 50628679173833693415/4, 6951643522366348968, 6842515151518070703, 111593750389650846885/16, 2607467890531740394315/9, -1829928525835506297]
++            [6823803569166584943, 5949539878899294213, 2005024558054813068, 5864879778877955778, 23955263915878682727/4, 5922188321411938518, 5286988283823825378, 11465667352242779838, -11451575907286171572, 3502708072571012181, 1500143935183238709184/225, 27180522378120223419/4, -5811874164190604461581/625, 26807786527159569093, 7041412654828066743, 475656155255883588, 265757454726766017891/49, 7272142121019825303, 50628679173833693415/4, 6951643522366348968, 6842515151518070703, 111593750389650846885/16, 2607467890531740394315/9, -1829928525835506297]
+ 
+         An example to show the explicit use of the height pairing matrix::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_rational_field.py b/src/sage/schemes/elliptic_curves/ell_rational_field.py
+index 3808822812..a75290ea35 100644
+--- a/src/sage/schemes/elliptic_curves/ell_rational_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_rational_field.py
+@@ -1827,7 +1827,7 @@ class EllipticCurve_rational_field(EllipticCurve_number_field):
+             sage: E = EllipticCurve('389a1')
+             sage: E._known_points = []  # clear cached points
+             sage: E.simon_two_descent()
+-            (2, 2, [(1 : 0 : 1), (-11/9 : 28/27 : 1)])
++            (2, 2, [(5/4 : 5/8 : 1), (-3/4 : 7/8 : 1)])
+             sage: E = EllipticCurve('5077a1')
+             sage: E.simon_two_descent()
+             (3, 3, [(1 : 0 : 1), (2 : 0 : 1), (0 : 2 : 1)])
+diff --git a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
+index 81ad295160..d484a4a18b 100644
+--- a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
++++ b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
+@@ -780,12 +780,12 @@ def deg_one_primes_iter(K, principal_only=False):
+         [Fractional ideal (2, a + 1),
+          Fractional ideal (3, a + 1),
+          Fractional ideal (3, a + 2),
+-         Fractional ideal (-a),
++         Fractional ideal (a),
+          Fractional ideal (7, a + 3),
+          Fractional ideal (7, a + 4)]
+         sage: it = deg_one_primes_iter(K, True)
+         sage: [next(it) for _ in range(6)]
+-        [Fractional ideal (-a),
++        [Fractional ideal (a),
+          Fractional ideal (-2*a + 3),
+          Fractional ideal (2*a + 3),
+          Fractional ideal (a + 6),
+diff --git a/src/sage/schemes/elliptic_curves/gp_simon.py b/src/sage/schemes/elliptic_curves/gp_simon.py
+index 28b97f34af..9f7d1b6020 100644
+--- a/src/sage/schemes/elliptic_curves/gp_simon.py
++++ b/src/sage/schemes/elliptic_curves/gp_simon.py
+@@ -56,7 +56,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+         sage: import sage.schemes.elliptic_curves.gp_simon
+         sage: E=EllipticCurve('389a1')
+         sage: sage.schemes.elliptic_curves.gp_simon.simon_two_descent(E)
+-        (2, 2, [(1 : 0 : 1), (-11/9 : 28/27 : 1)])
++        (2, 2, [(5/4 : 5/8 : 1), (-3/4 : 7/8 : 1)])
+ 
+     TESTS::
+ 
+@@ -117,7 +117,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+     # The block below mimics the defaults in Simon's scripts, and needs to be changed
+     # when these are updated.
+     if K is QQ:
+-        cmd = 'ellrank(%s, %s);' % (list(E.ainvs()), [P.__pari__() for P in known_points])
++        cmd = 'ellQ_ellrank(%s, %s);' % (list(E.ainvs()), [P.__pari__() for P in known_points])
+         if lim1 is None:
+             lim1 = 5
+         if lim3 is None:
+@@ -144,7 +144,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+     if verbose > 0:
+         print(s)
+     v = gp.eval('ans')
+-    if v=='ans': # then the call to ellrank() or bnfellrank() failed
++    if v=='ans': # then the call to ellQ_ellrank() or bnfellrank() failed
+         raise RuntimeError("An error occurred while running Simon's 2-descent program")
+     if verbose >= 2:
+         print("v = %s" % v)
+diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
+index a936deb74f..dc19254d8c 100644
+--- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
++++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
+@@ -1208,14 +1208,14 @@ def isogenies_13_0(E, minimal_models=True):
+         sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]  # long time (4s)
+         [(0,
+           0,
+-          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
++          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 + 1887439/1146978983704320*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 + 1030632647/7965131831280*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 - 43618899433/204234149520*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 2535050171/1418292705,
+           -139861295/2650795873449984*a^11 - 3455957/5664093746688*a^10 - 345310571/50976843720192*a^9 - 500530795/118001953056*a^8 - 12860048113/265504394376*a^7 - 25007420461/44250732396*a^6 + 458134176455/1416023436672*a^5 + 16701880631/9077073312*a^4 + 155941666417/9077073312*a^3 + 3499310115/378211388*a^2 - 736774863/94552847*a - 21954102381/94552847,
+-          579363345221/13763747804451840*a^11 + 371192377511/860234237778240*a^10 + 8855090365657/1146978983704320*a^9 + 5367261541663/1633873196160*a^8 + 614883554332193/15930263662560*a^7 + 30485197378483/68078049840*a^6 - 131000897588387/2450809794240*a^5 - 203628705777949/306351224280*a^4 - 1587619388190379/204234149520*a^3 + 14435069706551/11346341640*a^2 + 7537273048614/472764235*a + 89198980034806/472764235),
++          8342795944891/198197968384106496*a^11 + 8908625263589/20645621706677760*a^10 + 53130542636623/6881873902225920*a^9 + 376780111042213/114697898370432*a^8 + 614884052146333/15930263662560*a^7 + 3566768133324359/7965131831280*a^6 - 1885593809102545/35291661037056*a^5 - 2443732172026523/3676214691360*a^4 - 9525729503937541/1225404897120*a^3 + 51990274442321/40846829904*a^2 + 67834019370596/4254878115*a + 267603083706812/1418292705),
+          (0,
+           0,
+-          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
++          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 + 1887439/1146978983704320*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 + 1030632647/7965131831280*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 - 43618899433/204234149520*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 2535050171/1418292705,
+           -6465569317/1325397936724992*a^11 - 112132307/1960647835392*a^10 - 17075412917/25488421860096*a^9 - 207832519229/531008788752*a^8 - 1218275067617/265504394376*a^7 - 9513766502551/177002929584*a^6 + 4297077855437/708011718336*a^5 + 354485975837/4538536656*a^4 + 4199379308059/4538536656*a^3 - 30841577919/189105694*a^2 - 181916484042/94552847*a - 2135779171614/94552847,
+-          -132601797212627/3440936951112960*a^11 - 6212467020502021/13763747804451840*a^10 - 1515926454902497/286744745926080*a^9 - 15154913741799637/4901619588480*a^8 - 576888119803859263/15930263662560*a^7 - 86626751639648671/204234149520*a^6 + 16436657569218427/306351224280*a^5 + 1540027900265659087/2450809794240*a^4 + 375782662805915809/51058537380*a^3 - 14831920924677883/11346341640*a^2 - 7237947774817724/472764235*a - 84773764066089509/472764235)]
++          -1316873026840277/34172063514501120*a^11 - 18637401045099413/41291243413355520*a^10 - 36382234917217247/6881873902225920*a^9 - 61142238484016213/19775499719040*a^8 - 576888119306045123/15930263662560*a^7 - 3378443313906256321/7965131831280*a^6 + 326466167429333279/6084769144320*a^5 + 4620083325391594991/7352429382720*a^4 + 9018783894167184149/1225404897120*a^3 - 9206015742300283/7042556880*a^2 - 65141531411426446/4254878115*a - 254321286054666133/1418292705)]
+     """
+     if E.j_invariant()!=0:
+         raise ValueError("j-invariant must be 0.")
diff --git a/srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch b/srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch
new file mode 100644
index 000000000000..762bb2612632
--- /dev/null
+++ b/srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch
@@ -0,0 +1,29 @@
+From f0365f30834b6890313790b3845c647d0160fa6a Mon Sep 17 00:00:00 2001
+From: Vincent Delecroix <20100.delecroix@gmail.com*>
+Date: Fri, 30 Sep 2022 16:31:08 +0200
+Subject: fix doctest if fqf_orthogonal
+
+---
+ src/sage/groups/fqf_orthogonal.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/sage/groups/fqf_orthogonal.py b/src/sage/groups/fqf_orthogonal.py
+index 75de408..7fc4dbe 100644
+--- a/src/sage/groups/fqf_orthogonal.py
++++ b/src/sage/groups/fqf_orthogonal.py
+@@ -245,10 +245,10 @@ class FqfOrthogonalGroup(AbelianGroupAutomorphismGroup_subgroup):
+             sage: all(x*f==x*fbar for x in q.gens())
+             True
+             sage: L = IntegralLattice("A2").twist(3)
+-            sage: q = L.discriminant_group()
+             sage: OL = L.orthogonal_group()
++            sage: assert OL(OL.0.matrix()) == OL.0
++            sage: q = L.discriminant_group()
+             sage: Oq = q.orthogonal_group()
+-            sage: assert Oq(OL.0) == Oq(OL.0.matrix())
+             sage: assert Oq(Oq.0.matrix()) == Oq.0
+         """
+         from sage.libs.gap.element import GapElement
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch b/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
deleted file mode 100644
index 4bd6f4f4e2dc..000000000000
--- a/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
+++ /dev/null
@@ -1,670 +0,0 @@
-As produced by `git diff 9.5 9.6.beta3 -- src/sage/libs/lrcalc`
-
-diff --git a/src/sage/libs/lrcalc/lrcalc.pxd b/src/sage/libs/lrcalc/lrcalc.pxd
-deleted file mode 100644
-index 10b88db93f2..00000000000
---- a/src/sage/libs/lrcalc/lrcalc.pxd
-+++ /dev/null
-@@ -1,77 +0,0 @@
--# distutils: libraries = lrcalc
--
--cdef extern from "lrcalc/hashtab.h":
--    ctypedef struct hashtab:
--        pass
--
--    ctypedef struct hash_itr:
--        pass
--
--    ctypedef unsigned long hashkey_t
--    ctypedef int (*cmp_t) (void* a, void* b)
--    ctypedef hashkey_t (*hash_t) (void* a)
--
--    hashtab* hash_new(cmp_t cm, hash_t hsh)
--    void hash_free(hashtab *ht)
--
--    void* hash_lookup(hashtab *ht, void *key)
--    void* hash_insert(hashtab *ht, void *key, void *value)
--
--    bint hash_good(hash_itr)
--    void hash_first(hashtab* s, hash_itr itr)
--    void hash_next(hash_itr itr)
--    void* hash_key(hash_itr itr)
--    void* hash_value(hash_itr itr)
--    int hash_intvalue(hash_itr itr)
--
--cdef extern from "lrcalc/vector.h":
--    ctypedef struct vector:
--        size_t length
--        int* array
--
--    vector* v_new(int length)
--    void v_free(vector* v)
--    void v_print(vector *v)
--    int v_length(vector* v)
--    int v_elem(vector* v, int i)
--
--    ctypedef struct vecpair:
--        vector *first
--        vector *second
--
--    vector* vp_first(vecpair* vp)
--    vector* vp_second(vecpair* vp)
--
--cdef extern from "lrcalc/list.h":
--    cdef struct _list:
--        void **array
--        size_t allocated
--        size_t length
--    void l_free(_list *lst)
--
--cdef extern from "lrcalc/symfcn.h":
--    long long lrcoef_c "lrcoef"(vector* outer, vector* inner1, vector* inner2)
--    hashtab* mult_c "mult"(vector *sh1, vector *sh2, int maxrows)
--    hashtab* skew_c "skew"(vector *outer, vector *inner, int maxrows)
--    hashtab* coprod_c "coprod"(vector *part, int all)
--    void fusion_reduce_c "fusion_reduce"(hashtab* ht, int rows, int cols, int opt_zero)
--    _list *quantum_reduce_c "quantum_reduce"(hashtab* ht, int rows, int col)
--
--    ctypedef struct skewtab:
--        vector *outer
--        vector *inner
--        vector *conts
--        int maxrows
--        vector *conjugate
--        int rows
--        int cols
--        int matrix[1]
--
--    skewtab *st_new(vector *outer, vector *inner, vector *conts, int maxrows)
--    int st_next(skewtab *st)
--    void st_print(skewtab *st)
--    void st_free(skewtab *st)
--
--
--cdef extern from "lrcalc/schublib.h":
--    hashtab* mult_schubert_c "mult_schubert"(vector *sh1, vector *sh2, int rank)
-diff --git a/src/sage/libs/lrcalc/lrcalc.pyx b/src/sage/libs/lrcalc/lrcalc.py
-similarity index 60%
-rename from src/sage/libs/lrcalc/lrcalc.pyx
-rename to src/sage/libs/lrcalc/lrcalc.py
-index b591081ec4c..b541bfacd89 100644
---- a/src/sage/libs/lrcalc/lrcalc.pyx
-+++ b/src/sage/libs/lrcalc/lrcalc.py
-@@ -10,7 +10,8 @@ fusion products. All of the above are achieved by counting LR
- appropriate shape and content by iterating through them.
- Additionally, ``lrcalc`` handles products of Schubert polynomials.
- 
--The web page of ``lrcalc`` is `<http://sites.math.rutgers.edu/~asbuch/lrcalc/>`_.
-+The web page of ``lrcalc`` is
-+`<http://sites.math.rutgers.edu/~asbuch/lrcalc/>`_.
- 
- The following describes the Sage interface to this library.
- 
-@@ -36,12 +37,13 @@ Schur expansion::
-      [4, 2]: 1}
- 
- Same product, but include only partitions with at most 3 rows.  This
--corresponds to computing in the representation ring of gl(3)::
-+corresponds to computing in the representation ring of `\mathfrak{gl}(3)`::
- 
-     sage: lrcalc.mult([2,1], [2,1], 3)
-     {[2, 2, 2]: 1, [3, 2, 1]: 2, [3, 3]: 1, [4, 1, 1]: 1, [4, 2]: 1}
- 
--We can also compute the fusion product, here for sl(3) and level 2::
-+We can also compute the fusion product, here for `\mathfrak{sl}(3)`
-+and level 2::
- 
-     sage: lrcalc.mult([3,2,1], [3,2,1], 3,2)
-     {[4, 4, 4]: 1, [5, 4, 3]: 1}
-@@ -77,42 +79,38 @@ Multiply two Schubert polynomials::
-      [6, 2, 1, 4, 3, 5]: 1}
- 
- Same product, but include only permutations of 5 elements in the result.
--This corresponds to computing in the cohomology ring of Fl(5)::
-+This corresponds to computing in the cohomology ring of `Fl(5)`::
- 
-     sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3], 5)
-     {[4, 5, 1, 3, 2]: 1, [5, 3, 1, 4, 2]: 1, [5, 4, 1, 2, 3]: 1}
- 
- List all Littlewood-Richardson tableaux of skew shape `\mu/\nu`; in
- this example `\mu=[3,2,1]` and `\nu=[2,1]`. Specifying a third entry
--`maxrows` restricts the alphabet to `\{1,2,\ldots,maxrows\}`::
-+`M' = ``maxrows`` restricts the alphabet to `\{1,2,\ldots,M\}`::
- 
-     sage: list(lrcalc.lrskew([3,2,1],[2,1]))
-     [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
-     [[None, None, 1], [None, 2], [1]], [[None, None, 1], [None, 2], [3]]]
- 
-     sage: list(lrcalc.lrskew([3,2,1],[2,1],maxrows=2))
--    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]], [[None, None, 1], [None, 2], [1]]]
-+    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
-+     [[None, None, 1], [None, 2], [1]]]
- 
- .. TODO::
- 
--    use this library in the :class:`SymmetricFunctions` code, to
-+    Use this library in the :class:`SymmetricFunctions` code, to
-     make it easy to apply it to linear combinations of Schur functions.
- 
- .. SEEALSO::
- 
-     - :func:`lrcoef`
--
-     - :func:`mult`
--
-     - :func:`coprod`
--
-     - :func:`skew`
--
-     - :func:`lrskew`
--
-     - :func:`mult_schubert`
- 
--.. rubric:: Underlying algorithmic in lrcalc
-+.. RUBRIC:: Underlying algorithmic in lrcalc
- 
- Here is some additional information regarding the main low-level
- C-functions in `lrcalc`. Given two partitions ``outer`` and ``inner``
-@@ -187,180 +185,24 @@ AUTHORS:
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from sage.rings.integer cimport Integer
--from sage.structure.parent cimport Parent
- from sage.combinat.partition import _Partitions
- from sage.combinat.permutation import Permutation
--from sage.combinat.skew_tableau import SkewTableau
--
--
--cdef vector* iterable_to_vector(it):
--    """
--    Return an lrcalc vector (which is a list of integers) from a Python iterable.
--
--    TESTS::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector(Partition([3,2,1])); x   #indirect doctest
--        [3, 2, 1]
--    """
--    cdef vector* v
--    cdef list itr = list(it)
--    cdef int n = len(itr)
--    cdef int i
--    v = v_new(n)
--    for i in range(n):
--        v.array[i] = int(itr[i])
--    return v
--
--
--cdef list vector_to_list(vector *v):
--    """
--    Converts a lrcalc vector to Python list.
--
--    TESTS::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector([]); x         #indirect doctest
--        []
--    """
--    cdef int i, n
--    n = v_length(v)
--    cdef list result = [None]*n
--    for i in range(n):
--        result[i] = Integer(v_elem(v, i))
--    return result
--
--
--def test_iterable_to_vector(it):
--    """
--    A wrapper function for the cdef function ``iterable_to_vector``
--    and ``vector_to_list``, to test that they are working correctly.
-+from sage.combinat.skew_tableau import SemistandardSkewTableaux
-+from sage.combinat.skew_partition import SkewPartition
-+from sage.rings.integer import Integer
-+import lrcalc
- 
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector([3,2,1]); x
--        [3, 2, 1]
--    """
--    cdef vector *v = iterable_to_vector(it)
--    result = vector_to_list(v)
--    v_free(v)
--    return result
--
--
--cdef skewtab_to_SkewTableau(skewtab *st):
--    """
--    A wrapper function which transforms the data set ``st`` used in
--    ``lrcalc`` to a ``SkewTableau`` in Sage.
-+def _lrcalc_dict_to_sage(result):
-+    r"""
-+    Translate from lrcalc output format to Sage expected format.
- 
-     TESTS::
- 
--        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
--        sage: test_skewtab_to_SkewTableau([],[])
--        []
--    """
--    inner = vector_to_list(st.inner)
--    outer = vector_to_list(st.outer)
--    return SkewTableau(expr=[[inner[y] for y in range(len(outer))],
--                             [[st.matrix[x + y * st.cols] + 1
--                                for x in range(inner[y], outer[y])]
--                              for y in range(len(outer) - 1, -1, -1)]])
--
--
--def test_skewtab_to_SkewTableau(outer, inner):
--    """
--    A wrapper function for the cdef function ``skewtab_to_SkewTableau``
--    for testing purposes.
--
--    It constructs the first LR skew tableau of shape ``outer/inner``
--    as an ``lrcalc`` ``skewtab``, and converts it to a
--    :class:`SkewTableau`.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
--        sage: test_skewtab_to_SkewTableau([3,2,1],[])
--        [[1, 1, 1], [2, 2], [3]]
--        sage: test_skewtab_to_SkewTableau([4,3,2,1],[1,1]).pp()
--        .  1  1  1
--        .  2  2
--        1  3
--        2
--    """
--    cdef vector* o = iterable_to_vector(outer)
--    cdef vector* i = iterable_to_vector(inner+[0]*(len(outer)-len(inner)))
--    cdef skewtab* st = st_new(o, i, NULL, 0)
--    return skewtab_to_SkewTableau(st)
--
--
--cdef dict sf_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary representing a Schur function. The keys are
--    partitions and the values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
-         sage: from sage.libs.lrcalc.lrcalc import mult
--        sage: sorted(mult([1],[1]).items())        #indirect doctest
--        [([1, 1], 1), ([2], 1)]
--        sage: assert isinstance(mult([1],[1]),dict)#indirect doctest
--    """
--    cdef hash_itr itr
--    cdef dict result = {}
--    cdef list p
--    hash_first(ht, itr)
--    while hash_good(itr):
--        p = vector_to_list(<vector*> hash_key(itr))
--        result[_Partitions(p)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
--
--cdef dict schubert_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary corresponding to a Schubert polynomial whose keys
--    are permutations and whose values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import mult_schubert
--        sage: mult_schubert([3,2,1], [1,2,3])      #indirect doctest
--        {[3, 2, 1]: 1}
--    """
--    cdef hash_itr itr
--    cdef dict result = {}
--    hash_first(ht, itr)
--    while hash_good(itr):
--        p = vector_to_list(<vector*> hash_key(itr))
--        result[Permutation(p)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
--
--cdef dict vp_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary corresponding to the coproduct of a Schur function whose keys are
--    pairs of partitions and whose values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import coprod
--        sage: coprod([1])      #indirect doctest
--        {([1], []): 1}
-+        sage: mult([2,1],[3,2,1],3) # indirect doctest
-+        {[3, 3, 3]: 1, [4, 3, 2]: 2, [4, 4, 1]: 1, [5, 2, 2]: 1, [5, 3, 1]: 1}
-     """
--    cdef hash_itr itr
--    cdef vecpair* vp
--    cdef dict result = {}
--    hash_first(ht, itr)
--    while hash_good(itr):
--        vp = <vecpair*> hash_key(itr)
--        p1 = _Partitions(vector_to_list(vp_first(vp)))
--        p2 = _Partitions(vector_to_list(vp_second(vp)))
--        result[(p1, p2)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
-+    return {_Partitions(la): Integer(k) for la, k in result.items()}
- 
- def lrcoef_unsafe(outer, inner1, inner2):
-     r"""
-@@ -371,13 +213,11 @@ def lrcoef_unsafe(outer, inner1, inner2):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
--
--    - ``inner1`` -- a partition.
-+    - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
-+    - ``inner1`` -- a partition
-+    - ``inner2`` -- a partition
- 
--    - ``inner2`` -- a partition.
--
--    .. warning::
-+    .. WARNING::
- 
-        This function does not do any check on its input.  If you want
-        to use a safer version, use :func:`lrcoef`.
-@@ -392,18 +232,7 @@ def lrcoef_unsafe(outer, inner1, inner2):
-         sage: lrcoef_unsafe([2,1,1,1,1], [2,1], [2,1])
-         0
-     """
--    cdef long long result
--    cdef vector *o
--    cdef vector *i1
--    cdef vector *i2
--    o = iterable_to_vector(outer)
--    i1 = iterable_to_vector(inner1)
--    i2 = iterable_to_vector(inner2)
--    result = lrcoef_c(o, i1, i2)
--    v_free(o)
--    v_free(i1)
--    v_free(i2)
--    return Integer(result)
-+    return Integer(lrcalc.lrcoef(outer, inner1, inner2))
- 
- 
- def lrcoef(outer, inner1, inner2):
-@@ -415,11 +244,9 @@ def lrcoef(outer, inner1, inner2):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
--
--    - ``inner1`` -- a partition.
--
--    - ``inner2`` -- a partition.
-+    - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
-+    - ``inner1`` -- a partition
-+    - ``inner2`` -- a partition
- 
-     .. NOTE::
- 
-@@ -436,7 +263,6 @@ def lrcoef(outer, inner1, inner2):
-         1
-         sage: lrcoef([2,1,1,1,1], [2,1], [2,1])
-         0
--
-     """
-     return lrcoef_unsafe(_Partitions(outer), _Partitions(inner1), _Partitions(inner2))
- 
-@@ -451,13 +277,9 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-     INPUT:
- 
-     - ``part1`` -- a partition
--
-     - ``part2`` -- a partition
--
-     - ``maxrows`` -- (optional) an integer
--
-     - ``level`` -- (optional) an integer
--
-     - ``quantum`` -- (optional) an element of a ring
- 
-     If ``maxrows`` is specified, then only partitions with at most
-@@ -479,7 +301,8 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-         sage: sorted(mult([2],[2]).items())
-         [([2, 2], 1), ([3, 1], 1), ([4], 1)]
-         sage: sorted(mult([2,1],[2,1]).items())
--        [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1), ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
-+        [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1),
-+         ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
-         sage: sorted(mult([2,1],[2,1],maxrows=2).items())
-         [([3, 3], 1), ([4, 2], 1)]
-         sage: mult([2,1],[3,2,1],3)
-@@ -510,44 +333,24 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-     if quantum is not None and (level is None or maxrows is None):
-         raise ValueError('missing parameters maxrows or level')
- 
--    cdef vector* v1 = iterable_to_vector(part1)
--    cdef vector* v2 = iterable_to_vector(part2)
--    if maxrows is None:
--        maxrows = 0
--    cdef hashtab* ht = mult_c(v1, v2, int(maxrows))
--    cdef hashtab* tab
--    cdef dict result
--
-     if quantum is None:
-         if level is not None:
--            fusion_reduce_c(ht, int(maxrows), int(level), int(0))
--        result = sf_hashtab_to_dict(ht)
--        v_free(v1)
--        v_free(v2)
--        hash_free(ht)
--        return result
-+            return _lrcalc_dict_to_sage(lrcalc.mult_fusion(part1, part2, maxrows, level))
-+        if maxrows is None:
-+            maxrows = -1
-+        return _lrcalc_dict_to_sage(lrcalc.mult(part1, part2, maxrows))
- 
-     # Otherwise do quantum multiplication
--    cdef _list *qlist
--    cdef dict temp
--    qlist = quantum_reduce_c(ht, int(maxrows), int(level))
--    # The above call frees the memory associated with ht
--    v_free(v1)
--    v_free(v2)
--
--    cdef Parent P = quantum.parent()
--    result = {}
--    for i in range(qlist.length):
--        tab = <hashtab*>(qlist.array[i])
--        temp = sf_hashtab_to_dict(tab)
--        for k in temp:
--            result[k] = result.get(k, P.zero()) + quantum**i * temp[k]
--        hash_free(tab)
--    l_free(qlist)
--    return result
--
--
--def skew(outer, inner, maxrows=0):
-+    result = lrcalc.mult_quantum(part1, part2, maxrows, level, degrees=True)
-+    P = quantum.parent()
-+    output = {}
-+    for i,k in result.items():
-+        la = _Partitions(i[0])
-+        output[la] = output.get(la, P.zero()) + k * quantum**(i[1])
-+    return output
-+
-+
-+def skew(outer, inner, maxrows=-1):
-     """
-     Compute the Schur expansion of a skew Schur function.
- 
-@@ -557,11 +360,9 @@ def skew(outer, inner, maxrows=0):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition.
--
--    - ``inner`` -- a partition.
--
--    - ``maxrows`` -- an integer or ``None``.
-+    - ``outer`` -- a partition
-+    - ``inner`` -- a partition
-+    - ``maxrows`` -- an integer or ``None``
- 
-     If ``maxrows`` is specified, then only partitions with at most
-     this number of rows are included in the result.
-@@ -572,14 +373,7 @@ def skew(outer, inner, maxrows=0):
-         sage: sorted(skew([2,1],[1]).items())
-         [([1, 1], 1), ([2], 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(outer)
--    cdef vector* v2 = iterable_to_vector(inner)
--    cdef hashtab* ht = skew_c(v1, v2, int(maxrows))
--    result = sf_hashtab_to_dict(ht)
--    v_free(v1)
--    v_free(v2)
--    hash_free(ht)
--    return result
-+    return _lrcalc_dict_to_sage(lrcalc.skew(outer, inner, maxrows))
- 
- 
- def coprod(part, all=0):
-@@ -592,9 +386,8 @@ def coprod(part, all=0):
- 
-     INPUT:
- 
--    - ``part`` -- a partition.
--
--    - ``all`` -- an integer.
-+    - ``part`` -- a partition
-+    - ``all`` -- an integer
- 
-     If ``all`` is non-zero then all terms are included in the result.
-     If ``all`` is zero, then only pairs of partitions ``(part1,
-@@ -609,12 +402,9 @@ def coprod(part, all=0):
-         sage: sorted(coprod([2,1]).items())
-         [(([1, 1], [1]), 1), (([2], [1]), 1), (([2, 1], []), 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(part)
--    cdef hashtab* ht = coprod_c(v1, int(all))
--    result = vp_hashtab_to_dict(ht)
--    v_free(v1)
--    hash_free(ht)
--    return result
-+    result = lrcalc.coprod(part, all)
-+    return {tuple([_Partitions(mu) for mu in la]): Integer(k)
-+            for la, k in result.items()}
- 
- 
- def mult_schubert(w1, w2, rank=0):
-@@ -627,11 +417,9 @@ def mult_schubert(w1, w2, rank=0):
- 
-     INPUT:
- 
--    - ``w1`` -- a permutation.
--
--    - ``w2`` -- a permutation.
--
--    - ``rank`` -- an integer.
-+    - ``w1`` -- a permutation
-+    - ``w2`` -- a permutation
-+    - ``rank`` -- an integer
- 
-     If ``rank`` is non-zero, then only permutations from the symmetric
-     group `S(\mathrm{rank})` are included in the result.
-@@ -646,33 +434,24 @@ def mult_schubert(w1, w2, rank=0):
-          ([6, 4, 3, 1, 2, 5], 1), ([6, 5, 2, 1, 3, 4], 1),
-          ([7, 3, 4, 1, 2, 5, 6], 1), ([7, 4, 2, 1, 3, 5, 6], 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(w1)
--    cdef vector* v2 = iterable_to_vector(w2)
--    cdef hashtab* ht = mult_schubert_c(v1, v2, int(rank))
--    result = schubert_hashtab_to_dict(ht)
--    v_free(v1)
--    v_free(v2)
--    hash_free(ht)
--    return result
-+    result = lrcalc.schubmult(w1, w2, rank)
-+    return {Permutation(list(la)):Integer(k) for la,k in result.items()}
- 
- 
--def lrskew(outer, inner, weight=None, maxrows=0):
-+def lrskew(outer, inner, weight=None, maxrows=-1):
-     r"""
-     Iterate over the skew LR tableaux of shape ``outer / inner``.
- 
-     INPUT:
- 
-     - ``outer`` -- a partition
--
-     - ``inner`` -- a partition
--
-     - ``weight`` -- a partition (optional)
--
--    - ``maxrows`` -- an integer (optional)
-+    - ``maxrows`` -- a positive integer (optional)
- 
-     OUTPUT: an iterator of :class:`SkewTableau`
- 
--    Specifying ``maxrows`` restricts the alphabet to `\{1,2,\ldots,maxrows\}`.
-+    Specifying ``maxrows`` = `M` restricts the alphabet to `\{1,2,\ldots,M\}`.
- 
-     Specifying ``weight`` returns only those tableaux of given content/weight.
- 
-@@ -702,22 +481,40 @@ def lrskew(outer, inner, weight=None, maxrows=0):
- 
-         sage: list(lrskew([3,2,1],[2], weight=[3,1]))
-         [[[None, None, 1], [1, 1], [2]]]
-+
-+    TESTS::
-+
-+        sage: from sage.libs.lrcalc.lrcalc import lrskew
-+        sage: list(lrskew([3,2,1],[2], weight=[]))
-+        []
-+        sage: list(lrskew([3,2,1],[2], weight=[0]))
-+        []
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[]))
-+        [[[None, None, None], [None, None], [None]]]
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[0]))
-+        [[[None, None, None], [None, None], [None]]]
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[1]))
-+        []
-     """
--    cdef vector* o = iterable_to_vector(outer)
--    cdef vector* i = iterable_to_vector(inner + [0]*(len(outer) - len(inner)))
--    cdef skewtab* st = st_new(o, i, NULL, int(maxrows))
-+    iterator = lrcalc.lr_iterator(outer, inner, maxrows)
-+    shape = SkewPartition([outer, inner])
- 
-     if weight is None:
--        yield skewtab_to_SkewTableau(st)
--        while st_next(st):
--            yield skewtab_to_SkewTableau(st)
-+        ST = SemistandardSkewTableaux(shape)
-+        for data in iterator:
-+            yield ST.from_shape_and_word(shape, [i+1 for i in data])
-     else:
-         wt = _Partitions(weight)
--        r = skewtab_to_SkewTableau(st)
--        if r.weight() == wt:
--            yield r
--        while st_next(st):
--            r = skewtab_to_SkewTableau(st)
--            if r.weight() == wt:
--                yield r
--    st_free(st)
-+        ST = SemistandardSkewTableaux(shape, wt)
-+        m = len(wt)
-+        for data in iterator:
-+            w = [0] * m
-+            for j in data:
-+                if j >= m:
-+                    # We know they are not equal, so make the check below quick
-+                    w = None
-+                    break
-+                w[j] += 1
-+            if w == wt:
-+                yield ST.from_shape_and_word(shape, [i+1 for i in data])
-+
diff --git a/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch b/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
deleted file mode 100644
index 1e2e0ba90742..000000000000
--- a/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-As produced by `git diff a90a3146{^^,}`
-
-diff --git a/src/sage/repl/interface_magic.py b/src/sage/repl/interface_magic.py
-index 8a455b69b0e..a93e1c9e04c 100644
---- a/src/sage/repl/interface_magic.py
-+++ b/src/sage/repl/interface_magic.py
-@@ -260,7 +260,7 @@ class InterfaceMagic(object):
-             2
-             120
-             sage: shell.run_cell('%%gap foo\n1+1;\n')
--            ...File "<string>", line unknown
-+            ...File...<string>...
-             SyntaxError: Interface magics have no options, got "foo"
-             <BLANKLINE>
-             sage: shell.run_cell('%%gap?')
-diff --git a/src/sage/repl/interpreter.py b/src/sage/repl/interpreter.py
-index 7468afe52d7..06c47b7374a 100644
---- a/src/sage/repl/interpreter.py
-+++ b/src/sage/repl/interpreter.py
-@@ -78,9 +78,9 @@ Check that Cython source code appears in tracebacks::
-     dummy line
-     ...
-     ZeroDivisionError...Traceback (most recent call last)
--    <ipython-input-...> in <module>...
-+    ...in <module>...
-     ----> 1 Integer(1)/Integer(0)
--    .../sage/rings/integer.pyx in sage.rings.integer.Integer...div...
-+    .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
-     ...
-     -> ...                  raise ZeroDivisionError("rational division by zero")
-        ....:            x = <Rational> Rational.__new__(Rational)
-@@ -423,7 +423,7 @@ def SagePreparseTransformer(lines):
-         sage: from sage.repl.interpreter import get_test_shell
-         sage: shell = get_test_shell()
-         sage: shell.run_cell(bad_syntax)
--          File "<string>", line unknown
-+          File...<string>...
-         SyntaxError: Mismatched ']'
-         <BLANKLINE>
-         sage: shell.quit()
diff --git a/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch b/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
deleted file mode 100644
index 853813b0f5bd..000000000000
--- a/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Fix for ipython 8.1
-
---- a/src/sage/repl/interpreter.py
-+++ b/src/sage/repl/interpreter.py
-@@ -78,7 +78,7 @@ Check that Cython source code appears in tracebacks::
-     dummy line
-     ...
-     ZeroDivisionError...Traceback (most recent call last)
--    ...in <module>...
-+    ...
-     ----> 1 Integer(1)/Integer(0)
-     .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
-     ...
diff --git a/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch b/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
deleted file mode 100644
index b861af7ec982..000000000000
--- a/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
+++ /dev/null
@@ -1,126 +0,0 @@
-From 24cc94b1988a90f3bd22a2368ec30c086283af13 Mon Sep 17 00:00:00 2001
-From: Antonio Rojas <arojas@archlinux.org>
-Date: Sun, 16 Jan 2022 11:55:04 +0100
-Subject: Add abs tol to some arb tests
-
----
- src/sage/functions/error.py    |  2 +-
- src/sage/rings/complex_arb.pyx |  6 +++---
- src/sage/rings/real_arb.pyx    | 10 +++++-----
- 3 files changed, 9 insertions(+), 9 deletions(-)
-
-diff --git a/src/sage/functions/error.py b/src/sage/functions/error.py
-index f48d04f..06f0b24 100644
---- a/src/sage/functions/error.py
-+++ b/src/sage/functions/error.py
-@@ -267,7 +267,7 @@ class Function_erf(BuiltinFunction):
- 
-         Check that real ball evaluation is fixed :trac:`28061`::
- 
--            sage: RealBallField(128)(erf(5))
-+            sage: RealBallField(128)(erf(5)) # abs tol 1e-38
-             [0.99999999999846254020557196514981165651 +/- 7.33e-39]
-         """
-         R = parent or s_parent(x)
-diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
-index f986970..93ff565 100644
---- a/src/sage/rings/complex_arb.pyx
-+++ b/src/sage/rings/complex_arb.pyx
-@@ -3974,8 +3974,8 @@ cdef class ComplexBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: CBF(20).erfc()
--            [5.39586561160790e-176 +/- ...e-191]
-+            sage: CBF(20).erfc() # abs tol 1e-190
-+            [5.39586561160790e-176 +/- 6.73e-191]
-             sage: CBF(100, 100).erfc()
-             [0.00065234366376858 +/- ...e-18] + [-0.00393572636292141 +/- ...e-18]*I
-         """
-@@ -4280,7 +4280,7 @@ cdef class ComplexBall(RingElement):
- 
-         TESTS:
- 
--            sage: CBF(Shi(I))
-+            sage: CBF(Shi(I)) # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]*I
-         """
-         cdef ComplexBall result = self._new()
-diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
-index 4a81784..292bfea 100644
---- a/src/sage/rings/real_arb.pyx
-+++ b/src/sage/rings/real_arb.pyx
-@@ -3506,7 +3506,7 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1/2).erf()
-+            sage: RBF(1/2).erf() # abs tol 1e-16
-             [0.520499877813047 +/- 6.10e-16]
-         """
-         cdef RealBall res = self._new()
-@@ -3556,12 +3556,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Si()
-+            sage: RBF(1).Si() # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]
- 
-         TESTS::
- 
--            sage: RBF(Si(1))
-+            sage: RBF(Si(1)) # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]
-         """
-         cdef RealBall res = self._new()
-@@ -3578,12 +3578,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Ci()  # abs tol 1e-16
-+            sage: RBF(1).Ci()  # abs tol 1e-15
-             [0.337403922900968 +/- 3.25e-16]
- 
-         TESTS::
- 
--            sage: RBF(Ci(1))  # abs tol 1e-16
-+            sage: RBF(Ci(1))  # abs tol 1e-15
-             [0.337403922900968 +/- 3.25e-16]
-         """
-         cdef RealBall res = self._new()
--- 
-cgit v1.0-1-gd88e
-
-
-From 53532ddd4e2dc92469c1590ebf0c40f8f69bf579 Mon Sep 17 00:00:00 2001
-From: Antonio Rojas <arojas@archlinux.org>
-Date: Sun, 16 Jan 2022 14:16:53 +0100
-Subject: Decrease abs tol
-
----
- src/sage/rings/real_arb.pyx | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
-index 292bfea..eb30f7f 100644
---- a/src/sage/rings/real_arb.pyx
-+++ b/src/sage/rings/real_arb.pyx
-@@ -3578,12 +3578,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Ci()  # abs tol 1e-15
-+            sage: RBF(1).Ci()  # abs tol 5e-16
-             [0.337403922900968 +/- 3.25e-16]
- 
-         TESTS::
- 
--            sage: RBF(Ci(1))  # abs tol 1e-15
-+            sage: RBF(Ci(1))  # abs tol 5e-16
-             [0.337403922900968 +/- 3.25e-16]
-         """
-         cdef RealBall res = self._new()
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch b/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
deleted file mode 100644
index d4e8f8be60e3..000000000000
--- a/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From 33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c Mon Sep 17 00:00:00 2001
-From: Michael Orlitzky <michael@orlitzky.com>
-Date: Mon, 24 Jan 2022 09:03:29 -0500
-Subject: Trac #33226: update doctests for giac-1.7.0.45.
-
-We have two failing doctests with giac-1.7.0.45: one is a trivial
-tolerance issue, but the other is a symbolic integration result for
-which giac is no longer willing to return a symbolic answer. We add
-"abs tol" to the numeric test, and drop the symbolic one entirely.
----
- src/sage/functions/min_max.py | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/src/sage/functions/min_max.py b/src/sage/functions/min_max.py
-index fc18373..9b7d6d9 100644
---- a/src/sage/functions/min_max.py
-+++ b/src/sage/functions/min_max.py
-@@ -228,15 +228,15 @@ class MaxSymbolic(MinMax_base):
-             ...
-             TypeError: cannot evaluate symbolic expression numerically
- 
--        ::
-+        We can usually integrate these expressions, but can't
-+        guarantee a symbolic answer in closed form::
- 
-             sage: f = max_symbolic(sin(x), cos(x))
-             sage: r = integral(f, x, 0, 1)
-             ...
--            sage: r
--            sqrt(2) - cos(1)
--            sage: r.n()
-+            sage: r.n()  # abs tol 1e-8
-             0.873911256504955
-+
-         """
-         return max_symbolic(args)
- 
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch b/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
deleted file mode 100644
index 19b69700a4f6..000000000000
--- a/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-commit 9c8235e44ffb509efa8a3ca6cdb55154e2b5066d
-Author: Antonio Rojas <arojas@archlinux.org>
-Date:   Sun Feb 13 19:53:14 2022 +0100
-
-    Fix deprecation warning with scipy 1.8
-
-diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-index e9b60dae5ec..7932167b41d 100644
---- a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-@@ -356,7 +356,7 @@ Sage example in ./linsolve.tex, line 2230::
- 
- Sage example in ./linsolve.tex, line 2609::
- 
--  sage: from scipy.sparse.linalg.dsolve import *
-+  sage: from scipy.sparse.linalg import factorized
-   sage: from scipy.sparse import lil_matrix
-   sage: from numpy import array
-   sage: n = 200
diff --git a/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch b/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
new file mode 100644
index 000000000000..e052e306e7a1
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
@@ -0,0 +1,53 @@
+From 6330cee1a69229b2f5d8ac4a09a73d8152f5e14d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Mon, 28 Feb 2022 23:15:16 -0300
+Subject: trac 33360: avoid factoring in is_prime()
+
+In the added TEST, the ideal norm is product of two primes but factoring
+this product takes about half an hour, so factoring the ideal is slow.
+
+To fix the issue, we only factor the ideal if the norm is a prime power.
+---
+ src/sage/rings/number_field/number_field_ideal.py | 22 ++++++++++++++++++++++
+ 1 file changed, 22 insertions(+)
+
+diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
+index f785f22..10d1f88 100644
+--- a/src/sage/rings/number_field/number_field_ideal.py
++++ b/src/sage/rings/number_field/number_field_ideal.py
+@@ -995,10 +995,32 @@ class NumberFieldIdeal(Ideal_generic):
+             False
+             sage: K.ideal(17).is_prime()  # ramified
+             False
++
++        TESTS::
++
++        Check that we do not factor the norm of the ideal, this used
++        to take half an hour, see :trac:`33360`
++
++           sage: K.<a,b,c> = NumberField([x^2-2,x^2-3,x^2-5])
++           sage: t = (((-2611940*c + 1925290/7653)*b - 1537130/7653*c
++           ....:       + 10130950)*a + (1343014/7653*c - 8349770)*b
++           ....:       + 6477058*c - 2801449990/4002519)
++           sage: t.is_prime()
++           False
++
+         """
+         try:
+             return self._pari_prime is not None
+         except AttributeError:
++            K = self.number_field().pari_nf()
++            I = self.pari_hnf()
++            # This would be better, but it is broken in pari 2.13.3.
++            #   self._pari_prime = K.idealismaximal(I) or None
++            # Instead we factor I, but only if the norm is a prime power
++            n = K.idealnorm(I)
++            if n.denominator() > 1 or not n.isprimepower():
++                self._pari_prime = None
++                return False
+             F = self.factor()  # factorization with caching
+             if len(F) != 1 or F[0][1] != 1:
+                 self._pari_prime = None
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
deleted file mode 100644
index 9ba7ca5a6b7d..000000000000
--- a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
+++ /dev/null
@@ -1,99 +0,0 @@
-From 609dd9deaeaa6380ab2f0d50276d911233c00a04 Mon Sep 17 00:00:00 2001
-From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
-Date: Fri, 4 Mar 2022 16:07:09 -0800
-Subject: sage.manifolds: Update doctests for SymPy 1.10
-
----
- src/sage/manifolds/continuous_map.py              | 3 +--
- src/sage/manifolds/differentiable/diff_form.py    | 4 ++--
- src/sage/manifolds/differentiable/tensorfield.py  | 8 ++++----
- src/sage/manifolds/vector_bundle_fiber_element.py | 2 +-
- 4 files changed, 8 insertions(+), 9 deletions(-)
-
-diff --git a/src/sage/manifolds/continuous_map.py b/src/sage/manifolds/continuous_map.py
-index a6356e7..f6f9b6d 100644
---- a/src/sage/manifolds/continuous_map.py
-+++ b/src/sage/manifolds/continuous_map.py
-@@ -1357,8 +1357,7 @@ class ContinuousMap(Morphism):
-             sage: Phi.coord_functions(c_uv, c_xyz)
-             Coordinate functions (u*v, u/v, u + v) on the Chart (M, (u, v))
-             sage: Phi.coord_functions(c_UV, c_xyz)
--            Coordinate functions (-U**2/4 + V**2/4, -(U + V)/(U - V), V)
--             on the Chart (M, (U, V))
-+            Coordinate functions (-U**2/4 + V**2/4, (-U - V)/(U - V), V) on the Chart (M, (U, V))
-             sage: Phi.coord_functions(c_UV, c_XYZ)
-             Coordinate functions ((-U**3 + U**2*V + U*V**2 + 2*U*V + 6*U - V**3
-              - 2*V**2 + 6*V)/(2*(U - V)), (U**3/4 - U**2*V/4 - U*V**2/4 + U*V
-diff --git a/src/sage/manifolds/differentiable/diff_form.py b/src/sage/manifolds/differentiable/diff_form.py
-index 70dd8fb..0aa3469 100644
---- a/src/sage/manifolds/differentiable/diff_form.py
-+++ b/src/sage/manifolds/differentiable/diff_form.py
-@@ -266,7 +266,7 @@ class DiffForm(TensorField):
- 
-         sage: s = a.wedge(b)
-         sage: s.display(eU)
--        a∧b = -x*(2*x*y + 1) dx∧dy
-+        a∧b = x*(-2*x*y - 1) dx∧dy
-         sage: s.display(eV)
-         a∧b = (u**3/8 + u**2*v/8 - u*v**2/8 + u/4 - v**3/8 + v/4) du∧dv
- 
-@@ -275,7 +275,7 @@ class DiffForm(TensorField):
-         sage: f = M.scalar_field({c_xy: (x+y)^2, c_uv: u^2}, name='f')
-         sage: s = f*a
-         sage: s.display(eU)
--        f*a = -y*(x**2 + 2*x*y + y**2) dx + x*(x**2 + 2*x*y + y**2) dy
-+        f*a = y*(-x**2 - 2*x*y - y**2) dx + x*(x**2 + 2*x*y + y**2) dy
-         sage: s.display(eV)
-         f*a = u**2*v/2 du - u**3/2 dv
- 
-diff --git a/src/sage/manifolds/differentiable/tensorfield.py b/src/sage/manifolds/differentiable/tensorfield.py
-index 2775be9..6bc5c50 100644
---- a/src/sage/manifolds/differentiable/tensorfield.py
-+++ b/src/sage/manifolds/differentiable/tensorfield.py
-@@ -334,7 +334,7 @@ class TensorField(ModuleElementWithMutability):
-         sage: f.display()  # long time
-         t(a,b): S^2 → ℝ
-         on U: (x, y) ↦ -2*x*y - 3*x - y**2
--        on V: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+        on V: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
- 
-     The vectors can be defined only on subsets of `S^2`, the domain of the
-     result is then the common subset::
-@@ -343,12 +343,12 @@ class TensorField(ModuleElementWithMutability):
-         sage: s.display()  # long time
-         t(a,b): U → ℝ
-            (x, y) ↦ -2*x*y - 3*x - y**2
--        on W: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+        on W: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
-         sage: s = t(a.restrict(U), b.restrict(W))  # long time
-         sage: s.display()  # long time
-         t(a,b): W → ℝ
-            (x, y) ↦ -2*x*y - 3*x - y**2
--           (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+           (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
- 
-     The tensor itself can be defined only on some open subset of `S^2`,
-     yielding a result whose domain is this subset::
-@@ -356,7 +356,7 @@ class TensorField(ModuleElementWithMutability):
-         sage: s = t.restrict(V)(a,b)  # long time
-         sage: s.display()  # long time
-         t(a,b): V → ℝ
--           (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+           (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
-         on W: (x, y) ↦ -2*x*y - 3*x - y**2
- 
-     Tests regarding the multiplication by a scalar field::
-diff --git a/src/sage/manifolds/vector_bundle_fiber_element.py b/src/sage/manifolds/vector_bundle_fiber_element.py
-index 29ee81d..048275a 100644
---- a/src/sage/manifolds/vector_bundle_fiber_element.py
-+++ b/src/sage/manifolds/vector_bundle_fiber_element.py
-@@ -110,4 +110,4 @@ class VectorBundleFiberElement(FiniteRankFreeModuleElement):
-             desc += str(self._name) + " "
-         desc += "in the fiber of {} at {}".format(self._vbundle._name,
-                                                   self._point)
--        return desc
-\ No newline at end of file
-+        return desc
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
deleted file mode 100644
index f5ac180baa90..000000000000
--- a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From c49eff347454ac7f07e5918470b20e97b8f2357e Mon Sep 17 00:00:00 2001
-From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
-Date: Fri, 4 Mar 2022 15:14:43 -0800
-Subject: src/sage/calculus/calculus.py: Update laplace doctest for sympy 1.10
-
----
- src/sage/calculus/calculus.py | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/src/sage/calculus/calculus.py b/src/sage/calculus/calculus.py
-index 9c2f226..b335093 100644
---- a/src/sage/calculus/calculus.py
-+++ b/src/sage/calculus/calculus.py
-@@ -1639,9 +1639,9 @@ def laplace(ex, t, s, algorithm='maxima'):
-         sage: laplace(dirac_delta(t), t, s)
-         1
-         sage: F, a, cond = laplace(dirac_delta(t), t, s, algorithm='sympy')
--        sage: a, cond
--        (-oo, True)
--        sage: F       # random - sympy <1.9 includes undefined heaviside(0) in answer
-+        sage: a, cond  # random - sympy <1.10 gives (-oo, True)
-+        (0, True)
-+        sage: F        # random - sympy <1.9 includes undefined heaviside(0) in answer
-         1
-         sage: laplace(dirac_delta(t), t, s, algorithm='giac')
-         1
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch b/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
deleted file mode 100644
index 8e7bb64f5b01..000000000000
--- a/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From a04a0a0b14f67f4804e7113c3db41bbcf8a58296 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
-Date: Mon, 28 Mar 2022 20:39:59 -0300
-Subject: Trac #33585: fix doctest when dochtml is missing...
-
-...but sphinx is available in PYTHONPATH.
----
- src/sage/misc/sagedoc.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/sage/misc/sagedoc.py b/src/sage/misc/sagedoc.py
-index 4b3853f..08c4225 100644
---- a/src/sage/misc/sagedoc.py
-+++ b/src/sage/misc/sagedoc.py
-@@ -1401,7 +1401,7 @@ class _sage_doc:
-             "...**File:**...**Type:**...**Definition:** identity_matrix..."
-             sage: identity_matrix.__doc__ in browse_sage_doc(identity_matrix, 'rst')
-             True
--            sage: browse_sage_doc(identity_matrix, 'html', False)             # optional - sphinx
-+            sage: browse_sage_doc(identity_matrix, 'html', False)             # optional - sphinx sagemath_doc_html
-             '...div...File:...Type:...Definition:...identity_matrix...'
- 
-         In the 'text' version, double colons have been replaced with
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch b/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
new file mode 100644
index 000000000000..977a42400e59
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
@@ -0,0 +1,42 @@
+commit 5db5d4e56243c609f44afc1f21c112b026f9e1fe
+Author: Oscar Benjamin <oscar.j.benjamin@gmail.com>
+Date:   Mon Jul 11 21:24:01 2022 +0100
+
+    Update doctests for SymPy 1.11
+    
+    Doctests related to SymPy's rsolve function are updated in:
+    
+    src/sage/calculus/test_sympy.py
+    src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+    
+    The form of the output from SymPy has changed since
+    
+    https://github.com/sympy/sympy/pull/23567
+
+diff --git a/src/sage/calculus/test_sympy.py b/src/sage/calculus/test_sympy.py
+index 7cf7f3f6bfd..927e6ee4fb6 100644
+--- a/src/sage/calculus/test_sympy.py
++++ b/src/sage/calculus/test_sympy.py
+@@ -193,7 +193,7 @@ This was fixed in Sympy, see :trac:`14437`::
+     sage: u = Function('u')
+     sage: n = Symbol('n', integer=True)
+     sage: f = u(n+2) - u(n+1) + u(n)/4
+-    sage: 2**n * rsolve(f,u(n))
+-    C1*n + C0
++    sage: expand(2**n * rsolve(f,u(n)))
++    2*C1*n + C0
+ 
+ """
+diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+index 1062f4f7e8c..f53f813d793 100644
+--- a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
++++ b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+@@ -382,7 +382,7 @@ Sage example in ./recequadiff.tex, line 1798::
+   sage: from sympy import rsolve_hyper
+   sage: from sympy.abc import n
+   sage: rsolve_hyper([-2,1],2**(n+2),n)
+-  2**n*C0 + 2**(n + 2)*(C0 + n/2)
++  2**n*C0 + 2**(n + 1)*n
+ 
+ """
+ 
diff --git a/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch b/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch
new file mode 100644
index 000000000000..b544a3eef7dd
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch
@@ -0,0 +1,526 @@
+From aeff992d53a65a705dca5cd5216bcb97c218dce7 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:14:03 +0200
+Subject: Adapt to API changes in OpenOutputStream and CloseOutput
+
+---
+ src/sage/libs/gap/element.pyx      | 5 +++--
+ src/sage/libs/gap/gap_includes.pxd | 6 ++++--
+ 2 files changed, 7 insertions(+), 4 deletions(-)
+
+diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
+index be43c4c..e268116 100644
+--- a/src/sage/libs/gap/element.pyx
++++ b/src/sage/libs/gap/element.pyx
+@@ -130,6 +130,7 @@ cdef char *capture_stdout(Obj func, Obj obj):
+     """
+     cdef Obj s, stream, output_text_string
+     cdef UInt res
++    cdef TypOutputFile output
+     # The only way to get a string representation of an object that is truly
+     # consistent with how it would be represented at the GAP REPL is to call
+     # ViewObj on it.  Unfortunately, ViewObj *prints* to the output stream,
+@@ -145,12 +146,12 @@ cdef char *capture_stdout(Obj func, Obj obj):
+         output_text_string = GAP_ValueGlobalVariable("OutputTextString")
+         stream = CALL_2ARGS(output_text_string, s, GAP_True)
+ 
+-        if not OpenOutputStream(stream):
++        if not OpenOutputStream(&output, stream):
+             raise GAPError("failed to open output capture stream for "
+                            "representing GAP object")
+ 
+         CALL_1ARGS(func, obj)
+-        CloseOutput()
++        CloseOutput(&output)
+         return CSTR_STRING(s)
+     finally:
+         GAP_Leave()
+diff --git a/src/sage/libs/gap/gap_includes.pxd b/src/sage/libs/gap/gap_includes.pxd
+index 5a9ab48..34035fe 100644
+--- a/src/sage/libs/gap/gap_includes.pxd
++++ b/src/sage/libs/gap/gap_includes.pxd
+@@ -76,8 +76,10 @@ cdef extern from "gap/intobj.h" nogil:
+ 
+ 
+ cdef extern from "gap/io.h" nogil:
+-    UInt OpenOutputStream(Obj stream)
+-    UInt CloseOutput()
++    ctypedef struct TypOutputFile:
++        pass
++    UInt OpenOutputStream(TypOutputFile* output, Obj stream)
++    UInt CloseOutput(TypOutputFile* output)
+ 
+ 
+ cdef extern from "gap/libgap-api.h" nogil:
+-- 
+cgit v1.0-1-gd88e
+
+
+From c3367b4290981e5e93b7a30c48b02f1ae3770dc8 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:14:53 +0200
+Subject: Disable colored prompt as it breaks the pexpect interface
+
+---
+ src/sage/interfaces/gap.py | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/src/sage/interfaces/gap.py b/src/sage/interfaces/gap.py
+index c34fe53..569caa2 100644
+--- a/src/sage/interfaces/gap.py
++++ b/src/sage/interfaces/gap.py
+@@ -1512,6 +1512,8 @@ def gap_reset_workspace(max_workspace_size=None, verbose=False):
+     """
+     # Create new workspace with filename WORKSPACE
+     g = Gap(use_workspace_cache=False, max_workspace_size=None)
++    g.eval('ColorPrompt(false)')
++    g.eval('SetUserPreference("UseColorPrompt", false)')
+     g.eval('SetUserPreference("HistoryMaxLines", 30)')
+     from sage.tests.gap_packages import all_installed_packages
+     for pkg in all_installed_packages(gap=g):
+-- 
+cgit v1.0-1-gd88e
+
+
+From 3b63e998e4d6118fc86b13b940c8f3d3b8307a50 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:16:03 +0200
+Subject: Port NaturalHomomorphism uses
+
+---
+ src/sage/groups/abelian_gps/abelian_group_gap.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/sage/groups/abelian_gps/abelian_group_gap.py b/src/sage/groups/abelian_gps/abelian_group_gap.py
+index a4b0471..86090b4 100644
+--- a/src/sage/groups/abelian_gps/abelian_group_gap.py
++++ b/src/sage/groups/abelian_gps/abelian_group_gap.py
+@@ -338,7 +338,7 @@ class AbelianGroup_gap(UniqueRepresentation, GroupMixinLibGAP, ParentLibGAP, Abe
+         if isinstance(x, AbelianGroupElement_gap):
+             try:
+                 if x in self._cover:
+-                    x = self.gap().NaturalHomomorphism().Image(x.gap())
++                    x = self._cover.gap().NaturalHomomorphismByNormalSubgroup(self._relations).Image(x.gap())
+                 else:
+                     x = x.gap()
+             except AttributeError:
+@@ -1043,7 +1043,7 @@ class AbelianGroupQuotient_gap(AbelianGroup_gap):
+             From: Abelian group with gap, generator orders (4,)
+             To:   Quotient abelian group with generator orders (2,)
+         """
+-        phi = self.gap().NaturalHomomorphism()
++        phi = self._cover.gap().NaturalHomomorphismByNormalSubgroup(self._relations)
+         Hom = self._cover.Hom(self)
+         return Hom(phi)
+ 
+-- 
+cgit v1.0-1-gd88e
+
+
+From bc40764be044653e06f2da3497e1e05da08251f7 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:17:36 +0200
+Subject: Fix tests with GAP 4.12
+
+---
+ src/doc/en/thematic_tutorials/lie/weyl_groups.rst  | 12 ++++++------
+ src/sage/coding/codecan/autgroup_can_label.pyx     |  2 +-
+ src/sage/coding/linear_code.py                     | 22 +++++++++++-----------
+ .../root_system/hecke_algebra_representation.py    |  2 +-
+ src/sage/combinat/symmetric_group_algebra.py       |  2 +-
+ src/sage/groups/finitely_presented.py              |  6 +++---
+ src/sage/groups/fqf_orthogonal.py                  |  2 +-
+ src/sage/groups/libgap_wrapper.pyx                 |  6 +++---
+ .../perm_gps/partn_ref2/refinement_generic.pyx     |  2 +-
+ src/sage/groups/perm_gps/permgroup.py              |  8 ++++----
+ src/sage/libs/gap/libgap.pyx                       |  2 +-
+ src/sage/libs/gap/util.pyx                         |  8 +-------
+ src/sage/tests/gap_packages.py                     |  2 +-
+ 13 files changed, 35 insertions(+), 41 deletions(-)
+
+diff --git a/src/doc/en/thematic_tutorials/lie/weyl_groups.rst b/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
+index c917338..182e74a 100644
+--- a/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
++++ b/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
+@@ -139,12 +139,12 @@ string, which you can print::
+     X.1      1  1  1  1  1  1  1  1  1  1  1  1  1
+     X.2      1 -1  1  1 -1  1  1 -1 -1 -1  1  1  1
+     X.3      2  .  2 -1  .  2  2  .  .  . -1  2  2
+-    X.4      3 -1 -1  .  1 -1  3 -1  1 -1  . -1  3
+-    X.5      3 -1 -1  .  1  3 -1 -1 -1  1  . -1  3
+-    X.6      3  1 -1  . -1 -1  3  1 -1  1  . -1  3
+-    X.7      3  1 -1  . -1  3 -1  1  1 -1  . -1  3
+-    X.8      3 -1  3  . -1 -1 -1 -1  1  1  . -1  3
+-    X.9      3  1  3  .  1 -1 -1  1 -1 -1  . -1  3
++    X.4      3 -1 -1  .  1  3 -1 -1 -1  1  . -1  3
++    X.5      3  1 -1  . -1  3 -1  1  1 -1  . -1  3
++    X.6      3 -1  3  . -1 -1 -1 -1  1  1  . -1  3
++    X.7      3 -1 -1  .  1 -1  3 -1  1 -1  . -1  3
++    X.8      3  1  3  .  1 -1 -1  1 -1 -1  . -1  3
++    X.9      3  1 -1  . -1 -1  3  1 -1  1  . -1  3
+     X.10     4 -2  . -1  .  .  .  2  .  .  1  . -4
+     X.11     4  2  . -1  .  .  . -2  .  .  1  . -4
+     X.12     6  . -2  .  . -2 -2  .  .  .  .  2  6
+diff --git a/src/sage/coding/codecan/autgroup_can_label.pyx b/src/sage/coding/codecan/autgroup_can_label.pyx
+index de5db98..c83b926 100644
+--- a/src/sage/coding/codecan/autgroup_can_label.pyx
++++ b/src/sage/coding/codecan/autgroup_can_label.pyx
+@@ -76,7 +76,7 @@ columns do share the same coloring::
+     ((1,),
+      (2,),
+      (3, 5, 4),
+-     (6, 19, 16, 9, 21, 10, 8, 15, 14, 11, 20, 13, 12, 7, 17, 18))
++     (6, 19, 16, 21, 9, 10, 15, 8, 20, 11, 14, 13, 7, 12, 18, 17))
+ 
+ We can also restrict the group action to linear isometries::
+ 
+diff --git a/src/sage/coding/linear_code.py b/src/sage/coding/linear_code.py
+index e8e32f8..9d45160 100644
+--- a/src/sage/coding/linear_code.py
++++ b/src/sage/coding/linear_code.py
+@@ -466,27 +466,27 @@ class AbstractLinearCode(AbstractLinearCodeNoMetric):
+             0
+             sage: C = codes.HammingCode(GF(4, 'z'), 3)
+             sage: C.automorphism_group_gens()
+-            ([((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
++            ([((1, 1, 1, z, z + 1, 1, 1, 1, 1, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z); (1,13,14,20)(2,21,8,18,7,16,19,15)(3,10,5,12,17,9,6,4), Ring endomorphism of Finite Field in z of size 2^2
++                Defn: z |--> z + 1),
++              ((z, 1, z, z, z, z + 1, z, z, z, z, z, z, z + 1, z, z, z, z, z + 1, z, z, z); (1,11,5,12,3,19)(2,8)(6,18,13)(7,17,15)(9,10,14,16,20,21), 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 + 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
++            ([((z, 1, z + 1, z + 1, 1, z + 1, z, 1, z + 1, z + 1, 1, z, 1, z + 1, z, 1, z, 1, z + 1, 1, 1); (1,12,11,10,6,8,9,20,13,21,5,14,3,16,17,19,7,4,2,15,18), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+-              ((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
++              ((z + 1, z + 1, z + 1, z, 1, 1, z, z, 1, z + 1, z, 1, 1, z, 1, z + 1, z, z + 1, z + 1, 1, z); (1,3,18,2,17,6,19)(4,15,13,20,7,14,16)(5,11,8,21,12,9,10), 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)],
+              181440)
+             sage: C.automorphism_group_gens(equivalence="permutational")
+-            ([((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,19)(3,17)(4,21)(5,20)(7,14)(9,12)(10,16)(11,15), Ring endomorphism of Finite Field in z of size 2^2
++            ([((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,11)(3,10)(4,9)(5,7)(12,21)(14,20)(15,19)(16,17), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+-              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,11)(3,10)(4,9)(5,7)(12,21)(14,20)(15,19)(16,17), Ring endomorphism of Finite Field in z of size 2^2
++              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (2,18)(3,19)(4,10)(5,16)(8,13)(9,14)(11,21)(15,20), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+-              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,17)(2,8)(3,14)(4,10)(7,12)(9,19)(13,18)(15,20), Ring endomorphism of Finite Field in z of size 2^2
++              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,19)(3,17)(4,21)(5,20)(7,14)(9,12)(10,16)(11,15), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+               ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (2,13)(3,14)(4,20)(5,11)(8,18)(9,19)(10,15)(16,21), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z)],
+@@ -692,10 +692,10 @@ class AbstractLinearCode(AbstractLinearCodeNoMetric):
+             sage: C_iso == aut_group_can_label.get_canonical_form()
+             True
+             sage: aut_group_can_label.get_autom_gens()
+-            [((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
++            [((1, 1, 1, z, z + 1, 1, 1, 1, 1, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z); (1,13,14,20)(2,21,8,18,7,16,19,15)(3,10,5,12,17,9,6,4), Ring endomorphism of Finite Field in z of size 2^2
++               Defn: z |--> z + 1),
++             ((z, 1, z, z, z, z + 1, z, z, z, z, z, z, z + 1, z, z, z, z, z + 1, z, z, z); (1,11,5,12,3,19)(2,8)(6,18,13)(7,17,15)(9,10,14,16,20,21), 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/root_system/hecke_algebra_representation.py b/src/sage/combinat/root_system/hecke_algebra_representation.py
+index bde2823..bffcc85 100644
+--- a/src/sage/combinat/root_system/hecke_algebra_representation.py
++++ b/src/sage/combinat/root_system/hecke_algebra_representation.py
+@@ -355,7 +355,7 @@ class HeckeAlgebraRepresentation(WithEqualityById, SageObject):
+             sage: q1, q2 = K.gens()
+             sage: KW = W.algebra(K)
+             sage: x = KW.an_element(); x
+-            123 + 3*32 + 2*3 + e
++            123 + 3*2312 + 2*31 + e
+ 
+             sage: T = KW.demazure_lusztig_operators(q1,q2)
+             sage: T12 = T.Tw( (1,2) )
+diff --git a/src/sage/combinat/symmetric_group_algebra.py b/src/sage/combinat/symmetric_group_algebra.py
+index c3d6755..da953d2 100644
+--- a/src/sage/combinat/symmetric_group_algebra.py
++++ b/src/sage/combinat/symmetric_group_algebra.py
+@@ -101,7 +101,7 @@ def SymmetricGroupAlgebra(R, W, category=None):
+         sage: SGA.group()
+         Weyl Group of type ['A', 3] (as a matrix group acting on the ambient space)
+         sage: SGA.an_element()
+-        s1*s2*s3 + 3*s3*s2 + 2*s3 + 1
++        s1*s2*s3 + 3*s2*s3*s1*s2 + 2*s3*s1 + 1
+ 
+     The preferred way to construct the symmetric group algebra is to
+     go through the usual ``algebra`` method::
+diff --git a/src/sage/groups/finitely_presented.py b/src/sage/groups/finitely_presented.py
+index 2a61bbf..d26891a 100644
+--- a/src/sage/groups/finitely_presented.py
++++ b/src/sage/groups/finitely_presented.py
+@@ -596,9 +596,9 @@ class RewritingSystem():
+             sage: k = G.rewriting_system()
+             sage: k.gap()
+             Knuth Bendix Rewriting System for Monoid( [ a, A, b, B ] ) with rules
+-            [ [ a^2, <identity ...> ], [ a*A, <identity ...> ],
+-              [ A*a, <identity ...> ], [ b^2, <identity ...> ],
+-              [ b*B, <identity ...> ], [ B*b, <identity ...> ] ]
++            [ [ a*A, <identity ...> ], [ A*a, <identity ...> ],
++              [ b*B, <identity ...> ], [ B*b, <identity ...> ],
++              [ a^2, <identity ...> ], [ b^2, <identity ...> ] ]
+         """
+         return self._gap
+ 
+diff --git a/src/sage/groups/fqf_orthogonal.py b/src/sage/groups/fqf_orthogonal.py
+index 75de408..dd7d84d 100644
+--- a/src/sage/groups/fqf_orthogonal.py
++++ b/src/sage/groups/fqf_orthogonal.py
+@@ -143,7 +143,7 @@ class FqfOrthogonalGroup(AbelianGroupAutomorphismGroup_subgroup):
+         [2/3   0   0]
+         [  0 2/3   0]
+         [  0   0 4/3]
+-        generated by 2 elements
++        generated by 3 elements
+         sage: q = matrix.diagonal(QQ, [3/2, 1/4, 1/4])
+         sage: T = TorsionQuadraticForm(q)
+         sage: T.orthogonal_group().order()
+diff --git a/src/sage/groups/libgap_wrapper.pyx b/src/sage/groups/libgap_wrapper.pyx
+index a76afc2..9340c0d 100644
+--- a/src/sage/groups/libgap_wrapper.pyx
++++ b/src/sage/groups/libgap_wrapper.pyx
+@@ -25,7 +25,7 @@ Note how we call the constructor of both superclasses to initialize
+ its output via LibGAP::
+ 
+     sage: FooGroup()
+-    <pc group of size 3 with 1 generators>
++    <pc group of size 3 with 1 generator>
+     sage: type(FooGroup().gap())
+     <class 'sage.libs.gap.element.GapElement'>
+ 
+@@ -106,7 +106,7 @@ class ParentLibGAP(SageObject):
+         ....:         ParentLibGAP.__init__(self, lg)
+         ....:         Group.__init__(self)
+         sage: FooGroup()
+-        <pc group of size 3 with 1 generators>
++        <pc group of size 3 with 1 generator>
+     """
+ 
+     def __init__(self, libgap_parent, ambient=None):
+@@ -461,7 +461,7 @@ cdef class ElementLibGAP(MultiplicativeGroupElement):
+         ....:         ParentLibGAP.__init__(self, lg)
+         ....:         Group.__init__(self)
+         sage: FooGroup()
+-        <pc group of size 3 with 1 generators>
++        <pc group of size 3 with 1 generator>
+         sage: FooGroup().gens()
+         (f1,)
+     """
+diff --git a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
+index 2fcb036..ca73c6b 100644
+--- a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
++++ b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
+@@ -427,7 +427,7 @@ cdef class LabelledBranching:
+             sage: from sage.groups.perm_gps.partn_ref2.refinement_generic import LabelledBranching
+             sage: L = LabelledBranching(3)
+             sage: L.small_generating_set()
+-            []
++            [()]
+             sage: L.add_gen(libgap.eval('(1,2,3)'))
+             sage: L.small_generating_set()
+             [(1,2,3)]
+diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
+index 4908934..34ba0cc 100644
+--- a/src/sage/groups/perm_gps/permgroup.py
++++ b/src/sage/groups/perm_gps/permgroup.py
+@@ -913,7 +913,7 @@ class PermutationGroup_generic(FiniteGroup):
+            sage: f = PG._coerce_map_from_(MG)
+            sage: mg = MG.an_element()
+            sage: p = f(mg); p
+-           (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)
++           (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(p._gap_()) == p
+            True
+ 
+@@ -959,12 +959,12 @@ class PermutationGroup_generic(FiniteGroup):
+             sage: P = G.as_permutation_group(algorithm='smaller', seed=5)
+             sage: P1 = G.as_permutation_group()
+             sage: P == P1
+-            False
++            True
+             sage: g1, g2, g3 = G.gens()
+             sage: P(g1*g2)
+-            (1,3,7,12)(2,4,8,10)(5,11)(6,9)
++            (1,4,13,11)(2,5,14,18)(3,15,8,16)(6,7)(9,20,19,12)(10,17)
+             sage: P1(g1*g2)
+-            (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)
++            (1,4,13,11)(2,5,14,18)(3,15,8,16)(6,7)(9,20,19,12)(10,17)
+ 
+         Another check for :trac:`5583`::
+ 
+diff --git a/src/sage/libs/gap/libgap.pyx b/src/sage/libs/gap/libgap.pyx
+index b1a64e5..6a36613 100644
+--- a/src/sage/libs/gap/libgap.pyx
++++ b/src/sage/libs/gap/libgap.pyx
+@@ -695,7 +695,7 @@ class Gap(Parent):
+             sage: libgap.List
+             <Gap function "List">
+             sage: libgap.GlobalRandomSource
+-            <RandomSource in IsGlobalRandomSource>
++            <RandomSource in IsGAPRandomSource>
+         """
+         if name in dir(self.__class__):
+             return getattr(self.__class__, name)
+diff --git a/src/sage/libs/gap/util.pyx b/src/sage/libs/gap/util.pyx
+index 344ab88..6350987 100644
+--- a/src/sage/libs/gap/util.pyx
++++ b/src/sage/libs/gap/util.pyx
+@@ -362,15 +362,9 @@ cdef Obj gap_eval(str gap_string) except? NULL:
+         GAPError: Error, Variable: 'Complex' must have a value
+         Syntax error: ; expected in stream:1
+         Complex Field with 53 bits of precision;;
+-         ^^^^^^^^^^^^
++                ^^^^^
+         Error, Variable: 'with' must have a value
+-        Syntax error: ; expected in stream:1
+-        Complex Field with 53 bits of precision;;
+-         ^^^^^^^^^^^^^^^^^^^^
+         Error, Variable: 'bits' must have a value
+-        Syntax error: ; expected in stream:1
+-        Complex Field with 53 bits of precision;;
+-         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+         Error, Variable: 'precision' must have a value
+ 
+     Test that on a subsequent attempt we get the same message (no garbage was
+diff --git a/src/sage/tests/gap_packages.py b/src/sage/tests/gap_packages.py
+index 2e4518c..c302b16 100644
+--- a/src/sage/tests/gap_packages.py
++++ b/src/sage/tests/gap_packages.py
+@@ -103,7 +103,7 @@ def all_installed_packages(ignore_dot_gap=False, gap=None):
+ 
+         sage: from sage.tests.gap_packages import all_installed_packages
+         sage: all_installed_packages()
+-        (...'GAPDoc'...)
++        (...'gapdoc'...)
+         sage: all_installed_packages(ignore_dot_gap=True) == all_installed_packages(gap=gap, ignore_dot_gap=True)
+         True
+     """
+-- 
+cgit v1.0-1-gd88e
+
+
+From cbc902a79ff9ec01d4d4eb9a767a1c661fb5dda7 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Fri, 30 Sep 2022 19:17:42 +0200
+Subject: Adapt test to new is_transitive and is_primitive behavior
+
+---
+ src/sage/groups/perm_gps/permgroup.py | 22 ++++++++++++++++------
+ 1 file changed, 16 insertions(+), 6 deletions(-)
+
+diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
+index 34ba0cc..5832b98 100644
+--- a/src/sage/groups/perm_gps/permgroup.py
++++ b/src/sage/groups/perm_gps/permgroup.py
+@@ -4359,17 +4359,23 @@ class PermutationGroup_generic(FiniteGroup):
+ 
+         ::
+ 
+-            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)]]) #S_5 on [1..5]
+-            sage: G.is_transitive([1,4,5])
++            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)],[(6,7)]])
++            sage: G.is_transitive([1,2,3,4,5])
+             True
+-            sage: G.is_transitive([2..6])
++            sage: G.is_transitive([1..7])
+             False
+             sage: G.is_transitive(G.non_fixed_points())
+-            True
++            False
+             sage: H = PermutationGroup([[(1,2,3)],[(4,5,6)]])
+             sage: H.is_transitive(H.non_fixed_points())
+             False
+ 
++        If `G` does not act on the domain, it always returns ``False``::
++
++            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)]]) #S_5 on [1..5]
++            sage: G.is_transitive([1,4,5])
++            False
++
+         Note that this differs from the definition in GAP, where
+         ``IsTransitive`` returns whether the group is transitive on the
+         set of points moved by the group.
+@@ -4425,12 +4431,16 @@ class PermutationGroup_generic(FiniteGroup):
+             sage: G = PermutationGroup([[(1,2,3,4)],[(2,4)]])
+             sage: G.is_primitive([1..4])
+             False
+-            sage: G.is_primitive([1,2,3])
+-            True
+             sage: G = PermutationGroup([[(3,4,5,6)],[(3,4)]]) #S_4 on [3..6]
+             sage: G.is_primitive(G.non_fixed_points())
+             True
+ 
++        If `G` does not act on the domain, it always returns ``False``::
++
++            sage: G = PermutationGroup([[(1,2,3,4)],[(2,4)]])
++            sage: G.is_primitive([1,2,3])
++            False
++
+         """
+         #If the domain is not a subset of self.domain(), then the
+         #action isn't primitive.
+-- 
+cgit v1.0-1-gd88e
+
+
+From 80dd6b338236f170efca1fc3545df18ce8d8795c Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Fri, 30 Sep 2022 19:18:06 +0200
+Subject: Mark test as random. With gap 4.12 on x86_64 it is no longer 2
+
+---
+ src/sage/groups/perm_gps/permgroup.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
+index 5832b98..c1230a3 100644
+--- a/src/sage/groups/perm_gps/permgroup.py
++++ b/src/sage/groups/perm_gps/permgroup.py
+@@ -1287,7 +1287,7 @@ class PermutationGroup_generic(FiniteGroup):
+             sage: G.gens_small() # random
+             [('b','c'), ('a','c','b')] ## (on 64-bit Linux)
+             [('a','b'), ('a','c','b')] ## (on Solaris)
+-            sage: len(G.gens_small()) == 2
++            sage: len(G.gens_small()) == 2 # random
+             True
+         """
+         gens = self._libgap_().SmallGeneratingSet()
+-- 
+cgit v1.0-1-gd88e
+
+
+From a6c293d67cfcdf8fba7bc6aa7899e2086d42cc7e Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Fri, 30 Sep 2022 19:18:30 +0200
+Subject: Remove test that is now redundant, all seeds give the same answer
+
+---
+ src/sage/groups/matrix_gps/finitely_generated.py | 3 ---
+ 1 file changed, 3 deletions(-)
+
+diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
+index a6d3dc0..63956ad 100644
+--- a/src/sage/groups/matrix_gps/finitely_generated.py
++++ b/src/sage/groups/matrix_gps/finitely_generated.py
+@@ -563,9 +563,6 @@ class FinitelyGeneratedMatrixGroup_gap(MatrixGroup_gap):
+             21499084800
+             sage: P = G.as_permutation_group()
+             sage: Psmaller = G.as_permutation_group(algorithm="smaller", seed=6)
+-            sage: P == Psmaller  # see the note below
+-            True
+-            sage: Psmaller = G.as_permutation_group(algorithm="smaller")
+             sage: P == Psmaller
+             False
+             sage: P.cardinality()
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch b/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
new file mode 100644
index 000000000000..8fedcb78cf71
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
@@ -0,0 +1,19 @@
+commit 04971318f032caf8dc1c0de9489346d894409091
+Author: John H. Palmieri <jhpalmieri64@gmail.com>
+Date:   Wed Aug 31 14:22:26 2022 -0700
+
+    trac 34465: fix invalid escape sequence in functions/special.py
+
+diff --git a/src/sage/functions/special.py b/src/sage/functions/special.py
+index 02596e49620..901f02f9bee 100644
+--- a/src/sage/functions/special.py
++++ b/src/sage/functions/special.py
+@@ -849,7 +849,7 @@ class EllipticF(BuiltinFunction):
+     - :wikipedia:`Elliptic_integral#Incomplete_elliptic_integral_of_the_first_kind`
+     """
+     def __init__(self):
+-        """
++        r"""
+         EXAMPLES::
+ 
+             sage: loads(dumps(elliptic_f))
diff --git a/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch b/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch
deleted file mode 100644
index f3eb0aad2cca..000000000000
--- a/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch
+++ /dev/null
@@ -1,14 +0,0 @@
- - this is not a proper fix... should fix sage_getfile() instead
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -187,7 +187,8 @@ def loadable_module_extension():
-         True
-     """
-     # Return the full platform-specific extension module suffix
--    return import_machinery.EXTENSION_SUFFIXES[0]
-+    # PATCHED for void linux, we use the shortest extension (.so)
-+    return import_machinery.EXTENSION_SUFFIXES[-1]
- 
- 
- def isclassinstance(obj):
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 0d793262d572..8df50e4e13b6 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,7 +1,7 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=9.5
-revision=2
+version=9.7
+revision=1
 wrksrc=sage-$version
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
@@ -33,12 +33,9 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="http://sagemath.org/"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=8d70a3b26080802c5b2e33dda4c23795d494d8216a0c2ecfcd608ebab0e64ff6
+checksum=9f26f14aa322e3cf38a71835b12ac34b23026b467f74d54b064c5d025e76fbfd
 
 post_patch() {
-	# these are unused and nothing else uses ratpoints
-	rm sage/libs/ratpoints.{pyx,pxd}
-
 	# git tree needs bootstrapping
 	pushd $wrksrc/build/pkgs/sagelib
 	PATH=../../bin:$PATH BOOTSTRAP_QUIET=no ./bootstrap
@@ -65,6 +62,7 @@ do_configure() {
 
 pre_build() {
 	export PYTHONPATH=../sage-setup
+	export PYTHONDONTWRITEBYTECODE=yes
 	export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
 }
 
@@ -77,6 +75,7 @@ post_build() {
 
 pre_install() {
 	export PYTHONPATH=../sage-setup
+	export PYTHONDONTWRITEBYTECODE=yes
 	export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
 }
 
@@ -104,6 +103,7 @@ post_install() {
 do_check() {
 	_scripts=$(cd build/scripts* && pwd)
 	export PYTHONPATH=$(cd build/lib* && pwd)
+	export PYTHONDONTWRITEBYTECODE=yes
 
 	# get out of $build_wrksrc, otherwise python picks the wrong sage module
 	cd $(mktemp -dp build)

From 3f56c87612afa08f9a7ea021f7853dad829ace6c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Sat, 15 Oct 2022 23:21:33 -0300
Subject: [PATCH 13/15] sagemath: use conf files instead of patching

---
 srcpkgs/sagemath/files/sage-env-config |  3 ++
 srcpkgs/sagemath/files/sage_conf.py    |  3 ++
 srcpkgs/sagemath/template              | 40 ++++++++------------------
 3 files changed, 18 insertions(+), 28 deletions(-)
 create mode 100644 srcpkgs/sagemath/files/sage-env-config
 create mode 100644 srcpkgs/sagemath/files/sage_conf.py

diff --git a/srcpkgs/sagemath/files/sage-env-config b/srcpkgs/sagemath/files/sage-env-config
new file mode 100644
index 000000000000..7d2f97d92214
--- /dev/null
+++ b/srcpkgs/sagemath/files/sage-env-config
@@ -0,0 +1,3 @@
+# configure PATH using sage script location
+export PATH="$(dirname $SELF):$PATH"
+#export PYTHONPATH="$(cd $(dirname $SELF)/../lib/python*/site-packages/ && pwd):$PYTHONPATH"
diff --git a/srcpkgs/sagemath/files/sage_conf.py b/srcpkgs/sagemath/files/sage_conf.py
new file mode 100644
index 000000000000..85ec37dfb50e
--- /dev/null
+++ b/srcpkgs/sagemath/files/sage_conf.py
@@ -0,0 +1,3 @@
+# configuration for sage on void linux
+SAGE_SHARE = "/usr/share/sagemath"
+GAP_ROOT_DIR = "/usr/share/gap"
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 8df50e4e13b6..51d8067a7d3c 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -5,7 +5,7 @@ revision=1
 wrksrc=sage-$version
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
-_bindir=/usr/lib/sagemath/bin
+_bindir=/usr/lib/sagemath/${version}/bin
 make_install_args="--install-scripts=$_bindir"
 hostmakedepends="m4 pkg-config python3-Cython python3-Jinja2 python3-pkgconfig
  python3-setuptools"
@@ -35,29 +35,10 @@ homepage="http://sagemath.org/"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
 checksum=9f26f14aa322e3cf38a71835b12ac34b23026b467f74d54b064c5d025e76fbfd
 
-post_patch() {
-	# git tree needs bootstrapping
-	pushd $wrksrc/build/pkgs/sagelib
-	PATH=../../bin:$PATH BOOTSTRAP_QUIET=no ./bootstrap
-	popd
-}
-
 do_configure() {
-	# set variables in sage.env since we do not install sage_conf
-	cat >> sage/env.py <<-EOF
-	CONWAY_POLYNOMIALS_DATA_DIR = "/usr/share/sagemath/conway_polynomials"
-	GRAPHS_DATA_DIR = "/usr/share/sagemath/graphs"
-	ELLCURVE_DATA_DIR = "/usr/share/sagemath/ellcurves"
-	POLYTOPE_DATA_DIR = "/usr/share/sagemath/reflexive_polytopes"
-	COMBINATORIAL_DESIGN_DATA_DIR = "/usr/share/sagemath/combinatorial_designs"
-	CREMONA_MINI_DATA_DIR = "/usr/share/sagemath/cremona"
-	CREMONA_LARGE_DATA_DIR = "/usr/share/sagemath/cremona"
-	THREEJS_DIR = "/usr/share/sagemath/threejs-sage"
-	EOF
-
-	# don't install sage-venv-config: it is used to set SAGE_VENV=/usr and
-	# then sage-env prepends "$SAGE_VENV/bin" to PATH which is undesired
-	vsed -e '/sage-venv-config/d' -i $wrksrc/src/setup.cfg
+	# git tree needs bootstrapping
+	(cd "$wrksrc/build/pkgs/sagelib" &&
+	 PATH=../../bin:$PATH BOOTSTRAP_QUIET=no ./bootstrap)
 }
 
 pre_build() {
@@ -67,10 +48,13 @@ pre_build() {
 }
 
 post_build() {
+	_lib=$(cd build/lib* && pwd)
 	_scripts=$(cd build/scripts* && pwd)
-	cat >> $_scripts/sage-env-config <<-'EOF'
-	PATH=$(dirname $SELF):$PATH
-	EOF
+	# remove sage-venv-config since it clobbers PATH
+	rm "$_scripts/sage-venv-config"
+	# configuration files
+	cp "${FILESDIR}/sage-env-config" "$_scripts"
+	cp "${FILESDIR}/sage_conf.py" "$_lib"
 }
 
 pre_install() {
@@ -81,7 +65,7 @@ pre_install() {
 
 post_install() {
 	# fix jupyter kernel spec
-	vsed -i -e 's|"/usr/bin/sage", "--python"|"/usr/bin/python"|' \
+	vsed -i -e 's|"/usr/bin/sage"|"'"$_bindir"'/sage"|' \
 		${DESTDIR}/usr/share/jupyter/kernels/sagemath/kernel.json
 	# replace broken symlinks by good copies (sagemath logo images)
 	for file in $(ls sage/ext_data/notebook-ipython); do
@@ -91,7 +75,7 @@ post_install() {
 	done
 	# we don't have docs here
 	rm ${DESTDIR}/usr/share/jupyter/kernels/sagemath/doc
-	# we don't have threejs in void
+	# this symlink is shipped in threejs-sage pkg
 	rm ${DESTDIR}/usr/share/jupyter/nbextensions/threejs-sage
 
 	# symlink main binary

From bf079036006ba17bc761e314a78e43429f5aec8e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 17 Oct 2022 00:37:05 -0300
Subject: [PATCH 14/15] sagemath: more fixes

---
 srcpkgs/sagemath/files/sage_conf.py           |   1 +
 ...fc4ec8b8687bccd22d2e3161c86cf5553e06.patch | 427 ++++++++++++++++++
 ....11.patch => trac-33842-python-3.11.patch} |   0
 ...3d67cfcdf8fba7bc6aa7899e2086d42cc7e.patch} |   0
 ...ch => trac-34537-sagemath-pari-2.15.patch} |   0
 ...h => trac-34537-sagemath-pari-2.15b.patch} |   0
 ...0de0dca1cff0355326dd42bd8c7e5749568.patch} |   0
 srcpkgs/sagemath/template                     |  29 +-
 8 files changed, 451 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/sagemath/patches/trac-33446-make_GAP_SO_unnecessary-31e3fc4ec8b8687bccd22d2e3161c86cf5553e06.patch
 rename srcpkgs/sagemath/patches/{python-3.11.patch => trac-33842-python-3.11.patch} (100%)
 rename srcpkgs/sagemath/patches/{trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch => trac-34391-upgrade_gap_4.12-a6c293d67cfcdf8fba7bc6aa7899e2086d42cc7e.patch} (100%)
 rename srcpkgs/sagemath/patches/{sagemath-pari-2.15.patch => trac-34537-sagemath-pari-2.15.patch} (100%)
 rename srcpkgs/sagemath/patches/{sagemath-pari-2.15b.patch => trac-34537-sagemath-pari-2.15b.patch} (100%)
 rename srcpkgs/sagemath/patches/{matplotlib-3.6.patch => trac-34668-matplotlib_3.6-5501e0de0dca1cff0355326dd42bd8c7e5749568.patch} (100%)

diff --git a/srcpkgs/sagemath/files/sage_conf.py b/srcpkgs/sagemath/files/sage_conf.py
index 85ec37dfb50e..cd4b6b6f95b4 100644
--- a/srcpkgs/sagemath/files/sage_conf.py
+++ b/srcpkgs/sagemath/files/sage_conf.py
@@ -1,3 +1,4 @@
 # configuration for sage on void linux
 SAGE_SHARE = "/usr/share/sagemath"
 GAP_ROOT_DIR = "/usr/share/gap"
+#GAP_SO = "/usr/lib/libgap.so.8"
diff --git a/srcpkgs/sagemath/patches/trac-33446-make_GAP_SO_unnecessary-31e3fc4ec8b8687bccd22d2e3161c86cf5553e06.patch b/srcpkgs/sagemath/patches/trac-33446-make_GAP_SO_unnecessary-31e3fc4ec8b8687bccd22d2e3161c86cf5553e06.patch
new file mode 100644
index 000000000000..fb9e0f5a8071
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-33446-make_GAP_SO_unnecessary-31e3fc4ec8b8687bccd22d2e3161c86cf5553e06.patch
@@ -0,0 +1,427 @@
+From 9feec282d039ca25bbefa50710f8217b775ce111 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Thu, 3 Mar 2022 14:47:00 -0300
+Subject: gap: do not directly dlopen() the gap library
+
+This needs the soname (as in sage.env.GAP_SO) which has issues for
+system gap as explained in #33446.
+
+Instead we dlopen() the extension module sage.libs.gap.util which,
+having a link time dependency to libgap, will indirectly dlopen() it.
+
+For the record: by the time we run dlopen() the libgap should be already
+loaded. The purpose of doing it is to change mode to RTLD_GLOBAL so that
+symbols in libgap are placed in the global symbol table. This is
+required to compiled load gap packages.
+
+An easy test that this is working ok is:
+
+    sage: libgap.LoadPackage("io")
+    true
+
+This requires optional spkg `gap_packages` to be installed.
+---
+ src/sage/libs/gap/util.pyx | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/src/sage/libs/gap/util.pyx b/src/sage/libs/gap/util.pyx
+index 344ab88..aff604b 100644
+--- a/src/sage/libs/gap/util.pyx
++++ b/src/sage/libs/gap/util.pyx
+@@ -13,7 +13,7 @@ Utility functions for GAP
+ #*****************************************************************************
+ 
+ from libc.signal cimport signal, SIGCHLD, SIG_DFL
+-from posix.dlfcn cimport dlopen, dlclose, RTLD_NOW, RTLD_GLOBAL
++from posix.dlfcn cimport dlopen, dlclose, dlerror, RTLD_LAZY, RTLD_GLOBAL
+ 
+ from cpython.exc cimport PyErr_Fetch, PyErr_Restore
+ from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE
+@@ -232,12 +232,12 @@ cdef initialize():
+     # this isn't portable
+ 
+     cdef void* handle
+-    libgapname = str_to_bytes(sage.env.GAP_SO)
+-    handle = dlopen(libgapname, RTLD_NOW | RTLD_GLOBAL)
++    # reload the current module to force reload of libgap (see #33446)
++    lib = str_to_bytes(__loader__.path, FS_ENCODING, "surrogateescape")
++    handle = dlopen(lib, RTLD_GLOBAL|RTLD_LAZY)
+     if handle is NULL:
+-        raise RuntimeError(
+-                "Could not dlopen() libgap even though it should already "
+-                "be loaded!")
++        err = dlerror()
++        raise RuntimeError(f"Could not reload gap library with RTLD_GLOBAL ({err})")
+     dlclose(handle)
+ 
+     # Define argv variable, which we will pass in to
+-- 
+cgit v1.0-1-gd88e
+
+
+From 704a7953b97ab726e2af610724726aa562bc8bf8 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Thu, 3 Mar 2022 23:00:07 -0300
+Subject: singular: do not directly dlopen() the singular library
+
+Same as for gap in the previous commit. Instead of requiring the soname
+(as in sage.env.LIBSINGULAR_PATH) we dlopen() the extension module
+sage.libs.singular.singular which will indirectly dlopen() libSingular.
+---
+ src/sage/libs/singular/singular.pyx | 15 ++++-----------
+ 1 file changed, 4 insertions(+), 11 deletions(-)
+
+diff --git a/src/sage/libs/singular/singular.pyx b/src/sage/libs/singular/singular.pyx
+index d8ea7b0..4beb177 100644
+--- a/src/sage/libs/singular/singular.pyx
++++ b/src/sage/libs/singular/singular.pyx
+@@ -1705,14 +1705,7 @@ cdef object si2sa_intvec(intvec *v):
+ cdef extern from *: # hack to get at cython macro
+     int unlikely(int)
+ 
+-cdef extern from "dlfcn.h":
+-    void *dlopen(char *, long)
+-    char *dlerror()
+-    void dlclose(void *handle)
+-
+-cdef extern from "dlfcn.h":
+-    cdef long RTLD_LAZY
+-    cdef long RTLD_GLOBAL
++from posix.dlfcn cimport dlopen, dlclose, dlerror, RTLD_LAZY, RTLD_GLOBAL
+ 
+ cdef int overflow_check(unsigned long e, ring *_ring) except -1:
+     """
+@@ -1762,8 +1755,6 @@ cdef init_libsingular():
+ 
+     cdef void *handle = NULL
+ 
+-    from sage.env import LIBSINGULAR_PATH
+-    lib = str_to_bytes(LIBSINGULAR_PATH, FS_ENCODING, "surrogateescape")
+ 
+     # This is a workaround for https://github.com/Singular/Singular/issues/1113
+     # and can be removed once that fix makes it into release of Singular that
+@@ -1780,10 +1771,12 @@ cdef init_libsingular():
+ 
+     import platform
+     if not platform.system().startswith("CYGWIN"):
++        # reload the current module to force reload of libSingular (see #33446)
++        lib = str_to_bytes(__loader__.path, FS_ENCODING, "surrogateescape")
+         handle = dlopen(lib, RTLD_GLOBAL|RTLD_LAZY)
+         if not handle:
+             err = dlerror()
+-            raise ImportError(f"cannot load Singular library from {LIBSINGULAR_PATH} ({err})")
++            raise RuntimeError(f"Could not reload Singular library with RTLD_GLOBAL ({err})")
+ 
+     # load SINGULAR
+     siInit(lib)
+-- 
+cgit v1.0-1-gd88e
+
+
+From d7145c14ef58acfbe00d8f941d2802e96ad4ba15 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Fri, 4 Mar 2022 16:37:34 -0300
+Subject: singular: remove LIBSINGULAR_PATH, no longer needed
+
+---
+ build/pkgs/singular/spkg-configure.m4 | 63 +----------------------------------
+ pkgs/sage-conf/_sage_conf/_conf.py.in |  3 --
+ src/sage/env.py                       |  6 ----
+ 3 files changed, 1 insertion(+), 71 deletions(-)
+
+diff --git a/build/pkgs/singular/spkg-configure.m4 b/build/pkgs/singular/spkg-configure.m4
+index af2eb85..6d3d3da 100644
+--- a/build/pkgs/singular/spkg-configure.m4
++++ b/build/pkgs/singular/spkg-configure.m4
+@@ -9,52 +9,7 @@ SAGE_SPKG_CONFIGURE([singular], [
+        AC_MSG_CHECKING([that Singular's help is working])
+        AS_IF([test x`printf "system(\"--browser\", \"builtin\"); \n help;" | Singular 2>&1 | grep "error\ occurred"` = x], [
+         AC_MSG_RESULT(yes)
+-        dnl We have Singular. Now determine the shared library path on
+-        dnl platforms on which sage.libs.singular needs to reload the library with RTLD_GLOBAL.
+-        AS_CASE([$host_os],
+-          [cygwin*], [dnl Nothing to do
+-                     ],
+-                     [dnl Use pkg-config to get singular's libdir while we're at it. As a
+-                      dnl moral compromise for using pkg-config, this ultimately allows us
+-                      dnl to pass an absolute path to dlopen(), which is the only approach
+-                      dnl that POSIX guarantees will work.
+-                      PKG_CHECK_VAR([SINGULAR_LIB_DIR], [Singular], [libdir])
+-                      dnl The acl_shlibext variable is set in the top-level configure.ac.
+-                      AC_LANG_PUSH(C)
+-                      ORIG_LIBS="${LIBS}"
+-                      LIBS="${LIBS} -ldl"
+-                      AC_MSG_CHECKING([if we can dlopen($LIBSINGULAR_PATH)])
+-                      LIBSINGULAR_PATH="${SINGULAR_LIB_DIR}/libSingular.${acl_shlibext}"
+-
+-                      dnl if we can dlopen() it, substitute the name for sage_conf;
+-                      dnl otherwise, fall back to using the SPKG.
+-                      AC_RUN_IFELSE(
+-                        [AC_LANG_PROGRAM(
+-                          [[#include <dlfcn.h>]],
+-                          [[void* h = dlopen("${LIBSINGULAR_PATH}", RTLD_LAZY | RTLD_GLOBAL);
+-                            if (h == 0) { return 1; } else { return dlclose(h); }]]
+-                        )], [
+-                          AC_MSG_RESULT(yes)
+-                        ], [
+-                          dnl try Debian-specific name
+-                          LIBSINGULAR_PATH="${SINGULAR_LIB_DIR}/libsingular-Singular.${acl_shlibext}"
+-                          AC_RUN_IFELSE(
+-                           [AC_LANG_PROGRAM(
+-                             [[#include <dlfcn.h>]],
+-                             [[void* h = dlopen("${LIBSINGULAR_PATH}", RTLD_LAZY | RTLD_GLOBAL);
+-                               if (h == 0) { return 1; } else { return dlclose(h); }]]
+-                           )], [
+-                             AC_MSG_RESULT(yes)
+-                           ], [
+-                            AC_MSG_RESULT(no)
+-                            sage_spkg_install_singular=yes
+-                          ], [AC_MSG_RESULT(yes)])
+-                        ], [AC_MSG_RESULT(yes)])
+-
+-                      AC_LANG_POP()
+-                      LIBS="${ORIG_LIBS}"
+-                     ]
+-       )], [
++       ], [
+        AC_MSG_RESULT(no)
+        sage_spkg_install_singular=yes
+        ]
+@@ -64,20 +19,4 @@ SAGE_SPKG_CONFIGURE([singular], [
+       ])
+     ])
+   ])
+-],[],[],[
+-  dnl Post-check phase
+-  dnl We make the sage_conf substitutions here, because the "default"
+-  dnl substitution needs to be made even if we skipped the system-Singular
+-  dnl checks themselves.
+-  AS_IF([test "x${sage_spkg_install_singular}" = "xyes"], [
+-    AS_CASE([$host_os],
+-      [cygwin*], [dnl Nothing to do
+-                 ],
+-                 [dnl Set shared library path, needed for reloading the library with RTLD_GLOBAL
+-                  LIBSINGULAR_PATH="\$SAGE_LOCAL/lib/libSingular.${acl_shlibext}"
+-                 ]
+-    )
+-  ])
+-
+-  AC_SUBST(LIBSINGULAR_PATH, "${LIBSINGULAR_PATH}")
+ ])
+diff --git a/pkgs/sage-conf/_sage_conf/_conf.py.in b/pkgs/sage-conf/_sage_conf/_conf.py.in
+index 6cd28f5..d66bdb3 100644
+--- a/pkgs/sage-conf/_sage_conf/_conf.py.in
++++ b/pkgs/sage-conf/_sage_conf/_conf.py.in
+@@ -55,9 +55,6 @@ THREEJS_DIR = SAGE_LOCAL + "/share/threejs-sage"
+ OPENMP_CFLAGS = "@OPENMP_CFLAGS@"
+ OPENMP_CXXFLAGS = "@OPENMP_CXXFLAGS@"
+ 
+-# The full absolute path to the main Singular library.
+-LIBSINGULAR_PATH = "@LIBSINGULAR_PATH@".replace('$SAGE_LOCAL', SAGE_LOCAL)
+-
+ # Installation location of wheels. This is determined at configuration time
+ # and does not depend on the installation location of sage-conf.
+ SAGE_SPKG_WHEELS = "@SAGE_VENV@".replace('${SAGE_LOCAL}', SAGE_LOCAL) + "/var/lib/sage/wheels"
+diff --git a/src/sage/env.py b/src/sage/env.py
+index 911f34b..93f79de 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -229,12 +229,6 @@ NTL_LIBDIR = var("NTL_LIBDIR")
+ LIE_INFO_DIR = var("LIE_INFO_DIR", join(SAGE_LOCAL, "lib", "LiE"))
+ SINGULAR_BIN = var("SINGULAR_BIN") or "Singular"
+ 
+-# The path to libSingular, to be passed to dlopen(). This will
+-# typically be set to an absolute path in sage_conf, but the relative
+-# fallback path here works on systems where dlopen() searches the
+-# system's library locations.
+-LIBSINGULAR_PATH = var("LIBSINGULAR_PATH", "libSingular.so")
+-
+ # OpenMP
+ OPENMP_CFLAGS = var("OPENMP_CFLAGS", "")
+ OPENMP_CXXFLAGS = var("OPENMP_CXXFLAGS", "")
+-- 
+cgit v1.0-1-gd88e
+
+
+From 92e5a211c792f86f5325d601abfddf667da6a776 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Fri, 4 Mar 2022 15:49:26 -0300
+Subject: Revert "src/sage/interfaces/gap_workspace.py: Use hash of GAP_SO to
+ disambiguate the workspace file, not SAGE_LOCAL"
+
+This reverts commit a801e6d85bd420b60ea75b1671856eb43ac6b18b.
+
+See #33446.
+---
+ src/sage/interfaces/gap_workspace.py | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+diff --git a/src/sage/interfaces/gap_workspace.py b/src/sage/interfaces/gap_workspace.py
+index 33a87dd..953dc85 100644
+--- a/src/sage/interfaces/gap_workspace.py
++++ b/src/sage/interfaces/gap_workspace.py
+@@ -16,7 +16,7 @@ Support for (lib)GAP workspace files
+ import os
+ import time
+ import hashlib
+-from sage.env import DOT_SAGE, GAP_SO
++from sage.env import DOT_SAGE, SAGE_LOCAL
+ 
+ 
+ def gap_workspace_file(system="gap", name="workspace", dir=None):
+@@ -59,10 +59,7 @@ def gap_workspace_file(system="gap", name="workspace", dir=None):
+     if dir is None:
+         dir = os.path.join(DOT_SAGE, 'gap')
+ 
+-    if GAP_SO:
+-        h = hashlib.sha1(GAP_SO.encode('utf-8')).hexdigest()
+-    else:
+-        h = 'unknown'
++    h = hashlib.sha1(SAGE_LOCAL.encode('utf-8')).hexdigest()
+     return os.path.join(dir, '%s-%s-%s' % (system, name, h))
+ 
+ 
+-- 
+cgit v1.0-1-gd88e
+
+
+From b45e555b5711ae10d369b568333940c2aa771053 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Fri, 4 Mar 2022 16:38:49 -0300
+Subject: gap: remove GAP_SO, no longer needed
+
+---
+ src/sage/env.py | 75 ---------------------------------------------------------
+ 1 file changed, 75 deletions(-)
+
+diff --git a/src/sage/env.py b/src/sage/env.py
+index 93f79de..c16a094 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -249,81 +249,6 @@ if SAGE_GAP_MEMORY is not None:
+ SAGE_GAP_COMMAND = var('SAGE_GAP_COMMAND', _gap_cmd)
+ 
+ 
+-def _get_shared_lib_path(*libnames: str) -> Optional[str]:
+-    """
+-    Return the full path to a shared library file installed in
+-    ``$SAGE_LOCAL/lib`` or the directories associated with the
+-    Python sysconfig.
+-
+-    This can also be passed more than one library name (e.g. for cases where
+-    some library may have multiple names depending on the platform) in which
+-    case the first one found is returned.
+-
+-    This supports most *NIX variants (in which ``lib<libname>.so`` is found
+-    under ``$SAGE_LOCAL/lib``), macOS (same, but with the ``.dylib``
+-    extension), and Cygwin (under ``$SAGE_LOCAL/bin/cyg<libname>.dll``,
+-    or ``$SAGE_LOCAL/bin/cyg<libname>-*.dll`` for versioned DLLs).
+-
+-    For distributions like Debian that use a multiarch layout, we also try the
+-    multiarch lib paths (i.e. ``/usr/lib/<arch>/``).
+-
+-    This returns ``None`` if no matching library file could be found.
+-
+-    EXAMPLES::
+-
+-        sage: from sage.env import _get_shared_lib_path
+-        sage: "gap" in _get_shared_lib_path("gap")
+-        True
+-        sage: _get_shared_lib_path("an_absurd_lib") is None
+-        True
+-
+-    """
+-
+-    for libname in libnames:
+-        search_directories: List[Path] = []
+-        patterns: List[str] = []
+-        if sys.platform == 'cygwin':
+-            # Later down we take the first matching DLL found, so search
+-            # SAGE_LOCAL first so that it takes precedence
+-            if SAGE_LOCAL:
+-                search_directories.append(Path(SAGE_LOCAL) / 'bin')
+-            search_directories.append(Path(sysconfig.get_config_var('BINDIR')))
+-            # Note: The following is not very robust, since if there are multible
+-            # versions for the same library this just selects one more or less
+-            # at arbitrary. However, practically speaking, on Cygwin, there
+-            # will only ever be one version
+-            patterns = [f'cyg{libname}.dll', f'cyg{libname}-*.dll']
+-        else:
+-            if sys.platform == 'darwin':
+-                ext = 'dylib'
+-            else:
+-                ext = 'so'
+-
+-            if SAGE_LOCAL:
+-                search_directories.append(Path(SAGE_LOCAL) / 'lib')
+-            libdir = sysconfig.get_config_var('LIBDIR')
+-            if libdir is not None:
+-                libdir = Path(libdir)
+-                search_directories.append(libdir)
+-
+-                multiarchlib = sysconfig.get_config_var('MULTIARCH')
+-                if multiarchlib is not None:
+-                    search_directories.append(libdir / multiarchlib),
+-
+-            patterns = [f'lib{libname}.{ext}']
+-
+-        for directory in search_directories:
+-            for pattern in patterns:
+-                path = next(directory.glob(pattern), None)
+-                if path is not None:
+-                    return str(path.resolve())
+-
+-    # Just return None if no files were found
+-    return None
+-
+-# locate libgap shared object
+-GAP_SO = var("GAP_SO", _get_shared_lib_path("gap", ""))
+-
+ # post process
+ if DOT_SAGE is not None and ' ' in DOT_SAGE:
+     if UNAME[:6] == 'CYGWIN':
+-- 
+cgit v1.0-1-gd88e
+
+
+From 31e3fc4ec8b8687bccd22d2e3161c86cf5553e06 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Sun, 6 Mar 2022 12:10:37 -0300
+Subject: gap_workspace_file: include hostname and gap version
+
+---
+ src/sage/interfaces/gap_workspace.py | 11 ++++++++---
+ 1 file changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/src/sage/interfaces/gap_workspace.py b/src/sage/interfaces/gap_workspace.py
+index 953dc85..8c03b6b 100644
+--- a/src/sage/interfaces/gap_workspace.py
++++ b/src/sage/interfaces/gap_workspace.py
+@@ -16,7 +16,8 @@ Support for (lib)GAP workspace files
+ import os
+ import time
+ import hashlib
+-from sage.env import DOT_SAGE, SAGE_LOCAL
++import subprocess
++from sage.env import DOT_SAGE, SAGE_LOCAL, HOSTNAME, GAP_ROOT_DIR
+ 
+ 
+ def gap_workspace_file(system="gap", name="workspace", dir=None):
+@@ -59,8 +60,12 @@ def gap_workspace_file(system="gap", name="workspace", dir=None):
+     if dir is None:
+         dir = os.path.join(DOT_SAGE, 'gap')
+ 
+-    h = hashlib.sha1(SAGE_LOCAL.encode('utf-8')).hexdigest()
+-    return os.path.join(dir, '%s-%s-%s' % (system, name, h))
++    data = SAGE_LOCAL
++    sysinfo = os.path.join(GAP_ROOT_DIR, "sysinfo.gap")
++    if os.path.exists(sysinfo):
++        data += subprocess.getoutput(f'. "{sysinfo}" && echo ":$GAP_VERSION:$GAParch"')
++    h = hashlib.sha1(data.encode('utf-8')).hexdigest()
++    return os.path.join(dir, '%s-%s-%s-%s' % (system, name, HOSTNAME, h))
+ 
+ 
+ def prepare_workspace_dir(dir=None):
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/python-3.11.patch b/srcpkgs/sagemath/patches/trac-33842-python-3.11.patch
similarity index 100%
rename from srcpkgs/sagemath/patches/python-3.11.patch
rename to srcpkgs/sagemath/patches/trac-33842-python-3.11.patch
diff --git a/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch b/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-a6c293d67cfcdf8fba7bc6aa7899e2086d42cc7e.patch
similarity index 100%
rename from srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch
rename to srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-a6c293d67cfcdf8fba7bc6aa7899e2086d42cc7e.patch
diff --git a/srcpkgs/sagemath/patches/sagemath-pari-2.15.patch b/srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15.patch
similarity index 100%
rename from srcpkgs/sagemath/patches/sagemath-pari-2.15.patch
rename to srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15.patch
diff --git a/srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch b/srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15b.patch
similarity index 100%
rename from srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch
rename to srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15b.patch
diff --git a/srcpkgs/sagemath/patches/matplotlib-3.6.patch b/srcpkgs/sagemath/patches/trac-34668-matplotlib_3.6-5501e0de0dca1cff0355326dd42bd8c7e5749568.patch
similarity index 100%
rename from srcpkgs/sagemath/patches/matplotlib-3.6.patch
rename to srcpkgs/sagemath/patches/trac-34668-matplotlib_3.6-5501e0de0dca1cff0355326dd42bd8c7e5749568.patch
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 51d8067a7d3c..1872c2711b1e 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -37,8 +37,10 @@ checksum=9f26f14aa322e3cf38a71835b12ac34b23026b467f74d54b064c5d025e76fbfd
 
 do_configure() {
 	# git tree needs bootstrapping
-	(cd "$wrksrc/build/pkgs/sagelib" &&
-	 PATH=../../bin:$PATH BOOTSTRAP_QUIET=no ./bootstrap)
+	( cd "$wrksrc/build/pkgs/sagelib" &&
+	  PATH=../../bin:$PATH \
+	  BOOTSTRAP_QUIET=no \
+	  ./bootstrap )
 }
 
 pre_build() {
@@ -48,13 +50,26 @@ pre_build() {
 }
 
 post_build() {
-	_lib=$(cd build/lib* && pwd)
+	_libs=$(cd build/lib* && pwd)
 	_scripts=$(cd build/scripts* && pwd)
+
 	# remove sage-venv-config since it clobbers PATH
 	rm "$_scripts/sage-venv-config"
-	# configuration files
-	cp "${FILESDIR}/sage-env-config" "$_scripts"
-	cp "${FILESDIR}/sage_conf.py" "$_lib"
+
+	# sage-env configuration (bash)
+	cat >> "$_scripts/sage-env-config" <<-'EOF'
+	# configure PATH using sage script location
+	PATH=$(dirname $SELF):$PATH
+	#export PYTHONPATH="$(cd $(dirname $SELF)/../lib/python*/site-packages/ && pwd):$PYTHONPATH"
+	EOF
+
+	# sage.env configuration (python)
+	cat >> "$_libs/sage_conf.py" <<-'EOF'
+	# configuration for sage on void linux
+	SAGE_SHARE = "/usr/share/sagemath"
+	GAP_ROOT_DIR = "/usr/share/gap"
+	#GAP_SO = "/usr/lib/libgap.so.8"
+	EOF
 }
 
 pre_install() {
@@ -67,12 +82,14 @@ post_install() {
 	# fix jupyter kernel spec
 	vsed -i -e 's|"/usr/bin/sage"|"'"$_bindir"'/sage"|' \
 		${DESTDIR}/usr/share/jupyter/kernels/sagemath/kernel.json
+
 	# replace broken symlinks by good copies (sagemath logo images)
 	for file in $(ls sage/ext_data/notebook-ipython); do
 		rm ${DESTDIR}/usr/share/jupyter/kernels/sagemath/$file
 		cp -a sage/ext_data/notebook-ipython/$file \
 			${DESTDIR}/usr/share/jupyter/kernels/sagemath
 	done
+
 	# we don't have docs here
 	rm ${DESTDIR}/usr/share/jupyter/kernels/sagemath/doc
 	# this symlink is shipped in threejs-sage pkg

From 9ec08d3b2b2e1f4198f38a5f4f1389de57388766 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 17 Oct 2022 01:44:09 -0300
Subject: [PATCH 15/15] sagemath: more fixes

---
 srcpkgs/sagemath/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 1872c2711b1e..3a92f583fecb 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -53,14 +53,15 @@ post_build() {
 	_libs=$(cd build/lib* && pwd)
 	_scripts=$(cd build/scripts* && pwd)
 
-	# remove sage-venv-config since it clobbers PATH
-	rm "$_scripts/sage-venv-config"
-
 	# sage-env configuration (bash)
 	cat >> "$_scripts/sage-env-config" <<-'EOF'
 	# configure PATH using sage script location
 	PATH=$(dirname $SELF):$PATH
 	#export PYTHONPATH="$(cd $(dirname $SELF)/../lib/python*/site-packages/ && pwd):$PYTHONPATH"
+
+	# if SAGE_VENV is set, the script sage-env will prepend
+	# "$SAGE_VENV/bin" to the PATH, which is undesired
+	unset SAGE_VENV
 	EOF
 
 	# sage.env configuration (python)
@@ -68,7 +69,6 @@ post_build() {
 	# configuration for sage on void linux
 	SAGE_SHARE = "/usr/share/sagemath"
 	GAP_ROOT_DIR = "/usr/share/gap"
-	#GAP_SO = "/usr/lib/libgap.so.8"
 	EOF
 }
 

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PR PATCH] [Updated] DRAFT: sagemath update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (16 preceding siblings ...)
  2022-10-17  4:51 ` tornaria
@ 2022-10-29  2:30 ` tornaria
  2022-10-29 11:02 ` tornaria
                   ` (14 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: tornaria @ 2022-10-29  2:30 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1883 bytes --]

There is an updated pull request by tornaria against master on the void-packages repository

https://github.com/tornaria/void-packages sagemath-update
https://github.com/void-linux/void-packages/pull/39876

DRAFT: sagemath update to 9.7
This includes #39838, #39840, #39846, #39872, #39866, also update eclib-20220621.

For now I'm reverting python3-matplotlib to 3.5.3_1 since 3.6.0_1 gives a lot of problems (#39857 adds python3-contourpy which will solve some, but I think there are more issues).

I want to make sure everything works ok and the full testsuite passes as is. Then I'll just move matplotlib back to 3.6.0_1 and try to see if it's feasible to fix or workaround the issues (sagemath-the-distro is still on matplotlib 3.5.2 and I didn't find anything about the update to 3.6.0)

<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: currently running the testsuite in --long after the update of singular.

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/39876.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-sagemath-update-39876.patch --]
[-- Type: text/x-diff, Size: 276474 bytes --]

From 7006ff1be722c0035b68352c3e154ced59f9540a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 19:14:02 -0300
Subject: [PATCH 01/21] flintlib: update to 2.9.0.

---
 common/shlibs             | 2 +-
 srcpkgs/flintlib/template | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index c1b969e9d0b4..2d3547e10d4a 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4020,7 +4020,7 @@ libgtkdatabox.so.1 gtkdatabox3-1.0.0_1
 libxcvt.so.0 libxcvt-0.1.1_1
 libgf2x.so.3 gf2x-1.3.0_1
 libntl.so.44 ntl-11.5.1_1
-libflint.so.16 flintlib-2.8.0_1
+libflint.so.17 flintlib-2.9.0_1
 libarb.so.2 arb-2.20.0_1
 libec.so.8 eclib-20210625_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index 968dbcb525c2..27f202b4434c 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,6 +1,6 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.8.5
+version=2.9.0
 revision=1
 wrksrc="flint-${version}"
 build_style=configure
@@ -14,11 +14,10 @@ license="LGPL-2.1-or-later"
 homepage="https://flintlib.org"
 changelog="https://raw.githubusercontent.com/wbhart/flint2/trunk/NEWS"
 distfiles="https://flintlib.org/flint-${version}.tar.gz"
-checksum=5911fedff911100f15781f35e3a4fa934fe60e4aea02a8c10cc8918101c1eed8
+checksum=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
-build_options_default=""
 
 if [ -z "$CROSS_BUILD" ]; then
 	build_options_default+=" ntl"

From 6ae733bdcfb0aeea562154e6a0cffd5b5f46b551 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 19:16:18 -0300
Subject: [PATCH 02/21] arb: update to 2.23.0.

---
 srcpkgs/arb/template | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
index 52f11ef83c90..84a62c7ffdba 100644
--- a/srcpkgs/arb/template
+++ b/srcpkgs/arb/template
@@ -1,6 +1,6 @@
 # Template file for 'arb'
 pkgname=arb
-version=2.22.1
+version=2.23.0
 revision=1
 build_style=configure
 configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
@@ -11,9 +11,7 @@ license="LGPL-2.1-or-later"
 homepage="https://arblib.org"
 changelog="https://raw.githubusercontent.com/fredrik-johansson/arb/master/doc/source/history.rst"
 distfiles="https://github.com/fredrik-johansson/arb/archive/${version}.tar.gz"
-checksum=1ef85518eee04885e8a90196498bc75e4e2410621d4184f2bc01d46b7080a243
-
-CFLAGS="-D_GNU_SOURCE" # needed for cpu_set_t
+checksum=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
 
 arb-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"

From 323d456e51c061dc5c7dfe4263b7421607beb116 Mon Sep 17 00:00:00 2001
From: dkwo <nicolopiazzalunga@gmail.com>
Date: Mon, 10 Oct 2022 10:14:06 -0400
Subject: [PATCH 03/21] singular: update to 4.3.1p2 (fix gcc 12 build)

---
 common/shlibs             | 10 +++++-----
 srcpkgs/singular/template | 26 ++++++++++++++------------
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 2d3547e10d4a..f698e1a78bb8 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4062,11 +4062,11 @@ libumfpack.so.5 SuiteSparse-5.10.1_1
 libecl.so.21.2 ecl-21.2.1_1
 libecm.so.1 ecm-7.0.4_3
 libcliquer.so.1 cliquer-1.22_1
-libSingular-4.3.0.so singular-4.3.0_1
-libfactory-4.3.0.so singular-4.3.0_1
-libpolys-4.3.0.so singular-4.3.0_1
-libomalloc-0.9.6.so singular-4.3.0_1
-libsingular_resources-4.3.0.so singular-4.3.0_1
+libSingular-4.3.1.so singular-4.3.1p2_1
+libfactory-4.3.1.so singular-4.3.1p2_1
+libpolys-4.3.1.so singular-4.3.1p2_1
+libomalloc-0.9.6.so singular-4.3.1p2_1
+libsingular_resources-4.3.1.so singular-4.3.1p2_1
 libbrial.so.3 brial-1.2.10_1
 libbrial_groebner.so.3 brial-1.2.10_1
 libm4ri-0.0.20200125.so m4ri-20200125_1
diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index f23659ef5d83..a30beef915d2 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,25 +1,27 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.0
+version=4.3.1p2
 revision=1
+_majver=${version%p*}
+wrksrc=singular-${_majver}
 build_style=gnu-configure
 configure_args="--with-readline=ncurses
-	--enable-gfanlib
-	--enable-Singular
-	--enable-factory
-	--disable-doc
-	--disable-polymake
-	--without-python
-	--with-libparse
-	ac_cv_lib_cddgmp_dd_free_global_constants=yes"
+ --enable-gfanlib
+ --enable-Singular
+ --enable-factory
+ --disable-doc
+ --disable-polymake
+ --without-python
+ --with-libparse
+ ac_cv_lib_cddgmp_dd_free_global_constants=yes"
 hostmakedepends="perl tar doxygen"
 makedepends="flintlib-devel cddlib-devel readline-devel graphviz"
 short_desc="Computer algebra system for polynomial computations"
-maintainer="dkwo <nicolopiazzalunga@gmail.com>"
+maintainer="dkwo <npiazza@disroot.org>"
 license="GPL-2.0-or-later"
 homepage="https://www.singular.uni-kl.de"
-distfiles="https://www.singular.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${version//./-}/singular-${version}.tar.gz"
-checksum=74f38288203720e3f280256f2f8deb94030dd032b4237d844652aff0faab36e7
+distfiles="https://www.singular.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${_majver//./-}/singular-${version}.tar.gz"
+checksum=95814bba0f0bd0290cd9799ec1d2ecc6f4c8a4e6429d9a02eb7f9c4e5649682a
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From 0aa84fc120c3d12500cd7c96e9c6349158a68987 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 19:59:20 -0300
Subject: [PATCH 04/21] pari: update to 2.15.0.

---
 common/shlibs                      |  3 +-
 srcpkgs/pari/patches/float32.patch | 48 ++++++++++++++++++++++++++++++
 srcpkgs/pari/template              | 12 ++++++--
 3 files changed, 58 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/pari/patches/float32.patch

diff --git a/common/shlibs b/common/shlibs
index f698e1a78bb8..b8b3fbc69285 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4011,8 +4011,7 @@ libsimavrparts.so.1 simavr-1.6_2
 libsword-1.8.1.so libsword-1.8.1_6
 libgivaro.so.9 givaro-4.1.1_1
 liblinbox.so.0 linbox-1.6.3_1
-libpari-gmp.so.7 pari-2.13.0_1
-libpari-gmp-tls.so.7 pari-2.13.2_1
+libpari-gmp-tls.so.8 pari-2.15.0_1
 libtree-sitter.so.0 tree-sitter-0.19.0_1
 libplanarity.so.0 planarity-3.0.1.1_1
 libgap.so.0 gap-4.11.1_1
diff --git a/srcpkgs/pari/patches/float32.patch b/srcpkgs/pari/patches/float32.patch
new file mode 100644
index 000000000000..311dd6bf5a07
--- /dev/null
+++ b/srcpkgs/pari/patches/float32.patch
@@ -0,0 +1,48 @@
+Author: Gonzalo Tornaría <tornaria@cmat.edu.uy>
+Date:   Fri Oct 14 17:00:46 2022 -0300
+
+    Revert "x86 (32bit): force -mpc64 on compilers that supports it."
+    
+    This reverts commit ca61b6391cf95ac8af15669236e2ec5839d2ad91.
+
+
+This causes problems with floating point precision on i686:
+```
+$ cat exp40.c
+#include <math.h>
+#include <stdio.h>
+int main() {
+	volatile int a=40; /* do not optimize away the call to exp(a) */
+	printf("%f\n", exp(a));
+}
+$ cc -Wall exp40.c -lm && ./a.out
+235385266837020000.000000
+$ cc -Wall exp40.c -lm -mpc64 && ./a.out
+235385266837020448.000000
+```
+
+Note that when pari is built using -mpc64, just *linking* with -lpari
+causes the problem!!!
+```
+$ cc -Wall exp40.c -lm -lpari && ./a.out
+235385266837020448.000000
+```
+
+diff --git a/config/get_cc b/config/get_cc
+index 3cfaa88bb7..2d61d3871f 100644
+--- a/config/get_cc
++++ b/config/get_cc
+@@ -110,13 +110,6 @@ if test -n "$__gnuc__"; then
+   # Specific optimisations for some architectures
+   case "$arch" in
+     sparcv8*) cflags=-mv8;;
+-    i?86)
+-      cmd="$CC $CFLAGS $extraflag -mpc64 -fno-strict-aliasing -o $exe gnu.c"
+-      . log_cmd
+-      if test -s $exe; then
+-        cflags="-mpc64"
+-      fi
+-      . cleanup_exe;;
+   esac
+   # problems on some architectures
+   case "$osname" in
diff --git a/srcpkgs/pari/template b/srcpkgs/pari/template
index 8bac1e0343f8..811826a1ee14 100644
--- a/srcpkgs/pari/template
+++ b/srcpkgs/pari/template
@@ -1,6 +1,6 @@
 # Template file for 'pari'
 pkgname=pari
-version=2.13.4
+version=2.15.0
 revision=1
 build_style=configure
 build_helper=qemu
@@ -11,14 +11,15 @@ make_check_target=statest-all
 make_install_target="install install-lib-sta install-lib-dyn"
 hostmakedepends="perl texlive"
 makedepends="gmp-devel readline-devel $(vopt_if x11 libX11-devel)"
-checkdepends="pari-elldata-small pari-galdata pari-galpol-small pari-seadata-small"
+checkdepends="pari-elldata-small pari-galdata pari-galpol-small
+ pari-seadata-small pari-nflistdata"
 short_desc="Fast computations library in number theory"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="https://pari.math.u-bordeaux.fr"
 changelog="https://pari.math.u-bordeaux.fr/cgi-bin/gitweb.cgi?p=pari.git;a=blob_plain;f=CHANGES;hb=refs/heads/pari-${version%.*}"
 distfiles="https://pari.math.u-bordeaux.fr/pub/pari/unix/${pkgname}-${version}.tar.gz"
-checksum=bcde9eceae1592814381c1697cdb7063567b6504201b1be47bb58920f3bce185
+checksum=e474851e0d16d4e4f9a0d9612c746a2ae7c9a1ec185d04c440b1c74a85755685
 
 build_options="x11 pthreads"
 build_options_default="x11 pthreads"
@@ -27,6 +28,11 @@ desc_option_pthreads="Enable support for pthreads"
 # reduce speed losses due to pthreads
 CFLAGS="-flto -fno-semantic-interposition"
 
+case $XBPS_TARGET_MACHINE in
+	# avoid numerical noise caused by extended-precision of registers
+	i686*) CFLAGS+=" -ffloat-store" ;;
+esac
+
 post_patch() {
 	# sse2 is not available on all i686
 	# and it's available on all x86_64

From 2dff7db6a8c99a05a184b7fde9e6279d2bc9deb9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 20:33:23 -0300
Subject: [PATCH 05/21] gp2c: update to 0.0.13.

---
 srcpkgs/gp2c/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gp2c/template b/srcpkgs/gp2c/template
index f82cf95c2d90..9cf0f6fdce6e 100644
--- a/srcpkgs/gp2c/template
+++ b/srcpkgs/gp2c/template
@@ -1,6 +1,6 @@
 # Template file for 'gp2c'
 pkgname=gp2c
-version=0.0.12pl1
+version=0.0.13
 revision=1
 build_style=gnu-configure
 hostmakedepends="perl"
@@ -12,4 +12,4 @@ license="GPL-2.0-or-later"
 homepage="http://pari.math.u-bordeaux.fr/"
 changelog="http://pari.math.u-bordeaux.fr/cgi-bin/gitweb.cgi?p=gp2c.git;a=blob_plain;f=ChangeLog;hb=HEAD"
 distfiles="${homepage}pub/pari/GP2C/${pkgname}-${version}.tar.gz"
-checksum=79a8c46f7ad3331e4d8ae6af6b496c4742fd73a73b996b3ca7ead61452ca6e8d
+checksum=261374eca73ebd76c112a9593dca28b64812aa762561fda5a4b2c2cd79a69d36

From e6bed48f72d7a006bcfda4a4a9eef6c8f07a77c5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Fri, 23 Sep 2022 16:42:40 -0300
Subject: [PATCH 06/21] eclib: update to 20221012.

---
 common/shlibs          | 2 +-
 srcpkgs/eclib/template | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index b8b3fbc69285..a266aacfab99 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4021,7 +4021,7 @@ libgf2x.so.3 gf2x-1.3.0_1
 libntl.so.44 ntl-11.5.1_1
 libflint.so.17 flintlib-2.9.0_1
 libarb.so.2 arb-2.20.0_1
-libec.so.8 eclib-20210625_1
+libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
 liblrcalc.so.2 lrcalc-2.1_1
diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 694a39ed4068..31a3a01921fa 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
-version=20210625
-revision=2
+version=20221012
+revision=1
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 hostmakedepends="automake autoconf-archive libtool"
@@ -11,7 +11,7 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="https://github.com/JohnCremona/eclib"
 distfiles="https://github.com/JohnCremona/eclib/archive/refs/tags/${version}.tar.gz"
-checksum=00333fd36afd237c9e6e410c7ab98536ddcd7fdc430e6837fe293247b835c572
+checksum=bd6f0191876c1426ca57db851ce06ef79ea1755f01e81dd747358d1b76b5e932
 
 pre_configure() {
 	autoreconf -fi

From a2317b08629763ebbe8483c624dbe00f8ca8894f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:20 -0300
Subject: [PATCH 07/21] giac: update to 1.9.0.21.

---
 .../giac/patches/giac-pari-2.15-test.patch    | 10 ++++++++++
 srcpkgs/giac/patches/giac-pari-2.15.patch     | 20 +++++++++++++++++++
 srcpkgs/giac/template                         |  4 ++--
 3 files changed, 32 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/giac/patches/giac-pari-2.15-test.patch
 create mode 100644 srcpkgs/giac/patches/giac-pari-2.15.patch

diff --git a/srcpkgs/giac/patches/giac-pari-2.15-test.patch b/srcpkgs/giac/patches/giac-pari-2.15-test.patch
new file mode 100644
index 000000000000..1f1929571a46
--- /dev/null
+++ b/srcpkgs/giac/patches/giac-pari-2.15-test.patch
@@ -0,0 +1,10 @@
+Fix a failing test due to thread stack overflow
+
+--- a/check/chk_fhan4	2018-03-13 15:27:11.000000000 -0300
++++ b/check/chk_fhan4	2022-10-14 18:51:12.604731890 -0300
+@@ -1,4 +1,5 @@
+ #! /bin/sh
+ unset LANG
++export PARI_SIZE=2048000
+ ../src/icas TP04-sol.cas > TP04.tst
+ diff TP04.tst TP04-sol.cas.out1
diff --git a/srcpkgs/giac/patches/giac-pari-2.15.patch b/srcpkgs/giac/patches/giac-pari-2.15.patch
new file mode 100644
index 000000000000..be409be38f53
--- /dev/null
+++ b/srcpkgs/giac/patches/giac-pari-2.15.patch
@@ -0,0 +1,20 @@
+ANYARG patch
+
+diff --git a/src/pari.cc b/src/pari.cc
+index 76ce8e1..50d08ab 100644
+--- a/src/pari.cc
++++ b/src/pari.cc
+@@ -40,6 +40,13 @@ using namespace std;
+ 
+ #ifdef HAVE_LIBPARI
+ 
++// Anyarg disappeared from PARI 2.15.0
++#ifdef __cplusplus
++#  define ANYARG ...
++#else
++#  define ANYARG
++#endif
++
+ #ifdef HAVE_PTHREAD_H
+ #include <pthread.h>
+ #endif
diff --git a/srcpkgs/giac/template b/srcpkgs/giac/template
index e892c8bf7506..31045e9128ee 100644
--- a/srcpkgs/giac/template
+++ b/srcpkgs/giac/template
@@ -1,6 +1,6 @@
 # Template file for 'giac'
 pkgname=giac
-version=1.9.0.7
+version=1.9.0.21
 revision=1
 wrksrc="giac-${version%.*}"
 build_style=gnu-configure
@@ -14,7 +14,7 @@ license="GPL-3.0-or-later"
 homepage="https://www-fourier.ujf-grenoble.fr/~parisse/giac.html"
 changelog="https://www-fourier.ujf-grenoble.fr/~parisse/install_en#new"
 distfiles="https://www-fourier.ujf-grenoble.fr/~parisse/debian/dists/stable/main/source/giac_${version%.*}-${version##*.}.tar.gz"
-checksum=72016988b7180e9b630ecabecc60969213e7b61418c2598c91acbaec139fd740
+checksum=120cd16f2e033817302d2a03a22bd413dc1d85df8b225ba4f76b93a7805b07fe
 
 # need more than 4*65536 stack, see try_parse() in gen.cc line 11812
 LDFLAGS="-Wl,-z,stack-size=2097152"

From c7c535edb79b6ff50597ba372e4f4911caabb68a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 12 Oct 2022 23:59:37 -0300
Subject: [PATCH 08/21] gap: update to 4.12.0.

---
 common/shlibs                          |  2 +-
 srcpkgs/gap/patches/c57a07a3.patch     | 23 +++++++++++++++++++++++
 srcpkgs/gap/patches/dce6fa96.patch     | 24 ++++++++++++++++++++++++
 srcpkgs/gap/patches/fix-atlasrep.patch | 11 +++++++++++
 srcpkgs/gap/template                   | 12 +++++-------
 5 files changed, 64 insertions(+), 8 deletions(-)
 create mode 100644 srcpkgs/gap/patches/c57a07a3.patch
 create mode 100644 srcpkgs/gap/patches/dce6fa96.patch
 create mode 100644 srcpkgs/gap/patches/fix-atlasrep.patch

diff --git a/common/shlibs b/common/shlibs
index a266aacfab99..57be52a2a1cc 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4014,7 +4014,7 @@ liblinbox.so.0 linbox-1.6.3_1
 libpari-gmp-tls.so.8 pari-2.15.0_1
 libtree-sitter.so.0 tree-sitter-0.19.0_1
 libplanarity.so.0 planarity-3.0.1.1_1
-libgap.so.0 gap-4.11.1_1
+libgap.so.8 gap-4.12.0_1
 libgtkdatabox.so.1 gtkdatabox3-1.0.0_1
 libxcvt.so.0 libxcvt-0.1.1_1
 libgf2x.so.3 gf2x-1.3.0_1
diff --git a/srcpkgs/gap/patches/c57a07a3.patch b/srcpkgs/gap/patches/c57a07a3.patch
new file mode 100644
index 000000000000..27fd657666a6
--- /dev/null
+++ b/srcpkgs/gap/patches/c57a07a3.patch
@@ -0,0 +1,23 @@
+From c57a07a341e7bb713e74d60c259777b1a8645451 Mon Sep 17 00:00:00 2001
+From: Max Horn <max@quendi.de>
+Date: Fri, 7 Oct 2022 01:31:45 +0200
+Subject: [PATCH] Don't attempt to install the 'dev' manual...
+
+... as it is not contained in release tarballs!
+---
+ Makefile.rules | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile.rules b/Makefile.rules
+index d9dc2899df..de1dbc4823 100644
+--- a/Makefile.rules
++++ b/Makefile.rules
+@@ -597,7 +597,7 @@ install-doc:
+ 	# TODO: should this depend on the 'doc' target? but that target is phony
+ 	# and will re-run each time it is invoked, which is not really what we want.
+ 	$(INSTALL) -d -m 0755 $(DESTDIR)$(datarootdir)/gap/doc
+-	for book in ref tut hpc dev ; do \
++	for book in ref tut hpc ; do \
+ 		$(INSTALL) -d -m 0755 $(DESTDIR)$(datarootdir)/gap/doc/$$book ; \
+ 		for ext in css html js txt pdf six lab; do \
+ 			$(INSTALL) -m 0644  $(srcdir)/doc/$$book/*.$$ext $(DESTDIR)$(datarootdir)/gap/doc/$$book/ ; \
diff --git a/srcpkgs/gap/patches/dce6fa96.patch b/srcpkgs/gap/patches/dce6fa96.patch
new file mode 100644
index 000000000000..bc29c0eaaeb1
--- /dev/null
+++ b/srcpkgs/gap/patches/dce6fa96.patch
@@ -0,0 +1,24 @@
+From dce6fa9637a3c61c3a891cc809371eaa67a589c6 Mon Sep 17 00:00:00 2001
+From: Max Horn <max@quendi.de>
+Date: Sun, 2 Oct 2022 23:31:03 +0200
+Subject: [PATCH] kernel: if no GC is selected, default to GASMAN
+
+---
+ src/common.h | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/common.h b/src/common.h
+index e7c10b8d0b..95e6f3d609 100644
+--- a/src/common.h
++++ b/src/common.h
+@@ -35,6 +35,10 @@
+ // compiled with the wrong ABI
+ GAP_STATIC_ASSERT(sizeof(void *) == SIZEOF_VOID_P, "sizeof(void *) is wrong");
+ 
++// if no GC is selected explicitly, default to GASMAN
++#if !defined(USE_BOEHM_GC) && !defined(USE_JULIA_GC) && !defined(USE_GASMAN)
++#define USE_GASMAN 1
++#endif
+ 
+ // check for cygwin
+ #if defined(__CYGWIN__) || defined(__CYGWIN32__)
diff --git a/srcpkgs/gap/patches/fix-atlasrep.patch b/srcpkgs/gap/patches/fix-atlasrep.patch
new file mode 100644
index 000000000000..ccb9ae587d4b
--- /dev/null
+++ b/srcpkgs/gap/patches/fix-atlasrep.patch
@@ -0,0 +1,11 @@
+--- a/pkg/atlasrep/gap/access.gi.orig	2022-08-05 19:11:16.000000000 -0300
++++ b/pkg/atlasrep/gap/access.gi	2022-10-12 23:40:48.816642751 -0300
+@@ -3156,7 +3156,7 @@
+         uri:= url{ [ p .. Length( url ) ] };
+         body:= AtlasOfGroupRepresentationsTransferFile( domain, uri, fail,
+                                                         fail );
+-        if body = fail then
++        if body = false then
+           Info( InfoAtlasRep, 1,
+                 "AtlasOfGroupRepresentationsNotifyData:\n",
+                 "#I  cannot read '", url, "'" );
diff --git a/srcpkgs/gap/template b/srcpkgs/gap/template
index 7bc7d13ace20..88831e636c08 100644
--- a/srcpkgs/gap/template
+++ b/srcpkgs/gap/template
@@ -1,17 +1,17 @@
 # Template file for 'gap'
 pkgname=gap
-version=4.11.1
+version=4.12.0
 revision=1
 build_style=gnu-configure
-make_install_target="install-bin install-gaproot install-headers install-libgap"
 makedepends="gmp-devel zlib-devel readline-devel"
 checkdepends="perl"
 short_desc="Groups, Algorithms, Programming - computational discrete algebra"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="http://www.gap-system.org/"
+changelog="https://raw.githubusercontent.com/gap-system/gap/master/CHANGES.md"
 distfiles="https://github.com/gap-system/gap/releases/download/v${version}/gap-${version}.tar.gz"
-checksum=6635c5da7d82755f8339486b9cac33766f58712f297e8234fba40818902ea304
+checksum=6005d0c0316fe8803d84681f30be64eace83a9542f975f5cb3dedfadd4391849
 
 if [ "$XBPS_CHECK_PKGS" = full ]; then
 	# not sure about this -- takes about 25 minutes
@@ -21,10 +21,10 @@ fi
 _GAPROOT=/usr/share/gap/
 
 # minimal required packages
-_GAPPKGS="GAPDoc primgrp SmallGrp transgrp"
+_GAPPKGS="gapdoc primgrp smallgrp transgrp"
 
 # other expected packages
-_GAPPKGS+=" atlasrep autpgrp alnuth crisp ctbllib FactInt fga irredsol laguna
+_GAPPKGS+=" atlasrep autpgrp alnuth crisp ctbllib factint fga irredsol laguna
  polenta polycyclic resclasses sophus tomlib"
 
 post_install() {
@@ -33,8 +33,6 @@ post_install() {
 		[ -d pkg/$p ] || p="$p-*"
 		vcopy "pkg/$p" ${_GAPROOT}/pkg
 	done
-	# not handled by make install-headers
-	vcopy gen/config.h /usr/include/gap
 }
 
 gap-devel_package() {

From 3df78ecc2e65a7bfb95f9ae4f6dbd44ae513d8a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:19 -0300
Subject: [PATCH 09/21] lcalc: revbump for pari 2.15.0

---
 srcpkgs/lcalc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lcalc/template b/srcpkgs/lcalc/template
index 270078df9a54..3c6be5fcbc28 100644
--- a/srcpkgs/lcalc/template
+++ b/srcpkgs/lcalc/template
@@ -1,7 +1,7 @@
 # Template file for 'lcalc'
 pkgname=lcalc
 version=2.0.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--with-pari"
 hostmakedepends="automake libtool pkg-config gengetopt"

From adc05ef042127a81f53cd920f545b269df2f78d8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:21 -0300
Subject: [PATCH 10/21] python3-cysignals: revbump for pari 2.15.0

---
 srcpkgs/python3-cysignals/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/python3-cysignals/template b/srcpkgs/python3-cysignals/template
index 4655eead2a9c..08d1010976ff 100644
--- a/srcpkgs/python3-cysignals/template
+++ b/srcpkgs/python3-cysignals/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-cysignals'
 pkgname=python3-cysignals
 version=1.11.2
-revision=1
+revision=2
 wrksrc="cysignals-${version}"
 build_style=python3-module
 hostmakedepends="python3-setuptools python3-Cython autoconf"

From bd829476e4ca9458b20c788a36d596d4b7e7ca4d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:58:16 -0300
Subject: [PATCH 11/21] python3-cypari2: revbump for pari 2.15.0

---
 srcpkgs/python3-cypari2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/python3-cypari2/template b/srcpkgs/python3-cypari2/template
index 9ded61101e8e..9db3070a087c 100644
--- a/srcpkgs/python3-cypari2/template
+++ b/srcpkgs/python3-cypari2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-cypari2'
 pkgname=python3-cypari2
 version=2.1.2
-revision=1
+revision=2
 wrksrc=cypari2-${version}
 build_style=python3-module
 hostmakedepends="python3-setuptools python3-Cython pari perl"

From 893047f2b11e1d41847909a54deaea67c617a190 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 00:49:01 -0300
Subject: [PATCH 12/21] sagemath: update to 9.7.

---
 .../patches/01-dont_link_ratpoints.patch      |   10 -
 ...2-fix_get_shared_lib_path--see_29644.patch |   13 -
 .../patches/03-doctest_have_program.patch     |   20 -
 .../patches/04-doctest_sage_getfile.patch     |   22 -
 .../patches/05-fix_sage_getfile.patch         |   16 -
 .../sagemath/patches/07-ignore_warning.patch  |   15 -
 .../08-dont_run_pytest--see_31924.patch       |   27 -
 ...y_slow_doctest-polynomial_zmod_flint.patch |   14 -
 ...ry_slow_doctest-isogeny_small_degree.patch |  106 -
 ...fix_very_slow_doctest-function_field.patch |   97 -
 srcpkgs/sagemath/patches/matplotlib-3.6.patch |   72 +
 srcpkgs/sagemath/patches/python-3.11.patch    |   45 +
 .../sagemath/patches/sagemath-pari-2.15.patch | 1750 +++++++++++++++++
 .../patches/sagemath-pari-2.15b.patch         |   29 +
 .../trac-31355-upgrade_lrcalc_to_2.1.patch    |  670 -------
 .../trac-33170-fix_doctest_ipython_8.patch    |   40 -
 .../trac-33170b-fix_doctest_ipython_8.1.patch |   13 -
 ...2ddd4e2dc92469c1590ebf0c40f8f69bf579.patch |  126 --
 ...2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch |   40 -
 .../trac-33336-fix_doctest_scipy_1.8.patch    |   19 -
 ...cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch |   53 +
 ...d9deaeaa6380ab2f0d50276d911233c00a04.patch |   99 -
 ...ff347454ac7f07e5918470b20e97b8f2357e.patch |   29 -
 ...0a0b14f67f4804e7113c3db41bbcf8a58296.patch |   26 -
 ...d4e56243c609f44afc1f21c112b026f9e1fe.patch |   42 +
 ...75f90d3bfd36758cb0e9d1ccbcd72f32d496.patch |  526 +++++
 ...1318f032caf8dc1c0de9489346d894409091.patch |   19 +
 .../zzz-loadable_module_extension.patch       |   14 -
 srcpkgs/sagemath/template                     |   12 +-
 29 files changed, 2542 insertions(+), 1422 deletions(-)
 delete mode 100644 srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
 delete mode 100644 srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
 delete mode 100644 srcpkgs/sagemath/patches/03-doctest_have_program.patch
 delete mode 100644 srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
 delete mode 100644 srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
 delete mode 100644 srcpkgs/sagemath/patches/07-ignore_warning.patch
 delete mode 100644 srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
 delete mode 100644 srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
 delete mode 100644 srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
 delete mode 100644 srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
 create mode 100644 srcpkgs/sagemath/patches/matplotlib-3.6.patch
 create mode 100644 srcpkgs/sagemath/patches/python-3.11.patch
 create mode 100644 srcpkgs/sagemath/patches/sagemath-pari-2.15.patch
 create mode 100644 srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
 delete mode 100644 srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch

diff --git a/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch b/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
deleted file mode 100644
index e5c3f5776aa2..000000000000
--- a/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
+++ /dev/null
@@ -1,10 +0,0 @@
- - do not link ratpoints where it's not used
-
---- a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
-+++ b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
-@@ -1,5 +1,3 @@
--# distutils: libraries = ratpoints
--
- r"""
- Descent on elliptic curves over `\QQ` with a 2-isogeny
- """
diff --git a/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch b/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
deleted file mode 100644
index d3672b094c1c..000000000000
--- a/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
+++ /dev/null
@@ -1,13 +0,0 @@
- - fix _get_shared_lib_path() so we don't need to configure GAP_SO
-
---- a/src/sage/env.py
-+++ b/src/sage/env.py
-@@ -293,7 +293,7 @@ def _get_shared_lib_path(*libnames: str) -> Optional[str]:
-             if sys.platform == 'darwin':
-                 ext = 'dylib'
-             else:
--                ext = 'so'
-+                ext = 'so*'
- 
-             if SAGE_LOCAL:
-                 search_directories.append(Path(SAGE_LOCAL) / 'lib')
diff --git a/srcpkgs/sagemath/patches/03-doctest_have_program.patch b/srcpkgs/sagemath/patches/03-doctest_have_program.patch
deleted file mode 100644
index 27ba3776470c..000000000000
--- a/srcpkgs/sagemath/patches/03-doctest_have_program.patch
+++ /dev/null
@@ -1,20 +0,0 @@
- - we don't know `SAGE_VENV/bin` contains `sage`, but `sys.argv[0]` should
-   be the full path to `sage-ipython` and the same directory should have `sage`
-
---- a/src/sage/misc/sage_ostools.pyx
-+++ b/src/sage/misc/sage_ostools.pyx
-@@ -32,12 +32,11 @@ def have_program(program, path=None):
-         True
-         sage: have_program('there_is_not_a_program_with_this_name')
-         False
--        sage: from sage.env import SAGE_VENV
--        sage: have_program('sage', os.path.join(SAGE_VENV, 'bin'))
-+        sage: have_program('sage', os.path.dirname(sys.argv[0]))
-         True
-         sage: have_program('sage', '/there_is_not_a_path_with_this_name')
-         False
--        sage: have_program('there_is_not_a_program_with_this_name', os.path.join(SAGE_VENV, 'bin'))
-+        sage: have_program('there_is_not_a_program_with_this_name', "/bin")
-         False
-     """
-     if path is None:
diff --git a/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch b/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
deleted file mode 100644
index 95bce107f854..000000000000
--- a/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
+++ /dev/null
@@ -1,22 +0,0 @@
- - add one doctest for coverage
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -1341,10 +1342,12 @@ def sage_getfile(obj):
-     EXAMPLES::
- 
-         sage: from sage.misc.sageinspect import sage_getfile
--        sage: sage_getfile(sage.rings.rational)[-23:]
--        'sage/rings/rational.pyx'
--        sage: sage_getfile(Sq)[-42:]
--        'sage/algebras/steenrod/steenrod_algebra.py'
-+        sage: sage_getfile(sage.rings.rational)
-+        '...sage/rings/rational.pyx'
-+        sage: sage_getfile(Sq)
-+        '...sage/algebras/steenrod/steenrod_algebra.py'
-+        sage: sage_getfile(x)
-+        '...sage/symbolic/expression.pyx'
- 
-     The following tests against some bugs fixed in :trac:`9976`::
- 
-
diff --git a/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch b/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
deleted file mode 100644
index 56c58078f319..000000000000
--- a/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
+++ /dev/null
@@ -1,16 +0,0 @@
- - fix sage_getfile() by checking all possible EXTENSION_SUFFIXES
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -1400,8 +1403,9 @@ def sage_getfile(obj):
-         sourcefile = inspect.getabsfile(obj)
-     except TypeError: # this happens for Python builtins
-         return ''
--    if sourcefile.endswith(loadable_module_extension()):
--        return sourcefile[:-len(loadable_module_extension())]+os.path.extsep+'pyx'
-+    for suffix in import_machinery.EXTENSION_SUFFIXES:
-+        if sourcefile.endswith(suffix):
-+            return sourcefile[:-len(suffix)]+os.path.extsep+'pyx'
-     return sourcefile
- 
- 
diff --git a/srcpkgs/sagemath/patches/07-ignore_warning.patch b/srcpkgs/sagemath/patches/07-ignore_warning.patch
deleted file mode 100644
index 69668678a40b..000000000000
--- a/srcpkgs/sagemath/patches/07-ignore_warning.patch
+++ /dev/null
@@ -1,15 +0,0 @@
- - this ignores a warning caused by old notebook
-
---- a/src/sage/all.py
-+++ b/src/sage/all.py
-@@ -100,6 +100,9 @@ warnings.filterwarnings('ignore', category=DeprecationWarning,
-                         message='The distutils(.sysconfig module| package) is deprecated',
-                         module='Cython|distutils|numpy|sage.env|sage.features')
- 
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"invalid escape sequence '\\s'")
-+
- ################ end setup warnings ###############################
- 
- 
-
diff --git a/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch b/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
deleted file mode 100644
index 06bd2ccae6fb..000000000000
--- a/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
+++ /dev/null
@@ -1,27 +0,0 @@
- - using pytest is broken, see #31924
-
---- a/src/bin/sage-runtests
-+++ b/src/bin/sage-runtests
-@@ -154,21 +154,4 @@ if __name__ == "__main__":
-     DC = DocTestController(args, args.filenames)
-     err = DC.run()
- 
--    try:
--        exit_code_pytest = 0
--        import pytest
--        pytest_options = ["--import-mode", "importlib"]
--        if args.verbose:
--            pytest_options.append("-v")
--        exit_code_pytest = pytest.main(pytest_options + args.filenames)
--        if exit_code_pytest == 5:
--            # Exit code 5 means there were no test files, pass in this case
--            exit_code_pytest = 0
--
--    except ModuleNotFoundError:
--        print("Pytest is not installed, skip checking tests that rely on it.")
--
--    if err == 0:
--        sys.exit(exit_code_pytest)
--    else:
--        sys.exit(err)
-+    sys.exit(err)
diff --git a/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch b/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
deleted file mode 100644
index bae8387cf94a..000000000000
--- a/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
-+++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
-@@ -237,8 +237,9 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
- 
-             sage: a = ZZ['x'](range(100000))
-             sage: R = Integers(3)['x']
--            sage: R(a)  # long time (7s on sage.math, 2013)
--            2*x^99998 + ... + x
-+            sage: p = R(a)
-+            sage: p.truncate(10)  # testing the whole poly is VERY SLOW
-+            2*x^8 + x^7 + 2*x^5 + x^4 + 2*x^2 + x
-         """
-         sig_on()
-         fmpz_poly_get_nmod_poly(&self.x, x)
diff --git a/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch b/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
deleted file mode 100644
index f3da5bbb555e..000000000000
--- a/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
+++ /dev/null
@@ -1,106 +0,0 @@
-diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-index 43727346269..9d3ccd475cd 100644
---- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-+++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-@@ -186,7 +186,7 @@ def Psi(l, use_stored=True):
-         sage: assert Psi(3, use_stored=True) == Psi(3, use_stored=False)
-         sage: assert Psi(5, use_stored=True) == Psi(5, use_stored=False)
-         sage: assert Psi(7, use_stored=True) == Psi(7, use_stored=False)
--        sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False) # not tested (very long time)
-+        sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False)  # long time (2s)
-     """
-     if l not in [2, 3, 5, 7, 13]:
-         raise ValueError("Genus zero primes are 2, 3, 5, 7 or 13.")
-@@ -1207,7 +1207,7 @@ def isogenies_13_0(E, minimal_models=True):
-         sage: K.<a> = NumberField(f)
-         sage: E = EllipticCurve(j=K(0)); E.ainvs()
-         (0, 0, 0, 0, 1)
--        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]
-+        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]  # long time (4s)
-         [(0,
-           0,
-           20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
-@@ -1325,7 +1325,7 @@ def isogenies_13_1728(E, minimal_models=True):
-         sage: f = x^12 + 1092*x^10 - 432432*x^8 + 6641024*x^6 - 282896640*x^4 - 149879808*x^2 - 349360128
-         sage: K.<a> = NumberField(f)
-         sage: E = EllipticCurve(K, [1,0])
--        sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]
-+        sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]  # long time (3s)
-         [(0,
-         0,
-         0,
-@@ -1550,8 +1550,11 @@ def Psi2(l):
-         sage: from sage.schemes.elliptic_curves.isogeny_small_degree import Psi2
-         sage: Psi2(11)
-         x^5 - 55*x^4*u + 994*x^3*u^2 - 8774*x^2*u^3 + 41453*x*u^4 - 928945/11*u^5 + 33*x^4 + 276*x^3*u - 7794*x^2*u^2 + 4452*x*u^3 + 1319331/11*u^4 + 216*x^3*v - 4536*x^2*u*v + 31752*x*u^2*v - 842616/11*u^3*v + 162*x^3 + 38718*x^2*u - 610578*x*u^2 + 33434694/11*u^3 - 4536*x^2*v + 73872*x*u*v - 2745576/11*u^2*v - 16470*x^2 + 580068*x*u - 67821354/11*u^2 - 185976*x*v + 14143896/11*u*v + 7533*x - 20437029/11*u - 12389112/11*v + 19964151/11
--        sage: Psi2(71)  # long time (1 second)
--        -2209380711722505179506258739515288584116147237393815266468076436521/71*u^210 + ... - 14790739586438315394567393301990769678157425619440464678252277649/71
-+        sage: f = Psi2(71)
-+        sage: f.coefficient([0, 210, 0])
-+        -2209380711722505179506258739515288584116147237393815266468076436521/71
-+        sage: f.coefficient([0, 0, 0])
-+        -14790739586438315394567393301990769678157425619440464678252277649/71
- 
-     TESTS::
- 
-@@ -1665,17 +1668,17 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True):
-         sage: K = QuadraticField(5,'a')
-         sage: a = K.gen()
-         sage: E = EllipticCurve_from_j(184068066743177379840*a - 411588709724712960000)
--        sage: isogenies_prime_degree_genus_plus_0(E, 47) # long time (4.3s)
-+        sage: isogenies_prime_degree_genus_plus_0(E, 47)  # long time (2s)
-         [Isogeny of degree 47 from Elliptic Curve defined by y^2 = x^3 + (454562028554080355857852049849975895490560*a-1016431595837124114668689286176511361024000)*x + (-249456798429896080881440540950393713303830363999480904280965120*a+557802358738710443451273320227578156598454035482869042774016000) over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790? to Elliptic Curve defined by y^2 = x^3 + (39533118442361013730577638493616965245992960*a-88398740199669828340617478832005245173760000)*x + (214030321479466610282320528611562368963830105830555363061803253760*a-478586348074220699687616322532666163722004497458452316582576128000) over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790?]
- 
-         sage: K = QuadraticField(-66827,'a')
-         sage: a = K.gen()
-         sage: E = EllipticCurve_from_j(-98669236224000*a + 4401720074240000)
--        sage: isogenies_prime_degree_genus_plus_0(E, 59)   # long time (25s, 2012)
-+        sage: isogenies_prime_degree_genus_plus_0(E, 59)   # long time (5s)
-         [Isogeny of degree 59 from Elliptic Curve defined by y^2 = x^3 + (2605886146782144762297974784000*a+1893681048912773634944634716160000)*x + (-116918454256410782232296183198067568744071168000*a+17012043538294664027185882358514011304812871680000) over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I to Elliptic Curve defined by y^2 = x^3 + (-19387084027159786821400775098368000*a-4882059104868154225052787156713472000)*x + (-25659862010101415428713331477227179429538847260672000*a-2596038148441293485938798119003462972840818381946880000) over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I]
- 
-         sage: E = EllipticCurve_from_j(GF(13)(5))
--        sage: isogenies_prime_degree_genus_plus_0(E, 71) # long time
-+        sage: isogenies_prime_degree_genus_plus_0(E, 71)
-         [Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13, Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13]
- 
-         sage: E = EllipticCurve(GF(13),[0,1,1,1,0])
-@@ -2117,11 +2120,11 @@ def isogenies_prime_degree_general(E, l, minimal_models=True):
-         sage: isogenies_prime_degree_general(E, 19)
-         [Isogeny of degree 19 from Elliptic Curve defined by y^2 + y = x^3 - 1862*x - 30956 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - 672182*x + 212325489 over Rational Field]
-         sage: E = EllipticCurve([0, -1, 0, -6288, 211072])
--        sage: isogenies_prime_degree_general(E, 37)  # long time (10s)
-+        sage: isogenies_prime_degree_general(E, 37)  # long time (2s)
-         [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 - x^2 - 6288*x + 211072 over Rational Field to Elliptic Curve defined by y^2 = x^3 - x^2 - 163137088*x - 801950801728 over Rational Field]
- 
-         sage: E = EllipticCurve([-3440, 77658])
--        sage: isogenies_prime_degree_general(E, 43)  # long time (16s)
-+        sage: isogenies_prime_degree_general(E, 43)  # long time (2s)
-         [Isogeny of degree 43 from Elliptic Curve defined by y^2 = x^3 - 3440*x + 77658 over Rational Field to Elliptic Curve defined by y^2 = x^3 - 6360560*x - 6174354606 over Rational Field]
- 
-     Isogenies of degree equal to the characteristic are computed (but
-@@ -2175,7 +2178,7 @@ def isogenies_prime_degree_general(E, l, minimal_models=True):
- 
-         sage: K.<i> = QuadraticField(-1)
-         sage: E = EllipticCurve(K,[0,0,0,1,0])
--        sage: [phi.codomain().ainvs() for phi in E.isogenies_prime_degree(37)] # long time
-+        sage: [phi.codomain().ainvs() for phi in E.isogenies_prime_degree(37)]  # long time (6s)
-         [(0, 0, 0, -840*i + 1081, 0), (0, 0, 0, 840*i + 1081, 0)]
-     """
-     if not l.is_prime():
-@@ -2329,14 +2332,14 @@ def isogenies_prime_degree(E, l, minimal_models=True):
-         sage: E = EllipticCurve(GF(101), [-3440, 77658])
-         sage: E.isogenies_prime_degree(71) # fast
-         []
--        sage: E.isogenies_prime_degree(73) # slower (2s)
-+        sage: E.isogenies_prime_degree(73)  # long time (2s)
-         []
- 
-     Test that :trac:`32269` is fixed::
- 
-         sage: K = QuadraticField(-11)
-         sage: E = EllipticCurve(K, [0,1,0,-117,-541])
--        sage: E.isogenies_prime_degree(37)
-+        sage: E.isogenies_prime_degree(37)  # long time (9s)
-         [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I to Elliptic Curve defined by y^2 = x^3 + x^2 + (30800*a+123963)*x + (3931312*a-21805005) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I,
-          Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I to Elliptic Curve defined by y^2 = x^3 + x^2 + (-30800*a+123963)*x + (-3931312*a-21805005) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I]
- 
diff --git a/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch b/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
deleted file mode 100644
index 3b7b1ea843df..000000000000
--- a/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
+++ /dev/null
@@ -1,97 +0,0 @@
---- a/src/sage/rings/function_field/function_field.py
-+++ b/src/sage/rings/function_field/function_field.py
-@@ -111,22 +111,21 @@ Function fields over the algebraic field are supported::
-     sage: m = L.completion(pl, prec=5)
-     sage: m(x)
-     I + s + O(s^5)
--    sage: m(y)
-+    sage: m(y)                             # long time (4s)
-     -2*s + (-4 - I)*s^2 + (-15 - 4*I)*s^3 + (-75 - 23*I)*s^4 + (-413 - 154*I)*s^5 + O(s^6)
--    sage: m(y)^2 + m(y) + m(x) + 1/m(x)
-+    sage: m(y)^2 + m(y) + m(x) + 1/m(x)    # long time (8s)
-     O(s^5)
- 
- TESTS::
- 
-     sage: TestSuite(J).run()
--    sage: TestSuite(K).run(max_runs=1024) # long time (5s)
--    sage: TestSuite(L).run(max_runs=64)   # long time (10s)
--    sage: TestSuite(M).run(max_runs=32)   # long time (30s)
--    sage: TestSuite(N).run(max_runs=64, skip = '_test_derivation')  # long time (8s)
--    sage: TestSuite(O).run(max_runs=128, skip = '_test_derivation') # long time (8s)
--
-+    sage: TestSuite(K).run(max_runs=256)   # long time (10s)
-+    sage: TestSuite(L).run(max_runs=8)     # long time (25s)
-+    sage: TestSuite(M).run(max_runs=8)     # long time (35s)
-+    sage: TestSuite(N).run(max_runs=8, skip = '_test_derivation')    # long time (15s)
-+    sage: TestSuite(O).run()
-     sage: TestSuite(R).run()
--    sage: TestSuite(S).run() # long time (3s)
-+    sage: TestSuite(S).run()               # long time (4s)
- 
- Global function fields
- ----------------------
-@@ -287,7 +286,7 @@ class FunctionField(Field):
-         TESTS::
- 
-             sage: K.<x> = FunctionField(QQ)
--            sage: TestSuite(K).run()
-+            sage: TestSuite(K).run()               # long time (3s)
-         """
-         Field.__init__(self, base_field, names=names, category=category)
- 
-@@ -729,7 +728,7 @@ class FunctionField(Field):
-         EXAMPLES::
- 
-             sage: K.<x> = FunctionField(QQ)
--            sage: TestSuite(K).run() # indirect doctest
-+            sage: TestSuite(K).run()    # indirect doctest, long time (3s)
-         """
-         tester = self._tester(**options)
-         S = tester.some_elements()
-@@ -1209,7 +1208,7 @@ class FunctionField_polymod(FunctionField):
-             sage: K.<x> = FunctionField(QQ); R.<y> = K[]
-             sage: L = K.extension(y^5 - x^3 - 3*x + x*y); L
-             Function field in y defined by y^5 + x*y - x^3 - 3*x
--            sage: TestSuite(L).run()  # long time
-+            sage: TestSuite(L).run(max_runs=512)   # long time (15s)
- 
-         We can set the variable name, which doesn't have to be y::
- 
-@@ -2888,7 +2887,8 @@ class FunctionField_simple(FunctionField_polymod):
-             sage: F.<y> = K.extension(Y^3 - x^2*(x^2 + x + 1)^2)
-             sage: O = K.maximal_order()
-             sage: pls = [O.ideal(x-QQbar(sqrt(c))).place() for c in [-2, -1, 0, 1, 2]]
--            sage: all(q.place_below() == p for p in pls for q in F.places_above(p))
-+            sage: all(q.place_below() == p         # long time (4s)
-+            ....:     for p in pls for q in F.places_above(p))
-             True
-         """
-         R = self.base_field()
-@@ -3091,7 +3091,7 @@ class FunctionField_global(FunctionField_simple):
- 
-         sage: K.<x> = FunctionField(GF(4)); _.<Y> = K[]
-         sage: L.<y> = K.extension((1 - x)*Y^7 - x^3)
--        sage: L.gaps()
-+        sage: L.gaps()                         # long time (6s)
-         [1, 2, 3]
- 
-     or may define a trivial extension::
-@@ -3111,7 +3111,7 @@ class FunctionField_global(FunctionField_simple):
- 
-             sage: K.<x> = FunctionField(GF(5)); _.<Y> = K[]
-             sage: L.<y> = K.extension(Y^3 - (x^3 - 1)/(x^3 - 2))
--            sage: TestSuite(L).run()
-+            sage: TestSuite(L).run()               # long time (7s)
-         """
-         FunctionField_polymod.__init__(self, polynomial, names)
- 
-@@ -3807,7 +3807,7 @@ class RationalFunctionField(FunctionField):
- 
-             sage: K.<t> = FunctionField(CC); K
-             Rational function field in t over Complex Field with 53 bits of precision
--            sage: TestSuite(K).run()
-+            sage: TestSuite(K).run()               # long time (5s)
- 
-             sage: FunctionField(QQ[I], 'alpha')
-             Rational function field in alpha over Number Field in I with defining polynomial x^2 + 1 with I = 1*I
diff --git a/srcpkgs/sagemath/patches/matplotlib-3.6.patch b/srcpkgs/sagemath/patches/matplotlib-3.6.patch
new file mode 100644
index 000000000000..6afaf1b7162f
--- /dev/null
+++ b/srcpkgs/sagemath/patches/matplotlib-3.6.patch
@@ -0,0 +1,72 @@
+commit 5501e0de0dca1cff0355326dd42bd8c7e5749568
+Author: Gonzalo Tornaría <tornaria@cmat.edu.uy>
+Date:   Tue Oct 11 17:25:04 2022 -0300
+
+    Support matplotlib 3.6
+
+diff --git a/src/sage/plot/arc.py b/src/sage/plot/arc.py
+index bb834763afc..f65973bcbd5 100644
+--- a/src/sage/plot/arc.py
++++ b/src/sage/plot/arc.py
+@@ -273,9 +273,9 @@ class Arc(GraphicPrimitive):
+         p = patches.Arc((self.x, self.y),
+                         2. * self.r1,
+                         2. * self.r2,
+-                        fmod(self.angle, 2 * pi) * (180. / pi),
+-                        self.s1 * (180. / pi),
+-                        self.s2 * (180. / pi))
++                        angle=fmod(self.angle, 2 * pi) * (180. / pi),
++                        theta1=self.s1 * (180. / pi),
++                        theta2=self.s2 * (180. / pi))
+         return p
+ 
+     def bezier_path(self):
+diff --git a/src/sage/plot/ellipse.py b/src/sage/plot/ellipse.py
+index a77e6fe640a..c35bed574ef 100644
+--- a/src/sage/plot/ellipse.py
++++ b/src/sage/plot/ellipse.py
+@@ -192,7 +192,8 @@ class Ellipse(GraphicPrimitive):
+         options = self.options()
+         p = patches.Ellipse(
+                 (self.x,self.y),
+-                self.r1*2.,self.r2*2.,self.angle/pi*180.)
++                self.r1*2.,self.r2*2.,
++                angle=self.angle/pi*180.)
+         p.set_linewidth(float(options['thickness']))
+         p.set_fill(options['fill'])
+         a = float(options['alpha'])
+diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
+index e779e1210e3..8d620b5c625 100644
+--- a/src/sage/plot/graphics.py
++++ b/src/sage/plot/graphics.py
+@@ -2007,7 +2007,7 @@ class Graphics(WithEqualityById, SageObject):
+         We can also do custom formatting if you need it.  See above for full
+         details::
+ 
+-            sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex")
++            sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex") # not tested (broken with matplotlib 3.6)
+             Graphics object consisting of 1 graphics primitive
+ 
+         This is particularly useful when setting custom ticks in multiples
+@@ -2341,7 +2341,7 @@ class Graphics(WithEqualityById, SageObject):
+             sage: subplot = Figure().add_subplot(111)
+             sage: p._objects[0]._render_on_subplot(subplot)
+             sage: p._matplotlib_tick_formatter(subplot, **d)
+-            (<AxesSubplot:>,
++            (<AxesSubplot:...>,
+             <matplotlib.ticker.MaxNLocator object at ...>,
+             <matplotlib.ticker.MaxNLocator object at ...>,
+             <matplotlib.ticker.ScalarFormatter object at ...>,
+diff --git a/src/sage/plot/plot.py b/src/sage/plot/plot.py
+index b36ee57227c..5301a05c3dc 100644
+--- a/src/sage/plot/plot.py
++++ b/src/sage/plot/plot.py
+@@ -1741,7 +1741,7 @@ def plot(funcs, *args, **kwds):
+ 
+     ::
+ 
+-        sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex")
++        sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex") # not tested (broken with matplotlib 3.6)
+         Graphics object consisting of 1 graphics primitive
+ 
+     .. PLOT::
diff --git a/srcpkgs/sagemath/patches/python-3.11.patch b/srcpkgs/sagemath/patches/python-3.11.patch
new file mode 100644
index 000000000000..eafe76bfb794
--- /dev/null
+++ b/srcpkgs/sagemath/patches/python-3.11.patch
@@ -0,0 +1,45 @@
+--- a/src/sage/cpython/cython_metaclass.h
++++ b/src/sage/cpython/cython_metaclass.h
+@@ -66,7 +66,7 @@
+         }
+ 
+         /* Now, set t.__class__ to metaclass */
+-        Py_TYPE(t) = metaclass;
++        Py_SET_TYPE(t, metaclass);
+         PyType_Modified(t);
+     }
+     else
+--- a/src/sage/symbolic/ginac/numeric.cpp
++++ b/src/sage/symbolic/ginac/numeric.cpp
+@@ -52,7 +52,6 @@
+ #define register
+ #define PY_SSIZE_T_CLEAN
+ #include <Python.h>
+-#include <longintrepr.h>
+ #include "flint/fmpz.h"
+ #include "flint/fmpz_factor.h"
+ 
+--- a/src/sage/libs/gmp/pylong.pyx
++++ b/src/sage/libs/gmp/pylong.pyx
+@@ -32,7 +32,7 @@
+ from .mpz cimport *
+ 
+ cdef extern from *:
+-    Py_ssize_t* Py_SIZE_PTR "&Py_SIZE"(object)
++    void Py_SET_SIZE(object, Py_ssize_t)
+     int hash_bits """
+         #ifdef _PyHASH_BITS
+         _PyHASH_BITS         /* Python 3 */
+@@ -57,10 +57,8 @@
+     mpz_export(L.ob_digit, NULL,
+             -1, sizeof(digit), 0, PyLong_nails, z)
+     if mpz_sgn(z) < 0:
+-        # Set correct size (use a pointer to hack around Cython's
+-        # non-support for lvalues).
+-        sizeptr = Py_SIZE_PTR(L)
+-        sizeptr[0] = -pylong_size
++        # Set correct size
++        Py_SET_SIZE(L, -pylong_size)
+     return L
+ 
+ 
diff --git a/srcpkgs/sagemath/patches/sagemath-pari-2.15.patch b/srcpkgs/sagemath/patches/sagemath-pari-2.15.patch
new file mode 100644
index 000000000000..ccafad5070c4
--- /dev/null
+++ b/srcpkgs/sagemath/patches/sagemath-pari-2.15.patch
@@ -0,0 +1,1750 @@
+diff --git a/build/pkgs/giac/patches/pari_2_15.patch b/build/pkgs/giac/patches/pari_2_15.patch
+new file mode 100644
+index 0000000000..d2900a5ffc
+--- /dev/null
++++ b/build/pkgs/giac/patches/pari_2_15.patch
+@@ -0,0 +1,21 @@
++ANYARG patch
++
++diff --git a/src/pari.cc b/src/pari.cc
++index 76ce8e1..50d08ab 100644
++--- a/src/pari.cc
+++++ b/src/pari.cc
++@@ -40,6 +40,13 @@ using namespace std;
++ 
++ #ifdef HAVE_LIBPARI
++ 
+++// Anyarg disappeared from PARI 2.15.0
+++#ifdef __cplusplus
+++#  define ANYARG ...
+++#else
+++#  define ANYARG
+++#endif
+++
++ #ifdef HAVE_PTHREAD_H
++ #include <pthread.h>
++ #endif
++
+diff --git a/build/pkgs/pari/checksums.ini b/build/pkgs/pari/checksums.ini
+index b736feed31..bafd0f36f4 100644
+--- a/build/pkgs/pari/checksums.ini
++++ b/build/pkgs/pari/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=pari-VERSION.tar.gz
+-sha1=e01647aab7e96a8cb4922cf26a4f224337c6647f
+-md5=922f740fcdf8630b30d63dc76b58f756
+-cksum=297133525
++sha1=cba9b279f67d5efe2fbbccf3be6e9725f816cf07
++md5=76d430f1bea1b07fa2ad9712deeaa736
++cksum=1990743897
+ upstream_url=https://pari.math.u-bordeaux.fr/pub/pari/unix/pari-VERSION.tar.gz
+diff --git a/build/pkgs/pari/package-version.txt b/build/pkgs/pari/package-version.txt
+index a1a4224dd5..68e69e405e 100644
+--- a/build/pkgs/pari/package-version.txt
++++ b/build/pkgs/pari/package-version.txt
+@@ -1 +1 @@
+-2.13.3
++2.15.0
+diff --git a/src/doc/de/tutorial/tour_numtheory.rst b/src/doc/de/tutorial/tour_numtheory.rst
+index a012234c99..e3149fe949 100644
+--- a/src/doc/de/tutorial/tour_numtheory.rst
++++ b/src/doc/de/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ implementiert.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/en/tutorial/tour_numtheory.rst b/src/doc/en/tutorial/tour_numtheory.rst
+index 3064d100e2..075e0ac0ad 100644
+--- a/src/doc/en/tutorial/tour_numtheory.rst
++++ b/src/doc/en/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ NumberField class.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/es/tutorial/tour_numtheory.rst b/src/doc/es/tutorial/tour_numtheory.rst
+index a1f7d1a87b..48e5376cfe 100644
+--- a/src/doc/es/tutorial/tour_numtheory.rst
++++ b/src/doc/es/tutorial/tour_numtheory.rst
+@@ -140,7 +140,7 @@ Varios métodos relacionados están implementados en la clase ``NumberField``::
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/fr/tutorial/tour_numtheory.rst b/src/doc/fr/tutorial/tour_numtheory.rst
+index 871092f5fa..d1b2fee883 100644
+--- a/src/doc/fr/tutorial/tour_numtheory.rst
++++ b/src/doc/fr/tutorial/tour_numtheory.rst
+@@ -159,7 +159,7 @@ dans la classe NumberField.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/ja/tutorial/tour_numtheory.rst b/src/doc/ja/tutorial/tour_numtheory.rst
+index 47af68c862..4d4ed52d50 100644
+--- a/src/doc/ja/tutorial/tour_numtheory.rst
++++ b/src/doc/ja/tutorial/tour_numtheory.rst
+@@ -161,7 +161,7 @@ Sageには :math:`p` \-進数体も組込まれている.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/pt/tutorial/tour_numtheory.rst b/src/doc/pt/tutorial/tour_numtheory.rst
+index 6371b491ea..a3dc973a93 100644
+--- a/src/doc/pt/tutorial/tour_numtheory.rst
++++ b/src/doc/pt/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ NumberField.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus 
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/ru/tutorial/tour_numtheory.rst b/src/doc/ru/tutorial/tour_numtheory.rst
+index 652abfbc99..a985d49fbd 100644
+--- a/src/doc/ru/tutorial/tour_numtheory.rst
++++ b/src/doc/ru/tutorial/tour_numtheory.rst
+@@ -150,7 +150,7 @@ Sage содержит стандартные функции теории чис
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py
+index e57076646f..fec75d07c1 100644
+--- a/src/sage/arith/misc.py
++++ b/src/sage/arith/misc.py
+@@ -1465,13 +1465,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)]
++        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::
+ 
+@@ -2569,7 +2569,7 @@ def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds):
+ 
+         sage: K.<i> = QuadraticField(-1)
+         sage: factor(122 - 454*i)
+-        (-3*i - 2) * (-i - 2)^3 * (i + 1)^3 * (i + 4)
++        (-i) * (-i - 2)^3 * (i + 1)^3 * (-2*i + 3) * (i + 4)
+ 
+     To access the data in a factorization::
+ 
+diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
+index cdfc11a9e5..b6e1280d6e 100644
+--- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
++++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
+@@ -7825,9 +7825,9 @@ class DynamicalSystem_projective_field(DynamicalSystem_projective,
+             sage: f = DynamicalSystem_projective([x^2 + QQbar(sqrt(3))*y^2, y^2, QQbar(sqrt(2))*z^2])
+             sage: f.reduce_base_field()
+             Dynamical System of Projective Space of dimension 2 over Number Field in a with
+-            defining polynomial y^4 - 4*y^2 + 1 with a = 1.931851652578137?
++            defining polynomial y^4 - 4*y^2 + 1 with a = -0.5176380902050415?
+               Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x^2 + (a^2 - 2)*y^2 : y^2 : (a^3 - 3*a)*z^2)
++                    (x^2 + (-a^2 + 2)*y^2 : y^2 : (a^3 - 3*a)*z^2)
+ 
+         ::
+ 
+diff --git a/src/sage/ext_data/pari/simon/ellQ.gp b/src/sage/ext_data/pari/simon/ellQ.gp
+index 420af8f6a2..65e8386779 100644
+--- a/src/sage/ext_data/pari/simon/ellQ.gp
++++ b/src/sage/ext_data/pari/simon/ellQ.gp
+@@ -40,7 +40,7 @@
+   gp > \r ellcommon.gp
+   gp > \r ellQ.gp
+ 
+-  The main function is ellrank(), which takes as an argument
++  The main function is ellQ_ellrank(), which takes as an argument
+   any elliptic curve in the form [a1,a2,a3,a4,a6]
+   the result is a vector [r,s,v], where
+     r is a lower bound for the rank,
+@@ -50,7 +50,7 @@
+   Example:
+ 
+   gp > ell = [1,2,3,4,5];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+   %1 = [1, 1, [[1,2]]
+   In this example, the rank is exactly 1, and [1,2] has infinite order.
+ 
+@@ -92,7 +92,7 @@
+   \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+ 
+   Explications succintes :
+-  La fonction ellrank() accepte toutes les courbes sous la forme
++  La fonction ellQ_ellrank() accepte toutes les courbes sous la forme
+   [a1,a2,a3,a4,a6]
+   Les coefficients peuvent etre entiers ou non.
+   L'algorithme utilise est celui de la 2-descente.
+@@ -100,7 +100,7 @@
+   Il suffit de taper : 
+ 
+   gp > ell = [a1,a2,a3,a4,a6];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+ 
+   Retourne un vecteur [r,s,v] ou
+     r est le rang probable (c'est toujours une minoration du rang),
+@@ -110,7 +110,7 @@
+   Exemple :
+ 
+   gp > ell = [1,2,3,4,5];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+   %1 = [1, 1, [[1,2]]
+   Ici, le rang est exactement 1, et le point [1,2] est d'ordre infini.
+ 
+@@ -1571,12 +1571,12 @@ if( DEBUGLEVEL_ell >= 4, print("    end of ell2descent_gen"));
+     print("rank(E/Q)    >= ",m1)
+   );
+ }
+-{ellrank(ell,help=[]) =
++{ellQ_ellrank(ell,help=[]) =
+ \\ Algorithm of 2-descent on the elliptic curve ell.
+ \\ help is a list of known points on ell.
+ my(urst,urst1,den,eqell,tors2,bnf,rang,time1);
+ 
+-if( DEBUGLEVEL_ell >= 3, print("   starting ellrank"));
++if( DEBUGLEVEL_ell >= 3, print("   starting ellQ_ellrank"));
+   if( #ell < 13, ell = ellinit(ell));
+ 
+ \\ kill the coefficients a1 and a3
+@@ -1630,7 +1630,7 @@ if( DEBUGLEVEL_ell >= 1, print(" Elliptic curve: Y^2 = ",eqell));
+   ));
+ 
+   rang[3] = ellchangepoint(rang[3],ellinverturst(urst));
+-if( DEBUGLEVEL_ell >= 3, print("   end of ellrank"));
++if( DEBUGLEVEL_ell >= 3, print("   end of ellQ_ellrank"));
+ 
+   return(rang);
+ }
+@@ -2106,13 +2106,13 @@ if( DEBUGLEVEL_ell >= 3, print("   end of ell2descent_viaisog"));
+ {
+ \\                  functions for elliptic curves
+   addhelp(ell2descent_complete,
+-    "ell2descent_complete(e1,e2,e3): Performs a complete 2-descent on the elliptic curve y^2 = (x-e1)*(x-e2)*(x-e3). See ?ellrank for the format of the output.");
++    "ell2descent_complete(e1,e2,e3): Performs a complete 2-descent on the elliptic curve y^2 = (x-e1)*(x-e2)*(x-e3). See ?ellQ_ellrank for the format of the output.");
+   addhelp(ell2descent_gen,
+-    "ell2descent_gen((E,bnf,k=1,help=[]): E is a vector of the form [0,A,0,B,C], (or the result of ellinit of such a vector) A,B,C integers such that x^3+A*x^2+B*x+C; bnf is the corresponding bnfinit(,1); Performs 2-descent on the elliptic curve Ek: k*y^2=x^3+A*x^2+B*x+C. See ?ellrank for the format of the output.");
++    "ell2descent_gen((E,bnf,k=1,help=[]): E is a vector of the form [0,A,0,B,C], (or the result of ellinit of such a vector) A,B,C integers such that x^3+A*x^2+B*x+C; bnf is the corresponding bnfinit(,1); Performs 2-descent on the elliptic curve Ek: k*y^2=x^3+A*x^2+B*x+C. See ?ellQ_ellrank for the format of the output.");
+   addhelp(ell2descent_viaisog,
+-    "ell2descent_viaisog(E,help=[]): E is an elliptic curve of the form [0,a,0,b,0], with a, b integers. Performs a 2-descent via isogeny on E. See ?ellrank for the format of the output.");
+-  addhelp(ellrank,
+-    "ellrank(E,help=[]): E is any elliptic curve defined over Q. Returns a vector [r,s,v], where r is a lower bound for the rank of E, s is the rank of its 2-Selmer group and v is a list of independant points in E(Q)/2E(Q). If help is a vector of nontrivial points on E, the result might be faster. This function might be used in conjunction with elltors2(E). See also ?default_ellQ");
++    "ell2descent_viaisog(E,help=[]): E is an elliptic curve of the form [0,a,0,b,0], with a, b integers. Performs a 2-descent via isogeny on E. See ?ellQ_ellrank for the format of the output.");
++  addhelp(ellQ_ellrank,
++    "ellQ_ellrank(E,help=[]): E is any elliptic curve defined over Q. Returns a vector [r,s,v], where r is a lower bound for the rank of E, s is the rank of its 2-Selmer group and v is a list of independant points in E(Q)/2E(Q). If help is a vector of nontrivial points on E, the result might be faster. This function might be used in conjunction with elltors2(E). See also ?default_ellQ");
+   addhelp(ellhalf,
+     "ellhalf(E,P): returns the vector of all points Q on the elliptic curve E such that 2Q = P");
+   addhelp(ellredgen,
+@@ -2143,7 +2143,7 @@ if( DEBUGLEVEL_ell >= 3, print("   end of ell2descent_viaisog"));
+ 
+ \\                  others
+   addhelp(default_ellQ,
+-    "default_ellQ(DEBUGLEVEL_ell, LIM1, LIM3, LIMTRIV, ELLREDGENFLAG, COMPLETE, MAXPROB, LIMBIGPRIME): set the value of the global variables used for ellrank() and other related functions. DEBUGLEVEL_ell: 0-5: choose the quantity of information printed during the computation (default=0: print nothing); LIM1 (resp LIM3): search limit for easy (resp hard) points on quartics; LIMTRIV: search limit for trivial points on elliptic curves; ELLREDGENFLAG: if != 0, try to reduce the generators at the end; COMPLETE: if != 0 and full 2-torsion, use complete 2-descent, otherwise via 2-isogeny; MAXPROB, LIMBIGPRIME: technical.");
++    "default_ellQ(DEBUGLEVEL_ell, LIM1, LIM3, LIMTRIV, ELLREDGENFLAG, COMPLETE, MAXPROB, LIMBIGPRIME): set the value of the global variables used for ellQ_ellrank() and other related functions. DEBUGLEVEL_ell: 0-5: choose the quantity of information printed during the computation (default=0: print nothing); LIM1 (resp LIM3): search limit for easy (resp hard) points on quartics; LIMTRIV: search limit for trivial points on elliptic curves; ELLREDGENFLAG: if != 0, try to reduce the generators at the end; COMPLETE: if != 0 and full 2-torsion, use complete 2-descent, otherwise via 2-isogeny; MAXPROB, LIMBIGPRIME: technical.");
+ /*  addhelp(DEBUGLEVEL_ell,
+     "DEBUGLEVEL_ell: Choose a higher value of this global variable to have more details of the computations printed during the 2-descent algorithm. 0 = don't print anything; 1 = (default) just print the result; 2 = print more details including the Selmer group and the nontrivial quartics.");
+ */
+diff --git a/src/sage/ext_data/pari/simon/qfsolve.gp b/src/sage/ext_data/pari/simon/qfsolve.gp
+index 501fb50828..2107288c1d 100644
+--- a/src/sage/ext_data/pari/simon/qfsolve.gp
++++ b/src/sage/ext_data/pari/simon/qfsolve.gp
+@@ -434,146 +434,6 @@ my(cc);
+ return([U3~*G3*U3,red[2]*U1*U2*U3]);
+ }
+ 
+-\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+-\\        QUADRATIC FORMS MINIMIZATION         \\
+-\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+-
+-\\ Minimization of the quadratic form G, with nonzero determinant.
+-\\ of dimension n>=2.
+-\\ G must by symmetric and have integral coefficients.
+-\\ Returns [G',U,factd] with U in GLn(Q) such that G'=U~*G*U*constant
+-\\ is integral and has minimal determinant.
+-\\ In dimension 3 or 4, may return a prime p
+-\\ if the reduction at p is impossible because of the local non solvability.
+-\\ If given, factdetG must be equal to factor(abs(det(G))).
+-{qfminimize(G,factdetG) =
+-my(factd,U,Ker,Ker2,sol,aux,di);
+-my(p);
+-my(n,lf,i,vp,dimKer,dimKer2,m);
+-
+-  n = length(G);
+-  factd = matrix(0,2);
+-  if( !factdetG, factdetG = factor(matdet(G)));
+-
+-  lf = length(factdetG[,1]);
+-  i = 1; U = matid(n);
+-
+-  while(i <= lf,
+-    vp = factdetG[i,2];
+-    if( vp == 0, i++; next);
+-    p = factdetG[i,1];
+-    if( p == -1, i++; next);
+-if( DEBUGLEVEL_qfsolve >= 4, print("    p = ",p,"^",vp));
+-
+-\\ The case vp = 1 can be minimized only if n is odd.
+-    if( vp == 1 && n%2 == 0,
+-      factd = concat(factd~, Mat([p,1])~)~;
+-      i++; next
+-    );
+-    Ker = kermodp(G,p); dimKer = Ker[1]; Ker = Ker[2];
+-
+-\\ Rem: we must have dimKer <= vp
+-if( DEBUGLEVEL_qfsolve >= 4, print("    dimKer = ",dimKer));
+-\\ trivial case: dimKer = n
+-    if( dimKer == n, 
+-if( DEBUGLEVEL_qfsolve >= 4, print("     case 0: dimKer = n"));
+-      G /= p;
+-      factdetG[i,2] -= n;
+-      next
+-    );
+-    G = Ker~*G*Ker;
+-    U = U*Ker;
+-
+-\\ 1st case: dimKer < vp
+-\\ then the kernel mod p contains a kernel mod p^2
+-    if( dimKer < vp,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 1: dimker < vp"));
+-      if( dimKer == 1,
+-\\        G[,1] /= p; G[1,] /= p;
+-        G[,1] /= p; G[1,] = G[1,]/p;
+-        U[,1] /= p;
+-        factdetG[i,2] -= 2
+-      , 
+-        Ker2 = kermodp(matrix(dimKer,dimKer,j,k,G[j,k]/p),p);
+-        dimKer2 = Ker2[1]; Ker2 = Ker2[2];
+-        for( j = 1, dimKer2, Ker2[,j] /= p);
+-        Ker2 = matdiagonalblock([Ker2,matid(n-dimKer)]);
+-        G = Ker2~*G*Ker2;
+-        U = U*Ker2;
+-        factdetG[i,2] -= 2*dimKer2
+-);
+-
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 1"));
+-      next
+-    );
+-
+-\\ Now, we have vp = dimKer 
+-\\ 2nd case: the dimension of the kernel is >=2
+-\\ and contains an element of norm 0 mod p^2
+-
+-\\ search for an element of norm p^2... in the kernel
+-    if( dimKer > 2 || 
+-       (dimKer == 2 && issquare( di = Mod((G[1,2]^2-G[1,1]*G[2,2])/p^2,p))),
+-      if( dimKer > 2,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 2.1"));
+-        dimKer = 3;
+-        sol = qfsolvemodp(matrix(3,3,j,k,G[j,k]/p),p)
+-      ,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 2.2"));
+-        if( G[1,1]%p^2 == 0, 
+-          sol = [1,0]~
+-        , sol = [-G[1,2]/p+sqrt(di),Mod(G[1,1]/p,p)]~
+-        )
+-      );
+-      sol = centerlift(sol);
+-      sol /= content(sol);
+-if( DEBUGLEVEL_qfsolve >= 4, print("    sol = ",sol));
+-      Ker = vectorv(n, j, if( j<= dimKer, sol[j], 0)); \\ fill with 0's
+-      Ker = completebasis(Ker,1);
+-      Ker[,n] /= p;
+-      G = Ker~*G*Ker;
+-      U = U*Ker;
+-      factdetG[i,2] -= 2;
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 2"));
+-      next
+-    );
+-
+-\\ Now, we have vp = dimKer <= 2 
+-\\   and the kernel contains no vector with norm p^2...
+-
+-\\ In some cases, exchanging the kernel and the image
+-\\ makes the minimization easy.
+-
+-    m = (n-1)\2-1;
+-    if( ( vp == 1 && issquare(Mod(-(-1)^m*matdet(G)/G[1,1],p)))
+-     || ( vp == 2 && n%2 == 1 && n >= 5)
+-     || ( vp == 2 && n%2 == 0 && !issquare(Mod((-1)^m*matdet(G)/p^2,p)))
+-    , 
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 3"));
+-      Ker = matid(n);
+-      for( j = dimKer+1, n, Ker[j,j] = p);
+-      G = Ker~*G*Ker/p;
+-      U = U*Ker;
+-      factdetG[i,2] -= 2*dimKer-n;
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 3"));
+-      next
+-    );
+-
+-\\ Minimization was not possible se far.
+-\\ If n == 3 or 4, this proves the local non-solubility at p.
+-    if( n == 3 || n == 4, 
+-if( DEBUGLEVEL_qfsolve >= 1, print(" no local solution at ",p));
+-      return(p));
+-
+-if( DEBUGLEVEL_qfsolve >= 4, print("    prime ",p," finished"));
+-    factd = concat(factd~,Mat([p,vp])~)~;
+-    i++
+-  );
+-\\ apply LLL to avoid coefficients explosion
+-  aux = qflll(U/content(U));
+-return([aux~*G*aux,U*aux,factd]);
+-}
+-
+ \\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+ \\          CLASS GROUP COMPUTATIONS           \\
+ \\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+diff --git a/src/sage/geometry/polyhedron/backend_field.py b/src/sage/geometry/polyhedron/backend_field.py
+index 6b921d23a6..2f32c58b1e 100644
+--- a/src/sage/geometry/polyhedron/backend_field.py
++++ b/src/sage/geometry/polyhedron/backend_field.py
+@@ -265,7 +265,7 @@ class Polyhedron_field(Polyhedron_base):
+              An inequality (-0.1419794359520263?, -1.698172434277148?) x + 1.200789243901438? >= 0,
+              An inequality (0.3001973109753594?, 0.600394621950719?) x - 0.4245431085692869? >= 0)
+             sage: p.Vrepresentation()                                           # optional - sage.rings.number_field
+-            (A vertex at (0.?e-15, 0.707106781186548?),
++            (A vertex at (0.?e-16, 0.7071067811865475?),
+              A vertex at (1.414213562373095?, 0),
+              A vertex at (4.000000000000000?, 0.372677996249965?))
+         """
+@@ -308,7 +308,7 @@ class Polyhedron_field(Polyhedron_base):
+              An inequality (-0.1419794359520263?, -1.698172434277148?) x + 1.200789243901438? >= 0,
+              An inequality (0.3001973109753594?, 0.600394621950719?) x - 0.4245431085692869? >= 0)
+             sage: p.Vrepresentation()                                           # optional - sage.rings.number_field
+-            (A vertex at (0.?e-15, 0.707106781186548?),
++            (A vertex at (0.?e-16, 0.7071067811865475?),
+              A vertex at (1.414213562373095?, 0),
+              A vertex at (4.000000000000000?, 0.372677996249965?))
+         """
+diff --git a/src/sage/geometry/polyhedron/backend_normaliz.py b/src/sage/geometry/polyhedron/backend_normaliz.py
+index 86b89632a5..ca8a43b248 100644
+--- a/src/sage/geometry/polyhedron/backend_normaliz.py
++++ b/src/sage/geometry/polyhedron/backend_normaliz.py
+@@ -53,7 +53,7 @@ def _number_field_elements_from_algebraics_list_of_lists_of_lists(listss, **kwds
+         1.732050807568878?
+         sage: from sage.geometry.polyhedron.backend_normaliz import _number_field_elements_from_algebraics_list_of_lists_of_lists
+         sage: K, results, hom = _number_field_elements_from_algebraics_list_of_lists_of_lists([[[rt2], [1]], [[rt3]], [[1], []]]); results  # optional - sage.rings.number_field
+-        [[[-a^3 + 3*a], [1]], [[-a^2 + 2]], [[1], []]]
++        [[[-a^3 + 3*a], [1]], [[a^2 - 2]], [[1], []]]
+     """
+     from sage.rings.qqbar import number_field_elements_from_algebraics
+     numbers = []
+diff --git a/src/sage/groups/matrix_gps/isometries.py b/src/sage/groups/matrix_gps/isometries.py
+index f9111a2c92..cca45e7175 100644
+--- a/src/sage/groups/matrix_gps/isometries.py
++++ b/src/sage/groups/matrix_gps/isometries.py
+@@ -11,11 +11,11 @@ EXAMPLES::
+     sage: L = IntegralLattice("D4")
+     sage: O = L.orthogonal_group()
+     sage: O
+-    Group of isometries with 5 generators (
+-    [-1  0  0  0]  [0 0 0 1]  [-1 -1 -1 -1]  [ 1  1  0  0]  [ 1  0  0  0]
+-    [ 0 -1  0  0]  [0 1 0 0]  [ 0  0  1  0]  [ 0  0  1  0]  [-1 -1 -1 -1]
+-    [ 0  0 -1  0]  [0 0 1 0]  [ 0  1  0  1]  [ 0  1  0  1]  [ 0  0  1  0]
+-    [ 0  0  0 -1], [1 0 0 0], [ 0 -1 -1  0], [ 0 -1 -1  0], [ 0  0  0  1]
++    Group of isometries with 3 generators (
++    [0 0 0 1]  [ 1  1  0  0]  [ 1  0  0  0]
++    [0 1 0 0]  [ 0  0  1  0]  [-1 -1 -1 -1]
++    [0 0 1 0]  [ 0  1  0  1]  [ 0  0  1  0]
++    [1 0 0 0], [ 0 -1 -1  0], [ 0  0  0  1]
+     )
+ 
+ Basic functionality is provided by GAP::
+diff --git a/src/sage/interfaces/genus2reduction.py b/src/sage/interfaces/genus2reduction.py
+index 56ae04b235..7a4794daf2 100644
+--- a/src/sage/interfaces/genus2reduction.py
++++ b/src/sage/interfaces/genus2reduction.py
+@@ -143,31 +143,31 @@ class ReductionData(SageObject):
+        sur un corps de valuation discrète", Trans. AMS 348 (1996),
+        4577-4610, Section 7.2, Proposition 4).
+     """
+-    def __init__(self, pari_result, P, Q, minimal_equation, minimal_disc,
+-                 local_data, conductor, prime_to_2_conductor_only):
++    def __init__(self, pari_result, P, Q, Pmin, Qmin, minimal_disc,
++                 local_data, conductor):
+         self.pari_result = pari_result
+         self.P = P
+         self.Q = Q
+-        self.minimal_equation = minimal_equation
++        self.Pmin = Pmin
++        self.Qmin = Qmin
+         self.minimal_disc = minimal_disc
+         self.local_data = local_data
+         self.conductor = conductor
+-        self.prime_to_2_conductor_only = prime_to_2_conductor_only
+ 
+     def _repr_(self):
+-        if self.prime_to_2_conductor_only:
+-            ex = ' (away from 2)'
+-        else:
+-            ex = ''
+         if self.Q == 0:
+             yterm = ''
+         else:
+             yterm = '+ (%s)*y '%self.Q
++
+         s = 'Reduction data about this proper smooth genus 2 curve:\n'
+         s += '\ty^2 %s= %s\n'%(yterm, self.P)
+-        s += 'A Minimal Equation (away from 2):\n\ty^2 = %s\n'%self.minimal_equation
+-        s += 'Minimal Discriminant (away from 2):  %s\n'%self.minimal_disc
+-        s += 'Conductor%s: %s\n'%(ex, self.conductor)
++        if self.Qmin:
++            s += 'A Minimal Equation:\n\ty^2 + (%s)y = %s\n'%(self.Qmin, self.Pmin)
++        else:
++            s += 'A Minimal Equation:\n\ty^2 = %s\n'%self.Pmin
++        s += 'Minimal Discriminant: %s\n'%self.minimal_disc
++        s += 'Conductor: %s\n'%self.conductor
+         s += 'Local Data:\n%s'%self._local_data_str()
+         return s
+ 
+@@ -242,17 +242,7 @@ class Genus2reduction(SageObject):
+         sage: factor(R.conductor)
+         5^4 * 2267
+ 
+-    This means that only the odd part of the conductor is known.
+-
+-    ::
+-
+-        sage: R.prime_to_2_conductor_only
+-        True
+-
+-    The discriminant is always minimal away from 2, but possibly not at
+-    2.
+-
+-    ::
++    The discriminant is always minimal::
+ 
+         sage: factor(R.minimal_disc)
+         2^3 * 5^5 * 2267
+@@ -264,10 +254,10 @@ class Genus2reduction(SageObject):
+         sage: R
+         Reduction data about this proper smooth genus 2 curve:
+             y^2 + (x^3 - 2*x^2 - 2*x + 1)*y = -5*x^5
+-        A Minimal Equation (away from 2):
+-            y^2 = x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855
+-        Minimal Discriminant (away from 2):  56675000
+-        Conductor (away from 2): 1416875
++        A Minimal Equation:
++            y^2 ...
++        Minimal Discriminant: 56675000
++        Conductor: 1416875
+         Local Data:
+             p=2
+             (potential) stable reduction:  (II), j=1
+@@ -293,10 +283,10 @@ class Genus2reduction(SageObject):
+         sage: genus2reduction(0, x^6 + 3*x^3 + 63)
+         Reduction data about this proper smooth genus 2 curve:
+                 y^2 = x^6 + 3*x^3 + 63
+-        A Minimal Equation (away from 2):
+-                y^2 = x^6 + 3*x^3 + 63
+-        Minimal Discriminant (away from 2):  10628388316852992
+-        Conductor (away from 2): 2893401
++        A Minimal Equation:
++                y^2 ...
++        Minimal Discriminant: -10628388316852992
++        Conductor: 2893401
+         Local Data:
+                 p=2
+                 (potential) stable reduction:  (V), j1+j2=0, j1*j2=0
+@@ -327,9 +317,9 @@ class Genus2reduction(SageObject):
+         sage: genus2reduction(x^3-x^2-1, x^2 - x)
+         Reduction data about this proper smooth genus 2 curve:
+                 y^2 + (x^3 - x^2 - 1)*y = x^2 - x
+-        A Minimal Equation (away from 2):
+-                y^2 = x^6 + 58*x^5 + 1401*x^4 + 18038*x^3 + 130546*x^2 + 503516*x + 808561
+-        Minimal Discriminant (away from 2):  169
++        A Minimal Equation:
++                y^2 ...
++        Minimal Discriminant: -169
+         Conductor: 169
+         Local Data:
+                 p=13
+@@ -370,10 +360,10 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^3 - 2*x^2 - 2*x + 1, -5*x^5)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^3 - 2*x^2 - 2*x + 1)*y = -5*x^5
+-            A Minimal Equation (away from 2):
+-                    y^2 = x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855
+-            Minimal Discriminant (away from 2):  56675000
+-            Conductor (away from 2): 1416875
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 56675000
++            Conductor: 1416875
+             Local Data:
+                     p=2
+                     (potential) stable reduction:  (II), j=1
+@@ -389,9 +379,9 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^2 + 1, -5*x^5)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^2 + 1)*y = -5*x^5
+-            A Minimal Equation (away from 2):
+-                    y^2 = -20*x^5 + x^4 + 2*x^2 + 1
+-            Minimal Discriminant (away from 2):  48838125
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 48838125
+             Conductor: 32025
+             Local Data:
+                     p=3
+@@ -412,9 +402,9 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^3 + x^2 + x,-2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^3 + x^2 + x)*y = -2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2
+-            A Minimal Equation (away from 2):
+-                    y^2 = x^6 + 18*x^3 + 36*x^2 - 27
+-            Minimal Discriminant (away from 2):  1520984142
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 1520984142
+             Conductor: 954
+             Local Data:
+                     p=2
+@@ -436,18 +426,10 @@ class Genus2reduction(SageObject):
+             raise ValueError("Q (=%s) must have degree at most 3" % Q)
+ 
+         res = pari.genus2red([P, Q])
+-
+         conductor = ZZ(res[0])
+-        minimal_equation = R(res[2])
+-
+-        minimal_disc = QQ(res[2].poldisc()).abs()
+-        if minimal_equation.degree() == 5:
+-            minimal_disc *= minimal_equation[5]**2
+-        # Multiply with suitable power of 2 of the form 2^(2*(d-1) - 12)
+-        b = 2 * (minimal_equation.degree() - 1)
+-        k = QQ((12 - minimal_disc.valuation(2), b)).ceil()
+-        minimal_disc >>= 12 - b*k
+-        minimal_disc = ZZ(minimal_disc)
++        Pmin = R(res[2][0])
++        Qmin = R(res[2][1])
++        minimal_disc = ZZ(pari.hyperelldisc(res[2]))
+ 
+         local_data = {}
+         for red in res[3]:
+@@ -468,9 +450,7 @@ class Genus2reduction(SageObject):
+ 
+             local_data[p] = data
+ 
+-        prime_to_2_conductor_only = (-1 in res[1].component(2))
+-        return ReductionData(res, P, Q, minimal_equation, minimal_disc, local_data,
+-                             conductor, prime_to_2_conductor_only)
++        return ReductionData(res, P, Q, Pmin, Qmin, minimal_disc, local_data, conductor)
+ 
+     def __reduce__(self):
+         return _reduce_load_genus2reduction, tuple([])
+diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
+index fec450d7bc..236402c293 100644
+--- a/src/sage/lfunctions/dokchitser.py
++++ b/src/sage/lfunctions/dokchitser.py
+@@ -337,6 +337,7 @@ class Dokchitser(SageObject):
+             # After init_coeffs is called, future calls to this method should
+             # return the full output for further parsing
+             raise RuntimeError("unable to create L-series, due to precision or other limits in PARI")
++        t = t.replace("  *** _^_: Warning: normalizing a series with 0 leading term.\n", "")
+         return t
+ 
+     def __check_init(self):
+diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
+index d2b20f1891..6c31efe239 100644
+--- a/src/sage/lfunctions/pari.py
++++ b/src/sage/lfunctions/pari.py
+@@ -339,7 +339,7 @@ def lfun_eta_quotient(scalings, exponents):
+         0.0374412812685155
+ 
+         sage: lfun_eta_quotient([6],[4])
+-        [[Vecsmall([7]), [Vecsmall([6]), Vecsmall([4])]], 0, [0, 1], 2, 36, 1]
++        [[Vecsmall([7]), [Vecsmall([6]), Vecsmall([4]), 0]], 0, [0, 1], 2, 36, 1]
+ 
+         sage: lfun_eta_quotient([2,1,4], [5,-2,-2])
+         Traceback (most recent call last):
+diff --git a/src/sage/libs/pari/tests.py b/src/sage/libs/pari/tests.py
+index e5a2aa2517..0efcb15de0 100644
+--- a/src/sage/libs/pari/tests.py
++++ b/src/sage/libs/pari/tests.py
+@@ -356,7 +356,7 @@ Constructors::
+     [2, 4]~*x + [1, 3]~
+ 
+     sage: pari(3).Qfb(7, 1)
+-    Qfb(3, 7, 1, 0.E-19)
++    Qfb(3, 7, 1)
+     sage: pari(3).Qfb(7, 2)
+     Traceback (most recent call last):
+     ...
+@@ -512,7 +512,7 @@ Basic functions::
+     sage: pari('sqrt(-2)').frac()
+     Traceback (most recent call last):
+     ...
+-    PariError: incorrect type in gfloor (t_COMPLEX)
++    PariError: incorrect type in gfrac (t_COMPLEX)
+ 
+     sage: pari('1+2*I').imag()
+     2
+diff --git a/src/sage/modular/cusps_nf.py b/src/sage/modular/cusps_nf.py
+index 25d93cac92..157ebabe29 100644
+--- a/src/sage/modular/cusps_nf.py
++++ b/src/sage/modular/cusps_nf.py
+@@ -1220,7 +1220,7 @@ def units_mod_ideal(I):
+         sage: I = k.ideal(5, a + 1)
+         sage: units_mod_ideal(I)
+         [1,
+-        2*a^2 + 4*a - 1,
++        -2*a^2 - 4*a + 1,
+         ...]
+ 
+     ::
+diff --git a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
+index a881336596..090d1bfaf0 100644
+--- a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
++++ b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
+@@ -43,7 +43,7 @@ def coerce_AA(p):
+         sage: AA(p)._exact_field()
+         Number Field in a with defining polynomial y^8 ... with a in ...
+         sage: coerce_AA(p)._exact_field()
+-        Number Field in a with defining polynomial y^4 - 1910*y^2 - 3924*y + 681058 with a in 39.710518724...?
++        Number Field in a with defining polynomial y^4 - 1910*y^2 - 3924*y + 681058 with a in ...?
+     """
+     el = AA(p)
+     el.simplify()
+diff --git a/src/sage/modular/modsym/p1list_nf.py b/src/sage/modular/modsym/p1list_nf.py
+index 222caacca8..f9d969732c 100644
+--- a/src/sage/modular/modsym/p1list_nf.py
++++ b/src/sage/modular/modsym/p1list_nf.py
+@@ -58,7 +58,7 @@ Lift an MSymbol to a matrix in `SL(2, R)`:
+ 
+     sage: alpha = MSymbol(N, a + 2, 3*a^2)
+     sage: alpha.lift_to_sl2_Ok()
+-    [-3*a^2 + a + 12, 25*a^2 - 50*a + 100, a + 2, a^2 - 3*a + 3]
++    [-1, 4*a^2 - 13*a + 23, a + 2, 5*a^2 + 3*a - 3]
+     sage: Ok = k.ring_of_integers()
+     sage: M = Matrix(Ok, 2, alpha.lift_to_sl2_Ok())
+     sage: det(M)
+@@ -945,11 +945,11 @@ class P1NFList(SageObject):
+             sage: N = k.ideal(5, a + 1)
+             sage: P = P1NFList(N)
+             sage: u = k.unit_group().gens_values(); u
+-            [-1, 2*a^2 + 4*a - 1]
++            [-1, -2*a^2 - 4*a + 1]
+             sage: P.apply_J_epsilon(4, -1)
+             2
+             sage: P.apply_J_epsilon(4, u[0], u[1])
+-            1
++            5
+ 
+         ::
+ 
+diff --git a/src/sage/modules/free_quadratic_module_integer_symmetric.py b/src/sage/modules/free_quadratic_module_integer_symmetric.py
+index a206f0c721..aeb19ab669 100644
+--- a/src/sage/modules/free_quadratic_module_integer_symmetric.py
++++ b/src/sage/modules/free_quadratic_module_integer_symmetric.py
+@@ -1168,11 +1168,11 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+             sage: A4 = IntegralLattice("A4")
+             sage: Aut = A4.orthogonal_group()
+             sage: Aut
+-            Group of isometries with 5 generators (
+-            [-1  0  0  0]  [0 0 0 1]  [-1 -1 -1  0]  [ 1  0  0  0]  [ 1  0  0  0]
+-            [ 0 -1  0  0]  [0 0 1 0]  [ 0  0  0 -1]  [-1 -1 -1 -1]  [ 0  1  0  0]
+-            [ 0  0 -1  0]  [0 1 0 0]  [ 0  0  1  1]  [ 0  0  0  1]  [ 0  0  1  1]
+-            [ 0  0  0 -1], [1 0 0 0], [ 0  1  0  0], [ 0  0  1  0], [ 0  0  0 -1]
++            Group of isometries with 4 generators (
++            [0 0 0 1]  [-1 -1 -1  0]  [ 1  0  0  0]  [ 1  0  0  0]
++            [0 0 1 0]  [ 0  0  0 -1]  [-1 -1 -1 -1]  [ 0  1  0  0]
++            [0 1 0 0]  [ 0  0  1  1]  [ 0  0  0  1]  [ 0  0  1  1]
++            [1 0 0 0], [ 0  1  0  0], [ 0  0  1  0], [ 0  0  0 -1]
+             )
+ 
+         The group acts from the right on the lattice and its discriminant group::
+@@ -1180,19 +1180,19 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+             sage: x = A4.an_element()
+             sage: g = Aut.an_element()
+             sage: g
+-            [ 1  1  1  0]
+-            [ 0  0 -1  0]
+-            [ 0  0  1  1]
+-            [ 0 -1 -1 -1]
++            [-1 -1 -1  0]
++            [ 0  0  1  0]
++            [ 0  0 -1 -1]
++            [ 0  1  1  1]
+             sage: x*g
+-            (1, 1, 1, 0)
++            (-1, -1, -1, 0)
+             sage: (x*g).parent()==A4
+             True
+             sage: (g*x).parent()
+             Vector space of dimension 4 over Rational Field
+             sage: y = A4.discriminant_group().an_element()
+             sage: y*g
+-            (1)
++            (4)
+ 
+         If the group is finite we can compute the usual things::
+ 
+@@ -1208,10 +1208,10 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+ 
+             sage: A2 = IntegralLattice(matrix.identity(3),Matrix(ZZ,2,3,[1,-1,0,0,1,-1]))
+             sage: A2.orthogonal_group()
+-            Group of isometries with 3 generators (
+-            [-1/3  2/3  2/3]  [ 2/3  2/3 -1/3]  [1 0 0]
+-            [ 2/3 -1/3  2/3]  [ 2/3 -1/3  2/3]  [0 0 1]
+-            [ 2/3  2/3 -1/3], [-1/3  2/3  2/3], [0 1 0]
++            Group of isometries with 2 generators (
++            [ 2/3  2/3 -1/3]  [1 0 0]
++            [ 2/3 -1/3  2/3]  [0 0 1]
++            [-1/3  2/3  2/3], [0 1 0]
+             )
+ 
+         It can be negative definite as well::
+diff --git a/src/sage/quadratic_forms/binary_qf.py b/src/sage/quadratic_forms/binary_qf.py
+index cfa3ada73e..5ac823bc6c 100755
+--- a/src/sage/quadratic_forms/binary_qf.py
++++ b/src/sage/quadratic_forms/binary_qf.py
+@@ -141,7 +141,7 @@ class BinaryQF(SageObject):
+                   and a.degree() == 2 and a.parent().ngens() == 2):
+                 x, y = a.parent().gens()
+                 a, b, c = [a.monomial_coefficient(mon) for mon in [x**2, x*y, y**2]]
+-            elif isinstance(a, pari_gen) and a.type() in ('t_QFI', 't_QFR'):
++            elif isinstance(a, pari_gen) and a.type() in ('t_QFI', 't_QFR', 't_QFB'):
+                 # a has 3 or 4 components
+                 a, b, c = a[0], a[1], a[2]
+         try:
+diff --git a/src/sage/quadratic_forms/genera/genus.py b/src/sage/quadratic_forms/genera/genus.py
+index 8290b6c4fa..0fc43f33c6 100644
+--- a/src/sage/quadratic_forms/genera/genus.py
++++ b/src/sage/quadratic_forms/genera/genus.py
+@@ -3088,8 +3088,8 @@ class GenusSymbol_global_ring():
+             sage: G = Genus(matrix(ZZ, 3, [6,3,0, 3,6,0, 0,0,2]))
+             sage: G.representatives()
+             (
+-            [2 0 0]  [ 2 -1  0]
+-            [0 6 3]  [-1  2  0]
++            [2 0 0]  [ 2  1  0]
++            [0 6 3]  [ 1  2  0]
+             [0 3 6], [ 0  0 18]
+             )
+ 
+diff --git a/src/sage/quadratic_forms/qfsolve.py b/src/sage/quadratic_forms/qfsolve.py
+index ddde95e04f..d5e15d9f83 100644
+--- a/src/sage/quadratic_forms/qfsolve.py
++++ b/src/sage/quadratic_forms/qfsolve.py
+@@ -70,7 +70,7 @@ def qfsolve(G):
+ 
+         sage: M = Matrix(QQ, [[3, 0, 0, 0], [0, 5, 0, 0], [0, 0, -7, 0], [0, 0, 0, -11]])
+         sage: qfsolve(M)
+-        (3, -4, -3, -2)
++        (3, 4, -3, -2)
+     """
+     ret = G.__pari__().qfsolve()
+     if ret.type() == 't_COL':
+diff --git a/src/sage/quadratic_forms/quadratic_form__automorphisms.py b/src/sage/quadratic_forms/quadratic_form__automorphisms.py
+index c36c667e3b..3d72cf3be1 100644
+--- a/src/sage/quadratic_forms/quadratic_form__automorphisms.py
++++ b/src/sage/quadratic_forms/quadratic_form__automorphisms.py
+@@ -300,9 +300,9 @@ def automorphism_group(self):
+         sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1])
+         sage: Q.automorphism_group()
+         Matrix group over Rational Field with 3 generators (
+-        [-1  0  0]  [0 0 1]  [ 0  0  1]
+-        [ 0 -1  0]  [0 1 0]  [-1  0  0]
+-        [ 0  0 -1], [1 0 0], [ 0  1  0]
++        [ 0  0  1]  [1 0 0]  [ 1  0  0]
++        [-1  0  0]  [0 0 1]  [ 0 -1  0]
++        [ 0  1  0], [0 1 0], [ 0  0  1]
+         )
+ 
+     ::
+diff --git a/src/sage/rings/finite_rings/finite_field_prime_modn.py b/src/sage/rings/finite_rings/finite_field_prime_modn.py
+index 9129ecb56a..d5a4cb8f22 100644
+--- a/src/sage/rings/finite_rings/finite_field_prime_modn.py
++++ b/src/sage/rings/finite_rings/finite_field_prime_modn.py
+@@ -111,7 +111,7 @@ class FiniteField_prime_modn(FiniteField_generic, integer_mod_ring.IntegerModRin
+             sage: RF13 = K.residue_field(pp)
+             sage: RF13.hom([GF(13)(1)])
+             Ring morphism:
+-             From: Residue field of Fractional ideal (w + 18)
++             From: Residue field of Fractional ideal (-w - 18)
+              To:   Finite Field of size 13
+              Defn: 1 |--> 1
+ 
+diff --git a/src/sage/rings/finite_rings/residue_field.pyx b/src/sage/rings/finite_rings/residue_field.pyx
+index 7596f2a302..1e1869f1b1 100644
+--- a/src/sage/rings/finite_rings/residue_field.pyx
++++ b/src/sage/rings/finite_rings/residue_field.pyx
+@@ -20,13 +20,13 @@ monogenic (i.e., 2 is an essential discriminant divisor)::
+ 
+     sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8)
+     sage: F = K.factor(2); F
+-    (Fractional ideal (1/2*a^2 - 1/2*a + 1)) * (Fractional ideal (-a^2 + 2*a - 3)) * (Fractional ideal (-3/2*a^2 + 5/2*a - 4))
++    (Fractional ideal (-1/2*a^2 + 1/2*a - 1)) * (Fractional ideal (-a^2 + 2*a - 3)) * (Fractional ideal (3/2*a^2 - 5/2*a + 4))
+     sage: F[0][0].residue_field()
+-    Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++    Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+     sage: F[1][0].residue_field()
+     Residue field of Fractional ideal (-a^2 + 2*a - 3)
+     sage: F[2][0].residue_field()
+-    Residue field of Fractional ideal (-3/2*a^2 + 5/2*a - 4)
++    Residue field of Fractional ideal (3/2*a^2 - 5/2*a + 4)
+ 
+ We can also form residue fields from `\ZZ`::
+ 
+@@ -258,9 +258,9 @@ class ResidueFieldFactory(UniqueFactory):
+     the index of ``ZZ[a]`` in the maximal order for all ``a``::
+ 
+         sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8); P = K.ideal(2).factor()[0][0]; P
+-        Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F = K.residue_field(P); F
+-        Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F(a)
+         0
+         sage: B = K.maximal_order().basis(); B
+@@ -270,7 +270,7 @@ class ResidueFieldFactory(UniqueFactory):
+         sage: F(B[2])
+         0
+         sage: F
+-        Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F.degree()
+         1
+ 
+@@ -730,15 +730,15 @@ class ResidueField_generic(Field):
+         EXAMPLES::
+ 
+             sage: I = QQ[3^(1/3)].factor(5)[1][0]; I
+-            Fractional ideal (-a + 2)
++            Fractional ideal (a - 2)
+             sage: k = I.residue_field(); k
+-            Residue field of Fractional ideal (-a + 2)
++            Residue field of Fractional ideal (a - 2)
+             sage: f = k.lift_map(); f
+             Lifting map:
+-              From: Residue field of Fractional ideal (-a + 2)
++              From: Residue field of Fractional ideal (a - 2)
+               To:   Maximal Order in Number Field in a with defining polynomial x^3 - 3 with a = 1.442249570307409?
+             sage: f.domain()
+-            Residue field of Fractional ideal (-a + 2)
++            Residue field of Fractional ideal (a - 2)
+             sage: f.codomain()
+             Maximal Order in Number Field in a with defining polynomial x^3 - 3 with a = 1.442249570307409?
+             sage: f(k.0)
+@@ -768,7 +768,7 @@ class ResidueField_generic(Field):
+ 
+             sage: K.<a> = NumberField(x^3-11)
+             sage: F = K.ideal(37).factor(); F
+-            (Fractional ideal (37, a + 9)) * (Fractional ideal (37, a + 12)) * (Fractional ideal (2*a - 5))
++            (Fractional ideal (37, a + 9)) * (Fractional ideal (37, a + 12)) * (Fractional ideal (-2*a + 5))
+             sage: k = K.residue_field(F[0][0])
+             sage: l = K.residue_field(F[1][0])
+             sage: k == l
+@@ -846,7 +846,7 @@ cdef class ReductionMap(Map):
+             sage: F.reduction_map()
+             Partially defined reduction map:
+               From: Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
+-              To:   Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++              To:   Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+ 
+             sage: K.<theta_5> = CyclotomicField(5)
+             sage: F = K.factor(7)[0][0].residue_field()
+diff --git a/src/sage/rings/number_field/S_unit_solver.py b/src/sage/rings/number_field/S_unit_solver.py
+index e99dff850f..759cbfb334 100644
+--- a/src/sage/rings/number_field/S_unit_solver.py
++++ b/src/sage/rings/number_field/S_unit_solver.py
+@@ -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 (xi - 3),
+-         Fractional ideal (-2*xi^2 + 3),
++        (Fractional ideal (-2*xi^2 + 3),
++         Fractional ideal (-xi + 3),
+          Fractional ideal (2*xi + 1))
+ 
+         sage: sieve_data[1]
+-        (Residue field of Fractional ideal (xi - 3),
+-         Residue field of Fractional ideal (-2*xi^2 + 3),
++        (Residue field of Fractional ideal (-2*xi^2 + 3),
++         Residue field of Fractional ideal (-xi + 3),
+          Residue field of Fractional ideal (2*xi + 1))
+ 
+         sage: sieve_data[2]
+-        ([18, 7, 16, 4], [18, 9, 12, 8], [18, 3, 10, 10])
++        ([18, 12, 16, 8], [18, 16, 10, 4], [18, 10, 12, 10])
+ 
+         sage: sieve_data[3]
+-        (486, 648, 11664)
++        (648, 2916, 3888)
+     """
+ 
+     K = SUK.number_field()
+diff --git a/src/sage/rings/number_field/bdd_height.py b/src/sage/rings/number_field/bdd_height.py
+index beb047ae02..b7c8c33d0b 100644
+--- a/src/sage/rings/number_field/bdd_height.py
++++ b/src/sage/rings/number_field/bdd_height.py
+@@ -248,7 +248,7 @@ def bdd_norm_pr_ideal_gens(K, norm_list):
+         sage: from sage.rings.number_field.bdd_height import bdd_norm_pr_ideal_gens
+         sage: K.<g> = QuadraticField(123)
+         sage: bdd_norm_pr_ideal_gens(K, range(5))
+-        {0: [0], 1: [1], 2: [-g - 11], 3: [], 4: [2]}
++        {0: [0], 1: [1], 2: [g + 11], 3: [], 4: [2]}
+ 
+     ::
+ 
+diff --git a/src/sage/rings/number_field/class_group.py b/src/sage/rings/number_field/class_group.py
+index 018ff5f5c6..73c0462cd1 100644
+--- a/src/sage/rings/number_field/class_group.py
++++ b/src/sage/rings/number_field/class_group.py
+@@ -221,11 +221,11 @@ class FractionalIdealClass(AbelianGroupWithValuesElement):
+             Class group of order 76 with structure C38 x C2
+             of Number Field in a with defining polynomial x^2 + 20072
+             sage: I = (G.0)^11; I
+-            Fractional ideal class (41, 1/2*a + 5)
++            Fractional ideal class (33, 1/2*a + 8)
+             sage: J = G(I.ideal()^5); J
+-            Fractional ideal class (115856201, 1/2*a + 40407883)
++            Fractional ideal class (39135393, 1/2*a + 13654253)
+             sage: J.reduce()
+-            Fractional ideal class (57, 1/2*a + 44)
++            Fractional ideal class (73, 1/2*a + 47)
+             sage: J == I^5
+             True
+         """
+diff --git a/src/sage/rings/number_field/galois_group.py b/src/sage/rings/number_field/galois_group.py
+index 79acd053bb..e060148e4d 100644
+--- a/src/sage/rings/number_field/galois_group.py
++++ b/src/sage/rings/number_field/galois_group.py
+@@ -944,7 +944,7 @@ class GaloisGroup_v2(GaloisGroup_perm):
+             sage: K.<b> = NumberField(x^4 - 2*x^2 + 2, 'a').galois_closure()
+             sage: G = K.galois_group()
+             sage: [G.artin_symbol(P) for P in K.primes_above(7)]
+-            [(1,5)(2,6)(3,7)(4,8), (1,5)(2,6)(3,7)(4,8), (1,4)(2,3)(5,8)(6,7), (1,4)(2,3)(5,8)(6,7)]
++            [(1,4)(2,3)(5,8)(6,7), (1,4)(2,3)(5,8)(6,7), (1,5)(2,6)(3,7)(4,8), (1,5)(2,6)(3,7)(4,8)]
+             sage: G.artin_symbol(17)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
+index 58463d570d..ff65634e99 100644
+--- a/src/sage/rings/number_field/number_field.py
++++ b/src/sage/rings/number_field/number_field.py
+@@ -3643,7 +3643,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
+ 
+@@ -4227,7 +4227,8 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             (y^2 + 6, Mod(1/6*y, y^2 + 6), Mod(6*y, y^2 + 1/6))
+         """
+         f = self.absolute_polynomial()._pari_with_name('y')
+-        if f.pollead() == f.content().denominator() == 1:
++        f = f * f.content().denominator()
++        if f.pollead() == 1:
+             g = f
+             alpha = beta = g.variable().Mod(g)
+         else:
+@@ -4821,7 +4822,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+ 
+             sage: K.<a> = NumberField(2*x^2 - 1/3)
+             sage: K._S_class_group_and_units(tuple(K.primes_above(2) + K.primes_above(3)))
+-            ([-6*a + 2, 6*a + 3, -1, 12*a + 5], [])
++            ([6*a + 2, 6*a + 3, -1, -12*a + 5], [])
+         """
+         K_pari = self.pari_bnf(proof=proof)
+         S_pari = [p.pari_prime() for p in sorted(set(S))]
+@@ -5166,7 +5167,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+ 
+             sage: [K.ideal(g).factor() for g in gens]
+             [(Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1)),
+-            Fractional ideal (-a),
++            Fractional ideal (a),
+             (Fractional ideal (2, a + 1))^2,
+             1]
+ 
+@@ -5751,7 +5752,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: K.elements_of_norm(3)
+             []
+             sage: K.elements_of_norm(50)
+-            [-7*a + 1, 5*a - 5, 7*a + 1]
++            [-a - 7, 5*a - 5, 7*a + 1]
+ 
+         TESTS:
+ 
+@@ -5863,7 +5864,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: K.factor(1+a)
+             Fractional ideal (a + 1)
+             sage: K.factor(1+a/5)
+-            (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1 * (Fractional ideal (-3*a - 2))
++            (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1 * (Fractional ideal (-2*a + 3))
+ 
+         An example over a relative number field::
+ 
+@@ -6460,9 +6461,9 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: new_basis = k.reduced_basis(prec=120)
+             sage: [c.minpoly() for c in new_basis]
+             [x - 1,
+-             x^2 - x + 1,
++             x^2 + x + 1,
++             x^6 + 3*x^5 - 102*x^4 - 103*x^3 + 10572*x^2 - 59919*x + 127657,
+              x^6 + 3*x^5 - 102*x^4 - 103*x^3 + 10572*x^2 - 59919*x + 127657,
+-             x^6 - 3*x^5 - 102*x^4 + 315*x^3 + 10254*x^2 - 80955*x + 198147,
+              x^3 - 171*x + 848,
+              x^6 + 171*x^4 + 1696*x^3 + 29241*x^2 + 145008*x + 719104]
+             sage: R = k.order(new_basis)
+@@ -7058,7 +7059,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+              -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)
++             2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7)
+ 
+         TESTS:
+ 
+@@ -7067,7 +7068,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)
+ 
+@@ -7146,7 +7147,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^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]
++            [-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, 2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7]
+         """
+         proof = proof_flag(proof)
+ 
+diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx
+index 784c239dc1..aa740069dc 100644
+--- a/src/sage/rings/number_field/number_field_element.pyx
++++ b/src/sage/rings/number_field/number_field_element.pyx
+@@ -4446,7 +4446,7 @@ cdef class NumberFieldElement(FieldElement):
+             sage: f = Qi.embeddings(K)[0]
+             sage: a = f(2+3*i) * (2-zeta)^2
+             sage: a.descend_mod_power(Qi,2)
+-            [-3*i - 2, -2*i + 3]
++            [-2*i + 3, 3*i + 2]
+ 
+         An absolute example::
+ 
+@@ -5124,7 +5124,7 @@ cdef class NumberFieldElement_relative(NumberFieldElement):
+         EXAMPLES::
+ 
+             sage: K.<a, b, c> = NumberField([x^2 - 2, x^2 - 3, x^2 - 5])
+-            sage: P = K.prime_factors(5)[0]
++            sage: P = K.prime_factors(5)[1]
+             sage: (2*a + b - c).valuation(P)
+             1
+         """
+diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
+index 5f587556a4..33481fead0 100644
+--- a/src/sage/rings/number_field/number_field_ideal.py
++++ b/src/sage/rings/number_field/number_field_ideal.py
+@@ -3355,7 +3355,7 @@ def quotient_char_p(I, p):
+         []
+ 
+         sage: I = K.factor(13)[0][0]; I
+-        Fractional ideal (-3*i - 2)
++        Fractional ideal (-2*i + 3)
+         sage: I.residue_class_degree()
+         1
+         sage: quotient_char_p(I, 13)[0]
+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 bae36d4b9c..f64bd5b761 100644
+--- a/src/sage/rings/number_field/number_field_ideal_rel.py
++++ b/src/sage/rings/number_field/number_field_ideal_rel.py
+@@ -272,7 +272,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.gens_reduced()
+-            (2, 15*a*b + 3*a + 1)
++            (2, -15*a*b + 3*a + 1)
+         """
+         try:
+             # Compute the single generator, if it exists
+@@ -401,7 +401,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.relative_norm()
+-            Fractional ideal (-6*a + 2)
++            Fractional ideal (6*a + 2)
+         """
+         L = self.number_field()
+         K = L.base_field()
+@@ -518,7 +518,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.ideal_below()
+-            Fractional ideal (-6*a + 2)
++            Fractional ideal (6*a + 2)
+         """
+         L = self.number_field()
+         K = L.base_field()
+diff --git a/src/sage/rings/number_field/number_field_rel.py b/src/sage/rings/number_field/number_field_rel.py
+index d33980c4b1..50e846b205 100644
+--- a/src/sage/rings/number_field/number_field_rel.py
++++ b/src/sage/rings/number_field/number_field_rel.py
+@@ -213,14 +213,14 @@ class NumberField_relative(NumberField_generic):
+             sage: l.<b> = k.extension(5*x^2 + 3); l
+             Number Field in b with defining polynomial 5*x^2 + 3 over its base field
+             sage: l.pari_rnf()
+-            [x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4), ..., y^4 + 6*y^2 + 1, x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4)], [0, 0]]
++            [x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4), ..., y^4 + 6*y^2 + 1, x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4)], [0, 0]]
+             sage: b
+             b
+ 
+             sage: l.<b> = k.extension(x^2 + 3/5); l
+             Number Field in b with defining polynomial x^2 + 3/5 over its base field
+             sage: l.pari_rnf()
+-            [x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4), ..., y^4 + 6*y^2 + 1, x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4)], [0, 0]]
++            [x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4), ..., y^4 + 6*y^2 + 1, x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4)], [0, 0]]
+             sage: b
+             b
+ 
+diff --git a/src/sage/rings/number_field/order.py b/src/sage/rings/number_field/order.py
+index 6eca89ed8d..78ef4c3b33 100644
+--- a/src/sage/rings/number_field/order.py
++++ b/src/sage/rings/number_field/order.py
+@@ -520,7 +520,7 @@ class Order(IntegralDomain, sage.rings.abc.Order):
+             sage: k.<a> = NumberField(x^2 + 5077); G = k.class_group(); G
+             Class group of order 22 with structure C22 of Number Field in a with defining polynomial x^2 + 5077
+             sage: G.0 ^ -9
+-            Fractional ideal class (11, a + 7)
++            Fractional ideal class (43, a + 13)
+             sage: Ok = k.maximal_order(); Ok
+             Maximal Order in Number Field in a with defining polynomial x^2 + 5077
+             sage: Ok * (11, a + 7)
+diff --git a/src/sage/rings/number_field/selmer_group.py b/src/sage/rings/number_field/selmer_group.py
+index c534aaa9f6..6bc67565d2 100644
+--- a/src/sage/rings/number_field/selmer_group.py
++++ b/src/sage/rings/number_field/selmer_group.py
+@@ -491,7 +491,7 @@ def pSelmerGroup(K, S, p, proof=None, debug=False):
+ 
+         sage: [K.ideal(g).factor() for g in gens]
+         [(Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1)),
+-        Fractional ideal (-a),
++        Fractional ideal (a),
+         (Fractional ideal (2, a + 1))^2,
+         1]
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
+index bb5d8356be..8a7e5fa66f 100644
+--- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
++++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
+@@ -1791,7 +1791,7 @@ class PolynomialQuotientRing_generic(CommutativeRing):
+             sage: D.selmer_generators([K.ideal(2, -a+1), K.ideal(3, a+1)], 3)
+             [2, a + 1]
+             sage: D.selmer_generators([K.ideal(2, -a+1), K.ideal(3, a+1), K.ideal(a)], 3)
+-            [2, a + 1, a]
++            [2, a + 1, -a]
+ 
+         """
+         fields, isos, iso_classes = self._S_decomposition(tuple(S))
+diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py
+index 704b77ce5f..83ee4549e4 100644
+--- a/src/sage/rings/qqbar.py
++++ b/src/sage/rings/qqbar.py
+@@ -312,8 +312,8 @@ and we get a way to produce the number directly::
+     True
+     sage: sage_input(n)
+     R.<y> = QQ[]
+-    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(RR(0.51763809020504148), RR(0.51763809020504159)))
+-    -109*v^3 - 89*v^2 + 327*v + 178
++    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(-RR(1.9318516525781366), -RR(1.9318516525781364)))
++    -109*v^3 + 89*v^2 + 327*v - 178
+ 
+ We can also see that some computations (basically, those which are
+ easy to perform exactly) are performed directly, instead of storing
+@@ -362,7 +362,7 @@ algorithms in :trac:`10255`::
+     # Verified
+     R1.<x> = QQbar[]
+     R2.<y> = QQ[]
+-    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(RR(0.51763809020504148), RR(0.51763809020504159)))
++    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(-RR(1.9318516525781366), -RR(1.9318516525781364)))
+     AA.polynomial_root(AA.common_polynomial(x^4 + QQbar(v^3 - 3*v - 1)*x^3 + QQbar(-v^3 + 3*v - 3)*x^2 + QQbar(-3*v^3 + 9*v + 3)*x + QQbar(3*v^3 - 9*v)), RIF(RR(0.99999999999999989), RR(1.0000000000000002)))
+     sage: one
+     1
+@@ -2310,7 +2310,7 @@ def do_polred(poly, threshold=32):
+     cost = 2 * bitsize.nbits() + 5 * poly.degree().nbits()
+     if cost > threshold:
+         return parent.gen(), parent.gen(), poly
+-    new_poly, elt_back = poly.__pari__().polredbest(flag=1)
++    new_poly, elt_back = poly.numerator().__pari__().polredbest(flag=1)
+     elt_fwd = elt_back.modreverse()
+     return parent(elt_fwd.lift()), parent(elt_back.lift()), parent(new_poly)
+ 
+@@ -2542,10 +2542,10 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+            Defn: a |--> 1.414213562373095?)
+ 
+         sage: number_field_elements_from_algebraics((rt2,rt3))
+-        (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, [-a^3 + 3*a, -a^2 + 2], Ring morphism:
++        (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, [-a^3 + 3*a, a^2 - 2], Ring morphism:
+             From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+             To:   Algebraic Real Field
+-            Defn: a |--> 0.5176380902050415?)
++            Defn: a |--> -1.931851652578137?)
+ 
+     ``rt3a`` is a real number in ``QQbar``.  Ordinarily, we'd get a homomorphism
+     to ``AA`` (because all elements are real), but if we specify ``same_field=True``,
+@@ -2570,7 +2570,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, -a^3 + 3*a, Ring morphism:
+             From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+             To:   Algebraic Real Field
+-            Defn: a |--> 0.5176380902050415?)
++            Defn: a |--> -1.931851652578137?)
+ 
+     We can specify ``minimal=True`` if we want the smallest number field::
+ 
+@@ -2618,7 +2618,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         sage: nfI^2
+         -1
+         sage: sum = nfrt2 + nfrt3 + nfI + nfz3; sum
+-        2*a^6 + a^5 - a^4 - a^3 - 2*a^2 - a
++        a^5 + a^4 - a^3 + 2*a^2 - a - 1
+         sage: hom(sum)
+         2.646264369941973? + 1.866025403784439?*I
+         sage: hom(sum) == rt2 + rt3 + qqI + z3
+@@ -2658,7 +2658,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         sage: nf, nums, hom = number_field_elements_from_algebraics(elems, embedded=True)
+         sage: nf
+         Number Field in a with defining polynomial y^24 - 6*y^23 ...- 9*y^2 + 1
+-          with a = 0.2598678911433438? + 0.0572892247058457?*I
++          with a = 0.2598679? + 0.0572892?*I
+         sage: list(map(QQbar, nums)) == elems == list(map(hom, nums))
+         True
+ 
+@@ -2725,7 +2725,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+                          sqrt(2), AA.polynomial_root(x^3-3, RIF(0,3)), 11/9, 1]
+         sage: res = number_field_elements_from_algebraics(my_nums, embedded=True)
+         sage: res[0]
+-        Number Field in a with defining polynomial y^24 - 107010*y^22 - 24*y^21 + ... + 250678447193040618624307096815048024318853254384 with a = -95.5053039433554?
++        Number Field in a with defining polynomial y^24 - 107010*y^22 - 24*y^21 + ... + 250678447193040618624307096815048024318853254384 with a = 93.32530798172420?
+     """
+     gen = qq_generator
+ 
+@@ -3129,7 +3129,7 @@ class AlgebraicGenerator(SageObject):
+             sage: root = ANRoot(x^2 - x - 1, RIF(1, 2))
+             sage: gen = AlgebraicGenerator(nf, root)
+             sage: gen.pari_field()
+-             [y^2 - y - 1, [2, 0], ...]
++            [[y^2 - y - 1, [2, 0], ...]
+         """
+         if self.is_trivial():
+             raise ValueError("No PARI field attached to trivial generator")
+@@ -3213,7 +3213,7 @@ class AlgebraicGenerator(SageObject):
+             sage: qq_generator.union(gen3) is gen3
+             True
+             sage: gen2.union(gen3)
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+         """
+         if self._trivial:
+             return other
+@@ -3306,13 +3306,13 @@ class AlgebraicGenerator(SageObject):
+             Number Field in a with defining polynomial y^2 - 3 with a in 1.732050807568878?
+             sage: gen2_3 = gen2.union(gen3)
+             sage: gen2_3
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+             sage: qq_generator.super_poly(gen2) is None
+             True
+             sage: gen2.super_poly(gen2_3)
+             -a^3 + 3*a
+             sage: gen3.super_poly(gen2_3)
+-            -a^2 + 2
++            a^2 - 2
+ 
+         """
+         if checked is None:
+@@ -3360,13 +3360,13 @@ class AlgebraicGenerator(SageObject):
+             sage: sqrt3 = ANExtensionElement(gen3, nf3.gen())
+             sage: gen2_3 = gen2.union(gen3)
+             sage: gen2_3
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+             sage: gen2_3(sqrt2)
+             -a^3 + 3*a
+             sage: gen2_3(ANRational(1/7))
+             1/7
+             sage: gen2_3(sqrt3)
+-            -a^2 + 2
++            a^2 - 2
+         """
+         if self._trivial:
+             return elt._value
+@@ -4336,10 +4336,10 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: rt3 = AA(sqrt(3))
+             sage: rt3b = rt2 + rt3 - rt2
+             sage: rt3b.as_number_field_element()
+-            (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, -a^2 + 2, Ring morphism:
++            (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, a^2 - 2, Ring morphism:
+                 From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+                 To:   Algebraic Real Field
+-                Defn: a |--> 0.5176380902050415?)
++                Defn: a |--> -1.931851652578137?)
+             sage: rt3b.as_number_field_element(minimal=True)
+             (Number Field in a with defining polynomial y^2 - 3, a, Ring morphism:
+                From: Number Field in a with defining polynomial y^2 - 3
+@@ -4401,7 +4401,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: rt2b = rt3 + rt2 - rt3
+             sage: rt2b.exactify()
+             sage: rt2b._exact_value()
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b.simplify()
+             sage: rt2b._exact_value()
+             a where a^2 - 2 = 0 and a in 1.414213562373095?
+@@ -4422,7 +4422,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: QQbar(2)._exact_field()
+             Trivial generator
+             sage: (sqrt(QQbar(2)) + sqrt(QQbar(19)))._exact_field()
+-            Number Field in a with defining polynomial y^4 - 20*y^2 + 81 with a in 2.375100220297941?
++            Number Field in a with defining polynomial y^4 - 20*y^2 + 81 with a in -3.789313782671036?
+             sage: (QQbar(7)^(3/5))._exact_field()
+             Number Field in a with defining polynomial y^5 - 2*y^4 - 18*y^3 + 38*y^2 + 82*y - 181 with a in 2.554256611698490?
+         """
+@@ -4442,7 +4442,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: QQbar(2)._exact_value()
+             2
+             sage: (sqrt(QQbar(2)) + sqrt(QQbar(19)))._exact_value()
+-            -1/9*a^3 - a^2 + 11/9*a + 10 where a^4 - 20*a^2 + 81 = 0 and a in 2.375100220297941?
++            -1/9*a^3 + a^2 + 11/9*a - 10 where a^4 - 20*a^2 + 81 = 0 and a in -3.789313782671036?
+             sage: (QQbar(7)^(3/5))._exact_value()
+             2*a^4 + 2*a^3 - 34*a^2 - 17*a + 150 where a^5 - 2*a^4 - 18*a^3 + 38*a^2 + 82*a - 181 = 0 and a in 2.554256611698490?
+         """
+@@ -6857,7 +6857,7 @@ class AlgebraicPolynomialTracker(SageObject):
+             sage: p = sqrt(AA(2)) * x^2 - sqrt(AA(3))
+             sage: cp = AA.common_polynomial(p)
+             sage: cp.generator()
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 1.931851652578137?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -0.5176380902050415?
+         """
+         self.exactify()
+         return self._gen
+@@ -7706,7 +7706,7 @@ class ANExtensionElement(ANDescr):
+ 
+             sage: rt2b.exactify()
+             sage: rt2b._descr
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b._descr.is_simple()
+             False
+         """
+@@ -7791,7 +7791,7 @@ class ANExtensionElement(ANDescr):
+             sage: rt2b = rt3 + rt2 - rt3
+             sage: rt2b.exactify()
+             sage: rt2b._descr
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b._descr.simplify(rt2b)
+             a where a^2 - 2 = 0 and a in 1.414213562373095?
+         """
+@@ -7830,9 +7830,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.neg(a)
+-            1/3*a^3 - 2/3*a^2 + 4/3*a - 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -1/3*a^3 + 1/3*a^2 - a - 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+             sage: b.neg("ham spam and eggs")
+-            1/3*a^3 - 2/3*a^2 + 4/3*a - 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -1/3*a^3 + 1/3*a^2 - a - 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+         """
+         return ANExtensionElement(self._generator, -self._value)
+ 
+@@ -7848,9 +7848,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.invert(a)
+-            7/3*a^3 - 2/3*a^2 + 4/3*a - 12 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -7/3*a^3 + 19/3*a^2 - 7*a - 9 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+             sage: b.invert("ham spam and eggs")
+-            7/3*a^3 - 2/3*a^2 + 4/3*a - 12 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -7/3*a^3 + 19/3*a^2 - 7*a - 9 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+         """
+         return ANExtensionElement(self._generator, ~self._value)
+ 
+@@ -7866,9 +7866,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.conjugate(a)
+-            -1/3*a^3 + 2/3*a^2 - 4/3*a + 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? + 1.573132184970987?*I
++            1/3*a^3 - 1/3*a^2 + a + 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? - 1.573132184970987?*I
+             sage: b.conjugate("ham spam and eggs")
+-            -1/3*a^3 + 2/3*a^2 - 4/3*a + 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? + 1.573132184970987?*I
++            1/3*a^3 - 1/3*a^2 + a + 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? - 1.573132184970987?*I
+         """
+         if self._exactly_real:
+             return self
+@@ -8501,7 +8501,7 @@ def an_binop_expr(a, b, op):
+         sage: x = an_binop_expr(a, b, operator.add); x
+         <sage.rings.qqbar.ANBinaryExpr object at ...>
+         sage: x.exactify()
+-        -6/7*a^7 + 2/7*a^6 + 71/7*a^5 - 26/7*a^4 - 125/7*a^3 + 72/7*a^2 + 43/7*a - 47/7 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in 3.12580...?
++        6/7*a^7 - 2/7*a^6 - 71/7*a^5 + 26/7*a^4 + 125/7*a^3 - 72/7*a^2 - 43/7*a + 47/7 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in -0.3199179336182997?
+ 
+         sage: a = QQbar(sqrt(2)) + QQbar(sqrt(3))
+         sage: b = QQbar(sqrt(3)) + QQbar(sqrt(5))
+@@ -8510,7 +8510,7 @@ def an_binop_expr(a, b, op):
+         sage: x = an_binop_expr(a, b, operator.mul); x
+         <sage.rings.qqbar.ANBinaryExpr object at ...>
+         sage: x.exactify()
+-        2*a^7 - a^6 - 24*a^5 + 12*a^4 + 46*a^3 - 22*a^2 - 22*a + 9 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in 3.1258...?
++        2*a^7 - a^6 - 24*a^5 + 12*a^4 + 46*a^3 - 22*a^2 - 22*a + 9 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in -0.3199179336182997?
+     """
+     return ANBinaryExpr(a, b, op)
+ 
+diff --git a/src/sage/schemes/affine/affine_morphism.py b/src/sage/schemes/affine/affine_morphism.py
+index 1c4f2dff18..32c2e47e49 100644
+--- a/src/sage/schemes/affine/affine_morphism.py
++++ b/src/sage/schemes/affine/affine_morphism.py
+@@ -1148,9 +1148,9 @@ class SchemeMorphism_polynomial_affine_space_field(SchemeMorphism_polynomial_aff
+             sage: H = End(A)
+             sage: f = H([(QQbar(sqrt(2))*x^2 + 1/QQbar(sqrt(3))) / (5*x)])
+             sage: f.reduce_base_field()
+-            Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a = 1.931851652578137?
++            Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a = ...?
+               Defn: Defined on coordinates by sending (x) to
+-                    (((a^3 - 3*a)*x^2 + (1/3*a^2 - 2/3))/(5*x))
++                    (((a^3 - 3*a)*x^2 + (-1/3*a^2 + 2/3))/(5*x))
+ 
+         ::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_field.py b/src/sage/schemes/elliptic_curves/ell_field.py
+index 68b8375dae..48f358ea6a 100644
+--- a/src/sage/schemes/elliptic_curves/ell_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_field.py
+@@ -845,7 +845,7 @@ class EllipticCurve_field(ell_generic.EllipticCurve_generic, ProjectivePlaneCurv
+             sage: E = E.base_extend(G).quadratic_twist(c); E
+             Elliptic Curve defined by y^2 = x^3 + 5*a0*x^2 + (-200*a0^2)*x + (-42000*a0^2+42000*a0+126000) over Number Field in a0 with defining polynomial x^3 - 3*x^2 + 3*x + 9
+             sage: K.<b> = E.division_field(3, simplify_all=True); K
+-            Number Field in b with defining polynomial x^12 - 10*x^10 + 55*x^8 - 60*x^6 + 75*x^4 + 1350*x^2 + 2025
++            Number Field in b with defining polynomial x^12 + 5*x^10 + 40*x^8 + 315*x^6 + 750*x^4 + 675*x^2 + 2025
+ 
+         Some higher-degree examples::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_generic.py b/src/sage/schemes/elliptic_curves/ell_generic.py
+index 926ae310ea..3bae819fb0 100644
+--- a/src/sage/schemes/elliptic_curves/ell_generic.py
++++ b/src/sage/schemes/elliptic_curves/ell_generic.py
+@@ -3324,8 +3324,8 @@ 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),
++            [0, 0, 0, Mod(1, y^2 - 2),
++            Mod(y, y^2 - 2), 0, 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;
+diff --git a/src/sage/schemes/elliptic_curves/ell_number_field.py b/src/sage/schemes/elliptic_curves/ell_number_field.py
+index edbd196090..c44c803aa8 100644
+--- a/src/sage/schemes/elliptic_curves/ell_number_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_number_field.py
+@@ -218,7 +218,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: E == loads(dumps(E))
+             True
+             sage: E.simon_two_descent()
+-            (2, 2, [(0 : 0 : 1)])
++            (2, 2, [(0 : 0 : 1), (1/18*a + 7/18 : -5/54*a - 17/54 : 1)])
+             sage: E.simon_two_descent(lim1=5, lim3=5, limtriv=10, maxprob=7, limbigprime=10)
+             (2, 2, [(-1 : 0 : 1), (-2 : -1/2*a - 1/2 : 1)])
+ 
+@@ -274,7 +274,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: E.simon_two_descent()  # long time (4s on sage.math, 2013)
+             (3,
+              3,
+-             [(5/8*zeta43_0^2 + 17/8*zeta43_0 - 9/4 : -27/16*zeta43_0^2 - 103/16*zeta43_0 + 39/8 : 1),
++             [(1/8*zeta43_0^2 - 3/8*zeta43_0 - 1/4 : -5/16*zeta43_0^2 + 7/16*zeta43_0 + 1/8 : 1),
+               (0 : 0 : 1)])
+         """
+         verbose = int(verbose)
+@@ -865,7 +865,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             Conductor exponent: 1
+             Kodaira Symbol: I1
+             Tamagawa Number: 1,
+-            Local data at Fractional ideal (-3*i - 2):
++            Local data at Fractional ideal (-2*i + 3):
+             Reduction type: bad split multiplicative
+             Local minimal model: Elliptic Curve defined by y^2 + (i+1)*x*y + y = x^3 over Number Field in i with defining polynomial x^2 + 1
+             Minimal discriminant valuation: 2
+@@ -2645,12 +2645,12 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             [-92, -23, -23]
+ 
+             sage: C.matrix()  # long time
+-            [1 2 2 4 2 4]
+-            [2 1 2 2 4 4]
+-            [2 2 1 4 4 2]
+-            [4 2 4 1 3 3]
+-            [2 4 4 3 1 3]
+-            [4 4 2 3 3 1]
++            [1 2 2 4 4 2]
++            [2 1 2 4 2 4]
++            [2 2 1 2 4 4]
++            [4 4 2 1 3 3]
++            [4 2 4 3 1 3]
++            [2 4 4 3 3 1]
+ 
+         The graph of this isogeny class has a shape which does not
+         occur over `\QQ`: a triangular prism.  Note that for curves
+@@ -2677,12 +2677,12 @@ class EllipticCurve_number_field(EllipticCurve_field):
+ 
+             sage: G = C.graph()  # long time
+             sage: G.adjacency_matrix()  # long time
+-            [0 1 1 0 1 0]
+-            [1 0 1 1 0 0]
+-            [1 1 0 0 0 1]
+-            [0 1 0 0 1 1]
+-            [1 0 0 1 0 1]
+-            [0 0 1 1 1 0]
++            [0 1 1 0 0 1]
++            [1 0 1 0 1 0]
++            [1 1 0 1 0 0]
++            [0 0 1 0 1 1]
++            [0 1 0 1 0 1]
++            [1 0 0 1 1 0]
+ 
+         To display the graph without any edge labels::
+ 
+@@ -3316,7 +3316,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: points = [E.lift_x(x) for x in xi]
+             sage: newpoints, U = E.lll_reduce(points)  # long time (35s on sage.math, 2011)
+             sage: [P[0] for P in newpoints]            # long time
+-            [6823803569166584943, 5949539878899294213, 2005024558054813068, 5864879778877955778, 23955263915878682727/4, 5922188321411938518, 5286988283823825378, 175620639884534615751/25, -11451575907286171572, 3502708072571012181, 1500143935183238709184/225, 27180522378120223419/4, -5811874164190604461581/625, 26807786527159569093, 7404442636649562303, 475656155255883588, 265757454726766017891/49, 7272142121019825303, 50628679173833693415/4, 6951643522366348968, 6842515151518070703, 111593750389650846885/16, 2607467890531740394315/9, -1829928525835506297]
++            [6823803569166584943, 5949539878899294213, 2005024558054813068, 5864879778877955778, 23955263915878682727/4, 5922188321411938518, 5286988283823825378, 11465667352242779838, -11451575907286171572, 3502708072571012181, 1500143935183238709184/225, 27180522378120223419/4, -5811874164190604461581/625, 26807786527159569093, 7041412654828066743, 475656155255883588, 265757454726766017891/49, 7272142121019825303, 50628679173833693415/4, 6951643522366348968, 6842515151518070703, 111593750389650846885/16, 2607467890531740394315/9, -1829928525835506297]
+ 
+         An example to show the explicit use of the height pairing matrix::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_rational_field.py b/src/sage/schemes/elliptic_curves/ell_rational_field.py
+index 3808822812..a75290ea35 100644
+--- a/src/sage/schemes/elliptic_curves/ell_rational_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_rational_field.py
+@@ -1827,7 +1827,7 @@ class EllipticCurve_rational_field(EllipticCurve_number_field):
+             sage: E = EllipticCurve('389a1')
+             sage: E._known_points = []  # clear cached points
+             sage: E.simon_two_descent()
+-            (2, 2, [(1 : 0 : 1), (-11/9 : 28/27 : 1)])
++            (2, 2, [(5/4 : 5/8 : 1), (-3/4 : 7/8 : 1)])
+             sage: E = EllipticCurve('5077a1')
+             sage: E.simon_two_descent()
+             (3, 3, [(1 : 0 : 1), (2 : 0 : 1), (0 : 2 : 1)])
+diff --git a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
+index 81ad295160..d484a4a18b 100644
+--- a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
++++ b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
+@@ -780,12 +780,12 @@ def deg_one_primes_iter(K, principal_only=False):
+         [Fractional ideal (2, a + 1),
+          Fractional ideal (3, a + 1),
+          Fractional ideal (3, a + 2),
+-         Fractional ideal (-a),
++         Fractional ideal (a),
+          Fractional ideal (7, a + 3),
+          Fractional ideal (7, a + 4)]
+         sage: it = deg_one_primes_iter(K, True)
+         sage: [next(it) for _ in range(6)]
+-        [Fractional ideal (-a),
++        [Fractional ideal (a),
+          Fractional ideal (-2*a + 3),
+          Fractional ideal (2*a + 3),
+          Fractional ideal (a + 6),
+diff --git a/src/sage/schemes/elliptic_curves/gp_simon.py b/src/sage/schemes/elliptic_curves/gp_simon.py
+index 28b97f34af..9f7d1b6020 100644
+--- a/src/sage/schemes/elliptic_curves/gp_simon.py
++++ b/src/sage/schemes/elliptic_curves/gp_simon.py
+@@ -56,7 +56,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+         sage: import sage.schemes.elliptic_curves.gp_simon
+         sage: E=EllipticCurve('389a1')
+         sage: sage.schemes.elliptic_curves.gp_simon.simon_two_descent(E)
+-        (2, 2, [(1 : 0 : 1), (-11/9 : 28/27 : 1)])
++        (2, 2, [(5/4 : 5/8 : 1), (-3/4 : 7/8 : 1)])
+ 
+     TESTS::
+ 
+@@ -117,7 +117,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+     # The block below mimics the defaults in Simon's scripts, and needs to be changed
+     # when these are updated.
+     if K is QQ:
+-        cmd = 'ellrank(%s, %s);' % (list(E.ainvs()), [P.__pari__() for P in known_points])
++        cmd = 'ellQ_ellrank(%s, %s);' % (list(E.ainvs()), [P.__pari__() for P in known_points])
+         if lim1 is None:
+             lim1 = 5
+         if lim3 is None:
+@@ -144,7 +144,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+     if verbose > 0:
+         print(s)
+     v = gp.eval('ans')
+-    if v=='ans': # then the call to ellrank() or bnfellrank() failed
++    if v=='ans': # then the call to ellQ_ellrank() or bnfellrank() failed
+         raise RuntimeError("An error occurred while running Simon's 2-descent program")
+     if verbose >= 2:
+         print("v = %s" % v)
+diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
+index a936deb74f..dc19254d8c 100644
+--- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
++++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
+@@ -1208,14 +1208,14 @@ def isogenies_13_0(E, minimal_models=True):
+         sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]  # long time (4s)
+         [(0,
+           0,
+-          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
++          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 + 1887439/1146978983704320*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 + 1030632647/7965131831280*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 - 43618899433/204234149520*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 2535050171/1418292705,
+           -139861295/2650795873449984*a^11 - 3455957/5664093746688*a^10 - 345310571/50976843720192*a^9 - 500530795/118001953056*a^8 - 12860048113/265504394376*a^7 - 25007420461/44250732396*a^6 + 458134176455/1416023436672*a^5 + 16701880631/9077073312*a^4 + 155941666417/9077073312*a^3 + 3499310115/378211388*a^2 - 736774863/94552847*a - 21954102381/94552847,
+-          579363345221/13763747804451840*a^11 + 371192377511/860234237778240*a^10 + 8855090365657/1146978983704320*a^9 + 5367261541663/1633873196160*a^8 + 614883554332193/15930263662560*a^7 + 30485197378483/68078049840*a^6 - 131000897588387/2450809794240*a^5 - 203628705777949/306351224280*a^4 - 1587619388190379/204234149520*a^3 + 14435069706551/11346341640*a^2 + 7537273048614/472764235*a + 89198980034806/472764235),
++          8342795944891/198197968384106496*a^11 + 8908625263589/20645621706677760*a^10 + 53130542636623/6881873902225920*a^9 + 376780111042213/114697898370432*a^8 + 614884052146333/15930263662560*a^7 + 3566768133324359/7965131831280*a^6 - 1885593809102545/35291661037056*a^5 - 2443732172026523/3676214691360*a^4 - 9525729503937541/1225404897120*a^3 + 51990274442321/40846829904*a^2 + 67834019370596/4254878115*a + 267603083706812/1418292705),
+          (0,
+           0,
+-          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
++          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 + 1887439/1146978983704320*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 + 1030632647/7965131831280*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 - 43618899433/204234149520*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 2535050171/1418292705,
+           -6465569317/1325397936724992*a^11 - 112132307/1960647835392*a^10 - 17075412917/25488421860096*a^9 - 207832519229/531008788752*a^8 - 1218275067617/265504394376*a^7 - 9513766502551/177002929584*a^6 + 4297077855437/708011718336*a^5 + 354485975837/4538536656*a^4 + 4199379308059/4538536656*a^3 - 30841577919/189105694*a^2 - 181916484042/94552847*a - 2135779171614/94552847,
+-          -132601797212627/3440936951112960*a^11 - 6212467020502021/13763747804451840*a^10 - 1515926454902497/286744745926080*a^9 - 15154913741799637/4901619588480*a^8 - 576888119803859263/15930263662560*a^7 - 86626751639648671/204234149520*a^6 + 16436657569218427/306351224280*a^5 + 1540027900265659087/2450809794240*a^4 + 375782662805915809/51058537380*a^3 - 14831920924677883/11346341640*a^2 - 7237947774817724/472764235*a - 84773764066089509/472764235)]
++          -1316873026840277/34172063514501120*a^11 - 18637401045099413/41291243413355520*a^10 - 36382234917217247/6881873902225920*a^9 - 61142238484016213/19775499719040*a^8 - 576888119306045123/15930263662560*a^7 - 3378443313906256321/7965131831280*a^6 + 326466167429333279/6084769144320*a^5 + 4620083325391594991/7352429382720*a^4 + 9018783894167184149/1225404897120*a^3 - 9206015742300283/7042556880*a^2 - 65141531411426446/4254878115*a - 254321286054666133/1418292705)]
+     """
+     if E.j_invariant()!=0:
+         raise ValueError("j-invariant must be 0.")
diff --git a/srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch b/srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch
new file mode 100644
index 000000000000..762bb2612632
--- /dev/null
+++ b/srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch
@@ -0,0 +1,29 @@
+From f0365f30834b6890313790b3845c647d0160fa6a Mon Sep 17 00:00:00 2001
+From: Vincent Delecroix <20100.delecroix@gmail.com*>
+Date: Fri, 30 Sep 2022 16:31:08 +0200
+Subject: fix doctest if fqf_orthogonal
+
+---
+ src/sage/groups/fqf_orthogonal.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/sage/groups/fqf_orthogonal.py b/src/sage/groups/fqf_orthogonal.py
+index 75de408..7fc4dbe 100644
+--- a/src/sage/groups/fqf_orthogonal.py
++++ b/src/sage/groups/fqf_orthogonal.py
+@@ -245,10 +245,10 @@ class FqfOrthogonalGroup(AbelianGroupAutomorphismGroup_subgroup):
+             sage: all(x*f==x*fbar for x in q.gens())
+             True
+             sage: L = IntegralLattice("A2").twist(3)
+-            sage: q = L.discriminant_group()
+             sage: OL = L.orthogonal_group()
++            sage: assert OL(OL.0.matrix()) == OL.0
++            sage: q = L.discriminant_group()
+             sage: Oq = q.orthogonal_group()
+-            sage: assert Oq(OL.0) == Oq(OL.0.matrix())
+             sage: assert Oq(Oq.0.matrix()) == Oq.0
+         """
+         from sage.libs.gap.element import GapElement
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch b/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
deleted file mode 100644
index 4bd6f4f4e2dc..000000000000
--- a/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
+++ /dev/null
@@ -1,670 +0,0 @@
-As produced by `git diff 9.5 9.6.beta3 -- src/sage/libs/lrcalc`
-
-diff --git a/src/sage/libs/lrcalc/lrcalc.pxd b/src/sage/libs/lrcalc/lrcalc.pxd
-deleted file mode 100644
-index 10b88db93f2..00000000000
---- a/src/sage/libs/lrcalc/lrcalc.pxd
-+++ /dev/null
-@@ -1,77 +0,0 @@
--# distutils: libraries = lrcalc
--
--cdef extern from "lrcalc/hashtab.h":
--    ctypedef struct hashtab:
--        pass
--
--    ctypedef struct hash_itr:
--        pass
--
--    ctypedef unsigned long hashkey_t
--    ctypedef int (*cmp_t) (void* a, void* b)
--    ctypedef hashkey_t (*hash_t) (void* a)
--
--    hashtab* hash_new(cmp_t cm, hash_t hsh)
--    void hash_free(hashtab *ht)
--
--    void* hash_lookup(hashtab *ht, void *key)
--    void* hash_insert(hashtab *ht, void *key, void *value)
--
--    bint hash_good(hash_itr)
--    void hash_first(hashtab* s, hash_itr itr)
--    void hash_next(hash_itr itr)
--    void* hash_key(hash_itr itr)
--    void* hash_value(hash_itr itr)
--    int hash_intvalue(hash_itr itr)
--
--cdef extern from "lrcalc/vector.h":
--    ctypedef struct vector:
--        size_t length
--        int* array
--
--    vector* v_new(int length)
--    void v_free(vector* v)
--    void v_print(vector *v)
--    int v_length(vector* v)
--    int v_elem(vector* v, int i)
--
--    ctypedef struct vecpair:
--        vector *first
--        vector *second
--
--    vector* vp_first(vecpair* vp)
--    vector* vp_second(vecpair* vp)
--
--cdef extern from "lrcalc/list.h":
--    cdef struct _list:
--        void **array
--        size_t allocated
--        size_t length
--    void l_free(_list *lst)
--
--cdef extern from "lrcalc/symfcn.h":
--    long long lrcoef_c "lrcoef"(vector* outer, vector* inner1, vector* inner2)
--    hashtab* mult_c "mult"(vector *sh1, vector *sh2, int maxrows)
--    hashtab* skew_c "skew"(vector *outer, vector *inner, int maxrows)
--    hashtab* coprod_c "coprod"(vector *part, int all)
--    void fusion_reduce_c "fusion_reduce"(hashtab* ht, int rows, int cols, int opt_zero)
--    _list *quantum_reduce_c "quantum_reduce"(hashtab* ht, int rows, int col)
--
--    ctypedef struct skewtab:
--        vector *outer
--        vector *inner
--        vector *conts
--        int maxrows
--        vector *conjugate
--        int rows
--        int cols
--        int matrix[1]
--
--    skewtab *st_new(vector *outer, vector *inner, vector *conts, int maxrows)
--    int st_next(skewtab *st)
--    void st_print(skewtab *st)
--    void st_free(skewtab *st)
--
--
--cdef extern from "lrcalc/schublib.h":
--    hashtab* mult_schubert_c "mult_schubert"(vector *sh1, vector *sh2, int rank)
-diff --git a/src/sage/libs/lrcalc/lrcalc.pyx b/src/sage/libs/lrcalc/lrcalc.py
-similarity index 60%
-rename from src/sage/libs/lrcalc/lrcalc.pyx
-rename to src/sage/libs/lrcalc/lrcalc.py
-index b591081ec4c..b541bfacd89 100644
---- a/src/sage/libs/lrcalc/lrcalc.pyx
-+++ b/src/sage/libs/lrcalc/lrcalc.py
-@@ -10,7 +10,8 @@ fusion products. All of the above are achieved by counting LR
- appropriate shape and content by iterating through them.
- Additionally, ``lrcalc`` handles products of Schubert polynomials.
- 
--The web page of ``lrcalc`` is `<http://sites.math.rutgers.edu/~asbuch/lrcalc/>`_.
-+The web page of ``lrcalc`` is
-+`<http://sites.math.rutgers.edu/~asbuch/lrcalc/>`_.
- 
- The following describes the Sage interface to this library.
- 
-@@ -36,12 +37,13 @@ Schur expansion::
-      [4, 2]: 1}
- 
- Same product, but include only partitions with at most 3 rows.  This
--corresponds to computing in the representation ring of gl(3)::
-+corresponds to computing in the representation ring of `\mathfrak{gl}(3)`::
- 
-     sage: lrcalc.mult([2,1], [2,1], 3)
-     {[2, 2, 2]: 1, [3, 2, 1]: 2, [3, 3]: 1, [4, 1, 1]: 1, [4, 2]: 1}
- 
--We can also compute the fusion product, here for sl(3) and level 2::
-+We can also compute the fusion product, here for `\mathfrak{sl}(3)`
-+and level 2::
- 
-     sage: lrcalc.mult([3,2,1], [3,2,1], 3,2)
-     {[4, 4, 4]: 1, [5, 4, 3]: 1}
-@@ -77,42 +79,38 @@ Multiply two Schubert polynomials::
-      [6, 2, 1, 4, 3, 5]: 1}
- 
- Same product, but include only permutations of 5 elements in the result.
--This corresponds to computing in the cohomology ring of Fl(5)::
-+This corresponds to computing in the cohomology ring of `Fl(5)`::
- 
-     sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3], 5)
-     {[4, 5, 1, 3, 2]: 1, [5, 3, 1, 4, 2]: 1, [5, 4, 1, 2, 3]: 1}
- 
- List all Littlewood-Richardson tableaux of skew shape `\mu/\nu`; in
- this example `\mu=[3,2,1]` and `\nu=[2,1]`. Specifying a third entry
--`maxrows` restricts the alphabet to `\{1,2,\ldots,maxrows\}`::
-+`M' = ``maxrows`` restricts the alphabet to `\{1,2,\ldots,M\}`::
- 
-     sage: list(lrcalc.lrskew([3,2,1],[2,1]))
-     [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
-     [[None, None, 1], [None, 2], [1]], [[None, None, 1], [None, 2], [3]]]
- 
-     sage: list(lrcalc.lrskew([3,2,1],[2,1],maxrows=2))
--    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]], [[None, None, 1], [None, 2], [1]]]
-+    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
-+     [[None, None, 1], [None, 2], [1]]]
- 
- .. TODO::
- 
--    use this library in the :class:`SymmetricFunctions` code, to
-+    Use this library in the :class:`SymmetricFunctions` code, to
-     make it easy to apply it to linear combinations of Schur functions.
- 
- .. SEEALSO::
- 
-     - :func:`lrcoef`
--
-     - :func:`mult`
--
-     - :func:`coprod`
--
-     - :func:`skew`
--
-     - :func:`lrskew`
--
-     - :func:`mult_schubert`
- 
--.. rubric:: Underlying algorithmic in lrcalc
-+.. RUBRIC:: Underlying algorithmic in lrcalc
- 
- Here is some additional information regarding the main low-level
- C-functions in `lrcalc`. Given two partitions ``outer`` and ``inner``
-@@ -187,180 +185,24 @@ AUTHORS:
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from sage.rings.integer cimport Integer
--from sage.structure.parent cimport Parent
- from sage.combinat.partition import _Partitions
- from sage.combinat.permutation import Permutation
--from sage.combinat.skew_tableau import SkewTableau
--
--
--cdef vector* iterable_to_vector(it):
--    """
--    Return an lrcalc vector (which is a list of integers) from a Python iterable.
--
--    TESTS::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector(Partition([3,2,1])); x   #indirect doctest
--        [3, 2, 1]
--    """
--    cdef vector* v
--    cdef list itr = list(it)
--    cdef int n = len(itr)
--    cdef int i
--    v = v_new(n)
--    for i in range(n):
--        v.array[i] = int(itr[i])
--    return v
--
--
--cdef list vector_to_list(vector *v):
--    """
--    Converts a lrcalc vector to Python list.
--
--    TESTS::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector([]); x         #indirect doctest
--        []
--    """
--    cdef int i, n
--    n = v_length(v)
--    cdef list result = [None]*n
--    for i in range(n):
--        result[i] = Integer(v_elem(v, i))
--    return result
--
--
--def test_iterable_to_vector(it):
--    """
--    A wrapper function for the cdef function ``iterable_to_vector``
--    and ``vector_to_list``, to test that they are working correctly.
-+from sage.combinat.skew_tableau import SemistandardSkewTableaux
-+from sage.combinat.skew_partition import SkewPartition
-+from sage.rings.integer import Integer
-+import lrcalc
- 
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector([3,2,1]); x
--        [3, 2, 1]
--    """
--    cdef vector *v = iterable_to_vector(it)
--    result = vector_to_list(v)
--    v_free(v)
--    return result
--
--
--cdef skewtab_to_SkewTableau(skewtab *st):
--    """
--    A wrapper function which transforms the data set ``st`` used in
--    ``lrcalc`` to a ``SkewTableau`` in Sage.
-+def _lrcalc_dict_to_sage(result):
-+    r"""
-+    Translate from lrcalc output format to Sage expected format.
- 
-     TESTS::
- 
--        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
--        sage: test_skewtab_to_SkewTableau([],[])
--        []
--    """
--    inner = vector_to_list(st.inner)
--    outer = vector_to_list(st.outer)
--    return SkewTableau(expr=[[inner[y] for y in range(len(outer))],
--                             [[st.matrix[x + y * st.cols] + 1
--                                for x in range(inner[y], outer[y])]
--                              for y in range(len(outer) - 1, -1, -1)]])
--
--
--def test_skewtab_to_SkewTableau(outer, inner):
--    """
--    A wrapper function for the cdef function ``skewtab_to_SkewTableau``
--    for testing purposes.
--
--    It constructs the first LR skew tableau of shape ``outer/inner``
--    as an ``lrcalc`` ``skewtab``, and converts it to a
--    :class:`SkewTableau`.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
--        sage: test_skewtab_to_SkewTableau([3,2,1],[])
--        [[1, 1, 1], [2, 2], [3]]
--        sage: test_skewtab_to_SkewTableau([4,3,2,1],[1,1]).pp()
--        .  1  1  1
--        .  2  2
--        1  3
--        2
--    """
--    cdef vector* o = iterable_to_vector(outer)
--    cdef vector* i = iterable_to_vector(inner+[0]*(len(outer)-len(inner)))
--    cdef skewtab* st = st_new(o, i, NULL, 0)
--    return skewtab_to_SkewTableau(st)
--
--
--cdef dict sf_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary representing a Schur function. The keys are
--    partitions and the values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
-         sage: from sage.libs.lrcalc.lrcalc import mult
--        sage: sorted(mult([1],[1]).items())        #indirect doctest
--        [([1, 1], 1), ([2], 1)]
--        sage: assert isinstance(mult([1],[1]),dict)#indirect doctest
--    """
--    cdef hash_itr itr
--    cdef dict result = {}
--    cdef list p
--    hash_first(ht, itr)
--    while hash_good(itr):
--        p = vector_to_list(<vector*> hash_key(itr))
--        result[_Partitions(p)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
--
--cdef dict schubert_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary corresponding to a Schubert polynomial whose keys
--    are permutations and whose values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import mult_schubert
--        sage: mult_schubert([3,2,1], [1,2,3])      #indirect doctest
--        {[3, 2, 1]: 1}
--    """
--    cdef hash_itr itr
--    cdef dict result = {}
--    hash_first(ht, itr)
--    while hash_good(itr):
--        p = vector_to_list(<vector*> hash_key(itr))
--        result[Permutation(p)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
--
--cdef dict vp_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary corresponding to the coproduct of a Schur function whose keys are
--    pairs of partitions and whose values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import coprod
--        sage: coprod([1])      #indirect doctest
--        {([1], []): 1}
-+        sage: mult([2,1],[3,2,1],3) # indirect doctest
-+        {[3, 3, 3]: 1, [4, 3, 2]: 2, [4, 4, 1]: 1, [5, 2, 2]: 1, [5, 3, 1]: 1}
-     """
--    cdef hash_itr itr
--    cdef vecpair* vp
--    cdef dict result = {}
--    hash_first(ht, itr)
--    while hash_good(itr):
--        vp = <vecpair*> hash_key(itr)
--        p1 = _Partitions(vector_to_list(vp_first(vp)))
--        p2 = _Partitions(vector_to_list(vp_second(vp)))
--        result[(p1, p2)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
-+    return {_Partitions(la): Integer(k) for la, k in result.items()}
- 
- def lrcoef_unsafe(outer, inner1, inner2):
-     r"""
-@@ -371,13 +213,11 @@ def lrcoef_unsafe(outer, inner1, inner2):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
--
--    - ``inner1`` -- a partition.
-+    - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
-+    - ``inner1`` -- a partition
-+    - ``inner2`` -- a partition
- 
--    - ``inner2`` -- a partition.
--
--    .. warning::
-+    .. WARNING::
- 
-        This function does not do any check on its input.  If you want
-        to use a safer version, use :func:`lrcoef`.
-@@ -392,18 +232,7 @@ def lrcoef_unsafe(outer, inner1, inner2):
-         sage: lrcoef_unsafe([2,1,1,1,1], [2,1], [2,1])
-         0
-     """
--    cdef long long result
--    cdef vector *o
--    cdef vector *i1
--    cdef vector *i2
--    o = iterable_to_vector(outer)
--    i1 = iterable_to_vector(inner1)
--    i2 = iterable_to_vector(inner2)
--    result = lrcoef_c(o, i1, i2)
--    v_free(o)
--    v_free(i1)
--    v_free(i2)
--    return Integer(result)
-+    return Integer(lrcalc.lrcoef(outer, inner1, inner2))
- 
- 
- def lrcoef(outer, inner1, inner2):
-@@ -415,11 +244,9 @@ def lrcoef(outer, inner1, inner2):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
--
--    - ``inner1`` -- a partition.
--
--    - ``inner2`` -- a partition.
-+    - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
-+    - ``inner1`` -- a partition
-+    - ``inner2`` -- a partition
- 
-     .. NOTE::
- 
-@@ -436,7 +263,6 @@ def lrcoef(outer, inner1, inner2):
-         1
-         sage: lrcoef([2,1,1,1,1], [2,1], [2,1])
-         0
--
-     """
-     return lrcoef_unsafe(_Partitions(outer), _Partitions(inner1), _Partitions(inner2))
- 
-@@ -451,13 +277,9 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-     INPUT:
- 
-     - ``part1`` -- a partition
--
-     - ``part2`` -- a partition
--
-     - ``maxrows`` -- (optional) an integer
--
-     - ``level`` -- (optional) an integer
--
-     - ``quantum`` -- (optional) an element of a ring
- 
-     If ``maxrows`` is specified, then only partitions with at most
-@@ -479,7 +301,8 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-         sage: sorted(mult([2],[2]).items())
-         [([2, 2], 1), ([3, 1], 1), ([4], 1)]
-         sage: sorted(mult([2,1],[2,1]).items())
--        [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1), ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
-+        [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1),
-+         ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
-         sage: sorted(mult([2,1],[2,1],maxrows=2).items())
-         [([3, 3], 1), ([4, 2], 1)]
-         sage: mult([2,1],[3,2,1],3)
-@@ -510,44 +333,24 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-     if quantum is not None and (level is None or maxrows is None):
-         raise ValueError('missing parameters maxrows or level')
- 
--    cdef vector* v1 = iterable_to_vector(part1)
--    cdef vector* v2 = iterable_to_vector(part2)
--    if maxrows is None:
--        maxrows = 0
--    cdef hashtab* ht = mult_c(v1, v2, int(maxrows))
--    cdef hashtab* tab
--    cdef dict result
--
-     if quantum is None:
-         if level is not None:
--            fusion_reduce_c(ht, int(maxrows), int(level), int(0))
--        result = sf_hashtab_to_dict(ht)
--        v_free(v1)
--        v_free(v2)
--        hash_free(ht)
--        return result
-+            return _lrcalc_dict_to_sage(lrcalc.mult_fusion(part1, part2, maxrows, level))
-+        if maxrows is None:
-+            maxrows = -1
-+        return _lrcalc_dict_to_sage(lrcalc.mult(part1, part2, maxrows))
- 
-     # Otherwise do quantum multiplication
--    cdef _list *qlist
--    cdef dict temp
--    qlist = quantum_reduce_c(ht, int(maxrows), int(level))
--    # The above call frees the memory associated with ht
--    v_free(v1)
--    v_free(v2)
--
--    cdef Parent P = quantum.parent()
--    result = {}
--    for i in range(qlist.length):
--        tab = <hashtab*>(qlist.array[i])
--        temp = sf_hashtab_to_dict(tab)
--        for k in temp:
--            result[k] = result.get(k, P.zero()) + quantum**i * temp[k]
--        hash_free(tab)
--    l_free(qlist)
--    return result
--
--
--def skew(outer, inner, maxrows=0):
-+    result = lrcalc.mult_quantum(part1, part2, maxrows, level, degrees=True)
-+    P = quantum.parent()
-+    output = {}
-+    for i,k in result.items():
-+        la = _Partitions(i[0])
-+        output[la] = output.get(la, P.zero()) + k * quantum**(i[1])
-+    return output
-+
-+
-+def skew(outer, inner, maxrows=-1):
-     """
-     Compute the Schur expansion of a skew Schur function.
- 
-@@ -557,11 +360,9 @@ def skew(outer, inner, maxrows=0):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition.
--
--    - ``inner`` -- a partition.
--
--    - ``maxrows`` -- an integer or ``None``.
-+    - ``outer`` -- a partition
-+    - ``inner`` -- a partition
-+    - ``maxrows`` -- an integer or ``None``
- 
-     If ``maxrows`` is specified, then only partitions with at most
-     this number of rows are included in the result.
-@@ -572,14 +373,7 @@ def skew(outer, inner, maxrows=0):
-         sage: sorted(skew([2,1],[1]).items())
-         [([1, 1], 1), ([2], 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(outer)
--    cdef vector* v2 = iterable_to_vector(inner)
--    cdef hashtab* ht = skew_c(v1, v2, int(maxrows))
--    result = sf_hashtab_to_dict(ht)
--    v_free(v1)
--    v_free(v2)
--    hash_free(ht)
--    return result
-+    return _lrcalc_dict_to_sage(lrcalc.skew(outer, inner, maxrows))
- 
- 
- def coprod(part, all=0):
-@@ -592,9 +386,8 @@ def coprod(part, all=0):
- 
-     INPUT:
- 
--    - ``part`` -- a partition.
--
--    - ``all`` -- an integer.
-+    - ``part`` -- a partition
-+    - ``all`` -- an integer
- 
-     If ``all`` is non-zero then all terms are included in the result.
-     If ``all`` is zero, then only pairs of partitions ``(part1,
-@@ -609,12 +402,9 @@ def coprod(part, all=0):
-         sage: sorted(coprod([2,1]).items())
-         [(([1, 1], [1]), 1), (([2], [1]), 1), (([2, 1], []), 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(part)
--    cdef hashtab* ht = coprod_c(v1, int(all))
--    result = vp_hashtab_to_dict(ht)
--    v_free(v1)
--    hash_free(ht)
--    return result
-+    result = lrcalc.coprod(part, all)
-+    return {tuple([_Partitions(mu) for mu in la]): Integer(k)
-+            for la, k in result.items()}
- 
- 
- def mult_schubert(w1, w2, rank=0):
-@@ -627,11 +417,9 @@ def mult_schubert(w1, w2, rank=0):
- 
-     INPUT:
- 
--    - ``w1`` -- a permutation.
--
--    - ``w2`` -- a permutation.
--
--    - ``rank`` -- an integer.
-+    - ``w1`` -- a permutation
-+    - ``w2`` -- a permutation
-+    - ``rank`` -- an integer
- 
-     If ``rank`` is non-zero, then only permutations from the symmetric
-     group `S(\mathrm{rank})` are included in the result.
-@@ -646,33 +434,24 @@ def mult_schubert(w1, w2, rank=0):
-          ([6, 4, 3, 1, 2, 5], 1), ([6, 5, 2, 1, 3, 4], 1),
-          ([7, 3, 4, 1, 2, 5, 6], 1), ([7, 4, 2, 1, 3, 5, 6], 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(w1)
--    cdef vector* v2 = iterable_to_vector(w2)
--    cdef hashtab* ht = mult_schubert_c(v1, v2, int(rank))
--    result = schubert_hashtab_to_dict(ht)
--    v_free(v1)
--    v_free(v2)
--    hash_free(ht)
--    return result
-+    result = lrcalc.schubmult(w1, w2, rank)
-+    return {Permutation(list(la)):Integer(k) for la,k in result.items()}
- 
- 
--def lrskew(outer, inner, weight=None, maxrows=0):
-+def lrskew(outer, inner, weight=None, maxrows=-1):
-     r"""
-     Iterate over the skew LR tableaux of shape ``outer / inner``.
- 
-     INPUT:
- 
-     - ``outer`` -- a partition
--
-     - ``inner`` -- a partition
--
-     - ``weight`` -- a partition (optional)
--
--    - ``maxrows`` -- an integer (optional)
-+    - ``maxrows`` -- a positive integer (optional)
- 
-     OUTPUT: an iterator of :class:`SkewTableau`
- 
--    Specifying ``maxrows`` restricts the alphabet to `\{1,2,\ldots,maxrows\}`.
-+    Specifying ``maxrows`` = `M` restricts the alphabet to `\{1,2,\ldots,M\}`.
- 
-     Specifying ``weight`` returns only those tableaux of given content/weight.
- 
-@@ -702,22 +481,40 @@ def lrskew(outer, inner, weight=None, maxrows=0):
- 
-         sage: list(lrskew([3,2,1],[2], weight=[3,1]))
-         [[[None, None, 1], [1, 1], [2]]]
-+
-+    TESTS::
-+
-+        sage: from sage.libs.lrcalc.lrcalc import lrskew
-+        sage: list(lrskew([3,2,1],[2], weight=[]))
-+        []
-+        sage: list(lrskew([3,2,1],[2], weight=[0]))
-+        []
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[]))
-+        [[[None, None, None], [None, None], [None]]]
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[0]))
-+        [[[None, None, None], [None, None], [None]]]
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[1]))
-+        []
-     """
--    cdef vector* o = iterable_to_vector(outer)
--    cdef vector* i = iterable_to_vector(inner + [0]*(len(outer) - len(inner)))
--    cdef skewtab* st = st_new(o, i, NULL, int(maxrows))
-+    iterator = lrcalc.lr_iterator(outer, inner, maxrows)
-+    shape = SkewPartition([outer, inner])
- 
-     if weight is None:
--        yield skewtab_to_SkewTableau(st)
--        while st_next(st):
--            yield skewtab_to_SkewTableau(st)
-+        ST = SemistandardSkewTableaux(shape)
-+        for data in iterator:
-+            yield ST.from_shape_and_word(shape, [i+1 for i in data])
-     else:
-         wt = _Partitions(weight)
--        r = skewtab_to_SkewTableau(st)
--        if r.weight() == wt:
--            yield r
--        while st_next(st):
--            r = skewtab_to_SkewTableau(st)
--            if r.weight() == wt:
--                yield r
--    st_free(st)
-+        ST = SemistandardSkewTableaux(shape, wt)
-+        m = len(wt)
-+        for data in iterator:
-+            w = [0] * m
-+            for j in data:
-+                if j >= m:
-+                    # We know they are not equal, so make the check below quick
-+                    w = None
-+                    break
-+                w[j] += 1
-+            if w == wt:
-+                yield ST.from_shape_and_word(shape, [i+1 for i in data])
-+
diff --git a/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch b/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
deleted file mode 100644
index 1e2e0ba90742..000000000000
--- a/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-As produced by `git diff a90a3146{^^,}`
-
-diff --git a/src/sage/repl/interface_magic.py b/src/sage/repl/interface_magic.py
-index 8a455b69b0e..a93e1c9e04c 100644
---- a/src/sage/repl/interface_magic.py
-+++ b/src/sage/repl/interface_magic.py
-@@ -260,7 +260,7 @@ class InterfaceMagic(object):
-             2
-             120
-             sage: shell.run_cell('%%gap foo\n1+1;\n')
--            ...File "<string>", line unknown
-+            ...File...<string>...
-             SyntaxError: Interface magics have no options, got "foo"
-             <BLANKLINE>
-             sage: shell.run_cell('%%gap?')
-diff --git a/src/sage/repl/interpreter.py b/src/sage/repl/interpreter.py
-index 7468afe52d7..06c47b7374a 100644
---- a/src/sage/repl/interpreter.py
-+++ b/src/sage/repl/interpreter.py
-@@ -78,9 +78,9 @@ Check that Cython source code appears in tracebacks::
-     dummy line
-     ...
-     ZeroDivisionError...Traceback (most recent call last)
--    <ipython-input-...> in <module>...
-+    ...in <module>...
-     ----> 1 Integer(1)/Integer(0)
--    .../sage/rings/integer.pyx in sage.rings.integer.Integer...div...
-+    .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
-     ...
-     -> ...                  raise ZeroDivisionError("rational division by zero")
-        ....:            x = <Rational> Rational.__new__(Rational)
-@@ -423,7 +423,7 @@ def SagePreparseTransformer(lines):
-         sage: from sage.repl.interpreter import get_test_shell
-         sage: shell = get_test_shell()
-         sage: shell.run_cell(bad_syntax)
--          File "<string>", line unknown
-+          File...<string>...
-         SyntaxError: Mismatched ']'
-         <BLANKLINE>
-         sage: shell.quit()
diff --git a/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch b/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
deleted file mode 100644
index 853813b0f5bd..000000000000
--- a/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Fix for ipython 8.1
-
---- a/src/sage/repl/interpreter.py
-+++ b/src/sage/repl/interpreter.py
-@@ -78,7 +78,7 @@ Check that Cython source code appears in tracebacks::
-     dummy line
-     ...
-     ZeroDivisionError...Traceback (most recent call last)
--    ...in <module>...
-+    ...
-     ----> 1 Integer(1)/Integer(0)
-     .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
-     ...
diff --git a/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch b/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
deleted file mode 100644
index b861af7ec982..000000000000
--- a/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
+++ /dev/null
@@ -1,126 +0,0 @@
-From 24cc94b1988a90f3bd22a2368ec30c086283af13 Mon Sep 17 00:00:00 2001
-From: Antonio Rojas <arojas@archlinux.org>
-Date: Sun, 16 Jan 2022 11:55:04 +0100
-Subject: Add abs tol to some arb tests
-
----
- src/sage/functions/error.py    |  2 +-
- src/sage/rings/complex_arb.pyx |  6 +++---
- src/sage/rings/real_arb.pyx    | 10 +++++-----
- 3 files changed, 9 insertions(+), 9 deletions(-)
-
-diff --git a/src/sage/functions/error.py b/src/sage/functions/error.py
-index f48d04f..06f0b24 100644
---- a/src/sage/functions/error.py
-+++ b/src/sage/functions/error.py
-@@ -267,7 +267,7 @@ class Function_erf(BuiltinFunction):
- 
-         Check that real ball evaluation is fixed :trac:`28061`::
- 
--            sage: RealBallField(128)(erf(5))
-+            sage: RealBallField(128)(erf(5)) # abs tol 1e-38
-             [0.99999999999846254020557196514981165651 +/- 7.33e-39]
-         """
-         R = parent or s_parent(x)
-diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
-index f986970..93ff565 100644
---- a/src/sage/rings/complex_arb.pyx
-+++ b/src/sage/rings/complex_arb.pyx
-@@ -3974,8 +3974,8 @@ cdef class ComplexBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: CBF(20).erfc()
--            [5.39586561160790e-176 +/- ...e-191]
-+            sage: CBF(20).erfc() # abs tol 1e-190
-+            [5.39586561160790e-176 +/- 6.73e-191]
-             sage: CBF(100, 100).erfc()
-             [0.00065234366376858 +/- ...e-18] + [-0.00393572636292141 +/- ...e-18]*I
-         """
-@@ -4280,7 +4280,7 @@ cdef class ComplexBall(RingElement):
- 
-         TESTS:
- 
--            sage: CBF(Shi(I))
-+            sage: CBF(Shi(I)) # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]*I
-         """
-         cdef ComplexBall result = self._new()
-diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
-index 4a81784..292bfea 100644
---- a/src/sage/rings/real_arb.pyx
-+++ b/src/sage/rings/real_arb.pyx
-@@ -3506,7 +3506,7 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1/2).erf()
-+            sage: RBF(1/2).erf() # abs tol 1e-16
-             [0.520499877813047 +/- 6.10e-16]
-         """
-         cdef RealBall res = self._new()
-@@ -3556,12 +3556,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Si()
-+            sage: RBF(1).Si() # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]
- 
-         TESTS::
- 
--            sage: RBF(Si(1))
-+            sage: RBF(Si(1)) # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]
-         """
-         cdef RealBall res = self._new()
-@@ -3578,12 +3578,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Ci()  # abs tol 1e-16
-+            sage: RBF(1).Ci()  # abs tol 1e-15
-             [0.337403922900968 +/- 3.25e-16]
- 
-         TESTS::
- 
--            sage: RBF(Ci(1))  # abs tol 1e-16
-+            sage: RBF(Ci(1))  # abs tol 1e-15
-             [0.337403922900968 +/- 3.25e-16]
-         """
-         cdef RealBall res = self._new()
--- 
-cgit v1.0-1-gd88e
-
-
-From 53532ddd4e2dc92469c1590ebf0c40f8f69bf579 Mon Sep 17 00:00:00 2001
-From: Antonio Rojas <arojas@archlinux.org>
-Date: Sun, 16 Jan 2022 14:16:53 +0100
-Subject: Decrease abs tol
-
----
- src/sage/rings/real_arb.pyx | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
-index 292bfea..eb30f7f 100644
---- a/src/sage/rings/real_arb.pyx
-+++ b/src/sage/rings/real_arb.pyx
-@@ -3578,12 +3578,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Ci()  # abs tol 1e-15
-+            sage: RBF(1).Ci()  # abs tol 5e-16
-             [0.337403922900968 +/- 3.25e-16]
- 
-         TESTS::
- 
--            sage: RBF(Ci(1))  # abs tol 1e-15
-+            sage: RBF(Ci(1))  # abs tol 5e-16
-             [0.337403922900968 +/- 3.25e-16]
-         """
-         cdef RealBall res = self._new()
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch b/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
deleted file mode 100644
index d4e8f8be60e3..000000000000
--- a/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From 33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c Mon Sep 17 00:00:00 2001
-From: Michael Orlitzky <michael@orlitzky.com>
-Date: Mon, 24 Jan 2022 09:03:29 -0500
-Subject: Trac #33226: update doctests for giac-1.7.0.45.
-
-We have two failing doctests with giac-1.7.0.45: one is a trivial
-tolerance issue, but the other is a symbolic integration result for
-which giac is no longer willing to return a symbolic answer. We add
-"abs tol" to the numeric test, and drop the symbolic one entirely.
----
- src/sage/functions/min_max.py | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/src/sage/functions/min_max.py b/src/sage/functions/min_max.py
-index fc18373..9b7d6d9 100644
---- a/src/sage/functions/min_max.py
-+++ b/src/sage/functions/min_max.py
-@@ -228,15 +228,15 @@ class MaxSymbolic(MinMax_base):
-             ...
-             TypeError: cannot evaluate symbolic expression numerically
- 
--        ::
-+        We can usually integrate these expressions, but can't
-+        guarantee a symbolic answer in closed form::
- 
-             sage: f = max_symbolic(sin(x), cos(x))
-             sage: r = integral(f, x, 0, 1)
-             ...
--            sage: r
--            sqrt(2) - cos(1)
--            sage: r.n()
-+            sage: r.n()  # abs tol 1e-8
-             0.873911256504955
-+
-         """
-         return max_symbolic(args)
- 
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch b/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
deleted file mode 100644
index 19b69700a4f6..000000000000
--- a/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-commit 9c8235e44ffb509efa8a3ca6cdb55154e2b5066d
-Author: Antonio Rojas <arojas@archlinux.org>
-Date:   Sun Feb 13 19:53:14 2022 +0100
-
-    Fix deprecation warning with scipy 1.8
-
-diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-index e9b60dae5ec..7932167b41d 100644
---- a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-@@ -356,7 +356,7 @@ Sage example in ./linsolve.tex, line 2230::
- 
- Sage example in ./linsolve.tex, line 2609::
- 
--  sage: from scipy.sparse.linalg.dsolve import *
-+  sage: from scipy.sparse.linalg import factorized
-   sage: from scipy.sparse import lil_matrix
-   sage: from numpy import array
-   sage: n = 200
diff --git a/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch b/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
new file mode 100644
index 000000000000..e052e306e7a1
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
@@ -0,0 +1,53 @@
+From 6330cee1a69229b2f5d8ac4a09a73d8152f5e14d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Mon, 28 Feb 2022 23:15:16 -0300
+Subject: trac 33360: avoid factoring in is_prime()
+
+In the added TEST, the ideal norm is product of two primes but factoring
+this product takes about half an hour, so factoring the ideal is slow.
+
+To fix the issue, we only factor the ideal if the norm is a prime power.
+---
+ src/sage/rings/number_field/number_field_ideal.py | 22 ++++++++++++++++++++++
+ 1 file changed, 22 insertions(+)
+
+diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
+index f785f22..10d1f88 100644
+--- a/src/sage/rings/number_field/number_field_ideal.py
++++ b/src/sage/rings/number_field/number_field_ideal.py
+@@ -995,10 +995,32 @@ class NumberFieldIdeal(Ideal_generic):
+             False
+             sage: K.ideal(17).is_prime()  # ramified
+             False
++
++        TESTS::
++
++        Check that we do not factor the norm of the ideal, this used
++        to take half an hour, see :trac:`33360`
++
++           sage: K.<a,b,c> = NumberField([x^2-2,x^2-3,x^2-5])
++           sage: t = (((-2611940*c + 1925290/7653)*b - 1537130/7653*c
++           ....:       + 10130950)*a + (1343014/7653*c - 8349770)*b
++           ....:       + 6477058*c - 2801449990/4002519)
++           sage: t.is_prime()
++           False
++
+         """
+         try:
+             return self._pari_prime is not None
+         except AttributeError:
++            K = self.number_field().pari_nf()
++            I = self.pari_hnf()
++            # This would be better, but it is broken in pari 2.13.3.
++            #   self._pari_prime = K.idealismaximal(I) or None
++            # Instead we factor I, but only if the norm is a prime power
++            n = K.idealnorm(I)
++            if n.denominator() > 1 or not n.isprimepower():
++                self._pari_prime = None
++                return False
+             F = self.factor()  # factorization with caching
+             if len(F) != 1 or F[0][1] != 1:
+                 self._pari_prime = None
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
deleted file mode 100644
index 9ba7ca5a6b7d..000000000000
--- a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
+++ /dev/null
@@ -1,99 +0,0 @@
-From 609dd9deaeaa6380ab2f0d50276d911233c00a04 Mon Sep 17 00:00:00 2001
-From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
-Date: Fri, 4 Mar 2022 16:07:09 -0800
-Subject: sage.manifolds: Update doctests for SymPy 1.10
-
----
- src/sage/manifolds/continuous_map.py              | 3 +--
- src/sage/manifolds/differentiable/diff_form.py    | 4 ++--
- src/sage/manifolds/differentiable/tensorfield.py  | 8 ++++----
- src/sage/manifolds/vector_bundle_fiber_element.py | 2 +-
- 4 files changed, 8 insertions(+), 9 deletions(-)
-
-diff --git a/src/sage/manifolds/continuous_map.py b/src/sage/manifolds/continuous_map.py
-index a6356e7..f6f9b6d 100644
---- a/src/sage/manifolds/continuous_map.py
-+++ b/src/sage/manifolds/continuous_map.py
-@@ -1357,8 +1357,7 @@ class ContinuousMap(Morphism):
-             sage: Phi.coord_functions(c_uv, c_xyz)
-             Coordinate functions (u*v, u/v, u + v) on the Chart (M, (u, v))
-             sage: Phi.coord_functions(c_UV, c_xyz)
--            Coordinate functions (-U**2/4 + V**2/4, -(U + V)/(U - V), V)
--             on the Chart (M, (U, V))
-+            Coordinate functions (-U**2/4 + V**2/4, (-U - V)/(U - V), V) on the Chart (M, (U, V))
-             sage: Phi.coord_functions(c_UV, c_XYZ)
-             Coordinate functions ((-U**3 + U**2*V + U*V**2 + 2*U*V + 6*U - V**3
-              - 2*V**2 + 6*V)/(2*(U - V)), (U**3/4 - U**2*V/4 - U*V**2/4 + U*V
-diff --git a/src/sage/manifolds/differentiable/diff_form.py b/src/sage/manifolds/differentiable/diff_form.py
-index 70dd8fb..0aa3469 100644
---- a/src/sage/manifolds/differentiable/diff_form.py
-+++ b/src/sage/manifolds/differentiable/diff_form.py
-@@ -266,7 +266,7 @@ class DiffForm(TensorField):
- 
-         sage: s = a.wedge(b)
-         sage: s.display(eU)
--        a∧b = -x*(2*x*y + 1) dx∧dy
-+        a∧b = x*(-2*x*y - 1) dx∧dy
-         sage: s.display(eV)
-         a∧b = (u**3/8 + u**2*v/8 - u*v**2/8 + u/4 - v**3/8 + v/4) du∧dv
- 
-@@ -275,7 +275,7 @@ class DiffForm(TensorField):
-         sage: f = M.scalar_field({c_xy: (x+y)^2, c_uv: u^2}, name='f')
-         sage: s = f*a
-         sage: s.display(eU)
--        f*a = -y*(x**2 + 2*x*y + y**2) dx + x*(x**2 + 2*x*y + y**2) dy
-+        f*a = y*(-x**2 - 2*x*y - y**2) dx + x*(x**2 + 2*x*y + y**2) dy
-         sage: s.display(eV)
-         f*a = u**2*v/2 du - u**3/2 dv
- 
-diff --git a/src/sage/manifolds/differentiable/tensorfield.py b/src/sage/manifolds/differentiable/tensorfield.py
-index 2775be9..6bc5c50 100644
---- a/src/sage/manifolds/differentiable/tensorfield.py
-+++ b/src/sage/manifolds/differentiable/tensorfield.py
-@@ -334,7 +334,7 @@ class TensorField(ModuleElementWithMutability):
-         sage: f.display()  # long time
-         t(a,b): S^2 → ℝ
-         on U: (x, y) ↦ -2*x*y - 3*x - y**2
--        on V: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+        on V: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
- 
-     The vectors can be defined only on subsets of `S^2`, the domain of the
-     result is then the common subset::
-@@ -343,12 +343,12 @@ class TensorField(ModuleElementWithMutability):
-         sage: s.display()  # long time
-         t(a,b): U → ℝ
-            (x, y) ↦ -2*x*y - 3*x - y**2
--        on W: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+        on W: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
-         sage: s = t(a.restrict(U), b.restrict(W))  # long time
-         sage: s.display()  # long time
-         t(a,b): W → ℝ
-            (x, y) ↦ -2*x*y - 3*x - y**2
--           (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+           (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
- 
-     The tensor itself can be defined only on some open subset of `S^2`,
-     yielding a result whose domain is this subset::
-@@ -356,7 +356,7 @@ class TensorField(ModuleElementWithMutability):
-         sage: s = t.restrict(V)(a,b)  # long time
-         sage: s.display()  # long time
-         t(a,b): V → ℝ
--           (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+           (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
-         on W: (x, y) ↦ -2*x*y - 3*x - y**2
- 
-     Tests regarding the multiplication by a scalar field::
-diff --git a/src/sage/manifolds/vector_bundle_fiber_element.py b/src/sage/manifolds/vector_bundle_fiber_element.py
-index 29ee81d..048275a 100644
---- a/src/sage/manifolds/vector_bundle_fiber_element.py
-+++ b/src/sage/manifolds/vector_bundle_fiber_element.py
-@@ -110,4 +110,4 @@ class VectorBundleFiberElement(FiniteRankFreeModuleElement):
-             desc += str(self._name) + " "
-         desc += "in the fiber of {} at {}".format(self._vbundle._name,
-                                                   self._point)
--        return desc
-\ No newline at end of file
-+        return desc
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
deleted file mode 100644
index f5ac180baa90..000000000000
--- a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From c49eff347454ac7f07e5918470b20e97b8f2357e Mon Sep 17 00:00:00 2001
-From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
-Date: Fri, 4 Mar 2022 15:14:43 -0800
-Subject: src/sage/calculus/calculus.py: Update laplace doctest for sympy 1.10
-
----
- src/sage/calculus/calculus.py | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/src/sage/calculus/calculus.py b/src/sage/calculus/calculus.py
-index 9c2f226..b335093 100644
---- a/src/sage/calculus/calculus.py
-+++ b/src/sage/calculus/calculus.py
-@@ -1639,9 +1639,9 @@ def laplace(ex, t, s, algorithm='maxima'):
-         sage: laplace(dirac_delta(t), t, s)
-         1
-         sage: F, a, cond = laplace(dirac_delta(t), t, s, algorithm='sympy')
--        sage: a, cond
--        (-oo, True)
--        sage: F       # random - sympy <1.9 includes undefined heaviside(0) in answer
-+        sage: a, cond  # random - sympy <1.10 gives (-oo, True)
-+        (0, True)
-+        sage: F        # random - sympy <1.9 includes undefined heaviside(0) in answer
-         1
-         sage: laplace(dirac_delta(t), t, s, algorithm='giac')
-         1
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch b/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
deleted file mode 100644
index 8e7bb64f5b01..000000000000
--- a/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From a04a0a0b14f67f4804e7113c3db41bbcf8a58296 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
-Date: Mon, 28 Mar 2022 20:39:59 -0300
-Subject: Trac #33585: fix doctest when dochtml is missing...
-
-...but sphinx is available in PYTHONPATH.
----
- src/sage/misc/sagedoc.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/sage/misc/sagedoc.py b/src/sage/misc/sagedoc.py
-index 4b3853f..08c4225 100644
---- a/src/sage/misc/sagedoc.py
-+++ b/src/sage/misc/sagedoc.py
-@@ -1401,7 +1401,7 @@ class _sage_doc:
-             "...**File:**...**Type:**...**Definition:** identity_matrix..."
-             sage: identity_matrix.__doc__ in browse_sage_doc(identity_matrix, 'rst')
-             True
--            sage: browse_sage_doc(identity_matrix, 'html', False)             # optional - sphinx
-+            sage: browse_sage_doc(identity_matrix, 'html', False)             # optional - sphinx sagemath_doc_html
-             '...div...File:...Type:...Definition:...identity_matrix...'
- 
-         In the 'text' version, double colons have been replaced with
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch b/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
new file mode 100644
index 000000000000..977a42400e59
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
@@ -0,0 +1,42 @@
+commit 5db5d4e56243c609f44afc1f21c112b026f9e1fe
+Author: Oscar Benjamin <oscar.j.benjamin@gmail.com>
+Date:   Mon Jul 11 21:24:01 2022 +0100
+
+    Update doctests for SymPy 1.11
+    
+    Doctests related to SymPy's rsolve function are updated in:
+    
+    src/sage/calculus/test_sympy.py
+    src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+    
+    The form of the output from SymPy has changed since
+    
+    https://github.com/sympy/sympy/pull/23567
+
+diff --git a/src/sage/calculus/test_sympy.py b/src/sage/calculus/test_sympy.py
+index 7cf7f3f6bfd..927e6ee4fb6 100644
+--- a/src/sage/calculus/test_sympy.py
++++ b/src/sage/calculus/test_sympy.py
+@@ -193,7 +193,7 @@ This was fixed in Sympy, see :trac:`14437`::
+     sage: u = Function('u')
+     sage: n = Symbol('n', integer=True)
+     sage: f = u(n+2) - u(n+1) + u(n)/4
+-    sage: 2**n * rsolve(f,u(n))
+-    C1*n + C0
++    sage: expand(2**n * rsolve(f,u(n)))
++    2*C1*n + C0
+ 
+ """
+diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+index 1062f4f7e8c..f53f813d793 100644
+--- a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
++++ b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+@@ -382,7 +382,7 @@ Sage example in ./recequadiff.tex, line 1798::
+   sage: from sympy import rsolve_hyper
+   sage: from sympy.abc import n
+   sage: rsolve_hyper([-2,1],2**(n+2),n)
+-  2**n*C0 + 2**(n + 2)*(C0 + n/2)
++  2**n*C0 + 2**(n + 1)*n
+ 
+ """
+ 
diff --git a/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch b/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch
new file mode 100644
index 000000000000..b544a3eef7dd
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch
@@ -0,0 +1,526 @@
+From aeff992d53a65a705dca5cd5216bcb97c218dce7 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:14:03 +0200
+Subject: Adapt to API changes in OpenOutputStream and CloseOutput
+
+---
+ src/sage/libs/gap/element.pyx      | 5 +++--
+ src/sage/libs/gap/gap_includes.pxd | 6 ++++--
+ 2 files changed, 7 insertions(+), 4 deletions(-)
+
+diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
+index be43c4c..e268116 100644
+--- a/src/sage/libs/gap/element.pyx
++++ b/src/sage/libs/gap/element.pyx
+@@ -130,6 +130,7 @@ cdef char *capture_stdout(Obj func, Obj obj):
+     """
+     cdef Obj s, stream, output_text_string
+     cdef UInt res
++    cdef TypOutputFile output
+     # The only way to get a string representation of an object that is truly
+     # consistent with how it would be represented at the GAP REPL is to call
+     # ViewObj on it.  Unfortunately, ViewObj *prints* to the output stream,
+@@ -145,12 +146,12 @@ cdef char *capture_stdout(Obj func, Obj obj):
+         output_text_string = GAP_ValueGlobalVariable("OutputTextString")
+         stream = CALL_2ARGS(output_text_string, s, GAP_True)
+ 
+-        if not OpenOutputStream(stream):
++        if not OpenOutputStream(&output, stream):
+             raise GAPError("failed to open output capture stream for "
+                            "representing GAP object")
+ 
+         CALL_1ARGS(func, obj)
+-        CloseOutput()
++        CloseOutput(&output)
+         return CSTR_STRING(s)
+     finally:
+         GAP_Leave()
+diff --git a/src/sage/libs/gap/gap_includes.pxd b/src/sage/libs/gap/gap_includes.pxd
+index 5a9ab48..34035fe 100644
+--- a/src/sage/libs/gap/gap_includes.pxd
++++ b/src/sage/libs/gap/gap_includes.pxd
+@@ -76,8 +76,10 @@ cdef extern from "gap/intobj.h" nogil:
+ 
+ 
+ cdef extern from "gap/io.h" nogil:
+-    UInt OpenOutputStream(Obj stream)
+-    UInt CloseOutput()
++    ctypedef struct TypOutputFile:
++        pass
++    UInt OpenOutputStream(TypOutputFile* output, Obj stream)
++    UInt CloseOutput(TypOutputFile* output)
+ 
+ 
+ cdef extern from "gap/libgap-api.h" nogil:
+-- 
+cgit v1.0-1-gd88e
+
+
+From c3367b4290981e5e93b7a30c48b02f1ae3770dc8 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:14:53 +0200
+Subject: Disable colored prompt as it breaks the pexpect interface
+
+---
+ src/sage/interfaces/gap.py | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/src/sage/interfaces/gap.py b/src/sage/interfaces/gap.py
+index c34fe53..569caa2 100644
+--- a/src/sage/interfaces/gap.py
++++ b/src/sage/interfaces/gap.py
+@@ -1512,6 +1512,8 @@ def gap_reset_workspace(max_workspace_size=None, verbose=False):
+     """
+     # Create new workspace with filename WORKSPACE
+     g = Gap(use_workspace_cache=False, max_workspace_size=None)
++    g.eval('ColorPrompt(false)')
++    g.eval('SetUserPreference("UseColorPrompt", false)')
+     g.eval('SetUserPreference("HistoryMaxLines", 30)')
+     from sage.tests.gap_packages import all_installed_packages
+     for pkg in all_installed_packages(gap=g):
+-- 
+cgit v1.0-1-gd88e
+
+
+From 3b63e998e4d6118fc86b13b940c8f3d3b8307a50 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:16:03 +0200
+Subject: Port NaturalHomomorphism uses
+
+---
+ src/sage/groups/abelian_gps/abelian_group_gap.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/sage/groups/abelian_gps/abelian_group_gap.py b/src/sage/groups/abelian_gps/abelian_group_gap.py
+index a4b0471..86090b4 100644
+--- a/src/sage/groups/abelian_gps/abelian_group_gap.py
++++ b/src/sage/groups/abelian_gps/abelian_group_gap.py
+@@ -338,7 +338,7 @@ class AbelianGroup_gap(UniqueRepresentation, GroupMixinLibGAP, ParentLibGAP, Abe
+         if isinstance(x, AbelianGroupElement_gap):
+             try:
+                 if x in self._cover:
+-                    x = self.gap().NaturalHomomorphism().Image(x.gap())
++                    x = self._cover.gap().NaturalHomomorphismByNormalSubgroup(self._relations).Image(x.gap())
+                 else:
+                     x = x.gap()
+             except AttributeError:
+@@ -1043,7 +1043,7 @@ class AbelianGroupQuotient_gap(AbelianGroup_gap):
+             From: Abelian group with gap, generator orders (4,)
+             To:   Quotient abelian group with generator orders (2,)
+         """
+-        phi = self.gap().NaturalHomomorphism()
++        phi = self._cover.gap().NaturalHomomorphismByNormalSubgroup(self._relations)
+         Hom = self._cover.Hom(self)
+         return Hom(phi)
+ 
+-- 
+cgit v1.0-1-gd88e
+
+
+From bc40764be044653e06f2da3497e1e05da08251f7 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:17:36 +0200
+Subject: Fix tests with GAP 4.12
+
+---
+ src/doc/en/thematic_tutorials/lie/weyl_groups.rst  | 12 ++++++------
+ src/sage/coding/codecan/autgroup_can_label.pyx     |  2 +-
+ src/sage/coding/linear_code.py                     | 22 +++++++++++-----------
+ .../root_system/hecke_algebra_representation.py    |  2 +-
+ src/sage/combinat/symmetric_group_algebra.py       |  2 +-
+ src/sage/groups/finitely_presented.py              |  6 +++---
+ src/sage/groups/fqf_orthogonal.py                  |  2 +-
+ src/sage/groups/libgap_wrapper.pyx                 |  6 +++---
+ .../perm_gps/partn_ref2/refinement_generic.pyx     |  2 +-
+ src/sage/groups/perm_gps/permgroup.py              |  8 ++++----
+ src/sage/libs/gap/libgap.pyx                       |  2 +-
+ src/sage/libs/gap/util.pyx                         |  8 +-------
+ src/sage/tests/gap_packages.py                     |  2 +-
+ 13 files changed, 35 insertions(+), 41 deletions(-)
+
+diff --git a/src/doc/en/thematic_tutorials/lie/weyl_groups.rst b/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
+index c917338..182e74a 100644
+--- a/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
++++ b/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
+@@ -139,12 +139,12 @@ string, which you can print::
+     X.1      1  1  1  1  1  1  1  1  1  1  1  1  1
+     X.2      1 -1  1  1 -1  1  1 -1 -1 -1  1  1  1
+     X.3      2  .  2 -1  .  2  2  .  .  . -1  2  2
+-    X.4      3 -1 -1  .  1 -1  3 -1  1 -1  . -1  3
+-    X.5      3 -1 -1  .  1  3 -1 -1 -1  1  . -1  3
+-    X.6      3  1 -1  . -1 -1  3  1 -1  1  . -1  3
+-    X.7      3  1 -1  . -1  3 -1  1  1 -1  . -1  3
+-    X.8      3 -1  3  . -1 -1 -1 -1  1  1  . -1  3
+-    X.9      3  1  3  .  1 -1 -1  1 -1 -1  . -1  3
++    X.4      3 -1 -1  .  1  3 -1 -1 -1  1  . -1  3
++    X.5      3  1 -1  . -1  3 -1  1  1 -1  . -1  3
++    X.6      3 -1  3  . -1 -1 -1 -1  1  1  . -1  3
++    X.7      3 -1 -1  .  1 -1  3 -1  1 -1  . -1  3
++    X.8      3  1  3  .  1 -1 -1  1 -1 -1  . -1  3
++    X.9      3  1 -1  . -1 -1  3  1 -1  1  . -1  3
+     X.10     4 -2  . -1  .  .  .  2  .  .  1  . -4
+     X.11     4  2  . -1  .  .  . -2  .  .  1  . -4
+     X.12     6  . -2  .  . -2 -2  .  .  .  .  2  6
+diff --git a/src/sage/coding/codecan/autgroup_can_label.pyx b/src/sage/coding/codecan/autgroup_can_label.pyx
+index de5db98..c83b926 100644
+--- a/src/sage/coding/codecan/autgroup_can_label.pyx
++++ b/src/sage/coding/codecan/autgroup_can_label.pyx
+@@ -76,7 +76,7 @@ columns do share the same coloring::
+     ((1,),
+      (2,),
+      (3, 5, 4),
+-     (6, 19, 16, 9, 21, 10, 8, 15, 14, 11, 20, 13, 12, 7, 17, 18))
++     (6, 19, 16, 21, 9, 10, 15, 8, 20, 11, 14, 13, 7, 12, 18, 17))
+ 
+ We can also restrict the group action to linear isometries::
+ 
+diff --git a/src/sage/coding/linear_code.py b/src/sage/coding/linear_code.py
+index e8e32f8..9d45160 100644
+--- a/src/sage/coding/linear_code.py
++++ b/src/sage/coding/linear_code.py
+@@ -466,27 +466,27 @@ class AbstractLinearCode(AbstractLinearCodeNoMetric):
+             0
+             sage: C = codes.HammingCode(GF(4, 'z'), 3)
+             sage: C.automorphism_group_gens()
+-            ([((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
++            ([((1, 1, 1, z, z + 1, 1, 1, 1, 1, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z); (1,13,14,20)(2,21,8,18,7,16,19,15)(3,10,5,12,17,9,6,4), Ring endomorphism of Finite Field in z of size 2^2
++                Defn: z |--> z + 1),
++              ((z, 1, z, z, z, z + 1, z, z, z, z, z, z, z + 1, z, z, z, z, z + 1, z, z, z); (1,11,5,12,3,19)(2,8)(6,18,13)(7,17,15)(9,10,14,16,20,21), 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 + 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
++            ([((z, 1, z + 1, z + 1, 1, z + 1, z, 1, z + 1, z + 1, 1, z, 1, z + 1, z, 1, z, 1, z + 1, 1, 1); (1,12,11,10,6,8,9,20,13,21,5,14,3,16,17,19,7,4,2,15,18), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+-              ((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
++              ((z + 1, z + 1, z + 1, z, 1, 1, z, z, 1, z + 1, z, 1, 1, z, 1, z + 1, z, z + 1, z + 1, 1, z); (1,3,18,2,17,6,19)(4,15,13,20,7,14,16)(5,11,8,21,12,9,10), 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)],
+              181440)
+             sage: C.automorphism_group_gens(equivalence="permutational")
+-            ([((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,19)(3,17)(4,21)(5,20)(7,14)(9,12)(10,16)(11,15), Ring endomorphism of Finite Field in z of size 2^2
++            ([((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,11)(3,10)(4,9)(5,7)(12,21)(14,20)(15,19)(16,17), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+-              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,11)(3,10)(4,9)(5,7)(12,21)(14,20)(15,19)(16,17), Ring endomorphism of Finite Field in z of size 2^2
++              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (2,18)(3,19)(4,10)(5,16)(8,13)(9,14)(11,21)(15,20), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+-              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,17)(2,8)(3,14)(4,10)(7,12)(9,19)(13,18)(15,20), Ring endomorphism of Finite Field in z of size 2^2
++              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,19)(3,17)(4,21)(5,20)(7,14)(9,12)(10,16)(11,15), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+               ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (2,13)(3,14)(4,20)(5,11)(8,18)(9,19)(10,15)(16,21), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z)],
+@@ -692,10 +692,10 @@ class AbstractLinearCode(AbstractLinearCodeNoMetric):
+             sage: C_iso == aut_group_can_label.get_canonical_form()
+             True
+             sage: aut_group_can_label.get_autom_gens()
+-            [((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
++            [((1, 1, 1, z, z + 1, 1, 1, 1, 1, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z); (1,13,14,20)(2,21,8,18,7,16,19,15)(3,10,5,12,17,9,6,4), Ring endomorphism of Finite Field in z of size 2^2
++               Defn: z |--> z + 1),
++             ((z, 1, z, z, z, z + 1, z, z, z, z, z, z, z + 1, z, z, z, z, z + 1, z, z, z); (1,11,5,12,3,19)(2,8)(6,18,13)(7,17,15)(9,10,14,16,20,21), 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/root_system/hecke_algebra_representation.py b/src/sage/combinat/root_system/hecke_algebra_representation.py
+index bde2823..bffcc85 100644
+--- a/src/sage/combinat/root_system/hecke_algebra_representation.py
++++ b/src/sage/combinat/root_system/hecke_algebra_representation.py
+@@ -355,7 +355,7 @@ class HeckeAlgebraRepresentation(WithEqualityById, SageObject):
+             sage: q1, q2 = K.gens()
+             sage: KW = W.algebra(K)
+             sage: x = KW.an_element(); x
+-            123 + 3*32 + 2*3 + e
++            123 + 3*2312 + 2*31 + e
+ 
+             sage: T = KW.demazure_lusztig_operators(q1,q2)
+             sage: T12 = T.Tw( (1,2) )
+diff --git a/src/sage/combinat/symmetric_group_algebra.py b/src/sage/combinat/symmetric_group_algebra.py
+index c3d6755..da953d2 100644
+--- a/src/sage/combinat/symmetric_group_algebra.py
++++ b/src/sage/combinat/symmetric_group_algebra.py
+@@ -101,7 +101,7 @@ def SymmetricGroupAlgebra(R, W, category=None):
+         sage: SGA.group()
+         Weyl Group of type ['A', 3] (as a matrix group acting on the ambient space)
+         sage: SGA.an_element()
+-        s1*s2*s3 + 3*s3*s2 + 2*s3 + 1
++        s1*s2*s3 + 3*s2*s3*s1*s2 + 2*s3*s1 + 1
+ 
+     The preferred way to construct the symmetric group algebra is to
+     go through the usual ``algebra`` method::
+diff --git a/src/sage/groups/finitely_presented.py b/src/sage/groups/finitely_presented.py
+index 2a61bbf..d26891a 100644
+--- a/src/sage/groups/finitely_presented.py
++++ b/src/sage/groups/finitely_presented.py
+@@ -596,9 +596,9 @@ class RewritingSystem():
+             sage: k = G.rewriting_system()
+             sage: k.gap()
+             Knuth Bendix Rewriting System for Monoid( [ a, A, b, B ] ) with rules
+-            [ [ a^2, <identity ...> ], [ a*A, <identity ...> ],
+-              [ A*a, <identity ...> ], [ b^2, <identity ...> ],
+-              [ b*B, <identity ...> ], [ B*b, <identity ...> ] ]
++            [ [ a*A, <identity ...> ], [ A*a, <identity ...> ],
++              [ b*B, <identity ...> ], [ B*b, <identity ...> ],
++              [ a^2, <identity ...> ], [ b^2, <identity ...> ] ]
+         """
+         return self._gap
+ 
+diff --git a/src/sage/groups/fqf_orthogonal.py b/src/sage/groups/fqf_orthogonal.py
+index 75de408..dd7d84d 100644
+--- a/src/sage/groups/fqf_orthogonal.py
++++ b/src/sage/groups/fqf_orthogonal.py
+@@ -143,7 +143,7 @@ class FqfOrthogonalGroup(AbelianGroupAutomorphismGroup_subgroup):
+         [2/3   0   0]
+         [  0 2/3   0]
+         [  0   0 4/3]
+-        generated by 2 elements
++        generated by 3 elements
+         sage: q = matrix.diagonal(QQ, [3/2, 1/4, 1/4])
+         sage: T = TorsionQuadraticForm(q)
+         sage: T.orthogonal_group().order()
+diff --git a/src/sage/groups/libgap_wrapper.pyx b/src/sage/groups/libgap_wrapper.pyx
+index a76afc2..9340c0d 100644
+--- a/src/sage/groups/libgap_wrapper.pyx
++++ b/src/sage/groups/libgap_wrapper.pyx
+@@ -25,7 +25,7 @@ Note how we call the constructor of both superclasses to initialize
+ its output via LibGAP::
+ 
+     sage: FooGroup()
+-    <pc group of size 3 with 1 generators>
++    <pc group of size 3 with 1 generator>
+     sage: type(FooGroup().gap())
+     <class 'sage.libs.gap.element.GapElement'>
+ 
+@@ -106,7 +106,7 @@ class ParentLibGAP(SageObject):
+         ....:         ParentLibGAP.__init__(self, lg)
+         ....:         Group.__init__(self)
+         sage: FooGroup()
+-        <pc group of size 3 with 1 generators>
++        <pc group of size 3 with 1 generator>
+     """
+ 
+     def __init__(self, libgap_parent, ambient=None):
+@@ -461,7 +461,7 @@ cdef class ElementLibGAP(MultiplicativeGroupElement):
+         ....:         ParentLibGAP.__init__(self, lg)
+         ....:         Group.__init__(self)
+         sage: FooGroup()
+-        <pc group of size 3 with 1 generators>
++        <pc group of size 3 with 1 generator>
+         sage: FooGroup().gens()
+         (f1,)
+     """
+diff --git a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
+index 2fcb036..ca73c6b 100644
+--- a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
++++ b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
+@@ -427,7 +427,7 @@ cdef class LabelledBranching:
+             sage: from sage.groups.perm_gps.partn_ref2.refinement_generic import LabelledBranching
+             sage: L = LabelledBranching(3)
+             sage: L.small_generating_set()
+-            []
++            [()]
+             sage: L.add_gen(libgap.eval('(1,2,3)'))
+             sage: L.small_generating_set()
+             [(1,2,3)]
+diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
+index 4908934..34ba0cc 100644
+--- a/src/sage/groups/perm_gps/permgroup.py
++++ b/src/sage/groups/perm_gps/permgroup.py
+@@ -913,7 +913,7 @@ class PermutationGroup_generic(FiniteGroup):
+            sage: f = PG._coerce_map_from_(MG)
+            sage: mg = MG.an_element()
+            sage: p = f(mg); p
+-           (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)
++           (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(p._gap_()) == p
+            True
+ 
+@@ -959,12 +959,12 @@ class PermutationGroup_generic(FiniteGroup):
+             sage: P = G.as_permutation_group(algorithm='smaller', seed=5)
+             sage: P1 = G.as_permutation_group()
+             sage: P == P1
+-            False
++            True
+             sage: g1, g2, g3 = G.gens()
+             sage: P(g1*g2)
+-            (1,3,7,12)(2,4,8,10)(5,11)(6,9)
++            (1,4,13,11)(2,5,14,18)(3,15,8,16)(6,7)(9,20,19,12)(10,17)
+             sage: P1(g1*g2)
+-            (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)
++            (1,4,13,11)(2,5,14,18)(3,15,8,16)(6,7)(9,20,19,12)(10,17)
+ 
+         Another check for :trac:`5583`::
+ 
+diff --git a/src/sage/libs/gap/libgap.pyx b/src/sage/libs/gap/libgap.pyx
+index b1a64e5..6a36613 100644
+--- a/src/sage/libs/gap/libgap.pyx
++++ b/src/sage/libs/gap/libgap.pyx
+@@ -695,7 +695,7 @@ class Gap(Parent):
+             sage: libgap.List
+             <Gap function "List">
+             sage: libgap.GlobalRandomSource
+-            <RandomSource in IsGlobalRandomSource>
++            <RandomSource in IsGAPRandomSource>
+         """
+         if name in dir(self.__class__):
+             return getattr(self.__class__, name)
+diff --git a/src/sage/libs/gap/util.pyx b/src/sage/libs/gap/util.pyx
+index 344ab88..6350987 100644
+--- a/src/sage/libs/gap/util.pyx
++++ b/src/sage/libs/gap/util.pyx
+@@ -362,15 +362,9 @@ cdef Obj gap_eval(str gap_string) except? NULL:
+         GAPError: Error, Variable: 'Complex' must have a value
+         Syntax error: ; expected in stream:1
+         Complex Field with 53 bits of precision;;
+-         ^^^^^^^^^^^^
++                ^^^^^
+         Error, Variable: 'with' must have a value
+-        Syntax error: ; expected in stream:1
+-        Complex Field with 53 bits of precision;;
+-         ^^^^^^^^^^^^^^^^^^^^
+         Error, Variable: 'bits' must have a value
+-        Syntax error: ; expected in stream:1
+-        Complex Field with 53 bits of precision;;
+-         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+         Error, Variable: 'precision' must have a value
+ 
+     Test that on a subsequent attempt we get the same message (no garbage was
+diff --git a/src/sage/tests/gap_packages.py b/src/sage/tests/gap_packages.py
+index 2e4518c..c302b16 100644
+--- a/src/sage/tests/gap_packages.py
++++ b/src/sage/tests/gap_packages.py
+@@ -103,7 +103,7 @@ def all_installed_packages(ignore_dot_gap=False, gap=None):
+ 
+         sage: from sage.tests.gap_packages import all_installed_packages
+         sage: all_installed_packages()
+-        (...'GAPDoc'...)
++        (...'gapdoc'...)
+         sage: all_installed_packages(ignore_dot_gap=True) == all_installed_packages(gap=gap, ignore_dot_gap=True)
+         True
+     """
+-- 
+cgit v1.0-1-gd88e
+
+
+From cbc902a79ff9ec01d4d4eb9a767a1c661fb5dda7 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Fri, 30 Sep 2022 19:17:42 +0200
+Subject: Adapt test to new is_transitive and is_primitive behavior
+
+---
+ src/sage/groups/perm_gps/permgroup.py | 22 ++++++++++++++++------
+ 1 file changed, 16 insertions(+), 6 deletions(-)
+
+diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
+index 34ba0cc..5832b98 100644
+--- a/src/sage/groups/perm_gps/permgroup.py
++++ b/src/sage/groups/perm_gps/permgroup.py
+@@ -4359,17 +4359,23 @@ class PermutationGroup_generic(FiniteGroup):
+ 
+         ::
+ 
+-            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)]]) #S_5 on [1..5]
+-            sage: G.is_transitive([1,4,5])
++            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)],[(6,7)]])
++            sage: G.is_transitive([1,2,3,4,5])
+             True
+-            sage: G.is_transitive([2..6])
++            sage: G.is_transitive([1..7])
+             False
+             sage: G.is_transitive(G.non_fixed_points())
+-            True
++            False
+             sage: H = PermutationGroup([[(1,2,3)],[(4,5,6)]])
+             sage: H.is_transitive(H.non_fixed_points())
+             False
+ 
++        If `G` does not act on the domain, it always returns ``False``::
++
++            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)]]) #S_5 on [1..5]
++            sage: G.is_transitive([1,4,5])
++            False
++
+         Note that this differs from the definition in GAP, where
+         ``IsTransitive`` returns whether the group is transitive on the
+         set of points moved by the group.
+@@ -4425,12 +4431,16 @@ class PermutationGroup_generic(FiniteGroup):
+             sage: G = PermutationGroup([[(1,2,3,4)],[(2,4)]])
+             sage: G.is_primitive([1..4])
+             False
+-            sage: G.is_primitive([1,2,3])
+-            True
+             sage: G = PermutationGroup([[(3,4,5,6)],[(3,4)]]) #S_4 on [3..6]
+             sage: G.is_primitive(G.non_fixed_points())
+             True
+ 
++        If `G` does not act on the domain, it always returns ``False``::
++
++            sage: G = PermutationGroup([[(1,2,3,4)],[(2,4)]])
++            sage: G.is_primitive([1,2,3])
++            False
++
+         """
+         #If the domain is not a subset of self.domain(), then the
+         #action isn't primitive.
+-- 
+cgit v1.0-1-gd88e
+
+
+From 80dd6b338236f170efca1fc3545df18ce8d8795c Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Fri, 30 Sep 2022 19:18:06 +0200
+Subject: Mark test as random. With gap 4.12 on x86_64 it is no longer 2
+
+---
+ src/sage/groups/perm_gps/permgroup.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
+index 5832b98..c1230a3 100644
+--- a/src/sage/groups/perm_gps/permgroup.py
++++ b/src/sage/groups/perm_gps/permgroup.py
+@@ -1287,7 +1287,7 @@ class PermutationGroup_generic(FiniteGroup):
+             sage: G.gens_small() # random
+             [('b','c'), ('a','c','b')] ## (on 64-bit Linux)
+             [('a','b'), ('a','c','b')] ## (on Solaris)
+-            sage: len(G.gens_small()) == 2
++            sage: len(G.gens_small()) == 2 # random
+             True
+         """
+         gens = self._libgap_().SmallGeneratingSet()
+-- 
+cgit v1.0-1-gd88e
+
+
+From a6c293d67cfcdf8fba7bc6aa7899e2086d42cc7e Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Fri, 30 Sep 2022 19:18:30 +0200
+Subject: Remove test that is now redundant, all seeds give the same answer
+
+---
+ src/sage/groups/matrix_gps/finitely_generated.py | 3 ---
+ 1 file changed, 3 deletions(-)
+
+diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
+index a6d3dc0..63956ad 100644
+--- a/src/sage/groups/matrix_gps/finitely_generated.py
++++ b/src/sage/groups/matrix_gps/finitely_generated.py
+@@ -563,9 +563,6 @@ class FinitelyGeneratedMatrixGroup_gap(MatrixGroup_gap):
+             21499084800
+             sage: P = G.as_permutation_group()
+             sage: Psmaller = G.as_permutation_group(algorithm="smaller", seed=6)
+-            sage: P == Psmaller  # see the note below
+-            True
+-            sage: Psmaller = G.as_permutation_group(algorithm="smaller")
+             sage: P == Psmaller
+             False
+             sage: P.cardinality()
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch b/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
new file mode 100644
index 000000000000..8fedcb78cf71
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
@@ -0,0 +1,19 @@
+commit 04971318f032caf8dc1c0de9489346d894409091
+Author: John H. Palmieri <jhpalmieri64@gmail.com>
+Date:   Wed Aug 31 14:22:26 2022 -0700
+
+    trac 34465: fix invalid escape sequence in functions/special.py
+
+diff --git a/src/sage/functions/special.py b/src/sage/functions/special.py
+index 02596e49620..901f02f9bee 100644
+--- a/src/sage/functions/special.py
++++ b/src/sage/functions/special.py
+@@ -849,7 +849,7 @@ class EllipticF(BuiltinFunction):
+     - :wikipedia:`Elliptic_integral#Incomplete_elliptic_integral_of_the_first_kind`
+     """
+     def __init__(self):
+-        """
++        r"""
+         EXAMPLES::
+ 
+             sage: loads(dumps(elliptic_f))
diff --git a/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch b/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch
deleted file mode 100644
index f3eb0aad2cca..000000000000
--- a/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch
+++ /dev/null
@@ -1,14 +0,0 @@
- - this is not a proper fix... should fix sage_getfile() instead
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -187,7 +187,8 @@ def loadable_module_extension():
-         True
-     """
-     # Return the full platform-specific extension module suffix
--    return import_machinery.EXTENSION_SUFFIXES[0]
-+    # PATCHED for void linux, we use the shortest extension (.so)
-+    return import_machinery.EXTENSION_SUFFIXES[-1]
- 
- 
- def isclassinstance(obj):
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 0d793262d572..8df50e4e13b6 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,7 +1,7 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=9.5
-revision=2
+version=9.7
+revision=1
 wrksrc=sage-$version
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
@@ -33,12 +33,9 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="http://sagemath.org/"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=8d70a3b26080802c5b2e33dda4c23795d494d8216a0c2ecfcd608ebab0e64ff6
+checksum=9f26f14aa322e3cf38a71835b12ac34b23026b467f74d54b064c5d025e76fbfd
 
 post_patch() {
-	# these are unused and nothing else uses ratpoints
-	rm sage/libs/ratpoints.{pyx,pxd}
-
 	# git tree needs bootstrapping
 	pushd $wrksrc/build/pkgs/sagelib
 	PATH=../../bin:$PATH BOOTSTRAP_QUIET=no ./bootstrap
@@ -65,6 +62,7 @@ do_configure() {
 
 pre_build() {
 	export PYTHONPATH=../sage-setup
+	export PYTHONDONTWRITEBYTECODE=yes
 	export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
 }
 
@@ -77,6 +75,7 @@ post_build() {
 
 pre_install() {
 	export PYTHONPATH=../sage-setup
+	export PYTHONDONTWRITEBYTECODE=yes
 	export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
 }
 
@@ -104,6 +103,7 @@ post_install() {
 do_check() {
 	_scripts=$(cd build/scripts* && pwd)
 	export PYTHONPATH=$(cd build/lib* && pwd)
+	export PYTHONDONTWRITEBYTECODE=yes
 
 	# get out of $build_wrksrc, otherwise python picks the wrong sage module
 	cd $(mktemp -dp build)

From ad08d47b914c4f77ddc68143d5611111994cbfb0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Sat, 15 Oct 2022 23:21:33 -0300
Subject: [PATCH 13/21] sagemath: use conf files instead of patching

---
 srcpkgs/sagemath/files/sage-env-config |  3 ++
 srcpkgs/sagemath/files/sage_conf.py    |  3 ++
 srcpkgs/sagemath/template              | 40 ++++++++------------------
 3 files changed, 18 insertions(+), 28 deletions(-)
 create mode 100644 srcpkgs/sagemath/files/sage-env-config
 create mode 100644 srcpkgs/sagemath/files/sage_conf.py

diff --git a/srcpkgs/sagemath/files/sage-env-config b/srcpkgs/sagemath/files/sage-env-config
new file mode 100644
index 000000000000..7d2f97d92214
--- /dev/null
+++ b/srcpkgs/sagemath/files/sage-env-config
@@ -0,0 +1,3 @@
+# configure PATH using sage script location
+export PATH="$(dirname $SELF):$PATH"
+#export PYTHONPATH="$(cd $(dirname $SELF)/../lib/python*/site-packages/ && pwd):$PYTHONPATH"
diff --git a/srcpkgs/sagemath/files/sage_conf.py b/srcpkgs/sagemath/files/sage_conf.py
new file mode 100644
index 000000000000..85ec37dfb50e
--- /dev/null
+++ b/srcpkgs/sagemath/files/sage_conf.py
@@ -0,0 +1,3 @@
+# configuration for sage on void linux
+SAGE_SHARE = "/usr/share/sagemath"
+GAP_ROOT_DIR = "/usr/share/gap"
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 8df50e4e13b6..51d8067a7d3c 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -5,7 +5,7 @@ revision=1
 wrksrc=sage-$version
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
-_bindir=/usr/lib/sagemath/bin
+_bindir=/usr/lib/sagemath/${version}/bin
 make_install_args="--install-scripts=$_bindir"
 hostmakedepends="m4 pkg-config python3-Cython python3-Jinja2 python3-pkgconfig
  python3-setuptools"
@@ -35,29 +35,10 @@ homepage="http://sagemath.org/"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
 checksum=9f26f14aa322e3cf38a71835b12ac34b23026b467f74d54b064c5d025e76fbfd
 
-post_patch() {
-	# git tree needs bootstrapping
-	pushd $wrksrc/build/pkgs/sagelib
-	PATH=../../bin:$PATH BOOTSTRAP_QUIET=no ./bootstrap
-	popd
-}
-
 do_configure() {
-	# set variables in sage.env since we do not install sage_conf
-	cat >> sage/env.py <<-EOF
-	CONWAY_POLYNOMIALS_DATA_DIR = "/usr/share/sagemath/conway_polynomials"
-	GRAPHS_DATA_DIR = "/usr/share/sagemath/graphs"
-	ELLCURVE_DATA_DIR = "/usr/share/sagemath/ellcurves"
-	POLYTOPE_DATA_DIR = "/usr/share/sagemath/reflexive_polytopes"
-	COMBINATORIAL_DESIGN_DATA_DIR = "/usr/share/sagemath/combinatorial_designs"
-	CREMONA_MINI_DATA_DIR = "/usr/share/sagemath/cremona"
-	CREMONA_LARGE_DATA_DIR = "/usr/share/sagemath/cremona"
-	THREEJS_DIR = "/usr/share/sagemath/threejs-sage"
-	EOF
-
-	# don't install sage-venv-config: it is used to set SAGE_VENV=/usr and
-	# then sage-env prepends "$SAGE_VENV/bin" to PATH which is undesired
-	vsed -e '/sage-venv-config/d' -i $wrksrc/src/setup.cfg
+	# git tree needs bootstrapping
+	(cd "$wrksrc/build/pkgs/sagelib" &&
+	 PATH=../../bin:$PATH BOOTSTRAP_QUIET=no ./bootstrap)
 }
 
 pre_build() {
@@ -67,10 +48,13 @@ pre_build() {
 }
 
 post_build() {
+	_lib=$(cd build/lib* && pwd)
 	_scripts=$(cd build/scripts* && pwd)
-	cat >> $_scripts/sage-env-config <<-'EOF'
-	PATH=$(dirname $SELF):$PATH
-	EOF
+	# remove sage-venv-config since it clobbers PATH
+	rm "$_scripts/sage-venv-config"
+	# configuration files
+	cp "${FILESDIR}/sage-env-config" "$_scripts"
+	cp "${FILESDIR}/sage_conf.py" "$_lib"
 }
 
 pre_install() {
@@ -81,7 +65,7 @@ pre_install() {
 
 post_install() {
 	# fix jupyter kernel spec
-	vsed -i -e 's|"/usr/bin/sage", "--python"|"/usr/bin/python"|' \
+	vsed -i -e 's|"/usr/bin/sage"|"'"$_bindir"'/sage"|' \
 		${DESTDIR}/usr/share/jupyter/kernels/sagemath/kernel.json
 	# replace broken symlinks by good copies (sagemath logo images)
 	for file in $(ls sage/ext_data/notebook-ipython); do
@@ -91,7 +75,7 @@ post_install() {
 	done
 	# we don't have docs here
 	rm ${DESTDIR}/usr/share/jupyter/kernels/sagemath/doc
-	# we don't have threejs in void
+	# this symlink is shipped in threejs-sage pkg
 	rm ${DESTDIR}/usr/share/jupyter/nbextensions/threejs-sage
 
 	# symlink main binary

From bdcb4085ea10156500d64587ec062867d8262e1f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 17 Oct 2022 00:37:05 -0300
Subject: [PATCH 14/21] sagemath: more fixes

---
 srcpkgs/sagemath/files/sage_conf.py           |   1 +
 ...fc4ec8b8687bccd22d2e3161c86cf5553e06.patch | 427 ++++++++++++++++++
 ....11.patch => trac-33842-python-3.11.patch} |   0
 ...3d67cfcdf8fba7bc6aa7899e2086d42cc7e.patch} |   0
 ...ch => trac-34537-sagemath-pari-2.15.patch} |   0
 ...h => trac-34537-sagemath-pari-2.15b.patch} |   0
 ...0de0dca1cff0355326dd42bd8c7e5749568.patch} |   0
 srcpkgs/sagemath/template                     |  29 +-
 8 files changed, 451 insertions(+), 6 deletions(-)
 create mode 100644 srcpkgs/sagemath/patches/trac-33446-make_GAP_SO_unnecessary-31e3fc4ec8b8687bccd22d2e3161c86cf5553e06.patch
 rename srcpkgs/sagemath/patches/{python-3.11.patch => trac-33842-python-3.11.patch} (100%)
 rename srcpkgs/sagemath/patches/{trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch => trac-34391-upgrade_gap_4.12-a6c293d67cfcdf8fba7bc6aa7899e2086d42cc7e.patch} (100%)
 rename srcpkgs/sagemath/patches/{sagemath-pari-2.15.patch => trac-34537-sagemath-pari-2.15.patch} (100%)
 rename srcpkgs/sagemath/patches/{sagemath-pari-2.15b.patch => trac-34537-sagemath-pari-2.15b.patch} (100%)
 rename srcpkgs/sagemath/patches/{matplotlib-3.6.patch => trac-34668-matplotlib_3.6-5501e0de0dca1cff0355326dd42bd8c7e5749568.patch} (100%)

diff --git a/srcpkgs/sagemath/files/sage_conf.py b/srcpkgs/sagemath/files/sage_conf.py
index 85ec37dfb50e..cd4b6b6f95b4 100644
--- a/srcpkgs/sagemath/files/sage_conf.py
+++ b/srcpkgs/sagemath/files/sage_conf.py
@@ -1,3 +1,4 @@
 # configuration for sage on void linux
 SAGE_SHARE = "/usr/share/sagemath"
 GAP_ROOT_DIR = "/usr/share/gap"
+#GAP_SO = "/usr/lib/libgap.so.8"
diff --git a/srcpkgs/sagemath/patches/trac-33446-make_GAP_SO_unnecessary-31e3fc4ec8b8687bccd22d2e3161c86cf5553e06.patch b/srcpkgs/sagemath/patches/trac-33446-make_GAP_SO_unnecessary-31e3fc4ec8b8687bccd22d2e3161c86cf5553e06.patch
new file mode 100644
index 000000000000..fb9e0f5a8071
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-33446-make_GAP_SO_unnecessary-31e3fc4ec8b8687bccd22d2e3161c86cf5553e06.patch
@@ -0,0 +1,427 @@
+From 9feec282d039ca25bbefa50710f8217b775ce111 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Thu, 3 Mar 2022 14:47:00 -0300
+Subject: gap: do not directly dlopen() the gap library
+
+This needs the soname (as in sage.env.GAP_SO) which has issues for
+system gap as explained in #33446.
+
+Instead we dlopen() the extension module sage.libs.gap.util which,
+having a link time dependency to libgap, will indirectly dlopen() it.
+
+For the record: by the time we run dlopen() the libgap should be already
+loaded. The purpose of doing it is to change mode to RTLD_GLOBAL so that
+symbols in libgap are placed in the global symbol table. This is
+required to compiled load gap packages.
+
+An easy test that this is working ok is:
+
+    sage: libgap.LoadPackage("io")
+    true
+
+This requires optional spkg `gap_packages` to be installed.
+---
+ src/sage/libs/gap/util.pyx | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/src/sage/libs/gap/util.pyx b/src/sage/libs/gap/util.pyx
+index 344ab88..aff604b 100644
+--- a/src/sage/libs/gap/util.pyx
++++ b/src/sage/libs/gap/util.pyx
+@@ -13,7 +13,7 @@ Utility functions for GAP
+ #*****************************************************************************
+ 
+ from libc.signal cimport signal, SIGCHLD, SIG_DFL
+-from posix.dlfcn cimport dlopen, dlclose, RTLD_NOW, RTLD_GLOBAL
++from posix.dlfcn cimport dlopen, dlclose, dlerror, RTLD_LAZY, RTLD_GLOBAL
+ 
+ from cpython.exc cimport PyErr_Fetch, PyErr_Restore
+ from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE
+@@ -232,12 +232,12 @@ cdef initialize():
+     # this isn't portable
+ 
+     cdef void* handle
+-    libgapname = str_to_bytes(sage.env.GAP_SO)
+-    handle = dlopen(libgapname, RTLD_NOW | RTLD_GLOBAL)
++    # reload the current module to force reload of libgap (see #33446)
++    lib = str_to_bytes(__loader__.path, FS_ENCODING, "surrogateescape")
++    handle = dlopen(lib, RTLD_GLOBAL|RTLD_LAZY)
+     if handle is NULL:
+-        raise RuntimeError(
+-                "Could not dlopen() libgap even though it should already "
+-                "be loaded!")
++        err = dlerror()
++        raise RuntimeError(f"Could not reload gap library with RTLD_GLOBAL ({err})")
+     dlclose(handle)
+ 
+     # Define argv variable, which we will pass in to
+-- 
+cgit v1.0-1-gd88e
+
+
+From 704a7953b97ab726e2af610724726aa562bc8bf8 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Thu, 3 Mar 2022 23:00:07 -0300
+Subject: singular: do not directly dlopen() the singular library
+
+Same as for gap in the previous commit. Instead of requiring the soname
+(as in sage.env.LIBSINGULAR_PATH) we dlopen() the extension module
+sage.libs.singular.singular which will indirectly dlopen() libSingular.
+---
+ src/sage/libs/singular/singular.pyx | 15 ++++-----------
+ 1 file changed, 4 insertions(+), 11 deletions(-)
+
+diff --git a/src/sage/libs/singular/singular.pyx b/src/sage/libs/singular/singular.pyx
+index d8ea7b0..4beb177 100644
+--- a/src/sage/libs/singular/singular.pyx
++++ b/src/sage/libs/singular/singular.pyx
+@@ -1705,14 +1705,7 @@ cdef object si2sa_intvec(intvec *v):
+ cdef extern from *: # hack to get at cython macro
+     int unlikely(int)
+ 
+-cdef extern from "dlfcn.h":
+-    void *dlopen(char *, long)
+-    char *dlerror()
+-    void dlclose(void *handle)
+-
+-cdef extern from "dlfcn.h":
+-    cdef long RTLD_LAZY
+-    cdef long RTLD_GLOBAL
++from posix.dlfcn cimport dlopen, dlclose, dlerror, RTLD_LAZY, RTLD_GLOBAL
+ 
+ cdef int overflow_check(unsigned long e, ring *_ring) except -1:
+     """
+@@ -1762,8 +1755,6 @@ cdef init_libsingular():
+ 
+     cdef void *handle = NULL
+ 
+-    from sage.env import LIBSINGULAR_PATH
+-    lib = str_to_bytes(LIBSINGULAR_PATH, FS_ENCODING, "surrogateescape")
+ 
+     # This is a workaround for https://github.com/Singular/Singular/issues/1113
+     # and can be removed once that fix makes it into release of Singular that
+@@ -1780,10 +1771,12 @@ cdef init_libsingular():
+ 
+     import platform
+     if not platform.system().startswith("CYGWIN"):
++        # reload the current module to force reload of libSingular (see #33446)
++        lib = str_to_bytes(__loader__.path, FS_ENCODING, "surrogateescape")
+         handle = dlopen(lib, RTLD_GLOBAL|RTLD_LAZY)
+         if not handle:
+             err = dlerror()
+-            raise ImportError(f"cannot load Singular library from {LIBSINGULAR_PATH} ({err})")
++            raise RuntimeError(f"Could not reload Singular library with RTLD_GLOBAL ({err})")
+ 
+     # load SINGULAR
+     siInit(lib)
+-- 
+cgit v1.0-1-gd88e
+
+
+From d7145c14ef58acfbe00d8f941d2802e96ad4ba15 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Fri, 4 Mar 2022 16:37:34 -0300
+Subject: singular: remove LIBSINGULAR_PATH, no longer needed
+
+---
+ build/pkgs/singular/spkg-configure.m4 | 63 +----------------------------------
+ pkgs/sage-conf/_sage_conf/_conf.py.in |  3 --
+ src/sage/env.py                       |  6 ----
+ 3 files changed, 1 insertion(+), 71 deletions(-)
+
+diff --git a/build/pkgs/singular/spkg-configure.m4 b/build/pkgs/singular/spkg-configure.m4
+index af2eb85..6d3d3da 100644
+--- a/build/pkgs/singular/spkg-configure.m4
++++ b/build/pkgs/singular/spkg-configure.m4
+@@ -9,52 +9,7 @@ SAGE_SPKG_CONFIGURE([singular], [
+        AC_MSG_CHECKING([that Singular's help is working])
+        AS_IF([test x`printf "system(\"--browser\", \"builtin\"); \n help;" | Singular 2>&1 | grep "error\ occurred"` = x], [
+         AC_MSG_RESULT(yes)
+-        dnl We have Singular. Now determine the shared library path on
+-        dnl platforms on which sage.libs.singular needs to reload the library with RTLD_GLOBAL.
+-        AS_CASE([$host_os],
+-          [cygwin*], [dnl Nothing to do
+-                     ],
+-                     [dnl Use pkg-config to get singular's libdir while we're at it. As a
+-                      dnl moral compromise for using pkg-config, this ultimately allows us
+-                      dnl to pass an absolute path to dlopen(), which is the only approach
+-                      dnl that POSIX guarantees will work.
+-                      PKG_CHECK_VAR([SINGULAR_LIB_DIR], [Singular], [libdir])
+-                      dnl The acl_shlibext variable is set in the top-level configure.ac.
+-                      AC_LANG_PUSH(C)
+-                      ORIG_LIBS="${LIBS}"
+-                      LIBS="${LIBS} -ldl"
+-                      AC_MSG_CHECKING([if we can dlopen($LIBSINGULAR_PATH)])
+-                      LIBSINGULAR_PATH="${SINGULAR_LIB_DIR}/libSingular.${acl_shlibext}"
+-
+-                      dnl if we can dlopen() it, substitute the name for sage_conf;
+-                      dnl otherwise, fall back to using the SPKG.
+-                      AC_RUN_IFELSE(
+-                        [AC_LANG_PROGRAM(
+-                          [[#include <dlfcn.h>]],
+-                          [[void* h = dlopen("${LIBSINGULAR_PATH}", RTLD_LAZY | RTLD_GLOBAL);
+-                            if (h == 0) { return 1; } else { return dlclose(h); }]]
+-                        )], [
+-                          AC_MSG_RESULT(yes)
+-                        ], [
+-                          dnl try Debian-specific name
+-                          LIBSINGULAR_PATH="${SINGULAR_LIB_DIR}/libsingular-Singular.${acl_shlibext}"
+-                          AC_RUN_IFELSE(
+-                           [AC_LANG_PROGRAM(
+-                             [[#include <dlfcn.h>]],
+-                             [[void* h = dlopen("${LIBSINGULAR_PATH}", RTLD_LAZY | RTLD_GLOBAL);
+-                               if (h == 0) { return 1; } else { return dlclose(h); }]]
+-                           )], [
+-                             AC_MSG_RESULT(yes)
+-                           ], [
+-                            AC_MSG_RESULT(no)
+-                            sage_spkg_install_singular=yes
+-                          ], [AC_MSG_RESULT(yes)])
+-                        ], [AC_MSG_RESULT(yes)])
+-
+-                      AC_LANG_POP()
+-                      LIBS="${ORIG_LIBS}"
+-                     ]
+-       )], [
++       ], [
+        AC_MSG_RESULT(no)
+        sage_spkg_install_singular=yes
+        ]
+@@ -64,20 +19,4 @@ SAGE_SPKG_CONFIGURE([singular], [
+       ])
+     ])
+   ])
+-],[],[],[
+-  dnl Post-check phase
+-  dnl We make the sage_conf substitutions here, because the "default"
+-  dnl substitution needs to be made even if we skipped the system-Singular
+-  dnl checks themselves.
+-  AS_IF([test "x${sage_spkg_install_singular}" = "xyes"], [
+-    AS_CASE([$host_os],
+-      [cygwin*], [dnl Nothing to do
+-                 ],
+-                 [dnl Set shared library path, needed for reloading the library with RTLD_GLOBAL
+-                  LIBSINGULAR_PATH="\$SAGE_LOCAL/lib/libSingular.${acl_shlibext}"
+-                 ]
+-    )
+-  ])
+-
+-  AC_SUBST(LIBSINGULAR_PATH, "${LIBSINGULAR_PATH}")
+ ])
+diff --git a/pkgs/sage-conf/_sage_conf/_conf.py.in b/pkgs/sage-conf/_sage_conf/_conf.py.in
+index 6cd28f5..d66bdb3 100644
+--- a/pkgs/sage-conf/_sage_conf/_conf.py.in
++++ b/pkgs/sage-conf/_sage_conf/_conf.py.in
+@@ -55,9 +55,6 @@ THREEJS_DIR = SAGE_LOCAL + "/share/threejs-sage"
+ OPENMP_CFLAGS = "@OPENMP_CFLAGS@"
+ OPENMP_CXXFLAGS = "@OPENMP_CXXFLAGS@"
+ 
+-# The full absolute path to the main Singular library.
+-LIBSINGULAR_PATH = "@LIBSINGULAR_PATH@".replace('$SAGE_LOCAL', SAGE_LOCAL)
+-
+ # Installation location of wheels. This is determined at configuration time
+ # and does not depend on the installation location of sage-conf.
+ SAGE_SPKG_WHEELS = "@SAGE_VENV@".replace('${SAGE_LOCAL}', SAGE_LOCAL) + "/var/lib/sage/wheels"
+diff --git a/src/sage/env.py b/src/sage/env.py
+index 911f34b..93f79de 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -229,12 +229,6 @@ NTL_LIBDIR = var("NTL_LIBDIR")
+ LIE_INFO_DIR = var("LIE_INFO_DIR", join(SAGE_LOCAL, "lib", "LiE"))
+ SINGULAR_BIN = var("SINGULAR_BIN") or "Singular"
+ 
+-# The path to libSingular, to be passed to dlopen(). This will
+-# typically be set to an absolute path in sage_conf, but the relative
+-# fallback path here works on systems where dlopen() searches the
+-# system's library locations.
+-LIBSINGULAR_PATH = var("LIBSINGULAR_PATH", "libSingular.so")
+-
+ # OpenMP
+ OPENMP_CFLAGS = var("OPENMP_CFLAGS", "")
+ OPENMP_CXXFLAGS = var("OPENMP_CXXFLAGS", "")
+-- 
+cgit v1.0-1-gd88e
+
+
+From 92e5a211c792f86f5325d601abfddf667da6a776 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Fri, 4 Mar 2022 15:49:26 -0300
+Subject: Revert "src/sage/interfaces/gap_workspace.py: Use hash of GAP_SO to
+ disambiguate the workspace file, not SAGE_LOCAL"
+
+This reverts commit a801e6d85bd420b60ea75b1671856eb43ac6b18b.
+
+See #33446.
+---
+ src/sage/interfaces/gap_workspace.py | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+diff --git a/src/sage/interfaces/gap_workspace.py b/src/sage/interfaces/gap_workspace.py
+index 33a87dd..953dc85 100644
+--- a/src/sage/interfaces/gap_workspace.py
++++ b/src/sage/interfaces/gap_workspace.py
+@@ -16,7 +16,7 @@ Support for (lib)GAP workspace files
+ import os
+ import time
+ import hashlib
+-from sage.env import DOT_SAGE, GAP_SO
++from sage.env import DOT_SAGE, SAGE_LOCAL
+ 
+ 
+ def gap_workspace_file(system="gap", name="workspace", dir=None):
+@@ -59,10 +59,7 @@ def gap_workspace_file(system="gap", name="workspace", dir=None):
+     if dir is None:
+         dir = os.path.join(DOT_SAGE, 'gap')
+ 
+-    if GAP_SO:
+-        h = hashlib.sha1(GAP_SO.encode('utf-8')).hexdigest()
+-    else:
+-        h = 'unknown'
++    h = hashlib.sha1(SAGE_LOCAL.encode('utf-8')).hexdigest()
+     return os.path.join(dir, '%s-%s-%s' % (system, name, h))
+ 
+ 
+-- 
+cgit v1.0-1-gd88e
+
+
+From b45e555b5711ae10d369b568333940c2aa771053 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Fri, 4 Mar 2022 16:38:49 -0300
+Subject: gap: remove GAP_SO, no longer needed
+
+---
+ src/sage/env.py | 75 ---------------------------------------------------------
+ 1 file changed, 75 deletions(-)
+
+diff --git a/src/sage/env.py b/src/sage/env.py
+index 93f79de..c16a094 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -249,81 +249,6 @@ if SAGE_GAP_MEMORY is not None:
+ SAGE_GAP_COMMAND = var('SAGE_GAP_COMMAND', _gap_cmd)
+ 
+ 
+-def _get_shared_lib_path(*libnames: str) -> Optional[str]:
+-    """
+-    Return the full path to a shared library file installed in
+-    ``$SAGE_LOCAL/lib`` or the directories associated with the
+-    Python sysconfig.
+-
+-    This can also be passed more than one library name (e.g. for cases where
+-    some library may have multiple names depending on the platform) in which
+-    case the first one found is returned.
+-
+-    This supports most *NIX variants (in which ``lib<libname>.so`` is found
+-    under ``$SAGE_LOCAL/lib``), macOS (same, but with the ``.dylib``
+-    extension), and Cygwin (under ``$SAGE_LOCAL/bin/cyg<libname>.dll``,
+-    or ``$SAGE_LOCAL/bin/cyg<libname>-*.dll`` for versioned DLLs).
+-
+-    For distributions like Debian that use a multiarch layout, we also try the
+-    multiarch lib paths (i.e. ``/usr/lib/<arch>/``).
+-
+-    This returns ``None`` if no matching library file could be found.
+-
+-    EXAMPLES::
+-
+-        sage: from sage.env import _get_shared_lib_path
+-        sage: "gap" in _get_shared_lib_path("gap")
+-        True
+-        sage: _get_shared_lib_path("an_absurd_lib") is None
+-        True
+-
+-    """
+-
+-    for libname in libnames:
+-        search_directories: List[Path] = []
+-        patterns: List[str] = []
+-        if sys.platform == 'cygwin':
+-            # Later down we take the first matching DLL found, so search
+-            # SAGE_LOCAL first so that it takes precedence
+-            if SAGE_LOCAL:
+-                search_directories.append(Path(SAGE_LOCAL) / 'bin')
+-            search_directories.append(Path(sysconfig.get_config_var('BINDIR')))
+-            # Note: The following is not very robust, since if there are multible
+-            # versions for the same library this just selects one more or less
+-            # at arbitrary. However, practically speaking, on Cygwin, there
+-            # will only ever be one version
+-            patterns = [f'cyg{libname}.dll', f'cyg{libname}-*.dll']
+-        else:
+-            if sys.platform == 'darwin':
+-                ext = 'dylib'
+-            else:
+-                ext = 'so'
+-
+-            if SAGE_LOCAL:
+-                search_directories.append(Path(SAGE_LOCAL) / 'lib')
+-            libdir = sysconfig.get_config_var('LIBDIR')
+-            if libdir is not None:
+-                libdir = Path(libdir)
+-                search_directories.append(libdir)
+-
+-                multiarchlib = sysconfig.get_config_var('MULTIARCH')
+-                if multiarchlib is not None:
+-                    search_directories.append(libdir / multiarchlib),
+-
+-            patterns = [f'lib{libname}.{ext}']
+-
+-        for directory in search_directories:
+-            for pattern in patterns:
+-                path = next(directory.glob(pattern), None)
+-                if path is not None:
+-                    return str(path.resolve())
+-
+-    # Just return None if no files were found
+-    return None
+-
+-# locate libgap shared object
+-GAP_SO = var("GAP_SO", _get_shared_lib_path("gap", ""))
+-
+ # post process
+ if DOT_SAGE is not None and ' ' in DOT_SAGE:
+     if UNAME[:6] == 'CYGWIN':
+-- 
+cgit v1.0-1-gd88e
+
+
+From 31e3fc4ec8b8687bccd22d2e3161c86cf5553e06 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Sun, 6 Mar 2022 12:10:37 -0300
+Subject: gap_workspace_file: include hostname and gap version
+
+---
+ src/sage/interfaces/gap_workspace.py | 11 ++++++++---
+ 1 file changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/src/sage/interfaces/gap_workspace.py b/src/sage/interfaces/gap_workspace.py
+index 953dc85..8c03b6b 100644
+--- a/src/sage/interfaces/gap_workspace.py
++++ b/src/sage/interfaces/gap_workspace.py
+@@ -16,7 +16,8 @@ Support for (lib)GAP workspace files
+ import os
+ import time
+ import hashlib
+-from sage.env import DOT_SAGE, SAGE_LOCAL
++import subprocess
++from sage.env import DOT_SAGE, SAGE_LOCAL, HOSTNAME, GAP_ROOT_DIR
+ 
+ 
+ def gap_workspace_file(system="gap", name="workspace", dir=None):
+@@ -59,8 +60,12 @@ def gap_workspace_file(system="gap", name="workspace", dir=None):
+     if dir is None:
+         dir = os.path.join(DOT_SAGE, 'gap')
+ 
+-    h = hashlib.sha1(SAGE_LOCAL.encode('utf-8')).hexdigest()
+-    return os.path.join(dir, '%s-%s-%s' % (system, name, h))
++    data = SAGE_LOCAL
++    sysinfo = os.path.join(GAP_ROOT_DIR, "sysinfo.gap")
++    if os.path.exists(sysinfo):
++        data += subprocess.getoutput(f'. "{sysinfo}" && echo ":$GAP_VERSION:$GAParch"')
++    h = hashlib.sha1(data.encode('utf-8')).hexdigest()
++    return os.path.join(dir, '%s-%s-%s-%s' % (system, name, HOSTNAME, h))
+ 
+ 
+ def prepare_workspace_dir(dir=None):
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/python-3.11.patch b/srcpkgs/sagemath/patches/trac-33842-python-3.11.patch
similarity index 100%
rename from srcpkgs/sagemath/patches/python-3.11.patch
rename to srcpkgs/sagemath/patches/trac-33842-python-3.11.patch
diff --git a/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch b/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-a6c293d67cfcdf8fba7bc6aa7899e2086d42cc7e.patch
similarity index 100%
rename from srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-c25375f90d3bfd36758cb0e9d1ccbcd72f32d496.patch
rename to srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-a6c293d67cfcdf8fba7bc6aa7899e2086d42cc7e.patch
diff --git a/srcpkgs/sagemath/patches/sagemath-pari-2.15.patch b/srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15.patch
similarity index 100%
rename from srcpkgs/sagemath/patches/sagemath-pari-2.15.patch
rename to srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15.patch
diff --git a/srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch b/srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15b.patch
similarity index 100%
rename from srcpkgs/sagemath/patches/sagemath-pari-2.15b.patch
rename to srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15b.patch
diff --git a/srcpkgs/sagemath/patches/matplotlib-3.6.patch b/srcpkgs/sagemath/patches/trac-34668-matplotlib_3.6-5501e0de0dca1cff0355326dd42bd8c7e5749568.patch
similarity index 100%
rename from srcpkgs/sagemath/patches/matplotlib-3.6.patch
rename to srcpkgs/sagemath/patches/trac-34668-matplotlib_3.6-5501e0de0dca1cff0355326dd42bd8c7e5749568.patch
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 51d8067a7d3c..1872c2711b1e 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -37,8 +37,10 @@ checksum=9f26f14aa322e3cf38a71835b12ac34b23026b467f74d54b064c5d025e76fbfd
 
 do_configure() {
 	# git tree needs bootstrapping
-	(cd "$wrksrc/build/pkgs/sagelib" &&
-	 PATH=../../bin:$PATH BOOTSTRAP_QUIET=no ./bootstrap)
+	( cd "$wrksrc/build/pkgs/sagelib" &&
+	  PATH=../../bin:$PATH \
+	  BOOTSTRAP_QUIET=no \
+	  ./bootstrap )
 }
 
 pre_build() {
@@ -48,13 +50,26 @@ pre_build() {
 }
 
 post_build() {
-	_lib=$(cd build/lib* && pwd)
+	_libs=$(cd build/lib* && pwd)
 	_scripts=$(cd build/scripts* && pwd)
+
 	# remove sage-venv-config since it clobbers PATH
 	rm "$_scripts/sage-venv-config"
-	# configuration files
-	cp "${FILESDIR}/sage-env-config" "$_scripts"
-	cp "${FILESDIR}/sage_conf.py" "$_lib"
+
+	# sage-env configuration (bash)
+	cat >> "$_scripts/sage-env-config" <<-'EOF'
+	# configure PATH using sage script location
+	PATH=$(dirname $SELF):$PATH
+	#export PYTHONPATH="$(cd $(dirname $SELF)/../lib/python*/site-packages/ && pwd):$PYTHONPATH"
+	EOF
+
+	# sage.env configuration (python)
+	cat >> "$_libs/sage_conf.py" <<-'EOF'
+	# configuration for sage on void linux
+	SAGE_SHARE = "/usr/share/sagemath"
+	GAP_ROOT_DIR = "/usr/share/gap"
+	#GAP_SO = "/usr/lib/libgap.so.8"
+	EOF
 }
 
 pre_install() {
@@ -67,12 +82,14 @@ post_install() {
 	# fix jupyter kernel spec
 	vsed -i -e 's|"/usr/bin/sage"|"'"$_bindir"'/sage"|' \
 		${DESTDIR}/usr/share/jupyter/kernels/sagemath/kernel.json
+
 	# replace broken symlinks by good copies (sagemath logo images)
 	for file in $(ls sage/ext_data/notebook-ipython); do
 		rm ${DESTDIR}/usr/share/jupyter/kernels/sagemath/$file
 		cp -a sage/ext_data/notebook-ipython/$file \
 			${DESTDIR}/usr/share/jupyter/kernels/sagemath
 	done
+
 	# we don't have docs here
 	rm ${DESTDIR}/usr/share/jupyter/kernels/sagemath/doc
 	# this symlink is shipped in threejs-sage pkg

From 225c89c6351ca20bcbf7ced618337199fc4f591d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 17 Oct 2022 01:44:09 -0300
Subject: [PATCH 15/21] sagemath: more fixes

---
 srcpkgs/sagemath/template | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 1872c2711b1e..3a92f583fecb 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -53,14 +53,15 @@ post_build() {
 	_libs=$(cd build/lib* && pwd)
 	_scripts=$(cd build/scripts* && pwd)
 
-	# remove sage-venv-config since it clobbers PATH
-	rm "$_scripts/sage-venv-config"
-
 	# sage-env configuration (bash)
 	cat >> "$_scripts/sage-env-config" <<-'EOF'
 	# configure PATH using sage script location
 	PATH=$(dirname $SELF):$PATH
 	#export PYTHONPATH="$(cd $(dirname $SELF)/../lib/python*/site-packages/ && pwd):$PYTHONPATH"
+
+	# if SAGE_VENV is set, the script sage-env will prepend
+	# "$SAGE_VENV/bin" to the PATH, which is undesired
+	unset SAGE_VENV
 	EOF
 
 	# sage.env configuration (python)
@@ -68,7 +69,6 @@ post_build() {
 	# configuration for sage on void linux
 	SAGE_SHARE = "/usr/share/sagemath"
 	GAP_ROOT_DIR = "/usr/share/gap"
-	#GAP_SO = "/usr/lib/libgap.so.8"
 	EOF
 }
 

From 01817d04eaed32a87d419dc69361074b948252f2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 17 Oct 2022 19:30:41 -0300
Subject: [PATCH 16/21] sagemath: fix some timings

---
 srcpkgs/sagemath/files/timings2.json | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/sagemath/files/timings2.json b/srcpkgs/sagemath/files/timings2.json
index 01b2fcc9e0bf..bb3098680502 100644
--- a/srcpkgs/sagemath/files/timings2.json
+++ b/srcpkgs/sagemath/files/timings2.json
@@ -109,7 +109,7 @@
   "sage.combinat.symmetric_group_algebra": {"walltime": 16},
   "sage.combinat.tableau": {"walltime": 32},
   "sage.combinat.tableau_tuple": {"walltime": 32},
-  "sage.combinat.tiling": {"walltime": 256},
+  "sage.combinat.tiling": {"walltime": 16},
   "sage.combinat.tutorial": {"walltime": 16},
   "sage.combinat.words.paths": {"walltime": 64},
   "sage.crypto.block_cipher.des": {"walltime": 16},
@@ -193,10 +193,10 @@
   "sage.manifolds.differentiable.automorphismfield": {"walltime": 32},
   "sage.manifolds.differentiable.automorphismfield_group": {"walltime": 8},
   "sage.manifolds.differentiable.bundle_connection": {"walltime": 8},
-  "sage.manifolds.differentiable.characteristic_cohomology_class": {"walltime": 256},
+  "sage.manifolds.differentiable.characteristic_cohomology_class": {"walltime": 64},
   "sage.manifolds.differentiable.curve": {"walltime": 16},
   "sage.manifolds.differentiable.degenerate": {"walltime": 32},
-  "sage.manifolds.differentiable.degenerate_submanifold": {"walltime": 256},
+  "sage.manifolds.differentiable.degenerate_submanifold": {"walltime": 16},
   "sage.manifolds.differentiable.diff_form": {"walltime": 64},
   "sage.manifolds.differentiable.diff_map": {"walltime": 8},
   "sage.manifolds.differentiable.examples.euclidean": {"walltime": 32},
@@ -270,7 +270,7 @@
   "sage.modules.free_quadratic_module_integer_symmetric": {"walltime": 8},
   "sage.modules.torsion_quadratic_module": {"walltime": 16},
   "sage.parallel.map_reduce": {"walltime": 8},
-  "sage.plot.animate": {"walltime": 128},
+  "sage.plot.animate": {"walltime": 16},
   "sage.plot.arrow": {"walltime": 8},
   "sage.plot.circle": {"walltime": 8},
   "sage.plot.complex_plot": {"walltime": 8},
@@ -308,7 +308,7 @@
   "sage.rings.function_field.function_field_valuation": {"walltime": 64},
   "sage.rings.function_field.ideal": {"walltime": 8},
   "sage.rings.function_field.place": {"walltime": 8},
-  "sage.rings.integer": {"walltime": 128},
+  "sage.rings.integer": {"walltime": 64},
   "sage.rings.invariants.invariant_theory": {"walltime": 8},
   "sage.rings.number_field.bdd_height": {"walltime": 8},
   "sage.rings.number_field.number_field": {"walltime": 64},

From 4f1155d25945de2b90317dffb18789f145c8d505 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 17 Oct 2022 20:42:24 -0300
Subject: [PATCH 17/21] sagemath: fix variables

---
 srcpkgs/sagemath/template | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 3a92f583fecb..1a36fb9a9638 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -50,9 +50,16 @@ pre_build() {
 }
 
 post_build() {
-	_libs=$(cd build/lib* && pwd)
+	_lib=$(cd build/lib* && pwd)
 	_scripts=$(cd build/scripts* && pwd)
 
+	# sage.env configuration (python)
+	cat >> "$_lib/sage_conf.py" <<-'EOF'
+	# configuration for sage on void linux
+	SAGE_SHARE = "/usr/share/sagemath"
+	GAP_ROOT_DIR = "/usr/share/gap"
+	EOF
+
 	# sage-env configuration (bash)
 	cat >> "$_scripts/sage-env-config" <<-'EOF'
 	# configure PATH using sage script location
@@ -63,13 +70,6 @@ post_build() {
 	# "$SAGE_VENV/bin" to the PATH, which is undesired
 	unset SAGE_VENV
 	EOF
-
-	# sage.env configuration (python)
-	cat >> "$_libs/sage_conf.py" <<-'EOF'
-	# configuration for sage on void linux
-	SAGE_SHARE = "/usr/share/sagemath"
-	GAP_ROOT_DIR = "/usr/share/gap"
-	EOF
 }
 
 pre_install() {
@@ -102,8 +102,10 @@ post_install() {
 }
 
 do_check() {
+	_lib=$(cd build/lib* && pwd)
 	_scripts=$(cd build/scripts* && pwd)
-	export PYTHONPATH=$(cd build/lib* && pwd)
+
+	export PYTHONPATH="$_lib"
 	export PYTHONDONTWRITEBYTECODE=yes
 
 	# get out of $build_wrksrc, otherwise python picks the wrong sage module

From 2466d51ba55d30ea49918cbae009327d280298cf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Sat, 22 Oct 2022 11:54:52 -0300
Subject: [PATCH 18/21] sagemath: place all in /usr/lib/sagemath

---
 srcpkgs/sagemath/template | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 1a36fb9a9638..857ae041718a 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -5,8 +5,8 @@ revision=1
 wrksrc=sage-$version
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
-_bindir=/usr/lib/sagemath/${version}/bin
-make_install_args="--install-scripts=$_bindir"
+_prefix=/usr/lib/sagemath/$version
+make_install_args="--prefix=$_prefix"
 hostmakedepends="m4 pkg-config python3-Cython python3-Jinja2 python3-pkgconfig
  python3-setuptools"
 makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
@@ -54,17 +54,17 @@ post_build() {
 	_scripts=$(cd build/scripts* && pwd)
 
 	# sage.env configuration (python)
-	cat >> "$_lib/sage_conf.py" <<-'EOF'
+	cat > "$_lib/sage_conf.py" <<-'EOF'
 	# configuration for sage on void linux
 	SAGE_SHARE = "/usr/share/sagemath"
 	GAP_ROOT_DIR = "/usr/share/gap"
 	EOF
 
 	# sage-env configuration (bash)
-	cat >> "$_scripts/sage-env-config" <<-'EOF'
+	cat > "$_scripts/sage-env-config" <<-'EOF'
 	# configure PATH using sage script location
-	PATH=$(dirname $SELF):$PATH
-	#export PYTHONPATH="$(cd $(dirname $SELF)/../lib/python*/site-packages/ && pwd):$PYTHONPATH"
+	export PATH=$(dirname $SELF):$PATH
+	export PYTHONPATH="$(cd $(dirname $SELF)/../lib/python*/site-packages/ && pwd):$PYTHONPATH"
 
 	# if SAGE_VENV is set, the script sage-env will prepend
 	# "$SAGE_VENV/bin" to the PATH, which is undesired
@@ -80,24 +80,24 @@ pre_install() {
 
 post_install() {
 	# fix jupyter kernel spec
-	vsed -i -e 's|"/usr/bin/sage"|"'"$_bindir"'/sage"|' \
-		${DESTDIR}/usr/share/jupyter/kernels/sagemath/kernel.json
+	vsed -i -e 's|"/usr/bin/sage"|"'"${_prefix}"'/bin/sage"|' \
+		${DESTDIR}${_prefix}/share/jupyter/kernels/sagemath/kernel.json
 
 	# replace broken symlinks by good copies (sagemath logo images)
 	for file in $(ls sage/ext_data/notebook-ipython); do
-		rm ${DESTDIR}/usr/share/jupyter/kernels/sagemath/$file
+		rm ${DESTDIR}${_prefix}/share/jupyter/kernels/sagemath/$file
 		cp -a sage/ext_data/notebook-ipython/$file \
-			${DESTDIR}/usr/share/jupyter/kernels/sagemath
+			${DESTDIR}${_prefix}/share/jupyter/kernels/sagemath
 	done
 
 	# we don't have docs here
-	rm ${DESTDIR}/usr/share/jupyter/kernels/sagemath/doc
+	rm ${DESTDIR}${_prefix}/share/jupyter/kernels/sagemath/doc
 	# this symlink is shipped in threejs-sage pkg
-	rm ${DESTDIR}/usr/share/jupyter/nbextensions/threejs-sage
+	rm ${DESTDIR}${_prefix}/share/jupyter/nbextensions/threejs-sage
 
 	# symlink main binary
 	vmkdir usr/bin
-	ln -s $_bindir/sage ${DESTDIR}/usr/bin/sage-${version}
+	ln -s $_prefix/bin/sage ${DESTDIR}/usr/bin/sage-${version}
 	ln -s sage-${version} ${DESTDIR}/usr/bin/sage
 }
 
@@ -112,7 +112,7 @@ do_check() {
 	cd $(mktemp -dp build)
 
 	if [ -f ${XBPS_DISTDIR}/sagemath-check ] ; then
-		_sed='s|#.*||;/^\s*$/d;s|[^ ]*/sage/|'$PYTHONPATH'/sage/|g' \
+		_sed='s|#.*||;/^\s*$/d;s|[^ ]*/sage/|'$_lib'/sage/|g' \
 		_test_files=$(sed -e "$_sed" ${XBPS_DISTDIR}/sagemath-check)
 	fi
 	if [ -z "$_test_files" ]; then

From 029d32b014d100a7079d99f7bda728962cddaac3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Sat, 22 Oct 2022 11:55:40 -0300
Subject: [PATCH 19/21] sagemath: temporary, print pkg contents

---
 srcpkgs/sagemath/template | 48 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 857ae041718a..264b0b68f5b2 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -70,6 +70,26 @@ post_build() {
 	# "$SAGE_VENV/bin" to the PATH, which is undesired
 	unset SAGE_VENV
 	EOF
+
+	echo
+	echo "===== after build ====="
+	find build |
+		grep -v "^build/cythonized/sage/" |
+		grep -v "^build/lib.[^/]*/sage/" |
+		grep -v "^build/scripts.[^/]*/sage-" |
+		grep -v "^build/temp.[^/]*/sage/" |
+		grep -v "^build/temp.[^/]*/build/cythonized/sage/" |
+		grep -v "^${DESTDIR}${_prefix}/bin/"
+	echo "===== sage_conf.py ====="
+	cat build/lib*/sage_conf.py
+	echo "===== sage-env-config ====="
+	cat build/scripts*/sage-env-config
+	echo "========================="
+	#ls -l ${DESTDIR}${_prefix}/share/jupyter/nbextensions
+	#ls -l ${DESTDIR}${_prefix}/share/jupyter/kernels/sagemath
+	#cat ${DESTDIR}${_prefix}/share/jupyter/kernels/sagemath/kernel.json
+	#echo "========================="
+	echo
 }
 
 pre_install() {
@@ -79,6 +99,18 @@ pre_install() {
 }
 
 post_install() {
+	echo
+	echo "===== after install ====="
+	find $DESTDIR |
+		grep -v "^${DESTDIR}${_prefix}/lib/python3.10/site-packages/sage/" |
+		grep -v "^${DESTDIR}${_prefix}/bin/"
+	echo "========================="
+	ls -l ${DESTDIR}${_prefix}/share/jupyter/nbextensions
+	ls -l ${DESTDIR}${_prefix}/share/jupyter/kernels/sagemath
+	cat ${DESTDIR}${_prefix}/share/jupyter/kernels/sagemath/kernel.json
+	echo "========================="
+	echo
+
 	# fix jupyter kernel spec
 	vsed -i -e 's|"/usr/bin/sage"|"'"${_prefix}"'/bin/sage"|' \
 		${DESTDIR}${_prefix}/share/jupyter/kernels/sagemath/kernel.json
@@ -99,6 +131,22 @@ post_install() {
 	vmkdir usr/bin
 	ln -s $_prefix/bin/sage ${DESTDIR}/usr/bin/sage-${version}
 	ln -s sage-${version} ${DESTDIR}/usr/bin/sage
+
+	# symlink jupyter kernel
+	vmkdir usr/share/jupyter/kernels
+	ln -s $_prefix/share/jupyter/kernels/sagemath ${DESTDIR}/usr/share/jupyter/kernels/sagemath-${version}
+	ln -s sagemath-${version} ${DESTDIR}/usr/share/jupyter/kernels/sagemath
+
+	echo "===== after post-install ====="
+	find $DESTDIR |
+		grep -v "^${DESTDIR}${_prefix}/lib/python3.10/site-packages/sage/" |
+		grep -v "^${DESTDIR}${_prefix}/bin/"
+	echo "========================="
+	echo "<<< ${DESTDIR}{$_prefix}/share/jupyter/kernels/sagemath >>>"
+	ls -l ${DESTDIR}${_prefix}/share/jupyter/kernels/sagemath
+	echo "<<< ${DESTDIR}{$_prefix}/share/jupyter/kernels/sagemath/kernel.json >>>"
+	cat ${DESTDIR}${_prefix}/share/jupyter/kernels/sagemath/kernel.json
+	echo "=============================="
 }
 
 do_check() {

From bbe49cf372c634a844367905a2e68b47a7eda5a5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Sat, 22 Oct 2022 15:09:49 -0300
Subject: [PATCH 20/21] gap: update to 4.12.1.

---
 srcpkgs/gap/patches/c57a07a3.patch            | 23 -------------
 .../gap/patches/check-dont_use_network.patch  | 25 ++++++++++++++
 srcpkgs/gap/patches/dce6fa96.patch            | 24 -------------
 srcpkgs/gap/patches/fix-atlasrep.patch        | 11 ------
 srcpkgs/gap/template                          | 34 ++++++++++++++-----
 5 files changed, 51 insertions(+), 66 deletions(-)
 delete mode 100644 srcpkgs/gap/patches/c57a07a3.patch
 create mode 100644 srcpkgs/gap/patches/check-dont_use_network.patch
 delete mode 100644 srcpkgs/gap/patches/dce6fa96.patch
 delete mode 100644 srcpkgs/gap/patches/fix-atlasrep.patch

diff --git a/srcpkgs/gap/patches/c57a07a3.patch b/srcpkgs/gap/patches/c57a07a3.patch
deleted file mode 100644
index 27fd657666a6..000000000000
--- a/srcpkgs/gap/patches/c57a07a3.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From c57a07a341e7bb713e74d60c259777b1a8645451 Mon Sep 17 00:00:00 2001
-From: Max Horn <max@quendi.de>
-Date: Fri, 7 Oct 2022 01:31:45 +0200
-Subject: [PATCH] Don't attempt to install the 'dev' manual...
-
-... as it is not contained in release tarballs!
----
- Makefile.rules | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/Makefile.rules b/Makefile.rules
-index d9dc2899df..de1dbc4823 100644
---- a/Makefile.rules
-+++ b/Makefile.rules
-@@ -597,7 +597,7 @@ install-doc:
- 	# TODO: should this depend on the 'doc' target? but that target is phony
- 	# and will re-run each time it is invoked, which is not really what we want.
- 	$(INSTALL) -d -m 0755 $(DESTDIR)$(datarootdir)/gap/doc
--	for book in ref tut hpc dev ; do \
-+	for book in ref tut hpc ; do \
- 		$(INSTALL) -d -m 0755 $(DESTDIR)$(datarootdir)/gap/doc/$$book ; \
- 		for ext in css html js txt pdf six lab; do \
- 			$(INSTALL) -m 0644  $(srcdir)/doc/$$book/*.$$ext $(DESTDIR)$(datarootdir)/gap/doc/$$book/ ; \
diff --git a/srcpkgs/gap/patches/check-dont_use_network.patch b/srcpkgs/gap/patches/check-dont_use_network.patch
new file mode 100644
index 000000000000..a6263d0fd62e
--- /dev/null
+++ b/srcpkgs/gap/patches/check-dont_use_network.patch
@@ -0,0 +1,25 @@
+Configure AtlasRep so it does not access the network; otherwise
+warnings are printed and some tests fail.
+
+--- a/tst/testinstall.g	2022-10-20 16:53:39.000000000 -0300
++++ b/tst/testinstall.g	2022-10-22 15:43:02.598590437 -0300
+@@ -24,6 +24,8 @@
+ ##  <#/GAPDoc>
+ ##
+ 
++SetUserPreference("AtlasRep", "AtlasRepAccessRemoteFiles", false);
++
+ dirs := [
+   DirectoriesLibrary( "tst/testinstall" ),
+ ];
+--- a/tst/teststandard.g	2022-10-20 16:53:39.000000000 -0300
++++ b/tst/teststandard.g	2022-10-22 16:10:30.492052857 -0300
+@@ -16,6 +16,8 @@
+ ##  <#/GAPDoc>
+ ##
+ 
++SetUserPreference("AtlasRep", "AtlasRepAccessRemoteFiles", false);
++
+ dirs := [
+   DirectoriesLibrary( "tst/teststandard" ),
+   DirectoriesLibrary( "tst/testinstall" ),
diff --git a/srcpkgs/gap/patches/dce6fa96.patch b/srcpkgs/gap/patches/dce6fa96.patch
deleted file mode 100644
index bc29c0eaaeb1..000000000000
--- a/srcpkgs/gap/patches/dce6fa96.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-From dce6fa9637a3c61c3a891cc809371eaa67a589c6 Mon Sep 17 00:00:00 2001
-From: Max Horn <max@quendi.de>
-Date: Sun, 2 Oct 2022 23:31:03 +0200
-Subject: [PATCH] kernel: if no GC is selected, default to GASMAN
-
----
- src/common.h | 4 ++++
- 1 file changed, 4 insertions(+)
-
-diff --git a/src/common.h b/src/common.h
-index e7c10b8d0b..95e6f3d609 100644
---- a/src/common.h
-+++ b/src/common.h
-@@ -35,6 +35,10 @@
- // compiled with the wrong ABI
- GAP_STATIC_ASSERT(sizeof(void *) == SIZEOF_VOID_P, "sizeof(void *) is wrong");
- 
-+// if no GC is selected explicitly, default to GASMAN
-+#if !defined(USE_BOEHM_GC) && !defined(USE_JULIA_GC) && !defined(USE_GASMAN)
-+#define USE_GASMAN 1
-+#endif
- 
- // check for cygwin
- #if defined(__CYGWIN__) || defined(__CYGWIN32__)
diff --git a/srcpkgs/gap/patches/fix-atlasrep.patch b/srcpkgs/gap/patches/fix-atlasrep.patch
deleted file mode 100644
index ccb9ae587d4b..000000000000
--- a/srcpkgs/gap/patches/fix-atlasrep.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/pkg/atlasrep/gap/access.gi.orig	2022-08-05 19:11:16.000000000 -0300
-+++ b/pkg/atlasrep/gap/access.gi	2022-10-12 23:40:48.816642751 -0300
-@@ -3156,7 +3156,7 @@
-         uri:= url{ [ p .. Length( url ) ] };
-         body:= AtlasOfGroupRepresentationsTransferFile( domain, uri, fail,
-                                                         fail );
--        if body = fail then
-+        if body = false then
-           Info( InfoAtlasRep, 1,
-                 "AtlasOfGroupRepresentationsNotifyData:\n",
-                 "#I  cannot read '", url, "'" );
diff --git a/srcpkgs/gap/template b/srcpkgs/gap/template
index 88831e636c08..629b3a64b9b1 100644
--- a/srcpkgs/gap/template
+++ b/srcpkgs/gap/template
@@ -1,6 +1,6 @@
 # Template file for 'gap'
 pkgname=gap
-version=4.12.0
+version=4.12.1
 revision=1
 build_style=gnu-configure
 makedepends="gmp-devel zlib-devel readline-devel"
@@ -11,7 +11,7 @@ license="GPL-2.0-or-later"
 homepage="http://www.gap-system.org/"
 changelog="https://raw.githubusercontent.com/gap-system/gap/master/CHANGES.md"
 distfiles="https://github.com/gap-system/gap/releases/download/v${version}/gap-${version}.tar.gz"
-checksum=6005d0c0316fe8803d84681f30be64eace83a9542f975f5cb3dedfadd4391849
+checksum=f9ebef11ee31b210ce36e3c70960742b4e253282bbd5270adc9324273c92b016
 
 if [ "$XBPS_CHECK_PKGS" = full ]; then
 	# not sure about this -- takes about 25 minutes
@@ -21,18 +21,36 @@ fi
 _GAPROOT=/usr/share/gap/
 
 # minimal required packages
-_GAPPKGS="gapdoc primgrp smallgrp transgrp"
+_GAPPKGS="autodoc gapdoc primgrp smallgrp transgrp"
 
 # other expected packages
 _GAPPKGS+=" atlasrep autpgrp alnuth crisp ctbllib factint fga irredsol laguna
- polenta polycyclic resclasses sophus tomlib"
+ polenta polycyclic radiroot resclasses sophus tomlib utils"
 
-post_install() {
-	vmkdir ${_GAPROOT}/pkg
+post_extract() {
+	# keep around only the packages that we want to install
+	mkdir pkg.install
 	for p in ${_GAPPKGS}; do
-		[ -d pkg/$p ] || p="$p-*"
-		vcopy "pkg/$p" ${_GAPROOT}/pkg
+		mv "pkg/$p" pkg.install
 	done
+	mv pkg pkg.orig
+	mv pkg.install pkg
+}
+
+post_install() {
+	vmkdir ${_GAPROOT}
+	vcopy pkg ${_GAPROOT}
+}
+
+pre_check() {
+	msg_normal "Check that loading packages works\n"
+	for p in ${_GAPPKGS}; do
+		cat <<-EOF
+		if LoadPackage("$p") <> true then
+		    Error("loading package '$p'");
+		fi;
+		EOF
+	done | ./gap --quitonbreak -b -q -r
 }
 
 gap-devel_package() {

From 62258e23b8d599b0551acd8c77a1926511b4efef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Fri, 28 Oct 2022 23:28:37 -0300
Subject: [PATCH 21/21] sagemath: more fixes

---
 srcpkgs/sagemath/files/sage-env-config |  5 +-
 srcpkgs/sagemath/files/sage_conf.py    |  1 -
 srcpkgs/sagemath/template              | 87 ++++++--------------------
 3 files changed, 24 insertions(+), 69 deletions(-)

diff --git a/srcpkgs/sagemath/files/sage-env-config b/srcpkgs/sagemath/files/sage-env-config
index 7d2f97d92214..b84405301182 100644
--- a/srcpkgs/sagemath/files/sage-env-config
+++ b/srcpkgs/sagemath/files/sage-env-config
@@ -1,3 +1,6 @@
 # configure PATH using sage script location
 export PATH="$(dirname $SELF):$PATH"
-#export PYTHONPATH="$(cd $(dirname $SELF)/../lib/python*/site-packages/ && pwd):$PYTHONPATH"
+
+# if SAGE_VENV is set, the script sage-env will prepend
+# "$SAGE_VENV/bin" to the PATH, which is undesired
+unset SAGE_VENV
diff --git a/srcpkgs/sagemath/files/sage_conf.py b/srcpkgs/sagemath/files/sage_conf.py
index cd4b6b6f95b4..85ec37dfb50e 100644
--- a/srcpkgs/sagemath/files/sage_conf.py
+++ b/srcpkgs/sagemath/files/sage_conf.py
@@ -1,4 +1,3 @@
 # configuration for sage on void linux
 SAGE_SHARE = "/usr/share/sagemath"
 GAP_ROOT_DIR = "/usr/share/gap"
-#GAP_SO = "/usr/lib/libgap.so.8"
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 264b0b68f5b2..0bd777361e0d 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -6,6 +6,7 @@ wrksrc=sage-$version
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
 _prefix=/usr/lib/sagemath/$version
+_bindir=$_prefix/bin
 make_install_args="--prefix=$_prefix"
 hostmakedepends="m4 pkg-config python3-Cython python3-Jinja2 python3-pkgconfig
  python3-setuptools"
@@ -37,7 +38,7 @@ checksum=9f26f14aa322e3cf38a71835b12ac34b23026b467f74d54b064c5d025e76fbfd
 
 do_configure() {
 	# git tree needs bootstrapping
-	( cd "$wrksrc/build/pkgs/sagelib" &&
+	( cd $wrksrc/build/pkgs/sagelib &&
 	  PATH=../../bin:$PATH \
 	  BOOTSTRAP_QUIET=no \
 	  ./bootstrap )
@@ -53,43 +54,9 @@ post_build() {
 	_lib=$(cd build/lib* && pwd)
 	_scripts=$(cd build/scripts* && pwd)
 
-	# sage.env configuration (python)
-	cat > "$_lib/sage_conf.py" <<-'EOF'
-	# configuration for sage on void linux
-	SAGE_SHARE = "/usr/share/sagemath"
-	GAP_ROOT_DIR = "/usr/share/gap"
-	EOF
-
-	# sage-env configuration (bash)
-	cat > "$_scripts/sage-env-config" <<-'EOF'
-	# configure PATH using sage script location
-	export PATH=$(dirname $SELF):$PATH
-	export PYTHONPATH="$(cd $(dirname $SELF)/../lib/python*/site-packages/ && pwd):$PYTHONPATH"
-
-	# if SAGE_VENV is set, the script sage-env will prepend
-	# "$SAGE_VENV/bin" to the PATH, which is undesired
-	unset SAGE_VENV
-	EOF
-
-	echo
-	echo "===== after build ====="
-	find build |
-		grep -v "^build/cythonized/sage/" |
-		grep -v "^build/lib.[^/]*/sage/" |
-		grep -v "^build/scripts.[^/]*/sage-" |
-		grep -v "^build/temp.[^/]*/sage/" |
-		grep -v "^build/temp.[^/]*/build/cythonized/sage/" |
-		grep -v "^${DESTDIR}${_prefix}/bin/"
-	echo "===== sage_conf.py ====="
-	cat build/lib*/sage_conf.py
-	echo "===== sage-env-config ====="
-	cat build/scripts*/sage-env-config
-	echo "========================="
-	#ls -l ${DESTDIR}${_prefix}/share/jupyter/nbextensions
-	#ls -l ${DESTDIR}${_prefix}/share/jupyter/kernels/sagemath
-	#cat ${DESTDIR}${_prefix}/share/jupyter/kernels/sagemath/kernel.json
-	#echo "========================="
-	echo
+	# configuration files
+	cp ${FILESDIR}/sage_conf.py $_lib
+	cp ${FILESDIR}/sage-env-config $_scripts
 }
 
 pre_install() {
@@ -99,20 +66,8 @@ pre_install() {
 }
 
 post_install() {
-	echo
-	echo "===== after install ====="
-	find $DESTDIR |
-		grep -v "^${DESTDIR}${_prefix}/lib/python3.10/site-packages/sage/" |
-		grep -v "^${DESTDIR}${_prefix}/bin/"
-	echo "========================="
-	ls -l ${DESTDIR}${_prefix}/share/jupyter/nbextensions
-	ls -l ${DESTDIR}${_prefix}/share/jupyter/kernels/sagemath
-	cat ${DESTDIR}${_prefix}/share/jupyter/kernels/sagemath/kernel.json
-	echo "========================="
-	echo
-
 	# fix jupyter kernel spec
-	vsed -i -e 's|"/usr/bin/sage"|"'"${_prefix}"'/bin/sage"|' \
+	vsed -i -e 's|"/usr/bin/sage"|"'${_bindir}'/sage"|' \
 		${DESTDIR}${_prefix}/share/jupyter/kernels/sagemath/kernel.json
 
 	# replace broken symlinks by good copies (sagemath logo images)
@@ -129,38 +84,36 @@ post_install() {
 
 	# symlink main binary
 	vmkdir usr/bin
-	ln -s $_prefix/bin/sage ${DESTDIR}/usr/bin/sage-${version}
+	ln -s $_bindir/sage ${DESTDIR}/usr/bin/sage-${version}
 	ln -s sage-${version} ${DESTDIR}/usr/bin/sage
 
+	# symlink python library
+	vmkdir usr/lib/python${py3_ver}/site-packages
+	ln -s $_prefix/lib/python${py3_ver}/site-packages/sage \
+		${DESTDIR}/usr/lib/python${py3_ver}/site-packages/sage
+	ln -s $_prefix/lib/python${py3_ver}/site-packages/sage_conf.py \
+		${DESTDIR}/usr/lib/python${py3_ver}/site-packages/sage_conf.py
+
 	# symlink jupyter kernel
 	vmkdir usr/share/jupyter/kernels
-	ln -s $_prefix/share/jupyter/kernels/sagemath ${DESTDIR}/usr/share/jupyter/kernels/sagemath-${version}
-	ln -s sagemath-${version} ${DESTDIR}/usr/share/jupyter/kernels/sagemath
-
-	echo "===== after post-install ====="
-	find $DESTDIR |
-		grep -v "^${DESTDIR}${_prefix}/lib/python3.10/site-packages/sage/" |
-		grep -v "^${DESTDIR}${_prefix}/bin/"
-	echo "========================="
-	echo "<<< ${DESTDIR}{$_prefix}/share/jupyter/kernels/sagemath >>>"
-	ls -l ${DESTDIR}${_prefix}/share/jupyter/kernels/sagemath
-	echo "<<< ${DESTDIR}{$_prefix}/share/jupyter/kernels/sagemath/kernel.json >>>"
-	cat ${DESTDIR}${_prefix}/share/jupyter/kernels/sagemath/kernel.json
-	echo "=============================="
+	ln -s $_prefix/share/jupyter/kernels/sagemath \
+		${DESTDIR}/usr/share/jupyter/kernels/sagemath-${version}
+	ln -s sagemath-${version} \
+		${DESTDIR}/usr/share/jupyter/kernels/sagemath
 }
 
 do_check() {
 	_lib=$(cd build/lib* && pwd)
 	_scripts=$(cd build/scripts* && pwd)
 
-	export PYTHONPATH="$_lib"
+	export PYTHONPATH=$_lib
 	export PYTHONDONTWRITEBYTECODE=yes
 
 	# get out of $build_wrksrc, otherwise python picks the wrong sage module
 	cd $(mktemp -dp build)
 
 	if [ -f ${XBPS_DISTDIR}/sagemath-check ] ; then
-		_sed='s|#.*||;/^\s*$/d;s|[^ ]*/sage/|'$_lib'/sage/|g' \
+		_sed='s|#.*||;/^\s*$/d;s|^\([^ ]*/\)\?sage/|'$_lib'/sage/|g' \
 		_test_files=$(sed -e "$_sed" ${XBPS_DISTDIR}/sagemath-check)
 	fi
 	if [ -z "$_test_files" ]; then

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: DRAFT: sagemath update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (17 preceding siblings ...)
  2022-10-29  2:30 ` tornaria
@ 2022-10-29 11:02 ` tornaria
  2022-10-29 11:12 ` ahesford
                   ` (13 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: tornaria @ 2022-10-29 11:02 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1090 bytes --]

New comment by tornaria on void-packages repository

https://github.com/void-linux/void-packages/pull/39876#issuecomment-1295803372

Comment:
The check failures have to do with gap (atlasrep pkg) trying to download files from the network (and printing warnings b/c this fails since neither `curl` nor `wget` are installed in the chroot). The actual answers are ok so it seems the download is not really necessary for whatever sage is testing.

I will patch gap so it defaults to not download anything. The way the feature is implemented is not suitable for a system package anyway (wants to have a few shared 1777 directories, which I think is not an option).

Eventually, if these data files are important, we could try to download the data package and install it in the system... If someone needs this please tell me. See for instance https://www.math.rwth-aachen.de/homes/Thomas.Breuer/atlasrep/ where we are offered to download https://www.math.rwth-aachen.de/homes/Thomas.Breuer/atlasrep/atlasrepdata.tar.gz which is 22M so nothing compared to the current size of the gap package)

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: DRAFT: sagemath update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (18 preceding siblings ...)
  2022-10-29 11:02 ` tornaria
@ 2022-10-29 11:12 ` ahesford
  2022-10-29 12:16 ` [PR PATCH] [Updated] " tornaria
                   ` (12 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: ahesford @ 2022-10-29 11:12 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 391 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/39876#issuecomment-1295805673

Comment:
I am not worried about the checks. As for the data files, let somebody who needs them PR their addition.

Can this be ready to merge within the next week? I plan to bump Python next Saturday (5 Nov) and would like not to break your Sage workflow.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PR PATCH] [Updated] DRAFT: sagemath update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (19 preceding siblings ...)
  2022-10-29 11:12 ` ahesford
@ 2022-10-29 12:16 ` tornaria
  2022-10-29 16:55 ` tornaria
                   ` (11 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: tornaria @ 2022-10-29 12:16 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1883 bytes --]

There is an updated pull request by tornaria against master on the void-packages repository

https://github.com/tornaria/void-packages sagemath-update
https://github.com/void-linux/void-packages/pull/39876

DRAFT: sagemath update to 9.7
This includes #39838, #39840, #39846, #39872, #39866, also update eclib-20220621.

For now I'm reverting python3-matplotlib to 3.5.3_1 since 3.6.0_1 gives a lot of problems (#39857 adds python3-contourpy which will solve some, but I think there are more issues).

I want to make sure everything works ok and the full testsuite passes as is. Then I'll just move matplotlib back to 3.6.0_1 and try to see if it's feasible to fix or workaround the issues (sagemath-the-distro is still on matplotlib 3.5.2 and I didn't find anything about the update to 3.6.0)

<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: currently running the testsuite in --long after the update of singular.

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/39876.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-sagemath-update-39876.patch --]
[-- Type: text/x-diff, Size: 246034 bytes --]

From 2f30c35f7169ae672a739b88cbcac6304009c98b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 19:14:02 -0300
Subject: [PATCH 01/12] flintlib: update to 2.9.0.

---
 common/shlibs             | 2 +-
 srcpkgs/flintlib/template | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 7bd563a89134..82f6a8b8854e 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4020,7 +4020,7 @@ libgtkdatabox.so.1 gtkdatabox3-1.0.0_1
 libxcvt.so.0 libxcvt-0.1.1_1
 libgf2x.so.3 gf2x-1.3.0_1
 libntl.so.44 ntl-11.5.1_1
-libflint.so.16 flintlib-2.8.0_1
+libflint.so.17 flintlib-2.9.0_1
 libarb.so.2 arb-2.20.0_1
 libec.so.8 eclib-20210625_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index 968dbcb525c2..27f202b4434c 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,6 +1,6 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.8.5
+version=2.9.0
 revision=1
 wrksrc="flint-${version}"
 build_style=configure
@@ -14,11 +14,10 @@ license="LGPL-2.1-or-later"
 homepage="https://flintlib.org"
 changelog="https://raw.githubusercontent.com/wbhart/flint2/trunk/NEWS"
 distfiles="https://flintlib.org/flint-${version}.tar.gz"
-checksum=5911fedff911100f15781f35e3a4fa934fe60e4aea02a8c10cc8918101c1eed8
+checksum=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
-build_options_default=""
 
 if [ -z "$CROSS_BUILD" ]; then
 	build_options_default+=" ntl"

From 08b59f7277235ccbcae7174dc7ef8dcde0978b71 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 19:16:18 -0300
Subject: [PATCH 02/12] arb: update to 2.23.0.

---
 srcpkgs/arb/template | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
index 52f11ef83c90..84a62c7ffdba 100644
--- a/srcpkgs/arb/template
+++ b/srcpkgs/arb/template
@@ -1,6 +1,6 @@
 # Template file for 'arb'
 pkgname=arb
-version=2.22.1
+version=2.23.0
 revision=1
 build_style=configure
 configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
@@ -11,9 +11,7 @@ license="LGPL-2.1-or-later"
 homepage="https://arblib.org"
 changelog="https://raw.githubusercontent.com/fredrik-johansson/arb/master/doc/source/history.rst"
 distfiles="https://github.com/fredrik-johansson/arb/archive/${version}.tar.gz"
-checksum=1ef85518eee04885e8a90196498bc75e4e2410621d4184f2bc01d46b7080a243
-
-CFLAGS="-D_GNU_SOURCE" # needed for cpu_set_t
+checksum=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
 
 arb-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"

From b3440098382288bf57bacc5254114c61d3fc0b48 Mon Sep 17 00:00:00 2001
From: dkwo <nicolopiazzalunga@gmail.com>
Date: Mon, 10 Oct 2022 10:14:06 -0400
Subject: [PATCH 03/12] singular: update to 4.3.1p2 (fix gcc 12 build)

---
 common/shlibs             | 10 +++++-----
 srcpkgs/singular/template | 26 ++++++++++++++------------
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 82f6a8b8854e..2a17681a1c55 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4062,11 +4062,11 @@ libumfpack.so.5 SuiteSparse-5.10.1_1
 libecl.so.21.2 ecl-21.2.1_1
 libecm.so.1 ecm-7.0.4_3
 libcliquer.so.1 cliquer-1.22_1
-libSingular-4.3.0.so singular-4.3.0_1
-libfactory-4.3.0.so singular-4.3.0_1
-libpolys-4.3.0.so singular-4.3.0_1
-libomalloc-0.9.6.so singular-4.3.0_1
-libsingular_resources-4.3.0.so singular-4.3.0_1
+libSingular-4.3.1.so singular-4.3.1p2_1
+libfactory-4.3.1.so singular-4.3.1p2_1
+libpolys-4.3.1.so singular-4.3.1p2_1
+libomalloc-0.9.6.so singular-4.3.1p2_1
+libsingular_resources-4.3.1.so singular-4.3.1p2_1
 libbrial.so.3 brial-1.2.10_1
 libbrial_groebner.so.3 brial-1.2.10_1
 libm4ri-0.0.20200125.so m4ri-20200125_1
diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index f23659ef5d83..a30beef915d2 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,25 +1,27 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.0
+version=4.3.1p2
 revision=1
+_majver=${version%p*}
+wrksrc=singular-${_majver}
 build_style=gnu-configure
 configure_args="--with-readline=ncurses
-	--enable-gfanlib
-	--enable-Singular
-	--enable-factory
-	--disable-doc
-	--disable-polymake
-	--without-python
-	--with-libparse
-	ac_cv_lib_cddgmp_dd_free_global_constants=yes"
+ --enable-gfanlib
+ --enable-Singular
+ --enable-factory
+ --disable-doc
+ --disable-polymake
+ --without-python
+ --with-libparse
+ ac_cv_lib_cddgmp_dd_free_global_constants=yes"
 hostmakedepends="perl tar doxygen"
 makedepends="flintlib-devel cddlib-devel readline-devel graphviz"
 short_desc="Computer algebra system for polynomial computations"
-maintainer="dkwo <nicolopiazzalunga@gmail.com>"
+maintainer="dkwo <npiazza@disroot.org>"
 license="GPL-2.0-or-later"
 homepage="https://www.singular.uni-kl.de"
-distfiles="https://www.singular.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${version//./-}/singular-${version}.tar.gz"
-checksum=74f38288203720e3f280256f2f8deb94030dd032b4237d844652aff0faab36e7
+distfiles="https://www.singular.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${_majver//./-}/singular-${version}.tar.gz"
+checksum=95814bba0f0bd0290cd9799ec1d2ecc6f4c8a4e6429d9a02eb7f9c4e5649682a
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From c8c6b8f5088e57f47da905c8adb43633c792a102 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 19:59:20 -0300
Subject: [PATCH 04/12] pari: update to 2.15.0.

---
 common/shlibs                      |  3 +-
 srcpkgs/pari/patches/float32.patch | 48 ++++++++++++++++++++++++++++++
 srcpkgs/pari/template              | 12 ++++++--
 3 files changed, 58 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/pari/patches/float32.patch

diff --git a/common/shlibs b/common/shlibs
index 2a17681a1c55..36e502380de3 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4011,8 +4011,7 @@ libsimavrparts.so.1 simavr-1.6_2
 libsword-1.8.1.so libsword-1.8.1_6
 libgivaro.so.9 givaro-4.1.1_1
 liblinbox.so.0 linbox-1.6.3_1
-libpari-gmp.so.7 pari-2.13.0_1
-libpari-gmp-tls.so.7 pari-2.13.2_1
+libpari-gmp-tls.so.8 pari-2.15.0_1
 libtree-sitter.so.0 tree-sitter-0.19.0_1
 libplanarity.so.0 planarity-3.0.1.1_1
 libgap.so.0 gap-4.11.1_1
diff --git a/srcpkgs/pari/patches/float32.patch b/srcpkgs/pari/patches/float32.patch
new file mode 100644
index 000000000000..311dd6bf5a07
--- /dev/null
+++ b/srcpkgs/pari/patches/float32.patch
@@ -0,0 +1,48 @@
+Author: Gonzalo Tornaría <tornaria@cmat.edu.uy>
+Date:   Fri Oct 14 17:00:46 2022 -0300
+
+    Revert "x86 (32bit): force -mpc64 on compilers that supports it."
+    
+    This reverts commit ca61b6391cf95ac8af15669236e2ec5839d2ad91.
+
+
+This causes problems with floating point precision on i686:
+```
+$ cat exp40.c
+#include <math.h>
+#include <stdio.h>
+int main() {
+	volatile int a=40; /* do not optimize away the call to exp(a) */
+	printf("%f\n", exp(a));
+}
+$ cc -Wall exp40.c -lm && ./a.out
+235385266837020000.000000
+$ cc -Wall exp40.c -lm -mpc64 && ./a.out
+235385266837020448.000000
+```
+
+Note that when pari is built using -mpc64, just *linking* with -lpari
+causes the problem!!!
+```
+$ cc -Wall exp40.c -lm -lpari && ./a.out
+235385266837020448.000000
+```
+
+diff --git a/config/get_cc b/config/get_cc
+index 3cfaa88bb7..2d61d3871f 100644
+--- a/config/get_cc
++++ b/config/get_cc
+@@ -110,13 +110,6 @@ if test -n "$__gnuc__"; then
+   # Specific optimisations for some architectures
+   case "$arch" in
+     sparcv8*) cflags=-mv8;;
+-    i?86)
+-      cmd="$CC $CFLAGS $extraflag -mpc64 -fno-strict-aliasing -o $exe gnu.c"
+-      . log_cmd
+-      if test -s $exe; then
+-        cflags="-mpc64"
+-      fi
+-      . cleanup_exe;;
+   esac
+   # problems on some architectures
+   case "$osname" in
diff --git a/srcpkgs/pari/template b/srcpkgs/pari/template
index 8bac1e0343f8..811826a1ee14 100644
--- a/srcpkgs/pari/template
+++ b/srcpkgs/pari/template
@@ -1,6 +1,6 @@
 # Template file for 'pari'
 pkgname=pari
-version=2.13.4
+version=2.15.0
 revision=1
 build_style=configure
 build_helper=qemu
@@ -11,14 +11,15 @@ make_check_target=statest-all
 make_install_target="install install-lib-sta install-lib-dyn"
 hostmakedepends="perl texlive"
 makedepends="gmp-devel readline-devel $(vopt_if x11 libX11-devel)"
-checkdepends="pari-elldata-small pari-galdata pari-galpol-small pari-seadata-small"
+checkdepends="pari-elldata-small pari-galdata pari-galpol-small
+ pari-seadata-small pari-nflistdata"
 short_desc="Fast computations library in number theory"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="https://pari.math.u-bordeaux.fr"
 changelog="https://pari.math.u-bordeaux.fr/cgi-bin/gitweb.cgi?p=pari.git;a=blob_plain;f=CHANGES;hb=refs/heads/pari-${version%.*}"
 distfiles="https://pari.math.u-bordeaux.fr/pub/pari/unix/${pkgname}-${version}.tar.gz"
-checksum=bcde9eceae1592814381c1697cdb7063567b6504201b1be47bb58920f3bce185
+checksum=e474851e0d16d4e4f9a0d9612c746a2ae7c9a1ec185d04c440b1c74a85755685
 
 build_options="x11 pthreads"
 build_options_default="x11 pthreads"
@@ -27,6 +28,11 @@ desc_option_pthreads="Enable support for pthreads"
 # reduce speed losses due to pthreads
 CFLAGS="-flto -fno-semantic-interposition"
 
+case $XBPS_TARGET_MACHINE in
+	# avoid numerical noise caused by extended-precision of registers
+	i686*) CFLAGS+=" -ffloat-store" ;;
+esac
+
 post_patch() {
 	# sse2 is not available on all i686
 	# and it's available on all x86_64

From c3fac587602634647b09f9b2b14c2bc5d809ba35 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 20:33:23 -0300
Subject: [PATCH 05/12] gp2c: update to 0.0.13.

---
 srcpkgs/gp2c/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gp2c/template b/srcpkgs/gp2c/template
index f82cf95c2d90..9cf0f6fdce6e 100644
--- a/srcpkgs/gp2c/template
+++ b/srcpkgs/gp2c/template
@@ -1,6 +1,6 @@
 # Template file for 'gp2c'
 pkgname=gp2c
-version=0.0.12pl1
+version=0.0.13
 revision=1
 build_style=gnu-configure
 hostmakedepends="perl"
@@ -12,4 +12,4 @@ license="GPL-2.0-or-later"
 homepage="http://pari.math.u-bordeaux.fr/"
 changelog="http://pari.math.u-bordeaux.fr/cgi-bin/gitweb.cgi?p=gp2c.git;a=blob_plain;f=ChangeLog;hb=HEAD"
 distfiles="${homepage}pub/pari/GP2C/${pkgname}-${version}.tar.gz"
-checksum=79a8c46f7ad3331e4d8ae6af6b496c4742fd73a73b996b3ca7ead61452ca6e8d
+checksum=261374eca73ebd76c112a9593dca28b64812aa762561fda5a4b2c2cd79a69d36

From 6839777ae0c5ddcc2c1d94165a1524286d10c4b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Fri, 23 Sep 2022 16:42:40 -0300
Subject: [PATCH 06/12] eclib: update to 20221012.

---
 common/shlibs          | 2 +-
 srcpkgs/eclib/template | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 36e502380de3..a77784215a63 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4021,7 +4021,7 @@ libgf2x.so.3 gf2x-1.3.0_1
 libntl.so.44 ntl-11.5.1_1
 libflint.so.17 flintlib-2.9.0_1
 libarb.so.2 arb-2.20.0_1
-libec.so.8 eclib-20210625_1
+libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
 liblrcalc.so.2 lrcalc-2.1_1
diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 694a39ed4068..31a3a01921fa 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
-version=20210625
-revision=2
+version=20221012
+revision=1
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 hostmakedepends="automake autoconf-archive libtool"
@@ -11,7 +11,7 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="https://github.com/JohnCremona/eclib"
 distfiles="https://github.com/JohnCremona/eclib/archive/refs/tags/${version}.tar.gz"
-checksum=00333fd36afd237c9e6e410c7ab98536ddcd7fdc430e6837fe293247b835c572
+checksum=bd6f0191876c1426ca57db851ce06ef79ea1755f01e81dd747358d1b76b5e932
 
 pre_configure() {
 	autoreconf -fi

From fc6e1b7f81ae7c29e33e560273ad2cb3530d2bee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:20 -0300
Subject: [PATCH 07/12] giac: update to 1.9.0.27.

---
 .../giac/patches/giac-pari-2.15-test.patch    | 10 ++++++++++
 srcpkgs/giac/patches/giac-pari-2.15.patch     | 20 +++++++++++++++++++
 srcpkgs/giac/template                         |  4 ++--
 3 files changed, 32 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/giac/patches/giac-pari-2.15-test.patch
 create mode 100644 srcpkgs/giac/patches/giac-pari-2.15.patch

diff --git a/srcpkgs/giac/patches/giac-pari-2.15-test.patch b/srcpkgs/giac/patches/giac-pari-2.15-test.patch
new file mode 100644
index 000000000000..1f1929571a46
--- /dev/null
+++ b/srcpkgs/giac/patches/giac-pari-2.15-test.patch
@@ -0,0 +1,10 @@
+Fix a failing test due to thread stack overflow
+
+--- a/check/chk_fhan4	2018-03-13 15:27:11.000000000 -0300
++++ b/check/chk_fhan4	2022-10-14 18:51:12.604731890 -0300
+@@ -1,4 +1,5 @@
+ #! /bin/sh
+ unset LANG
++export PARI_SIZE=2048000
+ ../src/icas TP04-sol.cas > TP04.tst
+ diff TP04.tst TP04-sol.cas.out1
diff --git a/srcpkgs/giac/patches/giac-pari-2.15.patch b/srcpkgs/giac/patches/giac-pari-2.15.patch
new file mode 100644
index 000000000000..be409be38f53
--- /dev/null
+++ b/srcpkgs/giac/patches/giac-pari-2.15.patch
@@ -0,0 +1,20 @@
+ANYARG patch
+
+diff --git a/src/pari.cc b/src/pari.cc
+index 76ce8e1..50d08ab 100644
+--- a/src/pari.cc
++++ b/src/pari.cc
+@@ -40,6 +40,13 @@ using namespace std;
+ 
+ #ifdef HAVE_LIBPARI
+ 
++// Anyarg disappeared from PARI 2.15.0
++#ifdef __cplusplus
++#  define ANYARG ...
++#else
++#  define ANYARG
++#endif
++
+ #ifdef HAVE_PTHREAD_H
+ #include <pthread.h>
+ #endif
diff --git a/srcpkgs/giac/template b/srcpkgs/giac/template
index e892c8bf7506..5dcdbeb1e848 100644
--- a/srcpkgs/giac/template
+++ b/srcpkgs/giac/template
@@ -1,6 +1,6 @@
 # Template file for 'giac'
 pkgname=giac
-version=1.9.0.7
+version=1.9.0.27
 revision=1
 wrksrc="giac-${version%.*}"
 build_style=gnu-configure
@@ -14,7 +14,7 @@ license="GPL-3.0-or-later"
 homepage="https://www-fourier.ujf-grenoble.fr/~parisse/giac.html"
 changelog="https://www-fourier.ujf-grenoble.fr/~parisse/install_en#new"
 distfiles="https://www-fourier.ujf-grenoble.fr/~parisse/debian/dists/stable/main/source/giac_${version%.*}-${version##*.}.tar.gz"
-checksum=72016988b7180e9b630ecabecc60969213e7b61418c2598c91acbaec139fd740
+checksum=c5d222fbff5db2a0a560b4e106ce88dd13d109ecb21570a939b8b3b87521d5e0
 
 # need more than 4*65536 stack, see try_parse() in gen.cc line 11812
 LDFLAGS="-Wl,-z,stack-size=2097152"

From 6b361a0d03e2612cadca5168ce4d4918cddf517f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 12 Oct 2022 23:59:37 -0300
Subject: [PATCH 08/12] gap: update to 4.12.1.

---
 common/shlibs                                 |  2 +-
 ...atlasrep-dont_use_network_by_default.patch | 11 +++++
 srcpkgs/gap/template                          | 42 +++++++++++++------
 3 files changed, 41 insertions(+), 14 deletions(-)
 create mode 100644 srcpkgs/gap/patches/atlasrep-dont_use_network_by_default.patch

diff --git a/common/shlibs b/common/shlibs
index a77784215a63..31b11da9e6e3 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4014,7 +4014,7 @@ liblinbox.so.0 linbox-1.6.3_1
 libpari-gmp-tls.so.8 pari-2.15.0_1
 libtree-sitter.so.0 tree-sitter-0.19.0_1
 libplanarity.so.0 planarity-3.0.1.1_1
-libgap.so.0 gap-4.11.1_1
+libgap.so.8 gap-4.12.0_1
 libgtkdatabox.so.1 gtkdatabox3-1.0.0_1
 libxcvt.so.0 libxcvt-0.1.1_1
 libgf2x.so.3 gf2x-1.3.0_1
diff --git a/srcpkgs/gap/patches/atlasrep-dont_use_network_by_default.patch b/srcpkgs/gap/patches/atlasrep-dont_use_network_by_default.patch
new file mode 100644
index 000000000000..1a6be215091f
--- /dev/null
+++ b/srcpkgs/gap/patches/atlasrep-dont_use_network_by_default.patch
@@ -0,0 +1,11 @@
+--- a/pkg/atlasrep/gap/userpref.g	2022-09-06 17:41:17.000000000 -0300
++++ b/pkg/atlasrep/gap/userpref.g	2022-10-29 07:46:48.580833277 -0300
+@@ -46,7 +46,7 @@
+ this information depends on the value of the preference at the time \
+ when the AtlasRep package and its data extensions get loaded."
+     ],
+-  default:= true,
++  default:= false,
+   values:= [ true, false ],
+   multi:= false,
+   package:= "AtlasRep",
diff --git a/srcpkgs/gap/template b/srcpkgs/gap/template
index 7bc7d13ace20..277537fe0fa3 100644
--- a/srcpkgs/gap/template
+++ b/srcpkgs/gap/template
@@ -1,17 +1,17 @@
 # Template file for 'gap'
 pkgname=gap
-version=4.11.1
+version=4.12.1
 revision=1
 build_style=gnu-configure
-make_install_target="install-bin install-gaproot install-headers install-libgap"
 makedepends="gmp-devel zlib-devel readline-devel"
 checkdepends="perl"
 short_desc="Groups, Algorithms, Programming - computational discrete algebra"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
-homepage="http://www.gap-system.org/"
+homepage="https://www.gap-system.org/"
+changelog="https://raw.githubusercontent.com/gap-system/gap/master/CHANGES.md"
 distfiles="https://github.com/gap-system/gap/releases/download/v${version}/gap-${version}.tar.gz"
-checksum=6635c5da7d82755f8339486b9cac33766f58712f297e8234fba40818902ea304
+checksum=f9ebef11ee31b210ce36e3c70960742b4e253282bbd5270adc9324273c92b016
 
 if [ "$XBPS_CHECK_PKGS" = full ]; then
 	# not sure about this -- takes about 25 minutes
@@ -21,20 +21,36 @@ fi
 _GAPROOT=/usr/share/gap/
 
 # minimal required packages
-_GAPPKGS="GAPDoc primgrp SmallGrp transgrp"
+_GAPPKGS="autodoc gapdoc primgrp smallgrp transgrp"
 
 # other expected packages
-_GAPPKGS+=" atlasrep autpgrp alnuth crisp ctbllib FactInt fga irredsol laguna
- polenta polycyclic resclasses sophus tomlib"
+_GAPPKGS+=" atlasrep autpgrp alnuth crisp ctbllib factint fga irredsol laguna
+ polenta polycyclic radiroot resclasses sophus tomlib utils"
 
-post_install() {
-	vmkdir ${_GAPROOT}/pkg
+post_extract() {
+	# keep around only the packages that we want to install
+	mkdir pkg.install
 	for p in ${_GAPPKGS}; do
-		[ -d pkg/$p ] || p="$p-*"
-		vcopy "pkg/$p" ${_GAPROOT}/pkg
+		mv "pkg/$p" pkg.install
 	done
-	# not handled by make install-headers
-	vcopy gen/config.h /usr/include/gap
+	mv pkg pkg.orig
+	mv pkg.install pkg
+}
+
+post_install() {
+	vmkdir ${_GAPROOT}
+	vcopy pkg ${_GAPROOT}
+}
+
+pre_check() {
+	msg_normal "Check that loading packages works\n"
+	for p in ${_GAPPKGS}; do
+		cat <<-EOF
+		if LoadPackage("$p") <> true then
+		    Error("loading package '$p'");
+		fi;
+		EOF
+	done | ./gap --quitonbreak -b -q -r
 }
 
 gap-devel_package() {

From ce8b89ac797a8c34515507cd514adb980504ed98 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:19 -0300
Subject: [PATCH 09/12] lcalc: revbump for pari 2.15.0

---
 srcpkgs/lcalc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lcalc/template b/srcpkgs/lcalc/template
index 270078df9a54..3c6be5fcbc28 100644
--- a/srcpkgs/lcalc/template
+++ b/srcpkgs/lcalc/template
@@ -1,7 +1,7 @@
 # Template file for 'lcalc'
 pkgname=lcalc
 version=2.0.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--with-pari"
 hostmakedepends="automake libtool pkg-config gengetopt"

From 7837ab3f838f2c47f97a920803ce52ee8c6d2469 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:21 -0300
Subject: [PATCH 10/12] python3-cysignals: revbump for pari 2.15.0

---
 srcpkgs/python3-cysignals/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/python3-cysignals/template b/srcpkgs/python3-cysignals/template
index 4655eead2a9c..08d1010976ff 100644
--- a/srcpkgs/python3-cysignals/template
+++ b/srcpkgs/python3-cysignals/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-cysignals'
 pkgname=python3-cysignals
 version=1.11.2
-revision=1
+revision=2
 wrksrc="cysignals-${version}"
 build_style=python3-module
 hostmakedepends="python3-setuptools python3-Cython autoconf"

From 617407172345a7c64bc1e5562000efd08c412c17 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:58:16 -0300
Subject: [PATCH 11/12] python3-cypari2: revbump for pari 2.15.0

---
 srcpkgs/python3-cypari2/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/python3-cypari2/template b/srcpkgs/python3-cypari2/template
index 9ded61101e8e..9db3070a087c 100644
--- a/srcpkgs/python3-cypari2/template
+++ b/srcpkgs/python3-cypari2/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-cypari2'
 pkgname=python3-cypari2
 version=2.1.2
-revision=1
+revision=2
 wrksrc=cypari2-${version}
 build_style=python3-module
 hostmakedepends="python3-setuptools python3-Cython pari perl"

From b381da6836ea27730b96ce9090eae3cf0bf370a9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 00:49:01 -0300
Subject: [PATCH 12/12] sagemath: update to 9.7.

---
 srcpkgs/sagemath/files/sage-env-config        |    6 +
 srcpkgs/sagemath/files/sage_conf.py           |    3 +
 srcpkgs/sagemath/files/timings2.json          |   10 +-
 .../patches/01-dont_link_ratpoints.patch      |   10 -
 ...2-fix_get_shared_lib_path--see_29644.patch |   13 -
 .../patches/03-doctest_have_program.patch     |   20 -
 .../patches/04-doctest_sage_getfile.patch     |   22 -
 .../patches/05-fix_sage_getfile.patch         |   16 -
 .../sagemath/patches/07-ignore_warning.patch  |   15 -
 .../08-dont_run_pytest--see_31924.patch       |   27 -
 ...y_slow_doctest-polynomial_zmod_flint.patch |   14 -
 ...ry_slow_doctest-isogeny_small_degree.patch |  106 -
 ...fix_very_slow_doctest-function_field.patch |   97 -
 .../trac-31355-upgrade_lrcalc_to_2.1.patch    |  670 -------
 .../trac-33170-fix_doctest_ipython_8.patch    |   40 -
 .../trac-33170b-fix_doctest_ipython_8.1.patch |   13 -
 ...2ddd4e2dc92469c1590ebf0c40f8f69bf579.patch |  126 --
 ...2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch |   40 -
 .../trac-33336-fix_doctest_scipy_1.8.patch    |   19 -
 ...cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch |   53 +
 ...d9deaeaa6380ab2f0d50276d911233c00a04.patch |   99 -
 ...ff347454ac7f07e5918470b20e97b8f2357e.patch |   29 -
 ...fc4ec8b8687bccd22d2e3161c86cf5553e06.patch |  427 ++++
 ...0a0b14f67f4804e7113c3db41bbcf8a58296.patch |   26 -
 .../patches/trac-33842-python-3.11.patch      |   45 +
 ...d4e56243c609f44afc1f21c112b026f9e1fe.patch |   42 +
 ...93d67cfcdf8fba7bc6aa7899e2086d42cc7e.patch |  526 +++++
 ...1318f032caf8dc1c0de9489346d894409091.patch |   19 +
 .../trac-34537-sagemath-pari-2.15.patch       | 1750 +++++++++++++++++
 .../trac-34537-sagemath-pari-2.15b.patch      |   29 +
 ...e0de0dca1cff0355326dd42bd8c7e5749568.patch |   72 +
 .../zzz-loadable_module_extension.patch       |   14 -
 srcpkgs/sagemath/template                     |   61 +-
 33 files changed, 3002 insertions(+), 1457 deletions(-)
 create mode 100644 srcpkgs/sagemath/files/sage-env-config
 create mode 100644 srcpkgs/sagemath/files/sage_conf.py
 delete mode 100644 srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
 delete mode 100644 srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
 delete mode 100644 srcpkgs/sagemath/patches/03-doctest_have_program.patch
 delete mode 100644 srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
 delete mode 100644 srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
 delete mode 100644 srcpkgs/sagemath/patches/07-ignore_warning.patch
 delete mode 100644 srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
 delete mode 100644 srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
 delete mode 100644 srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
 delete mode 100644 srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-33446-make_GAP_SO_unnecessary-31e3fc4ec8b8687bccd22d2e3161c86cf5553e06.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-33842-python-3.11.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-a6c293d67cfcdf8fba7bc6aa7899e2086d42cc7e.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15b.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34668-matplotlib_3.6-5501e0de0dca1cff0355326dd42bd8c7e5749568.patch
 delete mode 100644 srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch

diff --git a/srcpkgs/sagemath/files/sage-env-config b/srcpkgs/sagemath/files/sage-env-config
new file mode 100644
index 000000000000..b84405301182
--- /dev/null
+++ b/srcpkgs/sagemath/files/sage-env-config
@@ -0,0 +1,6 @@
+# configure PATH using sage script location
+export PATH="$(dirname $SELF):$PATH"
+
+# if SAGE_VENV is set, the script sage-env will prepend
+# "$SAGE_VENV/bin" to the PATH, which is undesired
+unset SAGE_VENV
diff --git a/srcpkgs/sagemath/files/sage_conf.py b/srcpkgs/sagemath/files/sage_conf.py
new file mode 100644
index 000000000000..85ec37dfb50e
--- /dev/null
+++ b/srcpkgs/sagemath/files/sage_conf.py
@@ -0,0 +1,3 @@
+# configuration for sage on void linux
+SAGE_SHARE = "/usr/share/sagemath"
+GAP_ROOT_DIR = "/usr/share/gap"
diff --git a/srcpkgs/sagemath/files/timings2.json b/srcpkgs/sagemath/files/timings2.json
index 01b2fcc9e0bf..bb3098680502 100644
--- a/srcpkgs/sagemath/files/timings2.json
+++ b/srcpkgs/sagemath/files/timings2.json
@@ -109,7 +109,7 @@
   "sage.combinat.symmetric_group_algebra": {"walltime": 16},
   "sage.combinat.tableau": {"walltime": 32},
   "sage.combinat.tableau_tuple": {"walltime": 32},
-  "sage.combinat.tiling": {"walltime": 256},
+  "sage.combinat.tiling": {"walltime": 16},
   "sage.combinat.tutorial": {"walltime": 16},
   "sage.combinat.words.paths": {"walltime": 64},
   "sage.crypto.block_cipher.des": {"walltime": 16},
@@ -193,10 +193,10 @@
   "sage.manifolds.differentiable.automorphismfield": {"walltime": 32},
   "sage.manifolds.differentiable.automorphismfield_group": {"walltime": 8},
   "sage.manifolds.differentiable.bundle_connection": {"walltime": 8},
-  "sage.manifolds.differentiable.characteristic_cohomology_class": {"walltime": 256},
+  "sage.manifolds.differentiable.characteristic_cohomology_class": {"walltime": 64},
   "sage.manifolds.differentiable.curve": {"walltime": 16},
   "sage.manifolds.differentiable.degenerate": {"walltime": 32},
-  "sage.manifolds.differentiable.degenerate_submanifold": {"walltime": 256},
+  "sage.manifolds.differentiable.degenerate_submanifold": {"walltime": 16},
   "sage.manifolds.differentiable.diff_form": {"walltime": 64},
   "sage.manifolds.differentiable.diff_map": {"walltime": 8},
   "sage.manifolds.differentiable.examples.euclidean": {"walltime": 32},
@@ -270,7 +270,7 @@
   "sage.modules.free_quadratic_module_integer_symmetric": {"walltime": 8},
   "sage.modules.torsion_quadratic_module": {"walltime": 16},
   "sage.parallel.map_reduce": {"walltime": 8},
-  "sage.plot.animate": {"walltime": 128},
+  "sage.plot.animate": {"walltime": 16},
   "sage.plot.arrow": {"walltime": 8},
   "sage.plot.circle": {"walltime": 8},
   "sage.plot.complex_plot": {"walltime": 8},
@@ -308,7 +308,7 @@
   "sage.rings.function_field.function_field_valuation": {"walltime": 64},
   "sage.rings.function_field.ideal": {"walltime": 8},
   "sage.rings.function_field.place": {"walltime": 8},
-  "sage.rings.integer": {"walltime": 128},
+  "sage.rings.integer": {"walltime": 64},
   "sage.rings.invariants.invariant_theory": {"walltime": 8},
   "sage.rings.number_field.bdd_height": {"walltime": 8},
   "sage.rings.number_field.number_field": {"walltime": 64},
diff --git a/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch b/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
deleted file mode 100644
index e5c3f5776aa2..000000000000
--- a/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
+++ /dev/null
@@ -1,10 +0,0 @@
- - do not link ratpoints where it's not used
-
---- a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
-+++ b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
-@@ -1,5 +1,3 @@
--# distutils: libraries = ratpoints
--
- r"""
- Descent on elliptic curves over `\QQ` with a 2-isogeny
- """
diff --git a/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch b/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
deleted file mode 100644
index d3672b094c1c..000000000000
--- a/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
+++ /dev/null
@@ -1,13 +0,0 @@
- - fix _get_shared_lib_path() so we don't need to configure GAP_SO
-
---- a/src/sage/env.py
-+++ b/src/sage/env.py
-@@ -293,7 +293,7 @@ def _get_shared_lib_path(*libnames: str) -> Optional[str]:
-             if sys.platform == 'darwin':
-                 ext = 'dylib'
-             else:
--                ext = 'so'
-+                ext = 'so*'
- 
-             if SAGE_LOCAL:
-                 search_directories.append(Path(SAGE_LOCAL) / 'lib')
diff --git a/srcpkgs/sagemath/patches/03-doctest_have_program.patch b/srcpkgs/sagemath/patches/03-doctest_have_program.patch
deleted file mode 100644
index 27ba3776470c..000000000000
--- a/srcpkgs/sagemath/patches/03-doctest_have_program.patch
+++ /dev/null
@@ -1,20 +0,0 @@
- - we don't know `SAGE_VENV/bin` contains `sage`, but `sys.argv[0]` should
-   be the full path to `sage-ipython` and the same directory should have `sage`
-
---- a/src/sage/misc/sage_ostools.pyx
-+++ b/src/sage/misc/sage_ostools.pyx
-@@ -32,12 +32,11 @@ def have_program(program, path=None):
-         True
-         sage: have_program('there_is_not_a_program_with_this_name')
-         False
--        sage: from sage.env import SAGE_VENV
--        sage: have_program('sage', os.path.join(SAGE_VENV, 'bin'))
-+        sage: have_program('sage', os.path.dirname(sys.argv[0]))
-         True
-         sage: have_program('sage', '/there_is_not_a_path_with_this_name')
-         False
--        sage: have_program('there_is_not_a_program_with_this_name', os.path.join(SAGE_VENV, 'bin'))
-+        sage: have_program('there_is_not_a_program_with_this_name', "/bin")
-         False
-     """
-     if path is None:
diff --git a/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch b/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
deleted file mode 100644
index 95bce107f854..000000000000
--- a/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
+++ /dev/null
@@ -1,22 +0,0 @@
- - add one doctest for coverage
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -1341,10 +1342,12 @@ def sage_getfile(obj):
-     EXAMPLES::
- 
-         sage: from sage.misc.sageinspect import sage_getfile
--        sage: sage_getfile(sage.rings.rational)[-23:]
--        'sage/rings/rational.pyx'
--        sage: sage_getfile(Sq)[-42:]
--        'sage/algebras/steenrod/steenrod_algebra.py'
-+        sage: sage_getfile(sage.rings.rational)
-+        '...sage/rings/rational.pyx'
-+        sage: sage_getfile(Sq)
-+        '...sage/algebras/steenrod/steenrod_algebra.py'
-+        sage: sage_getfile(x)
-+        '...sage/symbolic/expression.pyx'
- 
-     The following tests against some bugs fixed in :trac:`9976`::
- 
-
diff --git a/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch b/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
deleted file mode 100644
index 56c58078f319..000000000000
--- a/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
+++ /dev/null
@@ -1,16 +0,0 @@
- - fix sage_getfile() by checking all possible EXTENSION_SUFFIXES
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -1400,8 +1403,9 @@ def sage_getfile(obj):
-         sourcefile = inspect.getabsfile(obj)
-     except TypeError: # this happens for Python builtins
-         return ''
--    if sourcefile.endswith(loadable_module_extension()):
--        return sourcefile[:-len(loadable_module_extension())]+os.path.extsep+'pyx'
-+    for suffix in import_machinery.EXTENSION_SUFFIXES:
-+        if sourcefile.endswith(suffix):
-+            return sourcefile[:-len(suffix)]+os.path.extsep+'pyx'
-     return sourcefile
- 
- 
diff --git a/srcpkgs/sagemath/patches/07-ignore_warning.patch b/srcpkgs/sagemath/patches/07-ignore_warning.patch
deleted file mode 100644
index 69668678a40b..000000000000
--- a/srcpkgs/sagemath/patches/07-ignore_warning.patch
+++ /dev/null
@@ -1,15 +0,0 @@
- - this ignores a warning caused by old notebook
-
---- a/src/sage/all.py
-+++ b/src/sage/all.py
-@@ -100,6 +100,9 @@ warnings.filterwarnings('ignore', category=DeprecationWarning,
-                         message='The distutils(.sysconfig module| package) is deprecated',
-                         module='Cython|distutils|numpy|sage.env|sage.features')
- 
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"invalid escape sequence '\\s'")
-+
- ################ end setup warnings ###############################
- 
- 
-
diff --git a/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch b/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
deleted file mode 100644
index 06bd2ccae6fb..000000000000
--- a/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
+++ /dev/null
@@ -1,27 +0,0 @@
- - using pytest is broken, see #31924
-
---- a/src/bin/sage-runtests
-+++ b/src/bin/sage-runtests
-@@ -154,21 +154,4 @@ if __name__ == "__main__":
-     DC = DocTestController(args, args.filenames)
-     err = DC.run()
- 
--    try:
--        exit_code_pytest = 0
--        import pytest
--        pytest_options = ["--import-mode", "importlib"]
--        if args.verbose:
--            pytest_options.append("-v")
--        exit_code_pytest = pytest.main(pytest_options + args.filenames)
--        if exit_code_pytest == 5:
--            # Exit code 5 means there were no test files, pass in this case
--            exit_code_pytest = 0
--
--    except ModuleNotFoundError:
--        print("Pytest is not installed, skip checking tests that rely on it.")
--
--    if err == 0:
--        sys.exit(exit_code_pytest)
--    else:
--        sys.exit(err)
-+    sys.exit(err)
diff --git a/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch b/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
deleted file mode 100644
index bae8387cf94a..000000000000
--- a/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
-+++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
-@@ -237,8 +237,9 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
- 
-             sage: a = ZZ['x'](range(100000))
-             sage: R = Integers(3)['x']
--            sage: R(a)  # long time (7s on sage.math, 2013)
--            2*x^99998 + ... + x
-+            sage: p = R(a)
-+            sage: p.truncate(10)  # testing the whole poly is VERY SLOW
-+            2*x^8 + x^7 + 2*x^5 + x^4 + 2*x^2 + x
-         """
-         sig_on()
-         fmpz_poly_get_nmod_poly(&self.x, x)
diff --git a/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch b/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
deleted file mode 100644
index f3da5bbb555e..000000000000
--- a/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
+++ /dev/null
@@ -1,106 +0,0 @@
-diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-index 43727346269..9d3ccd475cd 100644
---- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-+++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-@@ -186,7 +186,7 @@ def Psi(l, use_stored=True):
-         sage: assert Psi(3, use_stored=True) == Psi(3, use_stored=False)
-         sage: assert Psi(5, use_stored=True) == Psi(5, use_stored=False)
-         sage: assert Psi(7, use_stored=True) == Psi(7, use_stored=False)
--        sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False) # not tested (very long time)
-+        sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False)  # long time (2s)
-     """
-     if l not in [2, 3, 5, 7, 13]:
-         raise ValueError("Genus zero primes are 2, 3, 5, 7 or 13.")
-@@ -1207,7 +1207,7 @@ def isogenies_13_0(E, minimal_models=True):
-         sage: K.<a> = NumberField(f)
-         sage: E = EllipticCurve(j=K(0)); E.ainvs()
-         (0, 0, 0, 0, 1)
--        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]
-+        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]  # long time (4s)
-         [(0,
-           0,
-           20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
-@@ -1325,7 +1325,7 @@ def isogenies_13_1728(E, minimal_models=True):
-         sage: f = x^12 + 1092*x^10 - 432432*x^8 + 6641024*x^6 - 282896640*x^4 - 149879808*x^2 - 349360128
-         sage: K.<a> = NumberField(f)
-         sage: E = EllipticCurve(K, [1,0])
--        sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]
-+        sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]  # long time (3s)
-         [(0,
-         0,
-         0,
-@@ -1550,8 +1550,11 @@ def Psi2(l):
-         sage: from sage.schemes.elliptic_curves.isogeny_small_degree import Psi2
-         sage: Psi2(11)
-         x^5 - 55*x^4*u + 994*x^3*u^2 - 8774*x^2*u^3 + 41453*x*u^4 - 928945/11*u^5 + 33*x^4 + 276*x^3*u - 7794*x^2*u^2 + 4452*x*u^3 + 1319331/11*u^4 + 216*x^3*v - 4536*x^2*u*v + 31752*x*u^2*v - 842616/11*u^3*v + 162*x^3 + 38718*x^2*u - 610578*x*u^2 + 33434694/11*u^3 - 4536*x^2*v + 73872*x*u*v - 2745576/11*u^2*v - 16470*x^2 + 580068*x*u - 67821354/11*u^2 - 185976*x*v + 14143896/11*u*v + 7533*x - 20437029/11*u - 12389112/11*v + 19964151/11
--        sage: Psi2(71)  # long time (1 second)
--        -2209380711722505179506258739515288584116147237393815266468076436521/71*u^210 + ... - 14790739586438315394567393301990769678157425619440464678252277649/71
-+        sage: f = Psi2(71)
-+        sage: f.coefficient([0, 210, 0])
-+        -2209380711722505179506258739515288584116147237393815266468076436521/71
-+        sage: f.coefficient([0, 0, 0])
-+        -14790739586438315394567393301990769678157425619440464678252277649/71
- 
-     TESTS::
- 
-@@ -1665,17 +1668,17 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True):
-         sage: K = QuadraticField(5,'a')
-         sage: a = K.gen()
-         sage: E = EllipticCurve_from_j(184068066743177379840*a - 411588709724712960000)
--        sage: isogenies_prime_degree_genus_plus_0(E, 47) # long time (4.3s)
-+        sage: isogenies_prime_degree_genus_plus_0(E, 47)  # long time (2s)
-         [Isogeny of degree 47 from Elliptic Curve defined by y^2 = x^3 + (454562028554080355857852049849975895490560*a-1016431595837124114668689286176511361024000)*x + (-249456798429896080881440540950393713303830363999480904280965120*a+557802358738710443451273320227578156598454035482869042774016000) over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790? to Elliptic Curve defined by y^2 = x^3 + (39533118442361013730577638493616965245992960*a-88398740199669828340617478832005245173760000)*x + (214030321479466610282320528611562368963830105830555363061803253760*a-478586348074220699687616322532666163722004497458452316582576128000) over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790?]
- 
-         sage: K = QuadraticField(-66827,'a')
-         sage: a = K.gen()
-         sage: E = EllipticCurve_from_j(-98669236224000*a + 4401720074240000)
--        sage: isogenies_prime_degree_genus_plus_0(E, 59)   # long time (25s, 2012)
-+        sage: isogenies_prime_degree_genus_plus_0(E, 59)   # long time (5s)
-         [Isogeny of degree 59 from Elliptic Curve defined by y^2 = x^3 + (2605886146782144762297974784000*a+1893681048912773634944634716160000)*x + (-116918454256410782232296183198067568744071168000*a+17012043538294664027185882358514011304812871680000) over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I to Elliptic Curve defined by y^2 = x^3 + (-19387084027159786821400775098368000*a-4882059104868154225052787156713472000)*x + (-25659862010101415428713331477227179429538847260672000*a-2596038148441293485938798119003462972840818381946880000) over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I]
- 
-         sage: E = EllipticCurve_from_j(GF(13)(5))
--        sage: isogenies_prime_degree_genus_plus_0(E, 71) # long time
-+        sage: isogenies_prime_degree_genus_plus_0(E, 71)
-         [Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13, Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13]
- 
-         sage: E = EllipticCurve(GF(13),[0,1,1,1,0])
-@@ -2117,11 +2120,11 @@ def isogenies_prime_degree_general(E, l, minimal_models=True):
-         sage: isogenies_prime_degree_general(E, 19)
-         [Isogeny of degree 19 from Elliptic Curve defined by y^2 + y = x^3 - 1862*x - 30956 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - 672182*x + 212325489 over Rational Field]
-         sage: E = EllipticCurve([0, -1, 0, -6288, 211072])
--        sage: isogenies_prime_degree_general(E, 37)  # long time (10s)
-+        sage: isogenies_prime_degree_general(E, 37)  # long time (2s)
-         [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 - x^2 - 6288*x + 211072 over Rational Field to Elliptic Curve defined by y^2 = x^3 - x^2 - 163137088*x - 801950801728 over Rational Field]
- 
-         sage: E = EllipticCurve([-3440, 77658])
--        sage: isogenies_prime_degree_general(E, 43)  # long time (16s)
-+        sage: isogenies_prime_degree_general(E, 43)  # long time (2s)
-         [Isogeny of degree 43 from Elliptic Curve defined by y^2 = x^3 - 3440*x + 77658 over Rational Field to Elliptic Curve defined by y^2 = x^3 - 6360560*x - 6174354606 over Rational Field]
- 
-     Isogenies of degree equal to the characteristic are computed (but
-@@ -2175,7 +2178,7 @@ def isogenies_prime_degree_general(E, l, minimal_models=True):
- 
-         sage: K.<i> = QuadraticField(-1)
-         sage: E = EllipticCurve(K,[0,0,0,1,0])
--        sage: [phi.codomain().ainvs() for phi in E.isogenies_prime_degree(37)] # long time
-+        sage: [phi.codomain().ainvs() for phi in E.isogenies_prime_degree(37)]  # long time (6s)
-         [(0, 0, 0, -840*i + 1081, 0), (0, 0, 0, 840*i + 1081, 0)]
-     """
-     if not l.is_prime():
-@@ -2329,14 +2332,14 @@ def isogenies_prime_degree(E, l, minimal_models=True):
-         sage: E = EllipticCurve(GF(101), [-3440, 77658])
-         sage: E.isogenies_prime_degree(71) # fast
-         []
--        sage: E.isogenies_prime_degree(73) # slower (2s)
-+        sage: E.isogenies_prime_degree(73)  # long time (2s)
-         []
- 
-     Test that :trac:`32269` is fixed::
- 
-         sage: K = QuadraticField(-11)
-         sage: E = EllipticCurve(K, [0,1,0,-117,-541])
--        sage: E.isogenies_prime_degree(37)
-+        sage: E.isogenies_prime_degree(37)  # long time (9s)
-         [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I to Elliptic Curve defined by y^2 = x^3 + x^2 + (30800*a+123963)*x + (3931312*a-21805005) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I,
-          Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I to Elliptic Curve defined by y^2 = x^3 + x^2 + (-30800*a+123963)*x + (-3931312*a-21805005) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I]
- 
diff --git a/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch b/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
deleted file mode 100644
index 3b7b1ea843df..000000000000
--- a/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
+++ /dev/null
@@ -1,97 +0,0 @@
---- a/src/sage/rings/function_field/function_field.py
-+++ b/src/sage/rings/function_field/function_field.py
-@@ -111,22 +111,21 @@ Function fields over the algebraic field are supported::
-     sage: m = L.completion(pl, prec=5)
-     sage: m(x)
-     I + s + O(s^5)
--    sage: m(y)
-+    sage: m(y)                             # long time (4s)
-     -2*s + (-4 - I)*s^2 + (-15 - 4*I)*s^3 + (-75 - 23*I)*s^4 + (-413 - 154*I)*s^5 + O(s^6)
--    sage: m(y)^2 + m(y) + m(x) + 1/m(x)
-+    sage: m(y)^2 + m(y) + m(x) + 1/m(x)    # long time (8s)
-     O(s^5)
- 
- TESTS::
- 
-     sage: TestSuite(J).run()
--    sage: TestSuite(K).run(max_runs=1024) # long time (5s)
--    sage: TestSuite(L).run(max_runs=64)   # long time (10s)
--    sage: TestSuite(M).run(max_runs=32)   # long time (30s)
--    sage: TestSuite(N).run(max_runs=64, skip = '_test_derivation')  # long time (8s)
--    sage: TestSuite(O).run(max_runs=128, skip = '_test_derivation') # long time (8s)
--
-+    sage: TestSuite(K).run(max_runs=256)   # long time (10s)
-+    sage: TestSuite(L).run(max_runs=8)     # long time (25s)
-+    sage: TestSuite(M).run(max_runs=8)     # long time (35s)
-+    sage: TestSuite(N).run(max_runs=8, skip = '_test_derivation')    # long time (15s)
-+    sage: TestSuite(O).run()
-     sage: TestSuite(R).run()
--    sage: TestSuite(S).run() # long time (3s)
-+    sage: TestSuite(S).run()               # long time (4s)
- 
- Global function fields
- ----------------------
-@@ -287,7 +286,7 @@ class FunctionField(Field):
-         TESTS::
- 
-             sage: K.<x> = FunctionField(QQ)
--            sage: TestSuite(K).run()
-+            sage: TestSuite(K).run()               # long time (3s)
-         """
-         Field.__init__(self, base_field, names=names, category=category)
- 
-@@ -729,7 +728,7 @@ class FunctionField(Field):
-         EXAMPLES::
- 
-             sage: K.<x> = FunctionField(QQ)
--            sage: TestSuite(K).run() # indirect doctest
-+            sage: TestSuite(K).run()    # indirect doctest, long time (3s)
-         """
-         tester = self._tester(**options)
-         S = tester.some_elements()
-@@ -1209,7 +1208,7 @@ class FunctionField_polymod(FunctionField):
-             sage: K.<x> = FunctionField(QQ); R.<y> = K[]
-             sage: L = K.extension(y^5 - x^3 - 3*x + x*y); L
-             Function field in y defined by y^5 + x*y - x^3 - 3*x
--            sage: TestSuite(L).run()  # long time
-+            sage: TestSuite(L).run(max_runs=512)   # long time (15s)
- 
-         We can set the variable name, which doesn't have to be y::
- 
-@@ -2888,7 +2887,8 @@ class FunctionField_simple(FunctionField_polymod):
-             sage: F.<y> = K.extension(Y^3 - x^2*(x^2 + x + 1)^2)
-             sage: O = K.maximal_order()
-             sage: pls = [O.ideal(x-QQbar(sqrt(c))).place() for c in [-2, -1, 0, 1, 2]]
--            sage: all(q.place_below() == p for p in pls for q in F.places_above(p))
-+            sage: all(q.place_below() == p         # long time (4s)
-+            ....:     for p in pls for q in F.places_above(p))
-             True
-         """
-         R = self.base_field()
-@@ -3091,7 +3091,7 @@ class FunctionField_global(FunctionField_simple):
- 
-         sage: K.<x> = FunctionField(GF(4)); _.<Y> = K[]
-         sage: L.<y> = K.extension((1 - x)*Y^7 - x^3)
--        sage: L.gaps()
-+        sage: L.gaps()                         # long time (6s)
-         [1, 2, 3]
- 
-     or may define a trivial extension::
-@@ -3111,7 +3111,7 @@ class FunctionField_global(FunctionField_simple):
- 
-             sage: K.<x> = FunctionField(GF(5)); _.<Y> = K[]
-             sage: L.<y> = K.extension(Y^3 - (x^3 - 1)/(x^3 - 2))
--            sage: TestSuite(L).run()
-+            sage: TestSuite(L).run()               # long time (7s)
-         """
-         FunctionField_polymod.__init__(self, polynomial, names)
- 
-@@ -3807,7 +3807,7 @@ class RationalFunctionField(FunctionField):
- 
-             sage: K.<t> = FunctionField(CC); K
-             Rational function field in t over Complex Field with 53 bits of precision
--            sage: TestSuite(K).run()
-+            sage: TestSuite(K).run()               # long time (5s)
- 
-             sage: FunctionField(QQ[I], 'alpha')
-             Rational function field in alpha over Number Field in I with defining polynomial x^2 + 1 with I = 1*I
diff --git a/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch b/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
deleted file mode 100644
index 4bd6f4f4e2dc..000000000000
--- a/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
+++ /dev/null
@@ -1,670 +0,0 @@
-As produced by `git diff 9.5 9.6.beta3 -- src/sage/libs/lrcalc`
-
-diff --git a/src/sage/libs/lrcalc/lrcalc.pxd b/src/sage/libs/lrcalc/lrcalc.pxd
-deleted file mode 100644
-index 10b88db93f2..00000000000
---- a/src/sage/libs/lrcalc/lrcalc.pxd
-+++ /dev/null
-@@ -1,77 +0,0 @@
--# distutils: libraries = lrcalc
--
--cdef extern from "lrcalc/hashtab.h":
--    ctypedef struct hashtab:
--        pass
--
--    ctypedef struct hash_itr:
--        pass
--
--    ctypedef unsigned long hashkey_t
--    ctypedef int (*cmp_t) (void* a, void* b)
--    ctypedef hashkey_t (*hash_t) (void* a)
--
--    hashtab* hash_new(cmp_t cm, hash_t hsh)
--    void hash_free(hashtab *ht)
--
--    void* hash_lookup(hashtab *ht, void *key)
--    void* hash_insert(hashtab *ht, void *key, void *value)
--
--    bint hash_good(hash_itr)
--    void hash_first(hashtab* s, hash_itr itr)
--    void hash_next(hash_itr itr)
--    void* hash_key(hash_itr itr)
--    void* hash_value(hash_itr itr)
--    int hash_intvalue(hash_itr itr)
--
--cdef extern from "lrcalc/vector.h":
--    ctypedef struct vector:
--        size_t length
--        int* array
--
--    vector* v_new(int length)
--    void v_free(vector* v)
--    void v_print(vector *v)
--    int v_length(vector* v)
--    int v_elem(vector* v, int i)
--
--    ctypedef struct vecpair:
--        vector *first
--        vector *second
--
--    vector* vp_first(vecpair* vp)
--    vector* vp_second(vecpair* vp)
--
--cdef extern from "lrcalc/list.h":
--    cdef struct _list:
--        void **array
--        size_t allocated
--        size_t length
--    void l_free(_list *lst)
--
--cdef extern from "lrcalc/symfcn.h":
--    long long lrcoef_c "lrcoef"(vector* outer, vector* inner1, vector* inner2)
--    hashtab* mult_c "mult"(vector *sh1, vector *sh2, int maxrows)
--    hashtab* skew_c "skew"(vector *outer, vector *inner, int maxrows)
--    hashtab* coprod_c "coprod"(vector *part, int all)
--    void fusion_reduce_c "fusion_reduce"(hashtab* ht, int rows, int cols, int opt_zero)
--    _list *quantum_reduce_c "quantum_reduce"(hashtab* ht, int rows, int col)
--
--    ctypedef struct skewtab:
--        vector *outer
--        vector *inner
--        vector *conts
--        int maxrows
--        vector *conjugate
--        int rows
--        int cols
--        int matrix[1]
--
--    skewtab *st_new(vector *outer, vector *inner, vector *conts, int maxrows)
--    int st_next(skewtab *st)
--    void st_print(skewtab *st)
--    void st_free(skewtab *st)
--
--
--cdef extern from "lrcalc/schublib.h":
--    hashtab* mult_schubert_c "mult_schubert"(vector *sh1, vector *sh2, int rank)
-diff --git a/src/sage/libs/lrcalc/lrcalc.pyx b/src/sage/libs/lrcalc/lrcalc.py
-similarity index 60%
-rename from src/sage/libs/lrcalc/lrcalc.pyx
-rename to src/sage/libs/lrcalc/lrcalc.py
-index b591081ec4c..b541bfacd89 100644
---- a/src/sage/libs/lrcalc/lrcalc.pyx
-+++ b/src/sage/libs/lrcalc/lrcalc.py
-@@ -10,7 +10,8 @@ fusion products. All of the above are achieved by counting LR
- appropriate shape and content by iterating through them.
- Additionally, ``lrcalc`` handles products of Schubert polynomials.
- 
--The web page of ``lrcalc`` is `<http://sites.math.rutgers.edu/~asbuch/lrcalc/>`_.
-+The web page of ``lrcalc`` is
-+`<http://sites.math.rutgers.edu/~asbuch/lrcalc/>`_.
- 
- The following describes the Sage interface to this library.
- 
-@@ -36,12 +37,13 @@ Schur expansion::
-      [4, 2]: 1}
- 
- Same product, but include only partitions with at most 3 rows.  This
--corresponds to computing in the representation ring of gl(3)::
-+corresponds to computing in the representation ring of `\mathfrak{gl}(3)`::
- 
-     sage: lrcalc.mult([2,1], [2,1], 3)
-     {[2, 2, 2]: 1, [3, 2, 1]: 2, [3, 3]: 1, [4, 1, 1]: 1, [4, 2]: 1}
- 
--We can also compute the fusion product, here for sl(3) and level 2::
-+We can also compute the fusion product, here for `\mathfrak{sl}(3)`
-+and level 2::
- 
-     sage: lrcalc.mult([3,2,1], [3,2,1], 3,2)
-     {[4, 4, 4]: 1, [5, 4, 3]: 1}
-@@ -77,42 +79,38 @@ Multiply two Schubert polynomials::
-      [6, 2, 1, 4, 3, 5]: 1}
- 
- Same product, but include only permutations of 5 elements in the result.
--This corresponds to computing in the cohomology ring of Fl(5)::
-+This corresponds to computing in the cohomology ring of `Fl(5)`::
- 
-     sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3], 5)
-     {[4, 5, 1, 3, 2]: 1, [5, 3, 1, 4, 2]: 1, [5, 4, 1, 2, 3]: 1}
- 
- List all Littlewood-Richardson tableaux of skew shape `\mu/\nu`; in
- this example `\mu=[3,2,1]` and `\nu=[2,1]`. Specifying a third entry
--`maxrows` restricts the alphabet to `\{1,2,\ldots,maxrows\}`::
-+`M' = ``maxrows`` restricts the alphabet to `\{1,2,\ldots,M\}`::
- 
-     sage: list(lrcalc.lrskew([3,2,1],[2,1]))
-     [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
-     [[None, None, 1], [None, 2], [1]], [[None, None, 1], [None, 2], [3]]]
- 
-     sage: list(lrcalc.lrskew([3,2,1],[2,1],maxrows=2))
--    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]], [[None, None, 1], [None, 2], [1]]]
-+    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
-+     [[None, None, 1], [None, 2], [1]]]
- 
- .. TODO::
- 
--    use this library in the :class:`SymmetricFunctions` code, to
-+    Use this library in the :class:`SymmetricFunctions` code, to
-     make it easy to apply it to linear combinations of Schur functions.
- 
- .. SEEALSO::
- 
-     - :func:`lrcoef`
--
-     - :func:`mult`
--
-     - :func:`coprod`
--
-     - :func:`skew`
--
-     - :func:`lrskew`
--
-     - :func:`mult_schubert`
- 
--.. rubric:: Underlying algorithmic in lrcalc
-+.. RUBRIC:: Underlying algorithmic in lrcalc
- 
- Here is some additional information regarding the main low-level
- C-functions in `lrcalc`. Given two partitions ``outer`` and ``inner``
-@@ -187,180 +185,24 @@ AUTHORS:
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from sage.rings.integer cimport Integer
--from sage.structure.parent cimport Parent
- from sage.combinat.partition import _Partitions
- from sage.combinat.permutation import Permutation
--from sage.combinat.skew_tableau import SkewTableau
--
--
--cdef vector* iterable_to_vector(it):
--    """
--    Return an lrcalc vector (which is a list of integers) from a Python iterable.
--
--    TESTS::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector(Partition([3,2,1])); x   #indirect doctest
--        [3, 2, 1]
--    """
--    cdef vector* v
--    cdef list itr = list(it)
--    cdef int n = len(itr)
--    cdef int i
--    v = v_new(n)
--    for i in range(n):
--        v.array[i] = int(itr[i])
--    return v
--
--
--cdef list vector_to_list(vector *v):
--    """
--    Converts a lrcalc vector to Python list.
--
--    TESTS::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector([]); x         #indirect doctest
--        []
--    """
--    cdef int i, n
--    n = v_length(v)
--    cdef list result = [None]*n
--    for i in range(n):
--        result[i] = Integer(v_elem(v, i))
--    return result
--
--
--def test_iterable_to_vector(it):
--    """
--    A wrapper function for the cdef function ``iterable_to_vector``
--    and ``vector_to_list``, to test that they are working correctly.
-+from sage.combinat.skew_tableau import SemistandardSkewTableaux
-+from sage.combinat.skew_partition import SkewPartition
-+from sage.rings.integer import Integer
-+import lrcalc
- 
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector([3,2,1]); x
--        [3, 2, 1]
--    """
--    cdef vector *v = iterable_to_vector(it)
--    result = vector_to_list(v)
--    v_free(v)
--    return result
--
--
--cdef skewtab_to_SkewTableau(skewtab *st):
--    """
--    A wrapper function which transforms the data set ``st`` used in
--    ``lrcalc`` to a ``SkewTableau`` in Sage.
-+def _lrcalc_dict_to_sage(result):
-+    r"""
-+    Translate from lrcalc output format to Sage expected format.
- 
-     TESTS::
- 
--        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
--        sage: test_skewtab_to_SkewTableau([],[])
--        []
--    """
--    inner = vector_to_list(st.inner)
--    outer = vector_to_list(st.outer)
--    return SkewTableau(expr=[[inner[y] for y in range(len(outer))],
--                             [[st.matrix[x + y * st.cols] + 1
--                                for x in range(inner[y], outer[y])]
--                              for y in range(len(outer) - 1, -1, -1)]])
--
--
--def test_skewtab_to_SkewTableau(outer, inner):
--    """
--    A wrapper function for the cdef function ``skewtab_to_SkewTableau``
--    for testing purposes.
--
--    It constructs the first LR skew tableau of shape ``outer/inner``
--    as an ``lrcalc`` ``skewtab``, and converts it to a
--    :class:`SkewTableau`.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
--        sage: test_skewtab_to_SkewTableau([3,2,1],[])
--        [[1, 1, 1], [2, 2], [3]]
--        sage: test_skewtab_to_SkewTableau([4,3,2,1],[1,1]).pp()
--        .  1  1  1
--        .  2  2
--        1  3
--        2
--    """
--    cdef vector* o = iterable_to_vector(outer)
--    cdef vector* i = iterable_to_vector(inner+[0]*(len(outer)-len(inner)))
--    cdef skewtab* st = st_new(o, i, NULL, 0)
--    return skewtab_to_SkewTableau(st)
--
--
--cdef dict sf_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary representing a Schur function. The keys are
--    partitions and the values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
-         sage: from sage.libs.lrcalc.lrcalc import mult
--        sage: sorted(mult([1],[1]).items())        #indirect doctest
--        [([1, 1], 1), ([2], 1)]
--        sage: assert isinstance(mult([1],[1]),dict)#indirect doctest
--    """
--    cdef hash_itr itr
--    cdef dict result = {}
--    cdef list p
--    hash_first(ht, itr)
--    while hash_good(itr):
--        p = vector_to_list(<vector*> hash_key(itr))
--        result[_Partitions(p)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
--
--cdef dict schubert_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary corresponding to a Schubert polynomial whose keys
--    are permutations and whose values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import mult_schubert
--        sage: mult_schubert([3,2,1], [1,2,3])      #indirect doctest
--        {[3, 2, 1]: 1}
--    """
--    cdef hash_itr itr
--    cdef dict result = {}
--    hash_first(ht, itr)
--    while hash_good(itr):
--        p = vector_to_list(<vector*> hash_key(itr))
--        result[Permutation(p)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
--
--cdef dict vp_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary corresponding to the coproduct of a Schur function whose keys are
--    pairs of partitions and whose values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import coprod
--        sage: coprod([1])      #indirect doctest
--        {([1], []): 1}
-+        sage: mult([2,1],[3,2,1],3) # indirect doctest
-+        {[3, 3, 3]: 1, [4, 3, 2]: 2, [4, 4, 1]: 1, [5, 2, 2]: 1, [5, 3, 1]: 1}
-     """
--    cdef hash_itr itr
--    cdef vecpair* vp
--    cdef dict result = {}
--    hash_first(ht, itr)
--    while hash_good(itr):
--        vp = <vecpair*> hash_key(itr)
--        p1 = _Partitions(vector_to_list(vp_first(vp)))
--        p2 = _Partitions(vector_to_list(vp_second(vp)))
--        result[(p1, p2)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
-+    return {_Partitions(la): Integer(k) for la, k in result.items()}
- 
- def lrcoef_unsafe(outer, inner1, inner2):
-     r"""
-@@ -371,13 +213,11 @@ def lrcoef_unsafe(outer, inner1, inner2):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
--
--    - ``inner1`` -- a partition.
-+    - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
-+    - ``inner1`` -- a partition
-+    - ``inner2`` -- a partition
- 
--    - ``inner2`` -- a partition.
--
--    .. warning::
-+    .. WARNING::
- 
-        This function does not do any check on its input.  If you want
-        to use a safer version, use :func:`lrcoef`.
-@@ -392,18 +232,7 @@ def lrcoef_unsafe(outer, inner1, inner2):
-         sage: lrcoef_unsafe([2,1,1,1,1], [2,1], [2,1])
-         0
-     """
--    cdef long long result
--    cdef vector *o
--    cdef vector *i1
--    cdef vector *i2
--    o = iterable_to_vector(outer)
--    i1 = iterable_to_vector(inner1)
--    i2 = iterable_to_vector(inner2)
--    result = lrcoef_c(o, i1, i2)
--    v_free(o)
--    v_free(i1)
--    v_free(i2)
--    return Integer(result)
-+    return Integer(lrcalc.lrcoef(outer, inner1, inner2))
- 
- 
- def lrcoef(outer, inner1, inner2):
-@@ -415,11 +244,9 @@ def lrcoef(outer, inner1, inner2):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
--
--    - ``inner1`` -- a partition.
--
--    - ``inner2`` -- a partition.
-+    - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
-+    - ``inner1`` -- a partition
-+    - ``inner2`` -- a partition
- 
-     .. NOTE::
- 
-@@ -436,7 +263,6 @@ def lrcoef(outer, inner1, inner2):
-         1
-         sage: lrcoef([2,1,1,1,1], [2,1], [2,1])
-         0
--
-     """
-     return lrcoef_unsafe(_Partitions(outer), _Partitions(inner1), _Partitions(inner2))
- 
-@@ -451,13 +277,9 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-     INPUT:
- 
-     - ``part1`` -- a partition
--
-     - ``part2`` -- a partition
--
-     - ``maxrows`` -- (optional) an integer
--
-     - ``level`` -- (optional) an integer
--
-     - ``quantum`` -- (optional) an element of a ring
- 
-     If ``maxrows`` is specified, then only partitions with at most
-@@ -479,7 +301,8 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-         sage: sorted(mult([2],[2]).items())
-         [([2, 2], 1), ([3, 1], 1), ([4], 1)]
-         sage: sorted(mult([2,1],[2,1]).items())
--        [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1), ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
-+        [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1),
-+         ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
-         sage: sorted(mult([2,1],[2,1],maxrows=2).items())
-         [([3, 3], 1), ([4, 2], 1)]
-         sage: mult([2,1],[3,2,1],3)
-@@ -510,44 +333,24 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-     if quantum is not None and (level is None or maxrows is None):
-         raise ValueError('missing parameters maxrows or level')
- 
--    cdef vector* v1 = iterable_to_vector(part1)
--    cdef vector* v2 = iterable_to_vector(part2)
--    if maxrows is None:
--        maxrows = 0
--    cdef hashtab* ht = mult_c(v1, v2, int(maxrows))
--    cdef hashtab* tab
--    cdef dict result
--
-     if quantum is None:
-         if level is not None:
--            fusion_reduce_c(ht, int(maxrows), int(level), int(0))
--        result = sf_hashtab_to_dict(ht)
--        v_free(v1)
--        v_free(v2)
--        hash_free(ht)
--        return result
-+            return _lrcalc_dict_to_sage(lrcalc.mult_fusion(part1, part2, maxrows, level))
-+        if maxrows is None:
-+            maxrows = -1
-+        return _lrcalc_dict_to_sage(lrcalc.mult(part1, part2, maxrows))
- 
-     # Otherwise do quantum multiplication
--    cdef _list *qlist
--    cdef dict temp
--    qlist = quantum_reduce_c(ht, int(maxrows), int(level))
--    # The above call frees the memory associated with ht
--    v_free(v1)
--    v_free(v2)
--
--    cdef Parent P = quantum.parent()
--    result = {}
--    for i in range(qlist.length):
--        tab = <hashtab*>(qlist.array[i])
--        temp = sf_hashtab_to_dict(tab)
--        for k in temp:
--            result[k] = result.get(k, P.zero()) + quantum**i * temp[k]
--        hash_free(tab)
--    l_free(qlist)
--    return result
--
--
--def skew(outer, inner, maxrows=0):
-+    result = lrcalc.mult_quantum(part1, part2, maxrows, level, degrees=True)
-+    P = quantum.parent()
-+    output = {}
-+    for i,k in result.items():
-+        la = _Partitions(i[0])
-+        output[la] = output.get(la, P.zero()) + k * quantum**(i[1])
-+    return output
-+
-+
-+def skew(outer, inner, maxrows=-1):
-     """
-     Compute the Schur expansion of a skew Schur function.
- 
-@@ -557,11 +360,9 @@ def skew(outer, inner, maxrows=0):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition.
--
--    - ``inner`` -- a partition.
--
--    - ``maxrows`` -- an integer or ``None``.
-+    - ``outer`` -- a partition
-+    - ``inner`` -- a partition
-+    - ``maxrows`` -- an integer or ``None``
- 
-     If ``maxrows`` is specified, then only partitions with at most
-     this number of rows are included in the result.
-@@ -572,14 +373,7 @@ def skew(outer, inner, maxrows=0):
-         sage: sorted(skew([2,1],[1]).items())
-         [([1, 1], 1), ([2], 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(outer)
--    cdef vector* v2 = iterable_to_vector(inner)
--    cdef hashtab* ht = skew_c(v1, v2, int(maxrows))
--    result = sf_hashtab_to_dict(ht)
--    v_free(v1)
--    v_free(v2)
--    hash_free(ht)
--    return result
-+    return _lrcalc_dict_to_sage(lrcalc.skew(outer, inner, maxrows))
- 
- 
- def coprod(part, all=0):
-@@ -592,9 +386,8 @@ def coprod(part, all=0):
- 
-     INPUT:
- 
--    - ``part`` -- a partition.
--
--    - ``all`` -- an integer.
-+    - ``part`` -- a partition
-+    - ``all`` -- an integer
- 
-     If ``all`` is non-zero then all terms are included in the result.
-     If ``all`` is zero, then only pairs of partitions ``(part1,
-@@ -609,12 +402,9 @@ def coprod(part, all=0):
-         sage: sorted(coprod([2,1]).items())
-         [(([1, 1], [1]), 1), (([2], [1]), 1), (([2, 1], []), 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(part)
--    cdef hashtab* ht = coprod_c(v1, int(all))
--    result = vp_hashtab_to_dict(ht)
--    v_free(v1)
--    hash_free(ht)
--    return result
-+    result = lrcalc.coprod(part, all)
-+    return {tuple([_Partitions(mu) for mu in la]): Integer(k)
-+            for la, k in result.items()}
- 
- 
- def mult_schubert(w1, w2, rank=0):
-@@ -627,11 +417,9 @@ def mult_schubert(w1, w2, rank=0):
- 
-     INPUT:
- 
--    - ``w1`` -- a permutation.
--
--    - ``w2`` -- a permutation.
--
--    - ``rank`` -- an integer.
-+    - ``w1`` -- a permutation
-+    - ``w2`` -- a permutation
-+    - ``rank`` -- an integer
- 
-     If ``rank`` is non-zero, then only permutations from the symmetric
-     group `S(\mathrm{rank})` are included in the result.
-@@ -646,33 +434,24 @@ def mult_schubert(w1, w2, rank=0):
-          ([6, 4, 3, 1, 2, 5], 1), ([6, 5, 2, 1, 3, 4], 1),
-          ([7, 3, 4, 1, 2, 5, 6], 1), ([7, 4, 2, 1, 3, 5, 6], 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(w1)
--    cdef vector* v2 = iterable_to_vector(w2)
--    cdef hashtab* ht = mult_schubert_c(v1, v2, int(rank))
--    result = schubert_hashtab_to_dict(ht)
--    v_free(v1)
--    v_free(v2)
--    hash_free(ht)
--    return result
-+    result = lrcalc.schubmult(w1, w2, rank)
-+    return {Permutation(list(la)):Integer(k) for la,k in result.items()}
- 
- 
--def lrskew(outer, inner, weight=None, maxrows=0):
-+def lrskew(outer, inner, weight=None, maxrows=-1):
-     r"""
-     Iterate over the skew LR tableaux of shape ``outer / inner``.
- 
-     INPUT:
- 
-     - ``outer`` -- a partition
--
-     - ``inner`` -- a partition
--
-     - ``weight`` -- a partition (optional)
--
--    - ``maxrows`` -- an integer (optional)
-+    - ``maxrows`` -- a positive integer (optional)
- 
-     OUTPUT: an iterator of :class:`SkewTableau`
- 
--    Specifying ``maxrows`` restricts the alphabet to `\{1,2,\ldots,maxrows\}`.
-+    Specifying ``maxrows`` = `M` restricts the alphabet to `\{1,2,\ldots,M\}`.
- 
-     Specifying ``weight`` returns only those tableaux of given content/weight.
- 
-@@ -702,22 +481,40 @@ def lrskew(outer, inner, weight=None, maxrows=0):
- 
-         sage: list(lrskew([3,2,1],[2], weight=[3,1]))
-         [[[None, None, 1], [1, 1], [2]]]
-+
-+    TESTS::
-+
-+        sage: from sage.libs.lrcalc.lrcalc import lrskew
-+        sage: list(lrskew([3,2,1],[2], weight=[]))
-+        []
-+        sage: list(lrskew([3,2,1],[2], weight=[0]))
-+        []
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[]))
-+        [[[None, None, None], [None, None], [None]]]
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[0]))
-+        [[[None, None, None], [None, None], [None]]]
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[1]))
-+        []
-     """
--    cdef vector* o = iterable_to_vector(outer)
--    cdef vector* i = iterable_to_vector(inner + [0]*(len(outer) - len(inner)))
--    cdef skewtab* st = st_new(o, i, NULL, int(maxrows))
-+    iterator = lrcalc.lr_iterator(outer, inner, maxrows)
-+    shape = SkewPartition([outer, inner])
- 
-     if weight is None:
--        yield skewtab_to_SkewTableau(st)
--        while st_next(st):
--            yield skewtab_to_SkewTableau(st)
-+        ST = SemistandardSkewTableaux(shape)
-+        for data in iterator:
-+            yield ST.from_shape_and_word(shape, [i+1 for i in data])
-     else:
-         wt = _Partitions(weight)
--        r = skewtab_to_SkewTableau(st)
--        if r.weight() == wt:
--            yield r
--        while st_next(st):
--            r = skewtab_to_SkewTableau(st)
--            if r.weight() == wt:
--                yield r
--    st_free(st)
-+        ST = SemistandardSkewTableaux(shape, wt)
-+        m = len(wt)
-+        for data in iterator:
-+            w = [0] * m
-+            for j in data:
-+                if j >= m:
-+                    # We know they are not equal, so make the check below quick
-+                    w = None
-+                    break
-+                w[j] += 1
-+            if w == wt:
-+                yield ST.from_shape_and_word(shape, [i+1 for i in data])
-+
diff --git a/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch b/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
deleted file mode 100644
index 1e2e0ba90742..000000000000
--- a/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-As produced by `git diff a90a3146{^^,}`
-
-diff --git a/src/sage/repl/interface_magic.py b/src/sage/repl/interface_magic.py
-index 8a455b69b0e..a93e1c9e04c 100644
---- a/src/sage/repl/interface_magic.py
-+++ b/src/sage/repl/interface_magic.py
-@@ -260,7 +260,7 @@ class InterfaceMagic(object):
-             2
-             120
-             sage: shell.run_cell('%%gap foo\n1+1;\n')
--            ...File "<string>", line unknown
-+            ...File...<string>...
-             SyntaxError: Interface magics have no options, got "foo"
-             <BLANKLINE>
-             sage: shell.run_cell('%%gap?')
-diff --git a/src/sage/repl/interpreter.py b/src/sage/repl/interpreter.py
-index 7468afe52d7..06c47b7374a 100644
---- a/src/sage/repl/interpreter.py
-+++ b/src/sage/repl/interpreter.py
-@@ -78,9 +78,9 @@ Check that Cython source code appears in tracebacks::
-     dummy line
-     ...
-     ZeroDivisionError...Traceback (most recent call last)
--    <ipython-input-...> in <module>...
-+    ...in <module>...
-     ----> 1 Integer(1)/Integer(0)
--    .../sage/rings/integer.pyx in sage.rings.integer.Integer...div...
-+    .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
-     ...
-     -> ...                  raise ZeroDivisionError("rational division by zero")
-        ....:            x = <Rational> Rational.__new__(Rational)
-@@ -423,7 +423,7 @@ def SagePreparseTransformer(lines):
-         sage: from sage.repl.interpreter import get_test_shell
-         sage: shell = get_test_shell()
-         sage: shell.run_cell(bad_syntax)
--          File "<string>", line unknown
-+          File...<string>...
-         SyntaxError: Mismatched ']'
-         <BLANKLINE>
-         sage: shell.quit()
diff --git a/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch b/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
deleted file mode 100644
index 853813b0f5bd..000000000000
--- a/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Fix for ipython 8.1
-
---- a/src/sage/repl/interpreter.py
-+++ b/src/sage/repl/interpreter.py
-@@ -78,7 +78,7 @@ Check that Cython source code appears in tracebacks::
-     dummy line
-     ...
-     ZeroDivisionError...Traceback (most recent call last)
--    ...in <module>...
-+    ...
-     ----> 1 Integer(1)/Integer(0)
-     .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
-     ...
diff --git a/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch b/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
deleted file mode 100644
index b861af7ec982..000000000000
--- a/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
+++ /dev/null
@@ -1,126 +0,0 @@
-From 24cc94b1988a90f3bd22a2368ec30c086283af13 Mon Sep 17 00:00:00 2001
-From: Antonio Rojas <arojas@archlinux.org>
-Date: Sun, 16 Jan 2022 11:55:04 +0100
-Subject: Add abs tol to some arb tests
-
----
- src/sage/functions/error.py    |  2 +-
- src/sage/rings/complex_arb.pyx |  6 +++---
- src/sage/rings/real_arb.pyx    | 10 +++++-----
- 3 files changed, 9 insertions(+), 9 deletions(-)
-
-diff --git a/src/sage/functions/error.py b/src/sage/functions/error.py
-index f48d04f..06f0b24 100644
---- a/src/sage/functions/error.py
-+++ b/src/sage/functions/error.py
-@@ -267,7 +267,7 @@ class Function_erf(BuiltinFunction):
- 
-         Check that real ball evaluation is fixed :trac:`28061`::
- 
--            sage: RealBallField(128)(erf(5))
-+            sage: RealBallField(128)(erf(5)) # abs tol 1e-38
-             [0.99999999999846254020557196514981165651 +/- 7.33e-39]
-         """
-         R = parent or s_parent(x)
-diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
-index f986970..93ff565 100644
---- a/src/sage/rings/complex_arb.pyx
-+++ b/src/sage/rings/complex_arb.pyx
-@@ -3974,8 +3974,8 @@ cdef class ComplexBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: CBF(20).erfc()
--            [5.39586561160790e-176 +/- ...e-191]
-+            sage: CBF(20).erfc() # abs tol 1e-190
-+            [5.39586561160790e-176 +/- 6.73e-191]
-             sage: CBF(100, 100).erfc()
-             [0.00065234366376858 +/- ...e-18] + [-0.00393572636292141 +/- ...e-18]*I
-         """
-@@ -4280,7 +4280,7 @@ cdef class ComplexBall(RingElement):
- 
-         TESTS:
- 
--            sage: CBF(Shi(I))
-+            sage: CBF(Shi(I)) # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]*I
-         """
-         cdef ComplexBall result = self._new()
-diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
-index 4a81784..292bfea 100644
---- a/src/sage/rings/real_arb.pyx
-+++ b/src/sage/rings/real_arb.pyx
-@@ -3506,7 +3506,7 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1/2).erf()
-+            sage: RBF(1/2).erf() # abs tol 1e-16
-             [0.520499877813047 +/- 6.10e-16]
-         """
-         cdef RealBall res = self._new()
-@@ -3556,12 +3556,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Si()
-+            sage: RBF(1).Si() # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]
- 
-         TESTS::
- 
--            sage: RBF(Si(1))
-+            sage: RBF(Si(1)) # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]
-         """
-         cdef RealBall res = self._new()
-@@ -3578,12 +3578,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Ci()  # abs tol 1e-16
-+            sage: RBF(1).Ci()  # abs tol 1e-15
-             [0.337403922900968 +/- 3.25e-16]
- 
-         TESTS::
- 
--            sage: RBF(Ci(1))  # abs tol 1e-16
-+            sage: RBF(Ci(1))  # abs tol 1e-15
-             [0.337403922900968 +/- 3.25e-16]
-         """
-         cdef RealBall res = self._new()
--- 
-cgit v1.0-1-gd88e
-
-
-From 53532ddd4e2dc92469c1590ebf0c40f8f69bf579 Mon Sep 17 00:00:00 2001
-From: Antonio Rojas <arojas@archlinux.org>
-Date: Sun, 16 Jan 2022 14:16:53 +0100
-Subject: Decrease abs tol
-
----
- src/sage/rings/real_arb.pyx | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
-index 292bfea..eb30f7f 100644
---- a/src/sage/rings/real_arb.pyx
-+++ b/src/sage/rings/real_arb.pyx
-@@ -3578,12 +3578,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Ci()  # abs tol 1e-15
-+            sage: RBF(1).Ci()  # abs tol 5e-16
-             [0.337403922900968 +/- 3.25e-16]
- 
-         TESTS::
- 
--            sage: RBF(Ci(1))  # abs tol 1e-15
-+            sage: RBF(Ci(1))  # abs tol 5e-16
-             [0.337403922900968 +/- 3.25e-16]
-         """
-         cdef RealBall res = self._new()
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch b/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
deleted file mode 100644
index d4e8f8be60e3..000000000000
--- a/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From 33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c Mon Sep 17 00:00:00 2001
-From: Michael Orlitzky <michael@orlitzky.com>
-Date: Mon, 24 Jan 2022 09:03:29 -0500
-Subject: Trac #33226: update doctests for giac-1.7.0.45.
-
-We have two failing doctests with giac-1.7.0.45: one is a trivial
-tolerance issue, but the other is a symbolic integration result for
-which giac is no longer willing to return a symbolic answer. We add
-"abs tol" to the numeric test, and drop the symbolic one entirely.
----
- src/sage/functions/min_max.py | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/src/sage/functions/min_max.py b/src/sage/functions/min_max.py
-index fc18373..9b7d6d9 100644
---- a/src/sage/functions/min_max.py
-+++ b/src/sage/functions/min_max.py
-@@ -228,15 +228,15 @@ class MaxSymbolic(MinMax_base):
-             ...
-             TypeError: cannot evaluate symbolic expression numerically
- 
--        ::
-+        We can usually integrate these expressions, but can't
-+        guarantee a symbolic answer in closed form::
- 
-             sage: f = max_symbolic(sin(x), cos(x))
-             sage: r = integral(f, x, 0, 1)
-             ...
--            sage: r
--            sqrt(2) - cos(1)
--            sage: r.n()
-+            sage: r.n()  # abs tol 1e-8
-             0.873911256504955
-+
-         """
-         return max_symbolic(args)
- 
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch b/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
deleted file mode 100644
index 19b69700a4f6..000000000000
--- a/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-commit 9c8235e44ffb509efa8a3ca6cdb55154e2b5066d
-Author: Antonio Rojas <arojas@archlinux.org>
-Date:   Sun Feb 13 19:53:14 2022 +0100
-
-    Fix deprecation warning with scipy 1.8
-
-diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-index e9b60dae5ec..7932167b41d 100644
---- a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-@@ -356,7 +356,7 @@ Sage example in ./linsolve.tex, line 2230::
- 
- Sage example in ./linsolve.tex, line 2609::
- 
--  sage: from scipy.sparse.linalg.dsolve import *
-+  sage: from scipy.sparse.linalg import factorized
-   sage: from scipy.sparse import lil_matrix
-   sage: from numpy import array
-   sage: n = 200
diff --git a/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch b/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
new file mode 100644
index 000000000000..e052e306e7a1
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
@@ -0,0 +1,53 @@
+From 6330cee1a69229b2f5d8ac4a09a73d8152f5e14d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Mon, 28 Feb 2022 23:15:16 -0300
+Subject: trac 33360: avoid factoring in is_prime()
+
+In the added TEST, the ideal norm is product of two primes but factoring
+this product takes about half an hour, so factoring the ideal is slow.
+
+To fix the issue, we only factor the ideal if the norm is a prime power.
+---
+ src/sage/rings/number_field/number_field_ideal.py | 22 ++++++++++++++++++++++
+ 1 file changed, 22 insertions(+)
+
+diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
+index f785f22..10d1f88 100644
+--- a/src/sage/rings/number_field/number_field_ideal.py
++++ b/src/sage/rings/number_field/number_field_ideal.py
+@@ -995,10 +995,32 @@ class NumberFieldIdeal(Ideal_generic):
+             False
+             sage: K.ideal(17).is_prime()  # ramified
+             False
++
++        TESTS::
++
++        Check that we do not factor the norm of the ideal, this used
++        to take half an hour, see :trac:`33360`
++
++           sage: K.<a,b,c> = NumberField([x^2-2,x^2-3,x^2-5])
++           sage: t = (((-2611940*c + 1925290/7653)*b - 1537130/7653*c
++           ....:       + 10130950)*a + (1343014/7653*c - 8349770)*b
++           ....:       + 6477058*c - 2801449990/4002519)
++           sage: t.is_prime()
++           False
++
+         """
+         try:
+             return self._pari_prime is not None
+         except AttributeError:
++            K = self.number_field().pari_nf()
++            I = self.pari_hnf()
++            # This would be better, but it is broken in pari 2.13.3.
++            #   self._pari_prime = K.idealismaximal(I) or None
++            # Instead we factor I, but only if the norm is a prime power
++            n = K.idealnorm(I)
++            if n.denominator() > 1 or not n.isprimepower():
++                self._pari_prime = None
++                return False
+             F = self.factor()  # factorization with caching
+             if len(F) != 1 or F[0][1] != 1:
+                 self._pari_prime = None
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
deleted file mode 100644
index 9ba7ca5a6b7d..000000000000
--- a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
+++ /dev/null
@@ -1,99 +0,0 @@
-From 609dd9deaeaa6380ab2f0d50276d911233c00a04 Mon Sep 17 00:00:00 2001
-From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
-Date: Fri, 4 Mar 2022 16:07:09 -0800
-Subject: sage.manifolds: Update doctests for SymPy 1.10
-
----
- src/sage/manifolds/continuous_map.py              | 3 +--
- src/sage/manifolds/differentiable/diff_form.py    | 4 ++--
- src/sage/manifolds/differentiable/tensorfield.py  | 8 ++++----
- src/sage/manifolds/vector_bundle_fiber_element.py | 2 +-
- 4 files changed, 8 insertions(+), 9 deletions(-)
-
-diff --git a/src/sage/manifolds/continuous_map.py b/src/sage/manifolds/continuous_map.py
-index a6356e7..f6f9b6d 100644
---- a/src/sage/manifolds/continuous_map.py
-+++ b/src/sage/manifolds/continuous_map.py
-@@ -1357,8 +1357,7 @@ class ContinuousMap(Morphism):
-             sage: Phi.coord_functions(c_uv, c_xyz)
-             Coordinate functions (u*v, u/v, u + v) on the Chart (M, (u, v))
-             sage: Phi.coord_functions(c_UV, c_xyz)
--            Coordinate functions (-U**2/4 + V**2/4, -(U + V)/(U - V), V)
--             on the Chart (M, (U, V))
-+            Coordinate functions (-U**2/4 + V**2/4, (-U - V)/(U - V), V) on the Chart (M, (U, V))
-             sage: Phi.coord_functions(c_UV, c_XYZ)
-             Coordinate functions ((-U**3 + U**2*V + U*V**2 + 2*U*V + 6*U - V**3
-              - 2*V**2 + 6*V)/(2*(U - V)), (U**3/4 - U**2*V/4 - U*V**2/4 + U*V
-diff --git a/src/sage/manifolds/differentiable/diff_form.py b/src/sage/manifolds/differentiable/diff_form.py
-index 70dd8fb..0aa3469 100644
---- a/src/sage/manifolds/differentiable/diff_form.py
-+++ b/src/sage/manifolds/differentiable/diff_form.py
-@@ -266,7 +266,7 @@ class DiffForm(TensorField):
- 
-         sage: s = a.wedge(b)
-         sage: s.display(eU)
--        a∧b = -x*(2*x*y + 1) dx∧dy
-+        a∧b = x*(-2*x*y - 1) dx∧dy
-         sage: s.display(eV)
-         a∧b = (u**3/8 + u**2*v/8 - u*v**2/8 + u/4 - v**3/8 + v/4) du∧dv
- 
-@@ -275,7 +275,7 @@ class DiffForm(TensorField):
-         sage: f = M.scalar_field({c_xy: (x+y)^2, c_uv: u^2}, name='f')
-         sage: s = f*a
-         sage: s.display(eU)
--        f*a = -y*(x**2 + 2*x*y + y**2) dx + x*(x**2 + 2*x*y + y**2) dy
-+        f*a = y*(-x**2 - 2*x*y - y**2) dx + x*(x**2 + 2*x*y + y**2) dy
-         sage: s.display(eV)
-         f*a = u**2*v/2 du - u**3/2 dv
- 
-diff --git a/src/sage/manifolds/differentiable/tensorfield.py b/src/sage/manifolds/differentiable/tensorfield.py
-index 2775be9..6bc5c50 100644
---- a/src/sage/manifolds/differentiable/tensorfield.py
-+++ b/src/sage/manifolds/differentiable/tensorfield.py
-@@ -334,7 +334,7 @@ class TensorField(ModuleElementWithMutability):
-         sage: f.display()  # long time
-         t(a,b): S^2 → ℝ
-         on U: (x, y) ↦ -2*x*y - 3*x - y**2
--        on V: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+        on V: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
- 
-     The vectors can be defined only on subsets of `S^2`, the domain of the
-     result is then the common subset::
-@@ -343,12 +343,12 @@ class TensorField(ModuleElementWithMutability):
-         sage: s.display()  # long time
-         t(a,b): U → ℝ
-            (x, y) ↦ -2*x*y - 3*x - y**2
--        on W: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+        on W: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
-         sage: s = t(a.restrict(U), b.restrict(W))  # long time
-         sage: s.display()  # long time
-         t(a,b): W → ℝ
-            (x, y) ↦ -2*x*y - 3*x - y**2
--           (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+           (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
- 
-     The tensor itself can be defined only on some open subset of `S^2`,
-     yielding a result whose domain is this subset::
-@@ -356,7 +356,7 @@ class TensorField(ModuleElementWithMutability):
-         sage: s = t.restrict(V)(a,b)  # long time
-         sage: s.display()  # long time
-         t(a,b): V → ℝ
--           (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+           (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
-         on W: (x, y) ↦ -2*x*y - 3*x - y**2
- 
-     Tests regarding the multiplication by a scalar field::
-diff --git a/src/sage/manifolds/vector_bundle_fiber_element.py b/src/sage/manifolds/vector_bundle_fiber_element.py
-index 29ee81d..048275a 100644
---- a/src/sage/manifolds/vector_bundle_fiber_element.py
-+++ b/src/sage/manifolds/vector_bundle_fiber_element.py
-@@ -110,4 +110,4 @@ class VectorBundleFiberElement(FiniteRankFreeModuleElement):
-             desc += str(self._name) + " "
-         desc += "in the fiber of {} at {}".format(self._vbundle._name,
-                                                   self._point)
--        return desc
-\ No newline at end of file
-+        return desc
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
deleted file mode 100644
index f5ac180baa90..000000000000
--- a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From c49eff347454ac7f07e5918470b20e97b8f2357e Mon Sep 17 00:00:00 2001
-From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
-Date: Fri, 4 Mar 2022 15:14:43 -0800
-Subject: src/sage/calculus/calculus.py: Update laplace doctest for sympy 1.10
-
----
- src/sage/calculus/calculus.py | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/src/sage/calculus/calculus.py b/src/sage/calculus/calculus.py
-index 9c2f226..b335093 100644
---- a/src/sage/calculus/calculus.py
-+++ b/src/sage/calculus/calculus.py
-@@ -1639,9 +1639,9 @@ def laplace(ex, t, s, algorithm='maxima'):
-         sage: laplace(dirac_delta(t), t, s)
-         1
-         sage: F, a, cond = laplace(dirac_delta(t), t, s, algorithm='sympy')
--        sage: a, cond
--        (-oo, True)
--        sage: F       # random - sympy <1.9 includes undefined heaviside(0) in answer
-+        sage: a, cond  # random - sympy <1.10 gives (-oo, True)
-+        (0, True)
-+        sage: F        # random - sympy <1.9 includes undefined heaviside(0) in answer
-         1
-         sage: laplace(dirac_delta(t), t, s, algorithm='giac')
-         1
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33446-make_GAP_SO_unnecessary-31e3fc4ec8b8687bccd22d2e3161c86cf5553e06.patch b/srcpkgs/sagemath/patches/trac-33446-make_GAP_SO_unnecessary-31e3fc4ec8b8687bccd22d2e3161c86cf5553e06.patch
new file mode 100644
index 000000000000..fb9e0f5a8071
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-33446-make_GAP_SO_unnecessary-31e3fc4ec8b8687bccd22d2e3161c86cf5553e06.patch
@@ -0,0 +1,427 @@
+From 9feec282d039ca25bbefa50710f8217b775ce111 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Thu, 3 Mar 2022 14:47:00 -0300
+Subject: gap: do not directly dlopen() the gap library
+
+This needs the soname (as in sage.env.GAP_SO) which has issues for
+system gap as explained in #33446.
+
+Instead we dlopen() the extension module sage.libs.gap.util which,
+having a link time dependency to libgap, will indirectly dlopen() it.
+
+For the record: by the time we run dlopen() the libgap should be already
+loaded. The purpose of doing it is to change mode to RTLD_GLOBAL so that
+symbols in libgap are placed in the global symbol table. This is
+required to compiled load gap packages.
+
+An easy test that this is working ok is:
+
+    sage: libgap.LoadPackage("io")
+    true
+
+This requires optional spkg `gap_packages` to be installed.
+---
+ src/sage/libs/gap/util.pyx | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/src/sage/libs/gap/util.pyx b/src/sage/libs/gap/util.pyx
+index 344ab88..aff604b 100644
+--- a/src/sage/libs/gap/util.pyx
++++ b/src/sage/libs/gap/util.pyx
+@@ -13,7 +13,7 @@ Utility functions for GAP
+ #*****************************************************************************
+ 
+ from libc.signal cimport signal, SIGCHLD, SIG_DFL
+-from posix.dlfcn cimport dlopen, dlclose, RTLD_NOW, RTLD_GLOBAL
++from posix.dlfcn cimport dlopen, dlclose, dlerror, RTLD_LAZY, RTLD_GLOBAL
+ 
+ from cpython.exc cimport PyErr_Fetch, PyErr_Restore
+ from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE
+@@ -232,12 +232,12 @@ cdef initialize():
+     # this isn't portable
+ 
+     cdef void* handle
+-    libgapname = str_to_bytes(sage.env.GAP_SO)
+-    handle = dlopen(libgapname, RTLD_NOW | RTLD_GLOBAL)
++    # reload the current module to force reload of libgap (see #33446)
++    lib = str_to_bytes(__loader__.path, FS_ENCODING, "surrogateescape")
++    handle = dlopen(lib, RTLD_GLOBAL|RTLD_LAZY)
+     if handle is NULL:
+-        raise RuntimeError(
+-                "Could not dlopen() libgap even though it should already "
+-                "be loaded!")
++        err = dlerror()
++        raise RuntimeError(f"Could not reload gap library with RTLD_GLOBAL ({err})")
+     dlclose(handle)
+ 
+     # Define argv variable, which we will pass in to
+-- 
+cgit v1.0-1-gd88e
+
+
+From 704a7953b97ab726e2af610724726aa562bc8bf8 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Thu, 3 Mar 2022 23:00:07 -0300
+Subject: singular: do not directly dlopen() the singular library
+
+Same as for gap in the previous commit. Instead of requiring the soname
+(as in sage.env.LIBSINGULAR_PATH) we dlopen() the extension module
+sage.libs.singular.singular which will indirectly dlopen() libSingular.
+---
+ src/sage/libs/singular/singular.pyx | 15 ++++-----------
+ 1 file changed, 4 insertions(+), 11 deletions(-)
+
+diff --git a/src/sage/libs/singular/singular.pyx b/src/sage/libs/singular/singular.pyx
+index d8ea7b0..4beb177 100644
+--- a/src/sage/libs/singular/singular.pyx
++++ b/src/sage/libs/singular/singular.pyx
+@@ -1705,14 +1705,7 @@ cdef object si2sa_intvec(intvec *v):
+ cdef extern from *: # hack to get at cython macro
+     int unlikely(int)
+ 
+-cdef extern from "dlfcn.h":
+-    void *dlopen(char *, long)
+-    char *dlerror()
+-    void dlclose(void *handle)
+-
+-cdef extern from "dlfcn.h":
+-    cdef long RTLD_LAZY
+-    cdef long RTLD_GLOBAL
++from posix.dlfcn cimport dlopen, dlclose, dlerror, RTLD_LAZY, RTLD_GLOBAL
+ 
+ cdef int overflow_check(unsigned long e, ring *_ring) except -1:
+     """
+@@ -1762,8 +1755,6 @@ cdef init_libsingular():
+ 
+     cdef void *handle = NULL
+ 
+-    from sage.env import LIBSINGULAR_PATH
+-    lib = str_to_bytes(LIBSINGULAR_PATH, FS_ENCODING, "surrogateescape")
+ 
+     # This is a workaround for https://github.com/Singular/Singular/issues/1113
+     # and can be removed once that fix makes it into release of Singular that
+@@ -1780,10 +1771,12 @@ cdef init_libsingular():
+ 
+     import platform
+     if not platform.system().startswith("CYGWIN"):
++        # reload the current module to force reload of libSingular (see #33446)
++        lib = str_to_bytes(__loader__.path, FS_ENCODING, "surrogateescape")
+         handle = dlopen(lib, RTLD_GLOBAL|RTLD_LAZY)
+         if not handle:
+             err = dlerror()
+-            raise ImportError(f"cannot load Singular library from {LIBSINGULAR_PATH} ({err})")
++            raise RuntimeError(f"Could not reload Singular library with RTLD_GLOBAL ({err})")
+ 
+     # load SINGULAR
+     siInit(lib)
+-- 
+cgit v1.0-1-gd88e
+
+
+From d7145c14ef58acfbe00d8f941d2802e96ad4ba15 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Fri, 4 Mar 2022 16:37:34 -0300
+Subject: singular: remove LIBSINGULAR_PATH, no longer needed
+
+---
+ build/pkgs/singular/spkg-configure.m4 | 63 +----------------------------------
+ pkgs/sage-conf/_sage_conf/_conf.py.in |  3 --
+ src/sage/env.py                       |  6 ----
+ 3 files changed, 1 insertion(+), 71 deletions(-)
+
+diff --git a/build/pkgs/singular/spkg-configure.m4 b/build/pkgs/singular/spkg-configure.m4
+index af2eb85..6d3d3da 100644
+--- a/build/pkgs/singular/spkg-configure.m4
++++ b/build/pkgs/singular/spkg-configure.m4
+@@ -9,52 +9,7 @@ SAGE_SPKG_CONFIGURE([singular], [
+        AC_MSG_CHECKING([that Singular's help is working])
+        AS_IF([test x`printf "system(\"--browser\", \"builtin\"); \n help;" | Singular 2>&1 | grep "error\ occurred"` = x], [
+         AC_MSG_RESULT(yes)
+-        dnl We have Singular. Now determine the shared library path on
+-        dnl platforms on which sage.libs.singular needs to reload the library with RTLD_GLOBAL.
+-        AS_CASE([$host_os],
+-          [cygwin*], [dnl Nothing to do
+-                     ],
+-                     [dnl Use pkg-config to get singular's libdir while we're at it. As a
+-                      dnl moral compromise for using pkg-config, this ultimately allows us
+-                      dnl to pass an absolute path to dlopen(), which is the only approach
+-                      dnl that POSIX guarantees will work.
+-                      PKG_CHECK_VAR([SINGULAR_LIB_DIR], [Singular], [libdir])
+-                      dnl The acl_shlibext variable is set in the top-level configure.ac.
+-                      AC_LANG_PUSH(C)
+-                      ORIG_LIBS="${LIBS}"
+-                      LIBS="${LIBS} -ldl"
+-                      AC_MSG_CHECKING([if we can dlopen($LIBSINGULAR_PATH)])
+-                      LIBSINGULAR_PATH="${SINGULAR_LIB_DIR}/libSingular.${acl_shlibext}"
+-
+-                      dnl if we can dlopen() it, substitute the name for sage_conf;
+-                      dnl otherwise, fall back to using the SPKG.
+-                      AC_RUN_IFELSE(
+-                        [AC_LANG_PROGRAM(
+-                          [[#include <dlfcn.h>]],
+-                          [[void* h = dlopen("${LIBSINGULAR_PATH}", RTLD_LAZY | RTLD_GLOBAL);
+-                            if (h == 0) { return 1; } else { return dlclose(h); }]]
+-                        )], [
+-                          AC_MSG_RESULT(yes)
+-                        ], [
+-                          dnl try Debian-specific name
+-                          LIBSINGULAR_PATH="${SINGULAR_LIB_DIR}/libsingular-Singular.${acl_shlibext}"
+-                          AC_RUN_IFELSE(
+-                           [AC_LANG_PROGRAM(
+-                             [[#include <dlfcn.h>]],
+-                             [[void* h = dlopen("${LIBSINGULAR_PATH}", RTLD_LAZY | RTLD_GLOBAL);
+-                               if (h == 0) { return 1; } else { return dlclose(h); }]]
+-                           )], [
+-                             AC_MSG_RESULT(yes)
+-                           ], [
+-                            AC_MSG_RESULT(no)
+-                            sage_spkg_install_singular=yes
+-                          ], [AC_MSG_RESULT(yes)])
+-                        ], [AC_MSG_RESULT(yes)])
+-
+-                      AC_LANG_POP()
+-                      LIBS="${ORIG_LIBS}"
+-                     ]
+-       )], [
++       ], [
+        AC_MSG_RESULT(no)
+        sage_spkg_install_singular=yes
+        ]
+@@ -64,20 +19,4 @@ SAGE_SPKG_CONFIGURE([singular], [
+       ])
+     ])
+   ])
+-],[],[],[
+-  dnl Post-check phase
+-  dnl We make the sage_conf substitutions here, because the "default"
+-  dnl substitution needs to be made even if we skipped the system-Singular
+-  dnl checks themselves.
+-  AS_IF([test "x${sage_spkg_install_singular}" = "xyes"], [
+-    AS_CASE([$host_os],
+-      [cygwin*], [dnl Nothing to do
+-                 ],
+-                 [dnl Set shared library path, needed for reloading the library with RTLD_GLOBAL
+-                  LIBSINGULAR_PATH="\$SAGE_LOCAL/lib/libSingular.${acl_shlibext}"
+-                 ]
+-    )
+-  ])
+-
+-  AC_SUBST(LIBSINGULAR_PATH, "${LIBSINGULAR_PATH}")
+ ])
+diff --git a/pkgs/sage-conf/_sage_conf/_conf.py.in b/pkgs/sage-conf/_sage_conf/_conf.py.in
+index 6cd28f5..d66bdb3 100644
+--- a/pkgs/sage-conf/_sage_conf/_conf.py.in
++++ b/pkgs/sage-conf/_sage_conf/_conf.py.in
+@@ -55,9 +55,6 @@ THREEJS_DIR = SAGE_LOCAL + "/share/threejs-sage"
+ OPENMP_CFLAGS = "@OPENMP_CFLAGS@"
+ OPENMP_CXXFLAGS = "@OPENMP_CXXFLAGS@"
+ 
+-# The full absolute path to the main Singular library.
+-LIBSINGULAR_PATH = "@LIBSINGULAR_PATH@".replace('$SAGE_LOCAL', SAGE_LOCAL)
+-
+ # Installation location of wheels. This is determined at configuration time
+ # and does not depend on the installation location of sage-conf.
+ SAGE_SPKG_WHEELS = "@SAGE_VENV@".replace('${SAGE_LOCAL}', SAGE_LOCAL) + "/var/lib/sage/wheels"
+diff --git a/src/sage/env.py b/src/sage/env.py
+index 911f34b..93f79de 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -229,12 +229,6 @@ NTL_LIBDIR = var("NTL_LIBDIR")
+ LIE_INFO_DIR = var("LIE_INFO_DIR", join(SAGE_LOCAL, "lib", "LiE"))
+ SINGULAR_BIN = var("SINGULAR_BIN") or "Singular"
+ 
+-# The path to libSingular, to be passed to dlopen(). This will
+-# typically be set to an absolute path in sage_conf, but the relative
+-# fallback path here works on systems where dlopen() searches the
+-# system's library locations.
+-LIBSINGULAR_PATH = var("LIBSINGULAR_PATH", "libSingular.so")
+-
+ # OpenMP
+ OPENMP_CFLAGS = var("OPENMP_CFLAGS", "")
+ OPENMP_CXXFLAGS = var("OPENMP_CXXFLAGS", "")
+-- 
+cgit v1.0-1-gd88e
+
+
+From 92e5a211c792f86f5325d601abfddf667da6a776 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Fri, 4 Mar 2022 15:49:26 -0300
+Subject: Revert "src/sage/interfaces/gap_workspace.py: Use hash of GAP_SO to
+ disambiguate the workspace file, not SAGE_LOCAL"
+
+This reverts commit a801e6d85bd420b60ea75b1671856eb43ac6b18b.
+
+See #33446.
+---
+ src/sage/interfaces/gap_workspace.py | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+diff --git a/src/sage/interfaces/gap_workspace.py b/src/sage/interfaces/gap_workspace.py
+index 33a87dd..953dc85 100644
+--- a/src/sage/interfaces/gap_workspace.py
++++ b/src/sage/interfaces/gap_workspace.py
+@@ -16,7 +16,7 @@ Support for (lib)GAP workspace files
+ import os
+ import time
+ import hashlib
+-from sage.env import DOT_SAGE, GAP_SO
++from sage.env import DOT_SAGE, SAGE_LOCAL
+ 
+ 
+ def gap_workspace_file(system="gap", name="workspace", dir=None):
+@@ -59,10 +59,7 @@ def gap_workspace_file(system="gap", name="workspace", dir=None):
+     if dir is None:
+         dir = os.path.join(DOT_SAGE, 'gap')
+ 
+-    if GAP_SO:
+-        h = hashlib.sha1(GAP_SO.encode('utf-8')).hexdigest()
+-    else:
+-        h = 'unknown'
++    h = hashlib.sha1(SAGE_LOCAL.encode('utf-8')).hexdigest()
+     return os.path.join(dir, '%s-%s-%s' % (system, name, h))
+ 
+ 
+-- 
+cgit v1.0-1-gd88e
+
+
+From b45e555b5711ae10d369b568333940c2aa771053 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Fri, 4 Mar 2022 16:38:49 -0300
+Subject: gap: remove GAP_SO, no longer needed
+
+---
+ src/sage/env.py | 75 ---------------------------------------------------------
+ 1 file changed, 75 deletions(-)
+
+diff --git a/src/sage/env.py b/src/sage/env.py
+index 93f79de..c16a094 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -249,81 +249,6 @@ if SAGE_GAP_MEMORY is not None:
+ SAGE_GAP_COMMAND = var('SAGE_GAP_COMMAND', _gap_cmd)
+ 
+ 
+-def _get_shared_lib_path(*libnames: str) -> Optional[str]:
+-    """
+-    Return the full path to a shared library file installed in
+-    ``$SAGE_LOCAL/lib`` or the directories associated with the
+-    Python sysconfig.
+-
+-    This can also be passed more than one library name (e.g. for cases where
+-    some library may have multiple names depending on the platform) in which
+-    case the first one found is returned.
+-
+-    This supports most *NIX variants (in which ``lib<libname>.so`` is found
+-    under ``$SAGE_LOCAL/lib``), macOS (same, but with the ``.dylib``
+-    extension), and Cygwin (under ``$SAGE_LOCAL/bin/cyg<libname>.dll``,
+-    or ``$SAGE_LOCAL/bin/cyg<libname>-*.dll`` for versioned DLLs).
+-
+-    For distributions like Debian that use a multiarch layout, we also try the
+-    multiarch lib paths (i.e. ``/usr/lib/<arch>/``).
+-
+-    This returns ``None`` if no matching library file could be found.
+-
+-    EXAMPLES::
+-
+-        sage: from sage.env import _get_shared_lib_path
+-        sage: "gap" in _get_shared_lib_path("gap")
+-        True
+-        sage: _get_shared_lib_path("an_absurd_lib") is None
+-        True
+-
+-    """
+-
+-    for libname in libnames:
+-        search_directories: List[Path] = []
+-        patterns: List[str] = []
+-        if sys.platform == 'cygwin':
+-            # Later down we take the first matching DLL found, so search
+-            # SAGE_LOCAL first so that it takes precedence
+-            if SAGE_LOCAL:
+-                search_directories.append(Path(SAGE_LOCAL) / 'bin')
+-            search_directories.append(Path(sysconfig.get_config_var('BINDIR')))
+-            # Note: The following is not very robust, since if there are multible
+-            # versions for the same library this just selects one more or less
+-            # at arbitrary. However, practically speaking, on Cygwin, there
+-            # will only ever be one version
+-            patterns = [f'cyg{libname}.dll', f'cyg{libname}-*.dll']
+-        else:
+-            if sys.platform == 'darwin':
+-                ext = 'dylib'
+-            else:
+-                ext = 'so'
+-
+-            if SAGE_LOCAL:
+-                search_directories.append(Path(SAGE_LOCAL) / 'lib')
+-            libdir = sysconfig.get_config_var('LIBDIR')
+-            if libdir is not None:
+-                libdir = Path(libdir)
+-                search_directories.append(libdir)
+-
+-                multiarchlib = sysconfig.get_config_var('MULTIARCH')
+-                if multiarchlib is not None:
+-                    search_directories.append(libdir / multiarchlib),
+-
+-            patterns = [f'lib{libname}.{ext}']
+-
+-        for directory in search_directories:
+-            for pattern in patterns:
+-                path = next(directory.glob(pattern), None)
+-                if path is not None:
+-                    return str(path.resolve())
+-
+-    # Just return None if no files were found
+-    return None
+-
+-# locate libgap shared object
+-GAP_SO = var("GAP_SO", _get_shared_lib_path("gap", ""))
+-
+ # post process
+ if DOT_SAGE is not None and ' ' in DOT_SAGE:
+     if UNAME[:6] == 'CYGWIN':
+-- 
+cgit v1.0-1-gd88e
+
+
+From 31e3fc4ec8b8687bccd22d2e3161c86cf5553e06 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Sun, 6 Mar 2022 12:10:37 -0300
+Subject: gap_workspace_file: include hostname and gap version
+
+---
+ src/sage/interfaces/gap_workspace.py | 11 ++++++++---
+ 1 file changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/src/sage/interfaces/gap_workspace.py b/src/sage/interfaces/gap_workspace.py
+index 953dc85..8c03b6b 100644
+--- a/src/sage/interfaces/gap_workspace.py
++++ b/src/sage/interfaces/gap_workspace.py
+@@ -16,7 +16,8 @@ Support for (lib)GAP workspace files
+ import os
+ import time
+ import hashlib
+-from sage.env import DOT_SAGE, SAGE_LOCAL
++import subprocess
++from sage.env import DOT_SAGE, SAGE_LOCAL, HOSTNAME, GAP_ROOT_DIR
+ 
+ 
+ def gap_workspace_file(system="gap", name="workspace", dir=None):
+@@ -59,8 +60,12 @@ def gap_workspace_file(system="gap", name="workspace", dir=None):
+     if dir is None:
+         dir = os.path.join(DOT_SAGE, 'gap')
+ 
+-    h = hashlib.sha1(SAGE_LOCAL.encode('utf-8')).hexdigest()
+-    return os.path.join(dir, '%s-%s-%s' % (system, name, h))
++    data = SAGE_LOCAL
++    sysinfo = os.path.join(GAP_ROOT_DIR, "sysinfo.gap")
++    if os.path.exists(sysinfo):
++        data += subprocess.getoutput(f'. "{sysinfo}" && echo ":$GAP_VERSION:$GAParch"')
++    h = hashlib.sha1(data.encode('utf-8')).hexdigest()
++    return os.path.join(dir, '%s-%s-%s-%s' % (system, name, HOSTNAME, h))
+ 
+ 
+ def prepare_workspace_dir(dir=None):
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch b/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
deleted file mode 100644
index 8e7bb64f5b01..000000000000
--- a/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From a04a0a0b14f67f4804e7113c3db41bbcf8a58296 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
-Date: Mon, 28 Mar 2022 20:39:59 -0300
-Subject: Trac #33585: fix doctest when dochtml is missing...
-
-...but sphinx is available in PYTHONPATH.
----
- src/sage/misc/sagedoc.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/sage/misc/sagedoc.py b/src/sage/misc/sagedoc.py
-index 4b3853f..08c4225 100644
---- a/src/sage/misc/sagedoc.py
-+++ b/src/sage/misc/sagedoc.py
-@@ -1401,7 +1401,7 @@ class _sage_doc:
-             "...**File:**...**Type:**...**Definition:** identity_matrix..."
-             sage: identity_matrix.__doc__ in browse_sage_doc(identity_matrix, 'rst')
-             True
--            sage: browse_sage_doc(identity_matrix, 'html', False)             # optional - sphinx
-+            sage: browse_sage_doc(identity_matrix, 'html', False)             # optional - sphinx sagemath_doc_html
-             '...div...File:...Type:...Definition:...identity_matrix...'
- 
-         In the 'text' version, double colons have been replaced with
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33842-python-3.11.patch b/srcpkgs/sagemath/patches/trac-33842-python-3.11.patch
new file mode 100644
index 000000000000..eafe76bfb794
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-33842-python-3.11.patch
@@ -0,0 +1,45 @@
+--- a/src/sage/cpython/cython_metaclass.h
++++ b/src/sage/cpython/cython_metaclass.h
+@@ -66,7 +66,7 @@
+         }
+ 
+         /* Now, set t.__class__ to metaclass */
+-        Py_TYPE(t) = metaclass;
++        Py_SET_TYPE(t, metaclass);
+         PyType_Modified(t);
+     }
+     else
+--- a/src/sage/symbolic/ginac/numeric.cpp
++++ b/src/sage/symbolic/ginac/numeric.cpp
+@@ -52,7 +52,6 @@
+ #define register
+ #define PY_SSIZE_T_CLEAN
+ #include <Python.h>
+-#include <longintrepr.h>
+ #include "flint/fmpz.h"
+ #include "flint/fmpz_factor.h"
+ 
+--- a/src/sage/libs/gmp/pylong.pyx
++++ b/src/sage/libs/gmp/pylong.pyx
+@@ -32,7 +32,7 @@
+ from .mpz cimport *
+ 
+ cdef extern from *:
+-    Py_ssize_t* Py_SIZE_PTR "&Py_SIZE"(object)
++    void Py_SET_SIZE(object, Py_ssize_t)
+     int hash_bits """
+         #ifdef _PyHASH_BITS
+         _PyHASH_BITS         /* Python 3 */
+@@ -57,10 +57,8 @@
+     mpz_export(L.ob_digit, NULL,
+             -1, sizeof(digit), 0, PyLong_nails, z)
+     if mpz_sgn(z) < 0:
+-        # Set correct size (use a pointer to hack around Cython's
+-        # non-support for lvalues).
+-        sizeptr = Py_SIZE_PTR(L)
+-        sizeptr[0] = -pylong_size
++        # Set correct size
++        Py_SET_SIZE(L, -pylong_size)
+     return L
+ 
+ 
diff --git a/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch b/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
new file mode 100644
index 000000000000..977a42400e59
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
@@ -0,0 +1,42 @@
+commit 5db5d4e56243c609f44afc1f21c112b026f9e1fe
+Author: Oscar Benjamin <oscar.j.benjamin@gmail.com>
+Date:   Mon Jul 11 21:24:01 2022 +0100
+
+    Update doctests for SymPy 1.11
+    
+    Doctests related to SymPy's rsolve function are updated in:
+    
+    src/sage/calculus/test_sympy.py
+    src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+    
+    The form of the output from SymPy has changed since
+    
+    https://github.com/sympy/sympy/pull/23567
+
+diff --git a/src/sage/calculus/test_sympy.py b/src/sage/calculus/test_sympy.py
+index 7cf7f3f6bfd..927e6ee4fb6 100644
+--- a/src/sage/calculus/test_sympy.py
++++ b/src/sage/calculus/test_sympy.py
+@@ -193,7 +193,7 @@ This was fixed in Sympy, see :trac:`14437`::
+     sage: u = Function('u')
+     sage: n = Symbol('n', integer=True)
+     sage: f = u(n+2) - u(n+1) + u(n)/4
+-    sage: 2**n * rsolve(f,u(n))
+-    C1*n + C0
++    sage: expand(2**n * rsolve(f,u(n)))
++    2*C1*n + C0
+ 
+ """
+diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+index 1062f4f7e8c..f53f813d793 100644
+--- a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
++++ b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+@@ -382,7 +382,7 @@ Sage example in ./recequadiff.tex, line 1798::
+   sage: from sympy import rsolve_hyper
+   sage: from sympy.abc import n
+   sage: rsolve_hyper([-2,1],2**(n+2),n)
+-  2**n*C0 + 2**(n + 2)*(C0 + n/2)
++  2**n*C0 + 2**(n + 1)*n
+ 
+ """
+ 
diff --git a/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-a6c293d67cfcdf8fba7bc6aa7899e2086d42cc7e.patch b/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-a6c293d67cfcdf8fba7bc6aa7899e2086d42cc7e.patch
new file mode 100644
index 000000000000..b544a3eef7dd
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-a6c293d67cfcdf8fba7bc6aa7899e2086d42cc7e.patch
@@ -0,0 +1,526 @@
+From aeff992d53a65a705dca5cd5216bcb97c218dce7 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:14:03 +0200
+Subject: Adapt to API changes in OpenOutputStream and CloseOutput
+
+---
+ src/sage/libs/gap/element.pyx      | 5 +++--
+ src/sage/libs/gap/gap_includes.pxd | 6 ++++--
+ 2 files changed, 7 insertions(+), 4 deletions(-)
+
+diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
+index be43c4c..e268116 100644
+--- a/src/sage/libs/gap/element.pyx
++++ b/src/sage/libs/gap/element.pyx
+@@ -130,6 +130,7 @@ cdef char *capture_stdout(Obj func, Obj obj):
+     """
+     cdef Obj s, stream, output_text_string
+     cdef UInt res
++    cdef TypOutputFile output
+     # The only way to get a string representation of an object that is truly
+     # consistent with how it would be represented at the GAP REPL is to call
+     # ViewObj on it.  Unfortunately, ViewObj *prints* to the output stream,
+@@ -145,12 +146,12 @@ cdef char *capture_stdout(Obj func, Obj obj):
+         output_text_string = GAP_ValueGlobalVariable("OutputTextString")
+         stream = CALL_2ARGS(output_text_string, s, GAP_True)
+ 
+-        if not OpenOutputStream(stream):
++        if not OpenOutputStream(&output, stream):
+             raise GAPError("failed to open output capture stream for "
+                            "representing GAP object")
+ 
+         CALL_1ARGS(func, obj)
+-        CloseOutput()
++        CloseOutput(&output)
+         return CSTR_STRING(s)
+     finally:
+         GAP_Leave()
+diff --git a/src/sage/libs/gap/gap_includes.pxd b/src/sage/libs/gap/gap_includes.pxd
+index 5a9ab48..34035fe 100644
+--- a/src/sage/libs/gap/gap_includes.pxd
++++ b/src/sage/libs/gap/gap_includes.pxd
+@@ -76,8 +76,10 @@ cdef extern from "gap/intobj.h" nogil:
+ 
+ 
+ cdef extern from "gap/io.h" nogil:
+-    UInt OpenOutputStream(Obj stream)
+-    UInt CloseOutput()
++    ctypedef struct TypOutputFile:
++        pass
++    UInt OpenOutputStream(TypOutputFile* output, Obj stream)
++    UInt CloseOutput(TypOutputFile* output)
+ 
+ 
+ cdef extern from "gap/libgap-api.h" nogil:
+-- 
+cgit v1.0-1-gd88e
+
+
+From c3367b4290981e5e93b7a30c48b02f1ae3770dc8 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:14:53 +0200
+Subject: Disable colored prompt as it breaks the pexpect interface
+
+---
+ src/sage/interfaces/gap.py | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/src/sage/interfaces/gap.py b/src/sage/interfaces/gap.py
+index c34fe53..569caa2 100644
+--- a/src/sage/interfaces/gap.py
++++ b/src/sage/interfaces/gap.py
+@@ -1512,6 +1512,8 @@ def gap_reset_workspace(max_workspace_size=None, verbose=False):
+     """
+     # Create new workspace with filename WORKSPACE
+     g = Gap(use_workspace_cache=False, max_workspace_size=None)
++    g.eval('ColorPrompt(false)')
++    g.eval('SetUserPreference("UseColorPrompt", false)')
+     g.eval('SetUserPreference("HistoryMaxLines", 30)')
+     from sage.tests.gap_packages import all_installed_packages
+     for pkg in all_installed_packages(gap=g):
+-- 
+cgit v1.0-1-gd88e
+
+
+From 3b63e998e4d6118fc86b13b940c8f3d3b8307a50 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:16:03 +0200
+Subject: Port NaturalHomomorphism uses
+
+---
+ src/sage/groups/abelian_gps/abelian_group_gap.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/sage/groups/abelian_gps/abelian_group_gap.py b/src/sage/groups/abelian_gps/abelian_group_gap.py
+index a4b0471..86090b4 100644
+--- a/src/sage/groups/abelian_gps/abelian_group_gap.py
++++ b/src/sage/groups/abelian_gps/abelian_group_gap.py
+@@ -338,7 +338,7 @@ class AbelianGroup_gap(UniqueRepresentation, GroupMixinLibGAP, ParentLibGAP, Abe
+         if isinstance(x, AbelianGroupElement_gap):
+             try:
+                 if x in self._cover:
+-                    x = self.gap().NaturalHomomorphism().Image(x.gap())
++                    x = self._cover.gap().NaturalHomomorphismByNormalSubgroup(self._relations).Image(x.gap())
+                 else:
+                     x = x.gap()
+             except AttributeError:
+@@ -1043,7 +1043,7 @@ class AbelianGroupQuotient_gap(AbelianGroup_gap):
+             From: Abelian group with gap, generator orders (4,)
+             To:   Quotient abelian group with generator orders (2,)
+         """
+-        phi = self.gap().NaturalHomomorphism()
++        phi = self._cover.gap().NaturalHomomorphismByNormalSubgroup(self._relations)
+         Hom = self._cover.Hom(self)
+         return Hom(phi)
+ 
+-- 
+cgit v1.0-1-gd88e
+
+
+From bc40764be044653e06f2da3497e1e05da08251f7 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:17:36 +0200
+Subject: Fix tests with GAP 4.12
+
+---
+ src/doc/en/thematic_tutorials/lie/weyl_groups.rst  | 12 ++++++------
+ src/sage/coding/codecan/autgroup_can_label.pyx     |  2 +-
+ src/sage/coding/linear_code.py                     | 22 +++++++++++-----------
+ .../root_system/hecke_algebra_representation.py    |  2 +-
+ src/sage/combinat/symmetric_group_algebra.py       |  2 +-
+ src/sage/groups/finitely_presented.py              |  6 +++---
+ src/sage/groups/fqf_orthogonal.py                  |  2 +-
+ src/sage/groups/libgap_wrapper.pyx                 |  6 +++---
+ .../perm_gps/partn_ref2/refinement_generic.pyx     |  2 +-
+ src/sage/groups/perm_gps/permgroup.py              |  8 ++++----
+ src/sage/libs/gap/libgap.pyx                       |  2 +-
+ src/sage/libs/gap/util.pyx                         |  8 +-------
+ src/sage/tests/gap_packages.py                     |  2 +-
+ 13 files changed, 35 insertions(+), 41 deletions(-)
+
+diff --git a/src/doc/en/thematic_tutorials/lie/weyl_groups.rst b/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
+index c917338..182e74a 100644
+--- a/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
++++ b/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
+@@ -139,12 +139,12 @@ string, which you can print::
+     X.1      1  1  1  1  1  1  1  1  1  1  1  1  1
+     X.2      1 -1  1  1 -1  1  1 -1 -1 -1  1  1  1
+     X.3      2  .  2 -1  .  2  2  .  .  . -1  2  2
+-    X.4      3 -1 -1  .  1 -1  3 -1  1 -1  . -1  3
+-    X.5      3 -1 -1  .  1  3 -1 -1 -1  1  . -1  3
+-    X.6      3  1 -1  . -1 -1  3  1 -1  1  . -1  3
+-    X.7      3  1 -1  . -1  3 -1  1  1 -1  . -1  3
+-    X.8      3 -1  3  . -1 -1 -1 -1  1  1  . -1  3
+-    X.9      3  1  3  .  1 -1 -1  1 -1 -1  . -1  3
++    X.4      3 -1 -1  .  1  3 -1 -1 -1  1  . -1  3
++    X.5      3  1 -1  . -1  3 -1  1  1 -1  . -1  3
++    X.6      3 -1  3  . -1 -1 -1 -1  1  1  . -1  3
++    X.7      3 -1 -1  .  1 -1  3 -1  1 -1  . -1  3
++    X.8      3  1  3  .  1 -1 -1  1 -1 -1  . -1  3
++    X.9      3  1 -1  . -1 -1  3  1 -1  1  . -1  3
+     X.10     4 -2  . -1  .  .  .  2  .  .  1  . -4
+     X.11     4  2  . -1  .  .  . -2  .  .  1  . -4
+     X.12     6  . -2  .  . -2 -2  .  .  .  .  2  6
+diff --git a/src/sage/coding/codecan/autgroup_can_label.pyx b/src/sage/coding/codecan/autgroup_can_label.pyx
+index de5db98..c83b926 100644
+--- a/src/sage/coding/codecan/autgroup_can_label.pyx
++++ b/src/sage/coding/codecan/autgroup_can_label.pyx
+@@ -76,7 +76,7 @@ columns do share the same coloring::
+     ((1,),
+      (2,),
+      (3, 5, 4),
+-     (6, 19, 16, 9, 21, 10, 8, 15, 14, 11, 20, 13, 12, 7, 17, 18))
++     (6, 19, 16, 21, 9, 10, 15, 8, 20, 11, 14, 13, 7, 12, 18, 17))
+ 
+ We can also restrict the group action to linear isometries::
+ 
+diff --git a/src/sage/coding/linear_code.py b/src/sage/coding/linear_code.py
+index e8e32f8..9d45160 100644
+--- a/src/sage/coding/linear_code.py
++++ b/src/sage/coding/linear_code.py
+@@ -466,27 +466,27 @@ class AbstractLinearCode(AbstractLinearCodeNoMetric):
+             0
+             sage: C = codes.HammingCode(GF(4, 'z'), 3)
+             sage: C.automorphism_group_gens()
+-            ([((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
++            ([((1, 1, 1, z, z + 1, 1, 1, 1, 1, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z); (1,13,14,20)(2,21,8,18,7,16,19,15)(3,10,5,12,17,9,6,4), Ring endomorphism of Finite Field in z of size 2^2
++                Defn: z |--> z + 1),
++              ((z, 1, z, z, z, z + 1, z, z, z, z, z, z, z + 1, z, z, z, z, z + 1, z, z, z); (1,11,5,12,3,19)(2,8)(6,18,13)(7,17,15)(9,10,14,16,20,21), 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 + 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
++            ([((z, 1, z + 1, z + 1, 1, z + 1, z, 1, z + 1, z + 1, 1, z, 1, z + 1, z, 1, z, 1, z + 1, 1, 1); (1,12,11,10,6,8,9,20,13,21,5,14,3,16,17,19,7,4,2,15,18), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+-              ((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
++              ((z + 1, z + 1, z + 1, z, 1, 1, z, z, 1, z + 1, z, 1, 1, z, 1, z + 1, z, z + 1, z + 1, 1, z); (1,3,18,2,17,6,19)(4,15,13,20,7,14,16)(5,11,8,21,12,9,10), 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)],
+              181440)
+             sage: C.automorphism_group_gens(equivalence="permutational")
+-            ([((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,19)(3,17)(4,21)(5,20)(7,14)(9,12)(10,16)(11,15), Ring endomorphism of Finite Field in z of size 2^2
++            ([((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,11)(3,10)(4,9)(5,7)(12,21)(14,20)(15,19)(16,17), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+-              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,11)(3,10)(4,9)(5,7)(12,21)(14,20)(15,19)(16,17), Ring endomorphism of Finite Field in z of size 2^2
++              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (2,18)(3,19)(4,10)(5,16)(8,13)(9,14)(11,21)(15,20), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+-              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,17)(2,8)(3,14)(4,10)(7,12)(9,19)(13,18)(15,20), Ring endomorphism of Finite Field in z of size 2^2
++              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,19)(3,17)(4,21)(5,20)(7,14)(9,12)(10,16)(11,15), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+               ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (2,13)(3,14)(4,20)(5,11)(8,18)(9,19)(10,15)(16,21), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z)],
+@@ -692,10 +692,10 @@ class AbstractLinearCode(AbstractLinearCodeNoMetric):
+             sage: C_iso == aut_group_can_label.get_canonical_form()
+             True
+             sage: aut_group_can_label.get_autom_gens()
+-            [((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
++            [((1, 1, 1, z, z + 1, 1, 1, 1, 1, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z); (1,13,14,20)(2,21,8,18,7,16,19,15)(3,10,5,12,17,9,6,4), Ring endomorphism of Finite Field in z of size 2^2
++               Defn: z |--> z + 1),
++             ((z, 1, z, z, z, z + 1, z, z, z, z, z, z, z + 1, z, z, z, z, z + 1, z, z, z); (1,11,5,12,3,19)(2,8)(6,18,13)(7,17,15)(9,10,14,16,20,21), 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/root_system/hecke_algebra_representation.py b/src/sage/combinat/root_system/hecke_algebra_representation.py
+index bde2823..bffcc85 100644
+--- a/src/sage/combinat/root_system/hecke_algebra_representation.py
++++ b/src/sage/combinat/root_system/hecke_algebra_representation.py
+@@ -355,7 +355,7 @@ class HeckeAlgebraRepresentation(WithEqualityById, SageObject):
+             sage: q1, q2 = K.gens()
+             sage: KW = W.algebra(K)
+             sage: x = KW.an_element(); x
+-            123 + 3*32 + 2*3 + e
++            123 + 3*2312 + 2*31 + e
+ 
+             sage: T = KW.demazure_lusztig_operators(q1,q2)
+             sage: T12 = T.Tw( (1,2) )
+diff --git a/src/sage/combinat/symmetric_group_algebra.py b/src/sage/combinat/symmetric_group_algebra.py
+index c3d6755..da953d2 100644
+--- a/src/sage/combinat/symmetric_group_algebra.py
++++ b/src/sage/combinat/symmetric_group_algebra.py
+@@ -101,7 +101,7 @@ def SymmetricGroupAlgebra(R, W, category=None):
+         sage: SGA.group()
+         Weyl Group of type ['A', 3] (as a matrix group acting on the ambient space)
+         sage: SGA.an_element()
+-        s1*s2*s3 + 3*s3*s2 + 2*s3 + 1
++        s1*s2*s3 + 3*s2*s3*s1*s2 + 2*s3*s1 + 1
+ 
+     The preferred way to construct the symmetric group algebra is to
+     go through the usual ``algebra`` method::
+diff --git a/src/sage/groups/finitely_presented.py b/src/sage/groups/finitely_presented.py
+index 2a61bbf..d26891a 100644
+--- a/src/sage/groups/finitely_presented.py
++++ b/src/sage/groups/finitely_presented.py
+@@ -596,9 +596,9 @@ class RewritingSystem():
+             sage: k = G.rewriting_system()
+             sage: k.gap()
+             Knuth Bendix Rewriting System for Monoid( [ a, A, b, B ] ) with rules
+-            [ [ a^2, <identity ...> ], [ a*A, <identity ...> ],
+-              [ A*a, <identity ...> ], [ b^2, <identity ...> ],
+-              [ b*B, <identity ...> ], [ B*b, <identity ...> ] ]
++            [ [ a*A, <identity ...> ], [ A*a, <identity ...> ],
++              [ b*B, <identity ...> ], [ B*b, <identity ...> ],
++              [ a^2, <identity ...> ], [ b^2, <identity ...> ] ]
+         """
+         return self._gap
+ 
+diff --git a/src/sage/groups/fqf_orthogonal.py b/src/sage/groups/fqf_orthogonal.py
+index 75de408..dd7d84d 100644
+--- a/src/sage/groups/fqf_orthogonal.py
++++ b/src/sage/groups/fqf_orthogonal.py
+@@ -143,7 +143,7 @@ class FqfOrthogonalGroup(AbelianGroupAutomorphismGroup_subgroup):
+         [2/3   0   0]
+         [  0 2/3   0]
+         [  0   0 4/3]
+-        generated by 2 elements
++        generated by 3 elements
+         sage: q = matrix.diagonal(QQ, [3/2, 1/4, 1/4])
+         sage: T = TorsionQuadraticForm(q)
+         sage: T.orthogonal_group().order()
+diff --git a/src/sage/groups/libgap_wrapper.pyx b/src/sage/groups/libgap_wrapper.pyx
+index a76afc2..9340c0d 100644
+--- a/src/sage/groups/libgap_wrapper.pyx
++++ b/src/sage/groups/libgap_wrapper.pyx
+@@ -25,7 +25,7 @@ Note how we call the constructor of both superclasses to initialize
+ its output via LibGAP::
+ 
+     sage: FooGroup()
+-    <pc group of size 3 with 1 generators>
++    <pc group of size 3 with 1 generator>
+     sage: type(FooGroup().gap())
+     <class 'sage.libs.gap.element.GapElement'>
+ 
+@@ -106,7 +106,7 @@ class ParentLibGAP(SageObject):
+         ....:         ParentLibGAP.__init__(self, lg)
+         ....:         Group.__init__(self)
+         sage: FooGroup()
+-        <pc group of size 3 with 1 generators>
++        <pc group of size 3 with 1 generator>
+     """
+ 
+     def __init__(self, libgap_parent, ambient=None):
+@@ -461,7 +461,7 @@ cdef class ElementLibGAP(MultiplicativeGroupElement):
+         ....:         ParentLibGAP.__init__(self, lg)
+         ....:         Group.__init__(self)
+         sage: FooGroup()
+-        <pc group of size 3 with 1 generators>
++        <pc group of size 3 with 1 generator>
+         sage: FooGroup().gens()
+         (f1,)
+     """
+diff --git a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
+index 2fcb036..ca73c6b 100644
+--- a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
++++ b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
+@@ -427,7 +427,7 @@ cdef class LabelledBranching:
+             sage: from sage.groups.perm_gps.partn_ref2.refinement_generic import LabelledBranching
+             sage: L = LabelledBranching(3)
+             sage: L.small_generating_set()
+-            []
++            [()]
+             sage: L.add_gen(libgap.eval('(1,2,3)'))
+             sage: L.small_generating_set()
+             [(1,2,3)]
+diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
+index 4908934..34ba0cc 100644
+--- a/src/sage/groups/perm_gps/permgroup.py
++++ b/src/sage/groups/perm_gps/permgroup.py
+@@ -913,7 +913,7 @@ class PermutationGroup_generic(FiniteGroup):
+            sage: f = PG._coerce_map_from_(MG)
+            sage: mg = MG.an_element()
+            sage: p = f(mg); p
+-           (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)
++           (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(p._gap_()) == p
+            True
+ 
+@@ -959,12 +959,12 @@ class PermutationGroup_generic(FiniteGroup):
+             sage: P = G.as_permutation_group(algorithm='smaller', seed=5)
+             sage: P1 = G.as_permutation_group()
+             sage: P == P1
+-            False
++            True
+             sage: g1, g2, g3 = G.gens()
+             sage: P(g1*g2)
+-            (1,3,7,12)(2,4,8,10)(5,11)(6,9)
++            (1,4,13,11)(2,5,14,18)(3,15,8,16)(6,7)(9,20,19,12)(10,17)
+             sage: P1(g1*g2)
+-            (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)
++            (1,4,13,11)(2,5,14,18)(3,15,8,16)(6,7)(9,20,19,12)(10,17)
+ 
+         Another check for :trac:`5583`::
+ 
+diff --git a/src/sage/libs/gap/libgap.pyx b/src/sage/libs/gap/libgap.pyx
+index b1a64e5..6a36613 100644
+--- a/src/sage/libs/gap/libgap.pyx
++++ b/src/sage/libs/gap/libgap.pyx
+@@ -695,7 +695,7 @@ class Gap(Parent):
+             sage: libgap.List
+             <Gap function "List">
+             sage: libgap.GlobalRandomSource
+-            <RandomSource in IsGlobalRandomSource>
++            <RandomSource in IsGAPRandomSource>
+         """
+         if name in dir(self.__class__):
+             return getattr(self.__class__, name)
+diff --git a/src/sage/libs/gap/util.pyx b/src/sage/libs/gap/util.pyx
+index 344ab88..6350987 100644
+--- a/src/sage/libs/gap/util.pyx
++++ b/src/sage/libs/gap/util.pyx
+@@ -362,15 +362,9 @@ cdef Obj gap_eval(str gap_string) except? NULL:
+         GAPError: Error, Variable: 'Complex' must have a value
+         Syntax error: ; expected in stream:1
+         Complex Field with 53 bits of precision;;
+-         ^^^^^^^^^^^^
++                ^^^^^
+         Error, Variable: 'with' must have a value
+-        Syntax error: ; expected in stream:1
+-        Complex Field with 53 bits of precision;;
+-         ^^^^^^^^^^^^^^^^^^^^
+         Error, Variable: 'bits' must have a value
+-        Syntax error: ; expected in stream:1
+-        Complex Field with 53 bits of precision;;
+-         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+         Error, Variable: 'precision' must have a value
+ 
+     Test that on a subsequent attempt we get the same message (no garbage was
+diff --git a/src/sage/tests/gap_packages.py b/src/sage/tests/gap_packages.py
+index 2e4518c..c302b16 100644
+--- a/src/sage/tests/gap_packages.py
++++ b/src/sage/tests/gap_packages.py
+@@ -103,7 +103,7 @@ def all_installed_packages(ignore_dot_gap=False, gap=None):
+ 
+         sage: from sage.tests.gap_packages import all_installed_packages
+         sage: all_installed_packages()
+-        (...'GAPDoc'...)
++        (...'gapdoc'...)
+         sage: all_installed_packages(ignore_dot_gap=True) == all_installed_packages(gap=gap, ignore_dot_gap=True)
+         True
+     """
+-- 
+cgit v1.0-1-gd88e
+
+
+From cbc902a79ff9ec01d4d4eb9a767a1c661fb5dda7 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Fri, 30 Sep 2022 19:17:42 +0200
+Subject: Adapt test to new is_transitive and is_primitive behavior
+
+---
+ src/sage/groups/perm_gps/permgroup.py | 22 ++++++++++++++++------
+ 1 file changed, 16 insertions(+), 6 deletions(-)
+
+diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
+index 34ba0cc..5832b98 100644
+--- a/src/sage/groups/perm_gps/permgroup.py
++++ b/src/sage/groups/perm_gps/permgroup.py
+@@ -4359,17 +4359,23 @@ class PermutationGroup_generic(FiniteGroup):
+ 
+         ::
+ 
+-            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)]]) #S_5 on [1..5]
+-            sage: G.is_transitive([1,4,5])
++            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)],[(6,7)]])
++            sage: G.is_transitive([1,2,3,4,5])
+             True
+-            sage: G.is_transitive([2..6])
++            sage: G.is_transitive([1..7])
+             False
+             sage: G.is_transitive(G.non_fixed_points())
+-            True
++            False
+             sage: H = PermutationGroup([[(1,2,3)],[(4,5,6)]])
+             sage: H.is_transitive(H.non_fixed_points())
+             False
+ 
++        If `G` does not act on the domain, it always returns ``False``::
++
++            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)]]) #S_5 on [1..5]
++            sage: G.is_transitive([1,4,5])
++            False
++
+         Note that this differs from the definition in GAP, where
+         ``IsTransitive`` returns whether the group is transitive on the
+         set of points moved by the group.
+@@ -4425,12 +4431,16 @@ class PermutationGroup_generic(FiniteGroup):
+             sage: G = PermutationGroup([[(1,2,3,4)],[(2,4)]])
+             sage: G.is_primitive([1..4])
+             False
+-            sage: G.is_primitive([1,2,3])
+-            True
+             sage: G = PermutationGroup([[(3,4,5,6)],[(3,4)]]) #S_4 on [3..6]
+             sage: G.is_primitive(G.non_fixed_points())
+             True
+ 
++        If `G` does not act on the domain, it always returns ``False``::
++
++            sage: G = PermutationGroup([[(1,2,3,4)],[(2,4)]])
++            sage: G.is_primitive([1,2,3])
++            False
++
+         """
+         #If the domain is not a subset of self.domain(), then the
+         #action isn't primitive.
+-- 
+cgit v1.0-1-gd88e
+
+
+From 80dd6b338236f170efca1fc3545df18ce8d8795c Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Fri, 30 Sep 2022 19:18:06 +0200
+Subject: Mark test as random. With gap 4.12 on x86_64 it is no longer 2
+
+---
+ src/sage/groups/perm_gps/permgroup.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
+index 5832b98..c1230a3 100644
+--- a/src/sage/groups/perm_gps/permgroup.py
++++ b/src/sage/groups/perm_gps/permgroup.py
+@@ -1287,7 +1287,7 @@ class PermutationGroup_generic(FiniteGroup):
+             sage: G.gens_small() # random
+             [('b','c'), ('a','c','b')] ## (on 64-bit Linux)
+             [('a','b'), ('a','c','b')] ## (on Solaris)
+-            sage: len(G.gens_small()) == 2
++            sage: len(G.gens_small()) == 2 # random
+             True
+         """
+         gens = self._libgap_().SmallGeneratingSet()
+-- 
+cgit v1.0-1-gd88e
+
+
+From a6c293d67cfcdf8fba7bc6aa7899e2086d42cc7e Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Fri, 30 Sep 2022 19:18:30 +0200
+Subject: Remove test that is now redundant, all seeds give the same answer
+
+---
+ src/sage/groups/matrix_gps/finitely_generated.py | 3 ---
+ 1 file changed, 3 deletions(-)
+
+diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
+index a6d3dc0..63956ad 100644
+--- a/src/sage/groups/matrix_gps/finitely_generated.py
++++ b/src/sage/groups/matrix_gps/finitely_generated.py
+@@ -563,9 +563,6 @@ class FinitelyGeneratedMatrixGroup_gap(MatrixGroup_gap):
+             21499084800
+             sage: P = G.as_permutation_group()
+             sage: Psmaller = G.as_permutation_group(algorithm="smaller", seed=6)
+-            sage: P == Psmaller  # see the note below
+-            True
+-            sage: Psmaller = G.as_permutation_group(algorithm="smaller")
+             sage: P == Psmaller
+             False
+             sage: P.cardinality()
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch b/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
new file mode 100644
index 000000000000..8fedcb78cf71
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
@@ -0,0 +1,19 @@
+commit 04971318f032caf8dc1c0de9489346d894409091
+Author: John H. Palmieri <jhpalmieri64@gmail.com>
+Date:   Wed Aug 31 14:22:26 2022 -0700
+
+    trac 34465: fix invalid escape sequence in functions/special.py
+
+diff --git a/src/sage/functions/special.py b/src/sage/functions/special.py
+index 02596e49620..901f02f9bee 100644
+--- a/src/sage/functions/special.py
++++ b/src/sage/functions/special.py
+@@ -849,7 +849,7 @@ class EllipticF(BuiltinFunction):
+     - :wikipedia:`Elliptic_integral#Incomplete_elliptic_integral_of_the_first_kind`
+     """
+     def __init__(self):
+-        """
++        r"""
+         EXAMPLES::
+ 
+             sage: loads(dumps(elliptic_f))
diff --git a/srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15.patch b/srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15.patch
new file mode 100644
index 000000000000..ccafad5070c4
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15.patch
@@ -0,0 +1,1750 @@
+diff --git a/build/pkgs/giac/patches/pari_2_15.patch b/build/pkgs/giac/patches/pari_2_15.patch
+new file mode 100644
+index 0000000000..d2900a5ffc
+--- /dev/null
++++ b/build/pkgs/giac/patches/pari_2_15.patch
+@@ -0,0 +1,21 @@
++ANYARG patch
++
++diff --git a/src/pari.cc b/src/pari.cc
++index 76ce8e1..50d08ab 100644
++--- a/src/pari.cc
+++++ b/src/pari.cc
++@@ -40,6 +40,13 @@ using namespace std;
++ 
++ #ifdef HAVE_LIBPARI
++ 
+++// Anyarg disappeared from PARI 2.15.0
+++#ifdef __cplusplus
+++#  define ANYARG ...
+++#else
+++#  define ANYARG
+++#endif
+++
++ #ifdef HAVE_PTHREAD_H
++ #include <pthread.h>
++ #endif
++
+diff --git a/build/pkgs/pari/checksums.ini b/build/pkgs/pari/checksums.ini
+index b736feed31..bafd0f36f4 100644
+--- a/build/pkgs/pari/checksums.ini
++++ b/build/pkgs/pari/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=pari-VERSION.tar.gz
+-sha1=e01647aab7e96a8cb4922cf26a4f224337c6647f
+-md5=922f740fcdf8630b30d63dc76b58f756
+-cksum=297133525
++sha1=cba9b279f67d5efe2fbbccf3be6e9725f816cf07
++md5=76d430f1bea1b07fa2ad9712deeaa736
++cksum=1990743897
+ upstream_url=https://pari.math.u-bordeaux.fr/pub/pari/unix/pari-VERSION.tar.gz
+diff --git a/build/pkgs/pari/package-version.txt b/build/pkgs/pari/package-version.txt
+index a1a4224dd5..68e69e405e 100644
+--- a/build/pkgs/pari/package-version.txt
++++ b/build/pkgs/pari/package-version.txt
+@@ -1 +1 @@
+-2.13.3
++2.15.0
+diff --git a/src/doc/de/tutorial/tour_numtheory.rst b/src/doc/de/tutorial/tour_numtheory.rst
+index a012234c99..e3149fe949 100644
+--- a/src/doc/de/tutorial/tour_numtheory.rst
++++ b/src/doc/de/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ implementiert.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/en/tutorial/tour_numtheory.rst b/src/doc/en/tutorial/tour_numtheory.rst
+index 3064d100e2..075e0ac0ad 100644
+--- a/src/doc/en/tutorial/tour_numtheory.rst
++++ b/src/doc/en/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ NumberField class.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/es/tutorial/tour_numtheory.rst b/src/doc/es/tutorial/tour_numtheory.rst
+index a1f7d1a87b..48e5376cfe 100644
+--- a/src/doc/es/tutorial/tour_numtheory.rst
++++ b/src/doc/es/tutorial/tour_numtheory.rst
+@@ -140,7 +140,7 @@ Varios métodos relacionados están implementados en la clase ``NumberField``::
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/fr/tutorial/tour_numtheory.rst b/src/doc/fr/tutorial/tour_numtheory.rst
+index 871092f5fa..d1b2fee883 100644
+--- a/src/doc/fr/tutorial/tour_numtheory.rst
++++ b/src/doc/fr/tutorial/tour_numtheory.rst
+@@ -159,7 +159,7 @@ dans la classe NumberField.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/ja/tutorial/tour_numtheory.rst b/src/doc/ja/tutorial/tour_numtheory.rst
+index 47af68c862..4d4ed52d50 100644
+--- a/src/doc/ja/tutorial/tour_numtheory.rst
++++ b/src/doc/ja/tutorial/tour_numtheory.rst
+@@ -161,7 +161,7 @@ Sageには :math:`p` \-進数体も組込まれている.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/pt/tutorial/tour_numtheory.rst b/src/doc/pt/tutorial/tour_numtheory.rst
+index 6371b491ea..a3dc973a93 100644
+--- a/src/doc/pt/tutorial/tour_numtheory.rst
++++ b/src/doc/pt/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ NumberField.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus 
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/ru/tutorial/tour_numtheory.rst b/src/doc/ru/tutorial/tour_numtheory.rst
+index 652abfbc99..a985d49fbd 100644
+--- a/src/doc/ru/tutorial/tour_numtheory.rst
++++ b/src/doc/ru/tutorial/tour_numtheory.rst
+@@ -150,7 +150,7 @@ Sage содержит стандартные функции теории чис
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py
+index e57076646f..fec75d07c1 100644
+--- a/src/sage/arith/misc.py
++++ b/src/sage/arith/misc.py
+@@ -1465,13 +1465,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)]
++        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::
+ 
+@@ -2569,7 +2569,7 @@ def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds):
+ 
+         sage: K.<i> = QuadraticField(-1)
+         sage: factor(122 - 454*i)
+-        (-3*i - 2) * (-i - 2)^3 * (i + 1)^3 * (i + 4)
++        (-i) * (-i - 2)^3 * (i + 1)^3 * (-2*i + 3) * (i + 4)
+ 
+     To access the data in a factorization::
+ 
+diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
+index cdfc11a9e5..b6e1280d6e 100644
+--- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
++++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
+@@ -7825,9 +7825,9 @@ class DynamicalSystem_projective_field(DynamicalSystem_projective,
+             sage: f = DynamicalSystem_projective([x^2 + QQbar(sqrt(3))*y^2, y^2, QQbar(sqrt(2))*z^2])
+             sage: f.reduce_base_field()
+             Dynamical System of Projective Space of dimension 2 over Number Field in a with
+-            defining polynomial y^4 - 4*y^2 + 1 with a = 1.931851652578137?
++            defining polynomial y^4 - 4*y^2 + 1 with a = -0.5176380902050415?
+               Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x^2 + (a^2 - 2)*y^2 : y^2 : (a^3 - 3*a)*z^2)
++                    (x^2 + (-a^2 + 2)*y^2 : y^2 : (a^3 - 3*a)*z^2)
+ 
+         ::
+ 
+diff --git a/src/sage/ext_data/pari/simon/ellQ.gp b/src/sage/ext_data/pari/simon/ellQ.gp
+index 420af8f6a2..65e8386779 100644
+--- a/src/sage/ext_data/pari/simon/ellQ.gp
++++ b/src/sage/ext_data/pari/simon/ellQ.gp
+@@ -40,7 +40,7 @@
+   gp > \r ellcommon.gp
+   gp > \r ellQ.gp
+ 
+-  The main function is ellrank(), which takes as an argument
++  The main function is ellQ_ellrank(), which takes as an argument
+   any elliptic curve in the form [a1,a2,a3,a4,a6]
+   the result is a vector [r,s,v], where
+     r is a lower bound for the rank,
+@@ -50,7 +50,7 @@
+   Example:
+ 
+   gp > ell = [1,2,3,4,5];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+   %1 = [1, 1, [[1,2]]
+   In this example, the rank is exactly 1, and [1,2] has infinite order.
+ 
+@@ -92,7 +92,7 @@
+   \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+ 
+   Explications succintes :
+-  La fonction ellrank() accepte toutes les courbes sous la forme
++  La fonction ellQ_ellrank() accepte toutes les courbes sous la forme
+   [a1,a2,a3,a4,a6]
+   Les coefficients peuvent etre entiers ou non.
+   L'algorithme utilise est celui de la 2-descente.
+@@ -100,7 +100,7 @@
+   Il suffit de taper : 
+ 
+   gp > ell = [a1,a2,a3,a4,a6];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+ 
+   Retourne un vecteur [r,s,v] ou
+     r est le rang probable (c'est toujours une minoration du rang),
+@@ -110,7 +110,7 @@
+   Exemple :
+ 
+   gp > ell = [1,2,3,4,5];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+   %1 = [1, 1, [[1,2]]
+   Ici, le rang est exactement 1, et le point [1,2] est d'ordre infini.
+ 
+@@ -1571,12 +1571,12 @@ if( DEBUGLEVEL_ell >= 4, print("    end of ell2descent_gen"));
+     print("rank(E/Q)    >= ",m1)
+   );
+ }
+-{ellrank(ell,help=[]) =
++{ellQ_ellrank(ell,help=[]) =
+ \\ Algorithm of 2-descent on the elliptic curve ell.
+ \\ help is a list of known points on ell.
+ my(urst,urst1,den,eqell,tors2,bnf,rang,time1);
+ 
+-if( DEBUGLEVEL_ell >= 3, print("   starting ellrank"));
++if( DEBUGLEVEL_ell >= 3, print("   starting ellQ_ellrank"));
+   if( #ell < 13, ell = ellinit(ell));
+ 
+ \\ kill the coefficients a1 and a3
+@@ -1630,7 +1630,7 @@ if( DEBUGLEVEL_ell >= 1, print(" Elliptic curve: Y^2 = ",eqell));
+   ));
+ 
+   rang[3] = ellchangepoint(rang[3],ellinverturst(urst));
+-if( DEBUGLEVEL_ell >= 3, print("   end of ellrank"));
++if( DEBUGLEVEL_ell >= 3, print("   end of ellQ_ellrank"));
+ 
+   return(rang);
+ }
+@@ -2106,13 +2106,13 @@ if( DEBUGLEVEL_ell >= 3, print("   end of ell2descent_viaisog"));
+ {
+ \\                  functions for elliptic curves
+   addhelp(ell2descent_complete,
+-    "ell2descent_complete(e1,e2,e3): Performs a complete 2-descent on the elliptic curve y^2 = (x-e1)*(x-e2)*(x-e3). See ?ellrank for the format of the output.");
++    "ell2descent_complete(e1,e2,e3): Performs a complete 2-descent on the elliptic curve y^2 = (x-e1)*(x-e2)*(x-e3). See ?ellQ_ellrank for the format of the output.");
+   addhelp(ell2descent_gen,
+-    "ell2descent_gen((E,bnf,k=1,help=[]): E is a vector of the form [0,A,0,B,C], (or the result of ellinit of such a vector) A,B,C integers such that x^3+A*x^2+B*x+C; bnf is the corresponding bnfinit(,1); Performs 2-descent on the elliptic curve Ek: k*y^2=x^3+A*x^2+B*x+C. See ?ellrank for the format of the output.");
++    "ell2descent_gen((E,bnf,k=1,help=[]): E is a vector of the form [0,A,0,B,C], (or the result of ellinit of such a vector) A,B,C integers such that x^3+A*x^2+B*x+C; bnf is the corresponding bnfinit(,1); Performs 2-descent on the elliptic curve Ek: k*y^2=x^3+A*x^2+B*x+C. See ?ellQ_ellrank for the format of the output.");
+   addhelp(ell2descent_viaisog,
+-    "ell2descent_viaisog(E,help=[]): E is an elliptic curve of the form [0,a,0,b,0], with a, b integers. Performs a 2-descent via isogeny on E. See ?ellrank for the format of the output.");
+-  addhelp(ellrank,
+-    "ellrank(E,help=[]): E is any elliptic curve defined over Q. Returns a vector [r,s,v], where r is a lower bound for the rank of E, s is the rank of its 2-Selmer group and v is a list of independant points in E(Q)/2E(Q). If help is a vector of nontrivial points on E, the result might be faster. This function might be used in conjunction with elltors2(E). See also ?default_ellQ");
++    "ell2descent_viaisog(E,help=[]): E is an elliptic curve of the form [0,a,0,b,0], with a, b integers. Performs a 2-descent via isogeny on E. See ?ellQ_ellrank for the format of the output.");
++  addhelp(ellQ_ellrank,
++    "ellQ_ellrank(E,help=[]): E is any elliptic curve defined over Q. Returns a vector [r,s,v], where r is a lower bound for the rank of E, s is the rank of its 2-Selmer group and v is a list of independant points in E(Q)/2E(Q). If help is a vector of nontrivial points on E, the result might be faster. This function might be used in conjunction with elltors2(E). See also ?default_ellQ");
+   addhelp(ellhalf,
+     "ellhalf(E,P): returns the vector of all points Q on the elliptic curve E such that 2Q = P");
+   addhelp(ellredgen,
+@@ -2143,7 +2143,7 @@ if( DEBUGLEVEL_ell >= 3, print("   end of ell2descent_viaisog"));
+ 
+ \\                  others
+   addhelp(default_ellQ,
+-    "default_ellQ(DEBUGLEVEL_ell, LIM1, LIM3, LIMTRIV, ELLREDGENFLAG, COMPLETE, MAXPROB, LIMBIGPRIME): set the value of the global variables used for ellrank() and other related functions. DEBUGLEVEL_ell: 0-5: choose the quantity of information printed during the computation (default=0: print nothing); LIM1 (resp LIM3): search limit for easy (resp hard) points on quartics; LIMTRIV: search limit for trivial points on elliptic curves; ELLREDGENFLAG: if != 0, try to reduce the generators at the end; COMPLETE: if != 0 and full 2-torsion, use complete 2-descent, otherwise via 2-isogeny; MAXPROB, LIMBIGPRIME: technical.");
++    "default_ellQ(DEBUGLEVEL_ell, LIM1, LIM3, LIMTRIV, ELLREDGENFLAG, COMPLETE, MAXPROB, LIMBIGPRIME): set the value of the global variables used for ellQ_ellrank() and other related functions. DEBUGLEVEL_ell: 0-5: choose the quantity of information printed during the computation (default=0: print nothing); LIM1 (resp LIM3): search limit for easy (resp hard) points on quartics; LIMTRIV: search limit for trivial points on elliptic curves; ELLREDGENFLAG: if != 0, try to reduce the generators at the end; COMPLETE: if != 0 and full 2-torsion, use complete 2-descent, otherwise via 2-isogeny; MAXPROB, LIMBIGPRIME: technical.");
+ /*  addhelp(DEBUGLEVEL_ell,
+     "DEBUGLEVEL_ell: Choose a higher value of this global variable to have more details of the computations printed during the 2-descent algorithm. 0 = don't print anything; 1 = (default) just print the result; 2 = print more details including the Selmer group and the nontrivial quartics.");
+ */
+diff --git a/src/sage/ext_data/pari/simon/qfsolve.gp b/src/sage/ext_data/pari/simon/qfsolve.gp
+index 501fb50828..2107288c1d 100644
+--- a/src/sage/ext_data/pari/simon/qfsolve.gp
++++ b/src/sage/ext_data/pari/simon/qfsolve.gp
+@@ -434,146 +434,6 @@ my(cc);
+ return([U3~*G3*U3,red[2]*U1*U2*U3]);
+ }
+ 
+-\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+-\\        QUADRATIC FORMS MINIMIZATION         \\
+-\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+-
+-\\ Minimization of the quadratic form G, with nonzero determinant.
+-\\ of dimension n>=2.
+-\\ G must by symmetric and have integral coefficients.
+-\\ Returns [G',U,factd] with U in GLn(Q) such that G'=U~*G*U*constant
+-\\ is integral and has minimal determinant.
+-\\ In dimension 3 or 4, may return a prime p
+-\\ if the reduction at p is impossible because of the local non solvability.
+-\\ If given, factdetG must be equal to factor(abs(det(G))).
+-{qfminimize(G,factdetG) =
+-my(factd,U,Ker,Ker2,sol,aux,di);
+-my(p);
+-my(n,lf,i,vp,dimKer,dimKer2,m);
+-
+-  n = length(G);
+-  factd = matrix(0,2);
+-  if( !factdetG, factdetG = factor(matdet(G)));
+-
+-  lf = length(factdetG[,1]);
+-  i = 1; U = matid(n);
+-
+-  while(i <= lf,
+-    vp = factdetG[i,2];
+-    if( vp == 0, i++; next);
+-    p = factdetG[i,1];
+-    if( p == -1, i++; next);
+-if( DEBUGLEVEL_qfsolve >= 4, print("    p = ",p,"^",vp));
+-
+-\\ The case vp = 1 can be minimized only if n is odd.
+-    if( vp == 1 && n%2 == 0,
+-      factd = concat(factd~, Mat([p,1])~)~;
+-      i++; next
+-    );
+-    Ker = kermodp(G,p); dimKer = Ker[1]; Ker = Ker[2];
+-
+-\\ Rem: we must have dimKer <= vp
+-if( DEBUGLEVEL_qfsolve >= 4, print("    dimKer = ",dimKer));
+-\\ trivial case: dimKer = n
+-    if( dimKer == n, 
+-if( DEBUGLEVEL_qfsolve >= 4, print("     case 0: dimKer = n"));
+-      G /= p;
+-      factdetG[i,2] -= n;
+-      next
+-    );
+-    G = Ker~*G*Ker;
+-    U = U*Ker;
+-
+-\\ 1st case: dimKer < vp
+-\\ then the kernel mod p contains a kernel mod p^2
+-    if( dimKer < vp,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 1: dimker < vp"));
+-      if( dimKer == 1,
+-\\        G[,1] /= p; G[1,] /= p;
+-        G[,1] /= p; G[1,] = G[1,]/p;
+-        U[,1] /= p;
+-        factdetG[i,2] -= 2
+-      , 
+-        Ker2 = kermodp(matrix(dimKer,dimKer,j,k,G[j,k]/p),p);
+-        dimKer2 = Ker2[1]; Ker2 = Ker2[2];
+-        for( j = 1, dimKer2, Ker2[,j] /= p);
+-        Ker2 = matdiagonalblock([Ker2,matid(n-dimKer)]);
+-        G = Ker2~*G*Ker2;
+-        U = U*Ker2;
+-        factdetG[i,2] -= 2*dimKer2
+-);
+-
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 1"));
+-      next
+-    );
+-
+-\\ Now, we have vp = dimKer 
+-\\ 2nd case: the dimension of the kernel is >=2
+-\\ and contains an element of norm 0 mod p^2
+-
+-\\ search for an element of norm p^2... in the kernel
+-    if( dimKer > 2 || 
+-       (dimKer == 2 && issquare( di = Mod((G[1,2]^2-G[1,1]*G[2,2])/p^2,p))),
+-      if( dimKer > 2,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 2.1"));
+-        dimKer = 3;
+-        sol = qfsolvemodp(matrix(3,3,j,k,G[j,k]/p),p)
+-      ,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 2.2"));
+-        if( G[1,1]%p^2 == 0, 
+-          sol = [1,0]~
+-        , sol = [-G[1,2]/p+sqrt(di),Mod(G[1,1]/p,p)]~
+-        )
+-      );
+-      sol = centerlift(sol);
+-      sol /= content(sol);
+-if( DEBUGLEVEL_qfsolve >= 4, print("    sol = ",sol));
+-      Ker = vectorv(n, j, if( j<= dimKer, sol[j], 0)); \\ fill with 0's
+-      Ker = completebasis(Ker,1);
+-      Ker[,n] /= p;
+-      G = Ker~*G*Ker;
+-      U = U*Ker;
+-      factdetG[i,2] -= 2;
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 2"));
+-      next
+-    );
+-
+-\\ Now, we have vp = dimKer <= 2 
+-\\   and the kernel contains no vector with norm p^2...
+-
+-\\ In some cases, exchanging the kernel and the image
+-\\ makes the minimization easy.
+-
+-    m = (n-1)\2-1;
+-    if( ( vp == 1 && issquare(Mod(-(-1)^m*matdet(G)/G[1,1],p)))
+-     || ( vp == 2 && n%2 == 1 && n >= 5)
+-     || ( vp == 2 && n%2 == 0 && !issquare(Mod((-1)^m*matdet(G)/p^2,p)))
+-    , 
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 3"));
+-      Ker = matid(n);
+-      for( j = dimKer+1, n, Ker[j,j] = p);
+-      G = Ker~*G*Ker/p;
+-      U = U*Ker;
+-      factdetG[i,2] -= 2*dimKer-n;
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 3"));
+-      next
+-    );
+-
+-\\ Minimization was not possible se far.
+-\\ If n == 3 or 4, this proves the local non-solubility at p.
+-    if( n == 3 || n == 4, 
+-if( DEBUGLEVEL_qfsolve >= 1, print(" no local solution at ",p));
+-      return(p));
+-
+-if( DEBUGLEVEL_qfsolve >= 4, print("    prime ",p," finished"));
+-    factd = concat(factd~,Mat([p,vp])~)~;
+-    i++
+-  );
+-\\ apply LLL to avoid coefficients explosion
+-  aux = qflll(U/content(U));
+-return([aux~*G*aux,U*aux,factd]);
+-}
+-
+ \\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+ \\          CLASS GROUP COMPUTATIONS           \\
+ \\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+diff --git a/src/sage/geometry/polyhedron/backend_field.py b/src/sage/geometry/polyhedron/backend_field.py
+index 6b921d23a6..2f32c58b1e 100644
+--- a/src/sage/geometry/polyhedron/backend_field.py
++++ b/src/sage/geometry/polyhedron/backend_field.py
+@@ -265,7 +265,7 @@ class Polyhedron_field(Polyhedron_base):
+              An inequality (-0.1419794359520263?, -1.698172434277148?) x + 1.200789243901438? >= 0,
+              An inequality (0.3001973109753594?, 0.600394621950719?) x - 0.4245431085692869? >= 0)
+             sage: p.Vrepresentation()                                           # optional - sage.rings.number_field
+-            (A vertex at (0.?e-15, 0.707106781186548?),
++            (A vertex at (0.?e-16, 0.7071067811865475?),
+              A vertex at (1.414213562373095?, 0),
+              A vertex at (4.000000000000000?, 0.372677996249965?))
+         """
+@@ -308,7 +308,7 @@ class Polyhedron_field(Polyhedron_base):
+              An inequality (-0.1419794359520263?, -1.698172434277148?) x + 1.200789243901438? >= 0,
+              An inequality (0.3001973109753594?, 0.600394621950719?) x - 0.4245431085692869? >= 0)
+             sage: p.Vrepresentation()                                           # optional - sage.rings.number_field
+-            (A vertex at (0.?e-15, 0.707106781186548?),
++            (A vertex at (0.?e-16, 0.7071067811865475?),
+              A vertex at (1.414213562373095?, 0),
+              A vertex at (4.000000000000000?, 0.372677996249965?))
+         """
+diff --git a/src/sage/geometry/polyhedron/backend_normaliz.py b/src/sage/geometry/polyhedron/backend_normaliz.py
+index 86b89632a5..ca8a43b248 100644
+--- a/src/sage/geometry/polyhedron/backend_normaliz.py
++++ b/src/sage/geometry/polyhedron/backend_normaliz.py
+@@ -53,7 +53,7 @@ def _number_field_elements_from_algebraics_list_of_lists_of_lists(listss, **kwds
+         1.732050807568878?
+         sage: from sage.geometry.polyhedron.backend_normaliz import _number_field_elements_from_algebraics_list_of_lists_of_lists
+         sage: K, results, hom = _number_field_elements_from_algebraics_list_of_lists_of_lists([[[rt2], [1]], [[rt3]], [[1], []]]); results  # optional - sage.rings.number_field
+-        [[[-a^3 + 3*a], [1]], [[-a^2 + 2]], [[1], []]]
++        [[[-a^3 + 3*a], [1]], [[a^2 - 2]], [[1], []]]
+     """
+     from sage.rings.qqbar import number_field_elements_from_algebraics
+     numbers = []
+diff --git a/src/sage/groups/matrix_gps/isometries.py b/src/sage/groups/matrix_gps/isometries.py
+index f9111a2c92..cca45e7175 100644
+--- a/src/sage/groups/matrix_gps/isometries.py
++++ b/src/sage/groups/matrix_gps/isometries.py
+@@ -11,11 +11,11 @@ EXAMPLES::
+     sage: L = IntegralLattice("D4")
+     sage: O = L.orthogonal_group()
+     sage: O
+-    Group of isometries with 5 generators (
+-    [-1  0  0  0]  [0 0 0 1]  [-1 -1 -1 -1]  [ 1  1  0  0]  [ 1  0  0  0]
+-    [ 0 -1  0  0]  [0 1 0 0]  [ 0  0  1  0]  [ 0  0  1  0]  [-1 -1 -1 -1]
+-    [ 0  0 -1  0]  [0 0 1 0]  [ 0  1  0  1]  [ 0  1  0  1]  [ 0  0  1  0]
+-    [ 0  0  0 -1], [1 0 0 0], [ 0 -1 -1  0], [ 0 -1 -1  0], [ 0  0  0  1]
++    Group of isometries with 3 generators (
++    [0 0 0 1]  [ 1  1  0  0]  [ 1  0  0  0]
++    [0 1 0 0]  [ 0  0  1  0]  [-1 -1 -1 -1]
++    [0 0 1 0]  [ 0  1  0  1]  [ 0  0  1  0]
++    [1 0 0 0], [ 0 -1 -1  0], [ 0  0  0  1]
+     )
+ 
+ Basic functionality is provided by GAP::
+diff --git a/src/sage/interfaces/genus2reduction.py b/src/sage/interfaces/genus2reduction.py
+index 56ae04b235..7a4794daf2 100644
+--- a/src/sage/interfaces/genus2reduction.py
++++ b/src/sage/interfaces/genus2reduction.py
+@@ -143,31 +143,31 @@ class ReductionData(SageObject):
+        sur un corps de valuation discrète", Trans. AMS 348 (1996),
+        4577-4610, Section 7.2, Proposition 4).
+     """
+-    def __init__(self, pari_result, P, Q, minimal_equation, minimal_disc,
+-                 local_data, conductor, prime_to_2_conductor_only):
++    def __init__(self, pari_result, P, Q, Pmin, Qmin, minimal_disc,
++                 local_data, conductor):
+         self.pari_result = pari_result
+         self.P = P
+         self.Q = Q
+-        self.minimal_equation = minimal_equation
++        self.Pmin = Pmin
++        self.Qmin = Qmin
+         self.minimal_disc = minimal_disc
+         self.local_data = local_data
+         self.conductor = conductor
+-        self.prime_to_2_conductor_only = prime_to_2_conductor_only
+ 
+     def _repr_(self):
+-        if self.prime_to_2_conductor_only:
+-            ex = ' (away from 2)'
+-        else:
+-            ex = ''
+         if self.Q == 0:
+             yterm = ''
+         else:
+             yterm = '+ (%s)*y '%self.Q
++
+         s = 'Reduction data about this proper smooth genus 2 curve:\n'
+         s += '\ty^2 %s= %s\n'%(yterm, self.P)
+-        s += 'A Minimal Equation (away from 2):\n\ty^2 = %s\n'%self.minimal_equation
+-        s += 'Minimal Discriminant (away from 2):  %s\n'%self.minimal_disc
+-        s += 'Conductor%s: %s\n'%(ex, self.conductor)
++        if self.Qmin:
++            s += 'A Minimal Equation:\n\ty^2 + (%s)y = %s\n'%(self.Qmin, self.Pmin)
++        else:
++            s += 'A Minimal Equation:\n\ty^2 = %s\n'%self.Pmin
++        s += 'Minimal Discriminant: %s\n'%self.minimal_disc
++        s += 'Conductor: %s\n'%self.conductor
+         s += 'Local Data:\n%s'%self._local_data_str()
+         return s
+ 
+@@ -242,17 +242,7 @@ class Genus2reduction(SageObject):
+         sage: factor(R.conductor)
+         5^4 * 2267
+ 
+-    This means that only the odd part of the conductor is known.
+-
+-    ::
+-
+-        sage: R.prime_to_2_conductor_only
+-        True
+-
+-    The discriminant is always minimal away from 2, but possibly not at
+-    2.
+-
+-    ::
++    The discriminant is always minimal::
+ 
+         sage: factor(R.minimal_disc)
+         2^3 * 5^5 * 2267
+@@ -264,10 +254,10 @@ class Genus2reduction(SageObject):
+         sage: R
+         Reduction data about this proper smooth genus 2 curve:
+             y^2 + (x^3 - 2*x^2 - 2*x + 1)*y = -5*x^5
+-        A Minimal Equation (away from 2):
+-            y^2 = x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855
+-        Minimal Discriminant (away from 2):  56675000
+-        Conductor (away from 2): 1416875
++        A Minimal Equation:
++            y^2 ...
++        Minimal Discriminant: 56675000
++        Conductor: 1416875
+         Local Data:
+             p=2
+             (potential) stable reduction:  (II), j=1
+@@ -293,10 +283,10 @@ class Genus2reduction(SageObject):
+         sage: genus2reduction(0, x^6 + 3*x^3 + 63)
+         Reduction data about this proper smooth genus 2 curve:
+                 y^2 = x^6 + 3*x^3 + 63
+-        A Minimal Equation (away from 2):
+-                y^2 = x^6 + 3*x^3 + 63
+-        Minimal Discriminant (away from 2):  10628388316852992
+-        Conductor (away from 2): 2893401
++        A Minimal Equation:
++                y^2 ...
++        Minimal Discriminant: -10628388316852992
++        Conductor: 2893401
+         Local Data:
+                 p=2
+                 (potential) stable reduction:  (V), j1+j2=0, j1*j2=0
+@@ -327,9 +317,9 @@ class Genus2reduction(SageObject):
+         sage: genus2reduction(x^3-x^2-1, x^2 - x)
+         Reduction data about this proper smooth genus 2 curve:
+                 y^2 + (x^3 - x^2 - 1)*y = x^2 - x
+-        A Minimal Equation (away from 2):
+-                y^2 = x^6 + 58*x^5 + 1401*x^4 + 18038*x^3 + 130546*x^2 + 503516*x + 808561
+-        Minimal Discriminant (away from 2):  169
++        A Minimal Equation:
++                y^2 ...
++        Minimal Discriminant: -169
+         Conductor: 169
+         Local Data:
+                 p=13
+@@ -370,10 +360,10 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^3 - 2*x^2 - 2*x + 1, -5*x^5)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^3 - 2*x^2 - 2*x + 1)*y = -5*x^5
+-            A Minimal Equation (away from 2):
+-                    y^2 = x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855
+-            Minimal Discriminant (away from 2):  56675000
+-            Conductor (away from 2): 1416875
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 56675000
++            Conductor: 1416875
+             Local Data:
+                     p=2
+                     (potential) stable reduction:  (II), j=1
+@@ -389,9 +379,9 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^2 + 1, -5*x^5)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^2 + 1)*y = -5*x^5
+-            A Minimal Equation (away from 2):
+-                    y^2 = -20*x^5 + x^4 + 2*x^2 + 1
+-            Minimal Discriminant (away from 2):  48838125
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 48838125
+             Conductor: 32025
+             Local Data:
+                     p=3
+@@ -412,9 +402,9 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^3 + x^2 + x,-2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^3 + x^2 + x)*y = -2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2
+-            A Minimal Equation (away from 2):
+-                    y^2 = x^6 + 18*x^3 + 36*x^2 - 27
+-            Minimal Discriminant (away from 2):  1520984142
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 1520984142
+             Conductor: 954
+             Local Data:
+                     p=2
+@@ -436,18 +426,10 @@ class Genus2reduction(SageObject):
+             raise ValueError("Q (=%s) must have degree at most 3" % Q)
+ 
+         res = pari.genus2red([P, Q])
+-
+         conductor = ZZ(res[0])
+-        minimal_equation = R(res[2])
+-
+-        minimal_disc = QQ(res[2].poldisc()).abs()
+-        if minimal_equation.degree() == 5:
+-            minimal_disc *= minimal_equation[5]**2
+-        # Multiply with suitable power of 2 of the form 2^(2*(d-1) - 12)
+-        b = 2 * (minimal_equation.degree() - 1)
+-        k = QQ((12 - minimal_disc.valuation(2), b)).ceil()
+-        minimal_disc >>= 12 - b*k
+-        minimal_disc = ZZ(minimal_disc)
++        Pmin = R(res[2][0])
++        Qmin = R(res[2][1])
++        minimal_disc = ZZ(pari.hyperelldisc(res[2]))
+ 
+         local_data = {}
+         for red in res[3]:
+@@ -468,9 +450,7 @@ class Genus2reduction(SageObject):
+ 
+             local_data[p] = data
+ 
+-        prime_to_2_conductor_only = (-1 in res[1].component(2))
+-        return ReductionData(res, P, Q, minimal_equation, minimal_disc, local_data,
+-                             conductor, prime_to_2_conductor_only)
++        return ReductionData(res, P, Q, Pmin, Qmin, minimal_disc, local_data, conductor)
+ 
+     def __reduce__(self):
+         return _reduce_load_genus2reduction, tuple([])
+diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
+index fec450d7bc..236402c293 100644
+--- a/src/sage/lfunctions/dokchitser.py
++++ b/src/sage/lfunctions/dokchitser.py
+@@ -337,6 +337,7 @@ class Dokchitser(SageObject):
+             # After init_coeffs is called, future calls to this method should
+             # return the full output for further parsing
+             raise RuntimeError("unable to create L-series, due to precision or other limits in PARI")
++        t = t.replace("  *** _^_: Warning: normalizing a series with 0 leading term.\n", "")
+         return t
+ 
+     def __check_init(self):
+diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
+index d2b20f1891..6c31efe239 100644
+--- a/src/sage/lfunctions/pari.py
++++ b/src/sage/lfunctions/pari.py
+@@ -339,7 +339,7 @@ def lfun_eta_quotient(scalings, exponents):
+         0.0374412812685155
+ 
+         sage: lfun_eta_quotient([6],[4])
+-        [[Vecsmall([7]), [Vecsmall([6]), Vecsmall([4])]], 0, [0, 1], 2, 36, 1]
++        [[Vecsmall([7]), [Vecsmall([6]), Vecsmall([4]), 0]], 0, [0, 1], 2, 36, 1]
+ 
+         sage: lfun_eta_quotient([2,1,4], [5,-2,-2])
+         Traceback (most recent call last):
+diff --git a/src/sage/libs/pari/tests.py b/src/sage/libs/pari/tests.py
+index e5a2aa2517..0efcb15de0 100644
+--- a/src/sage/libs/pari/tests.py
++++ b/src/sage/libs/pari/tests.py
+@@ -356,7 +356,7 @@ Constructors::
+     [2, 4]~*x + [1, 3]~
+ 
+     sage: pari(3).Qfb(7, 1)
+-    Qfb(3, 7, 1, 0.E-19)
++    Qfb(3, 7, 1)
+     sage: pari(3).Qfb(7, 2)
+     Traceback (most recent call last):
+     ...
+@@ -512,7 +512,7 @@ Basic functions::
+     sage: pari('sqrt(-2)').frac()
+     Traceback (most recent call last):
+     ...
+-    PariError: incorrect type in gfloor (t_COMPLEX)
++    PariError: incorrect type in gfrac (t_COMPLEX)
+ 
+     sage: pari('1+2*I').imag()
+     2
+diff --git a/src/sage/modular/cusps_nf.py b/src/sage/modular/cusps_nf.py
+index 25d93cac92..157ebabe29 100644
+--- a/src/sage/modular/cusps_nf.py
++++ b/src/sage/modular/cusps_nf.py
+@@ -1220,7 +1220,7 @@ def units_mod_ideal(I):
+         sage: I = k.ideal(5, a + 1)
+         sage: units_mod_ideal(I)
+         [1,
+-        2*a^2 + 4*a - 1,
++        -2*a^2 - 4*a + 1,
+         ...]
+ 
+     ::
+diff --git a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
+index a881336596..090d1bfaf0 100644
+--- a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
++++ b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
+@@ -43,7 +43,7 @@ def coerce_AA(p):
+         sage: AA(p)._exact_field()
+         Number Field in a with defining polynomial y^8 ... with a in ...
+         sage: coerce_AA(p)._exact_field()
+-        Number Field in a with defining polynomial y^4 - 1910*y^2 - 3924*y + 681058 with a in 39.710518724...?
++        Number Field in a with defining polynomial y^4 - 1910*y^2 - 3924*y + 681058 with a in ...?
+     """
+     el = AA(p)
+     el.simplify()
+diff --git a/src/sage/modular/modsym/p1list_nf.py b/src/sage/modular/modsym/p1list_nf.py
+index 222caacca8..f9d969732c 100644
+--- a/src/sage/modular/modsym/p1list_nf.py
++++ b/src/sage/modular/modsym/p1list_nf.py
+@@ -58,7 +58,7 @@ Lift an MSymbol to a matrix in `SL(2, R)`:
+ 
+     sage: alpha = MSymbol(N, a + 2, 3*a^2)
+     sage: alpha.lift_to_sl2_Ok()
+-    [-3*a^2 + a + 12, 25*a^2 - 50*a + 100, a + 2, a^2 - 3*a + 3]
++    [-1, 4*a^2 - 13*a + 23, a + 2, 5*a^2 + 3*a - 3]
+     sage: Ok = k.ring_of_integers()
+     sage: M = Matrix(Ok, 2, alpha.lift_to_sl2_Ok())
+     sage: det(M)
+@@ -945,11 +945,11 @@ class P1NFList(SageObject):
+             sage: N = k.ideal(5, a + 1)
+             sage: P = P1NFList(N)
+             sage: u = k.unit_group().gens_values(); u
+-            [-1, 2*a^2 + 4*a - 1]
++            [-1, -2*a^2 - 4*a + 1]
+             sage: P.apply_J_epsilon(4, -1)
+             2
+             sage: P.apply_J_epsilon(4, u[0], u[1])
+-            1
++            5
+ 
+         ::
+ 
+diff --git a/src/sage/modules/free_quadratic_module_integer_symmetric.py b/src/sage/modules/free_quadratic_module_integer_symmetric.py
+index a206f0c721..aeb19ab669 100644
+--- a/src/sage/modules/free_quadratic_module_integer_symmetric.py
++++ b/src/sage/modules/free_quadratic_module_integer_symmetric.py
+@@ -1168,11 +1168,11 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+             sage: A4 = IntegralLattice("A4")
+             sage: Aut = A4.orthogonal_group()
+             sage: Aut
+-            Group of isometries with 5 generators (
+-            [-1  0  0  0]  [0 0 0 1]  [-1 -1 -1  0]  [ 1  0  0  0]  [ 1  0  0  0]
+-            [ 0 -1  0  0]  [0 0 1 0]  [ 0  0  0 -1]  [-1 -1 -1 -1]  [ 0  1  0  0]
+-            [ 0  0 -1  0]  [0 1 0 0]  [ 0  0  1  1]  [ 0  0  0  1]  [ 0  0  1  1]
+-            [ 0  0  0 -1], [1 0 0 0], [ 0  1  0  0], [ 0  0  1  0], [ 0  0  0 -1]
++            Group of isometries with 4 generators (
++            [0 0 0 1]  [-1 -1 -1  0]  [ 1  0  0  0]  [ 1  0  0  0]
++            [0 0 1 0]  [ 0  0  0 -1]  [-1 -1 -1 -1]  [ 0  1  0  0]
++            [0 1 0 0]  [ 0  0  1  1]  [ 0  0  0  1]  [ 0  0  1  1]
++            [1 0 0 0], [ 0  1  0  0], [ 0  0  1  0], [ 0  0  0 -1]
+             )
+ 
+         The group acts from the right on the lattice and its discriminant group::
+@@ -1180,19 +1180,19 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+             sage: x = A4.an_element()
+             sage: g = Aut.an_element()
+             sage: g
+-            [ 1  1  1  0]
+-            [ 0  0 -1  0]
+-            [ 0  0  1  1]
+-            [ 0 -1 -1 -1]
++            [-1 -1 -1  0]
++            [ 0  0  1  0]
++            [ 0  0 -1 -1]
++            [ 0  1  1  1]
+             sage: x*g
+-            (1, 1, 1, 0)
++            (-1, -1, -1, 0)
+             sage: (x*g).parent()==A4
+             True
+             sage: (g*x).parent()
+             Vector space of dimension 4 over Rational Field
+             sage: y = A4.discriminant_group().an_element()
+             sage: y*g
+-            (1)
++            (4)
+ 
+         If the group is finite we can compute the usual things::
+ 
+@@ -1208,10 +1208,10 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+ 
+             sage: A2 = IntegralLattice(matrix.identity(3),Matrix(ZZ,2,3,[1,-1,0,0,1,-1]))
+             sage: A2.orthogonal_group()
+-            Group of isometries with 3 generators (
+-            [-1/3  2/3  2/3]  [ 2/3  2/3 -1/3]  [1 0 0]
+-            [ 2/3 -1/3  2/3]  [ 2/3 -1/3  2/3]  [0 0 1]
+-            [ 2/3  2/3 -1/3], [-1/3  2/3  2/3], [0 1 0]
++            Group of isometries with 2 generators (
++            [ 2/3  2/3 -1/3]  [1 0 0]
++            [ 2/3 -1/3  2/3]  [0 0 1]
++            [-1/3  2/3  2/3], [0 1 0]
+             )
+ 
+         It can be negative definite as well::
+diff --git a/src/sage/quadratic_forms/binary_qf.py b/src/sage/quadratic_forms/binary_qf.py
+index cfa3ada73e..5ac823bc6c 100755
+--- a/src/sage/quadratic_forms/binary_qf.py
++++ b/src/sage/quadratic_forms/binary_qf.py
+@@ -141,7 +141,7 @@ class BinaryQF(SageObject):
+                   and a.degree() == 2 and a.parent().ngens() == 2):
+                 x, y = a.parent().gens()
+                 a, b, c = [a.monomial_coefficient(mon) for mon in [x**2, x*y, y**2]]
+-            elif isinstance(a, pari_gen) and a.type() in ('t_QFI', 't_QFR'):
++            elif isinstance(a, pari_gen) and a.type() in ('t_QFI', 't_QFR', 't_QFB'):
+                 # a has 3 or 4 components
+                 a, b, c = a[0], a[1], a[2]
+         try:
+diff --git a/src/sage/quadratic_forms/genera/genus.py b/src/sage/quadratic_forms/genera/genus.py
+index 8290b6c4fa..0fc43f33c6 100644
+--- a/src/sage/quadratic_forms/genera/genus.py
++++ b/src/sage/quadratic_forms/genera/genus.py
+@@ -3088,8 +3088,8 @@ class GenusSymbol_global_ring():
+             sage: G = Genus(matrix(ZZ, 3, [6,3,0, 3,6,0, 0,0,2]))
+             sage: G.representatives()
+             (
+-            [2 0 0]  [ 2 -1  0]
+-            [0 6 3]  [-1  2  0]
++            [2 0 0]  [ 2  1  0]
++            [0 6 3]  [ 1  2  0]
+             [0 3 6], [ 0  0 18]
+             )
+ 
+diff --git a/src/sage/quadratic_forms/qfsolve.py b/src/sage/quadratic_forms/qfsolve.py
+index ddde95e04f..d5e15d9f83 100644
+--- a/src/sage/quadratic_forms/qfsolve.py
++++ b/src/sage/quadratic_forms/qfsolve.py
+@@ -70,7 +70,7 @@ def qfsolve(G):
+ 
+         sage: M = Matrix(QQ, [[3, 0, 0, 0], [0, 5, 0, 0], [0, 0, -7, 0], [0, 0, 0, -11]])
+         sage: qfsolve(M)
+-        (3, -4, -3, -2)
++        (3, 4, -3, -2)
+     """
+     ret = G.__pari__().qfsolve()
+     if ret.type() == 't_COL':
+diff --git a/src/sage/quadratic_forms/quadratic_form__automorphisms.py b/src/sage/quadratic_forms/quadratic_form__automorphisms.py
+index c36c667e3b..3d72cf3be1 100644
+--- a/src/sage/quadratic_forms/quadratic_form__automorphisms.py
++++ b/src/sage/quadratic_forms/quadratic_form__automorphisms.py
+@@ -300,9 +300,9 @@ def automorphism_group(self):
+         sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1])
+         sage: Q.automorphism_group()
+         Matrix group over Rational Field with 3 generators (
+-        [-1  0  0]  [0 0 1]  [ 0  0  1]
+-        [ 0 -1  0]  [0 1 0]  [-1  0  0]
+-        [ 0  0 -1], [1 0 0], [ 0  1  0]
++        [ 0  0  1]  [1 0 0]  [ 1  0  0]
++        [-1  0  0]  [0 0 1]  [ 0 -1  0]
++        [ 0  1  0], [0 1 0], [ 0  0  1]
+         )
+ 
+     ::
+diff --git a/src/sage/rings/finite_rings/finite_field_prime_modn.py b/src/sage/rings/finite_rings/finite_field_prime_modn.py
+index 9129ecb56a..d5a4cb8f22 100644
+--- a/src/sage/rings/finite_rings/finite_field_prime_modn.py
++++ b/src/sage/rings/finite_rings/finite_field_prime_modn.py
+@@ -111,7 +111,7 @@ class FiniteField_prime_modn(FiniteField_generic, integer_mod_ring.IntegerModRin
+             sage: RF13 = K.residue_field(pp)
+             sage: RF13.hom([GF(13)(1)])
+             Ring morphism:
+-             From: Residue field of Fractional ideal (w + 18)
++             From: Residue field of Fractional ideal (-w - 18)
+              To:   Finite Field of size 13
+              Defn: 1 |--> 1
+ 
+diff --git a/src/sage/rings/finite_rings/residue_field.pyx b/src/sage/rings/finite_rings/residue_field.pyx
+index 7596f2a302..1e1869f1b1 100644
+--- a/src/sage/rings/finite_rings/residue_field.pyx
++++ b/src/sage/rings/finite_rings/residue_field.pyx
+@@ -20,13 +20,13 @@ monogenic (i.e., 2 is an essential discriminant divisor)::
+ 
+     sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8)
+     sage: F = K.factor(2); F
+-    (Fractional ideal (1/2*a^2 - 1/2*a + 1)) * (Fractional ideal (-a^2 + 2*a - 3)) * (Fractional ideal (-3/2*a^2 + 5/2*a - 4))
++    (Fractional ideal (-1/2*a^2 + 1/2*a - 1)) * (Fractional ideal (-a^2 + 2*a - 3)) * (Fractional ideal (3/2*a^2 - 5/2*a + 4))
+     sage: F[0][0].residue_field()
+-    Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++    Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+     sage: F[1][0].residue_field()
+     Residue field of Fractional ideal (-a^2 + 2*a - 3)
+     sage: F[2][0].residue_field()
+-    Residue field of Fractional ideal (-3/2*a^2 + 5/2*a - 4)
++    Residue field of Fractional ideal (3/2*a^2 - 5/2*a + 4)
+ 
+ We can also form residue fields from `\ZZ`::
+ 
+@@ -258,9 +258,9 @@ class ResidueFieldFactory(UniqueFactory):
+     the index of ``ZZ[a]`` in the maximal order for all ``a``::
+ 
+         sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8); P = K.ideal(2).factor()[0][0]; P
+-        Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F = K.residue_field(P); F
+-        Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F(a)
+         0
+         sage: B = K.maximal_order().basis(); B
+@@ -270,7 +270,7 @@ class ResidueFieldFactory(UniqueFactory):
+         sage: F(B[2])
+         0
+         sage: F
+-        Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F.degree()
+         1
+ 
+@@ -730,15 +730,15 @@ class ResidueField_generic(Field):
+         EXAMPLES::
+ 
+             sage: I = QQ[3^(1/3)].factor(5)[1][0]; I
+-            Fractional ideal (-a + 2)
++            Fractional ideal (a - 2)
+             sage: k = I.residue_field(); k
+-            Residue field of Fractional ideal (-a + 2)
++            Residue field of Fractional ideal (a - 2)
+             sage: f = k.lift_map(); f
+             Lifting map:
+-              From: Residue field of Fractional ideal (-a + 2)
++              From: Residue field of Fractional ideal (a - 2)
+               To:   Maximal Order in Number Field in a with defining polynomial x^3 - 3 with a = 1.442249570307409?
+             sage: f.domain()
+-            Residue field of Fractional ideal (-a + 2)
++            Residue field of Fractional ideal (a - 2)
+             sage: f.codomain()
+             Maximal Order in Number Field in a with defining polynomial x^3 - 3 with a = 1.442249570307409?
+             sage: f(k.0)
+@@ -768,7 +768,7 @@ class ResidueField_generic(Field):
+ 
+             sage: K.<a> = NumberField(x^3-11)
+             sage: F = K.ideal(37).factor(); F
+-            (Fractional ideal (37, a + 9)) * (Fractional ideal (37, a + 12)) * (Fractional ideal (2*a - 5))
++            (Fractional ideal (37, a + 9)) * (Fractional ideal (37, a + 12)) * (Fractional ideal (-2*a + 5))
+             sage: k = K.residue_field(F[0][0])
+             sage: l = K.residue_field(F[1][0])
+             sage: k == l
+@@ -846,7 +846,7 @@ cdef class ReductionMap(Map):
+             sage: F.reduction_map()
+             Partially defined reduction map:
+               From: Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
+-              To:   Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++              To:   Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+ 
+             sage: K.<theta_5> = CyclotomicField(5)
+             sage: F = K.factor(7)[0][0].residue_field()
+diff --git a/src/sage/rings/number_field/S_unit_solver.py b/src/sage/rings/number_field/S_unit_solver.py
+index e99dff850f..759cbfb334 100644
+--- a/src/sage/rings/number_field/S_unit_solver.py
++++ b/src/sage/rings/number_field/S_unit_solver.py
+@@ -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 (xi - 3),
+-         Fractional ideal (-2*xi^2 + 3),
++        (Fractional ideal (-2*xi^2 + 3),
++         Fractional ideal (-xi + 3),
+          Fractional ideal (2*xi + 1))
+ 
+         sage: sieve_data[1]
+-        (Residue field of Fractional ideal (xi - 3),
+-         Residue field of Fractional ideal (-2*xi^2 + 3),
++        (Residue field of Fractional ideal (-2*xi^2 + 3),
++         Residue field of Fractional ideal (-xi + 3),
+          Residue field of Fractional ideal (2*xi + 1))
+ 
+         sage: sieve_data[2]
+-        ([18, 7, 16, 4], [18, 9, 12, 8], [18, 3, 10, 10])
++        ([18, 12, 16, 8], [18, 16, 10, 4], [18, 10, 12, 10])
+ 
+         sage: sieve_data[3]
+-        (486, 648, 11664)
++        (648, 2916, 3888)
+     """
+ 
+     K = SUK.number_field()
+diff --git a/src/sage/rings/number_field/bdd_height.py b/src/sage/rings/number_field/bdd_height.py
+index beb047ae02..b7c8c33d0b 100644
+--- a/src/sage/rings/number_field/bdd_height.py
++++ b/src/sage/rings/number_field/bdd_height.py
+@@ -248,7 +248,7 @@ def bdd_norm_pr_ideal_gens(K, norm_list):
+         sage: from sage.rings.number_field.bdd_height import bdd_norm_pr_ideal_gens
+         sage: K.<g> = QuadraticField(123)
+         sage: bdd_norm_pr_ideal_gens(K, range(5))
+-        {0: [0], 1: [1], 2: [-g - 11], 3: [], 4: [2]}
++        {0: [0], 1: [1], 2: [g + 11], 3: [], 4: [2]}
+ 
+     ::
+ 
+diff --git a/src/sage/rings/number_field/class_group.py b/src/sage/rings/number_field/class_group.py
+index 018ff5f5c6..73c0462cd1 100644
+--- a/src/sage/rings/number_field/class_group.py
++++ b/src/sage/rings/number_field/class_group.py
+@@ -221,11 +221,11 @@ class FractionalIdealClass(AbelianGroupWithValuesElement):
+             Class group of order 76 with structure C38 x C2
+             of Number Field in a with defining polynomial x^2 + 20072
+             sage: I = (G.0)^11; I
+-            Fractional ideal class (41, 1/2*a + 5)
++            Fractional ideal class (33, 1/2*a + 8)
+             sage: J = G(I.ideal()^5); J
+-            Fractional ideal class (115856201, 1/2*a + 40407883)
++            Fractional ideal class (39135393, 1/2*a + 13654253)
+             sage: J.reduce()
+-            Fractional ideal class (57, 1/2*a + 44)
++            Fractional ideal class (73, 1/2*a + 47)
+             sage: J == I^5
+             True
+         """
+diff --git a/src/sage/rings/number_field/galois_group.py b/src/sage/rings/number_field/galois_group.py
+index 79acd053bb..e060148e4d 100644
+--- a/src/sage/rings/number_field/galois_group.py
++++ b/src/sage/rings/number_field/galois_group.py
+@@ -944,7 +944,7 @@ class GaloisGroup_v2(GaloisGroup_perm):
+             sage: K.<b> = NumberField(x^4 - 2*x^2 + 2, 'a').galois_closure()
+             sage: G = K.galois_group()
+             sage: [G.artin_symbol(P) for P in K.primes_above(7)]
+-            [(1,5)(2,6)(3,7)(4,8), (1,5)(2,6)(3,7)(4,8), (1,4)(2,3)(5,8)(6,7), (1,4)(2,3)(5,8)(6,7)]
++            [(1,4)(2,3)(5,8)(6,7), (1,4)(2,3)(5,8)(6,7), (1,5)(2,6)(3,7)(4,8), (1,5)(2,6)(3,7)(4,8)]
+             sage: G.artin_symbol(17)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
+index 58463d570d..ff65634e99 100644
+--- a/src/sage/rings/number_field/number_field.py
++++ b/src/sage/rings/number_field/number_field.py
+@@ -3643,7 +3643,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
+ 
+@@ -4227,7 +4227,8 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             (y^2 + 6, Mod(1/6*y, y^2 + 6), Mod(6*y, y^2 + 1/6))
+         """
+         f = self.absolute_polynomial()._pari_with_name('y')
+-        if f.pollead() == f.content().denominator() == 1:
++        f = f * f.content().denominator()
++        if f.pollead() == 1:
+             g = f
+             alpha = beta = g.variable().Mod(g)
+         else:
+@@ -4821,7 +4822,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+ 
+             sage: K.<a> = NumberField(2*x^2 - 1/3)
+             sage: K._S_class_group_and_units(tuple(K.primes_above(2) + K.primes_above(3)))
+-            ([-6*a + 2, 6*a + 3, -1, 12*a + 5], [])
++            ([6*a + 2, 6*a + 3, -1, -12*a + 5], [])
+         """
+         K_pari = self.pari_bnf(proof=proof)
+         S_pari = [p.pari_prime() for p in sorted(set(S))]
+@@ -5166,7 +5167,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+ 
+             sage: [K.ideal(g).factor() for g in gens]
+             [(Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1)),
+-            Fractional ideal (-a),
++            Fractional ideal (a),
+             (Fractional ideal (2, a + 1))^2,
+             1]
+ 
+@@ -5751,7 +5752,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: K.elements_of_norm(3)
+             []
+             sage: K.elements_of_norm(50)
+-            [-7*a + 1, 5*a - 5, 7*a + 1]
++            [-a - 7, 5*a - 5, 7*a + 1]
+ 
+         TESTS:
+ 
+@@ -5863,7 +5864,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: K.factor(1+a)
+             Fractional ideal (a + 1)
+             sage: K.factor(1+a/5)
+-            (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1 * (Fractional ideal (-3*a - 2))
++            (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1 * (Fractional ideal (-2*a + 3))
+ 
+         An example over a relative number field::
+ 
+@@ -6460,9 +6461,9 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: new_basis = k.reduced_basis(prec=120)
+             sage: [c.minpoly() for c in new_basis]
+             [x - 1,
+-             x^2 - x + 1,
++             x^2 + x + 1,
++             x^6 + 3*x^5 - 102*x^4 - 103*x^3 + 10572*x^2 - 59919*x + 127657,
+              x^6 + 3*x^5 - 102*x^4 - 103*x^3 + 10572*x^2 - 59919*x + 127657,
+-             x^6 - 3*x^5 - 102*x^4 + 315*x^3 + 10254*x^2 - 80955*x + 198147,
+              x^3 - 171*x + 848,
+              x^6 + 171*x^4 + 1696*x^3 + 29241*x^2 + 145008*x + 719104]
+             sage: R = k.order(new_basis)
+@@ -7058,7 +7059,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+              -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)
++             2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7)
+ 
+         TESTS:
+ 
+@@ -7067,7 +7068,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)
+ 
+@@ -7146,7 +7147,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^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]
++            [-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, 2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7]
+         """
+         proof = proof_flag(proof)
+ 
+diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx
+index 784c239dc1..aa740069dc 100644
+--- a/src/sage/rings/number_field/number_field_element.pyx
++++ b/src/sage/rings/number_field/number_field_element.pyx
+@@ -4446,7 +4446,7 @@ cdef class NumberFieldElement(FieldElement):
+             sage: f = Qi.embeddings(K)[0]
+             sage: a = f(2+3*i) * (2-zeta)^2
+             sage: a.descend_mod_power(Qi,2)
+-            [-3*i - 2, -2*i + 3]
++            [-2*i + 3, 3*i + 2]
+ 
+         An absolute example::
+ 
+@@ -5124,7 +5124,7 @@ cdef class NumberFieldElement_relative(NumberFieldElement):
+         EXAMPLES::
+ 
+             sage: K.<a, b, c> = NumberField([x^2 - 2, x^2 - 3, x^2 - 5])
+-            sage: P = K.prime_factors(5)[0]
++            sage: P = K.prime_factors(5)[1]
+             sage: (2*a + b - c).valuation(P)
+             1
+         """
+diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
+index 5f587556a4..33481fead0 100644
+--- a/src/sage/rings/number_field/number_field_ideal.py
++++ b/src/sage/rings/number_field/number_field_ideal.py
+@@ -3355,7 +3355,7 @@ def quotient_char_p(I, p):
+         []
+ 
+         sage: I = K.factor(13)[0][0]; I
+-        Fractional ideal (-3*i - 2)
++        Fractional ideal (-2*i + 3)
+         sage: I.residue_class_degree()
+         1
+         sage: quotient_char_p(I, 13)[0]
+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 bae36d4b9c..f64bd5b761 100644
+--- a/src/sage/rings/number_field/number_field_ideal_rel.py
++++ b/src/sage/rings/number_field/number_field_ideal_rel.py
+@@ -272,7 +272,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.gens_reduced()
+-            (2, 15*a*b + 3*a + 1)
++            (2, -15*a*b + 3*a + 1)
+         """
+         try:
+             # Compute the single generator, if it exists
+@@ -401,7 +401,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.relative_norm()
+-            Fractional ideal (-6*a + 2)
++            Fractional ideal (6*a + 2)
+         """
+         L = self.number_field()
+         K = L.base_field()
+@@ -518,7 +518,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.ideal_below()
+-            Fractional ideal (-6*a + 2)
++            Fractional ideal (6*a + 2)
+         """
+         L = self.number_field()
+         K = L.base_field()
+diff --git a/src/sage/rings/number_field/number_field_rel.py b/src/sage/rings/number_field/number_field_rel.py
+index d33980c4b1..50e846b205 100644
+--- a/src/sage/rings/number_field/number_field_rel.py
++++ b/src/sage/rings/number_field/number_field_rel.py
+@@ -213,14 +213,14 @@ class NumberField_relative(NumberField_generic):
+             sage: l.<b> = k.extension(5*x^2 + 3); l
+             Number Field in b with defining polynomial 5*x^2 + 3 over its base field
+             sage: l.pari_rnf()
+-            [x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4), ..., y^4 + 6*y^2 + 1, x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4)], [0, 0]]
++            [x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4), ..., y^4 + 6*y^2 + 1, x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4)], [0, 0]]
+             sage: b
+             b
+ 
+             sage: l.<b> = k.extension(x^2 + 3/5); l
+             Number Field in b with defining polynomial x^2 + 3/5 over its base field
+             sage: l.pari_rnf()
+-            [x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4), ..., y^4 + 6*y^2 + 1, x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4)], [0, 0]]
++            [x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4), ..., y^4 + 6*y^2 + 1, x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4)], [0, 0]]
+             sage: b
+             b
+ 
+diff --git a/src/sage/rings/number_field/order.py b/src/sage/rings/number_field/order.py
+index 6eca89ed8d..78ef4c3b33 100644
+--- a/src/sage/rings/number_field/order.py
++++ b/src/sage/rings/number_field/order.py
+@@ -520,7 +520,7 @@ class Order(IntegralDomain, sage.rings.abc.Order):
+             sage: k.<a> = NumberField(x^2 + 5077); G = k.class_group(); G
+             Class group of order 22 with structure C22 of Number Field in a with defining polynomial x^2 + 5077
+             sage: G.0 ^ -9
+-            Fractional ideal class (11, a + 7)
++            Fractional ideal class (43, a + 13)
+             sage: Ok = k.maximal_order(); Ok
+             Maximal Order in Number Field in a with defining polynomial x^2 + 5077
+             sage: Ok * (11, a + 7)
+diff --git a/src/sage/rings/number_field/selmer_group.py b/src/sage/rings/number_field/selmer_group.py
+index c534aaa9f6..6bc67565d2 100644
+--- a/src/sage/rings/number_field/selmer_group.py
++++ b/src/sage/rings/number_field/selmer_group.py
+@@ -491,7 +491,7 @@ def pSelmerGroup(K, S, p, proof=None, debug=False):
+ 
+         sage: [K.ideal(g).factor() for g in gens]
+         [(Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1)),
+-        Fractional ideal (-a),
++        Fractional ideal (a),
+         (Fractional ideal (2, a + 1))^2,
+         1]
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
+index bb5d8356be..8a7e5fa66f 100644
+--- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
++++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
+@@ -1791,7 +1791,7 @@ class PolynomialQuotientRing_generic(CommutativeRing):
+             sage: D.selmer_generators([K.ideal(2, -a+1), K.ideal(3, a+1)], 3)
+             [2, a + 1]
+             sage: D.selmer_generators([K.ideal(2, -a+1), K.ideal(3, a+1), K.ideal(a)], 3)
+-            [2, a + 1, a]
++            [2, a + 1, -a]
+ 
+         """
+         fields, isos, iso_classes = self._S_decomposition(tuple(S))
+diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py
+index 704b77ce5f..83ee4549e4 100644
+--- a/src/sage/rings/qqbar.py
++++ b/src/sage/rings/qqbar.py
+@@ -312,8 +312,8 @@ and we get a way to produce the number directly::
+     True
+     sage: sage_input(n)
+     R.<y> = QQ[]
+-    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(RR(0.51763809020504148), RR(0.51763809020504159)))
+-    -109*v^3 - 89*v^2 + 327*v + 178
++    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(-RR(1.9318516525781366), -RR(1.9318516525781364)))
++    -109*v^3 + 89*v^2 + 327*v - 178
+ 
+ We can also see that some computations (basically, those which are
+ easy to perform exactly) are performed directly, instead of storing
+@@ -362,7 +362,7 @@ algorithms in :trac:`10255`::
+     # Verified
+     R1.<x> = QQbar[]
+     R2.<y> = QQ[]
+-    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(RR(0.51763809020504148), RR(0.51763809020504159)))
++    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(-RR(1.9318516525781366), -RR(1.9318516525781364)))
+     AA.polynomial_root(AA.common_polynomial(x^4 + QQbar(v^3 - 3*v - 1)*x^3 + QQbar(-v^3 + 3*v - 3)*x^2 + QQbar(-3*v^3 + 9*v + 3)*x + QQbar(3*v^3 - 9*v)), RIF(RR(0.99999999999999989), RR(1.0000000000000002)))
+     sage: one
+     1
+@@ -2310,7 +2310,7 @@ def do_polred(poly, threshold=32):
+     cost = 2 * bitsize.nbits() + 5 * poly.degree().nbits()
+     if cost > threshold:
+         return parent.gen(), parent.gen(), poly
+-    new_poly, elt_back = poly.__pari__().polredbest(flag=1)
++    new_poly, elt_back = poly.numerator().__pari__().polredbest(flag=1)
+     elt_fwd = elt_back.modreverse()
+     return parent(elt_fwd.lift()), parent(elt_back.lift()), parent(new_poly)
+ 
+@@ -2542,10 +2542,10 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+            Defn: a |--> 1.414213562373095?)
+ 
+         sage: number_field_elements_from_algebraics((rt2,rt3))
+-        (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, [-a^3 + 3*a, -a^2 + 2], Ring morphism:
++        (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, [-a^3 + 3*a, a^2 - 2], Ring morphism:
+             From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+             To:   Algebraic Real Field
+-            Defn: a |--> 0.5176380902050415?)
++            Defn: a |--> -1.931851652578137?)
+ 
+     ``rt3a`` is a real number in ``QQbar``.  Ordinarily, we'd get a homomorphism
+     to ``AA`` (because all elements are real), but if we specify ``same_field=True``,
+@@ -2570,7 +2570,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, -a^3 + 3*a, Ring morphism:
+             From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+             To:   Algebraic Real Field
+-            Defn: a |--> 0.5176380902050415?)
++            Defn: a |--> -1.931851652578137?)
+ 
+     We can specify ``minimal=True`` if we want the smallest number field::
+ 
+@@ -2618,7 +2618,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         sage: nfI^2
+         -1
+         sage: sum = nfrt2 + nfrt3 + nfI + nfz3; sum
+-        2*a^6 + a^5 - a^4 - a^3 - 2*a^2 - a
++        a^5 + a^4 - a^3 + 2*a^2 - a - 1
+         sage: hom(sum)
+         2.646264369941973? + 1.866025403784439?*I
+         sage: hom(sum) == rt2 + rt3 + qqI + z3
+@@ -2658,7 +2658,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         sage: nf, nums, hom = number_field_elements_from_algebraics(elems, embedded=True)
+         sage: nf
+         Number Field in a with defining polynomial y^24 - 6*y^23 ...- 9*y^2 + 1
+-          with a = 0.2598678911433438? + 0.0572892247058457?*I
++          with a = 0.2598679? + 0.0572892?*I
+         sage: list(map(QQbar, nums)) == elems == list(map(hom, nums))
+         True
+ 
+@@ -2725,7 +2725,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+                          sqrt(2), AA.polynomial_root(x^3-3, RIF(0,3)), 11/9, 1]
+         sage: res = number_field_elements_from_algebraics(my_nums, embedded=True)
+         sage: res[0]
+-        Number Field in a with defining polynomial y^24 - 107010*y^22 - 24*y^21 + ... + 250678447193040618624307096815048024318853254384 with a = -95.5053039433554?
++        Number Field in a with defining polynomial y^24 - 107010*y^22 - 24*y^21 + ... + 250678447193040618624307096815048024318853254384 with a = 93.32530798172420?
+     """
+     gen = qq_generator
+ 
+@@ -3129,7 +3129,7 @@ class AlgebraicGenerator(SageObject):
+             sage: root = ANRoot(x^2 - x - 1, RIF(1, 2))
+             sage: gen = AlgebraicGenerator(nf, root)
+             sage: gen.pari_field()
+-             [y^2 - y - 1, [2, 0], ...]
++            [[y^2 - y - 1, [2, 0], ...]
+         """
+         if self.is_trivial():
+             raise ValueError("No PARI field attached to trivial generator")
+@@ -3213,7 +3213,7 @@ class AlgebraicGenerator(SageObject):
+             sage: qq_generator.union(gen3) is gen3
+             True
+             sage: gen2.union(gen3)
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+         """
+         if self._trivial:
+             return other
+@@ -3306,13 +3306,13 @@ class AlgebraicGenerator(SageObject):
+             Number Field in a with defining polynomial y^2 - 3 with a in 1.732050807568878?
+             sage: gen2_3 = gen2.union(gen3)
+             sage: gen2_3
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+             sage: qq_generator.super_poly(gen2) is None
+             True
+             sage: gen2.super_poly(gen2_3)
+             -a^3 + 3*a
+             sage: gen3.super_poly(gen2_3)
+-            -a^2 + 2
++            a^2 - 2
+ 
+         """
+         if checked is None:
+@@ -3360,13 +3360,13 @@ class AlgebraicGenerator(SageObject):
+             sage: sqrt3 = ANExtensionElement(gen3, nf3.gen())
+             sage: gen2_3 = gen2.union(gen3)
+             sage: gen2_3
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+             sage: gen2_3(sqrt2)
+             -a^3 + 3*a
+             sage: gen2_3(ANRational(1/7))
+             1/7
+             sage: gen2_3(sqrt3)
+-            -a^2 + 2
++            a^2 - 2
+         """
+         if self._trivial:
+             return elt._value
+@@ -4336,10 +4336,10 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: rt3 = AA(sqrt(3))
+             sage: rt3b = rt2 + rt3 - rt2
+             sage: rt3b.as_number_field_element()
+-            (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, -a^2 + 2, Ring morphism:
++            (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, a^2 - 2, Ring morphism:
+                 From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+                 To:   Algebraic Real Field
+-                Defn: a |--> 0.5176380902050415?)
++                Defn: a |--> -1.931851652578137?)
+             sage: rt3b.as_number_field_element(minimal=True)
+             (Number Field in a with defining polynomial y^2 - 3, a, Ring morphism:
+                From: Number Field in a with defining polynomial y^2 - 3
+@@ -4401,7 +4401,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: rt2b = rt3 + rt2 - rt3
+             sage: rt2b.exactify()
+             sage: rt2b._exact_value()
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b.simplify()
+             sage: rt2b._exact_value()
+             a where a^2 - 2 = 0 and a in 1.414213562373095?
+@@ -4422,7 +4422,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: QQbar(2)._exact_field()
+             Trivial generator
+             sage: (sqrt(QQbar(2)) + sqrt(QQbar(19)))._exact_field()
+-            Number Field in a with defining polynomial y^4 - 20*y^2 + 81 with a in 2.375100220297941?
++            Number Field in a with defining polynomial y^4 - 20*y^2 + 81 with a in -3.789313782671036?
+             sage: (QQbar(7)^(3/5))._exact_field()
+             Number Field in a with defining polynomial y^5 - 2*y^4 - 18*y^3 + 38*y^2 + 82*y - 181 with a in 2.554256611698490?
+         """
+@@ -4442,7 +4442,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: QQbar(2)._exact_value()
+             2
+             sage: (sqrt(QQbar(2)) + sqrt(QQbar(19)))._exact_value()
+-            -1/9*a^3 - a^2 + 11/9*a + 10 where a^4 - 20*a^2 + 81 = 0 and a in 2.375100220297941?
++            -1/9*a^3 + a^2 + 11/9*a - 10 where a^4 - 20*a^2 + 81 = 0 and a in -3.789313782671036?
+             sage: (QQbar(7)^(3/5))._exact_value()
+             2*a^4 + 2*a^3 - 34*a^2 - 17*a + 150 where a^5 - 2*a^4 - 18*a^3 + 38*a^2 + 82*a - 181 = 0 and a in 2.554256611698490?
+         """
+@@ -6857,7 +6857,7 @@ class AlgebraicPolynomialTracker(SageObject):
+             sage: p = sqrt(AA(2)) * x^2 - sqrt(AA(3))
+             sage: cp = AA.common_polynomial(p)
+             sage: cp.generator()
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 1.931851652578137?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -0.5176380902050415?
+         """
+         self.exactify()
+         return self._gen
+@@ -7706,7 +7706,7 @@ class ANExtensionElement(ANDescr):
+ 
+             sage: rt2b.exactify()
+             sage: rt2b._descr
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b._descr.is_simple()
+             False
+         """
+@@ -7791,7 +7791,7 @@ class ANExtensionElement(ANDescr):
+             sage: rt2b = rt3 + rt2 - rt3
+             sage: rt2b.exactify()
+             sage: rt2b._descr
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b._descr.simplify(rt2b)
+             a where a^2 - 2 = 0 and a in 1.414213562373095?
+         """
+@@ -7830,9 +7830,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.neg(a)
+-            1/3*a^3 - 2/3*a^2 + 4/3*a - 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -1/3*a^3 + 1/3*a^2 - a - 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+             sage: b.neg("ham spam and eggs")
+-            1/3*a^3 - 2/3*a^2 + 4/3*a - 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -1/3*a^3 + 1/3*a^2 - a - 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+         """
+         return ANExtensionElement(self._generator, -self._value)
+ 
+@@ -7848,9 +7848,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.invert(a)
+-            7/3*a^3 - 2/3*a^2 + 4/3*a - 12 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -7/3*a^3 + 19/3*a^2 - 7*a - 9 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+             sage: b.invert("ham spam and eggs")
+-            7/3*a^3 - 2/3*a^2 + 4/3*a - 12 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -7/3*a^3 + 19/3*a^2 - 7*a - 9 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+         """
+         return ANExtensionElement(self._generator, ~self._value)
+ 
+@@ -7866,9 +7866,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.conjugate(a)
+-            -1/3*a^3 + 2/3*a^2 - 4/3*a + 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? + 1.573132184970987?*I
++            1/3*a^3 - 1/3*a^2 + a + 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? - 1.573132184970987?*I
+             sage: b.conjugate("ham spam and eggs")
+-            -1/3*a^3 + 2/3*a^2 - 4/3*a + 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? + 1.573132184970987?*I
++            1/3*a^3 - 1/3*a^2 + a + 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? - 1.573132184970987?*I
+         """
+         if self._exactly_real:
+             return self
+@@ -8501,7 +8501,7 @@ def an_binop_expr(a, b, op):
+         sage: x = an_binop_expr(a, b, operator.add); x
+         <sage.rings.qqbar.ANBinaryExpr object at ...>
+         sage: x.exactify()
+-        -6/7*a^7 + 2/7*a^6 + 71/7*a^5 - 26/7*a^4 - 125/7*a^3 + 72/7*a^2 + 43/7*a - 47/7 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in 3.12580...?
++        6/7*a^7 - 2/7*a^6 - 71/7*a^5 + 26/7*a^4 + 125/7*a^3 - 72/7*a^2 - 43/7*a + 47/7 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in -0.3199179336182997?
+ 
+         sage: a = QQbar(sqrt(2)) + QQbar(sqrt(3))
+         sage: b = QQbar(sqrt(3)) + QQbar(sqrt(5))
+@@ -8510,7 +8510,7 @@ def an_binop_expr(a, b, op):
+         sage: x = an_binop_expr(a, b, operator.mul); x
+         <sage.rings.qqbar.ANBinaryExpr object at ...>
+         sage: x.exactify()
+-        2*a^7 - a^6 - 24*a^5 + 12*a^4 + 46*a^3 - 22*a^2 - 22*a + 9 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in 3.1258...?
++        2*a^7 - a^6 - 24*a^5 + 12*a^4 + 46*a^3 - 22*a^2 - 22*a + 9 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in -0.3199179336182997?
+     """
+     return ANBinaryExpr(a, b, op)
+ 
+diff --git a/src/sage/schemes/affine/affine_morphism.py b/src/sage/schemes/affine/affine_morphism.py
+index 1c4f2dff18..32c2e47e49 100644
+--- a/src/sage/schemes/affine/affine_morphism.py
++++ b/src/sage/schemes/affine/affine_morphism.py
+@@ -1148,9 +1148,9 @@ class SchemeMorphism_polynomial_affine_space_field(SchemeMorphism_polynomial_aff
+             sage: H = End(A)
+             sage: f = H([(QQbar(sqrt(2))*x^2 + 1/QQbar(sqrt(3))) / (5*x)])
+             sage: f.reduce_base_field()
+-            Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a = 1.931851652578137?
++            Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a = ...?
+               Defn: Defined on coordinates by sending (x) to
+-                    (((a^3 - 3*a)*x^2 + (1/3*a^2 - 2/3))/(5*x))
++                    (((a^3 - 3*a)*x^2 + (-1/3*a^2 + 2/3))/(5*x))
+ 
+         ::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_field.py b/src/sage/schemes/elliptic_curves/ell_field.py
+index 68b8375dae..48f358ea6a 100644
+--- a/src/sage/schemes/elliptic_curves/ell_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_field.py
+@@ -845,7 +845,7 @@ class EllipticCurve_field(ell_generic.EllipticCurve_generic, ProjectivePlaneCurv
+             sage: E = E.base_extend(G).quadratic_twist(c); E
+             Elliptic Curve defined by y^2 = x^3 + 5*a0*x^2 + (-200*a0^2)*x + (-42000*a0^2+42000*a0+126000) over Number Field in a0 with defining polynomial x^3 - 3*x^2 + 3*x + 9
+             sage: K.<b> = E.division_field(3, simplify_all=True); K
+-            Number Field in b with defining polynomial x^12 - 10*x^10 + 55*x^8 - 60*x^6 + 75*x^4 + 1350*x^2 + 2025
++            Number Field in b with defining polynomial x^12 + 5*x^10 + 40*x^8 + 315*x^6 + 750*x^4 + 675*x^2 + 2025
+ 
+         Some higher-degree examples::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_generic.py b/src/sage/schemes/elliptic_curves/ell_generic.py
+index 926ae310ea..3bae819fb0 100644
+--- a/src/sage/schemes/elliptic_curves/ell_generic.py
++++ b/src/sage/schemes/elliptic_curves/ell_generic.py
+@@ -3324,8 +3324,8 @@ 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),
++            [0, 0, 0, Mod(1, y^2 - 2),
++            Mod(y, y^2 - 2), 0, 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;
+diff --git a/src/sage/schemes/elliptic_curves/ell_number_field.py b/src/sage/schemes/elliptic_curves/ell_number_field.py
+index edbd196090..c44c803aa8 100644
+--- a/src/sage/schemes/elliptic_curves/ell_number_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_number_field.py
+@@ -218,7 +218,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: E == loads(dumps(E))
+             True
+             sage: E.simon_two_descent()
+-            (2, 2, [(0 : 0 : 1)])
++            (2, 2, [(0 : 0 : 1), (1/18*a + 7/18 : -5/54*a - 17/54 : 1)])
+             sage: E.simon_two_descent(lim1=5, lim3=5, limtriv=10, maxprob=7, limbigprime=10)
+             (2, 2, [(-1 : 0 : 1), (-2 : -1/2*a - 1/2 : 1)])
+ 
+@@ -274,7 +274,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: E.simon_two_descent()  # long time (4s on sage.math, 2013)
+             (3,
+              3,
+-             [(5/8*zeta43_0^2 + 17/8*zeta43_0 - 9/4 : -27/16*zeta43_0^2 - 103/16*zeta43_0 + 39/8 : 1),
++             [(1/8*zeta43_0^2 - 3/8*zeta43_0 - 1/4 : -5/16*zeta43_0^2 + 7/16*zeta43_0 + 1/8 : 1),
+               (0 : 0 : 1)])
+         """
+         verbose = int(verbose)
+@@ -865,7 +865,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             Conductor exponent: 1
+             Kodaira Symbol: I1
+             Tamagawa Number: 1,
+-            Local data at Fractional ideal (-3*i - 2):
++            Local data at Fractional ideal (-2*i + 3):
+             Reduction type: bad split multiplicative
+             Local minimal model: Elliptic Curve defined by y^2 + (i+1)*x*y + y = x^3 over Number Field in i with defining polynomial x^2 + 1
+             Minimal discriminant valuation: 2
+@@ -2645,12 +2645,12 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             [-92, -23, -23]
+ 
+             sage: C.matrix()  # long time
+-            [1 2 2 4 2 4]
+-            [2 1 2 2 4 4]
+-            [2 2 1 4 4 2]
+-            [4 2 4 1 3 3]
+-            [2 4 4 3 1 3]
+-            [4 4 2 3 3 1]
++            [1 2 2 4 4 2]
++            [2 1 2 4 2 4]
++            [2 2 1 2 4 4]
++            [4 4 2 1 3 3]
++            [4 2 4 3 1 3]
++            [2 4 4 3 3 1]
+ 
+         The graph of this isogeny class has a shape which does not
+         occur over `\QQ`: a triangular prism.  Note that for curves
+@@ -2677,12 +2677,12 @@ class EllipticCurve_number_field(EllipticCurve_field):
+ 
+             sage: G = C.graph()  # long time
+             sage: G.adjacency_matrix()  # long time
+-            [0 1 1 0 1 0]
+-            [1 0 1 1 0 0]
+-            [1 1 0 0 0 1]
+-            [0 1 0 0 1 1]
+-            [1 0 0 1 0 1]
+-            [0 0 1 1 1 0]
++            [0 1 1 0 0 1]
++            [1 0 1 0 1 0]
++            [1 1 0 1 0 0]
++            [0 0 1 0 1 1]
++            [0 1 0 1 0 1]
++            [1 0 0 1 1 0]
+ 
+         To display the graph without any edge labels::
+ 
+@@ -3316,7 +3316,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: points = [E.lift_x(x) for x in xi]
+             sage: newpoints, U = E.lll_reduce(points)  # long time (35s on sage.math, 2011)
+             sage: [P[0] for P in newpoints]            # long time
+-            [6823803569166584943, 5949539878899294213, 2005024558054813068, 5864879778877955778, 23955263915878682727/4, 5922188321411938518, 5286988283823825378, 175620639884534615751/25, -11451575907286171572, 3502708072571012181, 1500143935183238709184/225, 27180522378120223419/4, -5811874164190604461581/625, 26807786527159569093, 7404442636649562303, 475656155255883588, 265757454726766017891/49, 7272142121019825303, 50628679173833693415/4, 6951643522366348968, 6842515151518070703, 111593750389650846885/16, 2607467890531740394315/9, -1829928525835506297]
++            [6823803569166584943, 5949539878899294213, 2005024558054813068, 5864879778877955778, 23955263915878682727/4, 5922188321411938518, 5286988283823825378, 11465667352242779838, -11451575907286171572, 3502708072571012181, 1500143935183238709184/225, 27180522378120223419/4, -5811874164190604461581/625, 26807786527159569093, 7041412654828066743, 475656155255883588, 265757454726766017891/49, 7272142121019825303, 50628679173833693415/4, 6951643522366348968, 6842515151518070703, 111593750389650846885/16, 2607467890531740394315/9, -1829928525835506297]
+ 
+         An example to show the explicit use of the height pairing matrix::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_rational_field.py b/src/sage/schemes/elliptic_curves/ell_rational_field.py
+index 3808822812..a75290ea35 100644
+--- a/src/sage/schemes/elliptic_curves/ell_rational_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_rational_field.py
+@@ -1827,7 +1827,7 @@ class EllipticCurve_rational_field(EllipticCurve_number_field):
+             sage: E = EllipticCurve('389a1')
+             sage: E._known_points = []  # clear cached points
+             sage: E.simon_two_descent()
+-            (2, 2, [(1 : 0 : 1), (-11/9 : 28/27 : 1)])
++            (2, 2, [(5/4 : 5/8 : 1), (-3/4 : 7/8 : 1)])
+             sage: E = EllipticCurve('5077a1')
+             sage: E.simon_two_descent()
+             (3, 3, [(1 : 0 : 1), (2 : 0 : 1), (0 : 2 : 1)])
+diff --git a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
+index 81ad295160..d484a4a18b 100644
+--- a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
++++ b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
+@@ -780,12 +780,12 @@ def deg_one_primes_iter(K, principal_only=False):
+         [Fractional ideal (2, a + 1),
+          Fractional ideal (3, a + 1),
+          Fractional ideal (3, a + 2),
+-         Fractional ideal (-a),
++         Fractional ideal (a),
+          Fractional ideal (7, a + 3),
+          Fractional ideal (7, a + 4)]
+         sage: it = deg_one_primes_iter(K, True)
+         sage: [next(it) for _ in range(6)]
+-        [Fractional ideal (-a),
++        [Fractional ideal (a),
+          Fractional ideal (-2*a + 3),
+          Fractional ideal (2*a + 3),
+          Fractional ideal (a + 6),
+diff --git a/src/sage/schemes/elliptic_curves/gp_simon.py b/src/sage/schemes/elliptic_curves/gp_simon.py
+index 28b97f34af..9f7d1b6020 100644
+--- a/src/sage/schemes/elliptic_curves/gp_simon.py
++++ b/src/sage/schemes/elliptic_curves/gp_simon.py
+@@ -56,7 +56,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+         sage: import sage.schemes.elliptic_curves.gp_simon
+         sage: E=EllipticCurve('389a1')
+         sage: sage.schemes.elliptic_curves.gp_simon.simon_two_descent(E)
+-        (2, 2, [(1 : 0 : 1), (-11/9 : 28/27 : 1)])
++        (2, 2, [(5/4 : 5/8 : 1), (-3/4 : 7/8 : 1)])
+ 
+     TESTS::
+ 
+@@ -117,7 +117,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+     # The block below mimics the defaults in Simon's scripts, and needs to be changed
+     # when these are updated.
+     if K is QQ:
+-        cmd = 'ellrank(%s, %s);' % (list(E.ainvs()), [P.__pari__() for P in known_points])
++        cmd = 'ellQ_ellrank(%s, %s);' % (list(E.ainvs()), [P.__pari__() for P in known_points])
+         if lim1 is None:
+             lim1 = 5
+         if lim3 is None:
+@@ -144,7 +144,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+     if verbose > 0:
+         print(s)
+     v = gp.eval('ans')
+-    if v=='ans': # then the call to ellrank() or bnfellrank() failed
++    if v=='ans': # then the call to ellQ_ellrank() or bnfellrank() failed
+         raise RuntimeError("An error occurred while running Simon's 2-descent program")
+     if verbose >= 2:
+         print("v = %s" % v)
+diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
+index a936deb74f..dc19254d8c 100644
+--- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
++++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
+@@ -1208,14 +1208,14 @@ def isogenies_13_0(E, minimal_models=True):
+         sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]  # long time (4s)
+         [(0,
+           0,
+-          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
++          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 + 1887439/1146978983704320*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 + 1030632647/7965131831280*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 - 43618899433/204234149520*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 2535050171/1418292705,
+           -139861295/2650795873449984*a^11 - 3455957/5664093746688*a^10 - 345310571/50976843720192*a^9 - 500530795/118001953056*a^8 - 12860048113/265504394376*a^7 - 25007420461/44250732396*a^6 + 458134176455/1416023436672*a^5 + 16701880631/9077073312*a^4 + 155941666417/9077073312*a^3 + 3499310115/378211388*a^2 - 736774863/94552847*a - 21954102381/94552847,
+-          579363345221/13763747804451840*a^11 + 371192377511/860234237778240*a^10 + 8855090365657/1146978983704320*a^9 + 5367261541663/1633873196160*a^8 + 614883554332193/15930263662560*a^7 + 30485197378483/68078049840*a^6 - 131000897588387/2450809794240*a^5 - 203628705777949/306351224280*a^4 - 1587619388190379/204234149520*a^3 + 14435069706551/11346341640*a^2 + 7537273048614/472764235*a + 89198980034806/472764235),
++          8342795944891/198197968384106496*a^11 + 8908625263589/20645621706677760*a^10 + 53130542636623/6881873902225920*a^9 + 376780111042213/114697898370432*a^8 + 614884052146333/15930263662560*a^7 + 3566768133324359/7965131831280*a^6 - 1885593809102545/35291661037056*a^5 - 2443732172026523/3676214691360*a^4 - 9525729503937541/1225404897120*a^3 + 51990274442321/40846829904*a^2 + 67834019370596/4254878115*a + 267603083706812/1418292705),
+          (0,
+           0,
+-          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
++          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 + 1887439/1146978983704320*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 + 1030632647/7965131831280*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 - 43618899433/204234149520*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 2535050171/1418292705,
+           -6465569317/1325397936724992*a^11 - 112132307/1960647835392*a^10 - 17075412917/25488421860096*a^9 - 207832519229/531008788752*a^8 - 1218275067617/265504394376*a^7 - 9513766502551/177002929584*a^6 + 4297077855437/708011718336*a^5 + 354485975837/4538536656*a^4 + 4199379308059/4538536656*a^3 - 30841577919/189105694*a^2 - 181916484042/94552847*a - 2135779171614/94552847,
+-          -132601797212627/3440936951112960*a^11 - 6212467020502021/13763747804451840*a^10 - 1515926454902497/286744745926080*a^9 - 15154913741799637/4901619588480*a^8 - 576888119803859263/15930263662560*a^7 - 86626751639648671/204234149520*a^6 + 16436657569218427/306351224280*a^5 + 1540027900265659087/2450809794240*a^4 + 375782662805915809/51058537380*a^3 - 14831920924677883/11346341640*a^2 - 7237947774817724/472764235*a - 84773764066089509/472764235)]
++          -1316873026840277/34172063514501120*a^11 - 18637401045099413/41291243413355520*a^10 - 36382234917217247/6881873902225920*a^9 - 61142238484016213/19775499719040*a^8 - 576888119306045123/15930263662560*a^7 - 3378443313906256321/7965131831280*a^6 + 326466167429333279/6084769144320*a^5 + 4620083325391594991/7352429382720*a^4 + 9018783894167184149/1225404897120*a^3 - 9206015742300283/7042556880*a^2 - 65141531411426446/4254878115*a - 254321286054666133/1418292705)]
+     """
+     if E.j_invariant()!=0:
+         raise ValueError("j-invariant must be 0.")
diff --git a/srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15b.patch b/srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15b.patch
new file mode 100644
index 000000000000..762bb2612632
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15b.patch
@@ -0,0 +1,29 @@
+From f0365f30834b6890313790b3845c647d0160fa6a Mon Sep 17 00:00:00 2001
+From: Vincent Delecroix <20100.delecroix@gmail.com*>
+Date: Fri, 30 Sep 2022 16:31:08 +0200
+Subject: fix doctest if fqf_orthogonal
+
+---
+ src/sage/groups/fqf_orthogonal.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/sage/groups/fqf_orthogonal.py b/src/sage/groups/fqf_orthogonal.py
+index 75de408..7fc4dbe 100644
+--- a/src/sage/groups/fqf_orthogonal.py
++++ b/src/sage/groups/fqf_orthogonal.py
+@@ -245,10 +245,10 @@ class FqfOrthogonalGroup(AbelianGroupAutomorphismGroup_subgroup):
+             sage: all(x*f==x*fbar for x in q.gens())
+             True
+             sage: L = IntegralLattice("A2").twist(3)
+-            sage: q = L.discriminant_group()
+             sage: OL = L.orthogonal_group()
++            sage: assert OL(OL.0.matrix()) == OL.0
++            sage: q = L.discriminant_group()
+             sage: Oq = q.orthogonal_group()
+-            sage: assert Oq(OL.0) == Oq(OL.0.matrix())
+             sage: assert Oq(Oq.0.matrix()) == Oq.0
+         """
+         from sage.libs.gap.element import GapElement
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-34668-matplotlib_3.6-5501e0de0dca1cff0355326dd42bd8c7e5749568.patch b/srcpkgs/sagemath/patches/trac-34668-matplotlib_3.6-5501e0de0dca1cff0355326dd42bd8c7e5749568.patch
new file mode 100644
index 000000000000..6afaf1b7162f
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34668-matplotlib_3.6-5501e0de0dca1cff0355326dd42bd8c7e5749568.patch
@@ -0,0 +1,72 @@
+commit 5501e0de0dca1cff0355326dd42bd8c7e5749568
+Author: Gonzalo Tornaría <tornaria@cmat.edu.uy>
+Date:   Tue Oct 11 17:25:04 2022 -0300
+
+    Support matplotlib 3.6
+
+diff --git a/src/sage/plot/arc.py b/src/sage/plot/arc.py
+index bb834763afc..f65973bcbd5 100644
+--- a/src/sage/plot/arc.py
++++ b/src/sage/plot/arc.py
+@@ -273,9 +273,9 @@ class Arc(GraphicPrimitive):
+         p = patches.Arc((self.x, self.y),
+                         2. * self.r1,
+                         2. * self.r2,
+-                        fmod(self.angle, 2 * pi) * (180. / pi),
+-                        self.s1 * (180. / pi),
+-                        self.s2 * (180. / pi))
++                        angle=fmod(self.angle, 2 * pi) * (180. / pi),
++                        theta1=self.s1 * (180. / pi),
++                        theta2=self.s2 * (180. / pi))
+         return p
+ 
+     def bezier_path(self):
+diff --git a/src/sage/plot/ellipse.py b/src/sage/plot/ellipse.py
+index a77e6fe640a..c35bed574ef 100644
+--- a/src/sage/plot/ellipse.py
++++ b/src/sage/plot/ellipse.py
+@@ -192,7 +192,8 @@ class Ellipse(GraphicPrimitive):
+         options = self.options()
+         p = patches.Ellipse(
+                 (self.x,self.y),
+-                self.r1*2.,self.r2*2.,self.angle/pi*180.)
++                self.r1*2.,self.r2*2.,
++                angle=self.angle/pi*180.)
+         p.set_linewidth(float(options['thickness']))
+         p.set_fill(options['fill'])
+         a = float(options['alpha'])
+diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
+index e779e1210e3..8d620b5c625 100644
+--- a/src/sage/plot/graphics.py
++++ b/src/sage/plot/graphics.py
+@@ -2007,7 +2007,7 @@ class Graphics(WithEqualityById, SageObject):
+         We can also do custom formatting if you need it.  See above for full
+         details::
+ 
+-            sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex")
++            sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex") # not tested (broken with matplotlib 3.6)
+             Graphics object consisting of 1 graphics primitive
+ 
+         This is particularly useful when setting custom ticks in multiples
+@@ -2341,7 +2341,7 @@ class Graphics(WithEqualityById, SageObject):
+             sage: subplot = Figure().add_subplot(111)
+             sage: p._objects[0]._render_on_subplot(subplot)
+             sage: p._matplotlib_tick_formatter(subplot, **d)
+-            (<AxesSubplot:>,
++            (<AxesSubplot:...>,
+             <matplotlib.ticker.MaxNLocator object at ...>,
+             <matplotlib.ticker.MaxNLocator object at ...>,
+             <matplotlib.ticker.ScalarFormatter object at ...>,
+diff --git a/src/sage/plot/plot.py b/src/sage/plot/plot.py
+index b36ee57227c..5301a05c3dc 100644
+--- a/src/sage/plot/plot.py
++++ b/src/sage/plot/plot.py
+@@ -1741,7 +1741,7 @@ def plot(funcs, *args, **kwds):
+ 
+     ::
+ 
+-        sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex")
++        sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex") # not tested (broken with matplotlib 3.6)
+         Graphics object consisting of 1 graphics primitive
+ 
+     .. PLOT::
diff --git a/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch b/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch
deleted file mode 100644
index f3eb0aad2cca..000000000000
--- a/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch
+++ /dev/null
@@ -1,14 +0,0 @@
- - this is not a proper fix... should fix sage_getfile() instead
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -187,7 +187,8 @@ def loadable_module_extension():
-         True
-     """
-     # Return the full platform-specific extension module suffix
--    return import_machinery.EXTENSION_SUFFIXES[0]
-+    # PATCHED for void linux, we use the shortest extension (.so)
-+    return import_machinery.EXTENSION_SUFFIXES[-1]
- 
- 
- def isclassinstance(obj):
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 0d793262d572..49fe919112a1 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,11 +1,11 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=9.5
-revision=2
+version=9.7
+revision=1
 wrksrc=sage-$version
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
-_bindir=/usr/lib/sagemath/bin
+_bindir=/usr/lib/sagemath/$version/bin
 make_install_args="--install-scripts=$_bindir"
 hostmakedepends="m4 pkg-config python3-Cython python3-Jinja2 python3-pkgconfig
  python3-setuptools"
@@ -33,66 +33,52 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="http://sagemath.org/"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=8d70a3b26080802c5b2e33dda4c23795d494d8216a0c2ecfcd608ebab0e64ff6
-
-post_patch() {
-	# these are unused and nothing else uses ratpoints
-	rm sage/libs/ratpoints.{pyx,pxd}
-
-	# git tree needs bootstrapping
-	pushd $wrksrc/build/pkgs/sagelib
-	PATH=../../bin:$PATH BOOTSTRAP_QUIET=no ./bootstrap
-	popd
-}
+checksum=9f26f14aa322e3cf38a71835b12ac34b23026b467f74d54b064c5d025e76fbfd
 
 do_configure() {
-	# set variables in sage.env since we do not install sage_conf
-	cat >> sage/env.py <<-EOF
-	CONWAY_POLYNOMIALS_DATA_DIR = "/usr/share/sagemath/conway_polynomials"
-	GRAPHS_DATA_DIR = "/usr/share/sagemath/graphs"
-	ELLCURVE_DATA_DIR = "/usr/share/sagemath/ellcurves"
-	POLYTOPE_DATA_DIR = "/usr/share/sagemath/reflexive_polytopes"
-	COMBINATORIAL_DESIGN_DATA_DIR = "/usr/share/sagemath/combinatorial_designs"
-	CREMONA_MINI_DATA_DIR = "/usr/share/sagemath/cremona"
-	CREMONA_LARGE_DATA_DIR = "/usr/share/sagemath/cremona"
-	THREEJS_DIR = "/usr/share/sagemath/threejs-sage"
-	EOF
-
-	# don't install sage-venv-config: it is used to set SAGE_VENV=/usr and
-	# then sage-env prepends "$SAGE_VENV/bin" to PATH which is undesired
-	vsed -e '/sage-venv-config/d' -i $wrksrc/src/setup.cfg
+	# git tree needs bootstrapping
+	( cd $wrksrc/build/pkgs/sagelib &&
+	  PATH=../../bin:$PATH \
+	  BOOTSTRAP_QUIET=no \
+	  ./bootstrap )
 }
 
 pre_build() {
 	export PYTHONPATH=../sage-setup
+	export PYTHONDONTWRITEBYTECODE=yes
 	export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
 }
 
 post_build() {
+	_lib=$(cd build/lib* && pwd)
 	_scripts=$(cd build/scripts* && pwd)
-	cat >> $_scripts/sage-env-config <<-'EOF'
-	PATH=$(dirname $SELF):$PATH
-	EOF
+
+	# configuration files
+	cp ${FILESDIR}/sage_conf.py $_lib
+	cp ${FILESDIR}/sage-env-config $_scripts
 }
 
 pre_install() {
 	export PYTHONPATH=../sage-setup
+	export PYTHONDONTWRITEBYTECODE=yes
 	export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
 }
 
 post_install() {
 	# fix jupyter kernel spec
-	vsed -i -e 's|"/usr/bin/sage", "--python"|"/usr/bin/python"|' \
+	vsed -i -e 's|"/usr/bin/sage"|"'${_bindir}'/sage"|' \
 		${DESTDIR}/usr/share/jupyter/kernels/sagemath/kernel.json
+
 	# replace broken symlinks by good copies (sagemath logo images)
 	for file in $(ls sage/ext_data/notebook-ipython); do
 		rm ${DESTDIR}/usr/share/jupyter/kernels/sagemath/$file
 		cp -a sage/ext_data/notebook-ipython/$file \
 			${DESTDIR}/usr/share/jupyter/kernels/sagemath
 	done
+
 	# we don't have docs here
 	rm ${DESTDIR}/usr/share/jupyter/kernels/sagemath/doc
-	# we don't have threejs in void
+	# this symlink is shipped in threejs-sage pkg
 	rm ${DESTDIR}/usr/share/jupyter/nbextensions/threejs-sage
 
 	# symlink main binary
@@ -102,14 +88,17 @@ post_install() {
 }
 
 do_check() {
+	_lib=$(cd build/lib* && pwd)
 	_scripts=$(cd build/scripts* && pwd)
-	export PYTHONPATH=$(cd build/lib* && pwd)
+
+	export PYTHONPATH=$_lib
+	export PYTHONDONTWRITEBYTECODE=yes
 
 	# get out of $build_wrksrc, otherwise python picks the wrong sage module
 	cd $(mktemp -dp build)
 
 	if [ -f ${XBPS_DISTDIR}/sagemath-check ] ; then
-		_sed='s|#.*||;/^\s*$/d;s|[^ ]*/sage/|'$PYTHONPATH'/sage/|g' \
+		_sed='s|#.*||;/^\s*$/d;s|^\([^ ]*/\)\?sage/|'$_lib'/sage/|g' \
 		_test_files=$(sed -e "$_sed" ${XBPS_DISTDIR}/sagemath-check)
 	fi
 	if [ -z "$_test_files" ]; then

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: DRAFT: sagemath update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (20 preceding siblings ...)
  2022-10-29 12:16 ` [PR PATCH] [Updated] " tornaria
@ 2022-10-29 16:55 ` tornaria
  2022-10-29 16:58 ` sagemath: " tornaria
                   ` (10 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: tornaria @ 2022-10-29 16:55 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 3206 bytes --]

New comment by tornaria on void-packages repository

https://github.com/void-linux/void-packages/pull/39876#issuecomment-1295901019

Comment:
I'm not sure what  went wrong with i686. All started with
```
sage -t --warn-long 30.0 --random-seed=0 /builddir/sage-9.7/pkgs/sagemath-standard/build/lib.linux-x86_64-cpython-310/sage/manifolds/differentiable/pseudo_riemannian_submanifold.py
**********************************************************************
File "/builddir/sage-9.7/pkgs/sagemath-standard/build/lib.linux-x86_64-cpython-310/sage/manifolds/differentiable/pseudo_riemannian_submanifold.py", line 26, in sage.manifolds.differentiable.pseudo_riemannian_submanifold
Failed example:
    E.<w,x,y> = M.chart()
Exception raised:
    Traceback (most recent call last):
      File "sage/symbolic/expression.pyx", line 13959, in sage.symbolic.expression.send_sage_domain_to_maxima (build/cythonized/sage/symbolic/expression.cpp:104209)
        assume(v, 'real')
      File "/builddir/sage-9.7/pkgs/sagemath-standard/build/lib.linux-x86_64-cpython-310/sage/symbolic/assumptions.py", line 676, in assume
        x.assume()
      File "/builddir/sage-9.7/pkgs/sagemath-standard/build/lib.linux-x86_64-cpython-310/sage/symbolic/assumptions.py", line 249, in assume
        self._validate_feature()
      File "/builddir/sage-9.7/pkgs/sagemath-standard/build/lib.linux-x86_64-cpython-310/sage/symbolic/assumptions.py", line 219, in _validate_feature
        _valid_feature_strings.update(repr(x).strip() for x in list(maxima("features")))
      File "sage/misc/lazy_import.pyx", line 391, in sage.misc.lazy_import.LazyImport.__call__ (build/cythonized/sage/misc/lazy_import.c:4393)
        return self.get_object()(*args, **kwds)
      File "sage/misc/lazy_import.pyx", line 216, in sage.misc.lazy_import.LazyImport.get_object (build/cythonized/sage/misc/lazy_import.c:2674)
        return self._get_object()
      File "sage/misc/lazy_import.pyx", line 252, in sage.misc.lazy_import.LazyImport._get_object (build/cythonized/sage/misc/lazy_import.c:2998)
        self._object = getattr(__import__(self._module, {}, {}, [self._name]), self._name)
      File "/builddir/sage-9.7/pkgs/sagemath-standard/build/lib.linux-x86_64-cpython-310/sage/interfaces/maxima_lib.py", line 119, in <module>
        ecl_eval("(set-pathnames)")
      File "sage/libs/ecl.pyx", line 1352, in sage.libs.ecl.ecl_eval (build/cythonized/sage/libs/ecl.c:10922)
        cpdef EclObject ecl_eval(str s):
      File "sage/libs/ecl.pyx", line 1375, in sage.libs.ecl.ecl_eval (build/cythonized/sage/libs/ecl.c:10855)
        o=ecl_safe_eval(python_to_ecl(s, True))
      File "sage/libs/ecl.pyx", line 321, in sage.libs.ecl.ecl_safe_eval (build/cythonized/sage/libs/ecl.c:5637)
        raise RuntimeError("ECL says: {}".format(message))
    RuntimeError: ECL says: Could not create directory "/tmp/.sage/maxima/binary"
    C library error: "File exists"
```
Probably a race condition, since CI is doctesting using 2 threads. More doctest failures after this are all caused by `E` not being defined, etc.

I don't think we should delay this PR for this (maybe someone can restart that test to be sure).

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: sagemath: update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (21 preceding siblings ...)
  2022-10-29 16:55 ` tornaria
@ 2022-10-29 16:58 ` tornaria
  2022-10-30 17:09 ` tornaria
                   ` (9 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: tornaria @ 2022-10-29 16:58 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 198 bytes --]

New comment by tornaria on void-packages repository

https://github.com/void-linux/void-packages/pull/39876#issuecomment-1295901804

Comment:
@leahneukirchen @dkwo : I think this is ready to merge.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: sagemath: update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (22 preceding siblings ...)
  2022-10-29 16:58 ` sagemath: " tornaria
@ 2022-10-30 17:09 ` tornaria
  2022-10-30 22:06 ` [PR PATCH] [Updated] " tornaria
                   ` (8 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: tornaria @ 2022-10-30 17:09 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 610 bytes --]

New comment by tornaria on void-packages repository

https://github.com/void-linux/void-packages/pull/39876#issuecomment-1296304454

Comment:
@ahesford: I'm now testing this PR with python 3.11 (using your branch from #39346).

Compilation went fine, but sage fails to start due to some deprecated python stuff that was removed in 3.11. There is a candidate patch in https://trac.sagemath.org/ticket/33842 which I'm trying now. Based on the discussion there, we may be needing more patches in sagemath and/or python3-cypari2.

I'll report back, hopefully we can have this working before the python update.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PR PATCH] [Updated] sagemath: update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (23 preceding siblings ...)
  2022-10-30 17:09 ` tornaria
@ 2022-10-30 22:06 ` tornaria
  2022-10-30 23:37 ` tornaria
                   ` (7 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: tornaria @ 2022-10-30 22:06 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2413 bytes --]

There is an updated pull request by tornaria against master on the void-packages repository

https://github.com/tornaria/void-packages sagemath-update
https://github.com/void-linux/void-packages/pull/39876

sagemath: update to 9.7
[EDIT] this ticket includes:
 - updates to flintlib, arb, singular, pari, gp2c, eclib, giac, gap (all those require recompilation of sagemath)
 - revbump for lcalc, python3-cysignals, python3-cypari2 b/c the soname change for libpari

Everything seems to be working ok, this is now ready for merging.

----

With respect to the original description:
 - #39838, #39840, #39872 are already merged.
 - #39846 is not included here as it won't force rebuild
 - #39866 was moved here
 - matplotlib 3.6.1 is working now

----

This includes #39838, #39840, #39846, #39872, #39866, also update eclib-20220621.

For now I'm reverting python3-matplotlib to 3.5.3_1 since 3.6.0_1 gives a lot of problems (#39857 adds python3-contourpy which will solve some, but I think there are more issues).

I want to make sure everything works ok and the full testsuite passes as is. Then I'll just move matplotlib back to 3.6.0_1 and try to see if it's feasible to fix or workaround the issues (sagemath-the-distro is still on matplotlib 3.5.2 and I didn't find anything about the update to 3.6.0)

<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: currently running the testsuite in --long after the update of singular.

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/39876.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-sagemath-update-39876.patch --]
[-- Type: text/x-diff, Size: 253170 bytes --]

From aa12527fcb5bdbdaff1b0b6fbba547c779a7ced9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 19:14:02 -0300
Subject: [PATCH 01/12] flintlib: update to 2.9.0.

---
 common/shlibs             | 2 +-
 srcpkgs/flintlib/template | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 7bd563a89134..82f6a8b8854e 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4020,7 +4020,7 @@ libgtkdatabox.so.1 gtkdatabox3-1.0.0_1
 libxcvt.so.0 libxcvt-0.1.1_1
 libgf2x.so.3 gf2x-1.3.0_1
 libntl.so.44 ntl-11.5.1_1
-libflint.so.16 flintlib-2.8.0_1
+libflint.so.17 flintlib-2.9.0_1
 libarb.so.2 arb-2.20.0_1
 libec.so.8 eclib-20210625_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index 968dbcb525c2..27f202b4434c 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,6 +1,6 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.8.5
+version=2.9.0
 revision=1
 wrksrc="flint-${version}"
 build_style=configure
@@ -14,11 +14,10 @@ license="LGPL-2.1-or-later"
 homepage="https://flintlib.org"
 changelog="https://raw.githubusercontent.com/wbhart/flint2/trunk/NEWS"
 distfiles="https://flintlib.org/flint-${version}.tar.gz"
-checksum=5911fedff911100f15781f35e3a4fa934fe60e4aea02a8c10cc8918101c1eed8
+checksum=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
-build_options_default=""
 
 if [ -z "$CROSS_BUILD" ]; then
 	build_options_default+=" ntl"

From 3aa250b7c3913eb28bbc54388d6946500072390e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 19:16:18 -0300
Subject: [PATCH 02/12] arb: update to 2.23.0.

---
 srcpkgs/arb/template | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
index 52f11ef83c90..84a62c7ffdba 100644
--- a/srcpkgs/arb/template
+++ b/srcpkgs/arb/template
@@ -1,6 +1,6 @@
 # Template file for 'arb'
 pkgname=arb
-version=2.22.1
+version=2.23.0
 revision=1
 build_style=configure
 configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
@@ -11,9 +11,7 @@ license="LGPL-2.1-or-later"
 homepage="https://arblib.org"
 changelog="https://raw.githubusercontent.com/fredrik-johansson/arb/master/doc/source/history.rst"
 distfiles="https://github.com/fredrik-johansson/arb/archive/${version}.tar.gz"
-checksum=1ef85518eee04885e8a90196498bc75e4e2410621d4184f2bc01d46b7080a243
-
-CFLAGS="-D_GNU_SOURCE" # needed for cpu_set_t
+checksum=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
 
 arb-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"

From 104a573360916c7c8ecc7f6c64438a5dbf9cb829 Mon Sep 17 00:00:00 2001
From: dkwo <nicolopiazzalunga@gmail.com>
Date: Mon, 10 Oct 2022 10:14:06 -0400
Subject: [PATCH 03/12] singular: update to 4.3.1p2 (fix gcc 12 build)

---
 common/shlibs             | 10 +++++-----
 srcpkgs/singular/template | 26 ++++++++++++++------------
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 82f6a8b8854e..2a17681a1c55 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4062,11 +4062,11 @@ libumfpack.so.5 SuiteSparse-5.10.1_1
 libecl.so.21.2 ecl-21.2.1_1
 libecm.so.1 ecm-7.0.4_3
 libcliquer.so.1 cliquer-1.22_1
-libSingular-4.3.0.so singular-4.3.0_1
-libfactory-4.3.0.so singular-4.3.0_1
-libpolys-4.3.0.so singular-4.3.0_1
-libomalloc-0.9.6.so singular-4.3.0_1
-libsingular_resources-4.3.0.so singular-4.3.0_1
+libSingular-4.3.1.so singular-4.3.1p2_1
+libfactory-4.3.1.so singular-4.3.1p2_1
+libpolys-4.3.1.so singular-4.3.1p2_1
+libomalloc-0.9.6.so singular-4.3.1p2_1
+libsingular_resources-4.3.1.so singular-4.3.1p2_1
 libbrial.so.3 brial-1.2.10_1
 libbrial_groebner.so.3 brial-1.2.10_1
 libm4ri-0.0.20200125.so m4ri-20200125_1
diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index f23659ef5d83..a30beef915d2 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,25 +1,27 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.0
+version=4.3.1p2
 revision=1
+_majver=${version%p*}
+wrksrc=singular-${_majver}
 build_style=gnu-configure
 configure_args="--with-readline=ncurses
-	--enable-gfanlib
-	--enable-Singular
-	--enable-factory
-	--disable-doc
-	--disable-polymake
-	--without-python
-	--with-libparse
-	ac_cv_lib_cddgmp_dd_free_global_constants=yes"
+ --enable-gfanlib
+ --enable-Singular
+ --enable-factory
+ --disable-doc
+ --disable-polymake
+ --without-python
+ --with-libparse
+ ac_cv_lib_cddgmp_dd_free_global_constants=yes"
 hostmakedepends="perl tar doxygen"
 makedepends="flintlib-devel cddlib-devel readline-devel graphviz"
 short_desc="Computer algebra system for polynomial computations"
-maintainer="dkwo <nicolopiazzalunga@gmail.com>"
+maintainer="dkwo <npiazza@disroot.org>"
 license="GPL-2.0-or-later"
 homepage="https://www.singular.uni-kl.de"
-distfiles="https://www.singular.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${version//./-}/singular-${version}.tar.gz"
-checksum=74f38288203720e3f280256f2f8deb94030dd032b4237d844652aff0faab36e7
+distfiles="https://www.singular.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${_majver//./-}/singular-${version}.tar.gz"
+checksum=95814bba0f0bd0290cd9799ec1d2ecc6f4c8a4e6429d9a02eb7f9c4e5649682a
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From ee1fcee2dc8c99968944391fe4423c4448321de9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 19:59:20 -0300
Subject: [PATCH 04/12] pari: update to 2.15.0.

---
 common/shlibs                                 |  3 +-
 ...cd3f497f30f757c8eecadc9b45b33754a540.patch | 54 +++++++++++++++++++
 srcpkgs/pari/patches/float32.patch            | 48 +++++++++++++++++
 srcpkgs/pari/template                         | 12 +++--
 4 files changed, 112 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/pari/patches/9c4bcd3f497f30f757c8eecadc9b45b33754a540.patch
 create mode 100644 srcpkgs/pari/patches/float32.patch

diff --git a/common/shlibs b/common/shlibs
index 2a17681a1c55..36e502380de3 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4011,8 +4011,7 @@ libsimavrparts.so.1 simavr-1.6_2
 libsword-1.8.1.so libsword-1.8.1_6
 libgivaro.so.9 givaro-4.1.1_1
 liblinbox.so.0 linbox-1.6.3_1
-libpari-gmp.so.7 pari-2.13.0_1
-libpari-gmp-tls.so.7 pari-2.13.2_1
+libpari-gmp-tls.so.8 pari-2.15.0_1
 libtree-sitter.so.0 tree-sitter-0.19.0_1
 libplanarity.so.0 planarity-3.0.1.1_1
 libgap.so.0 gap-4.11.1_1
diff --git a/srcpkgs/pari/patches/9c4bcd3f497f30f757c8eecadc9b45b33754a540.patch b/srcpkgs/pari/patches/9c4bcd3f497f30f757c8eecadc9b45b33754a540.patch
new file mode 100644
index 000000000000..2cea7402b6e4
--- /dev/null
+++ b/srcpkgs/pari/patches/9c4bcd3f497f30f757c8eecadc9b45b33754a540.patch
@@ -0,0 +1,54 @@
+See: https://pari.math.u-bordeaux.fr/cgi-bin/bugreport.cgi?bug=2419
+--
+
+commit 9c4bcd3f497f30f757c8eecadc9b45b33754a540
+Author: Karim Belabas <Karim.Belabas@math.u-bordeaux.fr>
+Date:   Tue Oct 4 10:30:43 2022 +0200
+
+    6- conversion to float of t_QUAD with t_FRAC components [#2419]
+
+diff --git a/src/basemath/gen2.c b/src/basemath/gen2.c
+index 3ef74a7023..d810270b99 100644
+--- a/src/basemath/gen2.c
++++ b/src/basemath/gen2.c
+@@ -2429,8 +2429,8 @@ quadtofp(GEN x, long prec)
+   else
+   { /* if (b) x ~ (u + z) / 2 and quadnorm(x) ~ (u^2 - z^2) / 4
+      * else x ~ u + z and quadnorm(x) ~ u^2 - z^2 */
+-    long s = signe(u);
+-    if (s == -signe(v)) /* conjugate expression avoids cancellation */
++    long s = gsigne(u);
++    if (s == -gsigne(v)) /* conjugate expression avoids cancellation */
+     {
+       z = gdiv(quadnorm(x), gsub(u, z));
+       if (b) shiftr_inplace(z, 1);
+diff --git a/src/test/32/quad b/src/test/32/quad
+index 2b43d87a4a..1f1042d143 100644
+--- a/src/test/32/quad
++++ b/src/test/32/quad
+@@ -43,6 +43,7 @@ w
+ -4294967297
+ 4294967297
+ -4294967297
++2.2847006554165615148712535010323047844
+   ***   at top-level: floor(w8)
+   ***                 ^---------
+   *** floor: incorrect type in gfloor (t_QUAD).
+@@ -55,4 +56,4 @@ w
+   ***   at top-level: floor(Mod(0,3)*quadgen(5))
+   ***                 ^--------------------------
+   *** floor: incorrect type in gfloor (t_QUAD).
+-Total time spent: 2
++Total time spent: 1
+diff --git a/src/test/in/quad b/src/test/in/quad
+index c8cd5a586f..82cd5e992d 100644
+--- a/src/test/in/quad
++++ b/src/test/in/quad
+@@ -47,6 +47,7 @@ ceil(2*w)
+ ceil(-2*w)
+ round(2*w)
+ round(-2*w)
++quadgen(5) + 2/3 + 0.\\ #2419
+ 
+ \\ Errors keep at end of file
+ floor(w8)
diff --git a/srcpkgs/pari/patches/float32.patch b/srcpkgs/pari/patches/float32.patch
new file mode 100644
index 000000000000..311dd6bf5a07
--- /dev/null
+++ b/srcpkgs/pari/patches/float32.patch
@@ -0,0 +1,48 @@
+Author: Gonzalo Tornaría <tornaria@cmat.edu.uy>
+Date:   Fri Oct 14 17:00:46 2022 -0300
+
+    Revert "x86 (32bit): force -mpc64 on compilers that supports it."
+    
+    This reverts commit ca61b6391cf95ac8af15669236e2ec5839d2ad91.
+
+
+This causes problems with floating point precision on i686:
+```
+$ cat exp40.c
+#include <math.h>
+#include <stdio.h>
+int main() {
+	volatile int a=40; /* do not optimize away the call to exp(a) */
+	printf("%f\n", exp(a));
+}
+$ cc -Wall exp40.c -lm && ./a.out
+235385266837020000.000000
+$ cc -Wall exp40.c -lm -mpc64 && ./a.out
+235385266837020448.000000
+```
+
+Note that when pari is built using -mpc64, just *linking* with -lpari
+causes the problem!!!
+```
+$ cc -Wall exp40.c -lm -lpari && ./a.out
+235385266837020448.000000
+```
+
+diff --git a/config/get_cc b/config/get_cc
+index 3cfaa88bb7..2d61d3871f 100644
+--- a/config/get_cc
++++ b/config/get_cc
+@@ -110,13 +110,6 @@ if test -n "$__gnuc__"; then
+   # Specific optimisations for some architectures
+   case "$arch" in
+     sparcv8*) cflags=-mv8;;
+-    i?86)
+-      cmd="$CC $CFLAGS $extraflag -mpc64 -fno-strict-aliasing -o $exe gnu.c"
+-      . log_cmd
+-      if test -s $exe; then
+-        cflags="-mpc64"
+-      fi
+-      . cleanup_exe;;
+   esac
+   # problems on some architectures
+   case "$osname" in
diff --git a/srcpkgs/pari/template b/srcpkgs/pari/template
index 8bac1e0343f8..811826a1ee14 100644
--- a/srcpkgs/pari/template
+++ b/srcpkgs/pari/template
@@ -1,6 +1,6 @@
 # Template file for 'pari'
 pkgname=pari
-version=2.13.4
+version=2.15.0
 revision=1
 build_style=configure
 build_helper=qemu
@@ -11,14 +11,15 @@ make_check_target=statest-all
 make_install_target="install install-lib-sta install-lib-dyn"
 hostmakedepends="perl texlive"
 makedepends="gmp-devel readline-devel $(vopt_if x11 libX11-devel)"
-checkdepends="pari-elldata-small pari-galdata pari-galpol-small pari-seadata-small"
+checkdepends="pari-elldata-small pari-galdata pari-galpol-small
+ pari-seadata-small pari-nflistdata"
 short_desc="Fast computations library in number theory"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="https://pari.math.u-bordeaux.fr"
 changelog="https://pari.math.u-bordeaux.fr/cgi-bin/gitweb.cgi?p=pari.git;a=blob_plain;f=CHANGES;hb=refs/heads/pari-${version%.*}"
 distfiles="https://pari.math.u-bordeaux.fr/pub/pari/unix/${pkgname}-${version}.tar.gz"
-checksum=bcde9eceae1592814381c1697cdb7063567b6504201b1be47bb58920f3bce185
+checksum=e474851e0d16d4e4f9a0d9612c746a2ae7c9a1ec185d04c440b1c74a85755685
 
 build_options="x11 pthreads"
 build_options_default="x11 pthreads"
@@ -27,6 +28,11 @@ desc_option_pthreads="Enable support for pthreads"
 # reduce speed losses due to pthreads
 CFLAGS="-flto -fno-semantic-interposition"
 
+case $XBPS_TARGET_MACHINE in
+	# avoid numerical noise caused by extended-precision of registers
+	i686*) CFLAGS+=" -ffloat-store" ;;
+esac
+
 post_patch() {
 	# sse2 is not available on all i686
 	# and it's available on all x86_64

From 4148ceb8282b37970cf0a8350ab1c0b81437fd97 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 20:33:23 -0300
Subject: [PATCH 05/12] gp2c: update to 0.0.13.

---
 srcpkgs/gp2c/template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/gp2c/template b/srcpkgs/gp2c/template
index f82cf95c2d90..9cf0f6fdce6e 100644
--- a/srcpkgs/gp2c/template
+++ b/srcpkgs/gp2c/template
@@ -1,6 +1,6 @@
 # Template file for 'gp2c'
 pkgname=gp2c
-version=0.0.12pl1
+version=0.0.13
 revision=1
 build_style=gnu-configure
 hostmakedepends="perl"
@@ -12,4 +12,4 @@ license="GPL-2.0-or-later"
 homepage="http://pari.math.u-bordeaux.fr/"
 changelog="http://pari.math.u-bordeaux.fr/cgi-bin/gitweb.cgi?p=gp2c.git;a=blob_plain;f=ChangeLog;hb=HEAD"
 distfiles="${homepage}pub/pari/GP2C/${pkgname}-${version}.tar.gz"
-checksum=79a8c46f7ad3331e4d8ae6af6b496c4742fd73a73b996b3ca7ead61452ca6e8d
+checksum=261374eca73ebd76c112a9593dca28b64812aa762561fda5a4b2c2cd79a69d36

From fc511be9c3f622797d36e6c78f349297ba926a2a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Fri, 23 Sep 2022 16:42:40 -0300
Subject: [PATCH 06/12] eclib: update to 20221012.

---
 common/shlibs          | 2 +-
 srcpkgs/eclib/template | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/common/shlibs b/common/shlibs
index 36e502380de3..a77784215a63 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4021,7 +4021,7 @@ libgf2x.so.3 gf2x-1.3.0_1
 libntl.so.44 ntl-11.5.1_1
 libflint.so.17 flintlib-2.9.0_1
 libarb.so.2 arb-2.20.0_1
-libec.so.8 eclib-20210625_1
+libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
 liblrcalc.so.2 lrcalc-2.1_1
diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 694a39ed4068..31a3a01921fa 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
-version=20210625
-revision=2
+version=20221012
+revision=1
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 hostmakedepends="automake autoconf-archive libtool"
@@ -11,7 +11,7 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="https://github.com/JohnCremona/eclib"
 distfiles="https://github.com/JohnCremona/eclib/archive/refs/tags/${version}.tar.gz"
-checksum=00333fd36afd237c9e6e410c7ab98536ddcd7fdc430e6837fe293247b835c572
+checksum=bd6f0191876c1426ca57db851ce06ef79ea1755f01e81dd747358d1b76b5e932
 
 pre_configure() {
 	autoreconf -fi

From d570a35e30c4589d1833e01c63f2ad375d53e6d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:20 -0300
Subject: [PATCH 07/12] giac: update to 1.9.0.27.

---
 .../giac/patches/giac-pari-2.15-test.patch    | 10 ++++++++++
 srcpkgs/giac/patches/giac-pari-2.15.patch     | 20 +++++++++++++++++++
 srcpkgs/giac/template                         |  4 ++--
 3 files changed, 32 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/giac/patches/giac-pari-2.15-test.patch
 create mode 100644 srcpkgs/giac/patches/giac-pari-2.15.patch

diff --git a/srcpkgs/giac/patches/giac-pari-2.15-test.patch b/srcpkgs/giac/patches/giac-pari-2.15-test.patch
new file mode 100644
index 000000000000..1f1929571a46
--- /dev/null
+++ b/srcpkgs/giac/patches/giac-pari-2.15-test.patch
@@ -0,0 +1,10 @@
+Fix a failing test due to thread stack overflow
+
+--- a/check/chk_fhan4	2018-03-13 15:27:11.000000000 -0300
++++ b/check/chk_fhan4	2022-10-14 18:51:12.604731890 -0300
+@@ -1,4 +1,5 @@
+ #! /bin/sh
+ unset LANG
++export PARI_SIZE=2048000
+ ../src/icas TP04-sol.cas > TP04.tst
+ diff TP04.tst TP04-sol.cas.out1
diff --git a/srcpkgs/giac/patches/giac-pari-2.15.patch b/srcpkgs/giac/patches/giac-pari-2.15.patch
new file mode 100644
index 000000000000..be409be38f53
--- /dev/null
+++ b/srcpkgs/giac/patches/giac-pari-2.15.patch
@@ -0,0 +1,20 @@
+ANYARG patch
+
+diff --git a/src/pari.cc b/src/pari.cc
+index 76ce8e1..50d08ab 100644
+--- a/src/pari.cc
++++ b/src/pari.cc
+@@ -40,6 +40,13 @@ using namespace std;
+ 
+ #ifdef HAVE_LIBPARI
+ 
++// Anyarg disappeared from PARI 2.15.0
++#ifdef __cplusplus
++#  define ANYARG ...
++#else
++#  define ANYARG
++#endif
++
+ #ifdef HAVE_PTHREAD_H
+ #include <pthread.h>
+ #endif
diff --git a/srcpkgs/giac/template b/srcpkgs/giac/template
index e892c8bf7506..5dcdbeb1e848 100644
--- a/srcpkgs/giac/template
+++ b/srcpkgs/giac/template
@@ -1,6 +1,6 @@
 # Template file for 'giac'
 pkgname=giac
-version=1.9.0.7
+version=1.9.0.27
 revision=1
 wrksrc="giac-${version%.*}"
 build_style=gnu-configure
@@ -14,7 +14,7 @@ license="GPL-3.0-or-later"
 homepage="https://www-fourier.ujf-grenoble.fr/~parisse/giac.html"
 changelog="https://www-fourier.ujf-grenoble.fr/~parisse/install_en#new"
 distfiles="https://www-fourier.ujf-grenoble.fr/~parisse/debian/dists/stable/main/source/giac_${version%.*}-${version##*.}.tar.gz"
-checksum=72016988b7180e9b630ecabecc60969213e7b61418c2598c91acbaec139fd740
+checksum=c5d222fbff5db2a0a560b4e106ce88dd13d109ecb21570a939b8b3b87521d5e0
 
 # need more than 4*65536 stack, see try_parse() in gen.cc line 11812
 LDFLAGS="-Wl,-z,stack-size=2097152"

From e3f1afa56676a96785d7bc96a7896bb89867440e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 12 Oct 2022 23:59:37 -0300
Subject: [PATCH 08/12] gap: update to 4.12.1.

---
 common/shlibs                                 |  2 +-
 ...atlasrep-dont_use_network_by_default.patch | 11 +++++
 srcpkgs/gap/template                          | 42 +++++++++++++------
 3 files changed, 41 insertions(+), 14 deletions(-)
 create mode 100644 srcpkgs/gap/patches/atlasrep-dont_use_network_by_default.patch

diff --git a/common/shlibs b/common/shlibs
index a77784215a63..31b11da9e6e3 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -4014,7 +4014,7 @@ liblinbox.so.0 linbox-1.6.3_1
 libpari-gmp-tls.so.8 pari-2.15.0_1
 libtree-sitter.so.0 tree-sitter-0.19.0_1
 libplanarity.so.0 planarity-3.0.1.1_1
-libgap.so.0 gap-4.11.1_1
+libgap.so.8 gap-4.12.0_1
 libgtkdatabox.so.1 gtkdatabox3-1.0.0_1
 libxcvt.so.0 libxcvt-0.1.1_1
 libgf2x.so.3 gf2x-1.3.0_1
diff --git a/srcpkgs/gap/patches/atlasrep-dont_use_network_by_default.patch b/srcpkgs/gap/patches/atlasrep-dont_use_network_by_default.patch
new file mode 100644
index 000000000000..1a6be215091f
--- /dev/null
+++ b/srcpkgs/gap/patches/atlasrep-dont_use_network_by_default.patch
@@ -0,0 +1,11 @@
+--- a/pkg/atlasrep/gap/userpref.g	2022-09-06 17:41:17.000000000 -0300
++++ b/pkg/atlasrep/gap/userpref.g	2022-10-29 07:46:48.580833277 -0300
+@@ -46,7 +46,7 @@
+ this information depends on the value of the preference at the time \
+ when the AtlasRep package and its data extensions get loaded."
+     ],
+-  default:= true,
++  default:= false,
+   values:= [ true, false ],
+   multi:= false,
+   package:= "AtlasRep",
diff --git a/srcpkgs/gap/template b/srcpkgs/gap/template
index 7bc7d13ace20..277537fe0fa3 100644
--- a/srcpkgs/gap/template
+++ b/srcpkgs/gap/template
@@ -1,17 +1,17 @@
 # Template file for 'gap'
 pkgname=gap
-version=4.11.1
+version=4.12.1
 revision=1
 build_style=gnu-configure
-make_install_target="install-bin install-gaproot install-headers install-libgap"
 makedepends="gmp-devel zlib-devel readline-devel"
 checkdepends="perl"
 short_desc="Groups, Algorithms, Programming - computational discrete algebra"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
-homepage="http://www.gap-system.org/"
+homepage="https://www.gap-system.org/"
+changelog="https://raw.githubusercontent.com/gap-system/gap/master/CHANGES.md"
 distfiles="https://github.com/gap-system/gap/releases/download/v${version}/gap-${version}.tar.gz"
-checksum=6635c5da7d82755f8339486b9cac33766f58712f297e8234fba40818902ea304
+checksum=f9ebef11ee31b210ce36e3c70960742b4e253282bbd5270adc9324273c92b016
 
 if [ "$XBPS_CHECK_PKGS" = full ]; then
 	# not sure about this -- takes about 25 minutes
@@ -21,20 +21,36 @@ fi
 _GAPROOT=/usr/share/gap/
 
 # minimal required packages
-_GAPPKGS="GAPDoc primgrp SmallGrp transgrp"
+_GAPPKGS="autodoc gapdoc primgrp smallgrp transgrp"
 
 # other expected packages
-_GAPPKGS+=" atlasrep autpgrp alnuth crisp ctbllib FactInt fga irredsol laguna
- polenta polycyclic resclasses sophus tomlib"
+_GAPPKGS+=" atlasrep autpgrp alnuth crisp ctbllib factint fga irredsol laguna
+ polenta polycyclic radiroot resclasses sophus tomlib utils"
 
-post_install() {
-	vmkdir ${_GAPROOT}/pkg
+post_extract() {
+	# keep around only the packages that we want to install
+	mkdir pkg.install
 	for p in ${_GAPPKGS}; do
-		[ -d pkg/$p ] || p="$p-*"
-		vcopy "pkg/$p" ${_GAPROOT}/pkg
+		mv "pkg/$p" pkg.install
 	done
-	# not handled by make install-headers
-	vcopy gen/config.h /usr/include/gap
+	mv pkg pkg.orig
+	mv pkg.install pkg
+}
+
+post_install() {
+	vmkdir ${_GAPROOT}
+	vcopy pkg ${_GAPROOT}
+}
+
+pre_check() {
+	msg_normal "Check that loading packages works\n"
+	for p in ${_GAPPKGS}; do
+		cat <<-EOF
+		if LoadPackage("$p") <> true then
+		    Error("loading package '$p'");
+		fi;
+		EOF
+	done | ./gap --quitonbreak -b -q -r
 }
 
 gap-devel_package() {

From d17efd8813605e2093b09cbe868f9cae6b78e1a2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:19 -0300
Subject: [PATCH 09/12] lcalc: revbump for pari 2.15.0

---
 srcpkgs/lcalc/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/lcalc/template b/srcpkgs/lcalc/template
index 270078df9a54..3c6be5fcbc28 100644
--- a/srcpkgs/lcalc/template
+++ b/srcpkgs/lcalc/template
@@ -1,7 +1,7 @@
 # Template file for 'lcalc'
 pkgname=lcalc
 version=2.0.5
-revision=1
+revision=2
 build_style=gnu-configure
 configure_args="--with-pari"
 hostmakedepends="automake libtool pkg-config gengetopt"

From 149004e0a2ebc7473944616cb545cfe4097f4912 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 11 Oct 2022 18:56:21 -0300
Subject: [PATCH 10/12] python3-cysignals: revbump for pari 2.15.0

---
 srcpkgs/python3-cysignals/template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/srcpkgs/python3-cysignals/template b/srcpkgs/python3-cysignals/template
index 4655eead2a9c..08d1010976ff 100644
--- a/srcpkgs/python3-cysignals/template
+++ b/srcpkgs/python3-cysignals/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-cysignals'
 pkgname=python3-cysignals
 version=1.11.2
-revision=1
+revision=2
 wrksrc="cysignals-${version}"
 build_style=python3-module
 hostmakedepends="python3-setuptools python3-Cython autoconf"

From 7ee5ea8ccb3d0d6bf0226e083b48616875171679 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Sun, 30 Oct 2022 17:10:30 -0300
Subject: [PATCH 11/12] python3-cypari2: update to 2.1.3.

---
 .../python3-cypari2/patches/pari-2.15.patch   | 47 +++++++++++++++++++
 .../python3-cypari2/patches/python-3.11.patch | 28 -----------
 srcpkgs/python3-cypari2/template              | 18 +++----
 3 files changed, 56 insertions(+), 37 deletions(-)
 create mode 100644 srcpkgs/python3-cypari2/patches/pari-2.15.patch
 delete mode 100644 srcpkgs/python3-cypari2/patches/python-3.11.patch

diff --git a/srcpkgs/python3-cypari2/patches/pari-2.15.patch b/srcpkgs/python3-cypari2/patches/pari-2.15.patch
new file mode 100644
index 000000000000..d7fef450b4ce
--- /dev/null
+++ b/srcpkgs/python3-cypari2/patches/pari-2.15.patch
@@ -0,0 +1,47 @@
+See: 
+ - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1020456#10
+ - https://github.com/sagemath/cypari2/issues/122
+ - https://github.com/sagemath/cypari2/pull/123
+
+diff --git a/cypari2/closure.pyx b/cypari2/closure.pyx
+index 9848b51..ca87403 100644
+--- a/cypari2/closure.pyx
++++ b/cypari2/closure.pyx
+@@ -208,7 +208,7 @@ cpdef Gen objtoclosure(f):
+     >>> mul([1], [2])
+     Traceback (most recent call last):
+     ...
+-    PariError: call_python: forbidden multiplication t_VEC (1 elts) * t_VEC (1 elts)
++    PariError: call_python: incorrect type in qfbcomp (t_VEC)
+     """
+     if not callable(f):
+         raise TypeError("argument to objtoclosure() must be callable")
+diff --git a/cypari2/handle_error.pyx b/cypari2/handle_error.pyx
+index 1222889..ba93ad1 100644
+--- a/cypari2/handle_error.pyx
++++ b/cypari2/handle_error.pyx
+@@ -123,7 +123,7 @@ class PariError(RuntimeError):
+         >>> pari('!@#$%^&*()')
+         Traceback (most recent call last):
+         ...
+-        PariError: syntax error, unexpected $undefined
++        PariError: syntax error, unexpected invalid token
+         """
+         return self.errtext().rstrip(" .:")
+ 
+diff --git a/cypari2/pari_instance.pyx b/cypari2/pari_instance.pyx
+index 4291188..172fce5 100644
+--- a/cypari2/pari_instance.pyx
++++ b/cypari2/pari_instance.pyx
+@@ -1325,9 +1325,9 @@ cdef class Pari(Pari_auto):
+         >>> pari = cypari2.Pari()
+         >>> x = pari('x')
+         >>> pari.genus2red([-5*x**5, x**3 - 2*x**2 - 2*x + 1])
+-        [1416875, [2, -1; 5, 4; 2267, 1], x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855, [[2, [2, [Mod(1, 2)]], []], [5, [1, []], ["[V] page 156", [3]]], [2267, [2, [Mod(432, 2267)]], ["[I{1-0-0}] page 170", []]]]]
++        [1416875, [2, -1; 5, 4; 2267, 1], [-6*x^5 + 2*x^3 - x, x^3 + 1], [[2, [2, [Mod(1, 2)]], []], [5, [1, []], ["[V] page 156", [3]]], [2267, [2, [Mod(432, 2267)]], ["[I{1-0-0}] page 170", []]]]]
+         >>> pari.genus2red([-5*x**5, x**3 - 2*x**2 - 2*x + 1],2267)
+-        [2267, Mat([2267, 1]), x^6 - 24*x^5 + 10*x^3 - 4*x + 1, [2267, [2, [Mod(432, 2267)]], ["[I{1-0-0}] page 170", []]]]
++        [2267, Mat([2267, 1]), [-6*x^5 + 2*x^3 - x, x^3 + 1], [2267, [2, [Mod(432, 2267)]], ["[I{1-0-0}] page 170", []]]]
+         """
+         cdef Gen t0 = objtogen(P)
+         if p is None:
diff --git a/srcpkgs/python3-cypari2/patches/python-3.11.patch b/srcpkgs/python3-cypari2/patches/python-3.11.patch
deleted file mode 100644
index 02f4f9fb8cab..000000000000
--- a/srcpkgs/python3-cypari2/patches/python-3.11.patch
+++ /dev/null
@@ -1,28 +0,0 @@
---- a/cypari2/convert.pyx
-+++ b/cypari2/convert.pyx
-@@ -59,8 +59,7 @@ cdef extern from *:
-     ctypedef struct PyLongObject:
-         digit* ob_digit
- 
--    Py_ssize_t* Py_SIZE_PTR "&Py_SIZE"(object)
--
-+    void __Pyx_SET_SIZE(object, Py_ssize_t)
- 
- ########################################################################
- # Conversion PARI -> Python
-@@ -450,13 +449,10 @@ cdef PyLong_FromINT(GEN g):
-         if d:
-             sizedigits_final = i+1
- 
--    # Set correct size (use a pointer to hack around Cython's
--    # non-support for lvalues).
--    cdef Py_ssize_t* sizeptr = Py_SIZE_PTR(x)
-     if signe(g) > 0:
--        sizeptr[0] = sizedigits_final
-+        __Pyx_SET_SIZE(x, sizedigits_final);
-     else:
--        sizeptr[0] = -sizedigits_final
-+        __Pyx_SET_SIZE(x, -sizedigits_final);
- 
-     return x
- 
diff --git a/srcpkgs/python3-cypari2/template b/srcpkgs/python3-cypari2/template
index 9ded61101e8e..eacc14a9e8de 100644
--- a/srcpkgs/python3-cypari2/template
+++ b/srcpkgs/python3-cypari2/template
@@ -1,8 +1,10 @@
 # Template file for 'python3-cypari2'
 pkgname=python3-cypari2
-version=2.1.2
+version=2.1.3
 revision=1
-wrksrc=cypari2-${version}
+# This is precisely release 2.1.3 (Oct 3); but it's not tagged yet
+_githash=34198a78e86ba6ba684b25ae5ebb3e1a4e54c19f
+wrksrc=cypari2-${_githash}
 build_style=python3-module
 hostmakedepends="python3-setuptools python3-Cython pari perl"
 makedepends="python3-devel python3-cysignals pari-devel gmp-devel"
@@ -10,12 +12,10 @@ short_desc="Python interface to the number theory library PARI/GP"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="https://github.com/sagemath/cypari2"
-distfiles="${PYPI_SITE}/c/cypari2/cypari2-${version}.tar.gz"
-checksum=03cd45edab8716ebbfdb754e65fea72e873c73dc91aec098fe4a01e35324ac7a
+distfiles=https://github.com/sagemath/cypari2/archive/$_githash.tar.gz
+checksum=16bcc5da48a05e3d56a1466e9ed0c2ec91d48fe875bf1adda237bb7690d3f7c3
 
-post_extract() {
-	local _f
-	for _f in cypari2/*.pyx; do
-		rm -f ${_f%.pyx}.c
-	done
+do_check() {
+	PYTHONPATH="$(cd build/lib* && pwd)" \
+		make check
 }

From c4a6d3355b289e115e75bcb67a2f8ae70fbe22cb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 10 Oct 2022 00:49:01 -0300
Subject: [PATCH 12/12] sagemath: update to 9.7.

---
 srcpkgs/sagemath/files/sage-env-config        |    6 +
 srcpkgs/sagemath/files/sage_conf.py           |    3 +
 srcpkgs/sagemath/files/timings2.json          |   10 +-
 .../patches/01-dont_link_ratpoints.patch      |   10 -
 ...2-fix_get_shared_lib_path--see_29644.patch |   13 -
 .../patches/03-doctest_have_program.patch     |   20 -
 .../patches/04-doctest_sage_getfile.patch     |   22 -
 .../patches/05-fix_sage_getfile.patch         |   16 -
 .../sagemath/patches/07-ignore_warning.patch  |   15 -
 .../08-dont_run_pytest--see_31924.patch       |   27 -
 ...y_slow_doctest-polynomial_zmod_flint.patch |   14 -
 ...ry_slow_doctest-isogeny_small_degree.patch |  106 -
 ...fix_very_slow_doctest-function_field.patch |   97 -
 .../trac-31355-upgrade_lrcalc_to_2.1.patch    |  670 -------
 .../trac-33170-fix_doctest_ipython_8.patch    |   40 -
 .../trac-33170b-fix_doctest_ipython_8.1.patch |   13 -
 ...2ddd4e2dc92469c1590ebf0c40f8f69bf579.patch |  126 --
 ...2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch |   40 -
 .../trac-33336-fix_doctest_scipy_1.8.patch    |   19 -
 ...cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch |   53 +
 ...d9deaeaa6380ab2f0d50276d911233c00a04.patch |   99 -
 ...ff347454ac7f07e5918470b20e97b8f2357e.patch |   29 -
 ...fc4ec8b8687bccd22d2e3161c86cf5553e06.patch |  427 ++++
 ...0a0b14f67f4804e7113c3db41bbcf8a58296.patch |   26 -
 .../patches/trac-33842-python-3.11.patch      |   45 +
 ...d4e56243c609f44afc1f21c112b026f9e1fe.patch |   42 +
 ...93d67cfcdf8fba7bc6aa7899e2086d42cc7e.patch |  526 +++++
 ...1318f032caf8dc1c0de9489346d894409091.patch |   19 +
 .../trac-34537-sagemath-pari-2.15.patch       | 1750 +++++++++++++++++
 .../trac-34537-sagemath-pari-2.15b.patch      |   29 +
 ...e0de0dca1cff0355326dd42bd8c7e5749568.patch |   72 +
 .../zzz-loadable_module_extension.patch       |   14 -
 srcpkgs/sagemath/template                     |   61 +-
 33 files changed, 3002 insertions(+), 1457 deletions(-)
 create mode 100644 srcpkgs/sagemath/files/sage-env-config
 create mode 100644 srcpkgs/sagemath/files/sage_conf.py
 delete mode 100644 srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
 delete mode 100644 srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
 delete mode 100644 srcpkgs/sagemath/patches/03-doctest_have_program.patch
 delete mode 100644 srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
 delete mode 100644 srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
 delete mode 100644 srcpkgs/sagemath/patches/07-ignore_warning.patch
 delete mode 100644 srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
 delete mode 100644 srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
 delete mode 100644 srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
 delete mode 100644 srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-33446-make_GAP_SO_unnecessary-31e3fc4ec8b8687bccd22d2e3161c86cf5553e06.patch
 delete mode 100644 srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-33842-python-3.11.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-a6c293d67cfcdf8fba7bc6aa7899e2086d42cc7e.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15b.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-34668-matplotlib_3.6-5501e0de0dca1cff0355326dd42bd8c7e5749568.patch
 delete mode 100644 srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch

diff --git a/srcpkgs/sagemath/files/sage-env-config b/srcpkgs/sagemath/files/sage-env-config
new file mode 100644
index 000000000000..b84405301182
--- /dev/null
+++ b/srcpkgs/sagemath/files/sage-env-config
@@ -0,0 +1,6 @@
+# configure PATH using sage script location
+export PATH="$(dirname $SELF):$PATH"
+
+# if SAGE_VENV is set, the script sage-env will prepend
+# "$SAGE_VENV/bin" to the PATH, which is undesired
+unset SAGE_VENV
diff --git a/srcpkgs/sagemath/files/sage_conf.py b/srcpkgs/sagemath/files/sage_conf.py
new file mode 100644
index 000000000000..85ec37dfb50e
--- /dev/null
+++ b/srcpkgs/sagemath/files/sage_conf.py
@@ -0,0 +1,3 @@
+# configuration for sage on void linux
+SAGE_SHARE = "/usr/share/sagemath"
+GAP_ROOT_DIR = "/usr/share/gap"
diff --git a/srcpkgs/sagemath/files/timings2.json b/srcpkgs/sagemath/files/timings2.json
index 01b2fcc9e0bf..bb3098680502 100644
--- a/srcpkgs/sagemath/files/timings2.json
+++ b/srcpkgs/sagemath/files/timings2.json
@@ -109,7 +109,7 @@
   "sage.combinat.symmetric_group_algebra": {"walltime": 16},
   "sage.combinat.tableau": {"walltime": 32},
   "sage.combinat.tableau_tuple": {"walltime": 32},
-  "sage.combinat.tiling": {"walltime": 256},
+  "sage.combinat.tiling": {"walltime": 16},
   "sage.combinat.tutorial": {"walltime": 16},
   "sage.combinat.words.paths": {"walltime": 64},
   "sage.crypto.block_cipher.des": {"walltime": 16},
@@ -193,10 +193,10 @@
   "sage.manifolds.differentiable.automorphismfield": {"walltime": 32},
   "sage.manifolds.differentiable.automorphismfield_group": {"walltime": 8},
   "sage.manifolds.differentiable.bundle_connection": {"walltime": 8},
-  "sage.manifolds.differentiable.characteristic_cohomology_class": {"walltime": 256},
+  "sage.manifolds.differentiable.characteristic_cohomology_class": {"walltime": 64},
   "sage.manifolds.differentiable.curve": {"walltime": 16},
   "sage.manifolds.differentiable.degenerate": {"walltime": 32},
-  "sage.manifolds.differentiable.degenerate_submanifold": {"walltime": 256},
+  "sage.manifolds.differentiable.degenerate_submanifold": {"walltime": 16},
   "sage.manifolds.differentiable.diff_form": {"walltime": 64},
   "sage.manifolds.differentiable.diff_map": {"walltime": 8},
   "sage.manifolds.differentiable.examples.euclidean": {"walltime": 32},
@@ -270,7 +270,7 @@
   "sage.modules.free_quadratic_module_integer_symmetric": {"walltime": 8},
   "sage.modules.torsion_quadratic_module": {"walltime": 16},
   "sage.parallel.map_reduce": {"walltime": 8},
-  "sage.plot.animate": {"walltime": 128},
+  "sage.plot.animate": {"walltime": 16},
   "sage.plot.arrow": {"walltime": 8},
   "sage.plot.circle": {"walltime": 8},
   "sage.plot.complex_plot": {"walltime": 8},
@@ -308,7 +308,7 @@
   "sage.rings.function_field.function_field_valuation": {"walltime": 64},
   "sage.rings.function_field.ideal": {"walltime": 8},
   "sage.rings.function_field.place": {"walltime": 8},
-  "sage.rings.integer": {"walltime": 128},
+  "sage.rings.integer": {"walltime": 64},
   "sage.rings.invariants.invariant_theory": {"walltime": 8},
   "sage.rings.number_field.bdd_height": {"walltime": 8},
   "sage.rings.number_field.number_field": {"walltime": 64},
diff --git a/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch b/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
deleted file mode 100644
index e5c3f5776aa2..000000000000
--- a/srcpkgs/sagemath/patches/01-dont_link_ratpoints.patch
+++ /dev/null
@@ -1,10 +0,0 @@
- - do not link ratpoints where it's not used
-
---- a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
-+++ b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
-@@ -1,5 +1,3 @@
--# distutils: libraries = ratpoints
--
- r"""
- Descent on elliptic curves over `\QQ` with a 2-isogeny
- """
diff --git a/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch b/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
deleted file mode 100644
index d3672b094c1c..000000000000
--- a/srcpkgs/sagemath/patches/02-fix_get_shared_lib_path--see_29644.patch
+++ /dev/null
@@ -1,13 +0,0 @@
- - fix _get_shared_lib_path() so we don't need to configure GAP_SO
-
---- a/src/sage/env.py
-+++ b/src/sage/env.py
-@@ -293,7 +293,7 @@ def _get_shared_lib_path(*libnames: str) -> Optional[str]:
-             if sys.platform == 'darwin':
-                 ext = 'dylib'
-             else:
--                ext = 'so'
-+                ext = 'so*'
- 
-             if SAGE_LOCAL:
-                 search_directories.append(Path(SAGE_LOCAL) / 'lib')
diff --git a/srcpkgs/sagemath/patches/03-doctest_have_program.patch b/srcpkgs/sagemath/patches/03-doctest_have_program.patch
deleted file mode 100644
index 27ba3776470c..000000000000
--- a/srcpkgs/sagemath/patches/03-doctest_have_program.patch
+++ /dev/null
@@ -1,20 +0,0 @@
- - we don't know `SAGE_VENV/bin` contains `sage`, but `sys.argv[0]` should
-   be the full path to `sage-ipython` and the same directory should have `sage`
-
---- a/src/sage/misc/sage_ostools.pyx
-+++ b/src/sage/misc/sage_ostools.pyx
-@@ -32,12 +32,11 @@ def have_program(program, path=None):
-         True
-         sage: have_program('there_is_not_a_program_with_this_name')
-         False
--        sage: from sage.env import SAGE_VENV
--        sage: have_program('sage', os.path.join(SAGE_VENV, 'bin'))
-+        sage: have_program('sage', os.path.dirname(sys.argv[0]))
-         True
-         sage: have_program('sage', '/there_is_not_a_path_with_this_name')
-         False
--        sage: have_program('there_is_not_a_program_with_this_name', os.path.join(SAGE_VENV, 'bin'))
-+        sage: have_program('there_is_not_a_program_with_this_name', "/bin")
-         False
-     """
-     if path is None:
diff --git a/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch b/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
deleted file mode 100644
index 95bce107f854..000000000000
--- a/srcpkgs/sagemath/patches/04-doctest_sage_getfile.patch
+++ /dev/null
@@ -1,22 +0,0 @@
- - add one doctest for coverage
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -1341,10 +1342,12 @@ def sage_getfile(obj):
-     EXAMPLES::
- 
-         sage: from sage.misc.sageinspect import sage_getfile
--        sage: sage_getfile(sage.rings.rational)[-23:]
--        'sage/rings/rational.pyx'
--        sage: sage_getfile(Sq)[-42:]
--        'sage/algebras/steenrod/steenrod_algebra.py'
-+        sage: sage_getfile(sage.rings.rational)
-+        '...sage/rings/rational.pyx'
-+        sage: sage_getfile(Sq)
-+        '...sage/algebras/steenrod/steenrod_algebra.py'
-+        sage: sage_getfile(x)
-+        '...sage/symbolic/expression.pyx'
- 
-     The following tests against some bugs fixed in :trac:`9976`::
- 
-
diff --git a/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch b/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
deleted file mode 100644
index 56c58078f319..000000000000
--- a/srcpkgs/sagemath/patches/05-fix_sage_getfile.patch
+++ /dev/null
@@ -1,16 +0,0 @@
- - fix sage_getfile() by checking all possible EXTENSION_SUFFIXES
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -1400,8 +1403,9 @@ def sage_getfile(obj):
-         sourcefile = inspect.getabsfile(obj)
-     except TypeError: # this happens for Python builtins
-         return ''
--    if sourcefile.endswith(loadable_module_extension()):
--        return sourcefile[:-len(loadable_module_extension())]+os.path.extsep+'pyx'
-+    for suffix in import_machinery.EXTENSION_SUFFIXES:
-+        if sourcefile.endswith(suffix):
-+            return sourcefile[:-len(suffix)]+os.path.extsep+'pyx'
-     return sourcefile
- 
- 
diff --git a/srcpkgs/sagemath/patches/07-ignore_warning.patch b/srcpkgs/sagemath/patches/07-ignore_warning.patch
deleted file mode 100644
index 69668678a40b..000000000000
--- a/srcpkgs/sagemath/patches/07-ignore_warning.patch
+++ /dev/null
@@ -1,15 +0,0 @@
- - this ignores a warning caused by old notebook
-
---- a/src/sage/all.py
-+++ b/src/sage/all.py
-@@ -100,6 +100,9 @@ warnings.filterwarnings('ignore', category=DeprecationWarning,
-                         message='The distutils(.sysconfig module| package) is deprecated',
-                         module='Cython|distutils|numpy|sage.env|sage.features')
- 
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"invalid escape sequence '\\s'")
-+
- ################ end setup warnings ###############################
- 
- 
-
diff --git a/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch b/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
deleted file mode 100644
index 06bd2ccae6fb..000000000000
--- a/srcpkgs/sagemath/patches/08-dont_run_pytest--see_31924.patch
+++ /dev/null
@@ -1,27 +0,0 @@
- - using pytest is broken, see #31924
-
---- a/src/bin/sage-runtests
-+++ b/src/bin/sage-runtests
-@@ -154,21 +154,4 @@ if __name__ == "__main__":
-     DC = DocTestController(args, args.filenames)
-     err = DC.run()
- 
--    try:
--        exit_code_pytest = 0
--        import pytest
--        pytest_options = ["--import-mode", "importlib"]
--        if args.verbose:
--            pytest_options.append("-v")
--        exit_code_pytest = pytest.main(pytest_options + args.filenames)
--        if exit_code_pytest == 5:
--            # Exit code 5 means there were no test files, pass in this case
--            exit_code_pytest = 0
--
--    except ModuleNotFoundError:
--        print("Pytest is not installed, skip checking tests that rely on it.")
--
--    if err == 0:
--        sys.exit(exit_code_pytest)
--    else:
--        sys.exit(err)
-+    sys.exit(err)
diff --git a/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch b/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
deleted file mode 100644
index bae8387cf94a..000000000000
--- a/srcpkgs/sagemath/patches/10-fix_very_slow_doctest-polynomial_zmod_flint.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
-+++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
-@@ -237,8 +237,9 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
- 
-             sage: a = ZZ['x'](range(100000))
-             sage: R = Integers(3)['x']
--            sage: R(a)  # long time (7s on sage.math, 2013)
--            2*x^99998 + ... + x
-+            sage: p = R(a)
-+            sage: p.truncate(10)  # testing the whole poly is VERY SLOW
-+            2*x^8 + x^7 + 2*x^5 + x^4 + 2*x^2 + x
-         """
-         sig_on()
-         fmpz_poly_get_nmod_poly(&self.x, x)
diff --git a/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch b/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
deleted file mode 100644
index f3da5bbb555e..000000000000
--- a/srcpkgs/sagemath/patches/11-fix_very_slow_doctest-isogeny_small_degree.patch
+++ /dev/null
@@ -1,106 +0,0 @@
-diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-index 43727346269..9d3ccd475cd 100644
---- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-+++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
-@@ -186,7 +186,7 @@ def Psi(l, use_stored=True):
-         sage: assert Psi(3, use_stored=True) == Psi(3, use_stored=False)
-         sage: assert Psi(5, use_stored=True) == Psi(5, use_stored=False)
-         sage: assert Psi(7, use_stored=True) == Psi(7, use_stored=False)
--        sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False) # not tested (very long time)
-+        sage: assert Psi(13, use_stored=True) == Psi(13, use_stored=False)  # long time (2s)
-     """
-     if l not in [2, 3, 5, 7, 13]:
-         raise ValueError("Genus zero primes are 2, 3, 5, 7 or 13.")
-@@ -1207,7 +1207,7 @@ def isogenies_13_0(E, minimal_models=True):
-         sage: K.<a> = NumberField(f)
-         sage: E = EllipticCurve(j=K(0)); E.ainvs()
-         (0, 0, 0, 0, 1)
--        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]
-+        sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]  # long time (4s)
-         [(0,
-           0,
-           20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
-@@ -1325,7 +1325,7 @@ def isogenies_13_1728(E, minimal_models=True):
-         sage: f = x^12 + 1092*x^10 - 432432*x^8 + 6641024*x^6 - 282896640*x^4 - 149879808*x^2 - 349360128
-         sage: K.<a> = NumberField(f)
-         sage: E = EllipticCurve(K, [1,0])
--        sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]
-+        sage: [phi.codomain().ainvs() for phi in isogenies_13_1728(E)]  # long time (3s)
-         [(0,
-         0,
-         0,
-@@ -1550,8 +1550,11 @@ def Psi2(l):
-         sage: from sage.schemes.elliptic_curves.isogeny_small_degree import Psi2
-         sage: Psi2(11)
-         x^5 - 55*x^4*u + 994*x^3*u^2 - 8774*x^2*u^3 + 41453*x*u^4 - 928945/11*u^5 + 33*x^4 + 276*x^3*u - 7794*x^2*u^2 + 4452*x*u^3 + 1319331/11*u^4 + 216*x^3*v - 4536*x^2*u*v + 31752*x*u^2*v - 842616/11*u^3*v + 162*x^3 + 38718*x^2*u - 610578*x*u^2 + 33434694/11*u^3 - 4536*x^2*v + 73872*x*u*v - 2745576/11*u^2*v - 16470*x^2 + 580068*x*u - 67821354/11*u^2 - 185976*x*v + 14143896/11*u*v + 7533*x - 20437029/11*u - 12389112/11*v + 19964151/11
--        sage: Psi2(71)  # long time (1 second)
--        -2209380711722505179506258739515288584116147237393815266468076436521/71*u^210 + ... - 14790739586438315394567393301990769678157425619440464678252277649/71
-+        sage: f = Psi2(71)
-+        sage: f.coefficient([0, 210, 0])
-+        -2209380711722505179506258739515288584116147237393815266468076436521/71
-+        sage: f.coefficient([0, 0, 0])
-+        -14790739586438315394567393301990769678157425619440464678252277649/71
- 
-     TESTS::
- 
-@@ -1665,17 +1668,17 @@ def isogenies_prime_degree_genus_plus_0(E, l=None, minimal_models=True):
-         sage: K = QuadraticField(5,'a')
-         sage: a = K.gen()
-         sage: E = EllipticCurve_from_j(184068066743177379840*a - 411588709724712960000)
--        sage: isogenies_prime_degree_genus_plus_0(E, 47) # long time (4.3s)
-+        sage: isogenies_prime_degree_genus_plus_0(E, 47)  # long time (2s)
-         [Isogeny of degree 47 from Elliptic Curve defined by y^2 = x^3 + (454562028554080355857852049849975895490560*a-1016431595837124114668689286176511361024000)*x + (-249456798429896080881440540950393713303830363999480904280965120*a+557802358738710443451273320227578156598454035482869042774016000) over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790? to Elliptic Curve defined by y^2 = x^3 + (39533118442361013730577638493616965245992960*a-88398740199669828340617478832005245173760000)*x + (214030321479466610282320528611562368963830105830555363061803253760*a-478586348074220699687616322532666163722004497458452316582576128000) over Number Field in a with defining polynomial x^2 - 5 with a = 2.236067977499790?]
- 
-         sage: K = QuadraticField(-66827,'a')
-         sage: a = K.gen()
-         sage: E = EllipticCurve_from_j(-98669236224000*a + 4401720074240000)
--        sage: isogenies_prime_degree_genus_plus_0(E, 59)   # long time (25s, 2012)
-+        sage: isogenies_prime_degree_genus_plus_0(E, 59)   # long time (5s)
-         [Isogeny of degree 59 from Elliptic Curve defined by y^2 = x^3 + (2605886146782144762297974784000*a+1893681048912773634944634716160000)*x + (-116918454256410782232296183198067568744071168000*a+17012043538294664027185882358514011304812871680000) over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I to Elliptic Curve defined by y^2 = x^3 + (-19387084027159786821400775098368000*a-4882059104868154225052787156713472000)*x + (-25659862010101415428713331477227179429538847260672000*a-2596038148441293485938798119003462972840818381946880000) over Number Field in a with defining polynomial x^2 + 66827 with a = 258.5091874576221?*I]
- 
-         sage: E = EllipticCurve_from_j(GF(13)(5))
--        sage: isogenies_prime_degree_genus_plus_0(E, 71) # long time
-+        sage: isogenies_prime_degree_genus_plus_0(E, 71)
-         [Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13, Isogeny of degree 71 from Elliptic Curve defined by y^2 = x^3 + x + 4 over Finite Field of size 13 to Elliptic Curve defined by y^2 = x^3 + 10*x + 7 over Finite Field of size 13]
- 
-         sage: E = EllipticCurve(GF(13),[0,1,1,1,0])
-@@ -2117,11 +2120,11 @@ def isogenies_prime_degree_general(E, l, minimal_models=True):
-         sage: isogenies_prime_degree_general(E, 19)
-         [Isogeny of degree 19 from Elliptic Curve defined by y^2 + y = x^3 - 1862*x - 30956 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - 672182*x + 212325489 over Rational Field]
-         sage: E = EllipticCurve([0, -1, 0, -6288, 211072])
--        sage: isogenies_prime_degree_general(E, 37)  # long time (10s)
-+        sage: isogenies_prime_degree_general(E, 37)  # long time (2s)
-         [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 - x^2 - 6288*x + 211072 over Rational Field to Elliptic Curve defined by y^2 = x^3 - x^2 - 163137088*x - 801950801728 over Rational Field]
- 
-         sage: E = EllipticCurve([-3440, 77658])
--        sage: isogenies_prime_degree_general(E, 43)  # long time (16s)
-+        sage: isogenies_prime_degree_general(E, 43)  # long time (2s)
-         [Isogeny of degree 43 from Elliptic Curve defined by y^2 = x^3 - 3440*x + 77658 over Rational Field to Elliptic Curve defined by y^2 = x^3 - 6360560*x - 6174354606 over Rational Field]
- 
-     Isogenies of degree equal to the characteristic are computed (but
-@@ -2175,7 +2178,7 @@ def isogenies_prime_degree_general(E, l, minimal_models=True):
- 
-         sage: K.<i> = QuadraticField(-1)
-         sage: E = EllipticCurve(K,[0,0,0,1,0])
--        sage: [phi.codomain().ainvs() for phi in E.isogenies_prime_degree(37)] # long time
-+        sage: [phi.codomain().ainvs() for phi in E.isogenies_prime_degree(37)]  # long time (6s)
-         [(0, 0, 0, -840*i + 1081, 0), (0, 0, 0, 840*i + 1081, 0)]
-     """
-     if not l.is_prime():
-@@ -2329,14 +2332,14 @@ def isogenies_prime_degree(E, l, minimal_models=True):
-         sage: E = EllipticCurve(GF(101), [-3440, 77658])
-         sage: E.isogenies_prime_degree(71) # fast
-         []
--        sage: E.isogenies_prime_degree(73) # slower (2s)
-+        sage: E.isogenies_prime_degree(73)  # long time (2s)
-         []
- 
-     Test that :trac:`32269` is fixed::
- 
-         sage: K = QuadraticField(-11)
-         sage: E = EllipticCurve(K, [0,1,0,-117,-541])
--        sage: E.isogenies_prime_degree(37)
-+        sage: E.isogenies_prime_degree(37)  # long time (9s)
-         [Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I to Elliptic Curve defined by y^2 = x^3 + x^2 + (30800*a+123963)*x + (3931312*a-21805005) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I,
-          Isogeny of degree 37 from Elliptic Curve defined by y^2 = x^3 + x^2 + (-117)*x + (-541) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I to Elliptic Curve defined by y^2 = x^3 + x^2 + (-30800*a+123963)*x + (-3931312*a-21805005) over Number Field in a with defining polynomial x^2 + 11 with a = 3.316624790355400?*I]
- 
diff --git a/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch b/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
deleted file mode 100644
index 3b7b1ea843df..000000000000
--- a/srcpkgs/sagemath/patches/12-fix_very_slow_doctest-function_field.patch
+++ /dev/null
@@ -1,97 +0,0 @@
---- a/src/sage/rings/function_field/function_field.py
-+++ b/src/sage/rings/function_field/function_field.py
-@@ -111,22 +111,21 @@ Function fields over the algebraic field are supported::
-     sage: m = L.completion(pl, prec=5)
-     sage: m(x)
-     I + s + O(s^5)
--    sage: m(y)
-+    sage: m(y)                             # long time (4s)
-     -2*s + (-4 - I)*s^2 + (-15 - 4*I)*s^3 + (-75 - 23*I)*s^4 + (-413 - 154*I)*s^5 + O(s^6)
--    sage: m(y)^2 + m(y) + m(x) + 1/m(x)
-+    sage: m(y)^2 + m(y) + m(x) + 1/m(x)    # long time (8s)
-     O(s^5)
- 
- TESTS::
- 
-     sage: TestSuite(J).run()
--    sage: TestSuite(K).run(max_runs=1024) # long time (5s)
--    sage: TestSuite(L).run(max_runs=64)   # long time (10s)
--    sage: TestSuite(M).run(max_runs=32)   # long time (30s)
--    sage: TestSuite(N).run(max_runs=64, skip = '_test_derivation')  # long time (8s)
--    sage: TestSuite(O).run(max_runs=128, skip = '_test_derivation') # long time (8s)
--
-+    sage: TestSuite(K).run(max_runs=256)   # long time (10s)
-+    sage: TestSuite(L).run(max_runs=8)     # long time (25s)
-+    sage: TestSuite(M).run(max_runs=8)     # long time (35s)
-+    sage: TestSuite(N).run(max_runs=8, skip = '_test_derivation')    # long time (15s)
-+    sage: TestSuite(O).run()
-     sage: TestSuite(R).run()
--    sage: TestSuite(S).run() # long time (3s)
-+    sage: TestSuite(S).run()               # long time (4s)
- 
- Global function fields
- ----------------------
-@@ -287,7 +286,7 @@ class FunctionField(Field):
-         TESTS::
- 
-             sage: K.<x> = FunctionField(QQ)
--            sage: TestSuite(K).run()
-+            sage: TestSuite(K).run()               # long time (3s)
-         """
-         Field.__init__(self, base_field, names=names, category=category)
- 
-@@ -729,7 +728,7 @@ class FunctionField(Field):
-         EXAMPLES::
- 
-             sage: K.<x> = FunctionField(QQ)
--            sage: TestSuite(K).run() # indirect doctest
-+            sage: TestSuite(K).run()    # indirect doctest, long time (3s)
-         """
-         tester = self._tester(**options)
-         S = tester.some_elements()
-@@ -1209,7 +1208,7 @@ class FunctionField_polymod(FunctionField):
-             sage: K.<x> = FunctionField(QQ); R.<y> = K[]
-             sage: L = K.extension(y^5 - x^3 - 3*x + x*y); L
-             Function field in y defined by y^5 + x*y - x^3 - 3*x
--            sage: TestSuite(L).run()  # long time
-+            sage: TestSuite(L).run(max_runs=512)   # long time (15s)
- 
-         We can set the variable name, which doesn't have to be y::
- 
-@@ -2888,7 +2887,8 @@ class FunctionField_simple(FunctionField_polymod):
-             sage: F.<y> = K.extension(Y^3 - x^2*(x^2 + x + 1)^2)
-             sage: O = K.maximal_order()
-             sage: pls = [O.ideal(x-QQbar(sqrt(c))).place() for c in [-2, -1, 0, 1, 2]]
--            sage: all(q.place_below() == p for p in pls for q in F.places_above(p))
-+            sage: all(q.place_below() == p         # long time (4s)
-+            ....:     for p in pls for q in F.places_above(p))
-             True
-         """
-         R = self.base_field()
-@@ -3091,7 +3091,7 @@ class FunctionField_global(FunctionField_simple):
- 
-         sage: K.<x> = FunctionField(GF(4)); _.<Y> = K[]
-         sage: L.<y> = K.extension((1 - x)*Y^7 - x^3)
--        sage: L.gaps()
-+        sage: L.gaps()                         # long time (6s)
-         [1, 2, 3]
- 
-     or may define a trivial extension::
-@@ -3111,7 +3111,7 @@ class FunctionField_global(FunctionField_simple):
- 
-             sage: K.<x> = FunctionField(GF(5)); _.<Y> = K[]
-             sage: L.<y> = K.extension(Y^3 - (x^3 - 1)/(x^3 - 2))
--            sage: TestSuite(L).run()
-+            sage: TestSuite(L).run()               # long time (7s)
-         """
-         FunctionField_polymod.__init__(self, polynomial, names)
- 
-@@ -3807,7 +3807,7 @@ class RationalFunctionField(FunctionField):
- 
-             sage: K.<t> = FunctionField(CC); K
-             Rational function field in t over Complex Field with 53 bits of precision
--            sage: TestSuite(K).run()
-+            sage: TestSuite(K).run()               # long time (5s)
- 
-             sage: FunctionField(QQ[I], 'alpha')
-             Rational function field in alpha over Number Field in I with defining polynomial x^2 + 1 with I = 1*I
diff --git a/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch b/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
deleted file mode 100644
index 4bd6f4f4e2dc..000000000000
--- a/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
+++ /dev/null
@@ -1,670 +0,0 @@
-As produced by `git diff 9.5 9.6.beta3 -- src/sage/libs/lrcalc`
-
-diff --git a/src/sage/libs/lrcalc/lrcalc.pxd b/src/sage/libs/lrcalc/lrcalc.pxd
-deleted file mode 100644
-index 10b88db93f2..00000000000
---- a/src/sage/libs/lrcalc/lrcalc.pxd
-+++ /dev/null
-@@ -1,77 +0,0 @@
--# distutils: libraries = lrcalc
--
--cdef extern from "lrcalc/hashtab.h":
--    ctypedef struct hashtab:
--        pass
--
--    ctypedef struct hash_itr:
--        pass
--
--    ctypedef unsigned long hashkey_t
--    ctypedef int (*cmp_t) (void* a, void* b)
--    ctypedef hashkey_t (*hash_t) (void* a)
--
--    hashtab* hash_new(cmp_t cm, hash_t hsh)
--    void hash_free(hashtab *ht)
--
--    void* hash_lookup(hashtab *ht, void *key)
--    void* hash_insert(hashtab *ht, void *key, void *value)
--
--    bint hash_good(hash_itr)
--    void hash_first(hashtab* s, hash_itr itr)
--    void hash_next(hash_itr itr)
--    void* hash_key(hash_itr itr)
--    void* hash_value(hash_itr itr)
--    int hash_intvalue(hash_itr itr)
--
--cdef extern from "lrcalc/vector.h":
--    ctypedef struct vector:
--        size_t length
--        int* array
--
--    vector* v_new(int length)
--    void v_free(vector* v)
--    void v_print(vector *v)
--    int v_length(vector* v)
--    int v_elem(vector* v, int i)
--
--    ctypedef struct vecpair:
--        vector *first
--        vector *second
--
--    vector* vp_first(vecpair* vp)
--    vector* vp_second(vecpair* vp)
--
--cdef extern from "lrcalc/list.h":
--    cdef struct _list:
--        void **array
--        size_t allocated
--        size_t length
--    void l_free(_list *lst)
--
--cdef extern from "lrcalc/symfcn.h":
--    long long lrcoef_c "lrcoef"(vector* outer, vector* inner1, vector* inner2)
--    hashtab* mult_c "mult"(vector *sh1, vector *sh2, int maxrows)
--    hashtab* skew_c "skew"(vector *outer, vector *inner, int maxrows)
--    hashtab* coprod_c "coprod"(vector *part, int all)
--    void fusion_reduce_c "fusion_reduce"(hashtab* ht, int rows, int cols, int opt_zero)
--    _list *quantum_reduce_c "quantum_reduce"(hashtab* ht, int rows, int col)
--
--    ctypedef struct skewtab:
--        vector *outer
--        vector *inner
--        vector *conts
--        int maxrows
--        vector *conjugate
--        int rows
--        int cols
--        int matrix[1]
--
--    skewtab *st_new(vector *outer, vector *inner, vector *conts, int maxrows)
--    int st_next(skewtab *st)
--    void st_print(skewtab *st)
--    void st_free(skewtab *st)
--
--
--cdef extern from "lrcalc/schublib.h":
--    hashtab* mult_schubert_c "mult_schubert"(vector *sh1, vector *sh2, int rank)
-diff --git a/src/sage/libs/lrcalc/lrcalc.pyx b/src/sage/libs/lrcalc/lrcalc.py
-similarity index 60%
-rename from src/sage/libs/lrcalc/lrcalc.pyx
-rename to src/sage/libs/lrcalc/lrcalc.py
-index b591081ec4c..b541bfacd89 100644
---- a/src/sage/libs/lrcalc/lrcalc.pyx
-+++ b/src/sage/libs/lrcalc/lrcalc.py
-@@ -10,7 +10,8 @@ fusion products. All of the above are achieved by counting LR
- appropriate shape and content by iterating through them.
- Additionally, ``lrcalc`` handles products of Schubert polynomials.
- 
--The web page of ``lrcalc`` is `<http://sites.math.rutgers.edu/~asbuch/lrcalc/>`_.
-+The web page of ``lrcalc`` is
-+`<http://sites.math.rutgers.edu/~asbuch/lrcalc/>`_.
- 
- The following describes the Sage interface to this library.
- 
-@@ -36,12 +37,13 @@ Schur expansion::
-      [4, 2]: 1}
- 
- Same product, but include only partitions with at most 3 rows.  This
--corresponds to computing in the representation ring of gl(3)::
-+corresponds to computing in the representation ring of `\mathfrak{gl}(3)`::
- 
-     sage: lrcalc.mult([2,1], [2,1], 3)
-     {[2, 2, 2]: 1, [3, 2, 1]: 2, [3, 3]: 1, [4, 1, 1]: 1, [4, 2]: 1}
- 
--We can also compute the fusion product, here for sl(3) and level 2::
-+We can also compute the fusion product, here for `\mathfrak{sl}(3)`
-+and level 2::
- 
-     sage: lrcalc.mult([3,2,1], [3,2,1], 3,2)
-     {[4, 4, 4]: 1, [5, 4, 3]: 1}
-@@ -77,42 +79,38 @@ Multiply two Schubert polynomials::
-      [6, 2, 1, 4, 3, 5]: 1}
- 
- Same product, but include only permutations of 5 elements in the result.
--This corresponds to computing in the cohomology ring of Fl(5)::
-+This corresponds to computing in the cohomology ring of `Fl(5)`::
- 
-     sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3], 5)
-     {[4, 5, 1, 3, 2]: 1, [5, 3, 1, 4, 2]: 1, [5, 4, 1, 2, 3]: 1}
- 
- List all Littlewood-Richardson tableaux of skew shape `\mu/\nu`; in
- this example `\mu=[3,2,1]` and `\nu=[2,1]`. Specifying a third entry
--`maxrows` restricts the alphabet to `\{1,2,\ldots,maxrows\}`::
-+`M' = ``maxrows`` restricts the alphabet to `\{1,2,\ldots,M\}`::
- 
-     sage: list(lrcalc.lrskew([3,2,1],[2,1]))
-     [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
-     [[None, None, 1], [None, 2], [1]], [[None, None, 1], [None, 2], [3]]]
- 
-     sage: list(lrcalc.lrskew([3,2,1],[2,1],maxrows=2))
--    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]], [[None, None, 1], [None, 2], [1]]]
-+    [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
-+     [[None, None, 1], [None, 2], [1]]]
- 
- .. TODO::
- 
--    use this library in the :class:`SymmetricFunctions` code, to
-+    Use this library in the :class:`SymmetricFunctions` code, to
-     make it easy to apply it to linear combinations of Schur functions.
- 
- .. SEEALSO::
- 
-     - :func:`lrcoef`
--
-     - :func:`mult`
--
-     - :func:`coprod`
--
-     - :func:`skew`
--
-     - :func:`lrskew`
--
-     - :func:`mult_schubert`
- 
--.. rubric:: Underlying algorithmic in lrcalc
-+.. RUBRIC:: Underlying algorithmic in lrcalc
- 
- Here is some additional information regarding the main low-level
- C-functions in `lrcalc`. Given two partitions ``outer`` and ``inner``
-@@ -187,180 +185,24 @@ AUTHORS:
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from sage.rings.integer cimport Integer
--from sage.structure.parent cimport Parent
- from sage.combinat.partition import _Partitions
- from sage.combinat.permutation import Permutation
--from sage.combinat.skew_tableau import SkewTableau
--
--
--cdef vector* iterable_to_vector(it):
--    """
--    Return an lrcalc vector (which is a list of integers) from a Python iterable.
--
--    TESTS::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector(Partition([3,2,1])); x   #indirect doctest
--        [3, 2, 1]
--    """
--    cdef vector* v
--    cdef list itr = list(it)
--    cdef int n = len(itr)
--    cdef int i
--    v = v_new(n)
--    for i in range(n):
--        v.array[i] = int(itr[i])
--    return v
--
--
--cdef list vector_to_list(vector *v):
--    """
--    Converts a lrcalc vector to Python list.
--
--    TESTS::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector([]); x         #indirect doctest
--        []
--    """
--    cdef int i, n
--    n = v_length(v)
--    cdef list result = [None]*n
--    for i in range(n):
--        result[i] = Integer(v_elem(v, i))
--    return result
--
--
--def test_iterable_to_vector(it):
--    """
--    A wrapper function for the cdef function ``iterable_to_vector``
--    and ``vector_to_list``, to test that they are working correctly.
-+from sage.combinat.skew_tableau import SemistandardSkewTableaux
-+from sage.combinat.skew_partition import SkewPartition
-+from sage.rings.integer import Integer
-+import lrcalc
- 
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
--        sage: x = test_iterable_to_vector([3,2,1]); x
--        [3, 2, 1]
--    """
--    cdef vector *v = iterable_to_vector(it)
--    result = vector_to_list(v)
--    v_free(v)
--    return result
--
--
--cdef skewtab_to_SkewTableau(skewtab *st):
--    """
--    A wrapper function which transforms the data set ``st`` used in
--    ``lrcalc`` to a ``SkewTableau`` in Sage.
-+def _lrcalc_dict_to_sage(result):
-+    r"""
-+    Translate from lrcalc output format to Sage expected format.
- 
-     TESTS::
- 
--        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
--        sage: test_skewtab_to_SkewTableau([],[])
--        []
--    """
--    inner = vector_to_list(st.inner)
--    outer = vector_to_list(st.outer)
--    return SkewTableau(expr=[[inner[y] for y in range(len(outer))],
--                             [[st.matrix[x + y * st.cols] + 1
--                                for x in range(inner[y], outer[y])]
--                              for y in range(len(outer) - 1, -1, -1)]])
--
--
--def test_skewtab_to_SkewTableau(outer, inner):
--    """
--    A wrapper function for the cdef function ``skewtab_to_SkewTableau``
--    for testing purposes.
--
--    It constructs the first LR skew tableau of shape ``outer/inner``
--    as an ``lrcalc`` ``skewtab``, and converts it to a
--    :class:`SkewTableau`.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
--        sage: test_skewtab_to_SkewTableau([3,2,1],[])
--        [[1, 1, 1], [2, 2], [3]]
--        sage: test_skewtab_to_SkewTableau([4,3,2,1],[1,1]).pp()
--        .  1  1  1
--        .  2  2
--        1  3
--        2
--    """
--    cdef vector* o = iterable_to_vector(outer)
--    cdef vector* i = iterable_to_vector(inner+[0]*(len(outer)-len(inner)))
--    cdef skewtab* st = st_new(o, i, NULL, 0)
--    return skewtab_to_SkewTableau(st)
--
--
--cdef dict sf_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary representing a Schur function. The keys are
--    partitions and the values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
-         sage: from sage.libs.lrcalc.lrcalc import mult
--        sage: sorted(mult([1],[1]).items())        #indirect doctest
--        [([1, 1], 1), ([2], 1)]
--        sage: assert isinstance(mult([1],[1]),dict)#indirect doctest
--    """
--    cdef hash_itr itr
--    cdef dict result = {}
--    cdef list p
--    hash_first(ht, itr)
--    while hash_good(itr):
--        p = vector_to_list(<vector*> hash_key(itr))
--        result[_Partitions(p)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
--
--cdef dict schubert_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary corresponding to a Schubert polynomial whose keys
--    are permutations and whose values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import mult_schubert
--        sage: mult_schubert([3,2,1], [1,2,3])      #indirect doctest
--        {[3, 2, 1]: 1}
--    """
--    cdef hash_itr itr
--    cdef dict result = {}
--    hash_first(ht, itr)
--    while hash_good(itr):
--        p = vector_to_list(<vector*> hash_key(itr))
--        result[Permutation(p)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
--
--cdef dict vp_hashtab_to_dict(hashtab *ht):
--    """
--    Return a dictionary corresponding to the coproduct of a Schur function whose keys are
--    pairs of partitions and whose values are integers <class 'sage.rings.integer.Integer'>.
--
--    EXAMPLES::
--
--        sage: from sage.libs.lrcalc.lrcalc import coprod
--        sage: coprod([1])      #indirect doctest
--        {([1], []): 1}
-+        sage: mult([2,1],[3,2,1],3) # indirect doctest
-+        {[3, 3, 3]: 1, [4, 3, 2]: 2, [4, 4, 1]: 1, [5, 2, 2]: 1, [5, 3, 1]: 1}
-     """
--    cdef hash_itr itr
--    cdef vecpair* vp
--    cdef dict result = {}
--    hash_first(ht, itr)
--    while hash_good(itr):
--        vp = <vecpair*> hash_key(itr)
--        p1 = _Partitions(vector_to_list(vp_first(vp)))
--        p2 = _Partitions(vector_to_list(vp_second(vp)))
--        result[(p1, p2)] = Integer(hash_intvalue(itr))
--        hash_next(itr)
--    return result
--
-+    return {_Partitions(la): Integer(k) for la, k in result.items()}
- 
- def lrcoef_unsafe(outer, inner1, inner2):
-     r"""
-@@ -371,13 +213,11 @@ def lrcoef_unsafe(outer, inner1, inner2):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
--
--    - ``inner1`` -- a partition.
-+    - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
-+    - ``inner1`` -- a partition
-+    - ``inner2`` -- a partition
- 
--    - ``inner2`` -- a partition.
--
--    .. warning::
-+    .. WARNING::
- 
-        This function does not do any check on its input.  If you want
-        to use a safer version, use :func:`lrcoef`.
-@@ -392,18 +232,7 @@ def lrcoef_unsafe(outer, inner1, inner2):
-         sage: lrcoef_unsafe([2,1,1,1,1], [2,1], [2,1])
-         0
-     """
--    cdef long long result
--    cdef vector *o
--    cdef vector *i1
--    cdef vector *i2
--    o = iterable_to_vector(outer)
--    i1 = iterable_to_vector(inner1)
--    i2 = iterable_to_vector(inner2)
--    result = lrcoef_c(o, i1, i2)
--    v_free(o)
--    v_free(i1)
--    v_free(i2)
--    return Integer(result)
-+    return Integer(lrcalc.lrcoef(outer, inner1, inner2))
- 
- 
- def lrcoef(outer, inner1, inner2):
-@@ -415,11 +244,9 @@ def lrcoef(outer, inner1, inner2):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
--
--    - ``inner1`` -- a partition.
--
--    - ``inner2`` -- a partition.
-+    - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
-+    - ``inner1`` -- a partition
-+    - ``inner2`` -- a partition
- 
-     .. NOTE::
- 
-@@ -436,7 +263,6 @@ def lrcoef(outer, inner1, inner2):
-         1
-         sage: lrcoef([2,1,1,1,1], [2,1], [2,1])
-         0
--
-     """
-     return lrcoef_unsafe(_Partitions(outer), _Partitions(inner1), _Partitions(inner2))
- 
-@@ -451,13 +277,9 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-     INPUT:
- 
-     - ``part1`` -- a partition
--
-     - ``part2`` -- a partition
--
-     - ``maxrows`` -- (optional) an integer
--
-     - ``level`` -- (optional) an integer
--
-     - ``quantum`` -- (optional) an element of a ring
- 
-     If ``maxrows`` is specified, then only partitions with at most
-@@ -479,7 +301,8 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-         sage: sorted(mult([2],[2]).items())
-         [([2, 2], 1), ([3, 1], 1), ([4], 1)]
-         sage: sorted(mult([2,1],[2,1]).items())
--        [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1), ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
-+        [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1),
-+         ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
-         sage: sorted(mult([2,1],[2,1],maxrows=2).items())
-         [([3, 3], 1), ([4, 2], 1)]
-         sage: mult([2,1],[3,2,1],3)
-@@ -510,44 +333,24 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
-     if quantum is not None and (level is None or maxrows is None):
-         raise ValueError('missing parameters maxrows or level')
- 
--    cdef vector* v1 = iterable_to_vector(part1)
--    cdef vector* v2 = iterable_to_vector(part2)
--    if maxrows is None:
--        maxrows = 0
--    cdef hashtab* ht = mult_c(v1, v2, int(maxrows))
--    cdef hashtab* tab
--    cdef dict result
--
-     if quantum is None:
-         if level is not None:
--            fusion_reduce_c(ht, int(maxrows), int(level), int(0))
--        result = sf_hashtab_to_dict(ht)
--        v_free(v1)
--        v_free(v2)
--        hash_free(ht)
--        return result
-+            return _lrcalc_dict_to_sage(lrcalc.mult_fusion(part1, part2, maxrows, level))
-+        if maxrows is None:
-+            maxrows = -1
-+        return _lrcalc_dict_to_sage(lrcalc.mult(part1, part2, maxrows))
- 
-     # Otherwise do quantum multiplication
--    cdef _list *qlist
--    cdef dict temp
--    qlist = quantum_reduce_c(ht, int(maxrows), int(level))
--    # The above call frees the memory associated with ht
--    v_free(v1)
--    v_free(v2)
--
--    cdef Parent P = quantum.parent()
--    result = {}
--    for i in range(qlist.length):
--        tab = <hashtab*>(qlist.array[i])
--        temp = sf_hashtab_to_dict(tab)
--        for k in temp:
--            result[k] = result.get(k, P.zero()) + quantum**i * temp[k]
--        hash_free(tab)
--    l_free(qlist)
--    return result
--
--
--def skew(outer, inner, maxrows=0):
-+    result = lrcalc.mult_quantum(part1, part2, maxrows, level, degrees=True)
-+    P = quantum.parent()
-+    output = {}
-+    for i,k in result.items():
-+        la = _Partitions(i[0])
-+        output[la] = output.get(la, P.zero()) + k * quantum**(i[1])
-+    return output
-+
-+
-+def skew(outer, inner, maxrows=-1):
-     """
-     Compute the Schur expansion of a skew Schur function.
- 
-@@ -557,11 +360,9 @@ def skew(outer, inner, maxrows=0):
- 
-     INPUT:
- 
--    - ``outer`` -- a partition.
--
--    - ``inner`` -- a partition.
--
--    - ``maxrows`` -- an integer or ``None``.
-+    - ``outer`` -- a partition
-+    - ``inner`` -- a partition
-+    - ``maxrows`` -- an integer or ``None``
- 
-     If ``maxrows`` is specified, then only partitions with at most
-     this number of rows are included in the result.
-@@ -572,14 +373,7 @@ def skew(outer, inner, maxrows=0):
-         sage: sorted(skew([2,1],[1]).items())
-         [([1, 1], 1), ([2], 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(outer)
--    cdef vector* v2 = iterable_to_vector(inner)
--    cdef hashtab* ht = skew_c(v1, v2, int(maxrows))
--    result = sf_hashtab_to_dict(ht)
--    v_free(v1)
--    v_free(v2)
--    hash_free(ht)
--    return result
-+    return _lrcalc_dict_to_sage(lrcalc.skew(outer, inner, maxrows))
- 
- 
- def coprod(part, all=0):
-@@ -592,9 +386,8 @@ def coprod(part, all=0):
- 
-     INPUT:
- 
--    - ``part`` -- a partition.
--
--    - ``all`` -- an integer.
-+    - ``part`` -- a partition
-+    - ``all`` -- an integer
- 
-     If ``all`` is non-zero then all terms are included in the result.
-     If ``all`` is zero, then only pairs of partitions ``(part1,
-@@ -609,12 +402,9 @@ def coprod(part, all=0):
-         sage: sorted(coprod([2,1]).items())
-         [(([1, 1], [1]), 1), (([2], [1]), 1), (([2, 1], []), 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(part)
--    cdef hashtab* ht = coprod_c(v1, int(all))
--    result = vp_hashtab_to_dict(ht)
--    v_free(v1)
--    hash_free(ht)
--    return result
-+    result = lrcalc.coprod(part, all)
-+    return {tuple([_Partitions(mu) for mu in la]): Integer(k)
-+            for la, k in result.items()}
- 
- 
- def mult_schubert(w1, w2, rank=0):
-@@ -627,11 +417,9 @@ def mult_schubert(w1, w2, rank=0):
- 
-     INPUT:
- 
--    - ``w1`` -- a permutation.
--
--    - ``w2`` -- a permutation.
--
--    - ``rank`` -- an integer.
-+    - ``w1`` -- a permutation
-+    - ``w2`` -- a permutation
-+    - ``rank`` -- an integer
- 
-     If ``rank`` is non-zero, then only permutations from the symmetric
-     group `S(\mathrm{rank})` are included in the result.
-@@ -646,33 +434,24 @@ def mult_schubert(w1, w2, rank=0):
-          ([6, 4, 3, 1, 2, 5], 1), ([6, 5, 2, 1, 3, 4], 1),
-          ([7, 3, 4, 1, 2, 5, 6], 1), ([7, 4, 2, 1, 3, 5, 6], 1)]
-     """
--    cdef vector* v1 = iterable_to_vector(w1)
--    cdef vector* v2 = iterable_to_vector(w2)
--    cdef hashtab* ht = mult_schubert_c(v1, v2, int(rank))
--    result = schubert_hashtab_to_dict(ht)
--    v_free(v1)
--    v_free(v2)
--    hash_free(ht)
--    return result
-+    result = lrcalc.schubmult(w1, w2, rank)
-+    return {Permutation(list(la)):Integer(k) for la,k in result.items()}
- 
- 
--def lrskew(outer, inner, weight=None, maxrows=0):
-+def lrskew(outer, inner, weight=None, maxrows=-1):
-     r"""
-     Iterate over the skew LR tableaux of shape ``outer / inner``.
- 
-     INPUT:
- 
-     - ``outer`` -- a partition
--
-     - ``inner`` -- a partition
--
-     - ``weight`` -- a partition (optional)
--
--    - ``maxrows`` -- an integer (optional)
-+    - ``maxrows`` -- a positive integer (optional)
- 
-     OUTPUT: an iterator of :class:`SkewTableau`
- 
--    Specifying ``maxrows`` restricts the alphabet to `\{1,2,\ldots,maxrows\}`.
-+    Specifying ``maxrows`` = `M` restricts the alphabet to `\{1,2,\ldots,M\}`.
- 
-     Specifying ``weight`` returns only those tableaux of given content/weight.
- 
-@@ -702,22 +481,40 @@ def lrskew(outer, inner, weight=None, maxrows=0):
- 
-         sage: list(lrskew([3,2,1],[2], weight=[3,1]))
-         [[[None, None, 1], [1, 1], [2]]]
-+
-+    TESTS::
-+
-+        sage: from sage.libs.lrcalc.lrcalc import lrskew
-+        sage: list(lrskew([3,2,1],[2], weight=[]))
-+        []
-+        sage: list(lrskew([3,2,1],[2], weight=[0]))
-+        []
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[]))
-+        [[[None, None, None], [None, None], [None]]]
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[0]))
-+        [[[None, None, None], [None, None], [None]]]
-+        sage: list(lrskew([3,2,1],[3,2,1], weight=[1]))
-+        []
-     """
--    cdef vector* o = iterable_to_vector(outer)
--    cdef vector* i = iterable_to_vector(inner + [0]*(len(outer) - len(inner)))
--    cdef skewtab* st = st_new(o, i, NULL, int(maxrows))
-+    iterator = lrcalc.lr_iterator(outer, inner, maxrows)
-+    shape = SkewPartition([outer, inner])
- 
-     if weight is None:
--        yield skewtab_to_SkewTableau(st)
--        while st_next(st):
--            yield skewtab_to_SkewTableau(st)
-+        ST = SemistandardSkewTableaux(shape)
-+        for data in iterator:
-+            yield ST.from_shape_and_word(shape, [i+1 for i in data])
-     else:
-         wt = _Partitions(weight)
--        r = skewtab_to_SkewTableau(st)
--        if r.weight() == wt:
--            yield r
--        while st_next(st):
--            r = skewtab_to_SkewTableau(st)
--            if r.weight() == wt:
--                yield r
--    st_free(st)
-+        ST = SemistandardSkewTableaux(shape, wt)
-+        m = len(wt)
-+        for data in iterator:
-+            w = [0] * m
-+            for j in data:
-+                if j >= m:
-+                    # We know they are not equal, so make the check below quick
-+                    w = None
-+                    break
-+                w[j] += 1
-+            if w == wt:
-+                yield ST.from_shape_and_word(shape, [i+1 for i in data])
-+
diff --git a/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch b/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
deleted file mode 100644
index 1e2e0ba90742..000000000000
--- a/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-As produced by `git diff a90a3146{^^,}`
-
-diff --git a/src/sage/repl/interface_magic.py b/src/sage/repl/interface_magic.py
-index 8a455b69b0e..a93e1c9e04c 100644
---- a/src/sage/repl/interface_magic.py
-+++ b/src/sage/repl/interface_magic.py
-@@ -260,7 +260,7 @@ class InterfaceMagic(object):
-             2
-             120
-             sage: shell.run_cell('%%gap foo\n1+1;\n')
--            ...File "<string>", line unknown
-+            ...File...<string>...
-             SyntaxError: Interface magics have no options, got "foo"
-             <BLANKLINE>
-             sage: shell.run_cell('%%gap?')
-diff --git a/src/sage/repl/interpreter.py b/src/sage/repl/interpreter.py
-index 7468afe52d7..06c47b7374a 100644
---- a/src/sage/repl/interpreter.py
-+++ b/src/sage/repl/interpreter.py
-@@ -78,9 +78,9 @@ Check that Cython source code appears in tracebacks::
-     dummy line
-     ...
-     ZeroDivisionError...Traceback (most recent call last)
--    <ipython-input-...> in <module>...
-+    ...in <module>...
-     ----> 1 Integer(1)/Integer(0)
--    .../sage/rings/integer.pyx in sage.rings.integer.Integer...div...
-+    .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
-     ...
-     -> ...                  raise ZeroDivisionError("rational division by zero")
-        ....:            x = <Rational> Rational.__new__(Rational)
-@@ -423,7 +423,7 @@ def SagePreparseTransformer(lines):
-         sage: from sage.repl.interpreter import get_test_shell
-         sage: shell = get_test_shell()
-         sage: shell.run_cell(bad_syntax)
--          File "<string>", line unknown
-+          File...<string>...
-         SyntaxError: Mismatched ']'
-         <BLANKLINE>
-         sage: shell.quit()
diff --git a/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch b/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
deleted file mode 100644
index 853813b0f5bd..000000000000
--- a/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-Fix for ipython 8.1
-
---- a/src/sage/repl/interpreter.py
-+++ b/src/sage/repl/interpreter.py
-@@ -78,7 +78,7 @@ Check that Cython source code appears in tracebacks::
-     dummy line
-     ...
-     ZeroDivisionError...Traceback (most recent call last)
--    ...in <module>...
-+    ...
-     ----> 1 Integer(1)/Integer(0)
-     .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
-     ...
diff --git a/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch b/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
deleted file mode 100644
index b861af7ec982..000000000000
--- a/srcpkgs/sagemath/patches/trac-33189-fix_doctests_for_arb_2.22-53532ddd4e2dc92469c1590ebf0c40f8f69bf579.patch
+++ /dev/null
@@ -1,126 +0,0 @@
-From 24cc94b1988a90f3bd22a2368ec30c086283af13 Mon Sep 17 00:00:00 2001
-From: Antonio Rojas <arojas@archlinux.org>
-Date: Sun, 16 Jan 2022 11:55:04 +0100
-Subject: Add abs tol to some arb tests
-
----
- src/sage/functions/error.py    |  2 +-
- src/sage/rings/complex_arb.pyx |  6 +++---
- src/sage/rings/real_arb.pyx    | 10 +++++-----
- 3 files changed, 9 insertions(+), 9 deletions(-)
-
-diff --git a/src/sage/functions/error.py b/src/sage/functions/error.py
-index f48d04f..06f0b24 100644
---- a/src/sage/functions/error.py
-+++ b/src/sage/functions/error.py
-@@ -267,7 +267,7 @@ class Function_erf(BuiltinFunction):
- 
-         Check that real ball evaluation is fixed :trac:`28061`::
- 
--            sage: RealBallField(128)(erf(5))
-+            sage: RealBallField(128)(erf(5)) # abs tol 1e-38
-             [0.99999999999846254020557196514981165651 +/- 7.33e-39]
-         """
-         R = parent or s_parent(x)
-diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
-index f986970..93ff565 100644
---- a/src/sage/rings/complex_arb.pyx
-+++ b/src/sage/rings/complex_arb.pyx
-@@ -3974,8 +3974,8 @@ cdef class ComplexBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: CBF(20).erfc()
--            [5.39586561160790e-176 +/- ...e-191]
-+            sage: CBF(20).erfc() # abs tol 1e-190
-+            [5.39586561160790e-176 +/- 6.73e-191]
-             sage: CBF(100, 100).erfc()
-             [0.00065234366376858 +/- ...e-18] + [-0.00393572636292141 +/- ...e-18]*I
-         """
-@@ -4280,7 +4280,7 @@ cdef class ComplexBall(RingElement):
- 
-         TESTS:
- 
--            sage: CBF(Shi(I))
-+            sage: CBF(Shi(I)) # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]*I
-         """
-         cdef ComplexBall result = self._new()
-diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
-index 4a81784..292bfea 100644
---- a/src/sage/rings/real_arb.pyx
-+++ b/src/sage/rings/real_arb.pyx
-@@ -3506,7 +3506,7 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1/2).erf()
-+            sage: RBF(1/2).erf() # abs tol 1e-16
-             [0.520499877813047 +/- 6.10e-16]
-         """
-         cdef RealBall res = self._new()
-@@ -3556,12 +3556,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Si()
-+            sage: RBF(1).Si() # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]
- 
-         TESTS::
- 
--            sage: RBF(Si(1))
-+            sage: RBF(Si(1)) # abs tol 1e-15
-             [0.946083070367183 +/- 9.22e-16]
-         """
-         cdef RealBall res = self._new()
-@@ -3578,12 +3578,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Ci()  # abs tol 1e-16
-+            sage: RBF(1).Ci()  # abs tol 1e-15
-             [0.337403922900968 +/- 3.25e-16]
- 
-         TESTS::
- 
--            sage: RBF(Ci(1))  # abs tol 1e-16
-+            sage: RBF(Ci(1))  # abs tol 1e-15
-             [0.337403922900968 +/- 3.25e-16]
-         """
-         cdef RealBall res = self._new()
--- 
-cgit v1.0-1-gd88e
-
-
-From 53532ddd4e2dc92469c1590ebf0c40f8f69bf579 Mon Sep 17 00:00:00 2001
-From: Antonio Rojas <arojas@archlinux.org>
-Date: Sun, 16 Jan 2022 14:16:53 +0100
-Subject: Decrease abs tol
-
----
- src/sage/rings/real_arb.pyx | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
-index 292bfea..eb30f7f 100644
---- a/src/sage/rings/real_arb.pyx
-+++ b/src/sage/rings/real_arb.pyx
-@@ -3578,12 +3578,12 @@ cdef class RealBall(RingElement):
- 
-         EXAMPLES::
- 
--            sage: RBF(1).Ci()  # abs tol 1e-15
-+            sage: RBF(1).Ci()  # abs tol 5e-16
-             [0.337403922900968 +/- 3.25e-16]
- 
-         TESTS::
- 
--            sage: RBF(Ci(1))  # abs tol 1e-15
-+            sage: RBF(Ci(1))  # abs tol 5e-16
-             [0.337403922900968 +/- 3.25e-16]
-         """
-         cdef RealBall res = self._new()
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch b/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
deleted file mode 100644
index d4e8f8be60e3..000000000000
--- a/srcpkgs/sagemath/patches/trac-33226-fix_doctests_giac-1.7.0-33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-From 33ea2adf01e9e2ce9f1e33779f0b1ac0d9d1989c Mon Sep 17 00:00:00 2001
-From: Michael Orlitzky <michael@orlitzky.com>
-Date: Mon, 24 Jan 2022 09:03:29 -0500
-Subject: Trac #33226: update doctests for giac-1.7.0.45.
-
-We have two failing doctests with giac-1.7.0.45: one is a trivial
-tolerance issue, but the other is a symbolic integration result for
-which giac is no longer willing to return a symbolic answer. We add
-"abs tol" to the numeric test, and drop the symbolic one entirely.
----
- src/sage/functions/min_max.py | 8 ++++----
- 1 file changed, 4 insertions(+), 4 deletions(-)
-
-diff --git a/src/sage/functions/min_max.py b/src/sage/functions/min_max.py
-index fc18373..9b7d6d9 100644
---- a/src/sage/functions/min_max.py
-+++ b/src/sage/functions/min_max.py
-@@ -228,15 +228,15 @@ class MaxSymbolic(MinMax_base):
-             ...
-             TypeError: cannot evaluate symbolic expression numerically
- 
--        ::
-+        We can usually integrate these expressions, but can't
-+        guarantee a symbolic answer in closed form::
- 
-             sage: f = max_symbolic(sin(x), cos(x))
-             sage: r = integral(f, x, 0, 1)
-             ...
--            sage: r
--            sqrt(2) - cos(1)
--            sage: r.n()
-+            sage: r.n()  # abs tol 1e-8
-             0.873911256504955
-+
-         """
-         return max_symbolic(args)
- 
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch b/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
deleted file mode 100644
index 19b69700a4f6..000000000000
--- a/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
+++ /dev/null
@@ -1,19 +0,0 @@
-commit 9c8235e44ffb509efa8a3ca6cdb55154e2b5066d
-Author: Antonio Rojas <arojas@archlinux.org>
-Date:   Sun Feb 13 19:53:14 2022 +0100
-
-    Fix deprecation warning with scipy 1.8
-
-diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-index e9b60dae5ec..7932167b41d 100644
---- a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
-@@ -356,7 +356,7 @@ Sage example in ./linsolve.tex, line 2230::
- 
- Sage example in ./linsolve.tex, line 2609::
- 
--  sage: from scipy.sparse.linalg.dsolve import *
-+  sage: from scipy.sparse.linalg import factorized
-   sage: from scipy.sparse import lil_matrix
-   sage: from numpy import array
-   sage: n = 200
diff --git a/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch b/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
new file mode 100644
index 000000000000..e052e306e7a1
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-33360-avoid_factoring_in_is_prime-6330cee1a69229b2f5d8ac4a09a73d8152f5e14d.patch
@@ -0,0 +1,53 @@
+From 6330cee1a69229b2f5d8ac4a09a73d8152f5e14d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Mon, 28 Feb 2022 23:15:16 -0300
+Subject: trac 33360: avoid factoring in is_prime()
+
+In the added TEST, the ideal norm is product of two primes but factoring
+this product takes about half an hour, so factoring the ideal is slow.
+
+To fix the issue, we only factor the ideal if the norm is a prime power.
+---
+ src/sage/rings/number_field/number_field_ideal.py | 22 ++++++++++++++++++++++
+ 1 file changed, 22 insertions(+)
+
+diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
+index f785f22..10d1f88 100644
+--- a/src/sage/rings/number_field/number_field_ideal.py
++++ b/src/sage/rings/number_field/number_field_ideal.py
+@@ -995,10 +995,32 @@ class NumberFieldIdeal(Ideal_generic):
+             False
+             sage: K.ideal(17).is_prime()  # ramified
+             False
++
++        TESTS::
++
++        Check that we do not factor the norm of the ideal, this used
++        to take half an hour, see :trac:`33360`
++
++           sage: K.<a,b,c> = NumberField([x^2-2,x^2-3,x^2-5])
++           sage: t = (((-2611940*c + 1925290/7653)*b - 1537130/7653*c
++           ....:       + 10130950)*a + (1343014/7653*c - 8349770)*b
++           ....:       + 6477058*c - 2801449990/4002519)
++           sage: t.is_prime()
++           False
++
+         """
+         try:
+             return self._pari_prime is not None
+         except AttributeError:
++            K = self.number_field().pari_nf()
++            I = self.pari_hnf()
++            # This would be better, but it is broken in pari 2.13.3.
++            #   self._pari_prime = K.idealismaximal(I) or None
++            # Instead we factor I, but only if the norm is a prime power
++            n = K.idealnorm(I)
++            if n.denominator() > 1 or not n.isprimepower():
++                self._pari_prime = None
++                return False
+             F = self.factor()  # factorization with caching
+             if len(F) != 1 or F[0][1] != 1:
+                 self._pari_prime = None
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
deleted file mode 100644
index 9ba7ca5a6b7d..000000000000
--- a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
+++ /dev/null
@@ -1,99 +0,0 @@
-From 609dd9deaeaa6380ab2f0d50276d911233c00a04 Mon Sep 17 00:00:00 2001
-From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
-Date: Fri, 4 Mar 2022 16:07:09 -0800
-Subject: sage.manifolds: Update doctests for SymPy 1.10
-
----
- src/sage/manifolds/continuous_map.py              | 3 +--
- src/sage/manifolds/differentiable/diff_form.py    | 4 ++--
- src/sage/manifolds/differentiable/tensorfield.py  | 8 ++++----
- src/sage/manifolds/vector_bundle_fiber_element.py | 2 +-
- 4 files changed, 8 insertions(+), 9 deletions(-)
-
-diff --git a/src/sage/manifolds/continuous_map.py b/src/sage/manifolds/continuous_map.py
-index a6356e7..f6f9b6d 100644
---- a/src/sage/manifolds/continuous_map.py
-+++ b/src/sage/manifolds/continuous_map.py
-@@ -1357,8 +1357,7 @@ class ContinuousMap(Morphism):
-             sage: Phi.coord_functions(c_uv, c_xyz)
-             Coordinate functions (u*v, u/v, u + v) on the Chart (M, (u, v))
-             sage: Phi.coord_functions(c_UV, c_xyz)
--            Coordinate functions (-U**2/4 + V**2/4, -(U + V)/(U - V), V)
--             on the Chart (M, (U, V))
-+            Coordinate functions (-U**2/4 + V**2/4, (-U - V)/(U - V), V) on the Chart (M, (U, V))
-             sage: Phi.coord_functions(c_UV, c_XYZ)
-             Coordinate functions ((-U**3 + U**2*V + U*V**2 + 2*U*V + 6*U - V**3
-              - 2*V**2 + 6*V)/(2*(U - V)), (U**3/4 - U**2*V/4 - U*V**2/4 + U*V
-diff --git a/src/sage/manifolds/differentiable/diff_form.py b/src/sage/manifolds/differentiable/diff_form.py
-index 70dd8fb..0aa3469 100644
---- a/src/sage/manifolds/differentiable/diff_form.py
-+++ b/src/sage/manifolds/differentiable/diff_form.py
-@@ -266,7 +266,7 @@ class DiffForm(TensorField):
- 
-         sage: s = a.wedge(b)
-         sage: s.display(eU)
--        a∧b = -x*(2*x*y + 1) dx∧dy
-+        a∧b = x*(-2*x*y - 1) dx∧dy
-         sage: s.display(eV)
-         a∧b = (u**3/8 + u**2*v/8 - u*v**2/8 + u/4 - v**3/8 + v/4) du∧dv
- 
-@@ -275,7 +275,7 @@ class DiffForm(TensorField):
-         sage: f = M.scalar_field({c_xy: (x+y)^2, c_uv: u^2}, name='f')
-         sage: s = f*a
-         sage: s.display(eU)
--        f*a = -y*(x**2 + 2*x*y + y**2) dx + x*(x**2 + 2*x*y + y**2) dy
-+        f*a = y*(-x**2 - 2*x*y - y**2) dx + x*(x**2 + 2*x*y + y**2) dy
-         sage: s.display(eV)
-         f*a = u**2*v/2 du - u**3/2 dv
- 
-diff --git a/src/sage/manifolds/differentiable/tensorfield.py b/src/sage/manifolds/differentiable/tensorfield.py
-index 2775be9..6bc5c50 100644
---- a/src/sage/manifolds/differentiable/tensorfield.py
-+++ b/src/sage/manifolds/differentiable/tensorfield.py
-@@ -334,7 +334,7 @@ class TensorField(ModuleElementWithMutability):
-         sage: f.display()  # long time
-         t(a,b): S^2 → ℝ
-         on U: (x, y) ↦ -2*x*y - 3*x - y**2
--        on V: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+        on V: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
- 
-     The vectors can be defined only on subsets of `S^2`, the domain of the
-     result is then the common subset::
-@@ -343,12 +343,12 @@ class TensorField(ModuleElementWithMutability):
-         sage: s.display()  # long time
-         t(a,b): U → ℝ
-            (x, y) ↦ -2*x*y - 3*x - y**2
--        on W: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+        on W: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
-         sage: s = t(a.restrict(U), b.restrict(W))  # long time
-         sage: s.display()  # long time
-         t(a,b): W → ℝ
-            (x, y) ↦ -2*x*y - 3*x - y**2
--           (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+           (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
- 
-     The tensor itself can be defined only on some open subset of `S^2`,
-     yielding a result whose domain is this subset::
-@@ -356,7 +356,7 @@ class TensorField(ModuleElementWithMutability):
-         sage: s = t.restrict(V)(a,b)  # long time
-         sage: s.display()  # long time
-         t(a,b): V → ℝ
--           (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
-+           (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
-         on W: (x, y) ↦ -2*x*y - 3*x - y**2
- 
-     Tests regarding the multiplication by a scalar field::
-diff --git a/src/sage/manifolds/vector_bundle_fiber_element.py b/src/sage/manifolds/vector_bundle_fiber_element.py
-index 29ee81d..048275a 100644
---- a/src/sage/manifolds/vector_bundle_fiber_element.py
-+++ b/src/sage/manifolds/vector_bundle_fiber_element.py
-@@ -110,4 +110,4 @@ class VectorBundleFiberElement(FiniteRankFreeModuleElement):
-             desc += str(self._name) + " "
-         desc += "in the fiber of {} at {}".format(self._vbundle._name,
-                                                   self._point)
--        return desc
-\ No newline at end of file
-+        return desc
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
deleted file mode 100644
index f5ac180baa90..000000000000
--- a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-From c49eff347454ac7f07e5918470b20e97b8f2357e Mon Sep 17 00:00:00 2001
-From: Matthias Koeppe <mkoeppe@math.ucdavis.edu>
-Date: Fri, 4 Mar 2022 15:14:43 -0800
-Subject: src/sage/calculus/calculus.py: Update laplace doctest for sympy 1.10
-
----
- src/sage/calculus/calculus.py | 6 +++---
- 1 file changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/src/sage/calculus/calculus.py b/src/sage/calculus/calculus.py
-index 9c2f226..b335093 100644
---- a/src/sage/calculus/calculus.py
-+++ b/src/sage/calculus/calculus.py
-@@ -1639,9 +1639,9 @@ def laplace(ex, t, s, algorithm='maxima'):
-         sage: laplace(dirac_delta(t), t, s)
-         1
-         sage: F, a, cond = laplace(dirac_delta(t), t, s, algorithm='sympy')
--        sage: a, cond
--        (-oo, True)
--        sage: F       # random - sympy <1.9 includes undefined heaviside(0) in answer
-+        sage: a, cond  # random - sympy <1.10 gives (-oo, True)
-+        (0, True)
-+        sage: F        # random - sympy <1.9 includes undefined heaviside(0) in answer
-         1
-         sage: laplace(dirac_delta(t), t, s, algorithm='giac')
-         1
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33446-make_GAP_SO_unnecessary-31e3fc4ec8b8687bccd22d2e3161c86cf5553e06.patch b/srcpkgs/sagemath/patches/trac-33446-make_GAP_SO_unnecessary-31e3fc4ec8b8687bccd22d2e3161c86cf5553e06.patch
new file mode 100644
index 000000000000..fb9e0f5a8071
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-33446-make_GAP_SO_unnecessary-31e3fc4ec8b8687bccd22d2e3161c86cf5553e06.patch
@@ -0,0 +1,427 @@
+From 9feec282d039ca25bbefa50710f8217b775ce111 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Thu, 3 Mar 2022 14:47:00 -0300
+Subject: gap: do not directly dlopen() the gap library
+
+This needs the soname (as in sage.env.GAP_SO) which has issues for
+system gap as explained in #33446.
+
+Instead we dlopen() the extension module sage.libs.gap.util which,
+having a link time dependency to libgap, will indirectly dlopen() it.
+
+For the record: by the time we run dlopen() the libgap should be already
+loaded. The purpose of doing it is to change mode to RTLD_GLOBAL so that
+symbols in libgap are placed in the global symbol table. This is
+required to compiled load gap packages.
+
+An easy test that this is working ok is:
+
+    sage: libgap.LoadPackage("io")
+    true
+
+This requires optional spkg `gap_packages` to be installed.
+---
+ src/sage/libs/gap/util.pyx | 12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/src/sage/libs/gap/util.pyx b/src/sage/libs/gap/util.pyx
+index 344ab88..aff604b 100644
+--- a/src/sage/libs/gap/util.pyx
++++ b/src/sage/libs/gap/util.pyx
+@@ -13,7 +13,7 @@ Utility functions for GAP
+ #*****************************************************************************
+ 
+ from libc.signal cimport signal, SIGCHLD, SIG_DFL
+-from posix.dlfcn cimport dlopen, dlclose, RTLD_NOW, RTLD_GLOBAL
++from posix.dlfcn cimport dlopen, dlclose, dlerror, RTLD_LAZY, RTLD_GLOBAL
+ 
+ from cpython.exc cimport PyErr_Fetch, PyErr_Restore
+ from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE
+@@ -232,12 +232,12 @@ cdef initialize():
+     # this isn't portable
+ 
+     cdef void* handle
+-    libgapname = str_to_bytes(sage.env.GAP_SO)
+-    handle = dlopen(libgapname, RTLD_NOW | RTLD_GLOBAL)
++    # reload the current module to force reload of libgap (see #33446)
++    lib = str_to_bytes(__loader__.path, FS_ENCODING, "surrogateescape")
++    handle = dlopen(lib, RTLD_GLOBAL|RTLD_LAZY)
+     if handle is NULL:
+-        raise RuntimeError(
+-                "Could not dlopen() libgap even though it should already "
+-                "be loaded!")
++        err = dlerror()
++        raise RuntimeError(f"Could not reload gap library with RTLD_GLOBAL ({err})")
+     dlclose(handle)
+ 
+     # Define argv variable, which we will pass in to
+-- 
+cgit v1.0-1-gd88e
+
+
+From 704a7953b97ab726e2af610724726aa562bc8bf8 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Thu, 3 Mar 2022 23:00:07 -0300
+Subject: singular: do not directly dlopen() the singular library
+
+Same as for gap in the previous commit. Instead of requiring the soname
+(as in sage.env.LIBSINGULAR_PATH) we dlopen() the extension module
+sage.libs.singular.singular which will indirectly dlopen() libSingular.
+---
+ src/sage/libs/singular/singular.pyx | 15 ++++-----------
+ 1 file changed, 4 insertions(+), 11 deletions(-)
+
+diff --git a/src/sage/libs/singular/singular.pyx b/src/sage/libs/singular/singular.pyx
+index d8ea7b0..4beb177 100644
+--- a/src/sage/libs/singular/singular.pyx
++++ b/src/sage/libs/singular/singular.pyx
+@@ -1705,14 +1705,7 @@ cdef object si2sa_intvec(intvec *v):
+ cdef extern from *: # hack to get at cython macro
+     int unlikely(int)
+ 
+-cdef extern from "dlfcn.h":
+-    void *dlopen(char *, long)
+-    char *dlerror()
+-    void dlclose(void *handle)
+-
+-cdef extern from "dlfcn.h":
+-    cdef long RTLD_LAZY
+-    cdef long RTLD_GLOBAL
++from posix.dlfcn cimport dlopen, dlclose, dlerror, RTLD_LAZY, RTLD_GLOBAL
+ 
+ cdef int overflow_check(unsigned long e, ring *_ring) except -1:
+     """
+@@ -1762,8 +1755,6 @@ cdef init_libsingular():
+ 
+     cdef void *handle = NULL
+ 
+-    from sage.env import LIBSINGULAR_PATH
+-    lib = str_to_bytes(LIBSINGULAR_PATH, FS_ENCODING, "surrogateescape")
+ 
+     # This is a workaround for https://github.com/Singular/Singular/issues/1113
+     # and can be removed once that fix makes it into release of Singular that
+@@ -1780,10 +1771,12 @@ cdef init_libsingular():
+ 
+     import platform
+     if not platform.system().startswith("CYGWIN"):
++        # reload the current module to force reload of libSingular (see #33446)
++        lib = str_to_bytes(__loader__.path, FS_ENCODING, "surrogateescape")
+         handle = dlopen(lib, RTLD_GLOBAL|RTLD_LAZY)
+         if not handle:
+             err = dlerror()
+-            raise ImportError(f"cannot load Singular library from {LIBSINGULAR_PATH} ({err})")
++            raise RuntimeError(f"Could not reload Singular library with RTLD_GLOBAL ({err})")
+ 
+     # load SINGULAR
+     siInit(lib)
+-- 
+cgit v1.0-1-gd88e
+
+
+From d7145c14ef58acfbe00d8f941d2802e96ad4ba15 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Fri, 4 Mar 2022 16:37:34 -0300
+Subject: singular: remove LIBSINGULAR_PATH, no longer needed
+
+---
+ build/pkgs/singular/spkg-configure.m4 | 63 +----------------------------------
+ pkgs/sage-conf/_sage_conf/_conf.py.in |  3 --
+ src/sage/env.py                       |  6 ----
+ 3 files changed, 1 insertion(+), 71 deletions(-)
+
+diff --git a/build/pkgs/singular/spkg-configure.m4 b/build/pkgs/singular/spkg-configure.m4
+index af2eb85..6d3d3da 100644
+--- a/build/pkgs/singular/spkg-configure.m4
++++ b/build/pkgs/singular/spkg-configure.m4
+@@ -9,52 +9,7 @@ SAGE_SPKG_CONFIGURE([singular], [
+        AC_MSG_CHECKING([that Singular's help is working])
+        AS_IF([test x`printf "system(\"--browser\", \"builtin\"); \n help;" | Singular 2>&1 | grep "error\ occurred"` = x], [
+         AC_MSG_RESULT(yes)
+-        dnl We have Singular. Now determine the shared library path on
+-        dnl platforms on which sage.libs.singular needs to reload the library with RTLD_GLOBAL.
+-        AS_CASE([$host_os],
+-          [cygwin*], [dnl Nothing to do
+-                     ],
+-                     [dnl Use pkg-config to get singular's libdir while we're at it. As a
+-                      dnl moral compromise for using pkg-config, this ultimately allows us
+-                      dnl to pass an absolute path to dlopen(), which is the only approach
+-                      dnl that POSIX guarantees will work.
+-                      PKG_CHECK_VAR([SINGULAR_LIB_DIR], [Singular], [libdir])
+-                      dnl The acl_shlibext variable is set in the top-level configure.ac.
+-                      AC_LANG_PUSH(C)
+-                      ORIG_LIBS="${LIBS}"
+-                      LIBS="${LIBS} -ldl"
+-                      AC_MSG_CHECKING([if we can dlopen($LIBSINGULAR_PATH)])
+-                      LIBSINGULAR_PATH="${SINGULAR_LIB_DIR}/libSingular.${acl_shlibext}"
+-
+-                      dnl if we can dlopen() it, substitute the name for sage_conf;
+-                      dnl otherwise, fall back to using the SPKG.
+-                      AC_RUN_IFELSE(
+-                        [AC_LANG_PROGRAM(
+-                          [[#include <dlfcn.h>]],
+-                          [[void* h = dlopen("${LIBSINGULAR_PATH}", RTLD_LAZY | RTLD_GLOBAL);
+-                            if (h == 0) { return 1; } else { return dlclose(h); }]]
+-                        )], [
+-                          AC_MSG_RESULT(yes)
+-                        ], [
+-                          dnl try Debian-specific name
+-                          LIBSINGULAR_PATH="${SINGULAR_LIB_DIR}/libsingular-Singular.${acl_shlibext}"
+-                          AC_RUN_IFELSE(
+-                           [AC_LANG_PROGRAM(
+-                             [[#include <dlfcn.h>]],
+-                             [[void* h = dlopen("${LIBSINGULAR_PATH}", RTLD_LAZY | RTLD_GLOBAL);
+-                               if (h == 0) { return 1; } else { return dlclose(h); }]]
+-                           )], [
+-                             AC_MSG_RESULT(yes)
+-                           ], [
+-                            AC_MSG_RESULT(no)
+-                            sage_spkg_install_singular=yes
+-                          ], [AC_MSG_RESULT(yes)])
+-                        ], [AC_MSG_RESULT(yes)])
+-
+-                      AC_LANG_POP()
+-                      LIBS="${ORIG_LIBS}"
+-                     ]
+-       )], [
++       ], [
+        AC_MSG_RESULT(no)
+        sage_spkg_install_singular=yes
+        ]
+@@ -64,20 +19,4 @@ SAGE_SPKG_CONFIGURE([singular], [
+       ])
+     ])
+   ])
+-],[],[],[
+-  dnl Post-check phase
+-  dnl We make the sage_conf substitutions here, because the "default"
+-  dnl substitution needs to be made even if we skipped the system-Singular
+-  dnl checks themselves.
+-  AS_IF([test "x${sage_spkg_install_singular}" = "xyes"], [
+-    AS_CASE([$host_os],
+-      [cygwin*], [dnl Nothing to do
+-                 ],
+-                 [dnl Set shared library path, needed for reloading the library with RTLD_GLOBAL
+-                  LIBSINGULAR_PATH="\$SAGE_LOCAL/lib/libSingular.${acl_shlibext}"
+-                 ]
+-    )
+-  ])
+-
+-  AC_SUBST(LIBSINGULAR_PATH, "${LIBSINGULAR_PATH}")
+ ])
+diff --git a/pkgs/sage-conf/_sage_conf/_conf.py.in b/pkgs/sage-conf/_sage_conf/_conf.py.in
+index 6cd28f5..d66bdb3 100644
+--- a/pkgs/sage-conf/_sage_conf/_conf.py.in
++++ b/pkgs/sage-conf/_sage_conf/_conf.py.in
+@@ -55,9 +55,6 @@ THREEJS_DIR = SAGE_LOCAL + "/share/threejs-sage"
+ OPENMP_CFLAGS = "@OPENMP_CFLAGS@"
+ OPENMP_CXXFLAGS = "@OPENMP_CXXFLAGS@"
+ 
+-# The full absolute path to the main Singular library.
+-LIBSINGULAR_PATH = "@LIBSINGULAR_PATH@".replace('$SAGE_LOCAL', SAGE_LOCAL)
+-
+ # Installation location of wheels. This is determined at configuration time
+ # and does not depend on the installation location of sage-conf.
+ SAGE_SPKG_WHEELS = "@SAGE_VENV@".replace('${SAGE_LOCAL}', SAGE_LOCAL) + "/var/lib/sage/wheels"
+diff --git a/src/sage/env.py b/src/sage/env.py
+index 911f34b..93f79de 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -229,12 +229,6 @@ NTL_LIBDIR = var("NTL_LIBDIR")
+ LIE_INFO_DIR = var("LIE_INFO_DIR", join(SAGE_LOCAL, "lib", "LiE"))
+ SINGULAR_BIN = var("SINGULAR_BIN") or "Singular"
+ 
+-# The path to libSingular, to be passed to dlopen(). This will
+-# typically be set to an absolute path in sage_conf, but the relative
+-# fallback path here works on systems where dlopen() searches the
+-# system's library locations.
+-LIBSINGULAR_PATH = var("LIBSINGULAR_PATH", "libSingular.so")
+-
+ # OpenMP
+ OPENMP_CFLAGS = var("OPENMP_CFLAGS", "")
+ OPENMP_CXXFLAGS = var("OPENMP_CXXFLAGS", "")
+-- 
+cgit v1.0-1-gd88e
+
+
+From 92e5a211c792f86f5325d601abfddf667da6a776 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Fri, 4 Mar 2022 15:49:26 -0300
+Subject: Revert "src/sage/interfaces/gap_workspace.py: Use hash of GAP_SO to
+ disambiguate the workspace file, not SAGE_LOCAL"
+
+This reverts commit a801e6d85bd420b60ea75b1671856eb43ac6b18b.
+
+See #33446.
+---
+ src/sage/interfaces/gap_workspace.py | 7 ++-----
+ 1 file changed, 2 insertions(+), 5 deletions(-)
+
+diff --git a/src/sage/interfaces/gap_workspace.py b/src/sage/interfaces/gap_workspace.py
+index 33a87dd..953dc85 100644
+--- a/src/sage/interfaces/gap_workspace.py
++++ b/src/sage/interfaces/gap_workspace.py
+@@ -16,7 +16,7 @@ Support for (lib)GAP workspace files
+ import os
+ import time
+ import hashlib
+-from sage.env import DOT_SAGE, GAP_SO
++from sage.env import DOT_SAGE, SAGE_LOCAL
+ 
+ 
+ def gap_workspace_file(system="gap", name="workspace", dir=None):
+@@ -59,10 +59,7 @@ def gap_workspace_file(system="gap", name="workspace", dir=None):
+     if dir is None:
+         dir = os.path.join(DOT_SAGE, 'gap')
+ 
+-    if GAP_SO:
+-        h = hashlib.sha1(GAP_SO.encode('utf-8')).hexdigest()
+-    else:
+-        h = 'unknown'
++    h = hashlib.sha1(SAGE_LOCAL.encode('utf-8')).hexdigest()
+     return os.path.join(dir, '%s-%s-%s' % (system, name, h))
+ 
+ 
+-- 
+cgit v1.0-1-gd88e
+
+
+From b45e555b5711ae10d369b568333940c2aa771053 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Fri, 4 Mar 2022 16:38:49 -0300
+Subject: gap: remove GAP_SO, no longer needed
+
+---
+ src/sage/env.py | 75 ---------------------------------------------------------
+ 1 file changed, 75 deletions(-)
+
+diff --git a/src/sage/env.py b/src/sage/env.py
+index 93f79de..c16a094 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -249,81 +249,6 @@ if SAGE_GAP_MEMORY is not None:
+ SAGE_GAP_COMMAND = var('SAGE_GAP_COMMAND', _gap_cmd)
+ 
+ 
+-def _get_shared_lib_path(*libnames: str) -> Optional[str]:
+-    """
+-    Return the full path to a shared library file installed in
+-    ``$SAGE_LOCAL/lib`` or the directories associated with the
+-    Python sysconfig.
+-
+-    This can also be passed more than one library name (e.g. for cases where
+-    some library may have multiple names depending on the platform) in which
+-    case the first one found is returned.
+-
+-    This supports most *NIX variants (in which ``lib<libname>.so`` is found
+-    under ``$SAGE_LOCAL/lib``), macOS (same, but with the ``.dylib``
+-    extension), and Cygwin (under ``$SAGE_LOCAL/bin/cyg<libname>.dll``,
+-    or ``$SAGE_LOCAL/bin/cyg<libname>-*.dll`` for versioned DLLs).
+-
+-    For distributions like Debian that use a multiarch layout, we also try the
+-    multiarch lib paths (i.e. ``/usr/lib/<arch>/``).
+-
+-    This returns ``None`` if no matching library file could be found.
+-
+-    EXAMPLES::
+-
+-        sage: from sage.env import _get_shared_lib_path
+-        sage: "gap" in _get_shared_lib_path("gap")
+-        True
+-        sage: _get_shared_lib_path("an_absurd_lib") is None
+-        True
+-
+-    """
+-
+-    for libname in libnames:
+-        search_directories: List[Path] = []
+-        patterns: List[str] = []
+-        if sys.platform == 'cygwin':
+-            # Later down we take the first matching DLL found, so search
+-            # SAGE_LOCAL first so that it takes precedence
+-            if SAGE_LOCAL:
+-                search_directories.append(Path(SAGE_LOCAL) / 'bin')
+-            search_directories.append(Path(sysconfig.get_config_var('BINDIR')))
+-            # Note: The following is not very robust, since if there are multible
+-            # versions for the same library this just selects one more or less
+-            # at arbitrary. However, practically speaking, on Cygwin, there
+-            # will only ever be one version
+-            patterns = [f'cyg{libname}.dll', f'cyg{libname}-*.dll']
+-        else:
+-            if sys.platform == 'darwin':
+-                ext = 'dylib'
+-            else:
+-                ext = 'so'
+-
+-            if SAGE_LOCAL:
+-                search_directories.append(Path(SAGE_LOCAL) / 'lib')
+-            libdir = sysconfig.get_config_var('LIBDIR')
+-            if libdir is not None:
+-                libdir = Path(libdir)
+-                search_directories.append(libdir)
+-
+-                multiarchlib = sysconfig.get_config_var('MULTIARCH')
+-                if multiarchlib is not None:
+-                    search_directories.append(libdir / multiarchlib),
+-
+-            patterns = [f'lib{libname}.{ext}']
+-
+-        for directory in search_directories:
+-            for pattern in patterns:
+-                path = next(directory.glob(pattern), None)
+-                if path is not None:
+-                    return str(path.resolve())
+-
+-    # Just return None if no files were found
+-    return None
+-
+-# locate libgap shared object
+-GAP_SO = var("GAP_SO", _get_shared_lib_path("gap", ""))
+-
+ # post process
+ if DOT_SAGE is not None and ' ' in DOT_SAGE:
+     if UNAME[:6] == 'CYGWIN':
+-- 
+cgit v1.0-1-gd88e
+
+
+From 31e3fc4ec8b8687bccd22d2e3161c86cf5553e06 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Sun, 6 Mar 2022 12:10:37 -0300
+Subject: gap_workspace_file: include hostname and gap version
+
+---
+ src/sage/interfaces/gap_workspace.py | 11 ++++++++---
+ 1 file changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/src/sage/interfaces/gap_workspace.py b/src/sage/interfaces/gap_workspace.py
+index 953dc85..8c03b6b 100644
+--- a/src/sage/interfaces/gap_workspace.py
++++ b/src/sage/interfaces/gap_workspace.py
+@@ -16,7 +16,8 @@ Support for (lib)GAP workspace files
+ import os
+ import time
+ import hashlib
+-from sage.env import DOT_SAGE, SAGE_LOCAL
++import subprocess
++from sage.env import DOT_SAGE, SAGE_LOCAL, HOSTNAME, GAP_ROOT_DIR
+ 
+ 
+ def gap_workspace_file(system="gap", name="workspace", dir=None):
+@@ -59,8 +60,12 @@ def gap_workspace_file(system="gap", name="workspace", dir=None):
+     if dir is None:
+         dir = os.path.join(DOT_SAGE, 'gap')
+ 
+-    h = hashlib.sha1(SAGE_LOCAL.encode('utf-8')).hexdigest()
+-    return os.path.join(dir, '%s-%s-%s' % (system, name, h))
++    data = SAGE_LOCAL
++    sysinfo = os.path.join(GAP_ROOT_DIR, "sysinfo.gap")
++    if os.path.exists(sysinfo):
++        data += subprocess.getoutput(f'. "{sysinfo}" && echo ":$GAP_VERSION:$GAParch"')
++    h = hashlib.sha1(data.encode('utf-8')).hexdigest()
++    return os.path.join(dir, '%s-%s-%s-%s' % (system, name, HOSTNAME, h))
+ 
+ 
+ def prepare_workspace_dir(dir=None):
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch b/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
deleted file mode 100644
index 8e7bb64f5b01..000000000000
--- a/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From a04a0a0b14f67f4804e7113c3db41bbcf8a58296 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
-Date: Mon, 28 Mar 2022 20:39:59 -0300
-Subject: Trac #33585: fix doctest when dochtml is missing...
-
-...but sphinx is available in PYTHONPATH.
----
- src/sage/misc/sagedoc.py | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/sage/misc/sagedoc.py b/src/sage/misc/sagedoc.py
-index 4b3853f..08c4225 100644
---- a/src/sage/misc/sagedoc.py
-+++ b/src/sage/misc/sagedoc.py
-@@ -1401,7 +1401,7 @@ class _sage_doc:
-             "...**File:**...**Type:**...**Definition:** identity_matrix..."
-             sage: identity_matrix.__doc__ in browse_sage_doc(identity_matrix, 'rst')
-             True
--            sage: browse_sage_doc(identity_matrix, 'html', False)             # optional - sphinx
-+            sage: browse_sage_doc(identity_matrix, 'html', False)             # optional - sphinx sagemath_doc_html
-             '...div...File:...Type:...Definition:...identity_matrix...'
- 
-         In the 'text' version, double colons have been replaced with
--- 
-cgit v1.0-1-gd88e
-
diff --git a/srcpkgs/sagemath/patches/trac-33842-python-3.11.patch b/srcpkgs/sagemath/patches/trac-33842-python-3.11.patch
new file mode 100644
index 000000000000..eafe76bfb794
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-33842-python-3.11.patch
@@ -0,0 +1,45 @@
+--- a/src/sage/cpython/cython_metaclass.h
++++ b/src/sage/cpython/cython_metaclass.h
+@@ -66,7 +66,7 @@
+         }
+ 
+         /* Now, set t.__class__ to metaclass */
+-        Py_TYPE(t) = metaclass;
++        Py_SET_TYPE(t, metaclass);
+         PyType_Modified(t);
+     }
+     else
+--- a/src/sage/symbolic/ginac/numeric.cpp
++++ b/src/sage/symbolic/ginac/numeric.cpp
+@@ -52,7 +52,6 @@
+ #define register
+ #define PY_SSIZE_T_CLEAN
+ #include <Python.h>
+-#include <longintrepr.h>
+ #include "flint/fmpz.h"
+ #include "flint/fmpz_factor.h"
+ 
+--- a/src/sage/libs/gmp/pylong.pyx
++++ b/src/sage/libs/gmp/pylong.pyx
+@@ -32,7 +32,7 @@
+ from .mpz cimport *
+ 
+ cdef extern from *:
+-    Py_ssize_t* Py_SIZE_PTR "&Py_SIZE"(object)
++    void Py_SET_SIZE(object, Py_ssize_t)
+     int hash_bits """
+         #ifdef _PyHASH_BITS
+         _PyHASH_BITS         /* Python 3 */
+@@ -57,10 +57,8 @@
+     mpz_export(L.ob_digit, NULL,
+             -1, sizeof(digit), 0, PyLong_nails, z)
+     if mpz_sgn(z) < 0:
+-        # Set correct size (use a pointer to hack around Cython's
+-        # non-support for lvalues).
+-        sizeptr = Py_SIZE_PTR(L)
+-        sizeptr[0] = -pylong_size
++        # Set correct size
++        Py_SET_SIZE(L, -pylong_size)
+     return L
+ 
+ 
diff --git a/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch b/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
new file mode 100644
index 000000000000..977a42400e59
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34118-update_sympy_to_1.11.1-5db5d4e56243c609f44afc1f21c112b026f9e1fe.patch
@@ -0,0 +1,42 @@
+commit 5db5d4e56243c609f44afc1f21c112b026f9e1fe
+Author: Oscar Benjamin <oscar.j.benjamin@gmail.com>
+Date:   Mon Jul 11 21:24:01 2022 +0100
+
+    Update doctests for SymPy 1.11
+    
+    Doctests related to SymPy's rsolve function are updated in:
+    
+    src/sage/calculus/test_sympy.py
+    src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+    
+    The form of the output from SymPy has changed since
+    
+    https://github.com/sympy/sympy/pull/23567
+
+diff --git a/src/sage/calculus/test_sympy.py b/src/sage/calculus/test_sympy.py
+index 7cf7f3f6bfd..927e6ee4fb6 100644
+--- a/src/sage/calculus/test_sympy.py
++++ b/src/sage/calculus/test_sympy.py
+@@ -193,7 +193,7 @@ This was fixed in Sympy, see :trac:`14437`::
+     sage: u = Function('u')
+     sage: n = Symbol('n', integer=True)
+     sage: f = u(n+2) - u(n+1) + u(n)/4
+-    sage: 2**n * rsolve(f,u(n))
+-    C1*n + C0
++    sage: expand(2**n * rsolve(f,u(n)))
++    2*C1*n + C0
+ 
+ """
+diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+index 1062f4f7e8c..f53f813d793 100644
+--- a/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
++++ b/src/sage/tests/books/computational-mathematics-with-sagemath/recequadiff_doctest.py
+@@ -382,7 +382,7 @@ Sage example in ./recequadiff.tex, line 1798::
+   sage: from sympy import rsolve_hyper
+   sage: from sympy.abc import n
+   sage: rsolve_hyper([-2,1],2**(n+2),n)
+-  2**n*C0 + 2**(n + 2)*(C0 + n/2)
++  2**n*C0 + 2**(n + 1)*n
+ 
+ """
+ 
diff --git a/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-a6c293d67cfcdf8fba7bc6aa7899e2086d42cc7e.patch b/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-a6c293d67cfcdf8fba7bc6aa7899e2086d42cc7e.patch
new file mode 100644
index 000000000000..b544a3eef7dd
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34391-upgrade_gap_4.12-a6c293d67cfcdf8fba7bc6aa7899e2086d42cc7e.patch
@@ -0,0 +1,526 @@
+From aeff992d53a65a705dca5cd5216bcb97c218dce7 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:14:03 +0200
+Subject: Adapt to API changes in OpenOutputStream and CloseOutput
+
+---
+ src/sage/libs/gap/element.pyx      | 5 +++--
+ src/sage/libs/gap/gap_includes.pxd | 6 ++++--
+ 2 files changed, 7 insertions(+), 4 deletions(-)
+
+diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
+index be43c4c..e268116 100644
+--- a/src/sage/libs/gap/element.pyx
++++ b/src/sage/libs/gap/element.pyx
+@@ -130,6 +130,7 @@ cdef char *capture_stdout(Obj func, Obj obj):
+     """
+     cdef Obj s, stream, output_text_string
+     cdef UInt res
++    cdef TypOutputFile output
+     # The only way to get a string representation of an object that is truly
+     # consistent with how it would be represented at the GAP REPL is to call
+     # ViewObj on it.  Unfortunately, ViewObj *prints* to the output stream,
+@@ -145,12 +146,12 @@ cdef char *capture_stdout(Obj func, Obj obj):
+         output_text_string = GAP_ValueGlobalVariable("OutputTextString")
+         stream = CALL_2ARGS(output_text_string, s, GAP_True)
+ 
+-        if not OpenOutputStream(stream):
++        if not OpenOutputStream(&output, stream):
+             raise GAPError("failed to open output capture stream for "
+                            "representing GAP object")
+ 
+         CALL_1ARGS(func, obj)
+-        CloseOutput()
++        CloseOutput(&output)
+         return CSTR_STRING(s)
+     finally:
+         GAP_Leave()
+diff --git a/src/sage/libs/gap/gap_includes.pxd b/src/sage/libs/gap/gap_includes.pxd
+index 5a9ab48..34035fe 100644
+--- a/src/sage/libs/gap/gap_includes.pxd
++++ b/src/sage/libs/gap/gap_includes.pxd
+@@ -76,8 +76,10 @@ cdef extern from "gap/intobj.h" nogil:
+ 
+ 
+ cdef extern from "gap/io.h" nogil:
+-    UInt OpenOutputStream(Obj stream)
+-    UInt CloseOutput()
++    ctypedef struct TypOutputFile:
++        pass
++    UInt OpenOutputStream(TypOutputFile* output, Obj stream)
++    UInt CloseOutput(TypOutputFile* output)
+ 
+ 
+ cdef extern from "gap/libgap-api.h" nogil:
+-- 
+cgit v1.0-1-gd88e
+
+
+From c3367b4290981e5e93b7a30c48b02f1ae3770dc8 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:14:53 +0200
+Subject: Disable colored prompt as it breaks the pexpect interface
+
+---
+ src/sage/interfaces/gap.py | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/src/sage/interfaces/gap.py b/src/sage/interfaces/gap.py
+index c34fe53..569caa2 100644
+--- a/src/sage/interfaces/gap.py
++++ b/src/sage/interfaces/gap.py
+@@ -1512,6 +1512,8 @@ def gap_reset_workspace(max_workspace_size=None, verbose=False):
+     """
+     # Create new workspace with filename WORKSPACE
+     g = Gap(use_workspace_cache=False, max_workspace_size=None)
++    g.eval('ColorPrompt(false)')
++    g.eval('SetUserPreference("UseColorPrompt", false)')
+     g.eval('SetUserPreference("HistoryMaxLines", 30)')
+     from sage.tests.gap_packages import all_installed_packages
+     for pkg in all_installed_packages(gap=g):
+-- 
+cgit v1.0-1-gd88e
+
+
+From 3b63e998e4d6118fc86b13b940c8f3d3b8307a50 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:16:03 +0200
+Subject: Port NaturalHomomorphism uses
+
+---
+ src/sage/groups/abelian_gps/abelian_group_gap.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/sage/groups/abelian_gps/abelian_group_gap.py b/src/sage/groups/abelian_gps/abelian_group_gap.py
+index a4b0471..86090b4 100644
+--- a/src/sage/groups/abelian_gps/abelian_group_gap.py
++++ b/src/sage/groups/abelian_gps/abelian_group_gap.py
+@@ -338,7 +338,7 @@ class AbelianGroup_gap(UniqueRepresentation, GroupMixinLibGAP, ParentLibGAP, Abe
+         if isinstance(x, AbelianGroupElement_gap):
+             try:
+                 if x in self._cover:
+-                    x = self.gap().NaturalHomomorphism().Image(x.gap())
++                    x = self._cover.gap().NaturalHomomorphismByNormalSubgroup(self._relations).Image(x.gap())
+                 else:
+                     x = x.gap()
+             except AttributeError:
+@@ -1043,7 +1043,7 @@ class AbelianGroupQuotient_gap(AbelianGroup_gap):
+             From: Abelian group with gap, generator orders (4,)
+             To:   Quotient abelian group with generator orders (2,)
+         """
+-        phi = self.gap().NaturalHomomorphism()
++        phi = self._cover.gap().NaturalHomomorphismByNormalSubgroup(self._relations)
+         Hom = self._cover.Hom(self)
+         return Hom(phi)
+ 
+-- 
+cgit v1.0-1-gd88e
+
+
+From bc40764be044653e06f2da3497e1e05da08251f7 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Mon, 29 Aug 2022 23:17:36 +0200
+Subject: Fix tests with GAP 4.12
+
+---
+ src/doc/en/thematic_tutorials/lie/weyl_groups.rst  | 12 ++++++------
+ src/sage/coding/codecan/autgroup_can_label.pyx     |  2 +-
+ src/sage/coding/linear_code.py                     | 22 +++++++++++-----------
+ .../root_system/hecke_algebra_representation.py    |  2 +-
+ src/sage/combinat/symmetric_group_algebra.py       |  2 +-
+ src/sage/groups/finitely_presented.py              |  6 +++---
+ src/sage/groups/fqf_orthogonal.py                  |  2 +-
+ src/sage/groups/libgap_wrapper.pyx                 |  6 +++---
+ .../perm_gps/partn_ref2/refinement_generic.pyx     |  2 +-
+ src/sage/groups/perm_gps/permgroup.py              |  8 ++++----
+ src/sage/libs/gap/libgap.pyx                       |  2 +-
+ src/sage/libs/gap/util.pyx                         |  8 +-------
+ src/sage/tests/gap_packages.py                     |  2 +-
+ 13 files changed, 35 insertions(+), 41 deletions(-)
+
+diff --git a/src/doc/en/thematic_tutorials/lie/weyl_groups.rst b/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
+index c917338..182e74a 100644
+--- a/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
++++ b/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
+@@ -139,12 +139,12 @@ string, which you can print::
+     X.1      1  1  1  1  1  1  1  1  1  1  1  1  1
+     X.2      1 -1  1  1 -1  1  1 -1 -1 -1  1  1  1
+     X.3      2  .  2 -1  .  2  2  .  .  . -1  2  2
+-    X.4      3 -1 -1  .  1 -1  3 -1  1 -1  . -1  3
+-    X.5      3 -1 -1  .  1  3 -1 -1 -1  1  . -1  3
+-    X.6      3  1 -1  . -1 -1  3  1 -1  1  . -1  3
+-    X.7      3  1 -1  . -1  3 -1  1  1 -1  . -1  3
+-    X.8      3 -1  3  . -1 -1 -1 -1  1  1  . -1  3
+-    X.9      3  1  3  .  1 -1 -1  1 -1 -1  . -1  3
++    X.4      3 -1 -1  .  1  3 -1 -1 -1  1  . -1  3
++    X.5      3  1 -1  . -1  3 -1  1  1 -1  . -1  3
++    X.6      3 -1  3  . -1 -1 -1 -1  1  1  . -1  3
++    X.7      3 -1 -1  .  1 -1  3 -1  1 -1  . -1  3
++    X.8      3  1  3  .  1 -1 -1  1 -1 -1  . -1  3
++    X.9      3  1 -1  . -1 -1  3  1 -1  1  . -1  3
+     X.10     4 -2  . -1  .  .  .  2  .  .  1  . -4
+     X.11     4  2  . -1  .  .  . -2  .  .  1  . -4
+     X.12     6  . -2  .  . -2 -2  .  .  .  .  2  6
+diff --git a/src/sage/coding/codecan/autgroup_can_label.pyx b/src/sage/coding/codecan/autgroup_can_label.pyx
+index de5db98..c83b926 100644
+--- a/src/sage/coding/codecan/autgroup_can_label.pyx
++++ b/src/sage/coding/codecan/autgroup_can_label.pyx
+@@ -76,7 +76,7 @@ columns do share the same coloring::
+     ((1,),
+      (2,),
+      (3, 5, 4),
+-     (6, 19, 16, 9, 21, 10, 8, 15, 14, 11, 20, 13, 12, 7, 17, 18))
++     (6, 19, 16, 21, 9, 10, 15, 8, 20, 11, 14, 13, 7, 12, 18, 17))
+ 
+ We can also restrict the group action to linear isometries::
+ 
+diff --git a/src/sage/coding/linear_code.py b/src/sage/coding/linear_code.py
+index e8e32f8..9d45160 100644
+--- a/src/sage/coding/linear_code.py
++++ b/src/sage/coding/linear_code.py
+@@ -466,27 +466,27 @@ class AbstractLinearCode(AbstractLinearCodeNoMetric):
+             0
+             sage: C = codes.HammingCode(GF(4, 'z'), 3)
+             sage: C.automorphism_group_gens()
+-            ([((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
++            ([((1, 1, 1, z, z + 1, 1, 1, 1, 1, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z); (1,13,14,20)(2,21,8,18,7,16,19,15)(3,10,5,12,17,9,6,4), Ring endomorphism of Finite Field in z of size 2^2
++                Defn: z |--> z + 1),
++              ((z, 1, z, z, z, z + 1, z, z, z, z, z, z, z + 1, z, z, z, z, z + 1, z, z, z); (1,11,5,12,3,19)(2,8)(6,18,13)(7,17,15)(9,10,14,16,20,21), 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 + 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
++            ([((z, 1, z + 1, z + 1, 1, z + 1, z, 1, z + 1, z + 1, 1, z, 1, z + 1, z, 1, z, 1, z + 1, 1, 1); (1,12,11,10,6,8,9,20,13,21,5,14,3,16,17,19,7,4,2,15,18), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+-              ((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
++              ((z + 1, z + 1, z + 1, z, 1, 1, z, z, 1, z + 1, z, 1, 1, z, 1, z + 1, z, z + 1, z + 1, 1, z); (1,3,18,2,17,6,19)(4,15,13,20,7,14,16)(5,11,8,21,12,9,10), 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)],
+              181440)
+             sage: C.automorphism_group_gens(equivalence="permutational")
+-            ([((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,19)(3,17)(4,21)(5,20)(7,14)(9,12)(10,16)(11,15), Ring endomorphism of Finite Field in z of size 2^2
++            ([((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,11)(3,10)(4,9)(5,7)(12,21)(14,20)(15,19)(16,17), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+-              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,11)(3,10)(4,9)(5,7)(12,21)(14,20)(15,19)(16,17), Ring endomorphism of Finite Field in z of size 2^2
++              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (2,18)(3,19)(4,10)(5,16)(8,13)(9,14)(11,21)(15,20), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+-              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,17)(2,8)(3,14)(4,10)(7,12)(9,19)(13,18)(15,20), Ring endomorphism of Finite Field in z of size 2^2
++              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,19)(3,17)(4,21)(5,20)(7,14)(9,12)(10,16)(11,15), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z),
+               ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (2,13)(3,14)(4,20)(5,11)(8,18)(9,19)(10,15)(16,21), Ring endomorphism of Finite Field in z of size 2^2
+                 Defn: z |--> z)],
+@@ -692,10 +692,10 @@ class AbstractLinearCode(AbstractLinearCodeNoMetric):
+             sage: C_iso == aut_group_can_label.get_canonical_form()
+             True
+             sage: aut_group_can_label.get_autom_gens()
+-            [((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
++            [((1, 1, 1, z, z + 1, 1, 1, 1, 1, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z); (1,13,14,20)(2,21,8,18,7,16,19,15)(3,10,5,12,17,9,6,4), Ring endomorphism of Finite Field in z of size 2^2
++               Defn: z |--> z + 1),
++             ((z, 1, z, z, z, z + 1, z, z, z, z, z, z, z + 1, z, z, z, z, z + 1, z, z, z); (1,11,5,12,3,19)(2,8)(6,18,13)(7,17,15)(9,10,14,16,20,21), 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/root_system/hecke_algebra_representation.py b/src/sage/combinat/root_system/hecke_algebra_representation.py
+index bde2823..bffcc85 100644
+--- a/src/sage/combinat/root_system/hecke_algebra_representation.py
++++ b/src/sage/combinat/root_system/hecke_algebra_representation.py
+@@ -355,7 +355,7 @@ class HeckeAlgebraRepresentation(WithEqualityById, SageObject):
+             sage: q1, q2 = K.gens()
+             sage: KW = W.algebra(K)
+             sage: x = KW.an_element(); x
+-            123 + 3*32 + 2*3 + e
++            123 + 3*2312 + 2*31 + e
+ 
+             sage: T = KW.demazure_lusztig_operators(q1,q2)
+             sage: T12 = T.Tw( (1,2) )
+diff --git a/src/sage/combinat/symmetric_group_algebra.py b/src/sage/combinat/symmetric_group_algebra.py
+index c3d6755..da953d2 100644
+--- a/src/sage/combinat/symmetric_group_algebra.py
++++ b/src/sage/combinat/symmetric_group_algebra.py
+@@ -101,7 +101,7 @@ def SymmetricGroupAlgebra(R, W, category=None):
+         sage: SGA.group()
+         Weyl Group of type ['A', 3] (as a matrix group acting on the ambient space)
+         sage: SGA.an_element()
+-        s1*s2*s3 + 3*s3*s2 + 2*s3 + 1
++        s1*s2*s3 + 3*s2*s3*s1*s2 + 2*s3*s1 + 1
+ 
+     The preferred way to construct the symmetric group algebra is to
+     go through the usual ``algebra`` method::
+diff --git a/src/sage/groups/finitely_presented.py b/src/sage/groups/finitely_presented.py
+index 2a61bbf..d26891a 100644
+--- a/src/sage/groups/finitely_presented.py
++++ b/src/sage/groups/finitely_presented.py
+@@ -596,9 +596,9 @@ class RewritingSystem():
+             sage: k = G.rewriting_system()
+             sage: k.gap()
+             Knuth Bendix Rewriting System for Monoid( [ a, A, b, B ] ) with rules
+-            [ [ a^2, <identity ...> ], [ a*A, <identity ...> ],
+-              [ A*a, <identity ...> ], [ b^2, <identity ...> ],
+-              [ b*B, <identity ...> ], [ B*b, <identity ...> ] ]
++            [ [ a*A, <identity ...> ], [ A*a, <identity ...> ],
++              [ b*B, <identity ...> ], [ B*b, <identity ...> ],
++              [ a^2, <identity ...> ], [ b^2, <identity ...> ] ]
+         """
+         return self._gap
+ 
+diff --git a/src/sage/groups/fqf_orthogonal.py b/src/sage/groups/fqf_orthogonal.py
+index 75de408..dd7d84d 100644
+--- a/src/sage/groups/fqf_orthogonal.py
++++ b/src/sage/groups/fqf_orthogonal.py
+@@ -143,7 +143,7 @@ class FqfOrthogonalGroup(AbelianGroupAutomorphismGroup_subgroup):
+         [2/3   0   0]
+         [  0 2/3   0]
+         [  0   0 4/3]
+-        generated by 2 elements
++        generated by 3 elements
+         sage: q = matrix.diagonal(QQ, [3/2, 1/4, 1/4])
+         sage: T = TorsionQuadraticForm(q)
+         sage: T.orthogonal_group().order()
+diff --git a/src/sage/groups/libgap_wrapper.pyx b/src/sage/groups/libgap_wrapper.pyx
+index a76afc2..9340c0d 100644
+--- a/src/sage/groups/libgap_wrapper.pyx
++++ b/src/sage/groups/libgap_wrapper.pyx
+@@ -25,7 +25,7 @@ Note how we call the constructor of both superclasses to initialize
+ its output via LibGAP::
+ 
+     sage: FooGroup()
+-    <pc group of size 3 with 1 generators>
++    <pc group of size 3 with 1 generator>
+     sage: type(FooGroup().gap())
+     <class 'sage.libs.gap.element.GapElement'>
+ 
+@@ -106,7 +106,7 @@ class ParentLibGAP(SageObject):
+         ....:         ParentLibGAP.__init__(self, lg)
+         ....:         Group.__init__(self)
+         sage: FooGroup()
+-        <pc group of size 3 with 1 generators>
++        <pc group of size 3 with 1 generator>
+     """
+ 
+     def __init__(self, libgap_parent, ambient=None):
+@@ -461,7 +461,7 @@ cdef class ElementLibGAP(MultiplicativeGroupElement):
+         ....:         ParentLibGAP.__init__(self, lg)
+         ....:         Group.__init__(self)
+         sage: FooGroup()
+-        <pc group of size 3 with 1 generators>
++        <pc group of size 3 with 1 generator>
+         sage: FooGroup().gens()
+         (f1,)
+     """
+diff --git a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
+index 2fcb036..ca73c6b 100644
+--- a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
++++ b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
+@@ -427,7 +427,7 @@ cdef class LabelledBranching:
+             sage: from sage.groups.perm_gps.partn_ref2.refinement_generic import LabelledBranching
+             sage: L = LabelledBranching(3)
+             sage: L.small_generating_set()
+-            []
++            [()]
+             sage: L.add_gen(libgap.eval('(1,2,3)'))
+             sage: L.small_generating_set()
+             [(1,2,3)]
+diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
+index 4908934..34ba0cc 100644
+--- a/src/sage/groups/perm_gps/permgroup.py
++++ b/src/sage/groups/perm_gps/permgroup.py
+@@ -913,7 +913,7 @@ class PermutationGroup_generic(FiniteGroup):
+            sage: f = PG._coerce_map_from_(MG)
+            sage: mg = MG.an_element()
+            sage: p = f(mg); p
+-           (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)
++           (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(p._gap_()) == p
+            True
+ 
+@@ -959,12 +959,12 @@ class PermutationGroup_generic(FiniteGroup):
+             sage: P = G.as_permutation_group(algorithm='smaller', seed=5)
+             sage: P1 = G.as_permutation_group()
+             sage: P == P1
+-            False
++            True
+             sage: g1, g2, g3 = G.gens()
+             sage: P(g1*g2)
+-            (1,3,7,12)(2,4,8,10)(5,11)(6,9)
++            (1,4,13,11)(2,5,14,18)(3,15,8,16)(6,7)(9,20,19,12)(10,17)
+             sage: P1(g1*g2)
+-            (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)
++            (1,4,13,11)(2,5,14,18)(3,15,8,16)(6,7)(9,20,19,12)(10,17)
+ 
+         Another check for :trac:`5583`::
+ 
+diff --git a/src/sage/libs/gap/libgap.pyx b/src/sage/libs/gap/libgap.pyx
+index b1a64e5..6a36613 100644
+--- a/src/sage/libs/gap/libgap.pyx
++++ b/src/sage/libs/gap/libgap.pyx
+@@ -695,7 +695,7 @@ class Gap(Parent):
+             sage: libgap.List
+             <Gap function "List">
+             sage: libgap.GlobalRandomSource
+-            <RandomSource in IsGlobalRandomSource>
++            <RandomSource in IsGAPRandomSource>
+         """
+         if name in dir(self.__class__):
+             return getattr(self.__class__, name)
+diff --git a/src/sage/libs/gap/util.pyx b/src/sage/libs/gap/util.pyx
+index 344ab88..6350987 100644
+--- a/src/sage/libs/gap/util.pyx
++++ b/src/sage/libs/gap/util.pyx
+@@ -362,15 +362,9 @@ cdef Obj gap_eval(str gap_string) except? NULL:
+         GAPError: Error, Variable: 'Complex' must have a value
+         Syntax error: ; expected in stream:1
+         Complex Field with 53 bits of precision;;
+-         ^^^^^^^^^^^^
++                ^^^^^
+         Error, Variable: 'with' must have a value
+-        Syntax error: ; expected in stream:1
+-        Complex Field with 53 bits of precision;;
+-         ^^^^^^^^^^^^^^^^^^^^
+         Error, Variable: 'bits' must have a value
+-        Syntax error: ; expected in stream:1
+-        Complex Field with 53 bits of precision;;
+-         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+         Error, Variable: 'precision' must have a value
+ 
+     Test that on a subsequent attempt we get the same message (no garbage was
+diff --git a/src/sage/tests/gap_packages.py b/src/sage/tests/gap_packages.py
+index 2e4518c..c302b16 100644
+--- a/src/sage/tests/gap_packages.py
++++ b/src/sage/tests/gap_packages.py
+@@ -103,7 +103,7 @@ def all_installed_packages(ignore_dot_gap=False, gap=None):
+ 
+         sage: from sage.tests.gap_packages import all_installed_packages
+         sage: all_installed_packages()
+-        (...'GAPDoc'...)
++        (...'gapdoc'...)
+         sage: all_installed_packages(ignore_dot_gap=True) == all_installed_packages(gap=gap, ignore_dot_gap=True)
+         True
+     """
+-- 
+cgit v1.0-1-gd88e
+
+
+From cbc902a79ff9ec01d4d4eb9a767a1c661fb5dda7 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Fri, 30 Sep 2022 19:17:42 +0200
+Subject: Adapt test to new is_transitive and is_primitive behavior
+
+---
+ src/sage/groups/perm_gps/permgroup.py | 22 ++++++++++++++++------
+ 1 file changed, 16 insertions(+), 6 deletions(-)
+
+diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
+index 34ba0cc..5832b98 100644
+--- a/src/sage/groups/perm_gps/permgroup.py
++++ b/src/sage/groups/perm_gps/permgroup.py
+@@ -4359,17 +4359,23 @@ class PermutationGroup_generic(FiniteGroup):
+ 
+         ::
+ 
+-            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)]]) #S_5 on [1..5]
+-            sage: G.is_transitive([1,4,5])
++            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)],[(6,7)]])
++            sage: G.is_transitive([1,2,3,4,5])
+             True
+-            sage: G.is_transitive([2..6])
++            sage: G.is_transitive([1..7])
+             False
+             sage: G.is_transitive(G.non_fixed_points())
+-            True
++            False
+             sage: H = PermutationGroup([[(1,2,3)],[(4,5,6)]])
+             sage: H.is_transitive(H.non_fixed_points())
+             False
+ 
++        If `G` does not act on the domain, it always returns ``False``::
++
++            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)]]) #S_5 on [1..5]
++            sage: G.is_transitive([1,4,5])
++            False
++
+         Note that this differs from the definition in GAP, where
+         ``IsTransitive`` returns whether the group is transitive on the
+         set of points moved by the group.
+@@ -4425,12 +4431,16 @@ class PermutationGroup_generic(FiniteGroup):
+             sage: G = PermutationGroup([[(1,2,3,4)],[(2,4)]])
+             sage: G.is_primitive([1..4])
+             False
+-            sage: G.is_primitive([1,2,3])
+-            True
+             sage: G = PermutationGroup([[(3,4,5,6)],[(3,4)]]) #S_4 on [3..6]
+             sage: G.is_primitive(G.non_fixed_points())
+             True
+ 
++        If `G` does not act on the domain, it always returns ``False``::
++
++            sage: G = PermutationGroup([[(1,2,3,4)],[(2,4)]])
++            sage: G.is_primitive([1,2,3])
++            False
++
+         """
+         #If the domain is not a subset of self.domain(), then the
+         #action isn't primitive.
+-- 
+cgit v1.0-1-gd88e
+
+
+From 80dd6b338236f170efca1fc3545df18ce8d8795c Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Fri, 30 Sep 2022 19:18:06 +0200
+Subject: Mark test as random. With gap 4.12 on x86_64 it is no longer 2
+
+---
+ src/sage/groups/perm_gps/permgroup.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
+index 5832b98..c1230a3 100644
+--- a/src/sage/groups/perm_gps/permgroup.py
++++ b/src/sage/groups/perm_gps/permgroup.py
+@@ -1287,7 +1287,7 @@ class PermutationGroup_generic(FiniteGroup):
+             sage: G.gens_small() # random
+             [('b','c'), ('a','c','b')] ## (on 64-bit Linux)
+             [('a','b'), ('a','c','b')] ## (on Solaris)
+-            sage: len(G.gens_small()) == 2
++            sage: len(G.gens_small()) == 2 # random
+             True
+         """
+         gens = self._libgap_().SmallGeneratingSet()
+-- 
+cgit v1.0-1-gd88e
+
+
+From a6c293d67cfcdf8fba7bc6aa7899e2086d42cc7e Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Fri, 30 Sep 2022 19:18:30 +0200
+Subject: Remove test that is now redundant, all seeds give the same answer
+
+---
+ src/sage/groups/matrix_gps/finitely_generated.py | 3 ---
+ 1 file changed, 3 deletions(-)
+
+diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
+index a6d3dc0..63956ad 100644
+--- a/src/sage/groups/matrix_gps/finitely_generated.py
++++ b/src/sage/groups/matrix_gps/finitely_generated.py
+@@ -563,9 +563,6 @@ class FinitelyGeneratedMatrixGroup_gap(MatrixGroup_gap):
+             21499084800
+             sage: P = G.as_permutation_group()
+             sage: Psmaller = G.as_permutation_group(algorithm="smaller", seed=6)
+-            sage: P == Psmaller  # see the note below
+-            True
+-            sage: Psmaller = G.as_permutation_group(algorithm="smaller")
+             sage: P == Psmaller
+             False
+             sage: P.cardinality()
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch b/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
new file mode 100644
index 000000000000..8fedcb78cf71
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34465-fix_invalid_escape_sequence-04971318f032caf8dc1c0de9489346d894409091.patch
@@ -0,0 +1,19 @@
+commit 04971318f032caf8dc1c0de9489346d894409091
+Author: John H. Palmieri <jhpalmieri64@gmail.com>
+Date:   Wed Aug 31 14:22:26 2022 -0700
+
+    trac 34465: fix invalid escape sequence in functions/special.py
+
+diff --git a/src/sage/functions/special.py b/src/sage/functions/special.py
+index 02596e49620..901f02f9bee 100644
+--- a/src/sage/functions/special.py
++++ b/src/sage/functions/special.py
+@@ -849,7 +849,7 @@ class EllipticF(BuiltinFunction):
+     - :wikipedia:`Elliptic_integral#Incomplete_elliptic_integral_of_the_first_kind`
+     """
+     def __init__(self):
+-        """
++        r"""
+         EXAMPLES::
+ 
+             sage: loads(dumps(elliptic_f))
diff --git a/srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15.patch b/srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15.patch
new file mode 100644
index 000000000000..ccafad5070c4
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15.patch
@@ -0,0 +1,1750 @@
+diff --git a/build/pkgs/giac/patches/pari_2_15.patch b/build/pkgs/giac/patches/pari_2_15.patch
+new file mode 100644
+index 0000000000..d2900a5ffc
+--- /dev/null
++++ b/build/pkgs/giac/patches/pari_2_15.patch
+@@ -0,0 +1,21 @@
++ANYARG patch
++
++diff --git a/src/pari.cc b/src/pari.cc
++index 76ce8e1..50d08ab 100644
++--- a/src/pari.cc
+++++ b/src/pari.cc
++@@ -40,6 +40,13 @@ using namespace std;
++ 
++ #ifdef HAVE_LIBPARI
++ 
+++// Anyarg disappeared from PARI 2.15.0
+++#ifdef __cplusplus
+++#  define ANYARG ...
+++#else
+++#  define ANYARG
+++#endif
+++
++ #ifdef HAVE_PTHREAD_H
++ #include <pthread.h>
++ #endif
++
+diff --git a/build/pkgs/pari/checksums.ini b/build/pkgs/pari/checksums.ini
+index b736feed31..bafd0f36f4 100644
+--- a/build/pkgs/pari/checksums.ini
++++ b/build/pkgs/pari/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=pari-VERSION.tar.gz
+-sha1=e01647aab7e96a8cb4922cf26a4f224337c6647f
+-md5=922f740fcdf8630b30d63dc76b58f756
+-cksum=297133525
++sha1=cba9b279f67d5efe2fbbccf3be6e9725f816cf07
++md5=76d430f1bea1b07fa2ad9712deeaa736
++cksum=1990743897
+ upstream_url=https://pari.math.u-bordeaux.fr/pub/pari/unix/pari-VERSION.tar.gz
+diff --git a/build/pkgs/pari/package-version.txt b/build/pkgs/pari/package-version.txt
+index a1a4224dd5..68e69e405e 100644
+--- a/build/pkgs/pari/package-version.txt
++++ b/build/pkgs/pari/package-version.txt
+@@ -1 +1 @@
+-2.13.3
++2.15.0
+diff --git a/src/doc/de/tutorial/tour_numtheory.rst b/src/doc/de/tutorial/tour_numtheory.rst
+index a012234c99..e3149fe949 100644
+--- a/src/doc/de/tutorial/tour_numtheory.rst
++++ b/src/doc/de/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ implementiert.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/en/tutorial/tour_numtheory.rst b/src/doc/en/tutorial/tour_numtheory.rst
+index 3064d100e2..075e0ac0ad 100644
+--- a/src/doc/en/tutorial/tour_numtheory.rst
++++ b/src/doc/en/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ NumberField class.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/es/tutorial/tour_numtheory.rst b/src/doc/es/tutorial/tour_numtheory.rst
+index a1f7d1a87b..48e5376cfe 100644
+--- a/src/doc/es/tutorial/tour_numtheory.rst
++++ b/src/doc/es/tutorial/tour_numtheory.rst
+@@ -140,7 +140,7 @@ Varios métodos relacionados están implementados en la clase ``NumberField``::
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/fr/tutorial/tour_numtheory.rst b/src/doc/fr/tutorial/tour_numtheory.rst
+index 871092f5fa..d1b2fee883 100644
+--- a/src/doc/fr/tutorial/tour_numtheory.rst
++++ b/src/doc/fr/tutorial/tour_numtheory.rst
+@@ -159,7 +159,7 @@ dans la classe NumberField.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/ja/tutorial/tour_numtheory.rst b/src/doc/ja/tutorial/tour_numtheory.rst
+index 47af68c862..4d4ed52d50 100644
+--- a/src/doc/ja/tutorial/tour_numtheory.rst
++++ b/src/doc/ja/tutorial/tour_numtheory.rst
+@@ -161,7 +161,7 @@ Sageには :math:`p` \-進数体も組込まれている.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/pt/tutorial/tour_numtheory.rst b/src/doc/pt/tutorial/tour_numtheory.rst
+index 6371b491ea..a3dc973a93 100644
+--- a/src/doc/pt/tutorial/tour_numtheory.rst
++++ b/src/doc/pt/tutorial/tour_numtheory.rst
+@@ -157,7 +157,7 @@ NumberField.
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus 
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/doc/ru/tutorial/tour_numtheory.rst b/src/doc/ru/tutorial/tour_numtheory.rst
+index 652abfbc99..a985d49fbd 100644
+--- a/src/doc/ru/tutorial/tour_numtheory.rst
++++ b/src/doc/ru/tutorial/tour_numtheory.rst
+@@ -150,7 +150,7 @@ Sage содержит стандартные функции теории чис
+     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
+     x^3 + x^2 - 2*x + 8
+     sage: K.units()
+-    (3*a^2 + 13*a + 13,)
++    (-3*a^2 - 13*a - 13,)
+     sage: K.discriminant()
+     -503
+     sage: K.class_group()
+diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py
+index e57076646f..fec75d07c1 100644
+--- a/src/sage/arith/misc.py
++++ b/src/sage/arith/misc.py
+@@ -1465,13 +1465,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)]
++        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::
+ 
+@@ -2569,7 +2569,7 @@ def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds):
+ 
+         sage: K.<i> = QuadraticField(-1)
+         sage: factor(122 - 454*i)
+-        (-3*i - 2) * (-i - 2)^3 * (i + 1)^3 * (i + 4)
++        (-i) * (-i - 2)^3 * (i + 1)^3 * (-2*i + 3) * (i + 4)
+ 
+     To access the data in a factorization::
+ 
+diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
+index cdfc11a9e5..b6e1280d6e 100644
+--- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
++++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
+@@ -7825,9 +7825,9 @@ class DynamicalSystem_projective_field(DynamicalSystem_projective,
+             sage: f = DynamicalSystem_projective([x^2 + QQbar(sqrt(3))*y^2, y^2, QQbar(sqrt(2))*z^2])
+             sage: f.reduce_base_field()
+             Dynamical System of Projective Space of dimension 2 over Number Field in a with
+-            defining polynomial y^4 - 4*y^2 + 1 with a = 1.931851652578137?
++            defining polynomial y^4 - 4*y^2 + 1 with a = -0.5176380902050415?
+               Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x^2 + (a^2 - 2)*y^2 : y^2 : (a^3 - 3*a)*z^2)
++                    (x^2 + (-a^2 + 2)*y^2 : y^2 : (a^3 - 3*a)*z^2)
+ 
+         ::
+ 
+diff --git a/src/sage/ext_data/pari/simon/ellQ.gp b/src/sage/ext_data/pari/simon/ellQ.gp
+index 420af8f6a2..65e8386779 100644
+--- a/src/sage/ext_data/pari/simon/ellQ.gp
++++ b/src/sage/ext_data/pari/simon/ellQ.gp
+@@ -40,7 +40,7 @@
+   gp > \r ellcommon.gp
+   gp > \r ellQ.gp
+ 
+-  The main function is ellrank(), which takes as an argument
++  The main function is ellQ_ellrank(), which takes as an argument
+   any elliptic curve in the form [a1,a2,a3,a4,a6]
+   the result is a vector [r,s,v], where
+     r is a lower bound for the rank,
+@@ -50,7 +50,7 @@
+   Example:
+ 
+   gp > ell = [1,2,3,4,5];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+   %1 = [1, 1, [[1,2]]
+   In this example, the rank is exactly 1, and [1,2] has infinite order.
+ 
+@@ -92,7 +92,7 @@
+   \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+ 
+   Explications succintes :
+-  La fonction ellrank() accepte toutes les courbes sous la forme
++  La fonction ellQ_ellrank() accepte toutes les courbes sous la forme
+   [a1,a2,a3,a4,a6]
+   Les coefficients peuvent etre entiers ou non.
+   L'algorithme utilise est celui de la 2-descente.
+@@ -100,7 +100,7 @@
+   Il suffit de taper : 
+ 
+   gp > ell = [a1,a2,a3,a4,a6];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+ 
+   Retourne un vecteur [r,s,v] ou
+     r est le rang probable (c'est toujours une minoration du rang),
+@@ -110,7 +110,7 @@
+   Exemple :
+ 
+   gp > ell = [1,2,3,4,5];
+-  gp > ellrank(ell)
++  gp > ellQ_ellrank(ell)
+   %1 = [1, 1, [[1,2]]
+   Ici, le rang est exactement 1, et le point [1,2] est d'ordre infini.
+ 
+@@ -1571,12 +1571,12 @@ if( DEBUGLEVEL_ell >= 4, print("    end of ell2descent_gen"));
+     print("rank(E/Q)    >= ",m1)
+   );
+ }
+-{ellrank(ell,help=[]) =
++{ellQ_ellrank(ell,help=[]) =
+ \\ Algorithm of 2-descent on the elliptic curve ell.
+ \\ help is a list of known points on ell.
+ my(urst,urst1,den,eqell,tors2,bnf,rang,time1);
+ 
+-if( DEBUGLEVEL_ell >= 3, print("   starting ellrank"));
++if( DEBUGLEVEL_ell >= 3, print("   starting ellQ_ellrank"));
+   if( #ell < 13, ell = ellinit(ell));
+ 
+ \\ kill the coefficients a1 and a3
+@@ -1630,7 +1630,7 @@ if( DEBUGLEVEL_ell >= 1, print(" Elliptic curve: Y^2 = ",eqell));
+   ));
+ 
+   rang[3] = ellchangepoint(rang[3],ellinverturst(urst));
+-if( DEBUGLEVEL_ell >= 3, print("   end of ellrank"));
++if( DEBUGLEVEL_ell >= 3, print("   end of ellQ_ellrank"));
+ 
+   return(rang);
+ }
+@@ -2106,13 +2106,13 @@ if( DEBUGLEVEL_ell >= 3, print("   end of ell2descent_viaisog"));
+ {
+ \\                  functions for elliptic curves
+   addhelp(ell2descent_complete,
+-    "ell2descent_complete(e1,e2,e3): Performs a complete 2-descent on the elliptic curve y^2 = (x-e1)*(x-e2)*(x-e3). See ?ellrank for the format of the output.");
++    "ell2descent_complete(e1,e2,e3): Performs a complete 2-descent on the elliptic curve y^2 = (x-e1)*(x-e2)*(x-e3). See ?ellQ_ellrank for the format of the output.");
+   addhelp(ell2descent_gen,
+-    "ell2descent_gen((E,bnf,k=1,help=[]): E is a vector of the form [0,A,0,B,C], (or the result of ellinit of such a vector) A,B,C integers such that x^3+A*x^2+B*x+C; bnf is the corresponding bnfinit(,1); Performs 2-descent on the elliptic curve Ek: k*y^2=x^3+A*x^2+B*x+C. See ?ellrank for the format of the output.");
++    "ell2descent_gen((E,bnf,k=1,help=[]): E is a vector of the form [0,A,0,B,C], (or the result of ellinit of such a vector) A,B,C integers such that x^3+A*x^2+B*x+C; bnf is the corresponding bnfinit(,1); Performs 2-descent on the elliptic curve Ek: k*y^2=x^3+A*x^2+B*x+C. See ?ellQ_ellrank for the format of the output.");
+   addhelp(ell2descent_viaisog,
+-    "ell2descent_viaisog(E,help=[]): E is an elliptic curve of the form [0,a,0,b,0], with a, b integers. Performs a 2-descent via isogeny on E. See ?ellrank for the format of the output.");
+-  addhelp(ellrank,
+-    "ellrank(E,help=[]): E is any elliptic curve defined over Q. Returns a vector [r,s,v], where r is a lower bound for the rank of E, s is the rank of its 2-Selmer group and v is a list of independant points in E(Q)/2E(Q). If help is a vector of nontrivial points on E, the result might be faster. This function might be used in conjunction with elltors2(E). See also ?default_ellQ");
++    "ell2descent_viaisog(E,help=[]): E is an elliptic curve of the form [0,a,0,b,0], with a, b integers. Performs a 2-descent via isogeny on E. See ?ellQ_ellrank for the format of the output.");
++  addhelp(ellQ_ellrank,
++    "ellQ_ellrank(E,help=[]): E is any elliptic curve defined over Q. Returns a vector [r,s,v], where r is a lower bound for the rank of E, s is the rank of its 2-Selmer group and v is a list of independant points in E(Q)/2E(Q). If help is a vector of nontrivial points on E, the result might be faster. This function might be used in conjunction with elltors2(E). See also ?default_ellQ");
+   addhelp(ellhalf,
+     "ellhalf(E,P): returns the vector of all points Q on the elliptic curve E such that 2Q = P");
+   addhelp(ellredgen,
+@@ -2143,7 +2143,7 @@ if( DEBUGLEVEL_ell >= 3, print("   end of ell2descent_viaisog"));
+ 
+ \\                  others
+   addhelp(default_ellQ,
+-    "default_ellQ(DEBUGLEVEL_ell, LIM1, LIM3, LIMTRIV, ELLREDGENFLAG, COMPLETE, MAXPROB, LIMBIGPRIME): set the value of the global variables used for ellrank() and other related functions. DEBUGLEVEL_ell: 0-5: choose the quantity of information printed during the computation (default=0: print nothing); LIM1 (resp LIM3): search limit for easy (resp hard) points on quartics; LIMTRIV: search limit for trivial points on elliptic curves; ELLREDGENFLAG: if != 0, try to reduce the generators at the end; COMPLETE: if != 0 and full 2-torsion, use complete 2-descent, otherwise via 2-isogeny; MAXPROB, LIMBIGPRIME: technical.");
++    "default_ellQ(DEBUGLEVEL_ell, LIM1, LIM3, LIMTRIV, ELLREDGENFLAG, COMPLETE, MAXPROB, LIMBIGPRIME): set the value of the global variables used for ellQ_ellrank() and other related functions. DEBUGLEVEL_ell: 0-5: choose the quantity of information printed during the computation (default=0: print nothing); LIM1 (resp LIM3): search limit for easy (resp hard) points on quartics; LIMTRIV: search limit for trivial points on elliptic curves; ELLREDGENFLAG: if != 0, try to reduce the generators at the end; COMPLETE: if != 0 and full 2-torsion, use complete 2-descent, otherwise via 2-isogeny; MAXPROB, LIMBIGPRIME: technical.");
+ /*  addhelp(DEBUGLEVEL_ell,
+     "DEBUGLEVEL_ell: Choose a higher value of this global variable to have more details of the computations printed during the 2-descent algorithm. 0 = don't print anything; 1 = (default) just print the result; 2 = print more details including the Selmer group and the nontrivial quartics.");
+ */
+diff --git a/src/sage/ext_data/pari/simon/qfsolve.gp b/src/sage/ext_data/pari/simon/qfsolve.gp
+index 501fb50828..2107288c1d 100644
+--- a/src/sage/ext_data/pari/simon/qfsolve.gp
++++ b/src/sage/ext_data/pari/simon/qfsolve.gp
+@@ -434,146 +434,6 @@ my(cc);
+ return([U3~*G3*U3,red[2]*U1*U2*U3]);
+ }
+ 
+-\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+-\\        QUADRATIC FORMS MINIMIZATION         \\
+-\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+-
+-\\ Minimization of the quadratic form G, with nonzero determinant.
+-\\ of dimension n>=2.
+-\\ G must by symmetric and have integral coefficients.
+-\\ Returns [G',U,factd] with U in GLn(Q) such that G'=U~*G*U*constant
+-\\ is integral and has minimal determinant.
+-\\ In dimension 3 or 4, may return a prime p
+-\\ if the reduction at p is impossible because of the local non solvability.
+-\\ If given, factdetG must be equal to factor(abs(det(G))).
+-{qfminimize(G,factdetG) =
+-my(factd,U,Ker,Ker2,sol,aux,di);
+-my(p);
+-my(n,lf,i,vp,dimKer,dimKer2,m);
+-
+-  n = length(G);
+-  factd = matrix(0,2);
+-  if( !factdetG, factdetG = factor(matdet(G)));
+-
+-  lf = length(factdetG[,1]);
+-  i = 1; U = matid(n);
+-
+-  while(i <= lf,
+-    vp = factdetG[i,2];
+-    if( vp == 0, i++; next);
+-    p = factdetG[i,1];
+-    if( p == -1, i++; next);
+-if( DEBUGLEVEL_qfsolve >= 4, print("    p = ",p,"^",vp));
+-
+-\\ The case vp = 1 can be minimized only if n is odd.
+-    if( vp == 1 && n%2 == 0,
+-      factd = concat(factd~, Mat([p,1])~)~;
+-      i++; next
+-    );
+-    Ker = kermodp(G,p); dimKer = Ker[1]; Ker = Ker[2];
+-
+-\\ Rem: we must have dimKer <= vp
+-if( DEBUGLEVEL_qfsolve >= 4, print("    dimKer = ",dimKer));
+-\\ trivial case: dimKer = n
+-    if( dimKer == n, 
+-if( DEBUGLEVEL_qfsolve >= 4, print("     case 0: dimKer = n"));
+-      G /= p;
+-      factdetG[i,2] -= n;
+-      next
+-    );
+-    G = Ker~*G*Ker;
+-    U = U*Ker;
+-
+-\\ 1st case: dimKer < vp
+-\\ then the kernel mod p contains a kernel mod p^2
+-    if( dimKer < vp,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 1: dimker < vp"));
+-      if( dimKer == 1,
+-\\        G[,1] /= p; G[1,] /= p;
+-        G[,1] /= p; G[1,] = G[1,]/p;
+-        U[,1] /= p;
+-        factdetG[i,2] -= 2
+-      , 
+-        Ker2 = kermodp(matrix(dimKer,dimKer,j,k,G[j,k]/p),p);
+-        dimKer2 = Ker2[1]; Ker2 = Ker2[2];
+-        for( j = 1, dimKer2, Ker2[,j] /= p);
+-        Ker2 = matdiagonalblock([Ker2,matid(n-dimKer)]);
+-        G = Ker2~*G*Ker2;
+-        U = U*Ker2;
+-        factdetG[i,2] -= 2*dimKer2
+-);
+-
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 1"));
+-      next
+-    );
+-
+-\\ Now, we have vp = dimKer 
+-\\ 2nd case: the dimension of the kernel is >=2
+-\\ and contains an element of norm 0 mod p^2
+-
+-\\ search for an element of norm p^2... in the kernel
+-    if( dimKer > 2 || 
+-       (dimKer == 2 && issquare( di = Mod((G[1,2]^2-G[1,1]*G[2,2])/p^2,p))),
+-      if( dimKer > 2,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 2.1"));
+-        dimKer = 3;
+-        sol = qfsolvemodp(matrix(3,3,j,k,G[j,k]/p),p)
+-      ,
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 2.2"));
+-        if( G[1,1]%p^2 == 0, 
+-          sol = [1,0]~
+-        , sol = [-G[1,2]/p+sqrt(di),Mod(G[1,1]/p,p)]~
+-        )
+-      );
+-      sol = centerlift(sol);
+-      sol /= content(sol);
+-if( DEBUGLEVEL_qfsolve >= 4, print("    sol = ",sol));
+-      Ker = vectorv(n, j, if( j<= dimKer, sol[j], 0)); \\ fill with 0's
+-      Ker = completebasis(Ker,1);
+-      Ker[,n] /= p;
+-      G = Ker~*G*Ker;
+-      U = U*Ker;
+-      factdetG[i,2] -= 2;
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 2"));
+-      next
+-    );
+-
+-\\ Now, we have vp = dimKer <= 2 
+-\\   and the kernel contains no vector with norm p^2...
+-
+-\\ In some cases, exchanging the kernel and the image
+-\\ makes the minimization easy.
+-
+-    m = (n-1)\2-1;
+-    if( ( vp == 1 && issquare(Mod(-(-1)^m*matdet(G)/G[1,1],p)))
+-     || ( vp == 2 && n%2 == 1 && n >= 5)
+-     || ( vp == 2 && n%2 == 0 && !issquare(Mod((-1)^m*matdet(G)/p^2,p)))
+-    , 
+-if( DEBUGLEVEL_qfsolve >= 4, print("    case 3"));
+-      Ker = matid(n);
+-      for( j = dimKer+1, n, Ker[j,j] = p);
+-      G = Ker~*G*Ker/p;
+-      U = U*Ker;
+-      factdetG[i,2] -= 2*dimKer-n;
+-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 3"));
+-      next
+-    );
+-
+-\\ Minimization was not possible se far.
+-\\ If n == 3 or 4, this proves the local non-solubility at p.
+-    if( n == 3 || n == 4, 
+-if( DEBUGLEVEL_qfsolve >= 1, print(" no local solution at ",p));
+-      return(p));
+-
+-if( DEBUGLEVEL_qfsolve >= 4, print("    prime ",p," finished"));
+-    factd = concat(factd~,Mat([p,vp])~)~;
+-    i++
+-  );
+-\\ apply LLL to avoid coefficients explosion
+-  aux = qflll(U/content(U));
+-return([aux~*G*aux,U*aux,factd]);
+-}
+-
+ \\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+ \\          CLASS GROUP COMPUTATIONS           \\
+ \\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
+diff --git a/src/sage/geometry/polyhedron/backend_field.py b/src/sage/geometry/polyhedron/backend_field.py
+index 6b921d23a6..2f32c58b1e 100644
+--- a/src/sage/geometry/polyhedron/backend_field.py
++++ b/src/sage/geometry/polyhedron/backend_field.py
+@@ -265,7 +265,7 @@ class Polyhedron_field(Polyhedron_base):
+              An inequality (-0.1419794359520263?, -1.698172434277148?) x + 1.200789243901438? >= 0,
+              An inequality (0.3001973109753594?, 0.600394621950719?) x - 0.4245431085692869? >= 0)
+             sage: p.Vrepresentation()                                           # optional - sage.rings.number_field
+-            (A vertex at (0.?e-15, 0.707106781186548?),
++            (A vertex at (0.?e-16, 0.7071067811865475?),
+              A vertex at (1.414213562373095?, 0),
+              A vertex at (4.000000000000000?, 0.372677996249965?))
+         """
+@@ -308,7 +308,7 @@ class Polyhedron_field(Polyhedron_base):
+              An inequality (-0.1419794359520263?, -1.698172434277148?) x + 1.200789243901438? >= 0,
+              An inequality (0.3001973109753594?, 0.600394621950719?) x - 0.4245431085692869? >= 0)
+             sage: p.Vrepresentation()                                           # optional - sage.rings.number_field
+-            (A vertex at (0.?e-15, 0.707106781186548?),
++            (A vertex at (0.?e-16, 0.7071067811865475?),
+              A vertex at (1.414213562373095?, 0),
+              A vertex at (4.000000000000000?, 0.372677996249965?))
+         """
+diff --git a/src/sage/geometry/polyhedron/backend_normaliz.py b/src/sage/geometry/polyhedron/backend_normaliz.py
+index 86b89632a5..ca8a43b248 100644
+--- a/src/sage/geometry/polyhedron/backend_normaliz.py
++++ b/src/sage/geometry/polyhedron/backend_normaliz.py
+@@ -53,7 +53,7 @@ def _number_field_elements_from_algebraics_list_of_lists_of_lists(listss, **kwds
+         1.732050807568878?
+         sage: from sage.geometry.polyhedron.backend_normaliz import _number_field_elements_from_algebraics_list_of_lists_of_lists
+         sage: K, results, hom = _number_field_elements_from_algebraics_list_of_lists_of_lists([[[rt2], [1]], [[rt3]], [[1], []]]); results  # optional - sage.rings.number_field
+-        [[[-a^3 + 3*a], [1]], [[-a^2 + 2]], [[1], []]]
++        [[[-a^3 + 3*a], [1]], [[a^2 - 2]], [[1], []]]
+     """
+     from sage.rings.qqbar import number_field_elements_from_algebraics
+     numbers = []
+diff --git a/src/sage/groups/matrix_gps/isometries.py b/src/sage/groups/matrix_gps/isometries.py
+index f9111a2c92..cca45e7175 100644
+--- a/src/sage/groups/matrix_gps/isometries.py
++++ b/src/sage/groups/matrix_gps/isometries.py
+@@ -11,11 +11,11 @@ EXAMPLES::
+     sage: L = IntegralLattice("D4")
+     sage: O = L.orthogonal_group()
+     sage: O
+-    Group of isometries with 5 generators (
+-    [-1  0  0  0]  [0 0 0 1]  [-1 -1 -1 -1]  [ 1  1  0  0]  [ 1  0  0  0]
+-    [ 0 -1  0  0]  [0 1 0 0]  [ 0  0  1  0]  [ 0  0  1  0]  [-1 -1 -1 -1]
+-    [ 0  0 -1  0]  [0 0 1 0]  [ 0  1  0  1]  [ 0  1  0  1]  [ 0  0  1  0]
+-    [ 0  0  0 -1], [1 0 0 0], [ 0 -1 -1  0], [ 0 -1 -1  0], [ 0  0  0  1]
++    Group of isometries with 3 generators (
++    [0 0 0 1]  [ 1  1  0  0]  [ 1  0  0  0]
++    [0 1 0 0]  [ 0  0  1  0]  [-1 -1 -1 -1]
++    [0 0 1 0]  [ 0  1  0  1]  [ 0  0  1  0]
++    [1 0 0 0], [ 0 -1 -1  0], [ 0  0  0  1]
+     )
+ 
+ Basic functionality is provided by GAP::
+diff --git a/src/sage/interfaces/genus2reduction.py b/src/sage/interfaces/genus2reduction.py
+index 56ae04b235..7a4794daf2 100644
+--- a/src/sage/interfaces/genus2reduction.py
++++ b/src/sage/interfaces/genus2reduction.py
+@@ -143,31 +143,31 @@ class ReductionData(SageObject):
+        sur un corps de valuation discrète", Trans. AMS 348 (1996),
+        4577-4610, Section 7.2, Proposition 4).
+     """
+-    def __init__(self, pari_result, P, Q, minimal_equation, minimal_disc,
+-                 local_data, conductor, prime_to_2_conductor_only):
++    def __init__(self, pari_result, P, Q, Pmin, Qmin, minimal_disc,
++                 local_data, conductor):
+         self.pari_result = pari_result
+         self.P = P
+         self.Q = Q
+-        self.minimal_equation = minimal_equation
++        self.Pmin = Pmin
++        self.Qmin = Qmin
+         self.minimal_disc = minimal_disc
+         self.local_data = local_data
+         self.conductor = conductor
+-        self.prime_to_2_conductor_only = prime_to_2_conductor_only
+ 
+     def _repr_(self):
+-        if self.prime_to_2_conductor_only:
+-            ex = ' (away from 2)'
+-        else:
+-            ex = ''
+         if self.Q == 0:
+             yterm = ''
+         else:
+             yterm = '+ (%s)*y '%self.Q
++
+         s = 'Reduction data about this proper smooth genus 2 curve:\n'
+         s += '\ty^2 %s= %s\n'%(yterm, self.P)
+-        s += 'A Minimal Equation (away from 2):\n\ty^2 = %s\n'%self.minimal_equation
+-        s += 'Minimal Discriminant (away from 2):  %s\n'%self.minimal_disc
+-        s += 'Conductor%s: %s\n'%(ex, self.conductor)
++        if self.Qmin:
++            s += 'A Minimal Equation:\n\ty^2 + (%s)y = %s\n'%(self.Qmin, self.Pmin)
++        else:
++            s += 'A Minimal Equation:\n\ty^2 = %s\n'%self.Pmin
++        s += 'Minimal Discriminant: %s\n'%self.minimal_disc
++        s += 'Conductor: %s\n'%self.conductor
+         s += 'Local Data:\n%s'%self._local_data_str()
+         return s
+ 
+@@ -242,17 +242,7 @@ class Genus2reduction(SageObject):
+         sage: factor(R.conductor)
+         5^4 * 2267
+ 
+-    This means that only the odd part of the conductor is known.
+-
+-    ::
+-
+-        sage: R.prime_to_2_conductor_only
+-        True
+-
+-    The discriminant is always minimal away from 2, but possibly not at
+-    2.
+-
+-    ::
++    The discriminant is always minimal::
+ 
+         sage: factor(R.minimal_disc)
+         2^3 * 5^5 * 2267
+@@ -264,10 +254,10 @@ class Genus2reduction(SageObject):
+         sage: R
+         Reduction data about this proper smooth genus 2 curve:
+             y^2 + (x^3 - 2*x^2 - 2*x + 1)*y = -5*x^5
+-        A Minimal Equation (away from 2):
+-            y^2 = x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855
+-        Minimal Discriminant (away from 2):  56675000
+-        Conductor (away from 2): 1416875
++        A Minimal Equation:
++            y^2 ...
++        Minimal Discriminant: 56675000
++        Conductor: 1416875
+         Local Data:
+             p=2
+             (potential) stable reduction:  (II), j=1
+@@ -293,10 +283,10 @@ class Genus2reduction(SageObject):
+         sage: genus2reduction(0, x^6 + 3*x^3 + 63)
+         Reduction data about this proper smooth genus 2 curve:
+                 y^2 = x^6 + 3*x^3 + 63
+-        A Minimal Equation (away from 2):
+-                y^2 = x^6 + 3*x^3 + 63
+-        Minimal Discriminant (away from 2):  10628388316852992
+-        Conductor (away from 2): 2893401
++        A Minimal Equation:
++                y^2 ...
++        Minimal Discriminant: -10628388316852992
++        Conductor: 2893401
+         Local Data:
+                 p=2
+                 (potential) stable reduction:  (V), j1+j2=0, j1*j2=0
+@@ -327,9 +317,9 @@ class Genus2reduction(SageObject):
+         sage: genus2reduction(x^3-x^2-1, x^2 - x)
+         Reduction data about this proper smooth genus 2 curve:
+                 y^2 + (x^3 - x^2 - 1)*y = x^2 - x
+-        A Minimal Equation (away from 2):
+-                y^2 = x^6 + 58*x^5 + 1401*x^4 + 18038*x^3 + 130546*x^2 + 503516*x + 808561
+-        Minimal Discriminant (away from 2):  169
++        A Minimal Equation:
++                y^2 ...
++        Minimal Discriminant: -169
+         Conductor: 169
+         Local Data:
+                 p=13
+@@ -370,10 +360,10 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^3 - 2*x^2 - 2*x + 1, -5*x^5)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^3 - 2*x^2 - 2*x + 1)*y = -5*x^5
+-            A Minimal Equation (away from 2):
+-                    y^2 = x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855
+-            Minimal Discriminant (away from 2):  56675000
+-            Conductor (away from 2): 1416875
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 56675000
++            Conductor: 1416875
+             Local Data:
+                     p=2
+                     (potential) stable reduction:  (II), j=1
+@@ -389,9 +379,9 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^2 + 1, -5*x^5)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^2 + 1)*y = -5*x^5
+-            A Minimal Equation (away from 2):
+-                    y^2 = -20*x^5 + x^4 + 2*x^2 + 1
+-            Minimal Discriminant (away from 2):  48838125
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 48838125
+             Conductor: 32025
+             Local Data:
+                     p=3
+@@ -412,9 +402,9 @@ class Genus2reduction(SageObject):
+             sage: genus2reduction(x^3 + x^2 + x,-2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2)
+             Reduction data about this proper smooth genus 2 curve:
+                     y^2 + (x^3 + x^2 + x)*y = -2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2
+-            A Minimal Equation (away from 2):
+-                    y^2 = x^6 + 18*x^3 + 36*x^2 - 27
+-            Minimal Discriminant (away from 2):  1520984142
++            A Minimal Equation:
++                    y^2 ...
++            Minimal Discriminant: 1520984142
+             Conductor: 954
+             Local Data:
+                     p=2
+@@ -436,18 +426,10 @@ class Genus2reduction(SageObject):
+             raise ValueError("Q (=%s) must have degree at most 3" % Q)
+ 
+         res = pari.genus2red([P, Q])
+-
+         conductor = ZZ(res[0])
+-        minimal_equation = R(res[2])
+-
+-        minimal_disc = QQ(res[2].poldisc()).abs()
+-        if minimal_equation.degree() == 5:
+-            minimal_disc *= minimal_equation[5]**2
+-        # Multiply with suitable power of 2 of the form 2^(2*(d-1) - 12)
+-        b = 2 * (minimal_equation.degree() - 1)
+-        k = QQ((12 - minimal_disc.valuation(2), b)).ceil()
+-        minimal_disc >>= 12 - b*k
+-        minimal_disc = ZZ(minimal_disc)
++        Pmin = R(res[2][0])
++        Qmin = R(res[2][1])
++        minimal_disc = ZZ(pari.hyperelldisc(res[2]))
+ 
+         local_data = {}
+         for red in res[3]:
+@@ -468,9 +450,7 @@ class Genus2reduction(SageObject):
+ 
+             local_data[p] = data
+ 
+-        prime_to_2_conductor_only = (-1 in res[1].component(2))
+-        return ReductionData(res, P, Q, minimal_equation, minimal_disc, local_data,
+-                             conductor, prime_to_2_conductor_only)
++        return ReductionData(res, P, Q, Pmin, Qmin, minimal_disc, local_data, conductor)
+ 
+     def __reduce__(self):
+         return _reduce_load_genus2reduction, tuple([])
+diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
+index fec450d7bc..236402c293 100644
+--- a/src/sage/lfunctions/dokchitser.py
++++ b/src/sage/lfunctions/dokchitser.py
+@@ -337,6 +337,7 @@ class Dokchitser(SageObject):
+             # After init_coeffs is called, future calls to this method should
+             # return the full output for further parsing
+             raise RuntimeError("unable to create L-series, due to precision or other limits in PARI")
++        t = t.replace("  *** _^_: Warning: normalizing a series with 0 leading term.\n", "")
+         return t
+ 
+     def __check_init(self):
+diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
+index d2b20f1891..6c31efe239 100644
+--- a/src/sage/lfunctions/pari.py
++++ b/src/sage/lfunctions/pari.py
+@@ -339,7 +339,7 @@ def lfun_eta_quotient(scalings, exponents):
+         0.0374412812685155
+ 
+         sage: lfun_eta_quotient([6],[4])
+-        [[Vecsmall([7]), [Vecsmall([6]), Vecsmall([4])]], 0, [0, 1], 2, 36, 1]
++        [[Vecsmall([7]), [Vecsmall([6]), Vecsmall([4]), 0]], 0, [0, 1], 2, 36, 1]
+ 
+         sage: lfun_eta_quotient([2,1,4], [5,-2,-2])
+         Traceback (most recent call last):
+diff --git a/src/sage/libs/pari/tests.py b/src/sage/libs/pari/tests.py
+index e5a2aa2517..0efcb15de0 100644
+--- a/src/sage/libs/pari/tests.py
++++ b/src/sage/libs/pari/tests.py
+@@ -356,7 +356,7 @@ Constructors::
+     [2, 4]~*x + [1, 3]~
+ 
+     sage: pari(3).Qfb(7, 1)
+-    Qfb(3, 7, 1, 0.E-19)
++    Qfb(3, 7, 1)
+     sage: pari(3).Qfb(7, 2)
+     Traceback (most recent call last):
+     ...
+@@ -512,7 +512,7 @@ Basic functions::
+     sage: pari('sqrt(-2)').frac()
+     Traceback (most recent call last):
+     ...
+-    PariError: incorrect type in gfloor (t_COMPLEX)
++    PariError: incorrect type in gfrac (t_COMPLEX)
+ 
+     sage: pari('1+2*I').imag()
+     2
+diff --git a/src/sage/modular/cusps_nf.py b/src/sage/modular/cusps_nf.py
+index 25d93cac92..157ebabe29 100644
+--- a/src/sage/modular/cusps_nf.py
++++ b/src/sage/modular/cusps_nf.py
+@@ -1220,7 +1220,7 @@ def units_mod_ideal(I):
+         sage: I = k.ideal(5, a + 1)
+         sage: units_mod_ideal(I)
+         [1,
+-        2*a^2 + 4*a - 1,
++        -2*a^2 - 4*a + 1,
+         ...]
+ 
+     ::
+diff --git a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
+index a881336596..090d1bfaf0 100644
+--- a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
++++ b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
+@@ -43,7 +43,7 @@ def coerce_AA(p):
+         sage: AA(p)._exact_field()
+         Number Field in a with defining polynomial y^8 ... with a in ...
+         sage: coerce_AA(p)._exact_field()
+-        Number Field in a with defining polynomial y^4 - 1910*y^2 - 3924*y + 681058 with a in 39.710518724...?
++        Number Field in a with defining polynomial y^4 - 1910*y^2 - 3924*y + 681058 with a in ...?
+     """
+     el = AA(p)
+     el.simplify()
+diff --git a/src/sage/modular/modsym/p1list_nf.py b/src/sage/modular/modsym/p1list_nf.py
+index 222caacca8..f9d969732c 100644
+--- a/src/sage/modular/modsym/p1list_nf.py
++++ b/src/sage/modular/modsym/p1list_nf.py
+@@ -58,7 +58,7 @@ Lift an MSymbol to a matrix in `SL(2, R)`:
+ 
+     sage: alpha = MSymbol(N, a + 2, 3*a^2)
+     sage: alpha.lift_to_sl2_Ok()
+-    [-3*a^2 + a + 12, 25*a^2 - 50*a + 100, a + 2, a^2 - 3*a + 3]
++    [-1, 4*a^2 - 13*a + 23, a + 2, 5*a^2 + 3*a - 3]
+     sage: Ok = k.ring_of_integers()
+     sage: M = Matrix(Ok, 2, alpha.lift_to_sl2_Ok())
+     sage: det(M)
+@@ -945,11 +945,11 @@ class P1NFList(SageObject):
+             sage: N = k.ideal(5, a + 1)
+             sage: P = P1NFList(N)
+             sage: u = k.unit_group().gens_values(); u
+-            [-1, 2*a^2 + 4*a - 1]
++            [-1, -2*a^2 - 4*a + 1]
+             sage: P.apply_J_epsilon(4, -1)
+             2
+             sage: P.apply_J_epsilon(4, u[0], u[1])
+-            1
++            5
+ 
+         ::
+ 
+diff --git a/src/sage/modules/free_quadratic_module_integer_symmetric.py b/src/sage/modules/free_quadratic_module_integer_symmetric.py
+index a206f0c721..aeb19ab669 100644
+--- a/src/sage/modules/free_quadratic_module_integer_symmetric.py
++++ b/src/sage/modules/free_quadratic_module_integer_symmetric.py
+@@ -1168,11 +1168,11 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+             sage: A4 = IntegralLattice("A4")
+             sage: Aut = A4.orthogonal_group()
+             sage: Aut
+-            Group of isometries with 5 generators (
+-            [-1  0  0  0]  [0 0 0 1]  [-1 -1 -1  0]  [ 1  0  0  0]  [ 1  0  0  0]
+-            [ 0 -1  0  0]  [0 0 1 0]  [ 0  0  0 -1]  [-1 -1 -1 -1]  [ 0  1  0  0]
+-            [ 0  0 -1  0]  [0 1 0 0]  [ 0  0  1  1]  [ 0  0  0  1]  [ 0  0  1  1]
+-            [ 0  0  0 -1], [1 0 0 0], [ 0  1  0  0], [ 0  0  1  0], [ 0  0  0 -1]
++            Group of isometries with 4 generators (
++            [0 0 0 1]  [-1 -1 -1  0]  [ 1  0  0  0]  [ 1  0  0  0]
++            [0 0 1 0]  [ 0  0  0 -1]  [-1 -1 -1 -1]  [ 0  1  0  0]
++            [0 1 0 0]  [ 0  0  1  1]  [ 0  0  0  1]  [ 0  0  1  1]
++            [1 0 0 0], [ 0  1  0  0], [ 0  0  1  0], [ 0  0  0 -1]
+             )
+ 
+         The group acts from the right on the lattice and its discriminant group::
+@@ -1180,19 +1180,19 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+             sage: x = A4.an_element()
+             sage: g = Aut.an_element()
+             sage: g
+-            [ 1  1  1  0]
+-            [ 0  0 -1  0]
+-            [ 0  0  1  1]
+-            [ 0 -1 -1 -1]
++            [-1 -1 -1  0]
++            [ 0  0  1  0]
++            [ 0  0 -1 -1]
++            [ 0  1  1  1]
+             sage: x*g
+-            (1, 1, 1, 0)
++            (-1, -1, -1, 0)
+             sage: (x*g).parent()==A4
+             True
+             sage: (g*x).parent()
+             Vector space of dimension 4 over Rational Field
+             sage: y = A4.discriminant_group().an_element()
+             sage: y*g
+-            (1)
++            (4)
+ 
+         If the group is finite we can compute the usual things::
+ 
+@@ -1208,10 +1208,10 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
+ 
+             sage: A2 = IntegralLattice(matrix.identity(3),Matrix(ZZ,2,3,[1,-1,0,0,1,-1]))
+             sage: A2.orthogonal_group()
+-            Group of isometries with 3 generators (
+-            [-1/3  2/3  2/3]  [ 2/3  2/3 -1/3]  [1 0 0]
+-            [ 2/3 -1/3  2/3]  [ 2/3 -1/3  2/3]  [0 0 1]
+-            [ 2/3  2/3 -1/3], [-1/3  2/3  2/3], [0 1 0]
++            Group of isometries with 2 generators (
++            [ 2/3  2/3 -1/3]  [1 0 0]
++            [ 2/3 -1/3  2/3]  [0 0 1]
++            [-1/3  2/3  2/3], [0 1 0]
+             )
+ 
+         It can be negative definite as well::
+diff --git a/src/sage/quadratic_forms/binary_qf.py b/src/sage/quadratic_forms/binary_qf.py
+index cfa3ada73e..5ac823bc6c 100755
+--- a/src/sage/quadratic_forms/binary_qf.py
++++ b/src/sage/quadratic_forms/binary_qf.py
+@@ -141,7 +141,7 @@ class BinaryQF(SageObject):
+                   and a.degree() == 2 and a.parent().ngens() == 2):
+                 x, y = a.parent().gens()
+                 a, b, c = [a.monomial_coefficient(mon) for mon in [x**2, x*y, y**2]]
+-            elif isinstance(a, pari_gen) and a.type() in ('t_QFI', 't_QFR'):
++            elif isinstance(a, pari_gen) and a.type() in ('t_QFI', 't_QFR', 't_QFB'):
+                 # a has 3 or 4 components
+                 a, b, c = a[0], a[1], a[2]
+         try:
+diff --git a/src/sage/quadratic_forms/genera/genus.py b/src/sage/quadratic_forms/genera/genus.py
+index 8290b6c4fa..0fc43f33c6 100644
+--- a/src/sage/quadratic_forms/genera/genus.py
++++ b/src/sage/quadratic_forms/genera/genus.py
+@@ -3088,8 +3088,8 @@ class GenusSymbol_global_ring():
+             sage: G = Genus(matrix(ZZ, 3, [6,3,0, 3,6,0, 0,0,2]))
+             sage: G.representatives()
+             (
+-            [2 0 0]  [ 2 -1  0]
+-            [0 6 3]  [-1  2  0]
++            [2 0 0]  [ 2  1  0]
++            [0 6 3]  [ 1  2  0]
+             [0 3 6], [ 0  0 18]
+             )
+ 
+diff --git a/src/sage/quadratic_forms/qfsolve.py b/src/sage/quadratic_forms/qfsolve.py
+index ddde95e04f..d5e15d9f83 100644
+--- a/src/sage/quadratic_forms/qfsolve.py
++++ b/src/sage/quadratic_forms/qfsolve.py
+@@ -70,7 +70,7 @@ def qfsolve(G):
+ 
+         sage: M = Matrix(QQ, [[3, 0, 0, 0], [0, 5, 0, 0], [0, 0, -7, 0], [0, 0, 0, -11]])
+         sage: qfsolve(M)
+-        (3, -4, -3, -2)
++        (3, 4, -3, -2)
+     """
+     ret = G.__pari__().qfsolve()
+     if ret.type() == 't_COL':
+diff --git a/src/sage/quadratic_forms/quadratic_form__automorphisms.py b/src/sage/quadratic_forms/quadratic_form__automorphisms.py
+index c36c667e3b..3d72cf3be1 100644
+--- a/src/sage/quadratic_forms/quadratic_form__automorphisms.py
++++ b/src/sage/quadratic_forms/quadratic_form__automorphisms.py
+@@ -300,9 +300,9 @@ def automorphism_group(self):
+         sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1])
+         sage: Q.automorphism_group()
+         Matrix group over Rational Field with 3 generators (
+-        [-1  0  0]  [0 0 1]  [ 0  0  1]
+-        [ 0 -1  0]  [0 1 0]  [-1  0  0]
+-        [ 0  0 -1], [1 0 0], [ 0  1  0]
++        [ 0  0  1]  [1 0 0]  [ 1  0  0]
++        [-1  0  0]  [0 0 1]  [ 0 -1  0]
++        [ 0  1  0], [0 1 0], [ 0  0  1]
+         )
+ 
+     ::
+diff --git a/src/sage/rings/finite_rings/finite_field_prime_modn.py b/src/sage/rings/finite_rings/finite_field_prime_modn.py
+index 9129ecb56a..d5a4cb8f22 100644
+--- a/src/sage/rings/finite_rings/finite_field_prime_modn.py
++++ b/src/sage/rings/finite_rings/finite_field_prime_modn.py
+@@ -111,7 +111,7 @@ class FiniteField_prime_modn(FiniteField_generic, integer_mod_ring.IntegerModRin
+             sage: RF13 = K.residue_field(pp)
+             sage: RF13.hom([GF(13)(1)])
+             Ring morphism:
+-             From: Residue field of Fractional ideal (w + 18)
++             From: Residue field of Fractional ideal (-w - 18)
+              To:   Finite Field of size 13
+              Defn: 1 |--> 1
+ 
+diff --git a/src/sage/rings/finite_rings/residue_field.pyx b/src/sage/rings/finite_rings/residue_field.pyx
+index 7596f2a302..1e1869f1b1 100644
+--- a/src/sage/rings/finite_rings/residue_field.pyx
++++ b/src/sage/rings/finite_rings/residue_field.pyx
+@@ -20,13 +20,13 @@ monogenic (i.e., 2 is an essential discriminant divisor)::
+ 
+     sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8)
+     sage: F = K.factor(2); F
+-    (Fractional ideal (1/2*a^2 - 1/2*a + 1)) * (Fractional ideal (-a^2 + 2*a - 3)) * (Fractional ideal (-3/2*a^2 + 5/2*a - 4))
++    (Fractional ideal (-1/2*a^2 + 1/2*a - 1)) * (Fractional ideal (-a^2 + 2*a - 3)) * (Fractional ideal (3/2*a^2 - 5/2*a + 4))
+     sage: F[0][0].residue_field()
+-    Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++    Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+     sage: F[1][0].residue_field()
+     Residue field of Fractional ideal (-a^2 + 2*a - 3)
+     sage: F[2][0].residue_field()
+-    Residue field of Fractional ideal (-3/2*a^2 + 5/2*a - 4)
++    Residue field of Fractional ideal (3/2*a^2 - 5/2*a + 4)
+ 
+ We can also form residue fields from `\ZZ`::
+ 
+@@ -258,9 +258,9 @@ class ResidueFieldFactory(UniqueFactory):
+     the index of ``ZZ[a]`` in the maximal order for all ``a``::
+ 
+         sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8); P = K.ideal(2).factor()[0][0]; P
+-        Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F = K.residue_field(P); F
+-        Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F(a)
+         0
+         sage: B = K.maximal_order().basis(); B
+@@ -270,7 +270,7 @@ class ResidueFieldFactory(UniqueFactory):
+         sage: F(B[2])
+         0
+         sage: F
+-        Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++        Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+         sage: F.degree()
+         1
+ 
+@@ -730,15 +730,15 @@ class ResidueField_generic(Field):
+         EXAMPLES::
+ 
+             sage: I = QQ[3^(1/3)].factor(5)[1][0]; I
+-            Fractional ideal (-a + 2)
++            Fractional ideal (a - 2)
+             sage: k = I.residue_field(); k
+-            Residue field of Fractional ideal (-a + 2)
++            Residue field of Fractional ideal (a - 2)
+             sage: f = k.lift_map(); f
+             Lifting map:
+-              From: Residue field of Fractional ideal (-a + 2)
++              From: Residue field of Fractional ideal (a - 2)
+               To:   Maximal Order in Number Field in a with defining polynomial x^3 - 3 with a = 1.442249570307409?
+             sage: f.domain()
+-            Residue field of Fractional ideal (-a + 2)
++            Residue field of Fractional ideal (a - 2)
+             sage: f.codomain()
+             Maximal Order in Number Field in a with defining polynomial x^3 - 3 with a = 1.442249570307409?
+             sage: f(k.0)
+@@ -768,7 +768,7 @@ class ResidueField_generic(Field):
+ 
+             sage: K.<a> = NumberField(x^3-11)
+             sage: F = K.ideal(37).factor(); F
+-            (Fractional ideal (37, a + 9)) * (Fractional ideal (37, a + 12)) * (Fractional ideal (2*a - 5))
++            (Fractional ideal (37, a + 9)) * (Fractional ideal (37, a + 12)) * (Fractional ideal (-2*a + 5))
+             sage: k = K.residue_field(F[0][0])
+             sage: l = K.residue_field(F[1][0])
+             sage: k == l
+@@ -846,7 +846,7 @@ cdef class ReductionMap(Map):
+             sage: F.reduction_map()
+             Partially defined reduction map:
+               From: Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
+-              To:   Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
++              To:   Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
+ 
+             sage: K.<theta_5> = CyclotomicField(5)
+             sage: F = K.factor(7)[0][0].residue_field()
+diff --git a/src/sage/rings/number_field/S_unit_solver.py b/src/sage/rings/number_field/S_unit_solver.py
+index e99dff850f..759cbfb334 100644
+--- a/src/sage/rings/number_field/S_unit_solver.py
++++ b/src/sage/rings/number_field/S_unit_solver.py
+@@ -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 (xi - 3),
+-         Fractional ideal (-2*xi^2 + 3),
++        (Fractional ideal (-2*xi^2 + 3),
++         Fractional ideal (-xi + 3),
+          Fractional ideal (2*xi + 1))
+ 
+         sage: sieve_data[1]
+-        (Residue field of Fractional ideal (xi - 3),
+-         Residue field of Fractional ideal (-2*xi^2 + 3),
++        (Residue field of Fractional ideal (-2*xi^2 + 3),
++         Residue field of Fractional ideal (-xi + 3),
+          Residue field of Fractional ideal (2*xi + 1))
+ 
+         sage: sieve_data[2]
+-        ([18, 7, 16, 4], [18, 9, 12, 8], [18, 3, 10, 10])
++        ([18, 12, 16, 8], [18, 16, 10, 4], [18, 10, 12, 10])
+ 
+         sage: sieve_data[3]
+-        (486, 648, 11664)
++        (648, 2916, 3888)
+     """
+ 
+     K = SUK.number_field()
+diff --git a/src/sage/rings/number_field/bdd_height.py b/src/sage/rings/number_field/bdd_height.py
+index beb047ae02..b7c8c33d0b 100644
+--- a/src/sage/rings/number_field/bdd_height.py
++++ b/src/sage/rings/number_field/bdd_height.py
+@@ -248,7 +248,7 @@ def bdd_norm_pr_ideal_gens(K, norm_list):
+         sage: from sage.rings.number_field.bdd_height import bdd_norm_pr_ideal_gens
+         sage: K.<g> = QuadraticField(123)
+         sage: bdd_norm_pr_ideal_gens(K, range(5))
+-        {0: [0], 1: [1], 2: [-g - 11], 3: [], 4: [2]}
++        {0: [0], 1: [1], 2: [g + 11], 3: [], 4: [2]}
+ 
+     ::
+ 
+diff --git a/src/sage/rings/number_field/class_group.py b/src/sage/rings/number_field/class_group.py
+index 018ff5f5c6..73c0462cd1 100644
+--- a/src/sage/rings/number_field/class_group.py
++++ b/src/sage/rings/number_field/class_group.py
+@@ -221,11 +221,11 @@ class FractionalIdealClass(AbelianGroupWithValuesElement):
+             Class group of order 76 with structure C38 x C2
+             of Number Field in a with defining polynomial x^2 + 20072
+             sage: I = (G.0)^11; I
+-            Fractional ideal class (41, 1/2*a + 5)
++            Fractional ideal class (33, 1/2*a + 8)
+             sage: J = G(I.ideal()^5); J
+-            Fractional ideal class (115856201, 1/2*a + 40407883)
++            Fractional ideal class (39135393, 1/2*a + 13654253)
+             sage: J.reduce()
+-            Fractional ideal class (57, 1/2*a + 44)
++            Fractional ideal class (73, 1/2*a + 47)
+             sage: J == I^5
+             True
+         """
+diff --git a/src/sage/rings/number_field/galois_group.py b/src/sage/rings/number_field/galois_group.py
+index 79acd053bb..e060148e4d 100644
+--- a/src/sage/rings/number_field/galois_group.py
++++ b/src/sage/rings/number_field/galois_group.py
+@@ -944,7 +944,7 @@ class GaloisGroup_v2(GaloisGroup_perm):
+             sage: K.<b> = NumberField(x^4 - 2*x^2 + 2, 'a').galois_closure()
+             sage: G = K.galois_group()
+             sage: [G.artin_symbol(P) for P in K.primes_above(7)]
+-            [(1,5)(2,6)(3,7)(4,8), (1,5)(2,6)(3,7)(4,8), (1,4)(2,3)(5,8)(6,7), (1,4)(2,3)(5,8)(6,7)]
++            [(1,4)(2,3)(5,8)(6,7), (1,4)(2,3)(5,8)(6,7), (1,5)(2,6)(3,7)(4,8), (1,5)(2,6)(3,7)(4,8)]
+             sage: G.artin_symbol(17)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
+index 58463d570d..ff65634e99 100644
+--- a/src/sage/rings/number_field/number_field.py
++++ b/src/sage/rings/number_field/number_field.py
+@@ -3643,7 +3643,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
+ 
+@@ -4227,7 +4227,8 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             (y^2 + 6, Mod(1/6*y, y^2 + 6), Mod(6*y, y^2 + 1/6))
+         """
+         f = self.absolute_polynomial()._pari_with_name('y')
+-        if f.pollead() == f.content().denominator() == 1:
++        f = f * f.content().denominator()
++        if f.pollead() == 1:
+             g = f
+             alpha = beta = g.variable().Mod(g)
+         else:
+@@ -4821,7 +4822,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+ 
+             sage: K.<a> = NumberField(2*x^2 - 1/3)
+             sage: K._S_class_group_and_units(tuple(K.primes_above(2) + K.primes_above(3)))
+-            ([-6*a + 2, 6*a + 3, -1, 12*a + 5], [])
++            ([6*a + 2, 6*a + 3, -1, -12*a + 5], [])
+         """
+         K_pari = self.pari_bnf(proof=proof)
+         S_pari = [p.pari_prime() for p in sorted(set(S))]
+@@ -5166,7 +5167,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+ 
+             sage: [K.ideal(g).factor() for g in gens]
+             [(Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1)),
+-            Fractional ideal (-a),
++            Fractional ideal (a),
+             (Fractional ideal (2, a + 1))^2,
+             1]
+ 
+@@ -5751,7 +5752,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: K.elements_of_norm(3)
+             []
+             sage: K.elements_of_norm(50)
+-            [-7*a + 1, 5*a - 5, 7*a + 1]
++            [-a - 7, 5*a - 5, 7*a + 1]
+ 
+         TESTS:
+ 
+@@ -5863,7 +5864,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: K.factor(1+a)
+             Fractional ideal (a + 1)
+             sage: K.factor(1+a/5)
+-            (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1 * (Fractional ideal (-3*a - 2))
++            (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1 * (Fractional ideal (-2*a + 3))
+ 
+         An example over a relative number field::
+ 
+@@ -6460,9 +6461,9 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+             sage: new_basis = k.reduced_basis(prec=120)
+             sage: [c.minpoly() for c in new_basis]
+             [x - 1,
+-             x^2 - x + 1,
++             x^2 + x + 1,
++             x^6 + 3*x^5 - 102*x^4 - 103*x^3 + 10572*x^2 - 59919*x + 127657,
+              x^6 + 3*x^5 - 102*x^4 - 103*x^3 + 10572*x^2 - 59919*x + 127657,
+-             x^6 - 3*x^5 - 102*x^4 + 315*x^3 + 10254*x^2 - 80955*x + 198147,
+              x^3 - 171*x + 848,
+              x^6 + 171*x^4 + 1696*x^3 + 29241*x^2 + 145008*x + 719104]
+             sage: R = k.order(new_basis)
+@@ -7058,7 +7059,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
+              -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)
++             2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7)
+ 
+         TESTS:
+ 
+@@ -7067,7 +7068,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)
+ 
+@@ -7146,7 +7147,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^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]
++            [-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, 2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7]
+         """
+         proof = proof_flag(proof)
+ 
+diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx
+index 784c239dc1..aa740069dc 100644
+--- a/src/sage/rings/number_field/number_field_element.pyx
++++ b/src/sage/rings/number_field/number_field_element.pyx
+@@ -4446,7 +4446,7 @@ cdef class NumberFieldElement(FieldElement):
+             sage: f = Qi.embeddings(K)[0]
+             sage: a = f(2+3*i) * (2-zeta)^2
+             sage: a.descend_mod_power(Qi,2)
+-            [-3*i - 2, -2*i + 3]
++            [-2*i + 3, 3*i + 2]
+ 
+         An absolute example::
+ 
+@@ -5124,7 +5124,7 @@ cdef class NumberFieldElement_relative(NumberFieldElement):
+         EXAMPLES::
+ 
+             sage: K.<a, b, c> = NumberField([x^2 - 2, x^2 - 3, x^2 - 5])
+-            sage: P = K.prime_factors(5)[0]
++            sage: P = K.prime_factors(5)[1]
+             sage: (2*a + b - c).valuation(P)
+             1
+         """
+diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
+index 5f587556a4..33481fead0 100644
+--- a/src/sage/rings/number_field/number_field_ideal.py
++++ b/src/sage/rings/number_field/number_field_ideal.py
+@@ -3355,7 +3355,7 @@ def quotient_char_p(I, p):
+         []
+ 
+         sage: I = K.factor(13)[0][0]; I
+-        Fractional ideal (-3*i - 2)
++        Fractional ideal (-2*i + 3)
+         sage: I.residue_class_degree()
+         1
+         sage: quotient_char_p(I, 13)[0]
+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 bae36d4b9c..f64bd5b761 100644
+--- a/src/sage/rings/number_field/number_field_ideal_rel.py
++++ b/src/sage/rings/number_field/number_field_ideal_rel.py
+@@ -272,7 +272,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.gens_reduced()
+-            (2, 15*a*b + 3*a + 1)
++            (2, -15*a*b + 3*a + 1)
+         """
+         try:
+             # Compute the single generator, if it exists
+@@ -401,7 +401,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.relative_norm()
+-            Fractional ideal (-6*a + 2)
++            Fractional ideal (6*a + 2)
+         """
+         L = self.number_field()
+         K = L.base_field()
+@@ -518,7 +518,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
+             sage: L.<b> = K.extension(5*x^2 + 1)
+             sage: P = L.primes_above(2)[0]
+             sage: P.ideal_below()
+-            Fractional ideal (-6*a + 2)
++            Fractional ideal (6*a + 2)
+         """
+         L = self.number_field()
+         K = L.base_field()
+diff --git a/src/sage/rings/number_field/number_field_rel.py b/src/sage/rings/number_field/number_field_rel.py
+index d33980c4b1..50e846b205 100644
+--- a/src/sage/rings/number_field/number_field_rel.py
++++ b/src/sage/rings/number_field/number_field_rel.py
+@@ -213,14 +213,14 @@ class NumberField_relative(NumberField_generic):
+             sage: l.<b> = k.extension(5*x^2 + 3); l
+             Number Field in b with defining polynomial 5*x^2 + 3 over its base field
+             sage: l.pari_rnf()
+-            [x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4), ..., y^4 + 6*y^2 + 1, x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4)], [0, 0]]
++            [x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4), ..., y^4 + 6*y^2 + 1, x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4)], [0, 0]]
+             sage: b
+             b
+ 
+             sage: l.<b> = k.extension(x^2 + 3/5); l
+             Number Field in b with defining polynomial x^2 + 3/5 over its base field
+             sage: l.pari_rnf()
+-            [x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4), ..., y^4 + 6*y^2 + 1, x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4)], [0, 0]]
++            [x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4), ..., y^4 + 6*y^2 + 1, x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4)], [0, 0]]
+             sage: b
+             b
+ 
+diff --git a/src/sage/rings/number_field/order.py b/src/sage/rings/number_field/order.py
+index 6eca89ed8d..78ef4c3b33 100644
+--- a/src/sage/rings/number_field/order.py
++++ b/src/sage/rings/number_field/order.py
+@@ -520,7 +520,7 @@ class Order(IntegralDomain, sage.rings.abc.Order):
+             sage: k.<a> = NumberField(x^2 + 5077); G = k.class_group(); G
+             Class group of order 22 with structure C22 of Number Field in a with defining polynomial x^2 + 5077
+             sage: G.0 ^ -9
+-            Fractional ideal class (11, a + 7)
++            Fractional ideal class (43, a + 13)
+             sage: Ok = k.maximal_order(); Ok
+             Maximal Order in Number Field in a with defining polynomial x^2 + 5077
+             sage: Ok * (11, a + 7)
+diff --git a/src/sage/rings/number_field/selmer_group.py b/src/sage/rings/number_field/selmer_group.py
+index c534aaa9f6..6bc67565d2 100644
+--- a/src/sage/rings/number_field/selmer_group.py
++++ b/src/sage/rings/number_field/selmer_group.py
+@@ -491,7 +491,7 @@ def pSelmerGroup(K, S, p, proof=None, debug=False):
+ 
+         sage: [K.ideal(g).factor() for g in gens]
+         [(Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1)),
+-        Fractional ideal (-a),
++        Fractional ideal (a),
+         (Fractional ideal (2, a + 1))^2,
+         1]
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
+index bb5d8356be..8a7e5fa66f 100644
+--- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
++++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
+@@ -1791,7 +1791,7 @@ class PolynomialQuotientRing_generic(CommutativeRing):
+             sage: D.selmer_generators([K.ideal(2, -a+1), K.ideal(3, a+1)], 3)
+             [2, a + 1]
+             sage: D.selmer_generators([K.ideal(2, -a+1), K.ideal(3, a+1), K.ideal(a)], 3)
+-            [2, a + 1, a]
++            [2, a + 1, -a]
+ 
+         """
+         fields, isos, iso_classes = self._S_decomposition(tuple(S))
+diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py
+index 704b77ce5f..83ee4549e4 100644
+--- a/src/sage/rings/qqbar.py
++++ b/src/sage/rings/qqbar.py
+@@ -312,8 +312,8 @@ and we get a way to produce the number directly::
+     True
+     sage: sage_input(n)
+     R.<y> = QQ[]
+-    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(RR(0.51763809020504148), RR(0.51763809020504159)))
+-    -109*v^3 - 89*v^2 + 327*v + 178
++    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(-RR(1.9318516525781366), -RR(1.9318516525781364)))
++    -109*v^3 + 89*v^2 + 327*v - 178
+ 
+ We can also see that some computations (basically, those which are
+ easy to perform exactly) are performed directly, instead of storing
+@@ -362,7 +362,7 @@ algorithms in :trac:`10255`::
+     # Verified
+     R1.<x> = QQbar[]
+     R2.<y> = QQ[]
+-    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(RR(0.51763809020504148), RR(0.51763809020504159)))
++    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(-RR(1.9318516525781366), -RR(1.9318516525781364)))
+     AA.polynomial_root(AA.common_polynomial(x^4 + QQbar(v^3 - 3*v - 1)*x^3 + QQbar(-v^3 + 3*v - 3)*x^2 + QQbar(-3*v^3 + 9*v + 3)*x + QQbar(3*v^3 - 9*v)), RIF(RR(0.99999999999999989), RR(1.0000000000000002)))
+     sage: one
+     1
+@@ -2310,7 +2310,7 @@ def do_polred(poly, threshold=32):
+     cost = 2 * bitsize.nbits() + 5 * poly.degree().nbits()
+     if cost > threshold:
+         return parent.gen(), parent.gen(), poly
+-    new_poly, elt_back = poly.__pari__().polredbest(flag=1)
++    new_poly, elt_back = poly.numerator().__pari__().polredbest(flag=1)
+     elt_fwd = elt_back.modreverse()
+     return parent(elt_fwd.lift()), parent(elt_back.lift()), parent(new_poly)
+ 
+@@ -2542,10 +2542,10 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+            Defn: a |--> 1.414213562373095?)
+ 
+         sage: number_field_elements_from_algebraics((rt2,rt3))
+-        (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, [-a^3 + 3*a, -a^2 + 2], Ring morphism:
++        (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, [-a^3 + 3*a, a^2 - 2], Ring morphism:
+             From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+             To:   Algebraic Real Field
+-            Defn: a |--> 0.5176380902050415?)
++            Defn: a |--> -1.931851652578137?)
+ 
+     ``rt3a`` is a real number in ``QQbar``.  Ordinarily, we'd get a homomorphism
+     to ``AA`` (because all elements are real), but if we specify ``same_field=True``,
+@@ -2570,7 +2570,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, -a^3 + 3*a, Ring morphism:
+             From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+             To:   Algebraic Real Field
+-            Defn: a |--> 0.5176380902050415?)
++            Defn: a |--> -1.931851652578137?)
+ 
+     We can specify ``minimal=True`` if we want the smallest number field::
+ 
+@@ -2618,7 +2618,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         sage: nfI^2
+         -1
+         sage: sum = nfrt2 + nfrt3 + nfI + nfz3; sum
+-        2*a^6 + a^5 - a^4 - a^3 - 2*a^2 - a
++        a^5 + a^4 - a^3 + 2*a^2 - a - 1
+         sage: hom(sum)
+         2.646264369941973? + 1.866025403784439?*I
+         sage: hom(sum) == rt2 + rt3 + qqI + z3
+@@ -2658,7 +2658,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+         sage: nf, nums, hom = number_field_elements_from_algebraics(elems, embedded=True)
+         sage: nf
+         Number Field in a with defining polynomial y^24 - 6*y^23 ...- 9*y^2 + 1
+-          with a = 0.2598678911433438? + 0.0572892247058457?*I
++          with a = 0.2598679? + 0.0572892?*I
+         sage: list(map(QQbar, nums)) == elems == list(map(hom, nums))
+         True
+ 
+@@ -2725,7 +2725,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
+                          sqrt(2), AA.polynomial_root(x^3-3, RIF(0,3)), 11/9, 1]
+         sage: res = number_field_elements_from_algebraics(my_nums, embedded=True)
+         sage: res[0]
+-        Number Field in a with defining polynomial y^24 - 107010*y^22 - 24*y^21 + ... + 250678447193040618624307096815048024318853254384 with a = -95.5053039433554?
++        Number Field in a with defining polynomial y^24 - 107010*y^22 - 24*y^21 + ... + 250678447193040618624307096815048024318853254384 with a = 93.32530798172420?
+     """
+     gen = qq_generator
+ 
+@@ -3129,7 +3129,7 @@ class AlgebraicGenerator(SageObject):
+             sage: root = ANRoot(x^2 - x - 1, RIF(1, 2))
+             sage: gen = AlgebraicGenerator(nf, root)
+             sage: gen.pari_field()
+-             [y^2 - y - 1, [2, 0], ...]
++            [[y^2 - y - 1, [2, 0], ...]
+         """
+         if self.is_trivial():
+             raise ValueError("No PARI field attached to trivial generator")
+@@ -3213,7 +3213,7 @@ class AlgebraicGenerator(SageObject):
+             sage: qq_generator.union(gen3) is gen3
+             True
+             sage: gen2.union(gen3)
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+         """
+         if self._trivial:
+             return other
+@@ -3306,13 +3306,13 @@ class AlgebraicGenerator(SageObject):
+             Number Field in a with defining polynomial y^2 - 3 with a in 1.732050807568878?
+             sage: gen2_3 = gen2.union(gen3)
+             sage: gen2_3
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+             sage: qq_generator.super_poly(gen2) is None
+             True
+             sage: gen2.super_poly(gen2_3)
+             -a^3 + 3*a
+             sage: gen3.super_poly(gen2_3)
+-            -a^2 + 2
++            a^2 - 2
+ 
+         """
+         if checked is None:
+@@ -3360,13 +3360,13 @@ class AlgebraicGenerator(SageObject):
+             sage: sqrt3 = ANExtensionElement(gen3, nf3.gen())
+             sage: gen2_3 = gen2.union(gen3)
+             sage: gen2_3
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
+             sage: gen2_3(sqrt2)
+             -a^3 + 3*a
+             sage: gen2_3(ANRational(1/7))
+             1/7
+             sage: gen2_3(sqrt3)
+-            -a^2 + 2
++            a^2 - 2
+         """
+         if self._trivial:
+             return elt._value
+@@ -4336,10 +4336,10 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: rt3 = AA(sqrt(3))
+             sage: rt3b = rt2 + rt3 - rt2
+             sage: rt3b.as_number_field_element()
+-            (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, -a^2 + 2, Ring morphism:
++            (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, a^2 - 2, Ring morphism:
+                 From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
+                 To:   Algebraic Real Field
+-                Defn: a |--> 0.5176380902050415?)
++                Defn: a |--> -1.931851652578137?)
+             sage: rt3b.as_number_field_element(minimal=True)
+             (Number Field in a with defining polynomial y^2 - 3, a, Ring morphism:
+                From: Number Field in a with defining polynomial y^2 - 3
+@@ -4401,7 +4401,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: rt2b = rt3 + rt2 - rt3
+             sage: rt2b.exactify()
+             sage: rt2b._exact_value()
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b.simplify()
+             sage: rt2b._exact_value()
+             a where a^2 - 2 = 0 and a in 1.414213562373095?
+@@ -4422,7 +4422,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: QQbar(2)._exact_field()
+             Trivial generator
+             sage: (sqrt(QQbar(2)) + sqrt(QQbar(19)))._exact_field()
+-            Number Field in a with defining polynomial y^4 - 20*y^2 + 81 with a in 2.375100220297941?
++            Number Field in a with defining polynomial y^4 - 20*y^2 + 81 with a in -3.789313782671036?
+             sage: (QQbar(7)^(3/5))._exact_field()
+             Number Field in a with defining polynomial y^5 - 2*y^4 - 18*y^3 + 38*y^2 + 82*y - 181 with a in 2.554256611698490?
+         """
+@@ -4442,7 +4442,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
+             sage: QQbar(2)._exact_value()
+             2
+             sage: (sqrt(QQbar(2)) + sqrt(QQbar(19)))._exact_value()
+-            -1/9*a^3 - a^2 + 11/9*a + 10 where a^4 - 20*a^2 + 81 = 0 and a in 2.375100220297941?
++            -1/9*a^3 + a^2 + 11/9*a - 10 where a^4 - 20*a^2 + 81 = 0 and a in -3.789313782671036?
+             sage: (QQbar(7)^(3/5))._exact_value()
+             2*a^4 + 2*a^3 - 34*a^2 - 17*a + 150 where a^5 - 2*a^4 - 18*a^3 + 38*a^2 + 82*a - 181 = 0 and a in 2.554256611698490?
+         """
+@@ -6857,7 +6857,7 @@ class AlgebraicPolynomialTracker(SageObject):
+             sage: p = sqrt(AA(2)) * x^2 - sqrt(AA(3))
+             sage: cp = AA.common_polynomial(p)
+             sage: cp.generator()
+-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 1.931851652578137?
++            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -0.5176380902050415?
+         """
+         self.exactify()
+         return self._gen
+@@ -7706,7 +7706,7 @@ class ANExtensionElement(ANDescr):
+ 
+             sage: rt2b.exactify()
+             sage: rt2b._descr
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b._descr.is_simple()
+             False
+         """
+@@ -7791,7 +7791,7 @@ class ANExtensionElement(ANDescr):
+             sage: rt2b = rt3 + rt2 - rt3
+             sage: rt2b.exactify()
+             sage: rt2b._descr
+-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
++            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
+             sage: rt2b._descr.simplify(rt2b)
+             a where a^2 - 2 = 0 and a in 1.414213562373095?
+         """
+@@ -7830,9 +7830,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.neg(a)
+-            1/3*a^3 - 2/3*a^2 + 4/3*a - 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -1/3*a^3 + 1/3*a^2 - a - 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+             sage: b.neg("ham spam and eggs")
+-            1/3*a^3 - 2/3*a^2 + 4/3*a - 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -1/3*a^3 + 1/3*a^2 - a - 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+         """
+         return ANExtensionElement(self._generator, -self._value)
+ 
+@@ -7848,9 +7848,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.invert(a)
+-            7/3*a^3 - 2/3*a^2 + 4/3*a - 12 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -7/3*a^3 + 19/3*a^2 - 7*a - 9 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+             sage: b.invert("ham spam and eggs")
+-            7/3*a^3 - 2/3*a^2 + 4/3*a - 12 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
++            -7/3*a^3 + 19/3*a^2 - 7*a - 9 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
+         """
+         return ANExtensionElement(self._generator, ~self._value)
+ 
+@@ -7866,9 +7866,9 @@ class ANExtensionElement(ANDescr):
+             sage: type(b)
+             <class 'sage.rings.qqbar.ANExtensionElement'>
+             sage: b.conjugate(a)
+-            -1/3*a^3 + 2/3*a^2 - 4/3*a + 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? + 1.573132184970987?*I
++            1/3*a^3 - 1/3*a^2 + a + 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? - 1.573132184970987?*I
+             sage: b.conjugate("ham spam and eggs")
+-            -1/3*a^3 + 2/3*a^2 - 4/3*a + 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? + 1.573132184970987?*I
++            1/3*a^3 - 1/3*a^2 + a + 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? - 1.573132184970987?*I
+         """
+         if self._exactly_real:
+             return self
+@@ -8501,7 +8501,7 @@ def an_binop_expr(a, b, op):
+         sage: x = an_binop_expr(a, b, operator.add); x
+         <sage.rings.qqbar.ANBinaryExpr object at ...>
+         sage: x.exactify()
+-        -6/7*a^7 + 2/7*a^6 + 71/7*a^5 - 26/7*a^4 - 125/7*a^3 + 72/7*a^2 + 43/7*a - 47/7 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in 3.12580...?
++        6/7*a^7 - 2/7*a^6 - 71/7*a^5 + 26/7*a^4 + 125/7*a^3 - 72/7*a^2 - 43/7*a + 47/7 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in -0.3199179336182997?
+ 
+         sage: a = QQbar(sqrt(2)) + QQbar(sqrt(3))
+         sage: b = QQbar(sqrt(3)) + QQbar(sqrt(5))
+@@ -8510,7 +8510,7 @@ def an_binop_expr(a, b, op):
+         sage: x = an_binop_expr(a, b, operator.mul); x
+         <sage.rings.qqbar.ANBinaryExpr object at ...>
+         sage: x.exactify()
+-        2*a^7 - a^6 - 24*a^5 + 12*a^4 + 46*a^3 - 22*a^2 - 22*a + 9 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in 3.1258...?
++        2*a^7 - a^6 - 24*a^5 + 12*a^4 + 46*a^3 - 22*a^2 - 22*a + 9 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in -0.3199179336182997?
+     """
+     return ANBinaryExpr(a, b, op)
+ 
+diff --git a/src/sage/schemes/affine/affine_morphism.py b/src/sage/schemes/affine/affine_morphism.py
+index 1c4f2dff18..32c2e47e49 100644
+--- a/src/sage/schemes/affine/affine_morphism.py
++++ b/src/sage/schemes/affine/affine_morphism.py
+@@ -1148,9 +1148,9 @@ class SchemeMorphism_polynomial_affine_space_field(SchemeMorphism_polynomial_aff
+             sage: H = End(A)
+             sage: f = H([(QQbar(sqrt(2))*x^2 + 1/QQbar(sqrt(3))) / (5*x)])
+             sage: f.reduce_base_field()
+-            Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a = 1.931851652578137?
++            Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a = ...?
+               Defn: Defined on coordinates by sending (x) to
+-                    (((a^3 - 3*a)*x^2 + (1/3*a^2 - 2/3))/(5*x))
++                    (((a^3 - 3*a)*x^2 + (-1/3*a^2 + 2/3))/(5*x))
+ 
+         ::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_field.py b/src/sage/schemes/elliptic_curves/ell_field.py
+index 68b8375dae..48f358ea6a 100644
+--- a/src/sage/schemes/elliptic_curves/ell_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_field.py
+@@ -845,7 +845,7 @@ class EllipticCurve_field(ell_generic.EllipticCurve_generic, ProjectivePlaneCurv
+             sage: E = E.base_extend(G).quadratic_twist(c); E
+             Elliptic Curve defined by y^2 = x^3 + 5*a0*x^2 + (-200*a0^2)*x + (-42000*a0^2+42000*a0+126000) over Number Field in a0 with defining polynomial x^3 - 3*x^2 + 3*x + 9
+             sage: K.<b> = E.division_field(3, simplify_all=True); K
+-            Number Field in b with defining polynomial x^12 - 10*x^10 + 55*x^8 - 60*x^6 + 75*x^4 + 1350*x^2 + 2025
++            Number Field in b with defining polynomial x^12 + 5*x^10 + 40*x^8 + 315*x^6 + 750*x^4 + 675*x^2 + 2025
+ 
+         Some higher-degree examples::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_generic.py b/src/sage/schemes/elliptic_curves/ell_generic.py
+index 926ae310ea..3bae819fb0 100644
+--- a/src/sage/schemes/elliptic_curves/ell_generic.py
++++ b/src/sage/schemes/elliptic_curves/ell_generic.py
+@@ -3324,8 +3324,8 @@ 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),
++            [0, 0, 0, Mod(1, y^2 - 2),
++            Mod(y, y^2 - 2), 0, 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;
+diff --git a/src/sage/schemes/elliptic_curves/ell_number_field.py b/src/sage/schemes/elliptic_curves/ell_number_field.py
+index edbd196090..c44c803aa8 100644
+--- a/src/sage/schemes/elliptic_curves/ell_number_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_number_field.py
+@@ -218,7 +218,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: E == loads(dumps(E))
+             True
+             sage: E.simon_two_descent()
+-            (2, 2, [(0 : 0 : 1)])
++            (2, 2, [(0 : 0 : 1), (1/18*a + 7/18 : -5/54*a - 17/54 : 1)])
+             sage: E.simon_two_descent(lim1=5, lim3=5, limtriv=10, maxprob=7, limbigprime=10)
+             (2, 2, [(-1 : 0 : 1), (-2 : -1/2*a - 1/2 : 1)])
+ 
+@@ -274,7 +274,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: E.simon_two_descent()  # long time (4s on sage.math, 2013)
+             (3,
+              3,
+-             [(5/8*zeta43_0^2 + 17/8*zeta43_0 - 9/4 : -27/16*zeta43_0^2 - 103/16*zeta43_0 + 39/8 : 1),
++             [(1/8*zeta43_0^2 - 3/8*zeta43_0 - 1/4 : -5/16*zeta43_0^2 + 7/16*zeta43_0 + 1/8 : 1),
+               (0 : 0 : 1)])
+         """
+         verbose = int(verbose)
+@@ -865,7 +865,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             Conductor exponent: 1
+             Kodaira Symbol: I1
+             Tamagawa Number: 1,
+-            Local data at Fractional ideal (-3*i - 2):
++            Local data at Fractional ideal (-2*i + 3):
+             Reduction type: bad split multiplicative
+             Local minimal model: Elliptic Curve defined by y^2 + (i+1)*x*y + y = x^3 over Number Field in i with defining polynomial x^2 + 1
+             Minimal discriminant valuation: 2
+@@ -2645,12 +2645,12 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             [-92, -23, -23]
+ 
+             sage: C.matrix()  # long time
+-            [1 2 2 4 2 4]
+-            [2 1 2 2 4 4]
+-            [2 2 1 4 4 2]
+-            [4 2 4 1 3 3]
+-            [2 4 4 3 1 3]
+-            [4 4 2 3 3 1]
++            [1 2 2 4 4 2]
++            [2 1 2 4 2 4]
++            [2 2 1 2 4 4]
++            [4 4 2 1 3 3]
++            [4 2 4 3 1 3]
++            [2 4 4 3 3 1]
+ 
+         The graph of this isogeny class has a shape which does not
+         occur over `\QQ`: a triangular prism.  Note that for curves
+@@ -2677,12 +2677,12 @@ class EllipticCurve_number_field(EllipticCurve_field):
+ 
+             sage: G = C.graph()  # long time
+             sage: G.adjacency_matrix()  # long time
+-            [0 1 1 0 1 0]
+-            [1 0 1 1 0 0]
+-            [1 1 0 0 0 1]
+-            [0 1 0 0 1 1]
+-            [1 0 0 1 0 1]
+-            [0 0 1 1 1 0]
++            [0 1 1 0 0 1]
++            [1 0 1 0 1 0]
++            [1 1 0 1 0 0]
++            [0 0 1 0 1 1]
++            [0 1 0 1 0 1]
++            [1 0 0 1 1 0]
+ 
+         To display the graph without any edge labels::
+ 
+@@ -3316,7 +3316,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
+             sage: points = [E.lift_x(x) for x in xi]
+             sage: newpoints, U = E.lll_reduce(points)  # long time (35s on sage.math, 2011)
+             sage: [P[0] for P in newpoints]            # long time
+-            [6823803569166584943, 5949539878899294213, 2005024558054813068, 5864879778877955778, 23955263915878682727/4, 5922188321411938518, 5286988283823825378, 175620639884534615751/25, -11451575907286171572, 3502708072571012181, 1500143935183238709184/225, 27180522378120223419/4, -5811874164190604461581/625, 26807786527159569093, 7404442636649562303, 475656155255883588, 265757454726766017891/49, 7272142121019825303, 50628679173833693415/4, 6951643522366348968, 6842515151518070703, 111593750389650846885/16, 2607467890531740394315/9, -1829928525835506297]
++            [6823803569166584943, 5949539878899294213, 2005024558054813068, 5864879778877955778, 23955263915878682727/4, 5922188321411938518, 5286988283823825378, 11465667352242779838, -11451575907286171572, 3502708072571012181, 1500143935183238709184/225, 27180522378120223419/4, -5811874164190604461581/625, 26807786527159569093, 7041412654828066743, 475656155255883588, 265757454726766017891/49, 7272142121019825303, 50628679173833693415/4, 6951643522366348968, 6842515151518070703, 111593750389650846885/16, 2607467890531740394315/9, -1829928525835506297]
+ 
+         An example to show the explicit use of the height pairing matrix::
+ 
+diff --git a/src/sage/schemes/elliptic_curves/ell_rational_field.py b/src/sage/schemes/elliptic_curves/ell_rational_field.py
+index 3808822812..a75290ea35 100644
+--- a/src/sage/schemes/elliptic_curves/ell_rational_field.py
++++ b/src/sage/schemes/elliptic_curves/ell_rational_field.py
+@@ -1827,7 +1827,7 @@ class EllipticCurve_rational_field(EllipticCurve_number_field):
+             sage: E = EllipticCurve('389a1')
+             sage: E._known_points = []  # clear cached points
+             sage: E.simon_two_descent()
+-            (2, 2, [(1 : 0 : 1), (-11/9 : 28/27 : 1)])
++            (2, 2, [(5/4 : 5/8 : 1), (-3/4 : 7/8 : 1)])
+             sage: E = EllipticCurve('5077a1')
+             sage: E.simon_two_descent()
+             (3, 3, [(1 : 0 : 1), (2 : 0 : 1), (0 : 2 : 1)])
+diff --git a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
+index 81ad295160..d484a4a18b 100644
+--- a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
++++ b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
+@@ -780,12 +780,12 @@ def deg_one_primes_iter(K, principal_only=False):
+         [Fractional ideal (2, a + 1),
+          Fractional ideal (3, a + 1),
+          Fractional ideal (3, a + 2),
+-         Fractional ideal (-a),
++         Fractional ideal (a),
+          Fractional ideal (7, a + 3),
+          Fractional ideal (7, a + 4)]
+         sage: it = deg_one_primes_iter(K, True)
+         sage: [next(it) for _ in range(6)]
+-        [Fractional ideal (-a),
++        [Fractional ideal (a),
+          Fractional ideal (-2*a + 3),
+          Fractional ideal (2*a + 3),
+          Fractional ideal (a + 6),
+diff --git a/src/sage/schemes/elliptic_curves/gp_simon.py b/src/sage/schemes/elliptic_curves/gp_simon.py
+index 28b97f34af..9f7d1b6020 100644
+--- a/src/sage/schemes/elliptic_curves/gp_simon.py
++++ b/src/sage/schemes/elliptic_curves/gp_simon.py
+@@ -56,7 +56,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+         sage: import sage.schemes.elliptic_curves.gp_simon
+         sage: E=EllipticCurve('389a1')
+         sage: sage.schemes.elliptic_curves.gp_simon.simon_two_descent(E)
+-        (2, 2, [(1 : 0 : 1), (-11/9 : 28/27 : 1)])
++        (2, 2, [(5/4 : 5/8 : 1), (-3/4 : 7/8 : 1)])
+ 
+     TESTS::
+ 
+@@ -117,7 +117,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+     # The block below mimics the defaults in Simon's scripts, and needs to be changed
+     # when these are updated.
+     if K is QQ:
+-        cmd = 'ellrank(%s, %s);' % (list(E.ainvs()), [P.__pari__() for P in known_points])
++        cmd = 'ellQ_ellrank(%s, %s);' % (list(E.ainvs()), [P.__pari__() for P in known_points])
+         if lim1 is None:
+             lim1 = 5
+         if lim3 is None:
+@@ -144,7 +144,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
+     if verbose > 0:
+         print(s)
+     v = gp.eval('ans')
+-    if v=='ans': # then the call to ellrank() or bnfellrank() failed
++    if v=='ans': # then the call to ellQ_ellrank() or bnfellrank() failed
+         raise RuntimeError("An error occurred while running Simon's 2-descent program")
+     if verbose >= 2:
+         print("v = %s" % v)
+diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
+index a936deb74f..dc19254d8c 100644
+--- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
++++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
+@@ -1208,14 +1208,14 @@ def isogenies_13_0(E, minimal_models=True):
+         sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]  # long time (4s)
+         [(0,
+           0,
+-          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
++          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 + 1887439/1146978983704320*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 + 1030632647/7965131831280*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 - 43618899433/204234149520*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 2535050171/1418292705,
+           -139861295/2650795873449984*a^11 - 3455957/5664093746688*a^10 - 345310571/50976843720192*a^9 - 500530795/118001953056*a^8 - 12860048113/265504394376*a^7 - 25007420461/44250732396*a^6 + 458134176455/1416023436672*a^5 + 16701880631/9077073312*a^4 + 155941666417/9077073312*a^3 + 3499310115/378211388*a^2 - 736774863/94552847*a - 21954102381/94552847,
+-          579363345221/13763747804451840*a^11 + 371192377511/860234237778240*a^10 + 8855090365657/1146978983704320*a^9 + 5367261541663/1633873196160*a^8 + 614883554332193/15930263662560*a^7 + 30485197378483/68078049840*a^6 - 131000897588387/2450809794240*a^5 - 203628705777949/306351224280*a^4 - 1587619388190379/204234149520*a^3 + 14435069706551/11346341640*a^2 + 7537273048614/472764235*a + 89198980034806/472764235),
++          8342795944891/198197968384106496*a^11 + 8908625263589/20645621706677760*a^10 + 53130542636623/6881873902225920*a^9 + 376780111042213/114697898370432*a^8 + 614884052146333/15930263662560*a^7 + 3566768133324359/7965131831280*a^6 - 1885593809102545/35291661037056*a^5 - 2443732172026523/3676214691360*a^4 - 9525729503937541/1225404897120*a^3 + 51990274442321/40846829904*a^2 + 67834019370596/4254878115*a + 267603083706812/1418292705),
+          (0,
+           0,
+-          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
++          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 + 1887439/1146978983704320*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 + 1030632647/7965131831280*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 - 43618899433/204234149520*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 2535050171/1418292705,
+           -6465569317/1325397936724992*a^11 - 112132307/1960647835392*a^10 - 17075412917/25488421860096*a^9 - 207832519229/531008788752*a^8 - 1218275067617/265504394376*a^7 - 9513766502551/177002929584*a^6 + 4297077855437/708011718336*a^5 + 354485975837/4538536656*a^4 + 4199379308059/4538536656*a^3 - 30841577919/189105694*a^2 - 181916484042/94552847*a - 2135779171614/94552847,
+-          -132601797212627/3440936951112960*a^11 - 6212467020502021/13763747804451840*a^10 - 1515926454902497/286744745926080*a^9 - 15154913741799637/4901619588480*a^8 - 576888119803859263/15930263662560*a^7 - 86626751639648671/204234149520*a^6 + 16436657569218427/306351224280*a^5 + 1540027900265659087/2450809794240*a^4 + 375782662805915809/51058537380*a^3 - 14831920924677883/11346341640*a^2 - 7237947774817724/472764235*a - 84773764066089509/472764235)]
++          -1316873026840277/34172063514501120*a^11 - 18637401045099413/41291243413355520*a^10 - 36382234917217247/6881873902225920*a^9 - 61142238484016213/19775499719040*a^8 - 576888119306045123/15930263662560*a^7 - 3378443313906256321/7965131831280*a^6 + 326466167429333279/6084769144320*a^5 + 4620083325391594991/7352429382720*a^4 + 9018783894167184149/1225404897120*a^3 - 9206015742300283/7042556880*a^2 - 65141531411426446/4254878115*a - 254321286054666133/1418292705)]
+     """
+     if E.j_invariant()!=0:
+         raise ValueError("j-invariant must be 0.")
diff --git a/srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15b.patch b/srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15b.patch
new file mode 100644
index 000000000000..762bb2612632
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34537-sagemath-pari-2.15b.patch
@@ -0,0 +1,29 @@
+From f0365f30834b6890313790b3845c647d0160fa6a Mon Sep 17 00:00:00 2001
+From: Vincent Delecroix <20100.delecroix@gmail.com*>
+Date: Fri, 30 Sep 2022 16:31:08 +0200
+Subject: fix doctest if fqf_orthogonal
+
+---
+ src/sage/groups/fqf_orthogonal.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/sage/groups/fqf_orthogonal.py b/src/sage/groups/fqf_orthogonal.py
+index 75de408..7fc4dbe 100644
+--- a/src/sage/groups/fqf_orthogonal.py
++++ b/src/sage/groups/fqf_orthogonal.py
+@@ -245,10 +245,10 @@ class FqfOrthogonalGroup(AbelianGroupAutomorphismGroup_subgroup):
+             sage: all(x*f==x*fbar for x in q.gens())
+             True
+             sage: L = IntegralLattice("A2").twist(3)
+-            sage: q = L.discriminant_group()
+             sage: OL = L.orthogonal_group()
++            sage: assert OL(OL.0.matrix()) == OL.0
++            sage: q = L.discriminant_group()
+             sage: Oq = q.orthogonal_group()
+-            sage: assert Oq(OL.0) == Oq(OL.0.matrix())
+             sage: assert Oq(Oq.0.matrix()) == Oq.0
+         """
+         from sage.libs.gap.element import GapElement
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-34668-matplotlib_3.6-5501e0de0dca1cff0355326dd42bd8c7e5749568.patch b/srcpkgs/sagemath/patches/trac-34668-matplotlib_3.6-5501e0de0dca1cff0355326dd42bd8c7e5749568.patch
new file mode 100644
index 000000000000..6afaf1b7162f
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-34668-matplotlib_3.6-5501e0de0dca1cff0355326dd42bd8c7e5749568.patch
@@ -0,0 +1,72 @@
+commit 5501e0de0dca1cff0355326dd42bd8c7e5749568
+Author: Gonzalo Tornaría <tornaria@cmat.edu.uy>
+Date:   Tue Oct 11 17:25:04 2022 -0300
+
+    Support matplotlib 3.6
+
+diff --git a/src/sage/plot/arc.py b/src/sage/plot/arc.py
+index bb834763afc..f65973bcbd5 100644
+--- a/src/sage/plot/arc.py
++++ b/src/sage/plot/arc.py
+@@ -273,9 +273,9 @@ class Arc(GraphicPrimitive):
+         p = patches.Arc((self.x, self.y),
+                         2. * self.r1,
+                         2. * self.r2,
+-                        fmod(self.angle, 2 * pi) * (180. / pi),
+-                        self.s1 * (180. / pi),
+-                        self.s2 * (180. / pi))
++                        angle=fmod(self.angle, 2 * pi) * (180. / pi),
++                        theta1=self.s1 * (180. / pi),
++                        theta2=self.s2 * (180. / pi))
+         return p
+ 
+     def bezier_path(self):
+diff --git a/src/sage/plot/ellipse.py b/src/sage/plot/ellipse.py
+index a77e6fe640a..c35bed574ef 100644
+--- a/src/sage/plot/ellipse.py
++++ b/src/sage/plot/ellipse.py
+@@ -192,7 +192,8 @@ class Ellipse(GraphicPrimitive):
+         options = self.options()
+         p = patches.Ellipse(
+                 (self.x,self.y),
+-                self.r1*2.,self.r2*2.,self.angle/pi*180.)
++                self.r1*2.,self.r2*2.,
++                angle=self.angle/pi*180.)
+         p.set_linewidth(float(options['thickness']))
+         p.set_fill(options['fill'])
+         a = float(options['alpha'])
+diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
+index e779e1210e3..8d620b5c625 100644
+--- a/src/sage/plot/graphics.py
++++ b/src/sage/plot/graphics.py
+@@ -2007,7 +2007,7 @@ class Graphics(WithEqualityById, SageObject):
+         We can also do custom formatting if you need it.  See above for full
+         details::
+ 
+-            sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex")
++            sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex") # not tested (broken with matplotlib 3.6)
+             Graphics object consisting of 1 graphics primitive
+ 
+         This is particularly useful when setting custom ticks in multiples
+@@ -2341,7 +2341,7 @@ class Graphics(WithEqualityById, SageObject):
+             sage: subplot = Figure().add_subplot(111)
+             sage: p._objects[0]._render_on_subplot(subplot)
+             sage: p._matplotlib_tick_formatter(subplot, **d)
+-            (<AxesSubplot:>,
++            (<AxesSubplot:...>,
+             <matplotlib.ticker.MaxNLocator object at ...>,
+             <matplotlib.ticker.MaxNLocator object at ...>,
+             <matplotlib.ticker.ScalarFormatter object at ...>,
+diff --git a/src/sage/plot/plot.py b/src/sage/plot/plot.py
+index b36ee57227c..5301a05c3dc 100644
+--- a/src/sage/plot/plot.py
++++ b/src/sage/plot/plot.py
+@@ -1741,7 +1741,7 @@ def plot(funcs, *args, **kwds):
+ 
+     ::
+ 
+-        sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex")
++        sage: plot(2*x+1,(x,0,5),ticks=[[0,1,e,pi,sqrt(20)],2],tick_formatter="latex") # not tested (broken with matplotlib 3.6)
+         Graphics object consisting of 1 graphics primitive
+ 
+     .. PLOT::
diff --git a/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch b/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch
deleted file mode 100644
index f3eb0aad2cca..000000000000
--- a/srcpkgs/sagemath/patches/zzz-loadable_module_extension.patch
+++ /dev/null
@@ -1,14 +0,0 @@
- - this is not a proper fix... should fix sage_getfile() instead
-
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -187,7 +187,8 @@ def loadable_module_extension():
-         True
-     """
-     # Return the full platform-specific extension module suffix
--    return import_machinery.EXTENSION_SUFFIXES[0]
-+    # PATCHED for void linux, we use the shortest extension (.so)
-+    return import_machinery.EXTENSION_SUFFIXES[-1]
- 
- 
- def isclassinstance(obj):
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 0d793262d572..49fe919112a1 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,11 +1,11 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=9.5
-revision=2
+version=9.7
+revision=1
 wrksrc=sage-$version
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
-_bindir=/usr/lib/sagemath/bin
+_bindir=/usr/lib/sagemath/$version/bin
 make_install_args="--install-scripts=$_bindir"
 hostmakedepends="m4 pkg-config python3-Cython python3-Jinja2 python3-pkgconfig
  python3-setuptools"
@@ -33,66 +33,52 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-2.0-or-later"
 homepage="http://sagemath.org/"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=8d70a3b26080802c5b2e33dda4c23795d494d8216a0c2ecfcd608ebab0e64ff6
-
-post_patch() {
-	# these are unused and nothing else uses ratpoints
-	rm sage/libs/ratpoints.{pyx,pxd}
-
-	# git tree needs bootstrapping
-	pushd $wrksrc/build/pkgs/sagelib
-	PATH=../../bin:$PATH BOOTSTRAP_QUIET=no ./bootstrap
-	popd
-}
+checksum=9f26f14aa322e3cf38a71835b12ac34b23026b467f74d54b064c5d025e76fbfd
 
 do_configure() {
-	# set variables in sage.env since we do not install sage_conf
-	cat >> sage/env.py <<-EOF
-	CONWAY_POLYNOMIALS_DATA_DIR = "/usr/share/sagemath/conway_polynomials"
-	GRAPHS_DATA_DIR = "/usr/share/sagemath/graphs"
-	ELLCURVE_DATA_DIR = "/usr/share/sagemath/ellcurves"
-	POLYTOPE_DATA_DIR = "/usr/share/sagemath/reflexive_polytopes"
-	COMBINATORIAL_DESIGN_DATA_DIR = "/usr/share/sagemath/combinatorial_designs"
-	CREMONA_MINI_DATA_DIR = "/usr/share/sagemath/cremona"
-	CREMONA_LARGE_DATA_DIR = "/usr/share/sagemath/cremona"
-	THREEJS_DIR = "/usr/share/sagemath/threejs-sage"
-	EOF
-
-	# don't install sage-venv-config: it is used to set SAGE_VENV=/usr and
-	# then sage-env prepends "$SAGE_VENV/bin" to PATH which is undesired
-	vsed -e '/sage-venv-config/d' -i $wrksrc/src/setup.cfg
+	# git tree needs bootstrapping
+	( cd $wrksrc/build/pkgs/sagelib &&
+	  PATH=../../bin:$PATH \
+	  BOOTSTRAP_QUIET=no \
+	  ./bootstrap )
 }
 
 pre_build() {
 	export PYTHONPATH=../sage-setup
+	export PYTHONDONTWRITEBYTECODE=yes
 	export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
 }
 
 post_build() {
+	_lib=$(cd build/lib* && pwd)
 	_scripts=$(cd build/scripts* && pwd)
-	cat >> $_scripts/sage-env-config <<-'EOF'
-	PATH=$(dirname $SELF):$PATH
-	EOF
+
+	# configuration files
+	cp ${FILESDIR}/sage_conf.py $_lib
+	cp ${FILESDIR}/sage-env-config $_scripts
 }
 
 pre_install() {
 	export PYTHONPATH=../sage-setup
+	export PYTHONDONTWRITEBYTECODE=yes
 	export SAGE_NUM_THREADS="$XBPS_MAKEJOBS"
 }
 
 post_install() {
 	# fix jupyter kernel spec
-	vsed -i -e 's|"/usr/bin/sage", "--python"|"/usr/bin/python"|' \
+	vsed -i -e 's|"/usr/bin/sage"|"'${_bindir}'/sage"|' \
 		${DESTDIR}/usr/share/jupyter/kernels/sagemath/kernel.json
+
 	# replace broken symlinks by good copies (sagemath logo images)
 	for file in $(ls sage/ext_data/notebook-ipython); do
 		rm ${DESTDIR}/usr/share/jupyter/kernels/sagemath/$file
 		cp -a sage/ext_data/notebook-ipython/$file \
 			${DESTDIR}/usr/share/jupyter/kernels/sagemath
 	done
+
 	# we don't have docs here
 	rm ${DESTDIR}/usr/share/jupyter/kernels/sagemath/doc
-	# we don't have threejs in void
+	# this symlink is shipped in threejs-sage pkg
 	rm ${DESTDIR}/usr/share/jupyter/nbextensions/threejs-sage
 
 	# symlink main binary
@@ -102,14 +88,17 @@ post_install() {
 }
 
 do_check() {
+	_lib=$(cd build/lib* && pwd)
 	_scripts=$(cd build/scripts* && pwd)
-	export PYTHONPATH=$(cd build/lib* && pwd)
+
+	export PYTHONPATH=$_lib
+	export PYTHONDONTWRITEBYTECODE=yes
 
 	# get out of $build_wrksrc, otherwise python picks the wrong sage module
 	cd $(mktemp -dp build)
 
 	if [ -f ${XBPS_DISTDIR}/sagemath-check ] ; then
-		_sed='s|#.*||;/^\s*$/d;s|[^ ]*/sage/|'$PYTHONPATH'/sage/|g' \
+		_sed='s|#.*||;/^\s*$/d;s|^\([^ ]*/\)\?sage/|'$_lib'/sage/|g' \
 		_test_files=$(sed -e "$_sed" ${XBPS_DISTDIR}/sagemath-check)
 	fi
 	if [ -z "$_test_files" ]; then

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: sagemath: update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (24 preceding siblings ...)
  2022-10-30 22:06 ` [PR PATCH] [Updated] " tornaria
@ 2022-10-30 23:37 ` tornaria
  2022-10-31 11:56 ` tornaria
                   ` (6 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: tornaria @ 2022-10-30 23:37 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 419 bytes --]

New comment by tornaria on void-packages repository

https://github.com/void-linux/void-packages/pull/39876#issuecomment-1296379699

Comment:
I added the update of `python3-cypari2` to 2.1.3, which seems it will be necessary to support python 3.11.

However, I'm not being able to even start sage (no solution available yet, see https://trac.sagemath.org/ticket/33842#comment:48). This is a major showstopper for me.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: sagemath: update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (25 preceding siblings ...)
  2022-10-30 23:37 ` tornaria
@ 2022-10-31 11:56 ` tornaria
  2022-10-31 14:40 ` dkwo
                   ` (5 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: tornaria @ 2022-10-31 11:56 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1042 bytes --]

New comment by tornaria on void-packages repository

https://github.com/void-linux/void-packages/pull/39876#issuecomment-1296980145

Comment:
Just as a summary of the situation wrt to python 3.11 for @ahesford :
 - it seems sage is completely broken on python 3.11: it compiles but it doesn't start
 - sage depends on a custom implementation of `WeakValueDictionary` (the one in python `weakref` module is not good for several reasons discussed in https://trac.sagemath.org/ticket/13394)
 - the dict layout changed in 3.11 breaking everything
 - the whole thing hangs in a single low-level function which will have to be rewritten (https://git.sagemath.org/sage.git/tree/src/sage/cpython/dict_del_by_value.pyx?h=9.7#n131)
 - after this, the rest seems close enough, see starting at https://trac.sagemath.org/ticket/33842#comment:62

All of this does not affect the current PR with python 3.10. It would be nice to have it merged since having all the updated packages in the main repo makes it easier to work on they python 3.11 fixes.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: sagemath: update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (26 preceding siblings ...)
  2022-10-31 11:56 ` tornaria
@ 2022-10-31 14:40 ` dkwo
  2022-10-31 15:27 ` [PR PATCH] [Closed]: " ahesford
                   ` (4 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: dkwo @ 2022-10-31 14:40 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 208 bytes --]

New comment by dkwo on void-packages repository

https://github.com/void-linux/void-packages/pull/39876#issuecomment-1297192219

Comment:
> It would be nice to have it merged

I agree, for various reasons.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PR PATCH] [Closed]: sagemath: update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (27 preceding siblings ...)
  2022-10-31 14:40 ` dkwo
@ 2022-10-31 15:27 ` ahesford
  2022-10-31 15:37 ` ahesford
                   ` (3 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: ahesford @ 2022-10-31 15:27 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 2247 bytes --]

There's a closed pull request on the void-packages repository

sagemath: update to 9.7
https://github.com/void-linux/void-packages/pull/39876

Description:
[EDIT] this ticket includes:
 - updates to flintlib, arb, singular, pari, gp2c, eclib, giac, gap (all those require recompilation of sagemath)
 - revbump for lcalc, python3-cysignals, python3-cypari2 b/c the soname change for libpari

Everything seems to be working ok, this is now ready for merging.

----

With respect to the original description:
 - #39838, #39840, #39872 are already merged.
 - #39846 is not included here as it won't force rebuild
 - #39866 was moved here
 - matplotlib 3.6.1 is working now

----

This includes #39838, #39840, #39846, #39872, #39866, also update eclib-20220621.

For now I'm reverting python3-matplotlib to 3.5.3_1 since 3.6.0_1 gives a lot of problems (#39857 adds python3-contourpy which will solve some, but I think there are more issues).

I want to make sure everything works ok and the full testsuite passes as is. Then I'll just move matplotlib back to 3.6.0_1 and try to see if it's feasible to fix or workaround the issues (sagemath-the-distro is still on matplotlib 3.5.2 and I didn't find anything about the update to 3.6.0)

<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: currently running the testsuite in --long after the update of singular.

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: sagemath: update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (28 preceding siblings ...)
  2022-10-31 15:27 ` [PR PATCH] [Closed]: " ahesford
@ 2022-10-31 15:37 ` ahesford
  2022-10-31 20:30 ` tornaria
                   ` (2 subsequent siblings)
  32 siblings, 0 replies; 34+ messages in thread
From: ahesford @ 2022-10-31 15:37 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 576 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/39876#issuecomment-1297276791

Comment:
OK, time to focus on getting this ready for Python 3.11.

@tornaria if there is no more obvious fix in the next week, I'm tempted to pull your no-op delete patch in https://trac.sagemath.org/ticket/33842#comment:63. It seems the only side-effect of this patch is that stale weakrefs will persist in the dictionary. Those refs are checked when items are accessed so it should be harmless except for some wasted memory. What say you?

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: sagemath: update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (29 preceding siblings ...)
  2022-10-31 15:37 ` ahesford
@ 2022-10-31 20:30 ` tornaria
  2022-11-03 13:36 ` tornaria
  2022-11-03 13:59 ` ahesford
  32 siblings, 0 replies; 34+ messages in thread
From: tornaria @ 2022-10-31 20:30 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 766 bytes --]

New comment by tornaria on void-packages repository

https://github.com/void-linux/void-packages/pull/39876#issuecomment-1297645574

Comment:
> OK, time to focus on getting this ready for Python 3.11.
> 
> @tornaria if there is no more obvious fix in the next week, I'm tempted to pull your no-op delete patch in https://trac.sagemath.org/ticket/33842#comment:63. It seems the only side-effect of this patch is that stale weakrefs will persist in the dictionary. Those refs are checked when items are accessed so it should be harmless except for some wasted memory. What say you?

Not completely unreasonable. Let me try to cook up a PR to fix the rest of the issues (there are lots of issues but none look very bad at first sight, I'm already done with a few).

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: sagemath: update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (30 preceding siblings ...)
  2022-10-31 20:30 ` tornaria
@ 2022-11-03 13:36 ` tornaria
  2022-11-03 13:59 ` ahesford
  32 siblings, 0 replies; 34+ messages in thread
From: tornaria @ 2022-11-03 13:36 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 357 bytes --]

New comment by tornaria on void-packages repository

https://github.com/void-linux/void-packages/pull/39876#issuecomment-1302126771

Comment:
@ahesford: I think I have a fix using standard python api. I'll soon make a PR after I finish testing and can clean up a bit, if you want to stick to your schedule for python 3.11, I think we will be able to do it.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: sagemath: update to 9.7
  2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
                   ` (31 preceding siblings ...)
  2022-11-03 13:36 ` tornaria
@ 2022-11-03 13:59 ` ahesford
  32 siblings, 0 replies; 34+ messages in thread
From: ahesford @ 2022-11-03 13:59 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 364 bytes --]

New comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/39876#issuecomment-1302156907

Comment:
Thanks. I'm planning to start the rebuild around 1300 UTC on Saturday, 5 Nov. The whole process should take 2--3 days. As long as your fixes are ready in the next five days or so, we can support sage without interruption.

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2022-11-03 13:59 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-10 22:19 [PR PATCH] DRAFT: sagemath update to 9.7 tornaria
2022-10-11 12:58 ` tornaria
2022-10-11 13:51 ` dkwo
2022-10-11 14:33 ` ahesford
2022-10-11 19:13 ` tornaria
2022-10-11 19:23 ` ahesford
2022-10-11 21:35 ` [PR PATCH] [Updated] " tornaria
2022-10-11 21:37 ` tornaria
2022-10-12 14:46 ` [PR PATCH] [Updated] " tornaria
2022-10-12 18:18 ` dkwo
2022-10-12 18:18 ` dkwo
2022-10-12 20:17 ` tornaria
2022-10-12 22:02 ` dkwo
2022-10-13  3:15 ` [PR PATCH] [Updated] " tornaria
2022-10-13 14:03 ` tornaria
2022-10-14 20:11 ` tornaria
2022-10-16  1:52 ` tornaria
2022-10-17  4:51 ` tornaria
2022-10-29  2:30 ` tornaria
2022-10-29 11:02 ` tornaria
2022-10-29 11:12 ` ahesford
2022-10-29 12:16 ` [PR PATCH] [Updated] " tornaria
2022-10-29 16:55 ` tornaria
2022-10-29 16:58 ` sagemath: " tornaria
2022-10-30 17:09 ` tornaria
2022-10-30 22:06 ` [PR PATCH] [Updated] " tornaria
2022-10-30 23:37 ` tornaria
2022-10-31 11:56 ` tornaria
2022-10-31 14:40 ` dkwo
2022-10-31 15:27 ` [PR PATCH] [Closed]: " ahesford
2022-10-31 15:37 ` ahesford
2022-10-31 20:30 ` tornaria
2022-11-03 13:36 ` tornaria
2022-11-03 13:59 ` ahesford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).