Github messages for voidlinux
 help / color / mirror / Atom feed
From: tornaria <tornaria@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] DRAFT: sagemath update to 9.7
Date: Mon, 17 Oct 2022 06:51:40 +0200	[thread overview]
Message-ID: <20221017045140.p61jwwTPaaDD5GRsQnPjgbl3ApBeWFNDK7QGf94TId0@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-39876@inbox.vuxu.org>

[-- 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
 }
 

  parent reply	other threads:[~2022-10-17  4:51 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-10 22:19 [PR PATCH] " 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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221017045140.p61jwwTPaaDD5GRsQnPjgbl3ApBeWFNDK7QGf94TId0@z \
    --to=tornaria@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).