Github messages for voidlinux
 help / color / mirror / Atom feed
* Re: [PR PATCH] [Updated] [WIP] flintlib: update to 3.0.0.
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
@ 2023-10-26 12:12 ` tornaria
  2023-10-29 16:05 ` dkwo
                   ` (27 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: tornaria @ 2023-10-26 12:12 UTC (permalink / raw)
  To: ml

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

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

https://github.com/tornaria/void-packages flintlib
https://github.com/void-linux/void-packages/pull/46832

[WIP] flintlib: update to 3.0.0.
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **briefly**

This is a major update. A couple of packages need rebuilding (eclib, singular).

For sagemath, we need a patch (in progress: https://github.com/sagemath/sage/pull/35848).

Since backporting patches is a pain and we are not in a hurry, I'm instead targeting 10.2.beta8. Note this already moves sagemath to cython 3.

The goal is to merge flintlib 3.0 together with sagemath 10.2 when the latter is released.

<!--
#### 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/46832.patch is attached

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

From 3005e2f7829a601621b76ec63d78095622cb3ca0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 11 Sep 2023 20:11:20 -0300
Subject: [PATCH 1/6] flintlib: update to 3.0.0.

---
 common/shlibs                                 |  3 +-
 srcpkgs/arb                                   |  1 +
 srcpkgs/arb-devel                             |  2 +-
 srcpkgs/arb/template                          | 24 ------------
 .../patches/1545-fix_openblas_detection.patch | 32 ++++++++++++++++
 ...6723b1d74e66605c111483756322ebb1bc8d.patch | 37 +++++++++++++++++++
 .../patches/fix-test-t-sdiv_qrnnd.patch       | 23 ------------
 srcpkgs/flintlib/template                     | 29 ++++++++++++---
 8 files changed, 96 insertions(+), 55 deletions(-)
 create mode 120000 srcpkgs/arb
 delete mode 100644 srcpkgs/arb/template
 create mode 100644 srcpkgs/flintlib/patches/1545-fix_openblas_detection.patch
 create mode 100644 srcpkgs/flintlib/patches/1546-fix_nmod32_in_i686-7d046723b1d74e66605c111483756322ebb1bc8d.patch
 delete mode 100644 srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch

diff --git a/common/shlibs b/common/shlibs
index 67e0812c68e19..5163c82a922a8 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3972,8 +3972,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.17 flintlib-2.9.0_1
-libarb.so.2 arb-2.20.0_1
+libflint.so.18 flintlib-3.0.0_1
 libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
diff --git a/srcpkgs/arb b/srcpkgs/arb
new file mode 120000
index 0000000000000..7c2633183069f
--- /dev/null
+++ b/srcpkgs/arb
@@ -0,0 +1 @@
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb-devel b/srcpkgs/arb-devel
index 456b9f00a86cd..7c2633183069f 120000
--- a/srcpkgs/arb-devel
+++ b/srcpkgs/arb-devel
@@ -1 +1 @@
-arb
\ No newline at end of file
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
deleted file mode 100644
index 84a62c7ffdba3..0000000000000
--- a/srcpkgs/arb/template
+++ /dev/null
@@ -1,24 +0,0 @@
-# Template file for 'arb'
-pkgname=arb
-version=2.23.0
-revision=1
-build_style=configure
-configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
-makedepends="flintlib-devel"
-short_desc="C library for arbitrary-precision interval arithmetic"
-maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
-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=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
-
-arb-devel_package() {
-	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"
-	short_desc+=" - development files"
-	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.a"
-		vmove "usr/lib/*.so"
-	}
-}
diff --git a/srcpkgs/flintlib/patches/1545-fix_openblas_detection.patch b/srcpkgs/flintlib/patches/1545-fix_openblas_detection.patch
new file mode 100644
index 0000000000000..133e93eb07341
--- /dev/null
+++ b/srcpkgs/flintlib/patches/1545-fix_openblas_detection.patch
@@ -0,0 +1,32 @@
+From d818f171ec1907d815bbf7ccbb80968ca5a024ec Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Fri, 20 Oct 2023 18:56:58 -0300
+Subject: [PATCH] Fix use of AC_SEARCH_LIBS to find cblas_dgemm
+
+Without this change, configure only tries with `-lcblas` since
+`AC_SEARCH_LIBS` caches the result based on function name.
+---
+ configure.ac | 8 ++------
+ 1 file changed, 2 insertions(+), 6 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 84ba9de832..676e5ff886 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -705,14 +705,10 @@ fi
+ 
+ if test "$with_blas" = "yes";
+ then
+-    AC_SEARCH_LIBS([cblas_dgemm],[cblas],[],
+-        [AC_SEARCH_LIBS([cblas_dgemm],[openblas],[],
+-            [AC_SEARCH_LIBS([cblas_dgemm],[blas],[],
+-                [AC_MSG_ERROR([BLAS library was not found.  If you indeed have BLAS installed, please
++    AC_SEARCH_LIBS([cblas_dgemm],[cblas openblas blas],[],
++        [AC_MSG_ERROR([BLAS library was not found.  If you indeed have BLAS installed, please
+ submit a bug report to <https://github.com/flintlib/flint/issues/> so
+ that we can either fix the issue or give a more proper error message.])]
+-            )]
+-        )]
+     )
+ fi
+ 
diff --git a/srcpkgs/flintlib/patches/1546-fix_nmod32_in_i686-7d046723b1d74e66605c111483756322ebb1bc8d.patch b/srcpkgs/flintlib/patches/1546-fix_nmod32_in_i686-7d046723b1d74e66605c111483756322ebb1bc8d.patch
new file mode 100644
index 0000000000000..f98882112f3f8
--- /dev/null
+++ b/srcpkgs/flintlib/patches/1546-fix_nmod32_in_i686-7d046723b1d74e66605c111483756322ebb1bc8d.patch
@@ -0,0 +1,37 @@
+From 7d046723b1d74e66605c111483756322ebb1bc8d Mon Sep 17 00:00:00 2001
+From: Fredrik Johansson <fredrik.johansson@gmail.com>
+Date: Sat, 21 Oct 2023 13:43:37 +0200
+Subject: [PATCH] fix nmod32 on 32-bit systems
+
+---
+ src/gr/nmod32.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/src/gr/nmod32.c b/src/gr/nmod32.c
+index fde79822ac..31ee4e0184 100644
+--- a/src/gr/nmod32.c
++++ b/src/gr/nmod32.c
+@@ -325,7 +325,11 @@ _nmod32_vec_add(nmod32_struct * res, const nmod32_struct * vec1, const nmod32_st
+     nmod_t mod = NMOD32_CTX(ctx);
+ 
+     for (i = 0; i < len; i++)
++#if FLINT_BITS == 64
+         res[i] = _nmod_add(vec1[i], vec2[i], mod);
++#else
++        res[i] = nmod_add(vec1[i], vec2[i], mod);
++#endif
+ 
+     return GR_SUCCESS;
+ }
+@@ -337,7 +341,11 @@ _nmod32_vec_sub(nmod32_struct * res, const nmod32_struct * vec1, const nmod32_st
+     nmod_t mod = NMOD32_CTX(ctx);
+ 
+     for (i = 0; i < len; i++)
++#if FLINT_BITS == 64
++        res[i] = _nmod_sub(vec1[i], vec2[i], mod);
++#else
+         res[i] = nmod_sub(vec1[i], vec2[i], mod);
++#endif
+ 
+     return GR_SUCCESS;
+ }
diff --git a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch b/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
deleted file mode 100644
index cfa109792892c..0000000000000
--- a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From fb8ddbcc06afa2a8f25637032fbb8211f6c6c122 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= <albin.ahlback@gmail.com>
-Date: Fri, 20 May 2022 14:16:38 +0200
-Subject: [PATCH] Fix bug in test code for GCC 12
-
----
- test/t-sdiv_qrnnd.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/test/t-sdiv_qrnnd.c b/test/t-sdiv_qrnnd.c
-index 2e9822e848..2676903826 100644
---- a/test/t-sdiv_qrnnd.c
-+++ b/test/t-sdiv_qrnnd.c
-@@ -33,7 +33,7 @@ int main(void)
-         {
-             d = n_randtest_not_zero(state);
-             nh = n_randtest(state);
--        } while ((FLINT_ABS(nh) >= FLINT_ABS(d)/2) || (nh == WORD_MIN));
-+        } while ((nh == WORD_MIN) || (FLINT_ABS(nh) >= FLINT_ABS(d)/2));
- 
-         nl = n_randtest(state);
- 
-
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index f7442c8052aaa..845ed41e25960 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,10 +1,11 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.9.0
+version=3.0.0
 revision=1
-build_style=configure
+build_style=gnu-configure
 configure_args="--prefix=/usr $(vopt_with ntl)
- $(vopt_if openblas --with-blas=${XBPS_CROSS_BASE}/usr/include/openblas)"
+ $(vopt_if openblas --with-blas-include=${XBPS_CROSS_BASE}/usr/include/openblas)"
+hostmakedepends="automake gettext-devel libtool"
 makedepends="mpfr-devel $(vopt_if ntl ntl-devel)
  $(vopt_if openblas openblas-devel)"
 short_desc="Fast Library for Number Theory"
@@ -12,8 +13,8 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 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=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
+distfiles="https://flintlib.org/flint-${version/.alpha/-alpha}.tar.gz"
+checksum=b9086e31e3dab89896d7edbf05a5b758d5b4b72183a1a3478f23eabdcaaae044
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
@@ -28,12 +29,30 @@ esac
 
 CFLAGS="-D_GNU_SOURCE" # needed for cpu_set_t
 
+post_patch() {
+	# run autoconf because we patched configure.ac
+	autoreconf
+}
+
 flintlib-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision} mpfr-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
+		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
 		vmove "usr/lib/*.so"
 	}
 }
+
+arb_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}
+
+arb-devel_package() {
+	depends="${sourcepkg}-devel>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From 1590a13d93cbb5a43f51483eba449013d82e778c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:08:05 -0300
Subject: [PATCH 2/6] eclib: rebuild for flintlib-3.0.0

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

diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 1d4ad58f21b7b..12165ca788dd5 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
 version=20230424
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 makedepends="pari-devel ntl-devel flintlib-devel boost-devel"

From 90e6b55c73c3a80340a57770ea3e8ada36a66092 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:13:15 -0300
Subject: [PATCH 3/6] singular: update to 4.3.2p9 (patch for flintlib-3.0.0).

---
 .../singular/patches/1197-fix_includes.patch  | 87 +++++++++++++++++++
 srcpkgs/singular/template                     |  4 +-
 2 files changed, 89 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/singular/patches/1197-fix_includes.patch

diff --git a/srcpkgs/singular/patches/1197-fix_includes.patch b/srcpkgs/singular/patches/1197-fix_includes.patch
new file mode 100644
index 0000000000000..5aebbfadf8d79
--- /dev/null
+++ b/srcpkgs/singular/patches/1197-fix_includes.patch
@@ -0,0 +1,87 @@
+From f0d694f080941825a390ae64334fb4c77b07739a Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Sat, 21 Oct 2023 10:43:39 -0300
+Subject: [PATCH] Add some missing includes
+
+These are needed when building with flint 3.0 and without ntl.
+---
+ factory/FLINTconvert.h    | 1 +
+ factory/cfModGcd.cc       | 1 +
+ factory/cfModResultant.cc | 1 +
+ factory/facFqBivar.cc     | 1 +
+ factory/facFqFactorize.cc | 1 +
+ factory/facMul.cc         | 1 +
+ 6 files changed, 6 insertions(+)
+
+diff --git a/factory/FLINTconvert.h b/factory/FLINTconvert.h
+index 442fb61046..ec5a56c309 100644
+--- a/factory/FLINTconvert.h
++++ b/factory/FLINTconvert.h
+@@ -45,6 +45,7 @@ extern "C"
+ #endif
+ #if ( __FLINT_RELEASE >= 20700)
+ #include <flint/fq_nmod_mpoly_factor.h>
++#include <flint/fmpz_mod.h>
+ #endif
+ #endif
+ 
+diff --git a/factory/cfModGcd.cc b/factory/cfModGcd.cc
+index 435a663368..12cff69391 100644
+--- a/factory/cfModGcd.cc
++++ b/factory/cfModGcd.cc
+@@ -22,6 +22,7 @@
+ 
+ #include "config.h"
+ 
++#include <math.h>
+ 
+ #include "cf_assert.h"
+ #include "debug.h"
+diff --git a/factory/cfModResultant.cc b/factory/cfModResultant.cc
+index 601a15394a..c1060b6125 100644
+--- a/factory/cfModResultant.cc
++++ b/factory/cfModResultant.cc
+@@ -13,6 +13,7 @@
+ 
+ #include "config.h"
+ 
++#include <math.h>
+ 
+ #include "cf_assert.h"
+ #include "timing.h"
+diff --git a/factory/facFqBivar.cc b/factory/facFqBivar.cc
+index 7a1127c392..7d3ae84385 100644
+--- a/factory/facFqBivar.cc
++++ b/factory/facFqBivar.cc
+@@ -19,6 +19,7 @@
+ 
+ #include "config.h"
+ 
++#include <math.h>
+ 
+ #include "cf_assert.h"
+ #include "cf_util.h"
+diff --git a/factory/facFqFactorize.cc b/factory/facFqFactorize.cc
+index 6b35b64094..6cb91fd532 100644
+--- a/factory/facFqFactorize.cc
++++ b/factory/facFqFactorize.cc
+@@ -18,6 +18,7 @@
+ 
+ #include "config.h"
+ 
++#include <math.h>
+ 
+ #include "cf_assert.h"
+ #include "debug.h"
+diff --git a/factory/facMul.cc b/factory/facMul.cc
+index 79077046be..08d09ccdf8 100644
+--- a/factory/facMul.cc
++++ b/factory/facMul.cc
+@@ -22,6 +22,7 @@
+ 
+ #include "config.h"
+ 
++#include <math.h>
+ 
+ #include "canonicalform.h"
+ #include "facMul.h"
diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index 036e19d470354..96ff3e3967e01 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,6 +1,6 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.2p7
+version=4.3.2p9
 revision=1
 _majver=${version%p*}
 build_style=gnu-configure
@@ -20,7 +20,7 @@ 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/${_majver//./-}/singular-${version}.tar.gz"
-checksum=aad23c30066b7fbc011138a98d60532565d76a847eec6bf2938410d93b272ca3
+checksum=f3201c348291e4352979d4ff612f37bf8b3f6b72dedde5d1f293bab3f5b22ee1
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From 433543ee81ddc5497175c10998d01139366f994d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 19 Jul 2023 21:04:33 -0300
Subject: [PATCH 4/6] python3-pplpy: use cython 3.

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

diff --git a/srcpkgs/python3-pplpy/template b/srcpkgs/python3-pplpy/template
index 4a9c987b2a859..d3b9aebdf2237 100644
--- a/srcpkgs/python3-pplpy/template
+++ b/srcpkgs/python3-pplpy/template
@@ -1,9 +1,9 @@
 # Template file for 'python3-pplpy'
 pkgname=python3-pplpy
 version=0.8.9
-revision=1
+revision=2
 build_style=python3-pep517
-hostmakedepends="python3-setuptools python3-wheel python3-Cython0.29
+hostmakedepends="python3-setuptools python3-wheel python3-Cython
  python3-cysignals python3-gmpy2"
 makedepends="python3-devel gmp-devel gmpxx-devel ppl-devel mpfr-devel
  libmpc-devel pari-devel"

From f7bdb70813849dfbf90ff3484a90208c545cfbb3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Thu, 19 Oct 2023 08:52:15 -0300
Subject: [PATCH 5/6] python3-networkx: update to 3.2.

---
 srcpkgs/python3-networkx/template | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/python3-networkx/template b/srcpkgs/python3-networkx/template
index 186bf64f7bff9..8e202ba52bc46 100644
--- a/srcpkgs/python3-networkx/template
+++ b/srcpkgs/python3-networkx/template
@@ -1,11 +1,11 @@
 # Template file for 'python3-networkx'
 pkgname=python3-networkx
-version=3.1
-revision=2
-build_style=python3-module
+version=3.2
+revision=1
+build_style=python3-pep517
 # failing in i686
 make_check_args="--deselect networkx/algorithms/approximation/tests/test_traveling_salesman.py::test_asadpour_tsp"
-hostmakedepends="python3-setuptools"
+hostmakedepends="python3-setuptools python3-wheel"
 depends="python3"
 checkdepends="python3-numpy python3-scipy python3-matplotlib python3-pandas
  python3-lxml python3-sympy python3-pytest-xdist"
@@ -15,7 +15,7 @@ license="BSD-3-Clause"
 homepage="https://networkx.org"
 changelog="https://github.com/networkx/networkx/raw/main/doc/release/release_${version}.rst"
 distfiles="${PYPI_SITE}/n/networkx/networkx-${version}.tar.gz"
-checksum=de346335408f84de0eada6ff9fafafff9bcda11f0a0dfaa931133debb146ab61
+checksum=bda29edf392d9bfa5602034c767d28549214ec45f620081f0b74dc036a1fbbc1
 
 post_install() {
 	vlicense LICENSE.txt

From 43db4462e63fc5b63612a85ee82885a2f7b01901 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:50:44 -0300
Subject: [PATCH 6/6] sagemath: update to 10.2.beta8 (patch for
 flintlib-3.0.0).

---
 .../sagemath/patches/35848-flintlib_3.0.patch | 1738 ++++++++++++++++
 .../patches/35934-singular_4.3.2p7.patch      |  221 ---
 .../sagemath/patches/36006-gmp_6.3.0.patch    |   38 -
 .../patches/36046-fix_memory_leak.patch       |  740 -------
 .../sagemath/patches/36235-ecl_23.9.9.patch   |   39 -
 .../patches/36279-matplotlib_3.8.0.patch      |   24 -
 srcpkgs/sagemath/patches/36403-00pre.patch    |   29 -
 .../sagemath/patches/36407-python_3.12.patch  | 1744 -----------------
 .../sagemath/patches/36506-notebook_7.patch   |   18 +
 .../sagemath/patches/36544-networkx_3.2.patch |   41 +
 srcpkgs/sagemath/patches/get_patches          |   23 +-
 srcpkgs/sagemath/template                     |   12 +-
 12 files changed, 1807 insertions(+), 2860 deletions(-)
 create mode 100644 srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
 delete mode 100644 srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
 delete mode 100644 srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
 delete mode 100644 srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36403-00pre.patch
 delete mode 100644 srcpkgs/sagemath/patches/36407-python_3.12.patch
 create mode 100644 srcpkgs/sagemath/patches/36506-notebook_7.patch
 create mode 100644 srcpkgs/sagemath/patches/36544-networkx_3.2.patch

diff --git a/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
new file mode 100644
index 0000000000000..ed3d6d1913433
--- /dev/null
+++ b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
@@ -0,0 +1,1738 @@
+diff --git a/build/pkgs/antic/SPKG.rst b/build/pkgs/antic/SPKG.rst
+deleted file mode 100644
+index d6c32377957..00000000000
+--- a/build/pkgs/antic/SPKG.rst
++++ /dev/null
+@@ -1,18 +0,0 @@
+-antic: Algebraic Number Theory In C
+-===================================
+-
+-Description
+------------
+-
+-Algebraic Number Theory In C
+-
+-License
+--------
+-
+-LGPL 2.1
+-
+-Upstream Contact
+-----------------
+-
+-https://github.com/wbhart/antic
+-
+diff --git a/build/pkgs/antic/checksums.ini b/build/pkgs/antic/checksums.ini
+deleted file mode 100644
+index fc8711ecd13..00000000000
+--- a/build/pkgs/antic/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=antic-VERSION.tar.gz
+-sha1=940d8ea2c3512b9d49ee3101cf043f777764bd8f
+-md5=4e896420dd6344b53b307871efb2cbb4
+-cksum=1938565125
+-upstream_url=https://github.com/wbhart/antic/archive/refs/tags/vVERSION.tar.gz
+diff --git a/build/pkgs/antic/dependencies b/build/pkgs/antic/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/antic/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/antic/distros/arch.txt b/build/pkgs/antic/distros/arch.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/conda.txt b/build/pkgs/antic/distros/conda.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/debian.txt b/build/pkgs/antic/distros/debian.txt
+deleted file mode 100644
+index 8fdcd3e5721..00000000000
+--- a/build/pkgs/antic/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libantic-dev
+diff --git a/build/pkgs/antic/distros/fedora.txt b/build/pkgs/antic/distros/fedora.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/freebsd.txt b/build/pkgs/antic/distros/freebsd.txt
+deleted file mode 100644
+index 116ff3a26f3..00000000000
+--- a/build/pkgs/antic/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/antic
+diff --git a/build/pkgs/antic/distros/opensuse.txt b/build/pkgs/antic/distros/opensuse.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/repology.txt b/build/pkgs/antic/distros/repology.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/package-version.txt b/build/pkgs/antic/package-version.txt
+deleted file mode 100644
+index 3a4036fb450..00000000000
+--- a/build/pkgs/antic/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-0.2.5
+diff --git a/build/pkgs/antic/spkg-install.in b/build/pkgs/antic/spkg-install.in
+deleted file mode 100644
+index c57fa884a20..00000000000
+--- a/build/pkgs/antic/spkg-install.in
++++ /dev/null
+@@ -1,19 +0,0 @@
+-cd src
+-
+-# Copied from build/pkgs/flint/spkg-install.in:
+-#   Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-#   --with-ntl because otherwise FLINT's configure script uses
+-#   /usr/local, which is always wrong.
+-#   This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-#   The value $SAGE_LOCAL is always a safe choice even if the library
+-#   is coming from the system and is found using what is in
+-#   LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-flint="$SAGE_LOCAL"  || sdh_die "Error: Failed to configure antic."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/antic/type b/build/pkgs/antic/type
+deleted file mode 100644
+index 134d9bc32d5..00000000000
+--- a/build/pkgs/antic/type
++++ /dev/null
+@@ -1 +0,0 @@
+-optional
+diff --git a/build/pkgs/arb/SPKG.rst b/build/pkgs/arb/SPKG.rst
+deleted file mode 100644
+index cff49ddb95b..00000000000
+--- a/build/pkgs/arb/SPKG.rst
++++ /dev/null
+@@ -1,27 +0,0 @@
+-arb: Arbitrary-precision floating-point ball arithmetic
+-=======================================================
+-
+-Description
+------------
+-
+-Arb is a C library for arbitrary-precision floating-point ball
+-arithmetic, developed by Fredrik Johansson
+-(fredrik.johansson@gmail.com). It supports efficient high-precision
+-computation with polynomials, power series, matrices and special
+-functions over the real and complex numbers, with automatic, rigorous
+-error control.
+-
+-License
+--------
+-
+-GNU General Public License v2+
+-
+-
+-Upstream Contact
+-----------------
+-
+- - Fredrik Johansson: fredrik.johansson@gmail.com
+-
+- - https://arblib.org/
+-
+- - http://github.com/fredrik-johansson/arb/
+diff --git a/build/pkgs/arb/checksums.ini b/build/pkgs/arb/checksums.ini
+deleted file mode 100644
+index 80ef43dad5d..00000000000
+--- a/build/pkgs/arb/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=arb-VERSION.tar.gz
+-sha1=a1efe035dd3af3613dd685971a156f652b86ff63
+-md5=9b369e29f93cdf2d4f90b57a92526cce
+-cksum=64252121
+-upstream_url=https://github.com/fredrik-johansson/arb/archive/VERSION.tar.gz
+diff --git a/build/pkgs/arb/dependencies b/build/pkgs/arb/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/arb/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/arb/distros/arch.txt b/build/pkgs/arb/distros/arch.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/conda.txt b/build/pkgs/arb/distros/conda.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/debian.txt b/build/pkgs/arb/distros/debian.txt
+deleted file mode 100644
+index 9fe71110712..00000000000
+--- a/build/pkgs/arb/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libflint-arb-dev
+diff --git a/build/pkgs/arb/distros/fedora.txt b/build/pkgs/arb/distros/fedora.txt
+deleted file mode 100644
+index 76794404627..00000000000
+--- a/build/pkgs/arb/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb arb-devel
+diff --git a/build/pkgs/arb/distros/freebsd.txt b/build/pkgs/arb/distros/freebsd.txt
+deleted file mode 100644
+index 2ef8c7cec0f..00000000000
+--- a/build/pkgs/arb/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/arb
+diff --git a/build/pkgs/arb/distros/gentoo.txt b/build/pkgs/arb/distros/gentoo.txt
+deleted file mode 100644
+index 58e3d4f8008..00000000000
+--- a/build/pkgs/arb/distros/gentoo.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-sci-mathematics/arb
+diff --git a/build/pkgs/arb/distros/homebrew.txt b/build/pkgs/arb/distros/homebrew.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/homebrew.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/nix.txt b/build/pkgs/arb/distros/nix.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/nix.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/opensuse.txt b/build/pkgs/arb/distros/opensuse.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/distros/repology.txt b/build/pkgs/arb/distros/repology.txt
+deleted file mode 100644
+index 179c9d507e1..00000000000
+--- a/build/pkgs/arb/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-fp
+diff --git a/build/pkgs/arb/distros/void.txt b/build/pkgs/arb/distros/void.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/void.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/package-version.txt b/build/pkgs/arb/package-version.txt
+deleted file mode 100644
+index e9763f6bfed..00000000000
+--- a/build/pkgs/arb/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-2.23.0
+diff --git a/build/pkgs/arb/spkg-check.in b/build/pkgs/arb/spkg-check.in
+deleted file mode 100644
+index 27cd9419538..00000000000
+--- a/build/pkgs/arb/spkg-check.in
++++ /dev/null
+@@ -1,2 +0,0 @@
+-cd src
+-$MAKE check
+diff --git a/build/pkgs/arb/spkg-configure.m4 b/build/pkgs/arb/spkg-configure.m4
+deleted file mode 100644
+index ef2dd0aac4a..00000000000
+--- a/build/pkgs/arb/spkg-configure.m4
++++ /dev/null
+@@ -1,23 +0,0 @@
+-SAGE_SPKG_CONFIGURE([arb], [
+-    AC_REQUIRE([SAGE_SPKG_CONFIGURE_FLINT])
+-    SAGE_ARB_LIBRARY="arb"
+-    AC_MSG_CHECKING([installing flint? ])
+-    if test x$sage_spkg_install_flint = xyes; then
+-        AC_MSG_RESULT([yes; install arb as well])
+-        sage_spkg_install_arb=yes
+-    else
+-        AC_CHECK_HEADER(arb.h, [
+-        dnl below function added in version 2.16 of arb
+-            AC_CHECK_LIB([arb], [acb_mat_eig_simple], [],
+-              [dnl in Debian the name of dylib is different.
+-               AC_CHECK_LIB([flint-arb], [acb_mat_eig_simple],
+-                [SAGE_ARB_LIBRARY="flint-arb"], [sage_spkg_install_arb=yes])])
+-        ], [sage_spkg_install_arb=yes])
+-    fi
+-], [], [], [
+-    if test x$sage_spkg_install_arb = xyes; then
+-        AC_SUBST(SAGE_ARB_LIBRARY,["arb"])
+-    else
+-        AC_SUBST(SAGE_ARB_LIBRARY,[$SAGE_ARB_LIBRARY])
+-    fi
+-])
+diff --git a/build/pkgs/arb/spkg-install.in b/build/pkgs/arb/spkg-install.in
+deleted file mode 100644
+index 9322f04c912..00000000000
+--- a/build/pkgs/arb/spkg-install.in
++++ /dev/null
+@@ -1,17 +0,0 @@
+-cd src
+-
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-flint because otherwise ARB's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure --disable-static --prefix="$SAGE_LOCAL" \
+-        --with-gmp="$SAGE_LOCAL" \
+-        --with-mpfr="$SAGE_LOCAL" \
+-        --with-flint="$SAGE_LOCAL" || \
+-    sdh_die "Error configuring arb."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/arb/type b/build/pkgs/arb/type
+deleted file mode 100644
+index a6a7b9cd726..00000000000
+--- a/build/pkgs/arb/type
++++ /dev/null
+@@ -1 +0,0 @@
+-standard
+diff --git a/build/pkgs/e_antic/dependencies b/build/pkgs/e_antic/dependencies
+index fea1ffbda45..8e977a55c13 100644
+--- a/build/pkgs/e_antic/dependencies
++++ b/build/pkgs/e_antic/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) flint arb antic boost_cropped
++$(MP_LIBRARY) flint boost_cropped
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/SPKG.rst b/build/pkgs/flint/SPKG.rst
+index f91de70d1ff..d9dcea0903b 100644
+--- a/build/pkgs/flint/SPKG.rst
++++ b/build/pkgs/flint/SPKG.rst
+@@ -4,8 +4,8 @@ flint: Fast Library for Number Theory
+ Description
+ -----------
+ 
+-FLINT is a C library for doing number theory, maintained by William
+-Hart.
++FLINT is a C library for doing number theory, maintained by
++Fredrik Johansson.
+ 
+ Website: http://www.flintlib.org
+ 
+@@ -20,4 +20,4 @@ Upstream Contact
+ 
+ -  flint-devel Gougle Group
+    (http://groups.google.co.uk/group/flint-devel)
+--  William Hart
++-  Fredrik Johansson
+diff --git a/build/pkgs/flint/checksums.ini b/build/pkgs/flint/checksums.ini
+index 3d449d98064..2cec823bfb1 100644
+--- a/build/pkgs/flint/checksums.ini
++++ b/build/pkgs/flint/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=flint-VERSION.tar.gz
+-sha1=63d90f8242c8f8ab4011fbcfb44b86c154f43abd
+-md5=c2d3cec326438f159a530c66eb07fafe
+-cksum=4244948341
+-upstream_url=http://flintlib.org/flint-VERSION.tar.gz
++sha1=c548b1d5eb86a1805de9bef56629455b61e873f7
++md5=24551d4e475290ce6b831c78fafb5efb
++cksum=1567352998
++upstream_url=https://github.com/flintlib/flint/releases/download/vVERSION/flint-VERSION.tar.gz
+diff --git a/build/pkgs/flint/dependencies b/build/pkgs/flint/dependencies
+index 385df4faa7d..1108dc4fb21 100644
+--- a/build/pkgs/flint/dependencies
++++ b/build/pkgs/flint/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) mpfr ntl
++$(MP_LIBRARY) mpfr
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/package-version.txt b/build/pkgs/flint/package-version.txt
+index c8e38b61405..4a36342fcab 100644
+--- a/build/pkgs/flint/package-version.txt
++++ b/build/pkgs/flint/package-version.txt
+@@ -1 +1 @@
+-2.9.0
++3.0.0
+diff --git a/build/pkgs/flint/spkg-build.in b/build/pkgs/flint/spkg-build.in
+new file mode 100644
+index 00000000000..ffb822c8a97
+--- /dev/null
++++ b/build/pkgs/flint/spkg-build.in
+@@ -0,0 +1,3 @@
++cd src
++sdh_configure
++sdh_make
+diff --git a/build/pkgs/flint/spkg-configure.m4 b/build/pkgs/flint/spkg-configure.m4
+index a58108c9d6e..9576e4cc1e9 100644
+--- a/build/pkgs/flint/spkg-configure.m4
++++ b/build/pkgs/flint/spkg-configure.m4
+@@ -1,25 +1,8 @@
+ SAGE_SPKG_CONFIGURE([flint], [
+-    SAGE_SPKG_DEPCHECK([mpfr ntl], [
++    SAGE_SPKG_DEPCHECK([mpfr], [
+         AC_CHECK_HEADER(flint/flint.h, [
+-          dnl flint_parallel_binary_splitting appears in Flint 2.9.0, needed by arb 2.23
+-          AC_SEARCH_LIBS([flint_parallel_binary_splitting], [flint], [
+-            dnl check that NTL is linked in
+-            AC_SEARCH_LIBS([fmpz_poly_get_ZZX], [flint], [
+-
+-              AC_MSG_CHECKING([that GC is not enabled in Flint... ])
+-              AC_RUN_IFELSE([
+-                 AC_LANG_PROGRAM([[#include <flint/flint.h>]], [
+-                                  [#ifdef HAVE_GC]
+-                                     [return HAVE_GC;]
+-                                  [#else]
+-                                     [return 0;]
+-                                  [#endif]])],
+-                 [AC_MSG_RESULT([GC not enabled. Good.])],
+-                        [AC_MSG_RESULT([GC enabled. Incompatible with Sage.])
+-                         sage_spkg_install_flint=yes],
+-                 [AC_MSG_RESULT(["cross compiling. assuming GC is not enabled"])])
+-            ], [sage_spkg_install_flint=yes])
+-          ], [sage_spkg_install_flint=yes])
++          dnl gr_get_fexpr appears in Flint 3.0
++          AC_SEARCH_LIBS([gr_get_fexpr], [flint], [], [sage_spkg_install_flint=yes])
+         ], [sage_spkg_install_flint=yes])
+     ])
+ ], [], [], [
+diff --git a/build/pkgs/flint/spkg-install.in b/build/pkgs/flint/spkg-install.in
+index eacd7b6e491..3ea8c053669 100644
+--- a/build/pkgs/flint/spkg-install.in
++++ b/build/pkgs/flint/spkg-install.in
+@@ -1,36 +1,2 @@
+-###############################################################################
+-#
+-# FLINT Sage install script
+-#
+-###############################################################################
+-if [ "$SAGE_DEBUG" = "yes" ]; then
+-    echo "Building a debug version of FLINT."
+-    FLINT_TUNE=" $FLINT_TUNE"; export FLINT_TUNE
+-    FLINT_CONFIGURE="--enable-assert $FLINT_CONFIGURE"
+-fi
+-
+ cd src
+-
+-echo "Configuring FLINT."
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-ntl because otherwise FLINT's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-ntl="$SAGE_LOCAL" \
+-    $FLINT_CONFIGURE || sdh_die "Error: Failed to configure FLINT."
+-
+-sdh_make verbose
+-
+-echo "Deleting old FLINT files."
+-rm -f $SAGE_LOCAL/lib/libflint*
+-rm -rf $SAGE_LOCAL/include/flint
+-
+ sdh_make_install
+diff --git a/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+new file mode 100644
+index 00000000000..27a642a13b0
+--- /dev/null
++++ b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+@@ -0,0 +1,53 @@
++From fe730579476de0b2d4181a38efa7f63dff9c81d7 Mon Sep 17 00:00:00 2001
++From: Marc Mezzarobba <marc@mezzarobba.net>
++Date: Tue, 12 Sep 2023 08:23:08 +0200
++Subject: [PATCH] Make msolve build with flint3
++
++---
++ src/fglm/berlekamp_massey.c | 3 +++
++ src/fglm/data_fglm.c        | 7 +++++--
++ 2 files changed, 8 insertions(+), 2 deletions(-)
++
++diff --git a/src/fglm/berlekamp_massey.c b/src/fglm/berlekamp_massey.c
++index b0f2052..998af1c 100644
++--- a/src/fglm/berlekamp_massey.c
+++++ b/src/fglm/berlekamp_massey.c
++@@ -30,6 +30,9 @@
++ */
++ 
++ #include <stdlib.h>
+++#if __FLINT_VERSION >= 3
+++#  include <flint/nmod.h>
+++#endif
++ //#include "nmod_poly.h"
++ //#include "mpn_extras.h"
++ 
++diff --git a/src/fglm/data_fglm.c b/src/fglm/data_fglm.c
++index 0726760..0e1da6f 100644
++--- a/src/fglm/data_fglm.c
+++++ b/src/fglm/data_fglm.c
++@@ -24,6 +24,7 @@
++ #include <flint/mpn_extras.h>
++ #include <flint/nmod_poly.h>
++ #include <flint/nmod_poly_factor.h>
+++#include <flint/ulong_extras.h>
++ 
++ 
++ typedef uint32_t szmat_t;
++@@ -299,9 +300,11 @@ static inline void nmod_poly_set_prime(nmod_poly_t poly,
++   mp_limb_t ninv = n_preinvert_limb(prime);
++   poly->mod.n = prime;
++   poly->mod.ninv = ninv;
+++#if __FLINT_VERSION < 3
++   count_leading_zeros(poly->mod.norm, prime);
++-  /* poly->mod.norm = flint_clz(prime); */
++-
+++#else
+++  poly->mod.norm = flint_clz(prime);
+++#endif
++ }
++ 
++ static inline void fglm_param_set_prime(param_t *param, mp_limb_t prime){
++-- 
++2.40.1
++
+diff --git a/build/pkgs/sagelib/dependencies b/build/pkgs/sagelib/dependencies
+index 5dc2efe1d31..fa6e98df7db 100644
+--- a/build/pkgs/sagelib/dependencies
++++ b/build/pkgs/sagelib/dependencies
+@@ -1,4 +1,4 @@
+-FORCE $(SCRIPTS) arb boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
++FORCE $(SCRIPTS) boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/symengine/dependencies b/build/pkgs/symengine/dependencies
+index 1fc34963eda..7795d486018 100644
+--- a/build/pkgs/symengine/dependencies
++++ b/build/pkgs/symengine/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) arb ecm flint mpc mpfr | cmake
++$(MP_LIBRARY) ecm flint mpc mpfr | cmake
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/pkgs/sage-conf/_sage_conf/_conf.py.in b/pkgs/sage-conf/_sage_conf/_conf.py.in
+index 87b27ca05cb..895d6572d1e 100644
+--- a/pkgs/sage-conf/_sage_conf/_conf.py.in
++++ b/pkgs/sage-conf/_sage_conf/_conf.py.in
+@@ -19,8 +19,6 @@ MAXIMA_FAS = "@SAGE_MAXIMA_FAS@".replace('${prefix}', SAGE_LOCAL)
+ # Delete this line if your ECL can load Kenzo without further prodding.
+ KENZO_FAS = "@SAGE_KENZO_FAS@".replace('${prefix}', SAGE_LOCAL)
+ 
+-ARB_LIBRARY = "@SAGE_ARB_LIBRARY@"
+-
+ NTL_INCDIR = "@NTL_INCDIR@"
+ NTL_LIBDIR = "@NTL_LIBDIR@"
+ 
+diff --git a/src/sage/env.py b/src/sage/env.py
+index f4899639a6d..f6459313fd4 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -223,7 +223,6 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st
+ FOURTITWO_PPI = var("FOURTITWO_PPI")
+ FOURTITWO_CIRCUITS = var("FOURTITWO_CIRCUITS")
+ FOURTITWO_GROEBNER = var("FOURTITWO_GROEBNER")
+-ARB_LIBRARY = var("ARB_LIBRARY", "arb")
+ CBLAS_PC_MODULES = var("CBLAS_PC_MODULES", "cblas:openblas:blas")
+ ECL_CONFIG = var("ECL_CONFIG", "ecl-config")
+ NTL_INCDIR = var("NTL_INCDIR")
+@@ -356,8 +355,7 @@ def cython_aliases(required_modules=None,
+         sage: cython_aliases()
+         {...}
+         sage: sorted(cython_aliases().keys())
+-        ['ARB_LIBRARY',
+-         'CBLAS_CFLAGS',
++        ['CBLAS_CFLAGS',
+          ...,
+          'ZLIB_LIBRARIES']
+         sage: cython_aliases(required_modules=('module-that-is-assumed-to-not-exist'))
+@@ -475,8 +473,6 @@ def uname_specific(name, value, alternative):
+     if "LINBOX_CFLAGS" in aliases:
+         aliases["LINBOX_CFLAGS"].append("-std=gnu++11")
+ 
+-    aliases["ARB_LIBRARY"] = ARB_LIBRARY
+-
+     # TODO: Remove Cygwin hack by installing a suitable cblas.pc
+     if os.path.exists('/usr/lib/libblas.dll.a'):
+         aliases["CBLAS_LIBS"] = ['gslcblas']
+diff --git a/src/sage/features/sagemath.py b/src/sage/features/sagemath.py
+index 7404e6d0a8e..6037d097391 100644
+--- a/src/sage/features/sagemath.py
++++ b/src/sage/features/sagemath.py
+@@ -761,7 +761,7 @@ class sage__rings__number_field(JoinFeature):
+     A :class:`~sage.features.Feature` describing the presence of :mod:`sage.rings.number_field`.
+ 
+     Number fields are implemented in Sage using a complicated mixture of various libraries,
+-    including :ref:`arb <spkg_arb>`, :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
++    including :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
+     :ref:`MPFI <spkg_mpfi>`, :ref:`NTL <spkg_ntl>`, and :ref:`PARI <spkg_pari>`.
+ 
+     EXAMPLES:
+diff --git a/src/sage/libs/arb/acb.pxd b/src/sage/libs/arb/acb.pxd
+index 5148dc43991..851488d803a 100644
+--- a/src/sage/libs/arb/acb.pxd
++++ b/src/sage/libs/arb/acb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -152,10 +152,6 @@ cdef extern from "arb_wrap.h":
+     void acb_sech(acb_t s, const acb_t z, long prec)
+     void acb_csch(acb_t c, const acb_t z, long prec)
+ 
+-    void acb_rising_ui_bs(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui_rs(acb_t z, const acb_t x, unsigned long n, unsigned long step, long prec)
+-    void acb_rising_ui_rec(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui(acb_t z, const acb_t x, unsigned long n, long prec)
+     void acb_rising(acb_t z, const acb_t x, const acb_t n, long prec)
+ 
+     void acb_gamma(acb_t y, const acb_t x, long prec)
+diff --git a/src/sage/libs/arb/acb_calc.pxd b/src/sage/libs/arb/acb_calc.pxd
+index a5dbf360b5e..67bd2ed57dc 100644
+--- a/src/sage/libs/arb/acb_calc.pxd
++++ b/src/sage/libs/arb/acb_calc.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_calc.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_elliptic.pxd b/src/sage/libs/arb/acb_elliptic.pxd
+index 176f68df00e..e3480e9f73b 100644
+--- a/src/sage/libs/arb/acb_elliptic.pxd
++++ b/src/sage/libs/arb/acb_elliptic.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_elliptic.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_hypgeom.pxd b/src/sage/libs/arb/acb_hypgeom.pxd
+index 418e766f10d..c43e5c0623b 100644
+--- a/src/sage/libs/arb/acb_hypgeom.pxd
++++ b/src/sage/libs/arb/acb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_hypgeom.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_modular.pxd b/src/sage/libs/arb/acb_modular.pxd
+index c708e9bf97d..cdc413c92da 100644
+--- a/src/sage/libs/arb/acb_modular.pxd
++++ b/src/sage/libs/arb/acb_modular.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_modular.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_poly.pxd b/src/sage/libs/arb/acb_poly.pxd
+index 69f4320055b..ae02757ffd9 100644
+--- a/src/sage/libs/arb/acb_poly.pxd
++++ b/src/sage/libs/arb/acb_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -79,24 +79,10 @@ cdef extern from "arb_wrap.h":
+     void _acb_poly_divrem(acb_ptr Q, acb_ptr R, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec)
+     bint acb_poly_divrem(acb_poly_t Q, acb_poly_t R, const acb_poly_t A, const acb_poly_t B, long prec)
+     void _acb_poly_div_root(acb_ptr Q, acb_t R, acb_srcptr A, long len, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_horner(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_horner(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_divconquer(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_divconquer(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_convolution(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_convolution(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+     void _acb_poly_taylor_shift(acb_ptr g, const acb_t c, long n, long prec)
+     void acb_poly_taylor_shift(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_compose_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_divconquer(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_divconquer(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+     void _acb_poly_compose(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+     void acb_poly_compose(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_series_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+-    void _acb_poly_compose_series_brent_kung(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_brent_kung(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_compose_series(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+     void acb_poly_compose_series(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_revert_series_lagrange(acb_ptr h, acb_srcptr f, long flen, long n, long prec)
+@@ -161,10 +147,6 @@ cdef extern from "arb_wrap.h":
+     void acb_poly_exp_series_basecase(acb_poly_t f, const acb_poly_t h, long n, long prec)
+     void _acb_poly_exp_series(acb_ptr f, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_exp_series(acb_poly_t f, const acb_poly_t h, long n, long prec)
+-    void _acb_poly_sin_cos_series_basecase(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_basecase(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+-    void _acb_poly_sin_cos_series_tangent(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_tangent(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+     void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_sin_cos_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec)
+     void _acb_poly_sin_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec)
+diff --git a/src/sage/libs/arb/arb.pxd b/src/sage/libs/arb/arb.pxd
+index c82b94de30f..acd232ab816 100644
+--- a/src/sage/libs/arb/arb.pxd
++++ b/src/sage/libs/arb/arb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -224,15 +224,8 @@ cdef extern from "arb_wrap.h":
+ 
+     void arb_lambertw(arb_t res, const arb_t x, int flags, long prec)
+ 
+-    void arb_rising_ui_bs(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui_rs(arb_t z, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising_ui_rec(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui(arb_t z, const arb_t x, unsigned long n, long prec)
+     void arb_rising(arb_t z, const arb_t x, const arb_t n, long prec)
+     void arb_rising_fmpq_ui(arb_t z, const fmpq_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_bs(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_rs(arb_t u, arb_t v, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising2_ui(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+     void arb_fac_ui(arb_t z, unsigned long n, long prec)
+     void arb_bin_ui(arb_t z, const arb_t n, unsigned long k, long prec)
+     void arb_bin_uiui(arb_t z, unsigned long n, unsigned long k, long prec)
+diff --git a/src/sage/libs/arb/arb_fmpz_poly.pxd b/src/sage/libs/arb/arb_fmpz_poly.pxd
+index 079f76e9d9e..55daa705238 100644
+--- a/src/sage/libs/arb/arb_fmpz_poly.pxd
++++ b/src/sage/libs/arb/arb_fmpz_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_fmpz_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -22,5 +22,4 @@ cdef extern from "arb_wrap.h":
+     unsigned long arb_fmpz_poly_deflation(const fmpz_poly_t poly)
+     void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long deflation)
+     void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, long prec)
+-    void arb_fmpz_poly_cos_minpoly(fmpz_poly_t res, unsigned long n)
+     void arb_fmpz_poly_gauss_period_minpoly(fmpz_poly_t res, unsigned long q, unsigned long n)
+diff --git a/src/sage/libs/arb/arb_hypgeom.pxd b/src/sage/libs/arb/arb_hypgeom.pxd
+index fb1c40ddaa8..139b987d669 100644
+--- a/src/sage/libs/arb/arb_hypgeom.pxd
++++ b/src/sage/libs/arb/arb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_hypgeom.h
+ 
+ from sage.libs.flint.types cimport fmpz_t
+diff --git a/src/sage/libs/arb/arb_wrap.h b/src/sage/libs/arb/arb_wrap.h
+index 49997075ee5..488bb376d5e 100644
+--- a/src/sage/libs/arb/arb_wrap.h
++++ b/src/sage/libs/arb/arb_wrap.h
+@@ -5,25 +5,27 @@
+  * by arb, most of which rely on flint's ulong and slong defines.
+  */
+ 
++#include <mpfr.h>
++
+ #undef ulong
+ #undef slong
+ 
+ #define ulong mp_limb_t
+ #define slong mp_limb_signed_t
+ 
+-#include <acb.h>
+-#include <acb_calc.h>
+-#include <acb_elliptic.h>
+-#include <acb_hypgeom.h>
+-#include <acb_mat.h>
+-#include <acb_modular.h>
+-#include <acb_poly.h>
+-#include <arb.h>
+-#include <arb_fmpz_poly.h>
+-#include <arb_hypgeom.h>
+-#include <arf.h>
+-#include <bernoulli.h>
+-#include <mag.h>
++#include <flint/acb.h>
++#include <flint/acb_calc.h>
++#include <flint/acb_elliptic.h>
++#include <flint/acb_hypgeom.h>
++#include <flint/acb_mat.h>
++#include <flint/acb_modular.h>
++#include <flint/acb_poly.h>
++#include <flint/arb.h>
++#include <flint/arb_fmpz_poly.h>
++#include <flint/arb_hypgeom.h>
++#include <flint/arf.h>
++#include <flint/bernoulli.h>
++#include <flint/mag.h>
+ 
+ #undef ulong
+ #undef slong
+diff --git a/src/sage/libs/arb/arf.pxd b/src/sage/libs/arb/arf.pxd
+index b8b83fefcdc..84778fe9f09 100644
+--- a/src/sage/libs/arb/arf.pxd
++++ b/src/sage/libs/arb/arf.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arf.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -30,7 +30,6 @@ cdef extern from "arb_wrap.h":
+     void arf_set_ui(arf_t y, unsigned long x)
+     void arf_set_si(arf_t y, long x)
+     void arf_set_mpfr(arf_t y, const mpfr_t x)
+-    # void arf_set_fmpr(arf_t y, const fmpr_t x)
+     void arf_set_d(arf_t y, double x)
+     void arf_swap(arf_t y, arf_t x)
+     void arf_init_set_ui(arf_t y, unsigned long x)
+@@ -46,7 +45,6 @@ cdef extern from "arb_wrap.h":
+     int arf_set_round_fmpz_2exp(arf_t y, const fmpz_t x, const fmpz_t e, long prec, arf_rnd_t rnd)
+     void arf_get_fmpz_2exp(fmpz_t m, fmpz_t e, const arf_t x)
+     double arf_get_d(const arf_t x, arf_rnd_t rnd)
+-    # void arf_get_fmpr(fmpr_t y, const arf_t x)
+     int arf_get_mpfr(mpfr_t y, const arf_t x, mpfr_rnd_t rnd)
+     void arf_get_fmpz(fmpz_t z, const arf_t x, arf_rnd_t rnd)
+     long arf_get_si(const arf_t x, arf_rnd_t rnd)
+diff --git a/src/sage/libs/arb/bernoulli.pxd b/src/sage/libs/arb/bernoulli.pxd
+index 375b2b9bbcf..ea9340f4b15 100644
+--- a/src/sage/libs/arb/bernoulli.pxd
++++ b/src/sage/libs/arb/bernoulli.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = bernoulli.h
+ 
+ from ..flint.types cimport fmpq_t, ulong
+diff --git a/src/sage/libs/arb/mag.pxd b/src/sage/libs/arb/mag.pxd
+index d5d8693ea8f..69dfb990ae0 100644
+--- a/src/sage/libs/arb/mag.pxd
++++ b/src/sage/libs/arb/mag.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = mag.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -27,13 +27,11 @@ cdef extern from "arb_wrap.h":
+     # void mag_randtest(mag_t x, flint_rand_t state, long expbits)
+     # void mag_randtest_special(mag_t x, flint_rand_t state, long expbits)
+     void mag_set_d(mag_t y, double x)
+-    # void mag_set_fmpr(mag_t y, const fmpr_t x)
+     void mag_set_ui(mag_t y, unsigned long x)
+     void mag_set_fmpz(mag_t y, const fmpz_t x)
+     void mag_set_d_2exp_fmpz(mag_t z, double x, const fmpz_t y)
+     void mag_set_fmpz_2exp_fmpz(mag_t z, const fmpz_t x, const fmpz_t y)
+     void mag_set_ui_2exp_si(mag_t z, unsigned long x, long y)
+-    # void mag_get_fmpr(fmpr_t y, const mag_t x)
+     void mag_get_fmpq(fmpq_t y, const mag_t x)
+     void mag_set_ui_lower(mag_t z, unsigned long x)
+     void mag_set_fmpz_lower(mag_t z, const fmpz_t x)
+diff --git a/src/sage/libs/flint/flint_wrap.h b/src/sage/libs/flint/flint_wrap.h
+index 266535c3835..4db72b97660 100644
+--- a/src/sage/libs/flint/flint_wrap.h
++++ b/src/sage/libs/flint/flint_wrap.h
+@@ -15,6 +15,7 @@
+  */
+ 
+ #include <gmp.h>
++#include <mpfr.h>
+ 
+ /* Save previous definition of ulong if any, as pari also uses it */
+ /* Should work on GCC, clang, MSVC */
+@@ -33,6 +34,7 @@
+ 
+ #include <flint/arith.h>
+ #include <flint/fmpq.h>
++#include <flint/fmpq_vec.h>
+ #include <flint/fmpq_mat.h>
+ #include <flint/fmpq_poly.h>
+ #include <flint/fmpz.h>
+@@ -47,6 +49,7 @@
+ #include <flint/fq.h>
+ #include <flint/fq_nmod.h>
+ #include <flint/nmod_poly.h>
++#include <flint/nmod_poly_factor.h>
+ #include <flint/nmod_vec.h>
+ #include <flint/padic.h>
+ #include <flint/padic_poly.h>
+diff --git a/src/sage/libs/flint/fmpq.pxd b/src/sage/libs/flint/fmpq.pxd
+index 5e64c82102f..0616c0a7408 100644
+--- a/src/sage/libs/flint/fmpq.pxd
++++ b/src/sage/libs/flint/fmpq.pxd
+@@ -12,6 +12,8 @@ cdef extern from "flint_wrap.h":
+     fmpz * fmpq_denref(fmpq_t)
+     void fmpq_init(fmpq_t)
+     void fmpq_clear(fmpq_t)
++    void fmpq_init_set_readonly(fmpq_t, const mpq_t)
++    void fmpq_clear_readonly(fmpq_t)
+     void fmpq_one(fmpq_t)
+     void fmpq_zero(fmpq_t)
+     bint fmpq_is_zero(fmpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pxd b/src/sage/libs/flint/fmpq_poly.pxd
+index 20a797c0197..516f9e84cfc 100644
+--- a/src/sage/libs/flint/fmpq_poly.pxd
++++ b/src/sage/libs/flint/fmpq_poly.pxd
+@@ -30,6 +30,9 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_canonicalise(fmpq_poly_t)
+     int fmpq_poly_is_canonical(const fmpq_poly_t)
+ 
++    void _fmpq_poly_set_length(fmpq_poly_t, slong)
++    void _fmpq_poly_normalise(fmpq_poly_t)
++
+     # Polynomial parameters
+     slong fmpq_poly_degree(const fmpq_poly_t)
+     ulong fmpq_poly_length(const fmpq_poly_t)
+@@ -46,10 +49,7 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_ui(fmpq_poly_t, ulong)
+     void fmpq_poly_set_fmpz(fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_set_fmpq(fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+     void fmpq_poly_set_fmpz_poly(fmpq_poly_t, const fmpz_poly_t)
+-    void fmpq_poly_set_array_mpq(fmpq_poly_t, const mpq_t *, slong)
+ 
+     void fmpq_poly_set_str(fmpq_poly_t, const char *)
+     char *fmpq_poly_get_str(const fmpq_poly_t)
+@@ -67,7 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_reverse(fmpq_poly_t, const fmpq_poly_t, slong)
+ 
+     void fmpq_poly_get_coeff_fmpq(fmpq_t, const fmpq_poly_t, slong)
+-    void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_si(slong, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_ui(ulong, const fmpq_poly_t, slong)
+ 
+@@ -75,8 +74,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_coeff_ui(fmpq_poly_t, slong, ulong)
+     void fmpq_poly_set_coeff_fmpz(fmpq_poly_t, slong, const fmpz_t)
+     void fmpq_poly_set_coeff_fmpq(fmpq_poly_t, slong, const fmpq_t)
+-    void fmpq_poly_set_coeff_mpz(fmpq_poly_t, slong, const mpz_t)
+-    void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
+ 
+     # Comparison
+     int fmpq_poly_equal(const fmpq_poly_t, const fmpq_poly_t)
+@@ -100,8 +97,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_mul_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     void fmpq_poly_scalar_div_si(fmpq_poly_t, const fmpq_poly_t, slong)
+     void fmpq_poly_scalar_div_ui(fmpq_poly_t, const fmpq_poly_t, ulong)
+@@ -109,8 +104,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_div_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_div_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_div_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Multiplication
+     void fmpq_poly_mul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -155,8 +148,6 @@ cdef extern from "flint_wrap.h":
+     # Evaluation
+     void fmpq_poly_evaluate_fmpz(fmpq_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_evaluate_fmpq(fmpq_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_evaluate_mpz(mpq_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_evaluate_mpq(mpq_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Composition
+     void fmpq_poly_compose(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -189,3 +180,11 @@ cdef extern from "flint_wrap.h":
+ # since the fmpq_poly header seems to be lacking this inline function
+ cdef inline sage_fmpq_poly_max_limbs(const fmpq_poly_t poly):
+     return _fmpz_vec_max_limbs(fmpq_poly_numref(poly), fmpq_poly_length(poly))
++
++# functions removed from flint but still needed in sage
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
++cdef void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
++cdef void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pyx b/src/sage/libs/flint/fmpq_poly.pyx
+new file mode 100644
+index 00000000000..3b8a0cf0c51
+--- /dev/null
++++ b/src/sage/libs/flint/fmpq_poly.pyx
+@@ -0,0 +1,45 @@
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++from sage.libs.gmp.mpq cimport *
++from sage.libs.flint.fmpz cimport *
++from sage.libs.flint.fmpq cimport *
++
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t rop, const fmpq_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t rop, const fmpq_poly_t op, const mpq_t c):
++    cdef fmpq_t f
++    fmpq_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpq(rop, op, f)
++    fmpq_clear_readonly(f)
++
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t poly, slong n, const mpq_t x):
++    cdef fmpq_t t
++    fmpq_init_set_readonly(t, x)
++    fmpq_poly_set_coeff_fmpq(poly, n, t)
++    fmpq_clear_readonly(t)
++
++cdef void fmpq_poly_get_coeff_mpq(mpq_t x, const fmpq_poly_t poly, slong n):
++    cdef fmpq_t t
++    fmpq_init(t)
++    fmpq_poly_get_coeff_fmpq(t, poly, n)
++    fmpq_get_mpq(x, t)
++    fmpq_clear(t)
++
++cdef void fmpq_poly_set_mpq(fmpq_poly_t poly, const mpq_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), mpq_numref(x))
++    fmpz_set_mpz(fmpq_poly_denref(poly), mpq_denref(x))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
++
++cdef void fmpq_poly_set_mpz(fmpq_poly_t poly, const mpz_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), x)
++    fmpz_one(fmpq_poly_denref(poly))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz.pxd b/src/sage/libs/flint/fmpz.pxd
+index 01058d0f130..b97fbe1eae0 100644
+--- a/src/sage/libs/flint/fmpz.pxd
++++ b/src/sage/libs/flint/fmpz.pxd
+@@ -16,6 +16,9 @@ cdef extern from "flint_wrap.h":
+     void fmpz_init_set(fmpz_t, fmpz_t)
+     void fmpz_init_set_ui(fmpz_t, ulong)
+ 
++    void fmpz_init_set_readonly(fmpz_t, const mpz_t)
++    void fmpz_clear_readonly(fmpz_t)
++
+     # Conversion
+     void fmpz_set(fmpz_t f, fmpz_t g)
+     void fmpz_set_ui(fmpz_t, ulong)
+diff --git a/src/sage/libs/flint/fmpz_mod_poly.pxd b/src/sage/libs/flint/fmpz_mod_poly.pxd
+index 24b653eb3b7..2727246da98 100644
+--- a/src/sage/libs/flint/fmpz_mod_poly.pxd
++++ b/src/sage/libs/flint/fmpz_mod_poly.pxd
+@@ -67,13 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_get_coeff_fmpz(fmpz_t x, const fmpz_mod_poly_t poly,
+                                              slong n, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_set_coeff_mpz(fmpz_mod_poly_t poly,
+-                             slong n, const mpz_t x, const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_get_coeff_mpz(mpz_t x,
+-                 const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx)
+-
+-
+     void _fmpz_mod_poly_shift_left(fmpz * res, const fmpz * poly,
+                                                            slong len, slong n)
+ 
+@@ -194,14 +187,6 @@ cdef extern from "flint_wrap.h":
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_div_basecase(fmpz_mod_poly_t Q,
+-                            const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_div_newton_n_preinv(fmpz_mod_poly_t Q,
+-                         const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                         const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem_newton_n_preinv(fmpz_mod_poly_t Q,
+           fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                          const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+@@ -213,10 +198,6 @@ cdef extern from "flint_wrap.h":
+                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_divrem_divconquer(fmpz_mod_poly_t Q,
+-        fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem(fmpz_mod_poly_t Q, fmpz_mod_poly_t R,
+     const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+@@ -254,40 +235,13 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_make_monic_f(fmpz_t f, fmpz_mod_poly_t res,
+                          const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_euclidean(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_gcd_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_hgcd(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-
+     void fmpz_mod_poly_gcd(fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+ 
+-    void fmpz_mod_poly_xgcd_euclidean(fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_hgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S,
+-          fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_xgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                       const fmpz_mod_ctx_t ctx)
+@@ -361,14 +315,6 @@ cdef extern from "flint_wrap.h":
+                         const fmpz_mod_poly_t poly, const fmpz * xs, slong n,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_compose_horner(fmpz_mod_poly_t res,
+-                    const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_compose_divconquer(fmpz_mod_poly_t res,
+-                     const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_compose(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1,
+                          const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx)
+ 
+diff --git a/src/sage/libs/flint/fmpz_poly.pxd b/src/sage/libs/flint/fmpz_poly.pxd
+index 18b36672d30..c8bc6d3ca0a 100644
+--- a/src/sage/libs/flint/fmpz_poly.pxd
++++ b/src/sage/libs/flint/fmpz_poly.pxd
+@@ -28,7 +28,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_poly_set_ui(fmpz_poly_t, ulong)
+     void fmpz_poly_set_si(fmpz_poly_t, slong)
+     void fmpz_poly_set_fmpz(fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+     int fmpz_poly_set_str(fmpz_poly_t, const char *)
+ 
+     char *fmpz_poly_get_str(const fmpz_poly_t)
+@@ -70,7 +69,6 @@ cdef extern from "flint_wrap.h":
+     # Scalar multiplication and division
+     void fmpz_poly_scalar_mul_fmpz(
+             fmpz_poly_t, const fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+     void fmpz_poly_scalar_mul_si(fmpz_poly_t, const fmpz_poly_t, slong)
+     void fmpz_poly_scalar_mul_ui(fmpz_poly_t, const fmpz_poly_t, ulong)
+     void fmpz_poly_scalar_mul_2exp(fmpz_poly_t, const fmpz_poly_t, ulong)
+@@ -310,12 +308,14 @@ cdef extern from "flint_wrap.h":
+             fmpz_poly_t,
+                     const fmpz_poly_t, const fmpz_t, const nmod_poly_t, int)
+ 
+-    # Some functions for backwards compatibility
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
+-    void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++
++# functions removed from flint but still needed in sage
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
++cdef void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++cdef void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+ 
+ 
+ # Wrapper Cython class
+diff --git a/src/sage/libs/flint/fmpz_poly.pyx b/src/sage/libs/flint/fmpz_poly.pyx
+index 74915b37612..cfcbea9090c 100644
+--- a/src/sage/libs/flint/fmpz_poly.pyx
++++ b/src/sage/libs/flint/fmpz_poly.pyx
+@@ -25,10 +25,10 @@ from cysignals.memory cimport sig_free
+ 
+ from sage.arith.long cimport pyobject_to_long
+ from sage.cpython.string cimport char_to_str, str_to_bytes
++from sage.libs.flint.fmpz cimport *
+ from sage.structure.sage_object cimport SageObject
+ from sage.rings.integer cimport Integer
+ 
+-
+ cdef class Fmpz_poly(SageObject):
+ 
+     def __cinit__(self):
+@@ -455,3 +455,44 @@ cdef class Fmpz_poly(SageObject):
+         """
+         from sage.rings.integer_ring import ZZ
+         return ZZ[var](self.list())
++
++
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_divexact_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_fdiv_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t poly, slong n, const mpz_t x):
++    cdef fmpz_t t
++    fmpz_init_set_readonly(t, x)
++    fmpz_poly_set_coeff_fmpz(poly, n, t)
++    fmpz_clear_readonly(t)
++
++cdef void fmpz_poly_get_coeff_mpz(mpz_t x, const fmpz_poly_t poly, slong n):
++    cdef fmpz_t t
++    fmpz_init(t)
++    fmpz_poly_get_coeff_fmpz(t, poly, n)
++    fmpz_get_mpz(x, t)
++    fmpz_clear(t)
++
++cdef void fmpz_poly_set_mpz(fmpz_poly_t poly, const mpz_t x):
++    fmpz_poly_fit_length(poly, 1)
++    fmpz_set_mpz(poly.coeffs, x)
++    _fmpz_poly_set_length(poly, 1)
++    _fmpz_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz_poly_q.pxd b/src/sage/libs/flint/fmpz_poly_q.pxd
+index 846542dc0d8..63c13355bf6 100644
+--- a/src/sage/libs/flint/fmpz_poly_q.pxd
++++ b/src/sage/libs/flint/fmpz_poly_q.pxd
+@@ -49,11 +49,7 @@ cdef extern from "flint_wrap.h":
+ 
+     #* Scalar multiplication and division ****************************************/
+     void fmpz_poly_q_scalar_mul_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_mul_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_mul_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+     void fmpz_poly_q_scalar_div_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_div_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_div_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+ 
+     #* Multiplication and division ***********************************************/
+     void fmpz_poly_q_mul(fmpz_poly_q_t rop, 
+@@ -67,9 +63,6 @@ cdef extern from "flint_wrap.h":
+     #* Derivative ****************************************************************/
+     void fmpz_poly_q_derivative(fmpz_poly_q_t rop, const fmpz_poly_q_t op)
+ 
+-    #* Evaluation ****************************************************************/
+-    int fmpz_poly_q_evaluate(mpq_t rop, const fmpz_poly_q_t f, const mpq_t a)
+-
+     #* Input and output **********************************************************/
+     int fmpz_poly_q_set_str(fmpz_poly_q_t rop, const char *s)
+     char * fmpz_poly_q_get_str(const fmpz_poly_q_t op)
+diff --git a/src/sage/libs/linbox/linbox_flint_interface.pyx b/src/sage/libs/linbox/linbox_flint_interface.pyx
+index 415cd473947..83547f91cd2 100644
+--- a/src/sage/libs/linbox/linbox_flint_interface.pyx
++++ b/src/sage/libs/linbox/linbox_flint_interface.pyx
+@@ -33,6 +33,7 @@ and C. Pernet. The functions available are:
+ #                  https://www.gnu.org/licenses/
+ # ****************************************************************************
+ 
++from sage.libs.gmp.types cimport mpz_t
+ from sage.libs.flint.types cimport fmpz_t
+ from sage.libs.flint.fmpz cimport fmpz_get_mpz, fmpz_set_mpz
+ from sage.libs.flint.fmpz_mat cimport fmpz_mat_entry, fmpz_mat_nrows, fmpz_mat_ncols
+@@ -80,11 +81,13 @@ cdef void fmpz_poly_set_linbox(fmpz_poly_t p, PolynomialRing_integer.Element& q)
+     (the .pxd file) in order to keep the header C-compatible
+     """
+     cdef size_t i
++    cdef mpz_t tmp
+ 
+     fmpz_poly_fit_length(p, q.size())
+ 
+     for i in range(q.size()):
+-        fmpz_poly_set_coeff_mpz(p, i, q[i].get_mpz_const())
++        tmp = q[i].get_mpz_const()
++        fmpz_poly_set_coeff_mpz(p, i, tmp)
+ 
+     _fmpz_poly_set_length(p, q.size())
+ 
+diff --git a/src/sage/matrix/matrix_complex_ball_dense.pyx b/src/sage/matrix/matrix_complex_ball_dense.pyx
+index 3f56772a663..b1ece8a0e7b 100644
+--- a/src/sage/matrix/matrix_complex_ball_dense.pyx
++++ b/src/sage/matrix/matrix_complex_ball_dense.pyx
+@@ -1,4 +1,4 @@
+-# distutils: libraries = ARB_LIBRARY
++# distutils: libraries = flint
+ r"""
+ Arbitrary precision complex ball matrices using Arb
+ 
+diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx
+index f4320fcd914..b36ee300990 100644
+--- a/src/sage/matrix/matrix_integer_sparse.pyx
++++ b/src/sage/matrix/matrix_integer_sparse.pyx
+@@ -847,6 +847,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+             sage: matrix(ZZ, 1, 1, sparse=True)._charpoly_linbox()
+             x
+         """
++        cdef mpz_t tmp
+         if self._nrows != self._ncols:
+             raise ArithmeticError('only valid for square matrix')
+ 
+@@ -869,7 +870,8 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         cdef size_t i
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+@@ -966,9 +968,11 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         sig_off()
+ 
+         cdef size_t i
++        cdef mpz_t tmp
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
+index a22ce3c5e53..15be37734af 100644
+--- a/src/sage/rings/complex_arb.pyx
++++ b/src/sage/rings/complex_arb.pyx
+@@ -1360,12 +1360,13 @@ cdef class ComplexBall(RingElement):
+             sage: CBF100(-3r)
+             -3.000000000000000000000000000000
+ 
+-            sage: ComplexBall(CBF100, 10^100)
+-            1.000000000000000000000000000000e+100
+             sage: ComplexBall(CBF100, CIF(1, 2))
+             1.000000000000000000000000000000 + 2.000000000000000000000000000000*I
+             sage: ComplexBall(CBF100, RBF(1/3), RBF(1))
+             [0.3333333333333333 +/- ...e-17] + 1.000000000000000000000000000000*I
++            sage: ComplexBall(CBF100, 10^100)
++            [1.000000000000000000000000000000e+100 +/- ...]
++
+             sage: NF.<a> = QuadraticField(-1, embedding=CC(0, -1))
+             sage: CBF(a)
+             -1.000000000000000*I
+@@ -3009,7 +3010,7 @@ cdef class ComplexBall(RingElement):
+             sage: CBF(1).rising_factorial(2**64)
+             [+/- ...e+347382171326740403407]
+             sage: ComplexBallField(128)(1).rising_factorial(2**64)
+-            [2.343691126796861348e+347382171305201285713 +/- ...e+347382171305201285694]
++            [2.34369112679686134...e+347382171305201285713 +/- ...]
+             sage: CBF(1/2).rising_factorial(CBF(2,3)) # abs tol 1e-15
+             [-0.123060451458124 +/- 3.06e-16] + [0.0406412631676552 +/- 7.57e-17]*I
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+index b888b31d214..621d86f9bb8 100644
+--- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+@@ -222,7 +222,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef unsigned long n
+         cdef Rational c
+         cdef list L1
+-        cdef mpq_t * L2
++        cdef fmpq_t q
+ 
+         Polynomial.__init__(self, parent, is_gen=is_gen)
+ 
+@@ -253,14 +253,11 @@ cdef class Polynomial_rational_flint(Polynomial):
+             L1 = [e if isinstance(e, Rational) else Rational(e) for e in x]
+             n  = <unsigned long> len(x)
+             sig_on()
+-            L2 = <mpq_t *> check_allocarray(n, sizeof(mpq_t))
++            fmpq_poly_fit_length(self._poly, n)
+             for deg from 0 <= deg < n:
+-                mpq_init(L2[deg])
+-                mpq_set(L2[deg], (<Rational> L1[deg]).value)
+-            fmpq_poly_set_array_mpq(self._poly, L2, n)
+-            for deg from 0 <= deg < n:
+-                mpq_clear(L2[deg])
+-            sig_free(L2)
++                fmpq_init_set_readonly(q, (<Rational> L1[deg]).value)
++                fmpq_poly_set_coeff_fmpq(self._poly, deg, q)
++                fmpq_clear_readonly(q)
+             sig_off()
+ 
+ #           deg = 0
+@@ -435,6 +432,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         utmost care.
+         """
+         cdef bint do_sig = _do_sig(self._poly)
++        cdef fmpz_t tmpfz
+ 
+         if isinstance(value, int):
+             if do_sig: sig_str("FLINT exception")
+@@ -442,7 +440,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+             if do_sig: sig_off()
+         elif isinstance(value, Integer):
+             if do_sig: sig_str("FLINT exception")
+-            fmpq_poly_set_coeff_mpz(self._poly, n, (<Integer> value).value)
++            fmpz_init_set_readonly(tmpfz, (<Integer> value).value)
++            fmpq_poly_set_coeff_fmpz(self._poly, n, tmpfz)
++            fmpz_clear_readonly(tmpfz)
+             if do_sig: sig_off()
+         elif isinstance(value, Rational):
+             if do_sig: sig_str("FLINT exception")
+@@ -492,7 +492,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef Polynomial_rational_flint f
+         cdef Rational r
+         cdef fmpz_t tmpfz
+-        cdef fmpq_t tmpfq
++        cdef fmpq_t tmpfq, tmpfq1
+         cdef RealBall arb_a, arb_z
+         cdef ComplexBall acb_a, acb_z
+ 
+@@ -508,13 +508,23 @@ cdef class Polynomial_rational_flint(Polynomial):
+             elif isinstance(a, Rational):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpq(r.value, self._poly, (<Rational> a).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> a).value)
++                fmpq_init(tmpfq1)
++                fmpq_poly_evaluate_fmpq(tmpfq1, self._poly, tmpfq)
++                fmpq_get_mpq(r.value, tmpfq1)
++                fmpq_clear(tmpfq1)
++                fmpq_clear_readonly(tmpfq)
+                 sig_off()
+                 return r
+             elif isinstance(a, Integer):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpz(r.value, self._poly, (<Integer> a).value)
++                fmpz_init_set_readonly(tmpfz, (<Integer> a).value)
++                fmpq_init(tmpfq)
++                fmpq_poly_evaluate_fmpz(tmpfq, self._poly, tmpfz)
++                fmpq_get_mpq(r.value, tmpfq)
++                fmpq_clear(tmpfq)
++                fmpz_clear_readonly(tmpfz)
+                 sig_off()
+                 return r
+             elif isinstance(a, int):
+@@ -1321,6 +1331,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         """
+         cdef Polynomial_rational_flint res
+         cdef bint do_sig
++        cdef fmpq_t tmpfq
+ 
+         if right == 0:
+             raise ZeroDivisionError("division by zero polynomial")
+@@ -1331,8 +1342,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+                 do_sig = _do_sig(self._poly)
+ 
+                 if do_sig: sig_str("FLINT exception")
+-                fmpq_poly_scalar_div_mpq(res._poly, self._poly,
+-                                                  (<Rational> QQ(right)).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> QQ(right)).value)
++                fmpq_poly_scalar_div_fmpq(res._poly, self._poly, tmpfq)
++                fmpq_clear_readonly(tmpfq)
+                 if do_sig: sig_off()
+                 return res
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+index 4c480673861..780549af062 100644
+--- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+@@ -658,6 +658,11 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
+             ...
+             NotImplementedError: square free factorization of polynomials over rings with composite characteristic is not implemented
+ 
++        :trac:`20003`::
++
++            sage: P.<x> = GF(7)[]
++            sage: (6*x+3).squarefree_decomposition()
++            (6) * (x + 4)
+         """
+         if not self.base_ring().is_field():
+             raise NotImplementedError("square free factorization of polynomials over rings with composite characteristic is not implemented")
+diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
+index 17859068273..14baa5bc5aa 100644
+--- a/src/sage/rings/real_arb.pyx
++++ b/src/sage/rings/real_arb.pyx
+@@ -898,7 +898,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+             sage: RBF.gamma(5)
+             24.00000000000000
+             sage: RBF.gamma(10**20)
+-            [+/- ...e+1956570552410610660600]
++            [1.932849514310098...+1956570551809674817225 +/- ...]
+             sage: RBF.gamma(1/3)
+             [2.678938534707747 +/- ...e-16]
+             sage: RBF.gamma(-5)
+@@ -1102,7 +1102,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+              15.00000000000000,
+              48.00000000000000]
+             sage: RBF.double_factorial(2**20)
+-            [1.4483729903e+2928836 +/- ...e+2928825]
++            [1.448372990...e+2928836 +/- ...]
+             sage: RBF.double_factorial(2**1000)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/schemes/plane_conics/con_rational_function_field.py b/src/sage/schemes/plane_conics/con_rational_function_field.py
+index 1b3f0ac412a..485c9c71be3 100644
+--- a/src/sage/schemes/plane_conics/con_rational_function_field.py
++++ b/src/sage/schemes/plane_conics/con_rational_function_field.py
+@@ -198,38 +198,6 @@ def has_rational_point(self, point=False, algorithm='default',
+             Fraction Field of Univariate Polynomial Ring in u over Rational
+             Field with modulus v^2 - u^3 - 1
+ 
+-        ``has_rational_point`` fails for some conics over function fields
+-        over finite fields, due to :trac:`20003`::
+-
+-            sage: K.<t> = PolynomialRing(GF(7))
+-            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
+-            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
+-            sage: C.has_rational_point()
+-            Traceback (most recent call last):
+-            ...
+-            TypeError: self (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (-t^3 + 3*t^2 - 2*t - 2)/(t + 3)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (t^2 + 3*t + 3)*x*y + (-2*t^2 - 2)*y^2 + (-t^2 + 3*t + 2)*x*z + (-3*t + 3)*y*z + (-3*t^2 + t - 2)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x + (2*t - 2)/(t + 3)*y + (3*t^4 + 2*t^3 - 2*t^2 - 2*t + 3)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z
+-                     : y + (-t^3 - t^2 + 3*t - 1)/(t^3 - 3*t^2 + 2*t + 2)*z : z))
+-            domain must equal right (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^3 - t^2 + 3*t + 3)*x^2 + (t - 3)*y^2 + (-t^7 + 2*t^5 + t^4 + 2*t^3 + 3*t^2 - t - 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    -2/(t^3 - 3*t^2 + 2*t + 2)*x^2 + 1/(t^3 + 3*t^2 - 2*t + 1)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^9 - 2*t^8 + t^7 - t^6 + 3*t^5 - 3*t^3 + t^2 - 2*t + 3)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    ((t^3 - 3*t^2 + 2*t + 2)*x : (t^2 - 2)*y : (t^5 - 3*t^4 + t^2 + 3*t + 3)*z))
+-            codomain
+-
+-
+-
+         TESTS::
+ 
+             sage: K.<t> = FractionField(PolynomialRing(QQ, 't'))
+@@ -250,6 +218,16 @@ def has_rational_point(self, point=False, algorithm='default',
+             sage: C.has_rational_point(point = True) # long time (4 seconds)
+             (True,
+              ((-2/117*t^8 + 304/1053*t^7 + 40/117*t^6 - 1/27*t^5 - 110/351*t^4 - 2/195*t^3 + 11/351*t^2 + 1/117)/(t^4 + 2/39*t^3 + 4/117*t^2 + 2/39*t + 14/39) : -5/3*t^4 + 19*t^3 : 1))
++
++        ``has_rational_point`` used to fail for some conics over function fields
++        over finite fields, due to :trac:`20003`::
++
++            sage: K.<t> = PolynomialRing(GF(7))
++            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
++            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
++            sage: C.has_rational_point()
++            True
++
+         """
+         from .constructor import Conic
+ 
+diff --git a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+index a591cb4cd7c..a90f2050c59 100644
+--- a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
++++ b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+@@ -20,6 +20,7 @@
+ #include "utils.h"
+ 
+ #include "gmp.h"
++#include "flint/fmpz_poly.h"
+ #include "flint/fmpq_poly.h"
+ #include "flint/fmpq.h"
+ 
+@@ -63,7 +64,7 @@ static ex chebyt_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+@@ -122,7 +123,7 @@ static ex chebyu_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+diff --git a/src/sage/symbolic/ginac/useries.cpp b/src/sage/symbolic/ginac/useries.cpp
+index 40fbd7ab360..b9a8b867648 100644
+--- a/src/sage/symbolic/ginac/useries.cpp
++++ b/src/sage/symbolic/ginac/useries.cpp
+@@ -467,10 +467,17 @@ void add::useries(flint_series_t& fp, int order) const
+                 fmpq_poly_set_ui(fp.ft, 0);
+         else if (oc.is_long())
+                 fmpq_poly_set_si(fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ 
+         for (const auto & elem : seq) {
+ 		const ex& t = recombine_pair_to_ex(elem);
+@@ -505,10 +512,17 @@ void mul::useries(flint_series_t& fp, int order) const
+ 
+         if (oc.is_long())
+                 fmpq_poly_scalar_mul_si(fp.ft, fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_scalar_mul_mpz(fp.ft, fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_scalar_mul_mpq(fp.ft, fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_scalar_mul_fmpz(fp.ft, fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp.ft, fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ void power::useries(flint_series_t& fp, int order) const
+@@ -563,7 +577,10 @@ void power::useries(flint_series_t& fp, int order) const
+                 }
+                 check_poly_ccoeff_one(fp1);
+                 fmpq_poly_log_series(fp1.ft, fp1.ft, order);
+-                fmpq_poly_scalar_mul_mpq(fp1.ft, fp1.ft, nexp.as_mpq());
++                fmpq_t tmp;
++                fmpq_init_set_readonly(tmp, nexp.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp1.ft, fp1.ft, tmp);
++                fmpq_clear_readonly(tmp);
+                 fmpq_poly_exp_series(fp.ft, fp1.ft, order);
+                 return;
+         }
+@@ -608,10 +625,17 @@ void numeric::useries(flint_series_t& fp, int order) const
+ {
+         if (is_long())
+                 fmpq_poly_set_si(fp.ft, to_long());
+-        else if (is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, as_mpq());
++        else if (is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ } // namespace GiNaC
+diff --git a/src/sage_setup/library_order.py b/src/sage_setup/library_order.py
+index f40690f8d22..9ae0d2579a7 100644
+--- a/src/sage_setup/library_order.py
++++ b/src/sage_setup/library_order.py
+@@ -16,17 +16,12 @@
+ 
+ aliases = cython_aliases(required_modules=(), optional_modules=modules)
+ 
+-if "ARB_LIBRARY" in aliases:
+-    arb_dylib_names = [aliases["ARB_LIBRARY"]]
+-else:
+-    arb_dylib_names = []
+-
+ library_order_list = aliases.get("SINGULAR_LIBRARIES", []) + [
+     "giac", "intl", "curl",
+     "ec", "ecm"
+ ] + aliases.get("LINBOX_LIBRARIES", []) + aliases.get("FFLASFFPACK_LIBRARIES", []) + aliases.get("GSL_LIBRARIES", []) + [
+     "pari", "flint", "ecl", "glpk", "ppl",
+-] + arb_dylib_names + [
++] + [
+     "mpfi", "mpfr", "mpc", "ntl", "gmp", "gmpxx",
+     "brial",
+     "brial_groebner",
diff --git a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch b/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
deleted file mode 100644
index 7c55bce6e9bb4..0000000000000
--- a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
+++ /dev/null
@@ -1,221 +0,0 @@
-diff --git a/build/pkgs/singular/checksums.ini b/build/pkgs/singular/checksums.ini
-index 313463d2fea..1101fc55700 100644
---- a/build/pkgs/singular/checksums.ini
-+++ b/build/pkgs/singular/checksums.ini
-@@ -1,5 +1,5 @@
- tarball=singular-VERSION.tar.gz
--sha1=28bb3ee97ef48d04dfa96de182fd93eebe08426c
--md5=fc0a4f5720dadba45a52ee94324ce00c
--cksum=1573851737
--upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-1/singular-VERSION.tar.gz
-+sha1=df1997f412580f2073295aba569bb955ad227317
-+md5=50349213e206a18cdaa1bc410dde7ea4
-+cksum=376854707
-+upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-2/singular-VERSION.tar.gz
-diff --git a/build/pkgs/singular/package-version.txt b/build/pkgs/singular/package-version.txt
-index 66e2bede53a..9f1bf008217 100644
---- a/build/pkgs/singular/package-version.txt
-+++ b/build/pkgs/singular/package-version.txt
-@@ -1 +1 @@
--4.3.1p3
-+4.3.2p7
-diff --git a/build/pkgs/singular/spkg-configure.m4 b/build/pkgs/singular/spkg-configure.m4
-index 6a85631f624..f7621ec5fa1 100644
---- a/build/pkgs/singular/spkg-configure.m4
-+++ b/build/pkgs/singular/spkg-configure.m4
-@@ -6,14 +6,27 @@ SAGE_SPKG_CONFIGURE([singular], [
-     AS_IF([test -z "${SINGULAR_BIN}"], [sage_spkg_install_singular=yes], [
-       dnl Use pkg-config to ensure that Singular is new enough.
-       PKG_CHECK_MODULES([SINGULAR], [Singular >= 4.2.1], [
--       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)
--       ], [
--       AC_MSG_RESULT(no)
--       sage_spkg_install_singular=yes
--       ]
--      )], [
-+        AC_MSG_CHECKING([whether Singular is built with FLINT])
-+        AC_COMPILE_IFELSE([
-+          AC_LANG_PROGRAM([
-+            #include <singular/singularconfig.h>
-+            #if !defined(HAVE_FLINT)
-+            #  error "Need Singular compiled with FLINT"
-+          ], [])
-+        ], [
-+          AC_MSG_RESULT([yes])
-+          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)
-+          ], [
-+            AC_MSG_RESULT(no)
-+            sage_spkg_install_singular=yes
-+          ])
-+        ], [
-+          AC_MSG_RESULT([no])
-+          sage_spkg_install_singular=yes
-+        ])
-+      ], [
-       dnl pkg-config version check failed
-       sage_spkg_install_singular=yes
-       ])
-diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py
-index b15cc1c602c..4b5c76e2bfa 100644
---- a/src/sage/interfaces/singular.py
-+++ b/src/sage/interfaces/singular.py
-@@ -604,8 +604,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: i = singular.ideal(['x^2','y^2','z^2'])
-             sage: s = i.std()
-             sage: singular.eval('hilb(%s)'%(s.name()))
--            '// 1 t^0\n// -3 t^2\n// 3 t^4\n// -1 t^6\n\n// 1 t^0\n//
--            3 t^1\n// 3 t^2\n// 1 t^3\n// dimension (affine) = 0\n//
-+            '...// dimension (affine) = 0\n//
-             degree (affine) = 8'
- 
-         ::
-@@ -613,15 +612,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: from sage.misc.verbose import set_verbose
-             sage: set_verbose(1)
-             sage: o = singular.eval('hilb(%s)'%(s.name()))
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
- 
-         This is mainly useful if this method is called implicitly. Because
-@@ -631,15 +622,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-         ::
- 
-             sage: o = s.hilb()
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
-             // ** right side is not a datum, assignment ignored
-             ...
-diff --git a/src/sage/libs/singular/function.pyx b/src/sage/libs/singular/function.pyx
-index f40346d1fd0..c597c63aafe 100644
---- a/src/sage/libs/singular/function.pyx
-+++ b/src/sage/libs/singular/function.pyx
-@@ -1241,32 +1241,22 @@ cdef class SingularFunction(SageObject):
-             sage: I = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5])
-             sage: I = Ideal(I.groebner_basis())
-             sage: hilb = sage.libs.singular.function_factory.ff.hilb
--            sage: hilb(I) # Singular will print // ** _ is no standard basis
--            // ** _ is no standard basis
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: from sage.misc.sage_ostools import redirection
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I) # Singular will print // ** _ is no standard basis
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            True
- 
-         So we tell Singular that ``I`` is indeed a Groebner basis::
- 
--            sage: hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            False
- 
- 
-         TESTS:
-diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-index 22ada6de947..80352700872 100644
---- a/src/sage/rings/polynomial/multi_polynomial_ideal.py
-+++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-@@ -3132,13 +3132,16 @@ def hilbert_numerator(self, grading=None, algorithm='sage'):
-             sage: I.hilbert_numerator()                                                 # needs sage.rings.number_field
-             -t^5 + 1
- 
--        This example returns a wrong answer due to an integer overflow in Singular::
-+        This example returns a wrong answer in singular < 4.3.2p4 due to an integer overflow::
- 
-             sage: n=4; m=11; P = PolynomialRing(QQ, n*m, "x"); x = P.gens(); M = Matrix(n, x)
-             sage: I = P.ideal(M.minors(2))
-             sage: J = P * [m.lm() for m in I.groebner_basis()]
--            sage: J.hilbert_numerator(algorithm='singular')
--            ...120*t^33 - 3465*t^32 + 48180*t^31 - ...
-+            sage: J.hilbert_numerator(algorithm='singular') # known bug
-+            Traceback (most recent call last):
-+            ....
-+            RuntimeError: error in Singular function call 'hilb':
-+            overflow at t^22
- 
-         Our two algorithms should always agree; not tested until
-         :trac:`33178` is fixed::
-diff --git a/src/sage/sandpiles/sandpile.py b/src/sage/sandpiles/sandpile.py
-index 02d2021b2fb..c8e15e06f05 100644
---- a/src/sage/sandpiles/sandpile.py
-+++ b/src/sage/sandpiles/sandpile.py
-@@ -2493,9 +2493,15 @@ def _set_ideal(self):
-             sage: '_ideal' in S.__dict__
-             True
-         """
-+        from sage.libs.singular.function_factory import ff
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
-         R = self.ring()
--        I = self._unsaturated_ideal._singular_()
--        self._ideal = R.ideal(I.sat(prod(R.gens())._singular_())[1])
-+        I = self._unsaturated_ideal
-+        I_sat_gens = sat(I, prod(R.gens()))[0]
-+        self._ideal = R.ideal(I_sat_gens)
- 
-     def unsaturated_ideal(self):
-         r"""
-diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py
-index e6caf19ba74..afd6484d779 100644
---- a/src/sage/schemes/projective/projective_subscheme.py
-+++ b/src/sage/schemes/projective/projective_subscheme.py
-@@ -1001,7 +1001,10 @@ def dual(self):
-         for i in range(n + 1):
-             J = J + S.ideal(z[-1] * f_S.derivative(z[i]) - z[i + n + 1])
- 
--        sat = ff.elim__lib.sat
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
- 
-         max_ideal = S.ideal(z[n + 1: 2 * n + 2])
-         J_sat_gens = sat(J, max_ideal)[0]
diff --git a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch b/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
deleted file mode 100644
index 6a35ec3836550..0000000000000
--- a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-diff --git a/src/sage/ext/memory.pyx b/src/sage/ext/memory.pyx
-index 1de6dedab82..b95130b19dd 100644
---- a/src/sage/ext/memory.pyx
-+++ b/src/sage/ext/memory.pyx
-@@ -3,14 +3,14 @@ Low-level memory allocation functions
- 
- TESTS:
- 
--Check that a ``MemoryError`` is raised if we try to allocate a
-+Check that an error is raised if we try to allocate a
- ridiculously large integer, see :trac:`15363`::
- 
--    sage: 2^(2^63-3)
--    Traceback (most recent call last):
--    ...
--    OverflowError: exponent must be at most 2147483647         # 32-bit
--    RuntimeError: Aborted                                      # 64-bit
-+    sage: try:
-+    ....:     2^(2^63-3)
-+    ....: except (OverflowError, RuntimeError, FloatingPointError):
-+    ....:     print ('Overflow error')
-+    ...Overflow error
- 
- AUTHORS:
- 
-diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx
-index d5e87626d31..37ed9364845 100644
---- a/src/sage/rings/integer.pyx
-+++ b/src/sage/rings/integer.pyx
-@@ -6654,7 +6654,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
-             sage: try:
-             ....:     print('Possible error output from gmp', flush=True)
-             ....:     1 << (2^60)
--            ....: except (MemoryError, OverflowError, RuntimeError):
-+            ....: except (MemoryError, OverflowError, RuntimeError, FloatingPointError):
-             ....:     pass
-             ....: else:
-             ....:     print("Failed to raise exception")
diff --git a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch b/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
deleted file mode 100644
index 3d2a4bd9cd96f..0000000000000
--- a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
+++ /dev/null
@@ -1,740 +0,0 @@
-diff --git a/src/sage/ext_data/valgrind/valgrind-python.supp b/src/sage/ext_data/valgrind/valgrind-python.supp
-new file mode 100644
-index 00000000000..16aa2858484
---- /dev/null
-+++ b/src/sage/ext_data/valgrind/valgrind-python.supp
-@@ -0,0 +1,480 @@
-+# From the CPython repository with the suppressions for _PyObject_Free
-+# and _PyObject_Realloc enabled. See the upstream suppression file for
-+# details:
-+#
-+# https://github.com/python/cpython/blob/main/Misc/valgrind-python.supp
-+
-+# all tool names: Addrcheck,Memcheck,cachegrind,helgrind,massif
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 8 (x86_64 aka amd64)
-+   Memcheck:Value8
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:address_in_range
-+}
-+
-+#
-+# Leaks (including possible leaks)
-+#    Hmmm, I wonder if this masks some real leaks.  I think it does.
-+#    Will need to fix that.
-+#
-+
-+{
-+   Suppress leaking the GIL after a fork.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_allocate_lock
-+   fun:PyEval_ReInitThreads
-+}
-+
-+{
-+   Suppress leaking the autoTLSkey.  This looks like it shouldn't leak though.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_create_key
-+   fun:_PyGILState_Init
-+   fun:Py_InitializeEx
-+   fun:Py_Main
-+}
-+
-+{
-+   Hmmm, is this a real leak or like the GIL?
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_ReInitTLS
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:realloc
-+   fun:_PyObject_GC_Resize
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_New
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_NewVar
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+#
-+# Non-python specific leaks
-+#
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:calloc
-+   fun:allocate_dtv
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:memalign
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Realloc
-+}
-+
-+###
-+### All the suppressions below are for errors that occur within libraries
-+### that Python uses.  The problems to not appear to be related to Python's
-+### use of the libraries.
-+###
-+
-+{
-+   Generic ubuntu ld problems
-+   Memcheck:Addr8
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+}
-+
-+{
-+   Generic gentoo ld problems
-+   Memcheck:Cond
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_close
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Value8
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   GDBM problems, see test_gdbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   fun:gdbm_open
-+
-+}
-+
-+{
-+   Uninitialised byte(s) false alarm, see bpo-35561
-+   Memcheck:Param
-+   epoll_ctl(event)
-+   fun:epoll_ctl
-+   fun:pyepoll_internal_ctl
-+}
-+
-+{
-+   ZLIB problems, see test_gzip
-+   Memcheck:Cond
-+   obj:/lib/libz.so.1.2.3
-+   obj:/lib/libz.so.1.2.3
-+   fun:deflate
-+}
-+
-+{
-+   Avoid problems w/readline doing a putenv and leaking on exit
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:xmalloc
-+   fun:sh_set_lines_and_columns
-+   fun:_rl_get_screen_size
-+   fun:_rl_init_terminal_io
-+   obj:/lib/libreadline.so.4.3
-+   fun:rl_initialize
-+}
-+
-+# Valgrind emits "Conditional jump or move depends on uninitialised value(s)"
-+# false alarms on GCC builtin strcmp() function. The GCC code is correct.
-+#
-+# Valgrind bug: https://bugs.kde.org/show_bug.cgi?id=264936
-+{
-+   bpo-38118: Valgrind emits false alarm on GCC builtin strcmp()
-+   Memcheck:Cond
-+   fun:PyUnicode_Decode
-+}
-+
-+
-+###
-+### These occur from somewhere within the SSL, when running
-+###  test_socket_sll.  They are too general to leave on by default.
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:memset
-+###}
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:memset
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:MD5_Update
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:MD5_Update
-+###}
-+
-+# Fedora's package "openssl-1.0.1-0.1.beta2.fc17.x86_64" on x86_64
-+# See http://bugs.python.org/issue14171
-+{
-+   openssl 1.0.1 prng 1
-+   Memcheck:Cond
-+   fun:bcmp
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 2
-+   Memcheck:Cond
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 3
-+   Memcheck:Value8
-+   fun:_x86_64_AES_encrypt_compact
-+   fun:AES_encrypt
-+}
-+
-+#
-+# All of these problems come from using test_socket_ssl
-+#
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_bin2bn
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libcrypto.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_set_key_unchecked
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_encrypt2
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BUF_MEM_grow_clean
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:memcpy
-+   fun:ssl3_read_bytes
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:SHA1_Update
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:SHA1_Update
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-+{
-+   wcscmp_false_positive
-+   Memcheck:Addr8
-+   fun:wcscmp
-+   fun:_PyOS_GetOpt
-+   fun:Py_Main
-+   fun:main
-+}
-+
-+# Additional suppressions for the unified decimal tests:
-+{
-+   test_decimal
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_decimal2
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index b40ed64edb5..8c55861c147 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -1576,6 +1576,62 @@ const numeric numeric::div(const numeric &other) const {
-         }
- }
- 
-+
-+// Compute `a^b` as an integer, where a is an integer. Assign to ``res``` if it is integral, or return ``false``.
-+// The nonnegative real root is taken for even denominators. To be used inside numeric::integer_rational_power,
-+// to handle the special case of integral ``a``.
-+bool integer_rational_power_of_mpz(
-+        numeric& res,
-+        const numeric& a,
-+        const numeric& b
-+) {
-+        if (a.t != MPZ)
-+                throw std::runtime_error("integer_rational_power_of_mpz: bad input");
-+        mpz_t z;
-+        mpz_init(z);
-+        mpz_set_ui(z, 0);
-+        int sgn = mpz_sgn(a.v._bigint);
-+        if (mpz_cmp_ui(a.v._bigint, 1) == 0
-+            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
-+                mpz_set_ui(z, 1);
-+        else if (sgn == 0) {
-+                res = *_num0_p;
-+                mpz_clear(z);
-+                return true;
-+        }
-+        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1)) {
-+                mpz_clear(z);
-+                return false;
-+        } else {
-+                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-+                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat))) {
-+                        // too big to take roots/powers
-+                        mpz_clear(z);
-+                        return false;
-+                }
-+                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
-+                        if (mpz_perfect_square_p(a.v._bigint)) {
-+                                mpz_sqrt(z, a.v._bigint);
-+                        } else {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                else {
-+                        bool exact = mpz_root(z, a.v._bigint,
-+                                              mpz_get_ui(mpq_denref(b.v._bigrat)));
-+                        if (not exact) {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
-+        }
-+        res = numeric(z);   // transfers ownership, no mpz_clear
-+        return true;
-+}
-+
-+
- // Compute `a^b` as an integer, if it is integral, or return ``false``.
- // The nonnegative real root is taken for even denominators.
- bool numeric::integer_rational_power(numeric& res,
-@@ -1598,13 +1654,12 @@ bool numeric::integer_rational_power(numeric& res,
-                 if (a.v._long < 0
-                     and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
-                         return false;
--                long z;
-                 if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-                     or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
-                 // too big to take roots/powers
-                         return false;
-                 if (b.is_equal(*_num1_2_p)) {
--                        z = std::lround(std::sqrt(a.v._long));
-+                        long z = std::lround(std::sqrt(a.v._long));
-                         if (a.v._long == z*z) {
-                                 res = numeric(z);
-                                 return true;
-@@ -1613,44 +1668,11 @@ bool numeric::integer_rational_power(numeric& res,
-                 }
-                 return integer_rational_power(res, a.to_bigint(), b);
-         }
--        if (a.t != MPZ)
--                throw std::runtime_error("integer_rational_power: bad input");
--        int sgn = mpz_sgn(a.v._bigint);
--        mpz_t z;
--        mpz_init(z);
--        mpz_set_ui(z, 0);
--        if (mpz_cmp_ui(a.v._bigint, 1) == 0
--            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
--                mpz_set_ui(z, 1);
--        else if (sgn == 0) {
--                res = *_num0_p;
--                return true;
--        }
--        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
--                return false;
--        else {
--                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
--                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
--                // too big to take roots/powers
--                        return false;
--                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
--                        if (mpz_perfect_square_p(a.v._bigint))
--                                mpz_sqrt(z, a.v._bigint);
--                        else
--                                return false;
--                }
--                else {
--                        bool exact = mpz_root(z, a.v._bigint,
--                                        mpz_get_ui(mpq_denref(b.v._bigrat)));
--                        if (not exact)
--                                return false;
--                }
--                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
--        }
--        res = numeric(z);
--        return true;
-+        // otherwise: a is integer
-+        return integer_rational_power_of_mpz(res, a, b);
- }
- 
-+
- // for a^b return c,d such that a^b = c*d^b
- // only for MPZ/MPQ base and MPQ exponent
- void rational_power_parts(const numeric& a_orig, const numeric& b_orig,
-diff --git a/src/sage/tests/memcheck/__init__.py b/src/sage/tests/memcheck/__init__.py
-new file mode 100644
-index 00000000000..e69de29bb2d
-diff --git a/src/sage/tests/memcheck/run_tests.py b/src/sage/tests/memcheck/run_tests.py
-new file mode 100644
-index 00000000000..6ff4503a81b
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests.py
-@@ -0,0 +1,24 @@
-+import types
-+
-+
-+def run_tests() -> None:
-+    """
-+    Run all memcheck tests
-+    """
-+    from sage.tests.memcheck import symbolic_expression
-+    run_tests_in_module(symbolic_expression)
-+
-+
-+def run_tests_in_module(mod: types.ModuleType) -> None:
-+    """
-+    Run all memcheck tests in the given module
-+    """
-+    for entry in dir(mod):
-+        if not entry.startswith('test_'):
-+            continue
-+        test_func = getattr(mod, entry)
-+        test_func()
-+
-+
-+if __name__ == '__main__':
-+    run_tests()
-diff --git a/src/sage/tests/memcheck/run_tests_in_valgrind.py b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-new file mode 100644
-index 00000000000..df5ad0e92b2
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-@@ -0,0 +1,35 @@
-+"""
-+Launch valgrind and run the memory leak tests
-+
-+
-+From the commandline, run
-+
-+    sage -python -m sage.tests.memcheck.run_tests_in_valgrind
-+
-+to launch valgrind and execute the memory leak tests. Requires valgrind
-+to be installed. Alternatively, run as a unit test:
-+
-+    sage: from sage.tests.memcheck.run_tests_in_valgrind import run_tests_in_valgrind
-+    sage: run_tests_in_valgrind()    # optional - valgrind
-+"""
-+
-+import subprocess
-+
-+
-+def run_tests_in_valgrind() -> None:
-+    """
-+    Run the sage.tests.memcheck.run_tests module inside valgrind
-+    """
-+    subprocess.check_call([
-+        'valgrind',
-+        '--suppressions=src/sage/ext_data/valgrind/valgrind-python.supp',
-+        '--show-possibly-lost=no',
-+        '--show-reachable=no',
-+        './venv/bin/python',
-+        '-m',
-+        'sage.tests.memcheck.run_tests'
-+    ])
-+
-+
-+if __name__ == '__main__':
-+    run_tests_in_valgrind()
-diff --git a/src/sage/tests/memcheck/symbolic_expression.py b/src/sage/tests/memcheck/symbolic_expression.py
-new file mode 100644
-index 00000000000..52182fbe62d
---- /dev/null
-+++ b/src/sage/tests/memcheck/symbolic_expression.py
-@@ -0,0 +1,11 @@
-+from sage.tests.memcheck.verify_no_leak import verify_no_leak
-+
-+
-+def test_sqrt_sqrt_2() -> None:
-+    from sage.misc.functional import sqrt
-+    T2 = sqrt(2)
-+
-+    def sqrt_T2() -> None:
-+        sqrt(T2)
-+
-+    verify_no_leak(sqrt_T2)
-diff --git a/src/sage/tests/memcheck/verify_no_leak.py b/src/sage/tests/memcheck/verify_no_leak.py
-new file mode 100644
-index 00000000000..89ca90cf89c
---- /dev/null
-+++ b/src/sage/tests/memcheck/verify_no_leak.py
-@@ -0,0 +1,27 @@
-+from typing import Tuple, Sequence, List, Callable, Any
-+import valgrind
-+
-+
-+def verify_no_leak(callback: Callable[[], Any],
-+                   repeat: int = 10000,
-+                   fuzzy: int = 10,
-+                   ) -> None:
-+    """
-+    Verify that the callback does not generate new definitely lost blocks
-+
-+    Raises an assertion if the callback leaks memory
-+    """
-+    callback()   # warm_up
-+    initial_blocks = (0, 0, 0, 0)
-+    valgrind.memcheck_do_leak_check()
-+    initial_blocks = valgrind.memcheck_count_leak_blocks()
-+    for _ in range(repeat):
-+        callback()
-+    valgrind.memcheck_do_leak_check()
-+    leak_blocks = valgrind.memcheck_count_leak_blocks()
-+    leak = leak_blocks[0] - initial_blocks[0]
-+    if leak < repeat - fuzzy:
-+        return  # callback did not leak at least once per call
-+    blocks = round(leak / repeat, 2)
-+    message = f'{callback} leaked {blocks} block on average ({repeat} iterations)'
-+    raise AssertionError(message)
diff --git a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch b/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
deleted file mode 100644
index 684b62affaf5a..0000000000000
--- a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx
-index 8f46570313d..a8e73e57b52 100644
---- a/src/sage/libs/ecl.pyx
-+++ b/src/sage/libs/ecl.pyx
-@@ -563,15 +563,15 @@ cdef class EclObject:
-     Floats in Python are IEEE double, which LISP has as well. However,
-     the printing of floating point types in LISP depends on settings::
- 
--        sage: a = EclObject(float(10^40))
-+        sage: a = EclObject(float(1.234e40))
-         sage: ecl_eval("(setf *read-default-float-format* 'single-float)")
-         <ECL: SINGLE-FLOAT>
-         sage: a
--        <ECL: 1.d40>
-+        <ECL: 1.234d40>
-         sage: ecl_eval("(setf *read-default-float-format* 'double-float)")
-         <ECL: DOUBLE-FLOAT>
-         sage: a
--        <ECL: 1.e40>
-+        <ECL: 1.234e40>
- 
-     Tuples are translated to dotted lists::
- 
-diff --git a/src/sage/libs/eclsig.h b/src/sage/libs/eclsig.h
-index e249ccf6874..005b2d99d0b 100644
---- a/src/sage/libs/eclsig.h
-+++ b/src/sage/libs/eclsig.h
-@@ -45,7 +45,11 @@ static inline void ecl_sig_off(void)
-     sig_off();
- }
- 
-+#if ECL_VERSION_NUMBER < 230909
- #define ecl_mpz_from_bignum(obj) ((obj)->big.big_num)
-+#else
-+#define ecl_mpz_from_bignum(obj) ecl_bignum(obj)
-+#endif
- 
- cl_object ecl_bignum_from_mpz(mpz_t num)
- {
diff --git a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch b/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
deleted file mode 100644
index e858f2fd4a445..0000000000000
--- a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
-index 59f10f6b13f..adcccff059b 100644
---- a/src/sage/plot/graphics.py
-+++ b/src/sage/plot/graphics.py
-@@ -36,6 +36,7 @@
- # ****************************************************************************
- 
- import os
-+from numbers import Integral
- from collections.abc import Iterable
- from math import isnan
- import sage.misc.verbose
-@@ -2874,6 +2875,11 @@ def matplotlib(self, filename=None,
-                 weight=lopts.pop('font_weight', 'medium'),
-                 variant=lopts.pop('font_variant', 'normal'))
-             color = lopts.pop('back_color', 'white')
-+            if 'loc' in lopts:
-+                loc = lopts['loc']
-+                if isinstance(loc, Integral):
-+                    # matplotlib 3.8 doesn't support sage integers
-+                    lopts['loc'] = int(loc)
-             leg = subplot.legend(prop=prop, **lopts)
-             if leg is None:
-                 from warnings import warn
diff --git a/srcpkgs/sagemath/patches/36403-00pre.patch b/srcpkgs/sagemath/patches/36403-00pre.patch
deleted file mode 100644
index 060404d5430de..0000000000000
--- a/srcpkgs/sagemath/patches/36403-00pre.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-Minor patch so that #36403 applies cleanly over sagemath 10.1
-
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 2053bca80c3..86aca6e00d8 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15123,7 +15302,8 @@ cdef class Matrix(Matrix1):
-             sage: N.conjugate_transpose()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object has no attribute 'conjugate'
-+            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
-+            has no attribute 'conjugate'
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 525ea5aa934..52afed49d64 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -55,7 +55,7 @@ cdef class AttributeErrorMessage:
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-         sage: x = polygen(ZZ, 'x')
--        sage: QQ[x].gen().bla                                                           # optional - sage.libs.flint
-+        sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
diff --git a/srcpkgs/sagemath/patches/36407-python_3.12.patch b/srcpkgs/sagemath/patches/36407-python_3.12.patch
deleted file mode 100644
index c75c275c30764..0000000000000
--- a/srcpkgs/sagemath/patches/36407-python_3.12.patch
+++ /dev/null
@@ -1,1744 +0,0 @@
-diff --git a/build/sage_bootstrap/package.py b/build/sage_bootstrap/package.py
-index 15b342223c4..eb82f96e05f 100644
---- a/build/sage_bootstrap/package.py
-+++ b/build/sage_bootstrap/package.py
-@@ -303,7 +303,7 @@ def _init_checksum(self):
-         # Name of the directory containing the checksums.ini file
-         self.__tarball_package_name = os.path.realpath(checksums_ini).split(os.sep)[-2]
- 
--    VERSION_PATCHLEVEL = re.compile('(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
-+    VERSION_PATCHLEVEL = re.compile(r'(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
- 
-     def _init_version(self):
-         try:
-diff --git a/src/doc/en/thematic_tutorials/coercion_and_categories.rst b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-index bb23331c151..7f5712caea7 100644
---- a/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-+++ b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-@@ -1223,7 +1223,7 @@ However, only "elementary" construction functors have a rank::
-     sage: (Fract*Poly).rank
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'
-+    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'...
- 
- .. end of output
- 
-diff --git a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-index 553a946c4d8..3cd71a9bad4 100644
---- a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-+++ b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-@@ -318,7 +318,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: e.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'...
- 
-         sage: id4 = SymmetricGroup(4).one()
-         sage: type(id4)
-@@ -326,7 +326,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: id4.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'
-+        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'...
- 
- .. note::
- 
-diff --git a/src/sage/algebras/cluster_algebra.py b/src/sage/algebras/cluster_algebra.py
-index b72d2a12976..14669dfed5c 100644
---- a/src/sage/algebras/cluster_algebra.py
-+++ b/src/sage/algebras/cluster_algebra.py
-@@ -167,7 +167,7 @@
-     sage: (t*s).g_vector()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'
-+    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'...
-     sage: A = ClusterAlgebra(['A', 2], principal_coefficients=True)
-     sage: A.explore_to_depth(infinity)
-     sage: s = A.cluster_variable((0, -1)); s
-diff --git a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-index e4a91723558..343ee8a66f9 100644
---- a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-+++ b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-@@ -109,7 +109,7 @@ class WeylLieConformalAlgebra(LieConformalAlgebraWithStructureCoefficients):
-         sage: alpha0.degree()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'
-+        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'...
- 
-     TESTS::
- 
-diff --git a/src/sage/algebras/steenrod/steenrod_algebra.py b/src/sage/algebras/steenrod/steenrod_algebra.py
-index 978a3557a9d..7c4d444f81c 100644
---- a/src/sage/algebras/steenrod/steenrod_algebra.py
-+++ b/src/sage/algebras/steenrod/steenrod_algebra.py
-@@ -1080,7 +1080,7 @@ def homogeneous_component(self, n):
-             sage: a.antipode() # not defined
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'
-+            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'...
-             sage: A(a).antipode() # convert to elt of A, then compute antipode
-             Sq(2,1) + Sq(5)
- 
-diff --git a/src/sage/all__sagemath_repl.py b/src/sage/all__sagemath_repl.py
-index 8d0b43679ca..c31b206bcb8 100644
---- a/src/sage/all__sagemath_repl.py
-+++ b/src/sage/all__sagemath_repl.py
-@@ -79,6 +79,23 @@
-                         message=r"Use setlocale\(\), getencoding\(\) and getlocale\(\) instead",
-                         module='docutils.io')
- 
-+# triggered by dateutil 2.8.2 and sphinx 7.0.1 on Python 3.12
-+# see: https://github.com/dateutil/dateutil/pull/1285
-+# see: https://github.com/sphinx-doc/sphinx/pull/11468
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"datetime.datetime.utcfromtimestamp\(\) is deprecated",
-+                        module='dateutil.tz.tz|sphinx.(builders.gettext|util.i18n)')
-+
-+# triggered on Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"This process.* is multi-threaded, "
-+                                r"use of .*\(\) may lead to deadlocks in the child.")
-+
-+# pickling of itertools is deprecated in Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"Pickle, copy, and deepcopy support will be "
-+                                r"removed from itertools in Python 3.14.")
-+
- 
- from .all__sagemath_objects import *
- from .all__sagemath_environment import *
-diff --git a/src/sage/arith/long.pxd b/src/sage/arith/long.pxd
-index 0031a0ae337..3ea70cef571 100644
---- a/src/sage/arith/long.pxd
-+++ b/src/sage/arith/long.pxd
-@@ -19,6 +19,8 @@ from libc.limits cimport LONG_MIN, LONG_MAX
- from cpython.object cimport Py_SIZE
- from cpython.number cimport PyNumber_Index, PyIndex_Check
- from cpython.longintrepr cimport py_long, PyLong_SHIFT, digit
-+from sage.cpython.pycore_long cimport (
-+    ob_digit, _PyLong_IsNegative, _PyLong_DigitCount)
- 
- from sage.libs.gmp.mpz cimport mpz_fits_slong_p, mpz_get_si
- from sage.rings.integer_fake cimport is_Integer, Integer_AS_MPZ
-@@ -299,8 +301,11 @@ cdef inline bint integer_check_long_py(x, long* value, int* err):
-         return 0
- 
-     # x is a Python "int" (aka PyLongObject or py_long in cython)
--    cdef const digit* D = (<py_long>x).ob_digit
--    cdef Py_ssize_t size = Py_SIZE(x)
-+    cdef const digit* D = ob_digit(x)
-+    cdef Py_ssize_t size = _PyLong_DigitCount(x)
-+
-+    if _PyLong_IsNegative(x):
-+        size = -size
- 
-     # We assume PyLong_SHIFT <= BITS_IN_LONG <= 3 * PyLong_SHIFT.
-     # This is true in all the default configurations:
-diff --git a/src/sage/categories/category.py b/src/sage/categories/category.py
-index 57ef7f4184b..29bce8ee415 100644
---- a/src/sage/categories/category.py
-+++ b/src/sage/categories/category.py
-@@ -2129,7 +2129,7 @@ def _with_axioms(self, axioms):
-             sage: Semigroups().Inverse()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'
-+            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'...
-             sage: Semigroups()._with_axioms(["Inverse"])
-             Category of semigroups
- 
-diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py
-index 5227792e725..4775d4e5bf1 100644
---- a/src/sage/categories/category_with_axiom.py
-+++ b/src/sage/categories/category_with_axiom.py
-@@ -554,7 +554,7 @@ class from the base category class::
-     sage: Magmas.Unital.Associative
-     Traceback (most recent call last):
-     ...
--    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'
-+    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'...
- 
- The purpose of this section is to explain the design of the code
- layout and the rationale for this mismatch.
-@@ -769,7 +769,7 @@ def _(): return LazyImport('sage.categories.rngs', 'Rngs', at_startup=True)
-     sage: Semirings().NoZeroDivisors()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'
-+    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'...
- 
- Concretely, this is to be implemented by defining the new axiom in the
- (``SubcategoryMethods`` nested class of the) appropriate category with
-diff --git a/src/sage/categories/enumerated_sets.py b/src/sage/categories/enumerated_sets.py
-index a8bea53f907..b0ea05d0563 100644
---- a/src/sage/categories/enumerated_sets.py
-+++ b/src/sage/categories/enumerated_sets.py
-@@ -610,7 +610,7 @@ def _list_from_iterator(self):
-                 sage: (QQ^2).list()  # indirect test                                    # needs sage.modules
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'
-+                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'...
- 
-             Here we test that for an object that does not know whether it
-             is finite or not.  Calling ``x.list()`` simply tries to create
-@@ -622,11 +622,11 @@ def _list_from_iterator(self):
-                 sage: Q.is_finite()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'...
-                 sage: Q.list()   # indirect test
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'...
- 
-             Here is another example. We artificially create a version of
-             the ring of integers that does not know whether it is finite
-diff --git a/src/sage/categories/examples/sets_cat.py b/src/sage/categories/examples/sets_cat.py
-index e0853d63f94..fbadb9ca405 100644
---- a/src/sage/categories/examples/sets_cat.py
-+++ b/src/sage/categories/examples/sets_cat.py
-@@ -619,7 +619,7 @@ class PrimeNumbers_Facade(PrimeNumbers_Abstract):
-         sage: pf.next()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'...
- 
-     unlike in the other implementations::
- 
-diff --git a/src/sage/categories/homset.py b/src/sage/categories/homset.py
-index 22ba9d047fc..2a8b8aeedeb 100644
---- a/src/sage/categories/homset.py
-+++ b/src/sage/categories/homset.py
-@@ -632,7 +632,7 @@ def __init__(self, X, Y, category=None, base=None, check=True):
-             sage: H = MyHomset(X, Y, category=1, base = ZZ, check = False)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'...
-             sage: P.<t> = ZZ[]
-             sage: f = P.hom([1/2*t])
-             sage: f.parent().domain()
-diff --git a/src/sage/categories/modules_with_basis.py b/src/sage/categories/modules_with_basis.py
-index e97bf851388..c4933d0657f 100644
---- a/src/sage/categories/modules_with_basis.py
-+++ b/src/sage/categories/modules_with_basis.py
-@@ -2456,7 +2456,7 @@ def apply_multilinear_morphism(self, f, codomain=None):
-                     sage: tensor([a, b]).apply_multilinear_morphism(f)                  # needs sage.modules
-                     Traceback (most recent call last):
-                     ...
--                    AttributeError: 'int' object has no attribute 'parent'
-+                    AttributeError: 'int' object has no attribute 'parent'...
- 
-                 Here we consider an example where the codomain is a
-                 module with basis with a different base ring::
-diff --git a/src/sage/categories/monoids.py b/src/sage/categories/monoids.py
-index 38dd7248c9d..28474bd17b6 100644
---- a/src/sage/categories/monoids.py
-+++ b/src/sage/categories/monoids.py
-@@ -556,7 +556,7 @@ def algebra_generators(self):
-                     Traceback (most recent call last):
-                     ...
-                     AttributeError: 'IntegerModMonoid_with_category' object
--                    has no attribute 'monoid_generators'
-+                    has no attribute 'monoid_generators'...
-                     sage: Z12.semigroup_generators()
-                     Family (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
-                     sage: Z12.algebra(QQ).algebra_generators()                          # needs sage.modules
-diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py
-index 494e8154c80..ec5120e41e6 100644
---- a/src/sage/combinat/finite_state_machine.py
-+++ b/src/sage/combinat/finite_state_machine.py
-@@ -1835,7 +1835,7 @@ def __getstate__(self):
-             sage: T1.transitions
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'FSMState' object has no attribute 'transitions'
-+            AttributeError: 'FSMState' object has no attribute 'transitions'...
-             sage: A1 = loads(dumps(A))
-             sage: all(A.state(j) == A1.state(j) for j in [0, 1])
-             True
-diff --git a/src/sage/combinat/growth.py b/src/sage/combinat/growth.py
-index cf8d18c1764..766eea37917 100644
---- a/src/sage/combinat/growth.py
-+++ b/src/sage/combinat/growth.py
-@@ -371,7 +371,7 @@
-     sage: GrowthDiagram(RulePascal(), [3,1,2])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'RulePascal' object has no attribute 'forward_rule'
-+    AttributeError: 'RulePascal' object has no attribute 'forward_rule'...
- 
- We now re-implement the rule where we provide the dual graded graphs::
- 
-diff --git a/src/sage/combinat/integer_lists/lists.py b/src/sage/combinat/integer_lists/lists.py
-index 5143e5cb5e8..9117a6076f7 100644
---- a/src/sage/combinat/integer_lists/lists.py
-+++ b/src/sage/combinat/integer_lists/lists.py
-@@ -261,7 +261,7 @@ def __getattr__(self, name):
-             sage: L.foo
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'foo'
-+            AttributeError: 'NoneType' object has no attribute 'foo'...
-         """
-         return getattr(self.backend, name)
- 
-diff --git a/src/sage/combinat/posets/posets.py b/src/sage/combinat/posets/posets.py
-index c31597c72e9..c74bfc67cee 100644
---- a/src/sage/combinat/posets/posets.py
-+++ b/src/sage/combinat/posets/posets.py
-@@ -8825,7 +8825,7 @@ def is_induced_subposet(self, other):
-             sage: Poset().is_induced_subposet('junk')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'subposet'
-+            AttributeError: 'str' object has no attribute 'subposet'...
-         """
-         if (not self._is_facade or (isinstance(other, FinitePoset) and
-                                     not other._is_facade)):
-diff --git a/src/sage/cpython/atexit.pyx b/src/sage/cpython/atexit.pyx
-index 961aa348d0a..e5a82735137 100644
---- a/src/sage/cpython/atexit.pyx
-+++ b/src/sage/cpython/atexit.pyx
-@@ -154,6 +154,10 @@ cdef extern from *:
-     #undef _PyGC_FINALIZED
-     #include "internal/pycore_interp.h"
-     #include "internal/pycore_pystate.h"
-+    #if PY_VERSION_HEX >= 0x030c0000
-+    // struct atexit_callback was renamed in 3.12 to atexit_py_callback
-+    #define atexit_callback atexit_py_callback
-+    #endif
-     static atexit_callback ** _atexit_callbacks(PyObject *self) {
-         PyInterpreterState *interp = _PyInterpreterState_GET();
-         struct atexit_state state = interp->atexit;
-diff --git a/src/sage/cpython/debug.pyx b/src/sage/cpython/debug.pyx
-index 986abff2a99..cdaca3a4854 100644
---- a/src/sage/cpython/debug.pyx
-+++ b/src/sage/cpython/debug.pyx
-@@ -78,7 +78,7 @@ def getattr_debug(obj, name, default=_no_default):
- 
-     EXAMPLES::
- 
--        sage: _ = getattr_debug(list, "reverse")
-+        sage: _ = getattr_debug(list, "reverse")  # not tested - broken in python 3.12
-         getattr_debug(obj=<class 'list'>, name='reverse'):
-           type(obj) = <class 'type'>
-           object has __dict__ slot (<class 'dict'>)
-@@ -123,7 +123,7 @@ def getattr_debug(obj, name, default=_no_default):
-         sage: _ = getattr_debug(1, "foo")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'...
-         sage: _ = getattr_debug(1, "foo", "xyz")
-         getattr_debug(obj=1, name='foo'):
-           type(obj) = <class 'sage.rings.integer.Integer'>
-diff --git a/src/sage/cpython/dict_internal.h b/src/sage/cpython/dict_internal.h
-index 42a57bcb468..a5ee35bc198 100644
---- a/src/sage/cpython/dict_internal.h
-+++ b/src/sage/cpython/dict_internal.h
-@@ -169,6 +169,7 @@ dictkeys_set_index(PyDictKeysObject *keys, Py_ssize_t i, Py_ssize_t ix)
- #else   /* Python >= 3.11 */
- 
- #define Py_BUILD_CORE
-+#undef _PyGC_FINALIZED
- #include <internal/pycore_dict.h>
- 
- /************************************************************/
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 52afed49d64..1f49e5230c3 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -53,12 +53,12 @@ cdef class AttributeErrorMessage:
-         sage: 1.bla  #indirect doctest
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'...
-         sage: x = polygen(ZZ, 'x')
-         sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'...
- 
-     ::
- 
-@@ -144,7 +144,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(X, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: x = X()
-         sage: raw_getattr(x, "prop")
-         <property object at ...>
-@@ -173,7 +173,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(Y, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: y = Y()
-         sage: raw_getattr(y, "prop")
-         <property object at ...>
-@@ -278,7 +278,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     The integer ring is a parent, so, lazy attributes work::
- 
-@@ -289,7 +289,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(17, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     In general, descriptors are not yet well supported, because they
-     often do not accept to be cheated with the type of their instance::
-@@ -305,7 +305,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__weakref__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-     This was caught by :trac:`8296` for which we do a couple more tests::
- 
-@@ -314,7 +314,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: 1.__weakref__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-         sage: n = 1
-         sage: ip = get_ipython()                 # not tested: only works in interactive shell
-@@ -329,7 +329,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__call__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'...
- 
-     TESTS:
- 
-@@ -339,14 +339,14 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, type, "__name__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'...
- 
-     Non-strings as "name" are handled gracefully::
- 
-         sage: getattr_from_other_class(1, type, None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute None
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute None...
-     """
-     if not isinstance(cls, type):
-         raise TypeError(f"{cls!r} is not a type")
-diff --git a/src/sage/cpython/pycore_long.h b/src/sage/cpython/pycore_long.h
-new file mode 100644
-index 00000000000..ff1a73d097a
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.h
-@@ -0,0 +1,98 @@
-+#include "Python.h"
-+#include <stdbool.h>
-+
-+#if PY_VERSION_HEX >= 0x030C00A5
-+#define ob_digit(o)  (((PyLongObject*)o)->long_value.ob_digit)
-+#else
-+#define ob_digit(o)  (((PyLongObject*)o)->ob_digit)
-+#endif
-+
-+#if PY_VERSION_HEX >= 0x030C00A7
-+// taken from cpython:Include/internal/pycore_long.h @ 3.12
-+
-+/* Long value tag bits:
-+ * 0-1: Sign bits value = (1-sign), ie. negative=2, positive=0, zero=1.
-+ * 2: Reserved for immortality bit
-+ * 3+ Unsigned digit count
-+ */
-+#define SIGN_MASK 3
-+#define SIGN_ZERO 1
-+#define SIGN_NEGATIVE 2
-+#define NON_SIZE_BITS 3
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_ZERO;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_NEGATIVE;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    assert(PyLong_Check(op));
-+    return op->long_value.lv_tag >> NON_SIZE_BITS;
-+}
-+
-+#define TAG_FROM_SIGN_AND_SIZE(sign, size) ((1 - (sign)) | ((size) << NON_SIZE_BITS))
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+    assert(size >= 0);
-+    assert(-1 <= sign && sign <= 1);
-+    assert(sign != 0 || size == 0);
-+    op->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sign, (size_t)size);
-+}
-+
-+#else
-+// fallback for < 3.12
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) == 0;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) < 0;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) > 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    Py_ssize_t size = Py_SIZE(op);
-+    return size < 0 ? -size : size;
-+}
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION < 9)
-+// The function Py_SET_SIZE is defined starting with python 3.9.
-+    Py_SIZE(o) = size;
-+#else
-+    Py_SET_SIZE(op, sign < 0 ? -size : size);
-+#endif
-+}
-+
-+#endif
-diff --git a/src/sage/cpython/pycore_long.pxd b/src/sage/cpython/pycore_long.pxd
-new file mode 100644
-index 00000000000..41de637ff18
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.pxd
-@@ -0,0 +1,9 @@
-+from cpython.longintrepr cimport py_long, digit
-+
-+cdef extern from "pycore_long.h":
-+    digit* ob_digit(py_long o)
-+    bint _PyLong_IsZero(py_long o)
-+    bint _PyLong_IsNegative(py_long o)
-+    bint _PyLong_IsPositive(py_long o)
-+    Py_ssize_t _PyLong_DigitCount(py_long o)
-+    void _PyLong_SetSignAndDigitCount(py_long o, int sign, Py_ssize_t size)
-diff --git a/src/sage/crypto/classical.py b/src/sage/crypto/classical.py
-index 616dc861652..be899c781e5 100644
---- a/src/sage/crypto/classical.py
-+++ b/src/sage/crypto/classical.py
-@@ -494,7 +494,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: A.rank_by_chi_square("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_chi_square(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -703,7 +703,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: A.rank_by_squared_differences("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_squared_differences(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -2114,7 +2114,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: S.rank_by_chi_square("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_chi_square(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-@@ -2351,7 +2351,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: S.rank_by_squared_differences("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_squared_differences(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/crypto/mq/mpolynomialsystemgenerator.py b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-index 9028dab1d98..4416d9ef7f6 100644
---- a/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-+++ b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-@@ -156,7 +156,7 @@ def sbox(self):
-             sage: msg.sbox()
-             Traceback (most recent call last):
-             ...
--            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'
-+            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'...
-         """
-         return self._sbox
- 
-diff --git a/src/sage/data_structures/bitset.pyx b/src/sage/data_structures/bitset.pyx
-index 446062554c1..d9906b5edd2 100644
---- a/src/sage/data_structures/bitset.pyx
-+++ b/src/sage/data_structures/bitset.pyx
-@@ -967,7 +967,7 @@ cdef class FrozenBitset:
-             sage: None | FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute '_union'
-+            AttributeError: 'NoneType' object has no attribute '_union'...
-         """
-         return self._union(other)
- 
-@@ -1037,7 +1037,7 @@ cdef class FrozenBitset:
-             sage: None & FrozenBitset("101011")
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'intersection'
-+            AttributeError: 'NoneType' object has no attribute 'intersection'...
-         """
-         return self.intersection(other)
- 
-@@ -1106,7 +1106,7 @@ cdef class FrozenBitset:
-             sage: None - FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'difference'
-+            AttributeError: 'NoneType' object has no attribute 'difference'...
-         """
-         return self.difference(other)
- 
-@@ -1179,7 +1179,7 @@ cdef class FrozenBitset:
-             sage: None ^^ FrozenBitset('11111' * 10)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'
-+            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'...
-         """
-         return self.symmetric_difference(other)
- 
-diff --git a/src/sage/doctest/reporting.py b/src/sage/doctest/reporting.py
-index 361fea344c2..a3947c07e01 100644
---- a/src/sage/doctest/reporting.py
-+++ b/src/sage/doctest/reporting.py
-@@ -368,7 +368,7 @@ def report(self, source, timeout, return_code, results, output, pid=None):
-             sage: DTR.report(None, None, None, None, None)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'basename'
-+            AttributeError: 'NoneType' object has no attribute 'basename'...
- 
-         The only-errors mode does not output anything on success::
- 
-diff --git a/src/sage/dynamics/finite_dynamical_system.py b/src/sage/dynamics/finite_dynamical_system.py
-index e5fbf568b7e..4295070615a 100644
---- a/src/sage/dynamics/finite_dynamical_system.py
-+++ b/src/sage/dynamics/finite_dynamical_system.py
-@@ -240,7 +240,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-@@ -252,7 +252,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-diff --git a/src/sage/geometry/cone.py b/src/sage/geometry/cone.py
-index f0a8620011a..53f78a4b7b6 100644
---- a/src/sage/geometry/cone.py
-+++ b/src/sage/geometry/cone.py
-@@ -340,7 +340,7 @@ def Cone(rays, lattice=None, check=True, normalize=True):
-         sage: Cone([(1,0), (0,1)], check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     You can construct different "not" cones: not full-dimensional, not
-     strictly convex, not containing any rays::
-diff --git a/src/sage/geometry/fan.py b/src/sage/geometry/fan.py
-index 258544012fe..3aecc84a55b 100644
---- a/src/sage/geometry/fan.py
-+++ b/src/sage/geometry/fan.py
-@@ -443,7 +443,7 @@ def Fan(cones, rays=None, lattice=None, check=True, normalize=True,
-         sage: P2c = Fan(cones, rays, check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     Yet another way is to use functions :func:`FaceFan` and :func:`NormalFan`
-     to construct fans from :class:`lattice polytopes
-diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-index f0ac1e774a7..f03f0f832ff 100644
---- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-+++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-@@ -351,7 +351,7 @@ cdef class FaceIterator_base(SageObject):
-             sage: FaceIterator_base(2)  # indirect doctest
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'...
-         """
-         cdef int i
-         sig_free(self.structure.atom_rep)
-@@ -1945,7 +1945,8 @@ cdef inline int next_face_loop(iter_t structure) nogil except -1:
-         # The function is not supposed to be called,
-         # just prevent it from crashing.
-         # Actually raising an error here results in a bad branch prediction.
--        return -1
-+        # But return -1 results in a crash with python 3.12
-+        raise StopIteration
- 
-     # Getting ``[faces, n_faces, n_visited_all]`` according to dimension.
-     cdef face_list_t* faces = &structure.new_faces[structure.current_dimension]
-diff --git a/src/sage/geometry/toric_plotter.py b/src/sage/geometry/toric_plotter.py
-index 50b4008eb0f..950e3ba7ff8 100644
---- a/src/sage/geometry/toric_plotter.py
-+++ b/src/sage/geometry/toric_plotter.py
-@@ -706,7 +706,7 @@ def set_rays(self, generators):
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ToricPlotter' object has no attribute 'rays'
-+            AttributeError: 'ToricPlotter' object has no attribute 'rays'...
-             sage: tp.set_rays([(0,1)])
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Graphics object consisting of 2 graphics primitives
-diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
-index d0ec214bb3b..c8098ad578a 100644
---- a/src/sage/groups/matrix_gps/finitely_generated.py
-+++ b/src/sage/groups/matrix_gps/finitely_generated.py
-@@ -268,7 +268,7 @@ def MatrixGroup(*gens, **kwds):
-         sage: SL2C.gens()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'
-+        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'...
-     """
-     if isinstance(gens[-1], dict):   # hack for unpickling
-         kwds.update(gens[-1])
-diff --git a/src/sage/homology/chains.py b/src/sage/homology/chains.py
-index 87c0947c0b0..b9a54940943 100644
---- a/src/sage/homology/chains.py
-+++ b/src/sage/homology/chains.py
-@@ -298,7 +298,7 @@ def is_cycle(self):
-                 sage: chain.is_cocycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -325,7 +325,7 @@ def is_boundary(self):
-                 sage: chain.is_coboundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -539,7 +539,7 @@ def is_cocycle(self):
-                 sage: cochain.is_cycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -566,7 +566,7 @@ def is_coboundary(self):
-                 sage: cochain.is_boundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -604,7 +604,7 @@ def eval(self, other):
-                 sage: z.eval(c) # z is not a cochain
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'...
-                 sage: c.eval(c) # can't evaluate a cochain on a cochain
-                 Traceback (most recent call last):
-                 ...
-diff --git a/src/sage/homology/free_resolution.py b/src/sage/homology/free_resolution.py
-index e3d38de4240..280a479b438 100644
---- a/src/sage/homology/free_resolution.py
-+++ b/src/sage/homology/free_resolution.py
-@@ -275,7 +275,7 @@ def differential(self, i):
-             sage: FreeResolution.differiental(r, 1)
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'FreeResolution' has no attribute 'differiental'
-+            AttributeError: type object 'FreeResolution' has no attribute 'differiental'...
-         """
- 
-     def target(self):
-diff --git a/src/sage/interfaces/magma.py b/src/sage/interfaces/magma.py
-index b7a0ac20d03..529bfbc349b 100644
---- a/src/sage/interfaces/magma.py
-+++ b/src/sage/interfaces/magma.py
-@@ -824,7 +824,7 @@ def _coerce_from_special_method(self, x):
-             sage: magma._coerce_from_special_method('2 + 3')  # optional - magma
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute '_magma_init_'
-+            AttributeError: 'str' object has no attribute '_magma_init_'...
-         """
-         s = x._magma_init_(self)
-         a = self(s)
-diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
-index 58499396d6c..16119d20815 100644
---- a/src/sage/lfunctions/dokchitser.py
-+++ b/src/sage/lfunctions/dokchitser.py
-@@ -418,8 +418,8 @@ def init_coeffs(self, v, cutoff=1,
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
-index bbf289aa21c..e4968866303 100644
---- a/src/sage/lfunctions/pari.py
-+++ b/src/sage/lfunctions/pari.py
-@@ -141,8 +141,8 @@ def init_coeffs(self, v, cutoff=None, w=1):
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
-index 478caf9f9d0..363024ae281 100644
---- a/src/sage/libs/gap/element.pyx
-+++ b/src/sage/libs/gap/element.pyx
-@@ -380,7 +380,7 @@ cdef GapElement make_GapElement(parent, Obj obj):
-         sage: libgap(None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute '_libgap_init_'
-+        AttributeError: 'NoneType' object has no attribute '_libgap_init_'...
-     """
-     cdef GapElement r = GapElement.__new__(GapElement)
-     r._initialize(parent, obj)
-diff --git a/src/sage/libs/gmp/pylong.pxd b/src/sage/libs/gmp/pylong.pxd
-index a73f1da6d6f..84e1bb8cd87 100644
---- a/src/sage/libs/gmp/pylong.pxd
-+++ b/src/sage/libs/gmp/pylong.pxd
-@@ -2,9 +2,10 @@
- Various functions to deal with conversion mpz <-> Python int/long
- """
- 
-+from cpython.longintrepr cimport py_long
- from sage.libs.gmp.types cimport *
- 
- cdef mpz_get_pylong(mpz_srcptr z)
- cdef mpz_get_pyintlong(mpz_srcptr z)
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1
- cdef Py_hash_t mpz_pythonhash(mpz_srcptr z)
-diff --git a/src/sage/libs/gmp/pylong.pyx b/src/sage/libs/gmp/pylong.pyx
-index d5993cca5a5..1a36c29d3fa 100644
---- a/src/sage/libs/gmp/pylong.pyx
-+++ b/src/sage/libs/gmp/pylong.pyx
-@@ -28,6 +28,8 @@ AUTHORS:
- from cpython.object cimport Py_SIZE
- from cpython.long cimport PyLong_FromLong
- from cpython.longintrepr cimport _PyLong_New, py_long, digit, PyLong_SHIFT
-+from sage.cpython.pycore_long cimport (ob_digit, _PyLong_IsNegative,
-+    _PyLong_DigitCount, _PyLong_SetSignAndDigitCount)
- from .mpz cimport *
- 
- cdef extern from *:
-@@ -60,12 +62,9 @@ cdef mpz_get_pylong_large(mpz_srcptr z):
-     """
-     cdef size_t nbits = mpz_sizeinbase(z, 2)
-     cdef size_t pylong_size = (nbits + PyLong_SHIFT - 1) // PyLong_SHIFT
--    L = _PyLong_New(pylong_size)
--    mpz_export(L.ob_digit, NULL,
--            -1, sizeof(digit), 0, PyLong_nails, z)
--    if mpz_sgn(z) < 0:
--        # Set correct size
--        Py_SET_SIZE(L, -pylong_size)
-+    cdef py_long L = _PyLong_New(pylong_size)
-+    mpz_export(ob_digit(L), NULL, -1, sizeof(digit), 0, PyLong_nails, z)
-+    _PyLong_SetSignAndDigitCount(L, mpz_sgn(z), pylong_size)
-     return L
- 
- 
-@@ -88,16 +87,13 @@ cdef mpz_get_pyintlong(mpz_srcptr z):
-     return mpz_get_pylong_large(z)
- 
- 
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1:
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1:
-     """
-     Convert a Python ``long`` `L` to an ``mpz``.
-     """
--    cdef Py_ssize_t pylong_size = Py_SIZE(L)
--    if pylong_size < 0:
--        pylong_size = -pylong_size
--    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails,
--            (<py_long>L).ob_digit)
--    if Py_SIZE(L) < 0:
-+    cdef Py_ssize_t pylong_size = _PyLong_DigitCount(L)
-+    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails, ob_digit(L))
-+    if _PyLong_IsNegative(L):
-         mpz_neg(z, z)
- 
- 
-diff --git a/src/sage/manifolds/calculus_method.py b/src/sage/manifolds/calculus_method.py
-index f5830c0bc45..303dde6cd13 100644
---- a/src/sage/manifolds/calculus_method.py
-+++ b/src/sage/manifolds/calculus_method.py
-@@ -257,7 +257,7 @@ def simplify(self, expression, method=None):
-             sage: cm.simplify(f)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'
-+            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'...
- 
-         In the present case, one should either transform ``f`` to a SymPy
-         object::
-diff --git a/src/sage/manifolds/differentiable/vectorfield_module.py b/src/sage/manifolds/differentiable/vectorfield_module.py
-index d954b5d4839..af4bfb0ceec 100644
---- a/src/sage/manifolds/differentiable/vectorfield_module.py
-+++ b/src/sage/manifolds/differentiable/vectorfield_module.py
-@@ -885,7 +885,7 @@ def tensor(self, *args, **kwds):
-             sage: XM.tensor(XM).tensor(XM.dual().tensor(XM.dual()))
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'
-+            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'...
- 
-         .. SEEALSO::
- 
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 86aca6e00d8..a5f6716e731 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15303,7 +15303,7 @@ cdef class Matrix(Matrix1):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
--            has no attribute 'conjugate'
-+            has no attribute 'conjugate'...
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/matrix/matrix_cyclo_dense.pyx b/src/sage/matrix/matrix_cyclo_dense.pyx
-index f54f3423ded..a49bb6240e6 100644
---- a/src/sage/matrix/matrix_cyclo_dense.pyx
-+++ b/src/sage/matrix/matrix_cyclo_dense.pyx
-@@ -847,7 +847,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense):
-             sage: A.set_mutable()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'
-+            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'...
-             sage: B = A.__copy__()
-             sage: B[0,0] = 20
-             sage: B[0,0]
-diff --git a/src/sage/matrix/matrix_gfpn_dense.pyx b/src/sage/matrix/matrix_gfpn_dense.pyx
-index 4cccf473de1..8e8e4d7336b 100644
---- a/src/sage/matrix/matrix_gfpn_dense.pyx
-+++ b/src/sage/matrix/matrix_gfpn_dense.pyx
-@@ -159,7 +159,7 @@ cdef class FieldConverter_class:
-             sage: C.field_to_fel('foo')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'to_integer'
-+            AttributeError: 'str' object has no attribute 'to_integer'...
-         """
-         return FfFromInt(x.to_integer())
- 
-diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py
-index 6aab58352be..b5e6f52349b 100644
---- a/src/sage/matrix/matrix_space.py
-+++ b/src/sage/matrix/matrix_space.py
-@@ -1619,7 +1619,7 @@ def __getitem__(self, x):
-             sage: MS[2]
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'
-+            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'...
-         """
-         if isinstance(x, (integer.Integer, int)):
-             return self.list()[x]
-diff --git a/src/sage/matroids/lean_matrix.pyx b/src/sage/matroids/lean_matrix.pyx
-index 54c68e637c0..a137cbf70e5 100644
---- a/src/sage/matroids/lean_matrix.pyx
-+++ b/src/sage/matroids/lean_matrix.pyx
-@@ -1,5 +1,4 @@
- # sage.doctest: optional - sage.rings.finite_rings
--# cython: profile=True
- """
- Lean matrices
- 
-diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx
-index 36f563aa433..318c82f2b64 100644
---- a/src/sage/matroids/linear_matroid.pyx
-+++ b/src/sage/matroids/linear_matroid.pyx
-@@ -1134,7 +1134,7 @@ cdef class LinearMatroid(BasisExchangeMatroid):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.matroids.basis_matroid.BasisMatroid' object
--            has no attribute 'base_ring'
-+            has no attribute 'base_ring'...
-             sage: from sage.matroids.advanced import *
-             sage: M4 = BinaryMatroid(Matrix(M1))
-             sage: M5 = LinearMatroid(reduced_matrix=Matrix(GF(2), [[-1, 0, 1],
-diff --git a/src/sage/misc/dev_tools.py b/src/sage/misc/dev_tools.py
-index e7bf176592c..3ece7db2894 100644
---- a/src/sage/misc/dev_tools.py
-+++ b/src/sage/misc/dev_tools.py
-@@ -171,6 +171,7 @@ def load_submodules(module=None, exclude_pattern=None):
-         load sage.geometry.polyhedron.ppl_lattice_polygon... succeeded
-     """
-     from .package_dir import walk_packages
-+    import importlib.util
- 
-     if module is None:
-         import sage
-@@ -194,8 +195,12 @@ def load_submodules(module=None, exclude_pattern=None):
-         try:
-             sys.stdout.write("load %s..." % module_name)
-             sys.stdout.flush()
--            loader = importer.find_module(module_name)
--            loader.load_module(module_name)
-+            # see
-+            # https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
-+            spec = importer.find_spec(module_name)
-+            module = importlib.util.module_from_spec(spec)
-+            sys.modules[module_name] = module
-+            spec.loader.exec_module(module)
-             sys.stdout.write(" succeeded\n")
-         except (ValueError, AttributeError, TypeError, ImportError):
-             # we might get error because of cython code that has been
-diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py
-index c922b8f6f12..03697f08b7c 100644
---- a/src/sage/misc/functional.py
-+++ b/src/sage/misc/functional.py
-@@ -86,7 +86,7 @@ def base_field(x):
-         sage: R.base_field()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'
-+        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'...
-     """
-     try:
-         return x.base_field()
-diff --git a/src/sage/misc/instancedoc.pyx b/src/sage/misc/instancedoc.pyx
-index d8e1e4ac536..44ee70f64ba 100644
---- a/src/sage/misc/instancedoc.pyx
-+++ b/src/sage/misc/instancedoc.pyx
-@@ -256,7 +256,7 @@ cdef class InstanceDocDescriptor:
-             sage: descr.__delete__(obj)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'X' object has no attribute '__doc__'
-+            AttributeError: 'X' object has no attribute '__doc__'...
- 
-             sage: descr.__delete__([])
-             Traceback (most recent call last):
-diff --git a/src/sage/misc/lazy_attribute.pyx b/src/sage/misc/lazy_attribute.pyx
-index bdbec3b3ba1..1f07870b8ec 100644
---- a/src/sage/misc/lazy_attribute.pyx
-+++ b/src/sage/misc/lazy_attribute.pyx
-@@ -441,37 +441,37 @@ class lazy_attribute(_lazy_attribute):
-             sage: B().unimplemented_A # todo: not implemented
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'super' object has no attribute 'unimplemented_A'
-+            AttributeError: 'super' object has no attribute 'unimplemented_A'...
- 
-     We now make some systematic checks::
- 
-         sage: B().unimplemented_A
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: B().unimplemented_B
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: B().unimplemented_AB
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: B().unimplemented_B_implemented_A
-         1
- 
-         sage: C().unimplemented_A()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: C().unimplemented_B()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: C().unimplemented_AB()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: C().unimplemented_B_implemented_A # todo: not implemented
-         1
-     """
-diff --git a/src/sage/misc/object_multiplexer.py b/src/sage/misc/object_multiplexer.py
-index d4e811ef16e..00fd89d6652 100644
---- a/src/sage/misc/object_multiplexer.py
-+++ b/src/sage/misc/object_multiplexer.py
-@@ -85,7 +85,7 @@ def __getattr__(self, name):
-             sage: m.__bork__
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Multiplex' has no attribute '__bork__'
-+            AttributeError: 'Multiplex' has no attribute '__bork__'...
-         """
-         if name.startswith("__"):
-             raise AttributeError("'Multiplex' has no attribute '%s'" % name)
-diff --git a/src/sage/misc/sage_input.py b/src/sage/misc/sage_input.py
-index 66e78ecccbc..00e8d96ee9e 100644
---- a/src/sage/misc/sage_input.py
-+++ b/src/sage/misc/sage_input.py
-@@ -3461,7 +3461,7 @@ def verify_same(a, b):
-         sage: verify_same(1, 1r)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_same(1r, 1)
-         Traceback (most recent call last):
-         ...
-@@ -3525,7 +3525,7 @@ def verify_si_answer(x, answer, preparse):
-         sage: verify_si_answer(1, '1', False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_si_answer(1, 'ZZ(1)', None)
-     """
-     from sage.misc.sage_eval import sage_eval
-diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py
-index f0545be7d81..811afc48755 100644
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -602,7 +602,7 @@ def visit_Num(self, node):
-             On Python 3 negative numbers are parsed first, for some reason, as
-             a UnaryOp node.
-         """
--        return node.n
-+        return node.value
- 
-     def visit_Str(self, node):
-         r"""
-@@ -624,7 +624,7 @@ def visit_Str(self, node):
-             sage: [vis(s) for s in ['"abstract"', "'syntax'", r'''r"tr\ee"''']]
-             ['abstract', 'syntax', 'tr\\ee']
-         """
--        return node.s
-+        return node.value
- 
-     def visit_List(self, node):
-         """
-diff --git a/src/sage/modules/fp_graded/steenrod/module.py b/src/sage/modules/fp_graded/steenrod/module.py
-index 18460b0e9a1..4acfa6b4002 100755
---- a/src/sage/modules/fp_graded/steenrod/module.py
-+++ b/src/sage/modules/fp_graded/steenrod/module.py
-@@ -70,7 +70,7 @@
-     sage: SteenrodFPModule(ZZ, [0])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'
-+    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'...
- 
- AUTHORS:
- 
-diff --git a/src/sage/monoids/trace_monoid.py b/src/sage/monoids/trace_monoid.py
-index 00baa4d14f8..f8176a1e1f2 100644
---- a/src/sage/monoids/trace_monoid.py
-+++ b/src/sage/monoids/trace_monoid.py
-@@ -40,7 +40,6 @@
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from collections import OrderedDict
- from itertools import repeat, chain, product
- 
- from sage.misc.cachefunc import cached_method
-@@ -633,14 +632,14 @@ def _compute_dependence_stack(self, x):
-             sage: x = b*a*d*a*c*b
-             sage: M._compute_dependence_stack(x)
-             ({a, b, c, d},
--             OrderedDict([(a, [False, False, True, True, False]),
--                          (b, [True, False, False, False, True]),
--                          (c, [True, False, False, False]),
--                          (d, [False, False, True, False])]))
-+             {a: [False, False, True, True, False],
-+              b: [True, False, False, False, True],
-+              c: [True, False, False, False],
-+              d: [False, False, True, False]})
-         """
-         independence = self._independence
-         generators_set = set(e for e, _ in x)
--        stacks = OrderedDict(sorted((g, []) for g in generators_set))
-+        stacks = dict(sorted((g, []) for g in generators_set))
-         for generator, times in reversed(list(x)):
-             stacks[generator].extend(repeat(True, times))
-             for other_gen in generators_set:
-diff --git a/src/sage/parallel/map_reduce.py b/src/sage/parallel/map_reduce.py
-index 11e0673ee91..5441943731d 100644
---- a/src/sage/parallel/map_reduce.py
-+++ b/src/sage/parallel/map_reduce.py
-@@ -1234,7 +1234,7 @@ def finish(self):
-             sage: S.print_communication_statistics()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'RESetMPExample' object has no attribute '_stats'
-+            AttributeError: 'RESetMPExample' object has no attribute '_stats'...
- 
-             sage: S.finish()
- 
-diff --git a/src/sage/plot/colors.py b/src/sage/plot/colors.py
-index 8c0db2b3c34..3281199400b 100644
---- a/src/sage/plot/colors.py
-+++ b/src/sage/plot/colors.py
-@@ -1099,7 +1099,7 @@ def __getattr__(self, name):
-             sage: cols.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ColorsDict' has no attribute or colormap punk
-+            AttributeError: 'ColorsDict' has no attribute or colormap punk...
-         """
-         try:
-             return self[name]
-@@ -1599,7 +1599,7 @@ def __getattr__(self, name):
-             sage: maps.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Colormaps' has no attribute or colormap punk
-+            AttributeError: 'Colormaps' has no attribute or colormap punk...
-             sage: maps['punk']
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/rings/asymptotic/asymptotic_ring.py b/src/sage/rings/asymptotic/asymptotic_ring.py
-index b07319382d3..994490e6616 100644
---- a/src/sage/rings/asymptotic/asymptotic_ring.py
-+++ b/src/sage/rings/asymptotic/asymptotic_ring.py
-@@ -1091,7 +1091,7 @@ def monomial_coefficient(self, monomial):
-             sage: O(n).monomial_coefficient(n)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'
-+            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'...
- 
-         The ``monomial`` must be exact::
- 
-diff --git a/src/sage/rings/asymptotic/growth_group.py b/src/sage/rings/asymptotic/growth_group.py
-index 27c14592bca..5be12537d62 100644
---- a/src/sage/rings/asymptotic/growth_group.py
-+++ b/src/sage/rings/asymptotic/growth_group.py
-@@ -1572,7 +1572,7 @@ def variable_names(self):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'GenericGrowthGroup_with_category.element_class' object
--            has no attribute 'is_one'
-+            has no attribute 'is_one'...
-         """
-         if self.is_one():
-             return tuple()
-diff --git a/src/sage/rings/ideal.py b/src/sage/rings/ideal.py
-index d36d9406f32..01c9fa3bf2d 100644
---- a/src/sage/rings/ideal.py
-+++ b/src/sage/rings/ideal.py
-@@ -1553,7 +1553,7 @@ def gcd(self, other):
-             sage: J.gcd(I)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Ideal_generic' object has no attribute 'gcd'
-+            AttributeError: 'Ideal_generic' object has no attribute 'gcd'...
- 
-         Note::
- 
-diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
-index 7fe89197011..8832d27e8ea 100644
---- a/src/sage/rings/number_field/number_field.py
-+++ b/src/sage/rings/number_field/number_field.py
-@@ -3823,7 +3823,7 @@ def primes_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
-         """
-         if degree is not None:
-             degree = ZZ(degree)
-@@ -3917,7 +3917,7 @@ def prime_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
- 
-         """
-         ids = self.primes_above(x, degree)
-@@ -5926,7 +5926,7 @@ def factor(self, n):
-             sage: L.factor(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'...
- 
-         AUTHORS:
- 
-@@ -12698,7 +12698,7 @@ def is_real_place(v):
-         sage: is_real_place(v_fin)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'
-+        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'...
- 
-     """
-     RR = sage.rings.real_mpfr.RealField(53)
-diff --git a/src/sage/rings/padics/generic_nodes.py b/src/sage/rings/padics/generic_nodes.py
-index 7047020edec..b6b514d4005 100644
---- a/src/sage/rings/padics/generic_nodes.py
-+++ b/src/sage/rings/padics/generic_nodes.py
-@@ -740,7 +740,7 @@ def _get_element_class(self, name=None):
-             sage: R._get_element_class("foobar")
-             Traceback (most recent call last):
-             ...
--            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'
-+            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'...
-         """
-         if name is None:
-             return self.Element
-diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx
-index c5a1129aecf..a5b7f937cfe 100644
---- a/src/sage/rings/polynomial/polynomial_element.pyx
-+++ b/src/sage/rings/polynomial/polynomial_element.pyx
-@@ -10793,7 +10793,7 @@ cdef class Polynomial(CommutativePolynomial):
-             sage: (y**2 + x).nth_root(2)
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... has no attribute 'nth_root'
-+            AttributeError: ... has no attribute 'nth_root'...
- 
-         TESTS::
- 
-@@ -11831,7 +11831,7 @@ cdef class Polynomial_generic_dense(Polynomial):
-             sage: int(1) // x  # check that this doesn't segfault
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'int' has no attribute 'base_ring'
-+            AttributeError: type object 'int' has no attribute 'base_ring'...
-         """
-         if have_same_parent(self, right):
-             return (<Polynomial_generic_dense>self)._floordiv_(<Polynomial_generic_dense>right)
-diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-index e372be888ee..aca4f08420f 100644
---- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
-+++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-@@ -2362,7 +2362,7 @@ def field_extension(self, names):
-             sage: F, g, h = S.field_extension('b')                                      # needs sage.rings.finite_rings
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'
-+            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'...
- 
-         Over a finite field, the corresponding field extension is not a
-         number field::
-diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx
-index 5273891a5b0..a6e999b8805 100644
---- a/src/sage/rings/ring.pyx
-+++ b/src/sage/rings/ring.pyx
-@@ -1734,7 +1734,7 @@ cdef class IntegralDomain(CommutativeRing):
-             sage: Z5.is_integrally_closed()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'
-+            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'...
-         """
-         raise NotImplementedError
- 
-diff --git a/src/sage/sat/solvers/satsolver.pyx b/src/sage/sat/solvers/satsolver.pyx
-index c2f41b18f55..1c4ac400cb6 100644
---- a/src/sage/sat/solvers/satsolver.pyx
-+++ b/src/sage/sat/solvers/satsolver.pyx
-@@ -375,10 +375,10 @@ def SAT(solver=None, *args, **kwds):
-         DIMACS Solver: 'kissat -q {input}'
-     """
-     if solver is None:
--        import pkgutil
--        if pkgutil.find_loader('pycryptosat') is not None:
-+        from importlib.util import find_spec
-+        if find_spec('pycryptosat') is not None:
-             solver = "cryptominisat"
--        elif pkgutil.find_loader('pycosat') is not None:
-+        elif find_spec('pycosat') is not None:
-             solver = "picosat"
-         else:
-             solver = "LP"
-diff --git a/src/sage/schemes/toric/morphism.py b/src/sage/schemes/toric/morphism.py
-index 1c8944b6dfc..5d64d632f97 100644
---- a/src/sage/schemes/toric/morphism.py
-+++ b/src/sage/schemes/toric/morphism.py
-@@ -246,7 +246,7 @@
-     Traceback (most recent call last):
-     ...
-     AttributeError: 'SchemeMorphism_fan_toric_variety' object
--    has no attribute 'fiber_generic'
-+    has no attribute 'fiber_generic'...
- 
- Let's use factorization mentioned above::
- 
-diff --git a/src/sage/sets/disjoint_union_enumerated_sets.py b/src/sage/sets/disjoint_union_enumerated_sets.py
-index 3dea567a779..5c5e08612f2 100644
---- a/src/sage/sets/disjoint_union_enumerated_sets.py
-+++ b/src/sage/sets/disjoint_union_enumerated_sets.py
-@@ -597,7 +597,7 @@ def Element(self):
-             sage: U.Element
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'
-+            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'...
-         """
-         if not self._facade:
-             return ElementWrapper
-diff --git a/src/sage/sets/set.py b/src/sage/sets/set.py
-index a1789c61300..112d3d8dc3b 100644
---- a/src/sage/sets/set.py
-+++ b/src/sage/sets/set.py
-@@ -163,7 +163,7 @@ def Set(X=None, category=None):
-         sage: sorted(B.list(), key=repr)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'Set_object_with_category' object has no attribute 'list'
-+        AttributeError: 'Set_object_with_category' object has no attribute 'list'...
-         sage: type(B)
-         <class 'sage.sets.set.Set_object_with_category'>
- 
-diff --git a/src/sage/structure/category_object.pyx b/src/sage/structure/category_object.pyx
-index b6a7eaecb5b..c06933494dc 100644
---- a/src/sage/structure/category_object.pyx
-+++ b/src/sage/structure/category_object.pyx
-@@ -836,7 +836,7 @@ cdef class CategoryObject(SageObject):
-             sage: Sets().example().sadfasdf
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'
-+            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'...
-         """
-         return self.getattr_from_category(name)
- 
-diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx
-index caae7e40ffc..543506e9a74 100644
---- a/src/sage/structure/element.pyx
-+++ b/src/sage/structure/element.pyx
-@@ -219,7 +219,7 @@ the parents::
-     sage: x._add_(x)
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-     sage: x + x
-     Traceback (most recent call last):
-     ...
-@@ -478,13 +478,13 @@ cdef class Element(SageObject):
-             sage: 1.blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'...
-             sage: Semigroups().example().an_element().is_idempotent
-             <bound method LeftZeroSemigroup.Element.is_idempotent of 42>
-             sage: Semigroups().example().an_element().blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'
-+            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'...
-         """
-         return self.getattr_from_category(name)
- 
-@@ -1269,7 +1269,7 @@ cdef class Element(SageObject):
-             sage: e._add_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-         """
-         try:
-             python_op = (<object>self)._add_
-@@ -1381,7 +1381,7 @@ cdef class Element(SageObject):
-             sage: e._sub_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'...
-         """
-         try:
-             python_op = (<object>self)._sub_
-@@ -1435,7 +1435,7 @@ cdef class Element(SageObject):
-             sage: e._neg_()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'...
-         """
-         try:
-             python_op = (<object>self)._neg_
-@@ -1549,7 +1549,7 @@ cdef class Element(SageObject):
-             sage: e._mul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'...
-         """
-         try:
-             python_op = (<object>self)._mul_
-@@ -1662,7 +1662,7 @@ cdef class Element(SageObject):
-             sage: e._matmul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'...
-         """
-         try:
-             python_op = (<object>self)._matmul_
-@@ -1765,7 +1765,7 @@ cdef class Element(SageObject):
-             sage: e._div_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'...
-         """
-         try:
-             python_op = (<object>self)._div_
-@@ -1865,7 +1865,7 @@ cdef class Element(SageObject):
-             sage: e._floordiv_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'...
-         """
-         try:
-             python_op = (<object>self)._floordiv_
-@@ -1965,7 +1965,7 @@ cdef class Element(SageObject):
-             sage: e._mod_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'...
-         """
-         try:
-             python_op = (<object>self)._mod_
-@@ -2092,7 +2092,7 @@ cdef class Element(SageObject):
-             sage: e._pow_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'...
-         """
-         try:
-             python_op = (<object>self)._pow_
-@@ -2122,7 +2122,7 @@ cdef class Element(SageObject):
-             sage: e._pow_int(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'...
-         """
-         try:
-             python_op = (<object>self)._pow_int
-@@ -2856,7 +2856,7 @@ cdef class RingElement(ModuleElement):
-             sage: m.is_nilpotent()                                                      # needs sage.modules
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... object has no attribute 'is_nilpotent'
-+            AttributeError: '...' object has no attribute 'is_nilpotent'...
-         """
-         if self.is_unit():
-             return False
-@@ -4671,7 +4671,7 @@ def coerce_binop(method):
-         sage: x.test_add(CC(2))
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'
-+        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'...
- 
-     TESTS:
- 
-diff --git a/src/sage/structure/sequence.py b/src/sage/structure/sequence.py
-index 0c700c1fb81..c3972532ac3 100644
---- a/src/sage/structure/sequence.py
-+++ b/src/sage/structure/sequence.py
-@@ -854,7 +854,7 @@ def __getattr__(self, name):
-             sage: S.universe()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'...
-             sage: S._Sequence__universe = 'foobar'
-             sage: S.universe()
-             'foobar'
-@@ -867,7 +867,7 @@ def __getattr__(self, name):
-             sage: hash(S)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'...
-             sage: S._Sequence__hash = int(34)
-             sage: hash(S)
-             34
-diff --git a/src/sage/symbolic/assumptions.py b/src/sage/symbolic/assumptions.py
-index 7dcb15f0d85..15f6fa07ce6 100644
---- a/src/sage/symbolic/assumptions.py
-+++ b/src/sage/symbolic/assumptions.py
-@@ -636,7 +636,7 @@ def assume(*args):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no
--        attribute 'assume'
-+        attribute 'assume'...
- 
-     Ensure that we can combine the two types of assumptions, as documented::
- 
-diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx
-index 0f251ac4e5c..66f624141b3 100644
---- a/src/sage/symbolic/expression.pyx
-+++ b/src/sage/symbolic/expression.pyx
-@@ -13712,7 +13712,7 @@ cdef get_dynamic_class_for_function(unsigned serial):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.symbolic.expression.Expression' object has no
--        attribute 'argp1'
-+        attribute 'argp1'...
-         sage: t = (e + 1).op[0]; t
-         tfunc(x)
-         sage: t
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index c4152e092e3..4bcf45e8793 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -67,6 +67,7 @@
- #include "archive.h"
- #include "tostring.h"
- #include "utils.h"
-+#include "../../cpython/pycore_long.h"
- 
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wdeprecated-register"
-@@ -706,18 +707,12 @@ static long _mpq_pythonhash(mpq_t the_rat)
- // Initialize an mpz_t from a Python long integer
- static void _mpz_set_pylong(mpz_t z, PyLongObject* l)
- {
--    Py_ssize_t pylong_size = Py_SIZE(l);
--    int sign = 1;
--
--    if (pylong_size < 0) {
--        pylong_size = -pylong_size;
--        sign = -1;
--    }
-+    Py_ssize_t pylong_size = _PyLong_DigitCount(l);
- 
-     mpz_import(z, pylong_size, -1, sizeof(digit), 0,
--               8*sizeof(digit) - PyLong_SHIFT, l->ob_digit);
-+               8*sizeof(digit) - PyLong_SHIFT, ob_digit(l));
- 
--    if (sign < 0)
-+    if (_PyLong_IsNegative(l))
-         mpz_neg(z, z);
- }
- 
-diff --git a/src/sage/symbolic/pynac_impl.pxi b/src/sage/symbolic/pynac_impl.pxi
-index 68c31dcfde7..7fd7c3b314b 100644
---- a/src/sage/symbolic/pynac_impl.pxi
-+++ b/src/sage/symbolic/pynac_impl.pxi
-@@ -619,7 +619,7 @@ def tolerant_is_symbol(a):
-         sage: None.is_symbol()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute 'is_symbol'
-+        AttributeError: 'NoneType' object has no attribute 'is_symbol'...
-     """
-     try:
-         return a.is_symbol()
diff --git a/srcpkgs/sagemath/patches/36506-notebook_7.patch b/srcpkgs/sagemath/patches/36506-notebook_7.patch
new file mode 100644
index 0000000000000..a7d93d52c1b4a
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36506-notebook_7.patch
@@ -0,0 +1,18 @@
+diff --git a/src/bin/sage-notebook b/src/bin/sage-notebook
+index 2e8b12e1a1c..801b0a6a6a3 100755
+--- a/src/bin/sage-notebook
++++ b/src/bin/sage-notebook
+@@ -29,7 +29,12 @@ class NotebookJupyter():
+     def __init__(self, argv):
+         self.print_banner()
+         try:
+-            from notebook.notebookapp import main
++            try:
++                # notebook 6
++                from notebook.notebookapp import main
++            except ImportError:
++                # notebook 7
++                from notebook.app import main
+         except ImportError:
+             import traceback
+             traceback.print_exc()
diff --git a/srcpkgs/sagemath/patches/36544-networkx_3.2.patch b/srcpkgs/sagemath/patches/36544-networkx_3.2.patch
new file mode 100644
index 0000000000000..efcc935ac5476
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36544-networkx_3.2.patch
@@ -0,0 +1,41 @@
+diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py
+index eedbc36bef3..3fdc241a1c4 100644
+--- a/src/sage/graphs/generic_graph.py
++++ b/src/sage/graphs/generic_graph.py
+@@ -5102,13 +5102,13 @@ def cycle_basis(self, output='vertex'):
+         A cycle basis in Petersen's Graph ::
+ 
+             sage: g = graphs.PetersenGraph()
+-            sage: g.cycle_basis()                                                       # needs networkx
++            sage: g.cycle_basis()                                                       # needs networkx, random (changes in networkx 3.2)
+             [[1, 6, 8, 5, 0], [4, 9, 6, 8, 5, 0], [7, 9, 6, 8, 5],
+              [4, 3, 8, 5, 0], [1, 2, 3, 8, 5, 0], [7, 2, 3, 8, 5]]
+ 
+         One can also get the result as a list of lists of edges::
+ 
+-            sage: g.cycle_basis(output='edge')                                          # needs networkx
++            sage: g.cycle_basis(output='edge')                                          # needs networkx, random (changes in networkx 3.2)
+             [[(1, 6, None), (6, 8, None), (8, 5, None), (5, 0, None),
+              (0, 1, None)], [(4, 9, None), (9, 6, None), (6, 8, None),
+              (8, 5, None), (5, 0, None), (0, 4, None)], [(7, 9, None),
+@@ -5273,9 +5273,9 @@ def minimum_cycle_basis(self, algorithm=None, weight_function=None, by_weight=Fa
+             [[1, 2, 3], [1, 2, 3, 4], [5, 6, 7]]
+             sage: sorted(g.minimum_cycle_basis(by_weight=False))
+             [[1, 2, 3], [1, 3, 4], [5, 6, 7]]
+-            sage: sorted(g.minimum_cycle_basis(by_weight=True, algorithm='NetworkX'))   # needs networkx
++            sage: sorted(g.minimum_cycle_basis(by_weight=True, algorithm='NetworkX'))   # needs networkx, random (changes in networkx 3.2)
+             [[1, 2, 3], [1, 2, 3, 4], [5, 6, 7]]
+-            sage: g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX')          # needs networkx
++            sage: g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX')          # needs networkx, random (changes in networkx 3.2)
+             [[1, 2, 3], [1, 3, 4], [5, 6, 7]]
+ 
+         ::
+@@ -5283,7 +5283,7 @@ def minimum_cycle_basis(self, algorithm=None, weight_function=None, by_weight=Fa
+             sage: g = Graph([(1, 2), (2, 3), (3, 4), (4, 5), (5, 1), (5, 3)])
+             sage: sorted(g.minimum_cycle_basis(by_weight=False))
+             [[1, 2, 3, 5], [3, 4, 5]]
+-            sage: sorted(g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX'))  # needs networkx
++            sage: sorted(g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX'))  # needs networkx, random (changes in networkx 3.2)
+             [[1, 2, 3, 5], [3, 4, 5]]
+ 
+         TESTS::
diff --git a/srcpkgs/sagemath/patches/get_patches b/srcpkgs/sagemath/patches/get_patches
index 95a6963432948..94992f4978f8c 100755
--- a/srcpkgs/sagemath/patches/get_patches
+++ b/srcpkgs/sagemath/patches/get_patches
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-version=10.1
+version=10.2.beta8
 
 URL_BASE_PR="https://github.com/sagemath/sage/pull/"
 URL_BASE_COMPARE="https://github.com/sagemath/sage/compare/${version}..."
@@ -20,24 +20,9 @@ get_pr() {
 # run from patches dir
 cd $(dirname "$0")
 
-# merged in 10.2.beta0
-#get_pr  36018   "singular 4.3.2p4" # included in #35934
-get_pr  36046   "fix memory leak"
-
-# merged in 10.2.beta1
-get_pr  35934   "singular 4.3.2p7"
-
-# merged in 10.2.beta2
-get_pr  36006   "gmp 6.3.0"
-
-# merged in 10.2.beta3
-get_pr  36235   "ecl 23.9.9"
-
-# merged in 10.2.beta4
-get_pr  36279   "matplotlib 3.8.0"
-
 # positive review
-#get_pr  36403   "python 3.12" # included in #36407
+get_pr  36506   "notebook 7"
 
 # needs review
-get_pr  36407   "python 3.12"
+get_pr  35848   "flintlib 3.0"
+get_pr  36544   "networkx 3.2"
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index a80d8b7187ece..eb0ad26438538 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,14 +1,14 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=10.1
-revision=4
+version=10.2.beta8
+revision=1
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
 _bindir=/usr/lib/sagemath/$version/bin
 make_install_args="--install-scripts=$_bindir"
-hostmakedepends="m4 pkg-config python3-Cython0.29 python3-Jinja2
+hostmakedepends="m4 pkg-config python3-Cython python3-Jinja2
  python3-pkgconfig python3-setuptools"
-makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
+makedepends="boost-devel brial-devel cliquer-devel ecl eclib-devel
  ecm-devel fflas-ffpack flintlib-devel gap-devel gd-devel giac-devel glpk-devel
  gsl-devel iml-devel lcalc-devel libbraiding-devel libhomfly-devel libmpc-devel
  libpng-devel linbox-devel m4ri-devel m4rie-devel mpfi-devel
@@ -18,7 +18,7 @@ makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
 depends="eclib-devel fflas-ffpack flintlib-devel gcc-fortran gd-devel
  gfan giac gsl-devel gzip libpng-devel linbox-devel m4ri-devel maxima-ecl
  mpfr-devel nauty ntl-devel palp pari-devel pari-elldata-small pari-galdata
- pari-galpol-small pari-seadata-small pkg-config python3-Cython0.29 python3-cypari2
+ pari-galpol-small pari-seadata-small pkg-config python3-Cython python3-cypari2
  python3-cysignals python3-devel python3-fpylll python3-ipython python3-lrcalc
  python3-ipython_ipykernel python3-jupyter_ipywidgets python3-matplotlib
  python3-memory_allocator python3-networkx python3-pip python3-pkgconfig
@@ -33,7 +33,7 @@ license="GPL-2.0-or-later"
 homepage="https://www.sagemath.org/"
 changelog="https://github.com/sagemath/sage/releases"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=a658612b1b2376ddaf207cc8ed0ef458d4c2880c16e19139bedbe8baa42ad62f
+checksum=3bb0d92f1deeadbe5108afb6e41d1c189c84898b063110507ec9f9c9a52d9ddb
 nocross="due to ntl (flintlib), fflas-ffpack, givaro, linbox, cysignals, sympow, maxima"
 
 post_patch() {

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

* Re: [WIP] flintlib: update to 3.0.0.
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
  2023-10-26 12:12 ` [PR PATCH] [Updated] [WIP] flintlib: update to 3.0.0 tornaria
@ 2023-10-29 16:05 ` dkwo
  2023-10-30 19:23 ` [PR PATCH] [Updated] " tornaria
                   ` (26 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: dkwo @ 2023-10-29 16:05 UTC (permalink / raw)
  To: ml

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

New comment by dkwo on void-packages repository

https://github.com/void-linux/void-packages/pull/46832#issuecomment-1784153509

Comment:
Excellent. This builds and checks fine on `aarch64`, after rebasing.

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

* Re: [PR PATCH] [Updated] [WIP] flintlib: update to 3.0.0.
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
  2023-10-26 12:12 ` [PR PATCH] [Updated] [WIP] flintlib: update to 3.0.0 tornaria
  2023-10-29 16:05 ` dkwo
@ 2023-10-30 19:23 ` tornaria
  2023-10-31  1:28 ` tornaria
                   ` (25 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: tornaria @ 2023-10-30 19:23 UTC (permalink / raw)
  To: ml

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

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

https://github.com/tornaria/void-packages flintlib
https://github.com/void-linux/void-packages/pull/46832

[WIP] flintlib: update to 3.0.0.
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **briefly**

This is a major update. A couple of packages need rebuilding (eclib, singular).

For sagemath, we need a patch (in progress: https://github.com/sagemath/sage/pull/35848).

Since backporting patches is a pain and we are not in a hurry, I'm instead targeting 10.2.beta8. Note this already moves sagemath to cython 3.

The goal is to merge flintlib 3.0 together with sagemath 10.2 when the latter is released.

<!--
#### 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/46832.patch is attached

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

From b87ce21651f4d14a27d322868edeb36dd8b4e75c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 11 Sep 2023 20:11:20 -0300
Subject: [PATCH 1/6] flintlib: update to 3.0.0.

---
 common/shlibs                                 |  3 +-
 srcpkgs/arb                                   |  1 +
 srcpkgs/arb-devel                             |  2 +-
 srcpkgs/arb/template                          | 24 ------------
 .../patches/1545-fix_openblas_detection.patch | 32 ++++++++++++++++
 ...6723b1d74e66605c111483756322ebb1bc8d.patch | 37 +++++++++++++++++++
 .../patches/fix-test-t-sdiv_qrnnd.patch       | 23 ------------
 srcpkgs/flintlib/template                     | 29 ++++++++++++---
 8 files changed, 96 insertions(+), 55 deletions(-)
 create mode 120000 srcpkgs/arb
 delete mode 100644 srcpkgs/arb/template
 create mode 100644 srcpkgs/flintlib/patches/1545-fix_openblas_detection.patch
 create mode 100644 srcpkgs/flintlib/patches/1546-fix_nmod32_in_i686-7d046723b1d74e66605c111483756322ebb1bc8d.patch
 delete mode 100644 srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch

diff --git a/common/shlibs b/common/shlibs
index 9036a675c1ae5..cc76d4e8cfafd 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3974,8 +3974,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.17 flintlib-2.9.0_1
-libarb.so.2 arb-2.20.0_1
+libflint.so.18 flintlib-3.0.0_1
 libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
diff --git a/srcpkgs/arb b/srcpkgs/arb
new file mode 120000
index 0000000000000..7c2633183069f
--- /dev/null
+++ b/srcpkgs/arb
@@ -0,0 +1 @@
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb-devel b/srcpkgs/arb-devel
index 456b9f00a86cd..7c2633183069f 120000
--- a/srcpkgs/arb-devel
+++ b/srcpkgs/arb-devel
@@ -1 +1 @@
-arb
\ No newline at end of file
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
deleted file mode 100644
index 84a62c7ffdba3..0000000000000
--- a/srcpkgs/arb/template
+++ /dev/null
@@ -1,24 +0,0 @@
-# Template file for 'arb'
-pkgname=arb
-version=2.23.0
-revision=1
-build_style=configure
-configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
-makedepends="flintlib-devel"
-short_desc="C library for arbitrary-precision interval arithmetic"
-maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
-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=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
-
-arb-devel_package() {
-	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"
-	short_desc+=" - development files"
-	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.a"
-		vmove "usr/lib/*.so"
-	}
-}
diff --git a/srcpkgs/flintlib/patches/1545-fix_openblas_detection.patch b/srcpkgs/flintlib/patches/1545-fix_openblas_detection.patch
new file mode 100644
index 0000000000000..133e93eb07341
--- /dev/null
+++ b/srcpkgs/flintlib/patches/1545-fix_openblas_detection.patch
@@ -0,0 +1,32 @@
+From d818f171ec1907d815bbf7ccbb80968ca5a024ec Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Fri, 20 Oct 2023 18:56:58 -0300
+Subject: [PATCH] Fix use of AC_SEARCH_LIBS to find cblas_dgemm
+
+Without this change, configure only tries with `-lcblas` since
+`AC_SEARCH_LIBS` caches the result based on function name.
+---
+ configure.ac | 8 ++------
+ 1 file changed, 2 insertions(+), 6 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 84ba9de832..676e5ff886 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -705,14 +705,10 @@ fi
+ 
+ if test "$with_blas" = "yes";
+ then
+-    AC_SEARCH_LIBS([cblas_dgemm],[cblas],[],
+-        [AC_SEARCH_LIBS([cblas_dgemm],[openblas],[],
+-            [AC_SEARCH_LIBS([cblas_dgemm],[blas],[],
+-                [AC_MSG_ERROR([BLAS library was not found.  If you indeed have BLAS installed, please
++    AC_SEARCH_LIBS([cblas_dgemm],[cblas openblas blas],[],
++        [AC_MSG_ERROR([BLAS library was not found.  If you indeed have BLAS installed, please
+ submit a bug report to <https://github.com/flintlib/flint/issues/> so
+ that we can either fix the issue or give a more proper error message.])]
+-            )]
+-        )]
+     )
+ fi
+ 
diff --git a/srcpkgs/flintlib/patches/1546-fix_nmod32_in_i686-7d046723b1d74e66605c111483756322ebb1bc8d.patch b/srcpkgs/flintlib/patches/1546-fix_nmod32_in_i686-7d046723b1d74e66605c111483756322ebb1bc8d.patch
new file mode 100644
index 0000000000000..f98882112f3f8
--- /dev/null
+++ b/srcpkgs/flintlib/patches/1546-fix_nmod32_in_i686-7d046723b1d74e66605c111483756322ebb1bc8d.patch
@@ -0,0 +1,37 @@
+From 7d046723b1d74e66605c111483756322ebb1bc8d Mon Sep 17 00:00:00 2001
+From: Fredrik Johansson <fredrik.johansson@gmail.com>
+Date: Sat, 21 Oct 2023 13:43:37 +0200
+Subject: [PATCH] fix nmod32 on 32-bit systems
+
+---
+ src/gr/nmod32.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/src/gr/nmod32.c b/src/gr/nmod32.c
+index fde79822ac..31ee4e0184 100644
+--- a/src/gr/nmod32.c
++++ b/src/gr/nmod32.c
+@@ -325,7 +325,11 @@ _nmod32_vec_add(nmod32_struct * res, const nmod32_struct * vec1, const nmod32_st
+     nmod_t mod = NMOD32_CTX(ctx);
+ 
+     for (i = 0; i < len; i++)
++#if FLINT_BITS == 64
+         res[i] = _nmod_add(vec1[i], vec2[i], mod);
++#else
++        res[i] = nmod_add(vec1[i], vec2[i], mod);
++#endif
+ 
+     return GR_SUCCESS;
+ }
+@@ -337,7 +341,11 @@ _nmod32_vec_sub(nmod32_struct * res, const nmod32_struct * vec1, const nmod32_st
+     nmod_t mod = NMOD32_CTX(ctx);
+ 
+     for (i = 0; i < len; i++)
++#if FLINT_BITS == 64
++        res[i] = _nmod_sub(vec1[i], vec2[i], mod);
++#else
+         res[i] = nmod_sub(vec1[i], vec2[i], mod);
++#endif
+ 
+     return GR_SUCCESS;
+ }
diff --git a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch b/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
deleted file mode 100644
index cfa109792892c..0000000000000
--- a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From fb8ddbcc06afa2a8f25637032fbb8211f6c6c122 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= <albin.ahlback@gmail.com>
-Date: Fri, 20 May 2022 14:16:38 +0200
-Subject: [PATCH] Fix bug in test code for GCC 12
-
----
- test/t-sdiv_qrnnd.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/test/t-sdiv_qrnnd.c b/test/t-sdiv_qrnnd.c
-index 2e9822e848..2676903826 100644
---- a/test/t-sdiv_qrnnd.c
-+++ b/test/t-sdiv_qrnnd.c
-@@ -33,7 +33,7 @@ int main(void)
-         {
-             d = n_randtest_not_zero(state);
-             nh = n_randtest(state);
--        } while ((FLINT_ABS(nh) >= FLINT_ABS(d)/2) || (nh == WORD_MIN));
-+        } while ((nh == WORD_MIN) || (FLINT_ABS(nh) >= FLINT_ABS(d)/2));
- 
-         nl = n_randtest(state);
- 
-
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index f7442c8052aaa..845ed41e25960 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,10 +1,11 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.9.0
+version=3.0.0
 revision=1
-build_style=configure
+build_style=gnu-configure
 configure_args="--prefix=/usr $(vopt_with ntl)
- $(vopt_if openblas --with-blas=${XBPS_CROSS_BASE}/usr/include/openblas)"
+ $(vopt_if openblas --with-blas-include=${XBPS_CROSS_BASE}/usr/include/openblas)"
+hostmakedepends="automake gettext-devel libtool"
 makedepends="mpfr-devel $(vopt_if ntl ntl-devel)
  $(vopt_if openblas openblas-devel)"
 short_desc="Fast Library for Number Theory"
@@ -12,8 +13,8 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 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=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
+distfiles="https://flintlib.org/flint-${version/.alpha/-alpha}.tar.gz"
+checksum=b9086e31e3dab89896d7edbf05a5b758d5b4b72183a1a3478f23eabdcaaae044
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
@@ -28,12 +29,30 @@ esac
 
 CFLAGS="-D_GNU_SOURCE" # needed for cpu_set_t
 
+post_patch() {
+	# run autoconf because we patched configure.ac
+	autoreconf
+}
+
 flintlib-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision} mpfr-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
+		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
 		vmove "usr/lib/*.so"
 	}
 }
+
+arb_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}
+
+arb-devel_package() {
+	depends="${sourcepkg}-devel>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From e73a0c352fb94c3387df97e3f79679d26214bf9b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:08:05 -0300
Subject: [PATCH 2/6] eclib: rebuild for flintlib-3.0.0

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

diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 1d4ad58f21b7b..12165ca788dd5 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
 version=20230424
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 makedepends="pari-devel ntl-devel flintlib-devel boost-devel"

From 8a0f3aca9c926207abc00a6cb95faeb858a641d8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:13:15 -0300
Subject: [PATCH 3/6] singular: update to 4.3.2p10.

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

diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index 036e19d470354..beb0e6d30118e 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,6 +1,6 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.2p7
+version=4.3.2p10
 revision=1
 _majver=${version%p*}
 build_style=gnu-configure
@@ -20,7 +20,7 @@ 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/${_majver//./-}/singular-${version}.tar.gz"
-checksum=aad23c30066b7fbc011138a98d60532565d76a847eec6bf2938410d93b272ca3
+checksum=28c2c9fcfee954e00dfa56eb1a7d418d5b1de67c4398d25a0f2b8f73e71552a8
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From 3044b743f7f93fea355633f9771d107ac97ea9ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 19 Jul 2023 21:04:33 -0300
Subject: [PATCH 4/6] python3-pplpy: use cython 3.

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

diff --git a/srcpkgs/python3-pplpy/template b/srcpkgs/python3-pplpy/template
index 4a9c987b2a859..d3b9aebdf2237 100644
--- a/srcpkgs/python3-pplpy/template
+++ b/srcpkgs/python3-pplpy/template
@@ -1,9 +1,9 @@
 # Template file for 'python3-pplpy'
 pkgname=python3-pplpy
 version=0.8.9
-revision=1
+revision=2
 build_style=python3-pep517
-hostmakedepends="python3-setuptools python3-wheel python3-Cython0.29
+hostmakedepends="python3-setuptools python3-wheel python3-Cython
  python3-cysignals python3-gmpy2"
 makedepends="python3-devel gmp-devel gmpxx-devel ppl-devel mpfr-devel
  libmpc-devel pari-devel"

From aa8694c953f8da4f0d320501233230b4afa6f7d0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Thu, 19 Oct 2023 08:52:15 -0300
Subject: [PATCH 5/6] python3-networkx: update to 3.2.1.

---
 srcpkgs/python3-networkx/template | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/python3-networkx/template b/srcpkgs/python3-networkx/template
index 186bf64f7bff9..29283d9e5a032 100644
--- a/srcpkgs/python3-networkx/template
+++ b/srcpkgs/python3-networkx/template
@@ -1,11 +1,11 @@
 # Template file for 'python3-networkx'
 pkgname=python3-networkx
-version=3.1
-revision=2
-build_style=python3-module
+version=3.2.1
+revision=1
+build_style=python3-pep517
 # failing in i686
 make_check_args="--deselect networkx/algorithms/approximation/tests/test_traveling_salesman.py::test_asadpour_tsp"
-hostmakedepends="python3-setuptools"
+hostmakedepends="python3-setuptools python3-wheel"
 depends="python3"
 checkdepends="python3-numpy python3-scipy python3-matplotlib python3-pandas
  python3-lxml python3-sympy python3-pytest-xdist"
@@ -15,7 +15,7 @@ license="BSD-3-Clause"
 homepage="https://networkx.org"
 changelog="https://github.com/networkx/networkx/raw/main/doc/release/release_${version}.rst"
 distfiles="${PYPI_SITE}/n/networkx/networkx-${version}.tar.gz"
-checksum=de346335408f84de0eada6ff9fafafff9bcda11f0a0dfaa931133debb146ab61
+checksum=9f1bb5cf3409bf324e0a722c20bdb4c20ee39bf1c30ce8ae499c8502b0b5e0c6
 
 post_install() {
 	vlicense LICENSE.txt

From c163ebd29248d8b68b078b5e4a6e9445ea163cc8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:50:44 -0300
Subject: [PATCH 6/6] sagemath: update to 10.2.beta8 (patch for
 flintlib-3.0.0).

---
 .../sagemath/patches/35848-flintlib_3.0.patch | 1738 ++++++++++++++++
 .../patches/35934-singular_4.3.2p7.patch      |  221 ---
 .../sagemath/patches/36006-gmp_6.3.0.patch    |   38 -
 .../patches/36046-fix_memory_leak.patch       |  740 -------
 .../sagemath/patches/36235-ecl_23.9.9.patch   |   39 -
 .../patches/36279-matplotlib_3.8.0.patch      |   24 -
 srcpkgs/sagemath/patches/36403-00pre.patch    |   29 -
 .../sagemath/patches/36407-python_3.12.patch  | 1744 -----------------
 .../sagemath/patches/36506-notebook_7.patch   |   18 +
 .../sagemath/patches/36544-networkx_3.2.patch |   41 +
 srcpkgs/sagemath/patches/get_patches          |   23 +-
 srcpkgs/sagemath/template                     |   12 +-
 12 files changed, 1807 insertions(+), 2860 deletions(-)
 create mode 100644 srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
 delete mode 100644 srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
 delete mode 100644 srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
 delete mode 100644 srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36403-00pre.patch
 delete mode 100644 srcpkgs/sagemath/patches/36407-python_3.12.patch
 create mode 100644 srcpkgs/sagemath/patches/36506-notebook_7.patch
 create mode 100644 srcpkgs/sagemath/patches/36544-networkx_3.2.patch

diff --git a/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
new file mode 100644
index 0000000000000..ed3d6d1913433
--- /dev/null
+++ b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
@@ -0,0 +1,1738 @@
+diff --git a/build/pkgs/antic/SPKG.rst b/build/pkgs/antic/SPKG.rst
+deleted file mode 100644
+index d6c32377957..00000000000
+--- a/build/pkgs/antic/SPKG.rst
++++ /dev/null
+@@ -1,18 +0,0 @@
+-antic: Algebraic Number Theory In C
+-===================================
+-
+-Description
+------------
+-
+-Algebraic Number Theory In C
+-
+-License
+--------
+-
+-LGPL 2.1
+-
+-Upstream Contact
+-----------------
+-
+-https://github.com/wbhart/antic
+-
+diff --git a/build/pkgs/antic/checksums.ini b/build/pkgs/antic/checksums.ini
+deleted file mode 100644
+index fc8711ecd13..00000000000
+--- a/build/pkgs/antic/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=antic-VERSION.tar.gz
+-sha1=940d8ea2c3512b9d49ee3101cf043f777764bd8f
+-md5=4e896420dd6344b53b307871efb2cbb4
+-cksum=1938565125
+-upstream_url=https://github.com/wbhart/antic/archive/refs/tags/vVERSION.tar.gz
+diff --git a/build/pkgs/antic/dependencies b/build/pkgs/antic/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/antic/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/antic/distros/arch.txt b/build/pkgs/antic/distros/arch.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/conda.txt b/build/pkgs/antic/distros/conda.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/debian.txt b/build/pkgs/antic/distros/debian.txt
+deleted file mode 100644
+index 8fdcd3e5721..00000000000
+--- a/build/pkgs/antic/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libantic-dev
+diff --git a/build/pkgs/antic/distros/fedora.txt b/build/pkgs/antic/distros/fedora.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/freebsd.txt b/build/pkgs/antic/distros/freebsd.txt
+deleted file mode 100644
+index 116ff3a26f3..00000000000
+--- a/build/pkgs/antic/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/antic
+diff --git a/build/pkgs/antic/distros/opensuse.txt b/build/pkgs/antic/distros/opensuse.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/repology.txt b/build/pkgs/antic/distros/repology.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/package-version.txt b/build/pkgs/antic/package-version.txt
+deleted file mode 100644
+index 3a4036fb450..00000000000
+--- a/build/pkgs/antic/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-0.2.5
+diff --git a/build/pkgs/antic/spkg-install.in b/build/pkgs/antic/spkg-install.in
+deleted file mode 100644
+index c57fa884a20..00000000000
+--- a/build/pkgs/antic/spkg-install.in
++++ /dev/null
+@@ -1,19 +0,0 @@
+-cd src
+-
+-# Copied from build/pkgs/flint/spkg-install.in:
+-#   Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-#   --with-ntl because otherwise FLINT's configure script uses
+-#   /usr/local, which is always wrong.
+-#   This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-#   The value $SAGE_LOCAL is always a safe choice even if the library
+-#   is coming from the system and is found using what is in
+-#   LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-flint="$SAGE_LOCAL"  || sdh_die "Error: Failed to configure antic."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/antic/type b/build/pkgs/antic/type
+deleted file mode 100644
+index 134d9bc32d5..00000000000
+--- a/build/pkgs/antic/type
++++ /dev/null
+@@ -1 +0,0 @@
+-optional
+diff --git a/build/pkgs/arb/SPKG.rst b/build/pkgs/arb/SPKG.rst
+deleted file mode 100644
+index cff49ddb95b..00000000000
+--- a/build/pkgs/arb/SPKG.rst
++++ /dev/null
+@@ -1,27 +0,0 @@
+-arb: Arbitrary-precision floating-point ball arithmetic
+-=======================================================
+-
+-Description
+------------
+-
+-Arb is a C library for arbitrary-precision floating-point ball
+-arithmetic, developed by Fredrik Johansson
+-(fredrik.johansson@gmail.com). It supports efficient high-precision
+-computation with polynomials, power series, matrices and special
+-functions over the real and complex numbers, with automatic, rigorous
+-error control.
+-
+-License
+--------
+-
+-GNU General Public License v2+
+-
+-
+-Upstream Contact
+-----------------
+-
+- - Fredrik Johansson: fredrik.johansson@gmail.com
+-
+- - https://arblib.org/
+-
+- - http://github.com/fredrik-johansson/arb/
+diff --git a/build/pkgs/arb/checksums.ini b/build/pkgs/arb/checksums.ini
+deleted file mode 100644
+index 80ef43dad5d..00000000000
+--- a/build/pkgs/arb/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=arb-VERSION.tar.gz
+-sha1=a1efe035dd3af3613dd685971a156f652b86ff63
+-md5=9b369e29f93cdf2d4f90b57a92526cce
+-cksum=64252121
+-upstream_url=https://github.com/fredrik-johansson/arb/archive/VERSION.tar.gz
+diff --git a/build/pkgs/arb/dependencies b/build/pkgs/arb/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/arb/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/arb/distros/arch.txt b/build/pkgs/arb/distros/arch.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/conda.txt b/build/pkgs/arb/distros/conda.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/debian.txt b/build/pkgs/arb/distros/debian.txt
+deleted file mode 100644
+index 9fe71110712..00000000000
+--- a/build/pkgs/arb/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libflint-arb-dev
+diff --git a/build/pkgs/arb/distros/fedora.txt b/build/pkgs/arb/distros/fedora.txt
+deleted file mode 100644
+index 76794404627..00000000000
+--- a/build/pkgs/arb/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb arb-devel
+diff --git a/build/pkgs/arb/distros/freebsd.txt b/build/pkgs/arb/distros/freebsd.txt
+deleted file mode 100644
+index 2ef8c7cec0f..00000000000
+--- a/build/pkgs/arb/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/arb
+diff --git a/build/pkgs/arb/distros/gentoo.txt b/build/pkgs/arb/distros/gentoo.txt
+deleted file mode 100644
+index 58e3d4f8008..00000000000
+--- a/build/pkgs/arb/distros/gentoo.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-sci-mathematics/arb
+diff --git a/build/pkgs/arb/distros/homebrew.txt b/build/pkgs/arb/distros/homebrew.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/homebrew.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/nix.txt b/build/pkgs/arb/distros/nix.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/nix.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/opensuse.txt b/build/pkgs/arb/distros/opensuse.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/distros/repology.txt b/build/pkgs/arb/distros/repology.txt
+deleted file mode 100644
+index 179c9d507e1..00000000000
+--- a/build/pkgs/arb/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-fp
+diff --git a/build/pkgs/arb/distros/void.txt b/build/pkgs/arb/distros/void.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/void.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/package-version.txt b/build/pkgs/arb/package-version.txt
+deleted file mode 100644
+index e9763f6bfed..00000000000
+--- a/build/pkgs/arb/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-2.23.0
+diff --git a/build/pkgs/arb/spkg-check.in b/build/pkgs/arb/spkg-check.in
+deleted file mode 100644
+index 27cd9419538..00000000000
+--- a/build/pkgs/arb/spkg-check.in
++++ /dev/null
+@@ -1,2 +0,0 @@
+-cd src
+-$MAKE check
+diff --git a/build/pkgs/arb/spkg-configure.m4 b/build/pkgs/arb/spkg-configure.m4
+deleted file mode 100644
+index ef2dd0aac4a..00000000000
+--- a/build/pkgs/arb/spkg-configure.m4
++++ /dev/null
+@@ -1,23 +0,0 @@
+-SAGE_SPKG_CONFIGURE([arb], [
+-    AC_REQUIRE([SAGE_SPKG_CONFIGURE_FLINT])
+-    SAGE_ARB_LIBRARY="arb"
+-    AC_MSG_CHECKING([installing flint? ])
+-    if test x$sage_spkg_install_flint = xyes; then
+-        AC_MSG_RESULT([yes; install arb as well])
+-        sage_spkg_install_arb=yes
+-    else
+-        AC_CHECK_HEADER(arb.h, [
+-        dnl below function added in version 2.16 of arb
+-            AC_CHECK_LIB([arb], [acb_mat_eig_simple], [],
+-              [dnl in Debian the name of dylib is different.
+-               AC_CHECK_LIB([flint-arb], [acb_mat_eig_simple],
+-                [SAGE_ARB_LIBRARY="flint-arb"], [sage_spkg_install_arb=yes])])
+-        ], [sage_spkg_install_arb=yes])
+-    fi
+-], [], [], [
+-    if test x$sage_spkg_install_arb = xyes; then
+-        AC_SUBST(SAGE_ARB_LIBRARY,["arb"])
+-    else
+-        AC_SUBST(SAGE_ARB_LIBRARY,[$SAGE_ARB_LIBRARY])
+-    fi
+-])
+diff --git a/build/pkgs/arb/spkg-install.in b/build/pkgs/arb/spkg-install.in
+deleted file mode 100644
+index 9322f04c912..00000000000
+--- a/build/pkgs/arb/spkg-install.in
++++ /dev/null
+@@ -1,17 +0,0 @@
+-cd src
+-
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-flint because otherwise ARB's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure --disable-static --prefix="$SAGE_LOCAL" \
+-        --with-gmp="$SAGE_LOCAL" \
+-        --with-mpfr="$SAGE_LOCAL" \
+-        --with-flint="$SAGE_LOCAL" || \
+-    sdh_die "Error configuring arb."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/arb/type b/build/pkgs/arb/type
+deleted file mode 100644
+index a6a7b9cd726..00000000000
+--- a/build/pkgs/arb/type
++++ /dev/null
+@@ -1 +0,0 @@
+-standard
+diff --git a/build/pkgs/e_antic/dependencies b/build/pkgs/e_antic/dependencies
+index fea1ffbda45..8e977a55c13 100644
+--- a/build/pkgs/e_antic/dependencies
++++ b/build/pkgs/e_antic/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) flint arb antic boost_cropped
++$(MP_LIBRARY) flint boost_cropped
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/SPKG.rst b/build/pkgs/flint/SPKG.rst
+index f91de70d1ff..d9dcea0903b 100644
+--- a/build/pkgs/flint/SPKG.rst
++++ b/build/pkgs/flint/SPKG.rst
+@@ -4,8 +4,8 @@ flint: Fast Library for Number Theory
+ Description
+ -----------
+ 
+-FLINT is a C library for doing number theory, maintained by William
+-Hart.
++FLINT is a C library for doing number theory, maintained by
++Fredrik Johansson.
+ 
+ Website: http://www.flintlib.org
+ 
+@@ -20,4 +20,4 @@ Upstream Contact
+ 
+ -  flint-devel Gougle Group
+    (http://groups.google.co.uk/group/flint-devel)
+--  William Hart
++-  Fredrik Johansson
+diff --git a/build/pkgs/flint/checksums.ini b/build/pkgs/flint/checksums.ini
+index 3d449d98064..2cec823bfb1 100644
+--- a/build/pkgs/flint/checksums.ini
++++ b/build/pkgs/flint/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=flint-VERSION.tar.gz
+-sha1=63d90f8242c8f8ab4011fbcfb44b86c154f43abd
+-md5=c2d3cec326438f159a530c66eb07fafe
+-cksum=4244948341
+-upstream_url=http://flintlib.org/flint-VERSION.tar.gz
++sha1=c548b1d5eb86a1805de9bef56629455b61e873f7
++md5=24551d4e475290ce6b831c78fafb5efb
++cksum=1567352998
++upstream_url=https://github.com/flintlib/flint/releases/download/vVERSION/flint-VERSION.tar.gz
+diff --git a/build/pkgs/flint/dependencies b/build/pkgs/flint/dependencies
+index 385df4faa7d..1108dc4fb21 100644
+--- a/build/pkgs/flint/dependencies
++++ b/build/pkgs/flint/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) mpfr ntl
++$(MP_LIBRARY) mpfr
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/package-version.txt b/build/pkgs/flint/package-version.txt
+index c8e38b61405..4a36342fcab 100644
+--- a/build/pkgs/flint/package-version.txt
++++ b/build/pkgs/flint/package-version.txt
+@@ -1 +1 @@
+-2.9.0
++3.0.0
+diff --git a/build/pkgs/flint/spkg-build.in b/build/pkgs/flint/spkg-build.in
+new file mode 100644
+index 00000000000..ffb822c8a97
+--- /dev/null
++++ b/build/pkgs/flint/spkg-build.in
+@@ -0,0 +1,3 @@
++cd src
++sdh_configure
++sdh_make
+diff --git a/build/pkgs/flint/spkg-configure.m4 b/build/pkgs/flint/spkg-configure.m4
+index a58108c9d6e..9576e4cc1e9 100644
+--- a/build/pkgs/flint/spkg-configure.m4
++++ b/build/pkgs/flint/spkg-configure.m4
+@@ -1,25 +1,8 @@
+ SAGE_SPKG_CONFIGURE([flint], [
+-    SAGE_SPKG_DEPCHECK([mpfr ntl], [
++    SAGE_SPKG_DEPCHECK([mpfr], [
+         AC_CHECK_HEADER(flint/flint.h, [
+-          dnl flint_parallel_binary_splitting appears in Flint 2.9.0, needed by arb 2.23
+-          AC_SEARCH_LIBS([flint_parallel_binary_splitting], [flint], [
+-            dnl check that NTL is linked in
+-            AC_SEARCH_LIBS([fmpz_poly_get_ZZX], [flint], [
+-
+-              AC_MSG_CHECKING([that GC is not enabled in Flint... ])
+-              AC_RUN_IFELSE([
+-                 AC_LANG_PROGRAM([[#include <flint/flint.h>]], [
+-                                  [#ifdef HAVE_GC]
+-                                     [return HAVE_GC;]
+-                                  [#else]
+-                                     [return 0;]
+-                                  [#endif]])],
+-                 [AC_MSG_RESULT([GC not enabled. Good.])],
+-                        [AC_MSG_RESULT([GC enabled. Incompatible with Sage.])
+-                         sage_spkg_install_flint=yes],
+-                 [AC_MSG_RESULT(["cross compiling. assuming GC is not enabled"])])
+-            ], [sage_spkg_install_flint=yes])
+-          ], [sage_spkg_install_flint=yes])
++          dnl gr_get_fexpr appears in Flint 3.0
++          AC_SEARCH_LIBS([gr_get_fexpr], [flint], [], [sage_spkg_install_flint=yes])
+         ], [sage_spkg_install_flint=yes])
+     ])
+ ], [], [], [
+diff --git a/build/pkgs/flint/spkg-install.in b/build/pkgs/flint/spkg-install.in
+index eacd7b6e491..3ea8c053669 100644
+--- a/build/pkgs/flint/spkg-install.in
++++ b/build/pkgs/flint/spkg-install.in
+@@ -1,36 +1,2 @@
+-###############################################################################
+-#
+-# FLINT Sage install script
+-#
+-###############################################################################
+-if [ "$SAGE_DEBUG" = "yes" ]; then
+-    echo "Building a debug version of FLINT."
+-    FLINT_TUNE=" $FLINT_TUNE"; export FLINT_TUNE
+-    FLINT_CONFIGURE="--enable-assert $FLINT_CONFIGURE"
+-fi
+-
+ cd src
+-
+-echo "Configuring FLINT."
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-ntl because otherwise FLINT's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-ntl="$SAGE_LOCAL" \
+-    $FLINT_CONFIGURE || sdh_die "Error: Failed to configure FLINT."
+-
+-sdh_make verbose
+-
+-echo "Deleting old FLINT files."
+-rm -f $SAGE_LOCAL/lib/libflint*
+-rm -rf $SAGE_LOCAL/include/flint
+-
+ sdh_make_install
+diff --git a/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+new file mode 100644
+index 00000000000..27a642a13b0
+--- /dev/null
++++ b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+@@ -0,0 +1,53 @@
++From fe730579476de0b2d4181a38efa7f63dff9c81d7 Mon Sep 17 00:00:00 2001
++From: Marc Mezzarobba <marc@mezzarobba.net>
++Date: Tue, 12 Sep 2023 08:23:08 +0200
++Subject: [PATCH] Make msolve build with flint3
++
++---
++ src/fglm/berlekamp_massey.c | 3 +++
++ src/fglm/data_fglm.c        | 7 +++++--
++ 2 files changed, 8 insertions(+), 2 deletions(-)
++
++diff --git a/src/fglm/berlekamp_massey.c b/src/fglm/berlekamp_massey.c
++index b0f2052..998af1c 100644
++--- a/src/fglm/berlekamp_massey.c
+++++ b/src/fglm/berlekamp_massey.c
++@@ -30,6 +30,9 @@
++ */
++ 
++ #include <stdlib.h>
+++#if __FLINT_VERSION >= 3
+++#  include <flint/nmod.h>
+++#endif
++ //#include "nmod_poly.h"
++ //#include "mpn_extras.h"
++ 
++diff --git a/src/fglm/data_fglm.c b/src/fglm/data_fglm.c
++index 0726760..0e1da6f 100644
++--- a/src/fglm/data_fglm.c
+++++ b/src/fglm/data_fglm.c
++@@ -24,6 +24,7 @@
++ #include <flint/mpn_extras.h>
++ #include <flint/nmod_poly.h>
++ #include <flint/nmod_poly_factor.h>
+++#include <flint/ulong_extras.h>
++ 
++ 
++ typedef uint32_t szmat_t;
++@@ -299,9 +300,11 @@ static inline void nmod_poly_set_prime(nmod_poly_t poly,
++   mp_limb_t ninv = n_preinvert_limb(prime);
++   poly->mod.n = prime;
++   poly->mod.ninv = ninv;
+++#if __FLINT_VERSION < 3
++   count_leading_zeros(poly->mod.norm, prime);
++-  /* poly->mod.norm = flint_clz(prime); */
++-
+++#else
+++  poly->mod.norm = flint_clz(prime);
+++#endif
++ }
++ 
++ static inline void fglm_param_set_prime(param_t *param, mp_limb_t prime){
++-- 
++2.40.1
++
+diff --git a/build/pkgs/sagelib/dependencies b/build/pkgs/sagelib/dependencies
+index 5dc2efe1d31..fa6e98df7db 100644
+--- a/build/pkgs/sagelib/dependencies
++++ b/build/pkgs/sagelib/dependencies
+@@ -1,4 +1,4 @@
+-FORCE $(SCRIPTS) arb boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
++FORCE $(SCRIPTS) boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/symengine/dependencies b/build/pkgs/symengine/dependencies
+index 1fc34963eda..7795d486018 100644
+--- a/build/pkgs/symengine/dependencies
++++ b/build/pkgs/symengine/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) arb ecm flint mpc mpfr | cmake
++$(MP_LIBRARY) ecm flint mpc mpfr | cmake
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/pkgs/sage-conf/_sage_conf/_conf.py.in b/pkgs/sage-conf/_sage_conf/_conf.py.in
+index 87b27ca05cb..895d6572d1e 100644
+--- a/pkgs/sage-conf/_sage_conf/_conf.py.in
++++ b/pkgs/sage-conf/_sage_conf/_conf.py.in
+@@ -19,8 +19,6 @@ MAXIMA_FAS = "@SAGE_MAXIMA_FAS@".replace('${prefix}', SAGE_LOCAL)
+ # Delete this line if your ECL can load Kenzo without further prodding.
+ KENZO_FAS = "@SAGE_KENZO_FAS@".replace('${prefix}', SAGE_LOCAL)
+ 
+-ARB_LIBRARY = "@SAGE_ARB_LIBRARY@"
+-
+ NTL_INCDIR = "@NTL_INCDIR@"
+ NTL_LIBDIR = "@NTL_LIBDIR@"
+ 
+diff --git a/src/sage/env.py b/src/sage/env.py
+index f4899639a6d..f6459313fd4 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -223,7 +223,6 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st
+ FOURTITWO_PPI = var("FOURTITWO_PPI")
+ FOURTITWO_CIRCUITS = var("FOURTITWO_CIRCUITS")
+ FOURTITWO_GROEBNER = var("FOURTITWO_GROEBNER")
+-ARB_LIBRARY = var("ARB_LIBRARY", "arb")
+ CBLAS_PC_MODULES = var("CBLAS_PC_MODULES", "cblas:openblas:blas")
+ ECL_CONFIG = var("ECL_CONFIG", "ecl-config")
+ NTL_INCDIR = var("NTL_INCDIR")
+@@ -356,8 +355,7 @@ def cython_aliases(required_modules=None,
+         sage: cython_aliases()
+         {...}
+         sage: sorted(cython_aliases().keys())
+-        ['ARB_LIBRARY',
+-         'CBLAS_CFLAGS',
++        ['CBLAS_CFLAGS',
+          ...,
+          'ZLIB_LIBRARIES']
+         sage: cython_aliases(required_modules=('module-that-is-assumed-to-not-exist'))
+@@ -475,8 +473,6 @@ def uname_specific(name, value, alternative):
+     if "LINBOX_CFLAGS" in aliases:
+         aliases["LINBOX_CFLAGS"].append("-std=gnu++11")
+ 
+-    aliases["ARB_LIBRARY"] = ARB_LIBRARY
+-
+     # TODO: Remove Cygwin hack by installing a suitable cblas.pc
+     if os.path.exists('/usr/lib/libblas.dll.a'):
+         aliases["CBLAS_LIBS"] = ['gslcblas']
+diff --git a/src/sage/features/sagemath.py b/src/sage/features/sagemath.py
+index 7404e6d0a8e..6037d097391 100644
+--- a/src/sage/features/sagemath.py
++++ b/src/sage/features/sagemath.py
+@@ -761,7 +761,7 @@ class sage__rings__number_field(JoinFeature):
+     A :class:`~sage.features.Feature` describing the presence of :mod:`sage.rings.number_field`.
+ 
+     Number fields are implemented in Sage using a complicated mixture of various libraries,
+-    including :ref:`arb <spkg_arb>`, :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
++    including :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
+     :ref:`MPFI <spkg_mpfi>`, :ref:`NTL <spkg_ntl>`, and :ref:`PARI <spkg_pari>`.
+ 
+     EXAMPLES:
+diff --git a/src/sage/libs/arb/acb.pxd b/src/sage/libs/arb/acb.pxd
+index 5148dc43991..851488d803a 100644
+--- a/src/sage/libs/arb/acb.pxd
++++ b/src/sage/libs/arb/acb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -152,10 +152,6 @@ cdef extern from "arb_wrap.h":
+     void acb_sech(acb_t s, const acb_t z, long prec)
+     void acb_csch(acb_t c, const acb_t z, long prec)
+ 
+-    void acb_rising_ui_bs(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui_rs(acb_t z, const acb_t x, unsigned long n, unsigned long step, long prec)
+-    void acb_rising_ui_rec(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui(acb_t z, const acb_t x, unsigned long n, long prec)
+     void acb_rising(acb_t z, const acb_t x, const acb_t n, long prec)
+ 
+     void acb_gamma(acb_t y, const acb_t x, long prec)
+diff --git a/src/sage/libs/arb/acb_calc.pxd b/src/sage/libs/arb/acb_calc.pxd
+index a5dbf360b5e..67bd2ed57dc 100644
+--- a/src/sage/libs/arb/acb_calc.pxd
++++ b/src/sage/libs/arb/acb_calc.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_calc.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_elliptic.pxd b/src/sage/libs/arb/acb_elliptic.pxd
+index 176f68df00e..e3480e9f73b 100644
+--- a/src/sage/libs/arb/acb_elliptic.pxd
++++ b/src/sage/libs/arb/acb_elliptic.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_elliptic.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_hypgeom.pxd b/src/sage/libs/arb/acb_hypgeom.pxd
+index 418e766f10d..c43e5c0623b 100644
+--- a/src/sage/libs/arb/acb_hypgeom.pxd
++++ b/src/sage/libs/arb/acb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_hypgeom.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_modular.pxd b/src/sage/libs/arb/acb_modular.pxd
+index c708e9bf97d..cdc413c92da 100644
+--- a/src/sage/libs/arb/acb_modular.pxd
++++ b/src/sage/libs/arb/acb_modular.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_modular.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_poly.pxd b/src/sage/libs/arb/acb_poly.pxd
+index 69f4320055b..ae02757ffd9 100644
+--- a/src/sage/libs/arb/acb_poly.pxd
++++ b/src/sage/libs/arb/acb_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -79,24 +79,10 @@ cdef extern from "arb_wrap.h":
+     void _acb_poly_divrem(acb_ptr Q, acb_ptr R, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec)
+     bint acb_poly_divrem(acb_poly_t Q, acb_poly_t R, const acb_poly_t A, const acb_poly_t B, long prec)
+     void _acb_poly_div_root(acb_ptr Q, acb_t R, acb_srcptr A, long len, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_horner(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_horner(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_divconquer(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_divconquer(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_convolution(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_convolution(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+     void _acb_poly_taylor_shift(acb_ptr g, const acb_t c, long n, long prec)
+     void acb_poly_taylor_shift(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_compose_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_divconquer(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_divconquer(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+     void _acb_poly_compose(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+     void acb_poly_compose(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_series_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+-    void _acb_poly_compose_series_brent_kung(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_brent_kung(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_compose_series(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+     void acb_poly_compose_series(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_revert_series_lagrange(acb_ptr h, acb_srcptr f, long flen, long n, long prec)
+@@ -161,10 +147,6 @@ cdef extern from "arb_wrap.h":
+     void acb_poly_exp_series_basecase(acb_poly_t f, const acb_poly_t h, long n, long prec)
+     void _acb_poly_exp_series(acb_ptr f, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_exp_series(acb_poly_t f, const acb_poly_t h, long n, long prec)
+-    void _acb_poly_sin_cos_series_basecase(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_basecase(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+-    void _acb_poly_sin_cos_series_tangent(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_tangent(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+     void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_sin_cos_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec)
+     void _acb_poly_sin_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec)
+diff --git a/src/sage/libs/arb/arb.pxd b/src/sage/libs/arb/arb.pxd
+index c82b94de30f..acd232ab816 100644
+--- a/src/sage/libs/arb/arb.pxd
++++ b/src/sage/libs/arb/arb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -224,15 +224,8 @@ cdef extern from "arb_wrap.h":
+ 
+     void arb_lambertw(arb_t res, const arb_t x, int flags, long prec)
+ 
+-    void arb_rising_ui_bs(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui_rs(arb_t z, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising_ui_rec(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui(arb_t z, const arb_t x, unsigned long n, long prec)
+     void arb_rising(arb_t z, const arb_t x, const arb_t n, long prec)
+     void arb_rising_fmpq_ui(arb_t z, const fmpq_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_bs(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_rs(arb_t u, arb_t v, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising2_ui(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+     void arb_fac_ui(arb_t z, unsigned long n, long prec)
+     void arb_bin_ui(arb_t z, const arb_t n, unsigned long k, long prec)
+     void arb_bin_uiui(arb_t z, unsigned long n, unsigned long k, long prec)
+diff --git a/src/sage/libs/arb/arb_fmpz_poly.pxd b/src/sage/libs/arb/arb_fmpz_poly.pxd
+index 079f76e9d9e..55daa705238 100644
+--- a/src/sage/libs/arb/arb_fmpz_poly.pxd
++++ b/src/sage/libs/arb/arb_fmpz_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_fmpz_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -22,5 +22,4 @@ cdef extern from "arb_wrap.h":
+     unsigned long arb_fmpz_poly_deflation(const fmpz_poly_t poly)
+     void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long deflation)
+     void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, long prec)
+-    void arb_fmpz_poly_cos_minpoly(fmpz_poly_t res, unsigned long n)
+     void arb_fmpz_poly_gauss_period_minpoly(fmpz_poly_t res, unsigned long q, unsigned long n)
+diff --git a/src/sage/libs/arb/arb_hypgeom.pxd b/src/sage/libs/arb/arb_hypgeom.pxd
+index fb1c40ddaa8..139b987d669 100644
+--- a/src/sage/libs/arb/arb_hypgeom.pxd
++++ b/src/sage/libs/arb/arb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_hypgeom.h
+ 
+ from sage.libs.flint.types cimport fmpz_t
+diff --git a/src/sage/libs/arb/arb_wrap.h b/src/sage/libs/arb/arb_wrap.h
+index 49997075ee5..488bb376d5e 100644
+--- a/src/sage/libs/arb/arb_wrap.h
++++ b/src/sage/libs/arb/arb_wrap.h
+@@ -5,25 +5,27 @@
+  * by arb, most of which rely on flint's ulong and slong defines.
+  */
+ 
++#include <mpfr.h>
++
+ #undef ulong
+ #undef slong
+ 
+ #define ulong mp_limb_t
+ #define slong mp_limb_signed_t
+ 
+-#include <acb.h>
+-#include <acb_calc.h>
+-#include <acb_elliptic.h>
+-#include <acb_hypgeom.h>
+-#include <acb_mat.h>
+-#include <acb_modular.h>
+-#include <acb_poly.h>
+-#include <arb.h>
+-#include <arb_fmpz_poly.h>
+-#include <arb_hypgeom.h>
+-#include <arf.h>
+-#include <bernoulli.h>
+-#include <mag.h>
++#include <flint/acb.h>
++#include <flint/acb_calc.h>
++#include <flint/acb_elliptic.h>
++#include <flint/acb_hypgeom.h>
++#include <flint/acb_mat.h>
++#include <flint/acb_modular.h>
++#include <flint/acb_poly.h>
++#include <flint/arb.h>
++#include <flint/arb_fmpz_poly.h>
++#include <flint/arb_hypgeom.h>
++#include <flint/arf.h>
++#include <flint/bernoulli.h>
++#include <flint/mag.h>
+ 
+ #undef ulong
+ #undef slong
+diff --git a/src/sage/libs/arb/arf.pxd b/src/sage/libs/arb/arf.pxd
+index b8b83fefcdc..84778fe9f09 100644
+--- a/src/sage/libs/arb/arf.pxd
++++ b/src/sage/libs/arb/arf.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arf.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -30,7 +30,6 @@ cdef extern from "arb_wrap.h":
+     void arf_set_ui(arf_t y, unsigned long x)
+     void arf_set_si(arf_t y, long x)
+     void arf_set_mpfr(arf_t y, const mpfr_t x)
+-    # void arf_set_fmpr(arf_t y, const fmpr_t x)
+     void arf_set_d(arf_t y, double x)
+     void arf_swap(arf_t y, arf_t x)
+     void arf_init_set_ui(arf_t y, unsigned long x)
+@@ -46,7 +45,6 @@ cdef extern from "arb_wrap.h":
+     int arf_set_round_fmpz_2exp(arf_t y, const fmpz_t x, const fmpz_t e, long prec, arf_rnd_t rnd)
+     void arf_get_fmpz_2exp(fmpz_t m, fmpz_t e, const arf_t x)
+     double arf_get_d(const arf_t x, arf_rnd_t rnd)
+-    # void arf_get_fmpr(fmpr_t y, const arf_t x)
+     int arf_get_mpfr(mpfr_t y, const arf_t x, mpfr_rnd_t rnd)
+     void arf_get_fmpz(fmpz_t z, const arf_t x, arf_rnd_t rnd)
+     long arf_get_si(const arf_t x, arf_rnd_t rnd)
+diff --git a/src/sage/libs/arb/bernoulli.pxd b/src/sage/libs/arb/bernoulli.pxd
+index 375b2b9bbcf..ea9340f4b15 100644
+--- a/src/sage/libs/arb/bernoulli.pxd
++++ b/src/sage/libs/arb/bernoulli.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = bernoulli.h
+ 
+ from ..flint.types cimport fmpq_t, ulong
+diff --git a/src/sage/libs/arb/mag.pxd b/src/sage/libs/arb/mag.pxd
+index d5d8693ea8f..69dfb990ae0 100644
+--- a/src/sage/libs/arb/mag.pxd
++++ b/src/sage/libs/arb/mag.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = mag.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -27,13 +27,11 @@ cdef extern from "arb_wrap.h":
+     # void mag_randtest(mag_t x, flint_rand_t state, long expbits)
+     # void mag_randtest_special(mag_t x, flint_rand_t state, long expbits)
+     void mag_set_d(mag_t y, double x)
+-    # void mag_set_fmpr(mag_t y, const fmpr_t x)
+     void mag_set_ui(mag_t y, unsigned long x)
+     void mag_set_fmpz(mag_t y, const fmpz_t x)
+     void mag_set_d_2exp_fmpz(mag_t z, double x, const fmpz_t y)
+     void mag_set_fmpz_2exp_fmpz(mag_t z, const fmpz_t x, const fmpz_t y)
+     void mag_set_ui_2exp_si(mag_t z, unsigned long x, long y)
+-    # void mag_get_fmpr(fmpr_t y, const mag_t x)
+     void mag_get_fmpq(fmpq_t y, const mag_t x)
+     void mag_set_ui_lower(mag_t z, unsigned long x)
+     void mag_set_fmpz_lower(mag_t z, const fmpz_t x)
+diff --git a/src/sage/libs/flint/flint_wrap.h b/src/sage/libs/flint/flint_wrap.h
+index 266535c3835..4db72b97660 100644
+--- a/src/sage/libs/flint/flint_wrap.h
++++ b/src/sage/libs/flint/flint_wrap.h
+@@ -15,6 +15,7 @@
+  */
+ 
+ #include <gmp.h>
++#include <mpfr.h>
+ 
+ /* Save previous definition of ulong if any, as pari also uses it */
+ /* Should work on GCC, clang, MSVC */
+@@ -33,6 +34,7 @@
+ 
+ #include <flint/arith.h>
+ #include <flint/fmpq.h>
++#include <flint/fmpq_vec.h>
+ #include <flint/fmpq_mat.h>
+ #include <flint/fmpq_poly.h>
+ #include <flint/fmpz.h>
+@@ -47,6 +49,7 @@
+ #include <flint/fq.h>
+ #include <flint/fq_nmod.h>
+ #include <flint/nmod_poly.h>
++#include <flint/nmod_poly_factor.h>
+ #include <flint/nmod_vec.h>
+ #include <flint/padic.h>
+ #include <flint/padic_poly.h>
+diff --git a/src/sage/libs/flint/fmpq.pxd b/src/sage/libs/flint/fmpq.pxd
+index 5e64c82102f..0616c0a7408 100644
+--- a/src/sage/libs/flint/fmpq.pxd
++++ b/src/sage/libs/flint/fmpq.pxd
+@@ -12,6 +12,8 @@ cdef extern from "flint_wrap.h":
+     fmpz * fmpq_denref(fmpq_t)
+     void fmpq_init(fmpq_t)
+     void fmpq_clear(fmpq_t)
++    void fmpq_init_set_readonly(fmpq_t, const mpq_t)
++    void fmpq_clear_readonly(fmpq_t)
+     void fmpq_one(fmpq_t)
+     void fmpq_zero(fmpq_t)
+     bint fmpq_is_zero(fmpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pxd b/src/sage/libs/flint/fmpq_poly.pxd
+index 20a797c0197..516f9e84cfc 100644
+--- a/src/sage/libs/flint/fmpq_poly.pxd
++++ b/src/sage/libs/flint/fmpq_poly.pxd
+@@ -30,6 +30,9 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_canonicalise(fmpq_poly_t)
+     int fmpq_poly_is_canonical(const fmpq_poly_t)
+ 
++    void _fmpq_poly_set_length(fmpq_poly_t, slong)
++    void _fmpq_poly_normalise(fmpq_poly_t)
++
+     # Polynomial parameters
+     slong fmpq_poly_degree(const fmpq_poly_t)
+     ulong fmpq_poly_length(const fmpq_poly_t)
+@@ -46,10 +49,7 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_ui(fmpq_poly_t, ulong)
+     void fmpq_poly_set_fmpz(fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_set_fmpq(fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+     void fmpq_poly_set_fmpz_poly(fmpq_poly_t, const fmpz_poly_t)
+-    void fmpq_poly_set_array_mpq(fmpq_poly_t, const mpq_t *, slong)
+ 
+     void fmpq_poly_set_str(fmpq_poly_t, const char *)
+     char *fmpq_poly_get_str(const fmpq_poly_t)
+@@ -67,7 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_reverse(fmpq_poly_t, const fmpq_poly_t, slong)
+ 
+     void fmpq_poly_get_coeff_fmpq(fmpq_t, const fmpq_poly_t, slong)
+-    void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_si(slong, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_ui(ulong, const fmpq_poly_t, slong)
+ 
+@@ -75,8 +74,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_coeff_ui(fmpq_poly_t, slong, ulong)
+     void fmpq_poly_set_coeff_fmpz(fmpq_poly_t, slong, const fmpz_t)
+     void fmpq_poly_set_coeff_fmpq(fmpq_poly_t, slong, const fmpq_t)
+-    void fmpq_poly_set_coeff_mpz(fmpq_poly_t, slong, const mpz_t)
+-    void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
+ 
+     # Comparison
+     int fmpq_poly_equal(const fmpq_poly_t, const fmpq_poly_t)
+@@ -100,8 +97,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_mul_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     void fmpq_poly_scalar_div_si(fmpq_poly_t, const fmpq_poly_t, slong)
+     void fmpq_poly_scalar_div_ui(fmpq_poly_t, const fmpq_poly_t, ulong)
+@@ -109,8 +104,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_div_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_div_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_div_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Multiplication
+     void fmpq_poly_mul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -155,8 +148,6 @@ cdef extern from "flint_wrap.h":
+     # Evaluation
+     void fmpq_poly_evaluate_fmpz(fmpq_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_evaluate_fmpq(fmpq_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_evaluate_mpz(mpq_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_evaluate_mpq(mpq_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Composition
+     void fmpq_poly_compose(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -189,3 +180,11 @@ cdef extern from "flint_wrap.h":
+ # since the fmpq_poly header seems to be lacking this inline function
+ cdef inline sage_fmpq_poly_max_limbs(const fmpq_poly_t poly):
+     return _fmpz_vec_max_limbs(fmpq_poly_numref(poly), fmpq_poly_length(poly))
++
++# functions removed from flint but still needed in sage
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
++cdef void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
++cdef void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pyx b/src/sage/libs/flint/fmpq_poly.pyx
+new file mode 100644
+index 00000000000..3b8a0cf0c51
+--- /dev/null
++++ b/src/sage/libs/flint/fmpq_poly.pyx
+@@ -0,0 +1,45 @@
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++from sage.libs.gmp.mpq cimport *
++from sage.libs.flint.fmpz cimport *
++from sage.libs.flint.fmpq cimport *
++
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t rop, const fmpq_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t rop, const fmpq_poly_t op, const mpq_t c):
++    cdef fmpq_t f
++    fmpq_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpq(rop, op, f)
++    fmpq_clear_readonly(f)
++
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t poly, slong n, const mpq_t x):
++    cdef fmpq_t t
++    fmpq_init_set_readonly(t, x)
++    fmpq_poly_set_coeff_fmpq(poly, n, t)
++    fmpq_clear_readonly(t)
++
++cdef void fmpq_poly_get_coeff_mpq(mpq_t x, const fmpq_poly_t poly, slong n):
++    cdef fmpq_t t
++    fmpq_init(t)
++    fmpq_poly_get_coeff_fmpq(t, poly, n)
++    fmpq_get_mpq(x, t)
++    fmpq_clear(t)
++
++cdef void fmpq_poly_set_mpq(fmpq_poly_t poly, const mpq_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), mpq_numref(x))
++    fmpz_set_mpz(fmpq_poly_denref(poly), mpq_denref(x))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
++
++cdef void fmpq_poly_set_mpz(fmpq_poly_t poly, const mpz_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), x)
++    fmpz_one(fmpq_poly_denref(poly))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz.pxd b/src/sage/libs/flint/fmpz.pxd
+index 01058d0f130..b97fbe1eae0 100644
+--- a/src/sage/libs/flint/fmpz.pxd
++++ b/src/sage/libs/flint/fmpz.pxd
+@@ -16,6 +16,9 @@ cdef extern from "flint_wrap.h":
+     void fmpz_init_set(fmpz_t, fmpz_t)
+     void fmpz_init_set_ui(fmpz_t, ulong)
+ 
++    void fmpz_init_set_readonly(fmpz_t, const mpz_t)
++    void fmpz_clear_readonly(fmpz_t)
++
+     # Conversion
+     void fmpz_set(fmpz_t f, fmpz_t g)
+     void fmpz_set_ui(fmpz_t, ulong)
+diff --git a/src/sage/libs/flint/fmpz_mod_poly.pxd b/src/sage/libs/flint/fmpz_mod_poly.pxd
+index 24b653eb3b7..2727246da98 100644
+--- a/src/sage/libs/flint/fmpz_mod_poly.pxd
++++ b/src/sage/libs/flint/fmpz_mod_poly.pxd
+@@ -67,13 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_get_coeff_fmpz(fmpz_t x, const fmpz_mod_poly_t poly,
+                                              slong n, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_set_coeff_mpz(fmpz_mod_poly_t poly,
+-                             slong n, const mpz_t x, const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_get_coeff_mpz(mpz_t x,
+-                 const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx)
+-
+-
+     void _fmpz_mod_poly_shift_left(fmpz * res, const fmpz * poly,
+                                                            slong len, slong n)
+ 
+@@ -194,14 +187,6 @@ cdef extern from "flint_wrap.h":
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_div_basecase(fmpz_mod_poly_t Q,
+-                            const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_div_newton_n_preinv(fmpz_mod_poly_t Q,
+-                         const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                         const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem_newton_n_preinv(fmpz_mod_poly_t Q,
+           fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                          const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+@@ -213,10 +198,6 @@ cdef extern from "flint_wrap.h":
+                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_divrem_divconquer(fmpz_mod_poly_t Q,
+-        fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem(fmpz_mod_poly_t Q, fmpz_mod_poly_t R,
+     const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+@@ -254,40 +235,13 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_make_monic_f(fmpz_t f, fmpz_mod_poly_t res,
+                          const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_euclidean(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_gcd_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_hgcd(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-
+     void fmpz_mod_poly_gcd(fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+ 
+-    void fmpz_mod_poly_xgcd_euclidean(fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_hgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S,
+-          fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_xgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                       const fmpz_mod_ctx_t ctx)
+@@ -361,14 +315,6 @@ cdef extern from "flint_wrap.h":
+                         const fmpz_mod_poly_t poly, const fmpz * xs, slong n,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_compose_horner(fmpz_mod_poly_t res,
+-                    const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_compose_divconquer(fmpz_mod_poly_t res,
+-                     const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_compose(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1,
+                          const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx)
+ 
+diff --git a/src/sage/libs/flint/fmpz_poly.pxd b/src/sage/libs/flint/fmpz_poly.pxd
+index 18b36672d30..c8bc6d3ca0a 100644
+--- a/src/sage/libs/flint/fmpz_poly.pxd
++++ b/src/sage/libs/flint/fmpz_poly.pxd
+@@ -28,7 +28,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_poly_set_ui(fmpz_poly_t, ulong)
+     void fmpz_poly_set_si(fmpz_poly_t, slong)
+     void fmpz_poly_set_fmpz(fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+     int fmpz_poly_set_str(fmpz_poly_t, const char *)
+ 
+     char *fmpz_poly_get_str(const fmpz_poly_t)
+@@ -70,7 +69,6 @@ cdef extern from "flint_wrap.h":
+     # Scalar multiplication and division
+     void fmpz_poly_scalar_mul_fmpz(
+             fmpz_poly_t, const fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+     void fmpz_poly_scalar_mul_si(fmpz_poly_t, const fmpz_poly_t, slong)
+     void fmpz_poly_scalar_mul_ui(fmpz_poly_t, const fmpz_poly_t, ulong)
+     void fmpz_poly_scalar_mul_2exp(fmpz_poly_t, const fmpz_poly_t, ulong)
+@@ -310,12 +308,14 @@ cdef extern from "flint_wrap.h":
+             fmpz_poly_t,
+                     const fmpz_poly_t, const fmpz_t, const nmod_poly_t, int)
+ 
+-    # Some functions for backwards compatibility
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
+-    void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++
++# functions removed from flint but still needed in sage
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
++cdef void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++cdef void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+ 
+ 
+ # Wrapper Cython class
+diff --git a/src/sage/libs/flint/fmpz_poly.pyx b/src/sage/libs/flint/fmpz_poly.pyx
+index 74915b37612..cfcbea9090c 100644
+--- a/src/sage/libs/flint/fmpz_poly.pyx
++++ b/src/sage/libs/flint/fmpz_poly.pyx
+@@ -25,10 +25,10 @@ from cysignals.memory cimport sig_free
+ 
+ from sage.arith.long cimport pyobject_to_long
+ from sage.cpython.string cimport char_to_str, str_to_bytes
++from sage.libs.flint.fmpz cimport *
+ from sage.structure.sage_object cimport SageObject
+ from sage.rings.integer cimport Integer
+ 
+-
+ cdef class Fmpz_poly(SageObject):
+ 
+     def __cinit__(self):
+@@ -455,3 +455,44 @@ cdef class Fmpz_poly(SageObject):
+         """
+         from sage.rings.integer_ring import ZZ
+         return ZZ[var](self.list())
++
++
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_divexact_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_fdiv_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t poly, slong n, const mpz_t x):
++    cdef fmpz_t t
++    fmpz_init_set_readonly(t, x)
++    fmpz_poly_set_coeff_fmpz(poly, n, t)
++    fmpz_clear_readonly(t)
++
++cdef void fmpz_poly_get_coeff_mpz(mpz_t x, const fmpz_poly_t poly, slong n):
++    cdef fmpz_t t
++    fmpz_init(t)
++    fmpz_poly_get_coeff_fmpz(t, poly, n)
++    fmpz_get_mpz(x, t)
++    fmpz_clear(t)
++
++cdef void fmpz_poly_set_mpz(fmpz_poly_t poly, const mpz_t x):
++    fmpz_poly_fit_length(poly, 1)
++    fmpz_set_mpz(poly.coeffs, x)
++    _fmpz_poly_set_length(poly, 1)
++    _fmpz_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz_poly_q.pxd b/src/sage/libs/flint/fmpz_poly_q.pxd
+index 846542dc0d8..63c13355bf6 100644
+--- a/src/sage/libs/flint/fmpz_poly_q.pxd
++++ b/src/sage/libs/flint/fmpz_poly_q.pxd
+@@ -49,11 +49,7 @@ cdef extern from "flint_wrap.h":
+ 
+     #* Scalar multiplication and division ****************************************/
+     void fmpz_poly_q_scalar_mul_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_mul_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_mul_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+     void fmpz_poly_q_scalar_div_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_div_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_div_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+ 
+     #* Multiplication and division ***********************************************/
+     void fmpz_poly_q_mul(fmpz_poly_q_t rop, 
+@@ -67,9 +63,6 @@ cdef extern from "flint_wrap.h":
+     #* Derivative ****************************************************************/
+     void fmpz_poly_q_derivative(fmpz_poly_q_t rop, const fmpz_poly_q_t op)
+ 
+-    #* Evaluation ****************************************************************/
+-    int fmpz_poly_q_evaluate(mpq_t rop, const fmpz_poly_q_t f, const mpq_t a)
+-
+     #* Input and output **********************************************************/
+     int fmpz_poly_q_set_str(fmpz_poly_q_t rop, const char *s)
+     char * fmpz_poly_q_get_str(const fmpz_poly_q_t op)
+diff --git a/src/sage/libs/linbox/linbox_flint_interface.pyx b/src/sage/libs/linbox/linbox_flint_interface.pyx
+index 415cd473947..83547f91cd2 100644
+--- a/src/sage/libs/linbox/linbox_flint_interface.pyx
++++ b/src/sage/libs/linbox/linbox_flint_interface.pyx
+@@ -33,6 +33,7 @@ and C. Pernet. The functions available are:
+ #                  https://www.gnu.org/licenses/
+ # ****************************************************************************
+ 
++from sage.libs.gmp.types cimport mpz_t
+ from sage.libs.flint.types cimport fmpz_t
+ from sage.libs.flint.fmpz cimport fmpz_get_mpz, fmpz_set_mpz
+ from sage.libs.flint.fmpz_mat cimport fmpz_mat_entry, fmpz_mat_nrows, fmpz_mat_ncols
+@@ -80,11 +81,13 @@ cdef void fmpz_poly_set_linbox(fmpz_poly_t p, PolynomialRing_integer.Element& q)
+     (the .pxd file) in order to keep the header C-compatible
+     """
+     cdef size_t i
++    cdef mpz_t tmp
+ 
+     fmpz_poly_fit_length(p, q.size())
+ 
+     for i in range(q.size()):
+-        fmpz_poly_set_coeff_mpz(p, i, q[i].get_mpz_const())
++        tmp = q[i].get_mpz_const()
++        fmpz_poly_set_coeff_mpz(p, i, tmp)
+ 
+     _fmpz_poly_set_length(p, q.size())
+ 
+diff --git a/src/sage/matrix/matrix_complex_ball_dense.pyx b/src/sage/matrix/matrix_complex_ball_dense.pyx
+index 3f56772a663..b1ece8a0e7b 100644
+--- a/src/sage/matrix/matrix_complex_ball_dense.pyx
++++ b/src/sage/matrix/matrix_complex_ball_dense.pyx
+@@ -1,4 +1,4 @@
+-# distutils: libraries = ARB_LIBRARY
++# distutils: libraries = flint
+ r"""
+ Arbitrary precision complex ball matrices using Arb
+ 
+diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx
+index f4320fcd914..b36ee300990 100644
+--- a/src/sage/matrix/matrix_integer_sparse.pyx
++++ b/src/sage/matrix/matrix_integer_sparse.pyx
+@@ -847,6 +847,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+             sage: matrix(ZZ, 1, 1, sparse=True)._charpoly_linbox()
+             x
+         """
++        cdef mpz_t tmp
+         if self._nrows != self._ncols:
+             raise ArithmeticError('only valid for square matrix')
+ 
+@@ -869,7 +870,8 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         cdef size_t i
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+@@ -966,9 +968,11 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         sig_off()
+ 
+         cdef size_t i
++        cdef mpz_t tmp
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
+index a22ce3c5e53..15be37734af 100644
+--- a/src/sage/rings/complex_arb.pyx
++++ b/src/sage/rings/complex_arb.pyx
+@@ -1360,12 +1360,13 @@ cdef class ComplexBall(RingElement):
+             sage: CBF100(-3r)
+             -3.000000000000000000000000000000
+ 
+-            sage: ComplexBall(CBF100, 10^100)
+-            1.000000000000000000000000000000e+100
+             sage: ComplexBall(CBF100, CIF(1, 2))
+             1.000000000000000000000000000000 + 2.000000000000000000000000000000*I
+             sage: ComplexBall(CBF100, RBF(1/3), RBF(1))
+             [0.3333333333333333 +/- ...e-17] + 1.000000000000000000000000000000*I
++            sage: ComplexBall(CBF100, 10^100)
++            [1.000000000000000000000000000000e+100 +/- ...]
++
+             sage: NF.<a> = QuadraticField(-1, embedding=CC(0, -1))
+             sage: CBF(a)
+             -1.000000000000000*I
+@@ -3009,7 +3010,7 @@ cdef class ComplexBall(RingElement):
+             sage: CBF(1).rising_factorial(2**64)
+             [+/- ...e+347382171326740403407]
+             sage: ComplexBallField(128)(1).rising_factorial(2**64)
+-            [2.343691126796861348e+347382171305201285713 +/- ...e+347382171305201285694]
++            [2.34369112679686134...e+347382171305201285713 +/- ...]
+             sage: CBF(1/2).rising_factorial(CBF(2,3)) # abs tol 1e-15
+             [-0.123060451458124 +/- 3.06e-16] + [0.0406412631676552 +/- 7.57e-17]*I
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+index b888b31d214..621d86f9bb8 100644
+--- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+@@ -222,7 +222,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef unsigned long n
+         cdef Rational c
+         cdef list L1
+-        cdef mpq_t * L2
++        cdef fmpq_t q
+ 
+         Polynomial.__init__(self, parent, is_gen=is_gen)
+ 
+@@ -253,14 +253,11 @@ cdef class Polynomial_rational_flint(Polynomial):
+             L1 = [e if isinstance(e, Rational) else Rational(e) for e in x]
+             n  = <unsigned long> len(x)
+             sig_on()
+-            L2 = <mpq_t *> check_allocarray(n, sizeof(mpq_t))
++            fmpq_poly_fit_length(self._poly, n)
+             for deg from 0 <= deg < n:
+-                mpq_init(L2[deg])
+-                mpq_set(L2[deg], (<Rational> L1[deg]).value)
+-            fmpq_poly_set_array_mpq(self._poly, L2, n)
+-            for deg from 0 <= deg < n:
+-                mpq_clear(L2[deg])
+-            sig_free(L2)
++                fmpq_init_set_readonly(q, (<Rational> L1[deg]).value)
++                fmpq_poly_set_coeff_fmpq(self._poly, deg, q)
++                fmpq_clear_readonly(q)
+             sig_off()
+ 
+ #           deg = 0
+@@ -435,6 +432,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         utmost care.
+         """
+         cdef bint do_sig = _do_sig(self._poly)
++        cdef fmpz_t tmpfz
+ 
+         if isinstance(value, int):
+             if do_sig: sig_str("FLINT exception")
+@@ -442,7 +440,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+             if do_sig: sig_off()
+         elif isinstance(value, Integer):
+             if do_sig: sig_str("FLINT exception")
+-            fmpq_poly_set_coeff_mpz(self._poly, n, (<Integer> value).value)
++            fmpz_init_set_readonly(tmpfz, (<Integer> value).value)
++            fmpq_poly_set_coeff_fmpz(self._poly, n, tmpfz)
++            fmpz_clear_readonly(tmpfz)
+             if do_sig: sig_off()
+         elif isinstance(value, Rational):
+             if do_sig: sig_str("FLINT exception")
+@@ -492,7 +492,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef Polynomial_rational_flint f
+         cdef Rational r
+         cdef fmpz_t tmpfz
+-        cdef fmpq_t tmpfq
++        cdef fmpq_t tmpfq, tmpfq1
+         cdef RealBall arb_a, arb_z
+         cdef ComplexBall acb_a, acb_z
+ 
+@@ -508,13 +508,23 @@ cdef class Polynomial_rational_flint(Polynomial):
+             elif isinstance(a, Rational):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpq(r.value, self._poly, (<Rational> a).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> a).value)
++                fmpq_init(tmpfq1)
++                fmpq_poly_evaluate_fmpq(tmpfq1, self._poly, tmpfq)
++                fmpq_get_mpq(r.value, tmpfq1)
++                fmpq_clear(tmpfq1)
++                fmpq_clear_readonly(tmpfq)
+                 sig_off()
+                 return r
+             elif isinstance(a, Integer):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpz(r.value, self._poly, (<Integer> a).value)
++                fmpz_init_set_readonly(tmpfz, (<Integer> a).value)
++                fmpq_init(tmpfq)
++                fmpq_poly_evaluate_fmpz(tmpfq, self._poly, tmpfz)
++                fmpq_get_mpq(r.value, tmpfq)
++                fmpq_clear(tmpfq)
++                fmpz_clear_readonly(tmpfz)
+                 sig_off()
+                 return r
+             elif isinstance(a, int):
+@@ -1321,6 +1331,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         """
+         cdef Polynomial_rational_flint res
+         cdef bint do_sig
++        cdef fmpq_t tmpfq
+ 
+         if right == 0:
+             raise ZeroDivisionError("division by zero polynomial")
+@@ -1331,8 +1342,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+                 do_sig = _do_sig(self._poly)
+ 
+                 if do_sig: sig_str("FLINT exception")
+-                fmpq_poly_scalar_div_mpq(res._poly, self._poly,
+-                                                  (<Rational> QQ(right)).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> QQ(right)).value)
++                fmpq_poly_scalar_div_fmpq(res._poly, self._poly, tmpfq)
++                fmpq_clear_readonly(tmpfq)
+                 if do_sig: sig_off()
+                 return res
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+index 4c480673861..780549af062 100644
+--- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+@@ -658,6 +658,11 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
+             ...
+             NotImplementedError: square free factorization of polynomials over rings with composite characteristic is not implemented
+ 
++        :trac:`20003`::
++
++            sage: P.<x> = GF(7)[]
++            sage: (6*x+3).squarefree_decomposition()
++            (6) * (x + 4)
+         """
+         if not self.base_ring().is_field():
+             raise NotImplementedError("square free factorization of polynomials over rings with composite characteristic is not implemented")
+diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
+index 17859068273..14baa5bc5aa 100644
+--- a/src/sage/rings/real_arb.pyx
++++ b/src/sage/rings/real_arb.pyx
+@@ -898,7 +898,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+             sage: RBF.gamma(5)
+             24.00000000000000
+             sage: RBF.gamma(10**20)
+-            [+/- ...e+1956570552410610660600]
++            [1.932849514310098...+1956570551809674817225 +/- ...]
+             sage: RBF.gamma(1/3)
+             [2.678938534707747 +/- ...e-16]
+             sage: RBF.gamma(-5)
+@@ -1102,7 +1102,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+              15.00000000000000,
+              48.00000000000000]
+             sage: RBF.double_factorial(2**20)
+-            [1.4483729903e+2928836 +/- ...e+2928825]
++            [1.448372990...e+2928836 +/- ...]
+             sage: RBF.double_factorial(2**1000)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/schemes/plane_conics/con_rational_function_field.py b/src/sage/schemes/plane_conics/con_rational_function_field.py
+index 1b3f0ac412a..485c9c71be3 100644
+--- a/src/sage/schemes/plane_conics/con_rational_function_field.py
++++ b/src/sage/schemes/plane_conics/con_rational_function_field.py
+@@ -198,38 +198,6 @@ def has_rational_point(self, point=False, algorithm='default',
+             Fraction Field of Univariate Polynomial Ring in u over Rational
+             Field with modulus v^2 - u^3 - 1
+ 
+-        ``has_rational_point`` fails for some conics over function fields
+-        over finite fields, due to :trac:`20003`::
+-
+-            sage: K.<t> = PolynomialRing(GF(7))
+-            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
+-            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
+-            sage: C.has_rational_point()
+-            Traceback (most recent call last):
+-            ...
+-            TypeError: self (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (-t^3 + 3*t^2 - 2*t - 2)/(t + 3)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (t^2 + 3*t + 3)*x*y + (-2*t^2 - 2)*y^2 + (-t^2 + 3*t + 2)*x*z + (-3*t + 3)*y*z + (-3*t^2 + t - 2)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x + (2*t - 2)/(t + 3)*y + (3*t^4 + 2*t^3 - 2*t^2 - 2*t + 3)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z
+-                     : y + (-t^3 - t^2 + 3*t - 1)/(t^3 - 3*t^2 + 2*t + 2)*z : z))
+-            domain must equal right (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^3 - t^2 + 3*t + 3)*x^2 + (t - 3)*y^2 + (-t^7 + 2*t^5 + t^4 + 2*t^3 + 3*t^2 - t - 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    -2/(t^3 - 3*t^2 + 2*t + 2)*x^2 + 1/(t^3 + 3*t^2 - 2*t + 1)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^9 - 2*t^8 + t^7 - t^6 + 3*t^5 - 3*t^3 + t^2 - 2*t + 3)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    ((t^3 - 3*t^2 + 2*t + 2)*x : (t^2 - 2)*y : (t^5 - 3*t^4 + t^2 + 3*t + 3)*z))
+-            codomain
+-
+-
+-
+         TESTS::
+ 
+             sage: K.<t> = FractionField(PolynomialRing(QQ, 't'))
+@@ -250,6 +218,16 @@ def has_rational_point(self, point=False, algorithm='default',
+             sage: C.has_rational_point(point = True) # long time (4 seconds)
+             (True,
+              ((-2/117*t^8 + 304/1053*t^7 + 40/117*t^6 - 1/27*t^5 - 110/351*t^4 - 2/195*t^3 + 11/351*t^2 + 1/117)/(t^4 + 2/39*t^3 + 4/117*t^2 + 2/39*t + 14/39) : -5/3*t^4 + 19*t^3 : 1))
++
++        ``has_rational_point`` used to fail for some conics over function fields
++        over finite fields, due to :trac:`20003`::
++
++            sage: K.<t> = PolynomialRing(GF(7))
++            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
++            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
++            sage: C.has_rational_point()
++            True
++
+         """
+         from .constructor import Conic
+ 
+diff --git a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+index a591cb4cd7c..a90f2050c59 100644
+--- a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
++++ b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+@@ -20,6 +20,7 @@
+ #include "utils.h"
+ 
+ #include "gmp.h"
++#include "flint/fmpz_poly.h"
+ #include "flint/fmpq_poly.h"
+ #include "flint/fmpq.h"
+ 
+@@ -63,7 +64,7 @@ static ex chebyt_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+@@ -122,7 +123,7 @@ static ex chebyu_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+diff --git a/src/sage/symbolic/ginac/useries.cpp b/src/sage/symbolic/ginac/useries.cpp
+index 40fbd7ab360..b9a8b867648 100644
+--- a/src/sage/symbolic/ginac/useries.cpp
++++ b/src/sage/symbolic/ginac/useries.cpp
+@@ -467,10 +467,17 @@ void add::useries(flint_series_t& fp, int order) const
+                 fmpq_poly_set_ui(fp.ft, 0);
+         else if (oc.is_long())
+                 fmpq_poly_set_si(fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ 
+         for (const auto & elem : seq) {
+ 		const ex& t = recombine_pair_to_ex(elem);
+@@ -505,10 +512,17 @@ void mul::useries(flint_series_t& fp, int order) const
+ 
+         if (oc.is_long())
+                 fmpq_poly_scalar_mul_si(fp.ft, fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_scalar_mul_mpz(fp.ft, fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_scalar_mul_mpq(fp.ft, fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_scalar_mul_fmpz(fp.ft, fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp.ft, fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ void power::useries(flint_series_t& fp, int order) const
+@@ -563,7 +577,10 @@ void power::useries(flint_series_t& fp, int order) const
+                 }
+                 check_poly_ccoeff_one(fp1);
+                 fmpq_poly_log_series(fp1.ft, fp1.ft, order);
+-                fmpq_poly_scalar_mul_mpq(fp1.ft, fp1.ft, nexp.as_mpq());
++                fmpq_t tmp;
++                fmpq_init_set_readonly(tmp, nexp.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp1.ft, fp1.ft, tmp);
++                fmpq_clear_readonly(tmp);
+                 fmpq_poly_exp_series(fp.ft, fp1.ft, order);
+                 return;
+         }
+@@ -608,10 +625,17 @@ void numeric::useries(flint_series_t& fp, int order) const
+ {
+         if (is_long())
+                 fmpq_poly_set_si(fp.ft, to_long());
+-        else if (is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, as_mpq());
++        else if (is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ } // namespace GiNaC
+diff --git a/src/sage_setup/library_order.py b/src/sage_setup/library_order.py
+index f40690f8d22..9ae0d2579a7 100644
+--- a/src/sage_setup/library_order.py
++++ b/src/sage_setup/library_order.py
+@@ -16,17 +16,12 @@
+ 
+ aliases = cython_aliases(required_modules=(), optional_modules=modules)
+ 
+-if "ARB_LIBRARY" in aliases:
+-    arb_dylib_names = [aliases["ARB_LIBRARY"]]
+-else:
+-    arb_dylib_names = []
+-
+ library_order_list = aliases.get("SINGULAR_LIBRARIES", []) + [
+     "giac", "intl", "curl",
+     "ec", "ecm"
+ ] + aliases.get("LINBOX_LIBRARIES", []) + aliases.get("FFLASFFPACK_LIBRARIES", []) + aliases.get("GSL_LIBRARIES", []) + [
+     "pari", "flint", "ecl", "glpk", "ppl",
+-] + arb_dylib_names + [
++] + [
+     "mpfi", "mpfr", "mpc", "ntl", "gmp", "gmpxx",
+     "brial",
+     "brial_groebner",
diff --git a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch b/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
deleted file mode 100644
index 7c55bce6e9bb4..0000000000000
--- a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
+++ /dev/null
@@ -1,221 +0,0 @@
-diff --git a/build/pkgs/singular/checksums.ini b/build/pkgs/singular/checksums.ini
-index 313463d2fea..1101fc55700 100644
---- a/build/pkgs/singular/checksums.ini
-+++ b/build/pkgs/singular/checksums.ini
-@@ -1,5 +1,5 @@
- tarball=singular-VERSION.tar.gz
--sha1=28bb3ee97ef48d04dfa96de182fd93eebe08426c
--md5=fc0a4f5720dadba45a52ee94324ce00c
--cksum=1573851737
--upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-1/singular-VERSION.tar.gz
-+sha1=df1997f412580f2073295aba569bb955ad227317
-+md5=50349213e206a18cdaa1bc410dde7ea4
-+cksum=376854707
-+upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-2/singular-VERSION.tar.gz
-diff --git a/build/pkgs/singular/package-version.txt b/build/pkgs/singular/package-version.txt
-index 66e2bede53a..9f1bf008217 100644
---- a/build/pkgs/singular/package-version.txt
-+++ b/build/pkgs/singular/package-version.txt
-@@ -1 +1 @@
--4.3.1p3
-+4.3.2p7
-diff --git a/build/pkgs/singular/spkg-configure.m4 b/build/pkgs/singular/spkg-configure.m4
-index 6a85631f624..f7621ec5fa1 100644
---- a/build/pkgs/singular/spkg-configure.m4
-+++ b/build/pkgs/singular/spkg-configure.m4
-@@ -6,14 +6,27 @@ SAGE_SPKG_CONFIGURE([singular], [
-     AS_IF([test -z "${SINGULAR_BIN}"], [sage_spkg_install_singular=yes], [
-       dnl Use pkg-config to ensure that Singular is new enough.
-       PKG_CHECK_MODULES([SINGULAR], [Singular >= 4.2.1], [
--       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)
--       ], [
--       AC_MSG_RESULT(no)
--       sage_spkg_install_singular=yes
--       ]
--      )], [
-+        AC_MSG_CHECKING([whether Singular is built with FLINT])
-+        AC_COMPILE_IFELSE([
-+          AC_LANG_PROGRAM([
-+            #include <singular/singularconfig.h>
-+            #if !defined(HAVE_FLINT)
-+            #  error "Need Singular compiled with FLINT"
-+          ], [])
-+        ], [
-+          AC_MSG_RESULT([yes])
-+          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)
-+          ], [
-+            AC_MSG_RESULT(no)
-+            sage_spkg_install_singular=yes
-+          ])
-+        ], [
-+          AC_MSG_RESULT([no])
-+          sage_spkg_install_singular=yes
-+        ])
-+      ], [
-       dnl pkg-config version check failed
-       sage_spkg_install_singular=yes
-       ])
-diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py
-index b15cc1c602c..4b5c76e2bfa 100644
---- a/src/sage/interfaces/singular.py
-+++ b/src/sage/interfaces/singular.py
-@@ -604,8 +604,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: i = singular.ideal(['x^2','y^2','z^2'])
-             sage: s = i.std()
-             sage: singular.eval('hilb(%s)'%(s.name()))
--            '// 1 t^0\n// -3 t^2\n// 3 t^4\n// -1 t^6\n\n// 1 t^0\n//
--            3 t^1\n// 3 t^2\n// 1 t^3\n// dimension (affine) = 0\n//
-+            '...// dimension (affine) = 0\n//
-             degree (affine) = 8'
- 
-         ::
-@@ -613,15 +612,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: from sage.misc.verbose import set_verbose
-             sage: set_verbose(1)
-             sage: o = singular.eval('hilb(%s)'%(s.name()))
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
- 
-         This is mainly useful if this method is called implicitly. Because
-@@ -631,15 +622,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-         ::
- 
-             sage: o = s.hilb()
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
-             // ** right side is not a datum, assignment ignored
-             ...
-diff --git a/src/sage/libs/singular/function.pyx b/src/sage/libs/singular/function.pyx
-index f40346d1fd0..c597c63aafe 100644
---- a/src/sage/libs/singular/function.pyx
-+++ b/src/sage/libs/singular/function.pyx
-@@ -1241,32 +1241,22 @@ cdef class SingularFunction(SageObject):
-             sage: I = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5])
-             sage: I = Ideal(I.groebner_basis())
-             sage: hilb = sage.libs.singular.function_factory.ff.hilb
--            sage: hilb(I) # Singular will print // ** _ is no standard basis
--            // ** _ is no standard basis
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: from sage.misc.sage_ostools import redirection
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I) # Singular will print // ** _ is no standard basis
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            True
- 
-         So we tell Singular that ``I`` is indeed a Groebner basis::
- 
--            sage: hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            False
- 
- 
-         TESTS:
-diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-index 22ada6de947..80352700872 100644
---- a/src/sage/rings/polynomial/multi_polynomial_ideal.py
-+++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-@@ -3132,13 +3132,16 @@ def hilbert_numerator(self, grading=None, algorithm='sage'):
-             sage: I.hilbert_numerator()                                                 # needs sage.rings.number_field
-             -t^5 + 1
- 
--        This example returns a wrong answer due to an integer overflow in Singular::
-+        This example returns a wrong answer in singular < 4.3.2p4 due to an integer overflow::
- 
-             sage: n=4; m=11; P = PolynomialRing(QQ, n*m, "x"); x = P.gens(); M = Matrix(n, x)
-             sage: I = P.ideal(M.minors(2))
-             sage: J = P * [m.lm() for m in I.groebner_basis()]
--            sage: J.hilbert_numerator(algorithm='singular')
--            ...120*t^33 - 3465*t^32 + 48180*t^31 - ...
-+            sage: J.hilbert_numerator(algorithm='singular') # known bug
-+            Traceback (most recent call last):
-+            ....
-+            RuntimeError: error in Singular function call 'hilb':
-+            overflow at t^22
- 
-         Our two algorithms should always agree; not tested until
-         :trac:`33178` is fixed::
-diff --git a/src/sage/sandpiles/sandpile.py b/src/sage/sandpiles/sandpile.py
-index 02d2021b2fb..c8e15e06f05 100644
---- a/src/sage/sandpiles/sandpile.py
-+++ b/src/sage/sandpiles/sandpile.py
-@@ -2493,9 +2493,15 @@ def _set_ideal(self):
-             sage: '_ideal' in S.__dict__
-             True
-         """
-+        from sage.libs.singular.function_factory import ff
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
-         R = self.ring()
--        I = self._unsaturated_ideal._singular_()
--        self._ideal = R.ideal(I.sat(prod(R.gens())._singular_())[1])
-+        I = self._unsaturated_ideal
-+        I_sat_gens = sat(I, prod(R.gens()))[0]
-+        self._ideal = R.ideal(I_sat_gens)
- 
-     def unsaturated_ideal(self):
-         r"""
-diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py
-index e6caf19ba74..afd6484d779 100644
---- a/src/sage/schemes/projective/projective_subscheme.py
-+++ b/src/sage/schemes/projective/projective_subscheme.py
-@@ -1001,7 +1001,10 @@ def dual(self):
-         for i in range(n + 1):
-             J = J + S.ideal(z[-1] * f_S.derivative(z[i]) - z[i + n + 1])
- 
--        sat = ff.elim__lib.sat
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
- 
-         max_ideal = S.ideal(z[n + 1: 2 * n + 2])
-         J_sat_gens = sat(J, max_ideal)[0]
diff --git a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch b/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
deleted file mode 100644
index 6a35ec3836550..0000000000000
--- a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-diff --git a/src/sage/ext/memory.pyx b/src/sage/ext/memory.pyx
-index 1de6dedab82..b95130b19dd 100644
---- a/src/sage/ext/memory.pyx
-+++ b/src/sage/ext/memory.pyx
-@@ -3,14 +3,14 @@ Low-level memory allocation functions
- 
- TESTS:
- 
--Check that a ``MemoryError`` is raised if we try to allocate a
-+Check that an error is raised if we try to allocate a
- ridiculously large integer, see :trac:`15363`::
- 
--    sage: 2^(2^63-3)
--    Traceback (most recent call last):
--    ...
--    OverflowError: exponent must be at most 2147483647         # 32-bit
--    RuntimeError: Aborted                                      # 64-bit
-+    sage: try:
-+    ....:     2^(2^63-3)
-+    ....: except (OverflowError, RuntimeError, FloatingPointError):
-+    ....:     print ('Overflow error')
-+    ...Overflow error
- 
- AUTHORS:
- 
-diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx
-index d5e87626d31..37ed9364845 100644
---- a/src/sage/rings/integer.pyx
-+++ b/src/sage/rings/integer.pyx
-@@ -6654,7 +6654,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
-             sage: try:
-             ....:     print('Possible error output from gmp', flush=True)
-             ....:     1 << (2^60)
--            ....: except (MemoryError, OverflowError, RuntimeError):
-+            ....: except (MemoryError, OverflowError, RuntimeError, FloatingPointError):
-             ....:     pass
-             ....: else:
-             ....:     print("Failed to raise exception")
diff --git a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch b/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
deleted file mode 100644
index 3d2a4bd9cd96f..0000000000000
--- a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
+++ /dev/null
@@ -1,740 +0,0 @@
-diff --git a/src/sage/ext_data/valgrind/valgrind-python.supp b/src/sage/ext_data/valgrind/valgrind-python.supp
-new file mode 100644
-index 00000000000..16aa2858484
---- /dev/null
-+++ b/src/sage/ext_data/valgrind/valgrind-python.supp
-@@ -0,0 +1,480 @@
-+# From the CPython repository with the suppressions for _PyObject_Free
-+# and _PyObject_Realloc enabled. See the upstream suppression file for
-+# details:
-+#
-+# https://github.com/python/cpython/blob/main/Misc/valgrind-python.supp
-+
-+# all tool names: Addrcheck,Memcheck,cachegrind,helgrind,massif
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 8 (x86_64 aka amd64)
-+   Memcheck:Value8
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:address_in_range
-+}
-+
-+#
-+# Leaks (including possible leaks)
-+#    Hmmm, I wonder if this masks some real leaks.  I think it does.
-+#    Will need to fix that.
-+#
-+
-+{
-+   Suppress leaking the GIL after a fork.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_allocate_lock
-+   fun:PyEval_ReInitThreads
-+}
-+
-+{
-+   Suppress leaking the autoTLSkey.  This looks like it shouldn't leak though.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_create_key
-+   fun:_PyGILState_Init
-+   fun:Py_InitializeEx
-+   fun:Py_Main
-+}
-+
-+{
-+   Hmmm, is this a real leak or like the GIL?
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_ReInitTLS
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:realloc
-+   fun:_PyObject_GC_Resize
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_New
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_NewVar
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+#
-+# Non-python specific leaks
-+#
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:calloc
-+   fun:allocate_dtv
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:memalign
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Realloc
-+}
-+
-+###
-+### All the suppressions below are for errors that occur within libraries
-+### that Python uses.  The problems to not appear to be related to Python's
-+### use of the libraries.
-+###
-+
-+{
-+   Generic ubuntu ld problems
-+   Memcheck:Addr8
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+}
-+
-+{
-+   Generic gentoo ld problems
-+   Memcheck:Cond
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_close
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Value8
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   GDBM problems, see test_gdbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   fun:gdbm_open
-+
-+}
-+
-+{
-+   Uninitialised byte(s) false alarm, see bpo-35561
-+   Memcheck:Param
-+   epoll_ctl(event)
-+   fun:epoll_ctl
-+   fun:pyepoll_internal_ctl
-+}
-+
-+{
-+   ZLIB problems, see test_gzip
-+   Memcheck:Cond
-+   obj:/lib/libz.so.1.2.3
-+   obj:/lib/libz.so.1.2.3
-+   fun:deflate
-+}
-+
-+{
-+   Avoid problems w/readline doing a putenv and leaking on exit
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:xmalloc
-+   fun:sh_set_lines_and_columns
-+   fun:_rl_get_screen_size
-+   fun:_rl_init_terminal_io
-+   obj:/lib/libreadline.so.4.3
-+   fun:rl_initialize
-+}
-+
-+# Valgrind emits "Conditional jump or move depends on uninitialised value(s)"
-+# false alarms on GCC builtin strcmp() function. The GCC code is correct.
-+#
-+# Valgrind bug: https://bugs.kde.org/show_bug.cgi?id=264936
-+{
-+   bpo-38118: Valgrind emits false alarm on GCC builtin strcmp()
-+   Memcheck:Cond
-+   fun:PyUnicode_Decode
-+}
-+
-+
-+###
-+### These occur from somewhere within the SSL, when running
-+###  test_socket_sll.  They are too general to leave on by default.
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:memset
-+###}
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:memset
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:MD5_Update
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:MD5_Update
-+###}
-+
-+# Fedora's package "openssl-1.0.1-0.1.beta2.fc17.x86_64" on x86_64
-+# See http://bugs.python.org/issue14171
-+{
-+   openssl 1.0.1 prng 1
-+   Memcheck:Cond
-+   fun:bcmp
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 2
-+   Memcheck:Cond
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 3
-+   Memcheck:Value8
-+   fun:_x86_64_AES_encrypt_compact
-+   fun:AES_encrypt
-+}
-+
-+#
-+# All of these problems come from using test_socket_ssl
-+#
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_bin2bn
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libcrypto.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_set_key_unchecked
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_encrypt2
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BUF_MEM_grow_clean
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:memcpy
-+   fun:ssl3_read_bytes
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:SHA1_Update
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:SHA1_Update
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-+{
-+   wcscmp_false_positive
-+   Memcheck:Addr8
-+   fun:wcscmp
-+   fun:_PyOS_GetOpt
-+   fun:Py_Main
-+   fun:main
-+}
-+
-+# Additional suppressions for the unified decimal tests:
-+{
-+   test_decimal
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_decimal2
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index b40ed64edb5..8c55861c147 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -1576,6 +1576,62 @@ const numeric numeric::div(const numeric &other) const {
-         }
- }
- 
-+
-+// Compute `a^b` as an integer, where a is an integer. Assign to ``res``` if it is integral, or return ``false``.
-+// The nonnegative real root is taken for even denominators. To be used inside numeric::integer_rational_power,
-+// to handle the special case of integral ``a``.
-+bool integer_rational_power_of_mpz(
-+        numeric& res,
-+        const numeric& a,
-+        const numeric& b
-+) {
-+        if (a.t != MPZ)
-+                throw std::runtime_error("integer_rational_power_of_mpz: bad input");
-+        mpz_t z;
-+        mpz_init(z);
-+        mpz_set_ui(z, 0);
-+        int sgn = mpz_sgn(a.v._bigint);
-+        if (mpz_cmp_ui(a.v._bigint, 1) == 0
-+            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
-+                mpz_set_ui(z, 1);
-+        else if (sgn == 0) {
-+                res = *_num0_p;
-+                mpz_clear(z);
-+                return true;
-+        }
-+        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1)) {
-+                mpz_clear(z);
-+                return false;
-+        } else {
-+                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-+                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat))) {
-+                        // too big to take roots/powers
-+                        mpz_clear(z);
-+                        return false;
-+                }
-+                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
-+                        if (mpz_perfect_square_p(a.v._bigint)) {
-+                                mpz_sqrt(z, a.v._bigint);
-+                        } else {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                else {
-+                        bool exact = mpz_root(z, a.v._bigint,
-+                                              mpz_get_ui(mpq_denref(b.v._bigrat)));
-+                        if (not exact) {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
-+        }
-+        res = numeric(z);   // transfers ownership, no mpz_clear
-+        return true;
-+}
-+
-+
- // Compute `a^b` as an integer, if it is integral, or return ``false``.
- // The nonnegative real root is taken for even denominators.
- bool numeric::integer_rational_power(numeric& res,
-@@ -1598,13 +1654,12 @@ bool numeric::integer_rational_power(numeric& res,
-                 if (a.v._long < 0
-                     and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
-                         return false;
--                long z;
-                 if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-                     or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
-                 // too big to take roots/powers
-                         return false;
-                 if (b.is_equal(*_num1_2_p)) {
--                        z = std::lround(std::sqrt(a.v._long));
-+                        long z = std::lround(std::sqrt(a.v._long));
-                         if (a.v._long == z*z) {
-                                 res = numeric(z);
-                                 return true;
-@@ -1613,44 +1668,11 @@ bool numeric::integer_rational_power(numeric& res,
-                 }
-                 return integer_rational_power(res, a.to_bigint(), b);
-         }
--        if (a.t != MPZ)
--                throw std::runtime_error("integer_rational_power: bad input");
--        int sgn = mpz_sgn(a.v._bigint);
--        mpz_t z;
--        mpz_init(z);
--        mpz_set_ui(z, 0);
--        if (mpz_cmp_ui(a.v._bigint, 1) == 0
--            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
--                mpz_set_ui(z, 1);
--        else if (sgn == 0) {
--                res = *_num0_p;
--                return true;
--        }
--        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
--                return false;
--        else {
--                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
--                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
--                // too big to take roots/powers
--                        return false;
--                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
--                        if (mpz_perfect_square_p(a.v._bigint))
--                                mpz_sqrt(z, a.v._bigint);
--                        else
--                                return false;
--                }
--                else {
--                        bool exact = mpz_root(z, a.v._bigint,
--                                        mpz_get_ui(mpq_denref(b.v._bigrat)));
--                        if (not exact)
--                                return false;
--                }
--                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
--        }
--        res = numeric(z);
--        return true;
-+        // otherwise: a is integer
-+        return integer_rational_power_of_mpz(res, a, b);
- }
- 
-+
- // for a^b return c,d such that a^b = c*d^b
- // only for MPZ/MPQ base and MPQ exponent
- void rational_power_parts(const numeric& a_orig, const numeric& b_orig,
-diff --git a/src/sage/tests/memcheck/__init__.py b/src/sage/tests/memcheck/__init__.py
-new file mode 100644
-index 00000000000..e69de29bb2d
-diff --git a/src/sage/tests/memcheck/run_tests.py b/src/sage/tests/memcheck/run_tests.py
-new file mode 100644
-index 00000000000..6ff4503a81b
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests.py
-@@ -0,0 +1,24 @@
-+import types
-+
-+
-+def run_tests() -> None:
-+    """
-+    Run all memcheck tests
-+    """
-+    from sage.tests.memcheck import symbolic_expression
-+    run_tests_in_module(symbolic_expression)
-+
-+
-+def run_tests_in_module(mod: types.ModuleType) -> None:
-+    """
-+    Run all memcheck tests in the given module
-+    """
-+    for entry in dir(mod):
-+        if not entry.startswith('test_'):
-+            continue
-+        test_func = getattr(mod, entry)
-+        test_func()
-+
-+
-+if __name__ == '__main__':
-+    run_tests()
-diff --git a/src/sage/tests/memcheck/run_tests_in_valgrind.py b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-new file mode 100644
-index 00000000000..df5ad0e92b2
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-@@ -0,0 +1,35 @@
-+"""
-+Launch valgrind and run the memory leak tests
-+
-+
-+From the commandline, run
-+
-+    sage -python -m sage.tests.memcheck.run_tests_in_valgrind
-+
-+to launch valgrind and execute the memory leak tests. Requires valgrind
-+to be installed. Alternatively, run as a unit test:
-+
-+    sage: from sage.tests.memcheck.run_tests_in_valgrind import run_tests_in_valgrind
-+    sage: run_tests_in_valgrind()    # optional - valgrind
-+"""
-+
-+import subprocess
-+
-+
-+def run_tests_in_valgrind() -> None:
-+    """
-+    Run the sage.tests.memcheck.run_tests module inside valgrind
-+    """
-+    subprocess.check_call([
-+        'valgrind',
-+        '--suppressions=src/sage/ext_data/valgrind/valgrind-python.supp',
-+        '--show-possibly-lost=no',
-+        '--show-reachable=no',
-+        './venv/bin/python',
-+        '-m',
-+        'sage.tests.memcheck.run_tests'
-+    ])
-+
-+
-+if __name__ == '__main__':
-+    run_tests_in_valgrind()
-diff --git a/src/sage/tests/memcheck/symbolic_expression.py b/src/sage/tests/memcheck/symbolic_expression.py
-new file mode 100644
-index 00000000000..52182fbe62d
---- /dev/null
-+++ b/src/sage/tests/memcheck/symbolic_expression.py
-@@ -0,0 +1,11 @@
-+from sage.tests.memcheck.verify_no_leak import verify_no_leak
-+
-+
-+def test_sqrt_sqrt_2() -> None:
-+    from sage.misc.functional import sqrt
-+    T2 = sqrt(2)
-+
-+    def sqrt_T2() -> None:
-+        sqrt(T2)
-+
-+    verify_no_leak(sqrt_T2)
-diff --git a/src/sage/tests/memcheck/verify_no_leak.py b/src/sage/tests/memcheck/verify_no_leak.py
-new file mode 100644
-index 00000000000..89ca90cf89c
---- /dev/null
-+++ b/src/sage/tests/memcheck/verify_no_leak.py
-@@ -0,0 +1,27 @@
-+from typing import Tuple, Sequence, List, Callable, Any
-+import valgrind
-+
-+
-+def verify_no_leak(callback: Callable[[], Any],
-+                   repeat: int = 10000,
-+                   fuzzy: int = 10,
-+                   ) -> None:
-+    """
-+    Verify that the callback does not generate new definitely lost blocks
-+
-+    Raises an assertion if the callback leaks memory
-+    """
-+    callback()   # warm_up
-+    initial_blocks = (0, 0, 0, 0)
-+    valgrind.memcheck_do_leak_check()
-+    initial_blocks = valgrind.memcheck_count_leak_blocks()
-+    for _ in range(repeat):
-+        callback()
-+    valgrind.memcheck_do_leak_check()
-+    leak_blocks = valgrind.memcheck_count_leak_blocks()
-+    leak = leak_blocks[0] - initial_blocks[0]
-+    if leak < repeat - fuzzy:
-+        return  # callback did not leak at least once per call
-+    blocks = round(leak / repeat, 2)
-+    message = f'{callback} leaked {blocks} block on average ({repeat} iterations)'
-+    raise AssertionError(message)
diff --git a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch b/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
deleted file mode 100644
index 684b62affaf5a..0000000000000
--- a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx
-index 8f46570313d..a8e73e57b52 100644
---- a/src/sage/libs/ecl.pyx
-+++ b/src/sage/libs/ecl.pyx
-@@ -563,15 +563,15 @@ cdef class EclObject:
-     Floats in Python are IEEE double, which LISP has as well. However,
-     the printing of floating point types in LISP depends on settings::
- 
--        sage: a = EclObject(float(10^40))
-+        sage: a = EclObject(float(1.234e40))
-         sage: ecl_eval("(setf *read-default-float-format* 'single-float)")
-         <ECL: SINGLE-FLOAT>
-         sage: a
--        <ECL: 1.d40>
-+        <ECL: 1.234d40>
-         sage: ecl_eval("(setf *read-default-float-format* 'double-float)")
-         <ECL: DOUBLE-FLOAT>
-         sage: a
--        <ECL: 1.e40>
-+        <ECL: 1.234e40>
- 
-     Tuples are translated to dotted lists::
- 
-diff --git a/src/sage/libs/eclsig.h b/src/sage/libs/eclsig.h
-index e249ccf6874..005b2d99d0b 100644
---- a/src/sage/libs/eclsig.h
-+++ b/src/sage/libs/eclsig.h
-@@ -45,7 +45,11 @@ static inline void ecl_sig_off(void)
-     sig_off();
- }
- 
-+#if ECL_VERSION_NUMBER < 230909
- #define ecl_mpz_from_bignum(obj) ((obj)->big.big_num)
-+#else
-+#define ecl_mpz_from_bignum(obj) ecl_bignum(obj)
-+#endif
- 
- cl_object ecl_bignum_from_mpz(mpz_t num)
- {
diff --git a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch b/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
deleted file mode 100644
index e858f2fd4a445..0000000000000
--- a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
-index 59f10f6b13f..adcccff059b 100644
---- a/src/sage/plot/graphics.py
-+++ b/src/sage/plot/graphics.py
-@@ -36,6 +36,7 @@
- # ****************************************************************************
- 
- import os
-+from numbers import Integral
- from collections.abc import Iterable
- from math import isnan
- import sage.misc.verbose
-@@ -2874,6 +2875,11 @@ def matplotlib(self, filename=None,
-                 weight=lopts.pop('font_weight', 'medium'),
-                 variant=lopts.pop('font_variant', 'normal'))
-             color = lopts.pop('back_color', 'white')
-+            if 'loc' in lopts:
-+                loc = lopts['loc']
-+                if isinstance(loc, Integral):
-+                    # matplotlib 3.8 doesn't support sage integers
-+                    lopts['loc'] = int(loc)
-             leg = subplot.legend(prop=prop, **lopts)
-             if leg is None:
-                 from warnings import warn
diff --git a/srcpkgs/sagemath/patches/36403-00pre.patch b/srcpkgs/sagemath/patches/36403-00pre.patch
deleted file mode 100644
index 060404d5430de..0000000000000
--- a/srcpkgs/sagemath/patches/36403-00pre.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-Minor patch so that #36403 applies cleanly over sagemath 10.1
-
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 2053bca80c3..86aca6e00d8 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15123,7 +15302,8 @@ cdef class Matrix(Matrix1):
-             sage: N.conjugate_transpose()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object has no attribute 'conjugate'
-+            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
-+            has no attribute 'conjugate'
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 525ea5aa934..52afed49d64 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -55,7 +55,7 @@ cdef class AttributeErrorMessage:
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-         sage: x = polygen(ZZ, 'x')
--        sage: QQ[x].gen().bla                                                           # optional - sage.libs.flint
-+        sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
diff --git a/srcpkgs/sagemath/patches/36407-python_3.12.patch b/srcpkgs/sagemath/patches/36407-python_3.12.patch
deleted file mode 100644
index c75c275c30764..0000000000000
--- a/srcpkgs/sagemath/patches/36407-python_3.12.patch
+++ /dev/null
@@ -1,1744 +0,0 @@
-diff --git a/build/sage_bootstrap/package.py b/build/sage_bootstrap/package.py
-index 15b342223c4..eb82f96e05f 100644
---- a/build/sage_bootstrap/package.py
-+++ b/build/sage_bootstrap/package.py
-@@ -303,7 +303,7 @@ def _init_checksum(self):
-         # Name of the directory containing the checksums.ini file
-         self.__tarball_package_name = os.path.realpath(checksums_ini).split(os.sep)[-2]
- 
--    VERSION_PATCHLEVEL = re.compile('(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
-+    VERSION_PATCHLEVEL = re.compile(r'(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
- 
-     def _init_version(self):
-         try:
-diff --git a/src/doc/en/thematic_tutorials/coercion_and_categories.rst b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-index bb23331c151..7f5712caea7 100644
---- a/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-+++ b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-@@ -1223,7 +1223,7 @@ However, only "elementary" construction functors have a rank::
-     sage: (Fract*Poly).rank
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'
-+    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'...
- 
- .. end of output
- 
-diff --git a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-index 553a946c4d8..3cd71a9bad4 100644
---- a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-+++ b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-@@ -318,7 +318,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: e.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'...
- 
-         sage: id4 = SymmetricGroup(4).one()
-         sage: type(id4)
-@@ -326,7 +326,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: id4.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'
-+        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'...
- 
- .. note::
- 
-diff --git a/src/sage/algebras/cluster_algebra.py b/src/sage/algebras/cluster_algebra.py
-index b72d2a12976..14669dfed5c 100644
---- a/src/sage/algebras/cluster_algebra.py
-+++ b/src/sage/algebras/cluster_algebra.py
-@@ -167,7 +167,7 @@
-     sage: (t*s).g_vector()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'
-+    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'...
-     sage: A = ClusterAlgebra(['A', 2], principal_coefficients=True)
-     sage: A.explore_to_depth(infinity)
-     sage: s = A.cluster_variable((0, -1)); s
-diff --git a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-index e4a91723558..343ee8a66f9 100644
---- a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-+++ b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-@@ -109,7 +109,7 @@ class WeylLieConformalAlgebra(LieConformalAlgebraWithStructureCoefficients):
-         sage: alpha0.degree()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'
-+        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'...
- 
-     TESTS::
- 
-diff --git a/src/sage/algebras/steenrod/steenrod_algebra.py b/src/sage/algebras/steenrod/steenrod_algebra.py
-index 978a3557a9d..7c4d444f81c 100644
---- a/src/sage/algebras/steenrod/steenrod_algebra.py
-+++ b/src/sage/algebras/steenrod/steenrod_algebra.py
-@@ -1080,7 +1080,7 @@ def homogeneous_component(self, n):
-             sage: a.antipode() # not defined
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'
-+            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'...
-             sage: A(a).antipode() # convert to elt of A, then compute antipode
-             Sq(2,1) + Sq(5)
- 
-diff --git a/src/sage/all__sagemath_repl.py b/src/sage/all__sagemath_repl.py
-index 8d0b43679ca..c31b206bcb8 100644
---- a/src/sage/all__sagemath_repl.py
-+++ b/src/sage/all__sagemath_repl.py
-@@ -79,6 +79,23 @@
-                         message=r"Use setlocale\(\), getencoding\(\) and getlocale\(\) instead",
-                         module='docutils.io')
- 
-+# triggered by dateutil 2.8.2 and sphinx 7.0.1 on Python 3.12
-+# see: https://github.com/dateutil/dateutil/pull/1285
-+# see: https://github.com/sphinx-doc/sphinx/pull/11468
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"datetime.datetime.utcfromtimestamp\(\) is deprecated",
-+                        module='dateutil.tz.tz|sphinx.(builders.gettext|util.i18n)')
-+
-+# triggered on Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"This process.* is multi-threaded, "
-+                                r"use of .*\(\) may lead to deadlocks in the child.")
-+
-+# pickling of itertools is deprecated in Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"Pickle, copy, and deepcopy support will be "
-+                                r"removed from itertools in Python 3.14.")
-+
- 
- from .all__sagemath_objects import *
- from .all__sagemath_environment import *
-diff --git a/src/sage/arith/long.pxd b/src/sage/arith/long.pxd
-index 0031a0ae337..3ea70cef571 100644
---- a/src/sage/arith/long.pxd
-+++ b/src/sage/arith/long.pxd
-@@ -19,6 +19,8 @@ from libc.limits cimport LONG_MIN, LONG_MAX
- from cpython.object cimport Py_SIZE
- from cpython.number cimport PyNumber_Index, PyIndex_Check
- from cpython.longintrepr cimport py_long, PyLong_SHIFT, digit
-+from sage.cpython.pycore_long cimport (
-+    ob_digit, _PyLong_IsNegative, _PyLong_DigitCount)
- 
- from sage.libs.gmp.mpz cimport mpz_fits_slong_p, mpz_get_si
- from sage.rings.integer_fake cimport is_Integer, Integer_AS_MPZ
-@@ -299,8 +301,11 @@ cdef inline bint integer_check_long_py(x, long* value, int* err):
-         return 0
- 
-     # x is a Python "int" (aka PyLongObject or py_long in cython)
--    cdef const digit* D = (<py_long>x).ob_digit
--    cdef Py_ssize_t size = Py_SIZE(x)
-+    cdef const digit* D = ob_digit(x)
-+    cdef Py_ssize_t size = _PyLong_DigitCount(x)
-+
-+    if _PyLong_IsNegative(x):
-+        size = -size
- 
-     # We assume PyLong_SHIFT <= BITS_IN_LONG <= 3 * PyLong_SHIFT.
-     # This is true in all the default configurations:
-diff --git a/src/sage/categories/category.py b/src/sage/categories/category.py
-index 57ef7f4184b..29bce8ee415 100644
---- a/src/sage/categories/category.py
-+++ b/src/sage/categories/category.py
-@@ -2129,7 +2129,7 @@ def _with_axioms(self, axioms):
-             sage: Semigroups().Inverse()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'
-+            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'...
-             sage: Semigroups()._with_axioms(["Inverse"])
-             Category of semigroups
- 
-diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py
-index 5227792e725..4775d4e5bf1 100644
---- a/src/sage/categories/category_with_axiom.py
-+++ b/src/sage/categories/category_with_axiom.py
-@@ -554,7 +554,7 @@ class from the base category class::
-     sage: Magmas.Unital.Associative
-     Traceback (most recent call last):
-     ...
--    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'
-+    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'...
- 
- The purpose of this section is to explain the design of the code
- layout and the rationale for this mismatch.
-@@ -769,7 +769,7 @@ def _(): return LazyImport('sage.categories.rngs', 'Rngs', at_startup=True)
-     sage: Semirings().NoZeroDivisors()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'
-+    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'...
- 
- Concretely, this is to be implemented by defining the new axiom in the
- (``SubcategoryMethods`` nested class of the) appropriate category with
-diff --git a/src/sage/categories/enumerated_sets.py b/src/sage/categories/enumerated_sets.py
-index a8bea53f907..b0ea05d0563 100644
---- a/src/sage/categories/enumerated_sets.py
-+++ b/src/sage/categories/enumerated_sets.py
-@@ -610,7 +610,7 @@ def _list_from_iterator(self):
-                 sage: (QQ^2).list()  # indirect test                                    # needs sage.modules
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'
-+                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'...
- 
-             Here we test that for an object that does not know whether it
-             is finite or not.  Calling ``x.list()`` simply tries to create
-@@ -622,11 +622,11 @@ def _list_from_iterator(self):
-                 sage: Q.is_finite()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'...
-                 sage: Q.list()   # indirect test
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'...
- 
-             Here is another example. We artificially create a version of
-             the ring of integers that does not know whether it is finite
-diff --git a/src/sage/categories/examples/sets_cat.py b/src/sage/categories/examples/sets_cat.py
-index e0853d63f94..fbadb9ca405 100644
---- a/src/sage/categories/examples/sets_cat.py
-+++ b/src/sage/categories/examples/sets_cat.py
-@@ -619,7 +619,7 @@ class PrimeNumbers_Facade(PrimeNumbers_Abstract):
-         sage: pf.next()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'...
- 
-     unlike in the other implementations::
- 
-diff --git a/src/sage/categories/homset.py b/src/sage/categories/homset.py
-index 22ba9d047fc..2a8b8aeedeb 100644
---- a/src/sage/categories/homset.py
-+++ b/src/sage/categories/homset.py
-@@ -632,7 +632,7 @@ def __init__(self, X, Y, category=None, base=None, check=True):
-             sage: H = MyHomset(X, Y, category=1, base = ZZ, check = False)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'...
-             sage: P.<t> = ZZ[]
-             sage: f = P.hom([1/2*t])
-             sage: f.parent().domain()
-diff --git a/src/sage/categories/modules_with_basis.py b/src/sage/categories/modules_with_basis.py
-index e97bf851388..c4933d0657f 100644
---- a/src/sage/categories/modules_with_basis.py
-+++ b/src/sage/categories/modules_with_basis.py
-@@ -2456,7 +2456,7 @@ def apply_multilinear_morphism(self, f, codomain=None):
-                     sage: tensor([a, b]).apply_multilinear_morphism(f)                  # needs sage.modules
-                     Traceback (most recent call last):
-                     ...
--                    AttributeError: 'int' object has no attribute 'parent'
-+                    AttributeError: 'int' object has no attribute 'parent'...
- 
-                 Here we consider an example where the codomain is a
-                 module with basis with a different base ring::
-diff --git a/src/sage/categories/monoids.py b/src/sage/categories/monoids.py
-index 38dd7248c9d..28474bd17b6 100644
---- a/src/sage/categories/monoids.py
-+++ b/src/sage/categories/monoids.py
-@@ -556,7 +556,7 @@ def algebra_generators(self):
-                     Traceback (most recent call last):
-                     ...
-                     AttributeError: 'IntegerModMonoid_with_category' object
--                    has no attribute 'monoid_generators'
-+                    has no attribute 'monoid_generators'...
-                     sage: Z12.semigroup_generators()
-                     Family (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
-                     sage: Z12.algebra(QQ).algebra_generators()                          # needs sage.modules
-diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py
-index 494e8154c80..ec5120e41e6 100644
---- a/src/sage/combinat/finite_state_machine.py
-+++ b/src/sage/combinat/finite_state_machine.py
-@@ -1835,7 +1835,7 @@ def __getstate__(self):
-             sage: T1.transitions
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'FSMState' object has no attribute 'transitions'
-+            AttributeError: 'FSMState' object has no attribute 'transitions'...
-             sage: A1 = loads(dumps(A))
-             sage: all(A.state(j) == A1.state(j) for j in [0, 1])
-             True
-diff --git a/src/sage/combinat/growth.py b/src/sage/combinat/growth.py
-index cf8d18c1764..766eea37917 100644
---- a/src/sage/combinat/growth.py
-+++ b/src/sage/combinat/growth.py
-@@ -371,7 +371,7 @@
-     sage: GrowthDiagram(RulePascal(), [3,1,2])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'RulePascal' object has no attribute 'forward_rule'
-+    AttributeError: 'RulePascal' object has no attribute 'forward_rule'...
- 
- We now re-implement the rule where we provide the dual graded graphs::
- 
-diff --git a/src/sage/combinat/integer_lists/lists.py b/src/sage/combinat/integer_lists/lists.py
-index 5143e5cb5e8..9117a6076f7 100644
---- a/src/sage/combinat/integer_lists/lists.py
-+++ b/src/sage/combinat/integer_lists/lists.py
-@@ -261,7 +261,7 @@ def __getattr__(self, name):
-             sage: L.foo
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'foo'
-+            AttributeError: 'NoneType' object has no attribute 'foo'...
-         """
-         return getattr(self.backend, name)
- 
-diff --git a/src/sage/combinat/posets/posets.py b/src/sage/combinat/posets/posets.py
-index c31597c72e9..c74bfc67cee 100644
---- a/src/sage/combinat/posets/posets.py
-+++ b/src/sage/combinat/posets/posets.py
-@@ -8825,7 +8825,7 @@ def is_induced_subposet(self, other):
-             sage: Poset().is_induced_subposet('junk')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'subposet'
-+            AttributeError: 'str' object has no attribute 'subposet'...
-         """
-         if (not self._is_facade or (isinstance(other, FinitePoset) and
-                                     not other._is_facade)):
-diff --git a/src/sage/cpython/atexit.pyx b/src/sage/cpython/atexit.pyx
-index 961aa348d0a..e5a82735137 100644
---- a/src/sage/cpython/atexit.pyx
-+++ b/src/sage/cpython/atexit.pyx
-@@ -154,6 +154,10 @@ cdef extern from *:
-     #undef _PyGC_FINALIZED
-     #include "internal/pycore_interp.h"
-     #include "internal/pycore_pystate.h"
-+    #if PY_VERSION_HEX >= 0x030c0000
-+    // struct atexit_callback was renamed in 3.12 to atexit_py_callback
-+    #define atexit_callback atexit_py_callback
-+    #endif
-     static atexit_callback ** _atexit_callbacks(PyObject *self) {
-         PyInterpreterState *interp = _PyInterpreterState_GET();
-         struct atexit_state state = interp->atexit;
-diff --git a/src/sage/cpython/debug.pyx b/src/sage/cpython/debug.pyx
-index 986abff2a99..cdaca3a4854 100644
---- a/src/sage/cpython/debug.pyx
-+++ b/src/sage/cpython/debug.pyx
-@@ -78,7 +78,7 @@ def getattr_debug(obj, name, default=_no_default):
- 
-     EXAMPLES::
- 
--        sage: _ = getattr_debug(list, "reverse")
-+        sage: _ = getattr_debug(list, "reverse")  # not tested - broken in python 3.12
-         getattr_debug(obj=<class 'list'>, name='reverse'):
-           type(obj) = <class 'type'>
-           object has __dict__ slot (<class 'dict'>)
-@@ -123,7 +123,7 @@ def getattr_debug(obj, name, default=_no_default):
-         sage: _ = getattr_debug(1, "foo")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'...
-         sage: _ = getattr_debug(1, "foo", "xyz")
-         getattr_debug(obj=1, name='foo'):
-           type(obj) = <class 'sage.rings.integer.Integer'>
-diff --git a/src/sage/cpython/dict_internal.h b/src/sage/cpython/dict_internal.h
-index 42a57bcb468..a5ee35bc198 100644
---- a/src/sage/cpython/dict_internal.h
-+++ b/src/sage/cpython/dict_internal.h
-@@ -169,6 +169,7 @@ dictkeys_set_index(PyDictKeysObject *keys, Py_ssize_t i, Py_ssize_t ix)
- #else   /* Python >= 3.11 */
- 
- #define Py_BUILD_CORE
-+#undef _PyGC_FINALIZED
- #include <internal/pycore_dict.h>
- 
- /************************************************************/
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 52afed49d64..1f49e5230c3 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -53,12 +53,12 @@ cdef class AttributeErrorMessage:
-         sage: 1.bla  #indirect doctest
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'...
-         sage: x = polygen(ZZ, 'x')
-         sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'...
- 
-     ::
- 
-@@ -144,7 +144,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(X, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: x = X()
-         sage: raw_getattr(x, "prop")
-         <property object at ...>
-@@ -173,7 +173,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(Y, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: y = Y()
-         sage: raw_getattr(y, "prop")
-         <property object at ...>
-@@ -278,7 +278,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     The integer ring is a parent, so, lazy attributes work::
- 
-@@ -289,7 +289,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(17, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     In general, descriptors are not yet well supported, because they
-     often do not accept to be cheated with the type of their instance::
-@@ -305,7 +305,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__weakref__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-     This was caught by :trac:`8296` for which we do a couple more tests::
- 
-@@ -314,7 +314,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: 1.__weakref__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-         sage: n = 1
-         sage: ip = get_ipython()                 # not tested: only works in interactive shell
-@@ -329,7 +329,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__call__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'...
- 
-     TESTS:
- 
-@@ -339,14 +339,14 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, type, "__name__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'...
- 
-     Non-strings as "name" are handled gracefully::
- 
-         sage: getattr_from_other_class(1, type, None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute None
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute None...
-     """
-     if not isinstance(cls, type):
-         raise TypeError(f"{cls!r} is not a type")
-diff --git a/src/sage/cpython/pycore_long.h b/src/sage/cpython/pycore_long.h
-new file mode 100644
-index 00000000000..ff1a73d097a
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.h
-@@ -0,0 +1,98 @@
-+#include "Python.h"
-+#include <stdbool.h>
-+
-+#if PY_VERSION_HEX >= 0x030C00A5
-+#define ob_digit(o)  (((PyLongObject*)o)->long_value.ob_digit)
-+#else
-+#define ob_digit(o)  (((PyLongObject*)o)->ob_digit)
-+#endif
-+
-+#if PY_VERSION_HEX >= 0x030C00A7
-+// taken from cpython:Include/internal/pycore_long.h @ 3.12
-+
-+/* Long value tag bits:
-+ * 0-1: Sign bits value = (1-sign), ie. negative=2, positive=0, zero=1.
-+ * 2: Reserved for immortality bit
-+ * 3+ Unsigned digit count
-+ */
-+#define SIGN_MASK 3
-+#define SIGN_ZERO 1
-+#define SIGN_NEGATIVE 2
-+#define NON_SIZE_BITS 3
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_ZERO;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_NEGATIVE;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    assert(PyLong_Check(op));
-+    return op->long_value.lv_tag >> NON_SIZE_BITS;
-+}
-+
-+#define TAG_FROM_SIGN_AND_SIZE(sign, size) ((1 - (sign)) | ((size) << NON_SIZE_BITS))
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+    assert(size >= 0);
-+    assert(-1 <= sign && sign <= 1);
-+    assert(sign != 0 || size == 0);
-+    op->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sign, (size_t)size);
-+}
-+
-+#else
-+// fallback for < 3.12
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) == 0;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) < 0;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) > 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    Py_ssize_t size = Py_SIZE(op);
-+    return size < 0 ? -size : size;
-+}
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION < 9)
-+// The function Py_SET_SIZE is defined starting with python 3.9.
-+    Py_SIZE(o) = size;
-+#else
-+    Py_SET_SIZE(op, sign < 0 ? -size : size);
-+#endif
-+}
-+
-+#endif
-diff --git a/src/sage/cpython/pycore_long.pxd b/src/sage/cpython/pycore_long.pxd
-new file mode 100644
-index 00000000000..41de637ff18
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.pxd
-@@ -0,0 +1,9 @@
-+from cpython.longintrepr cimport py_long, digit
-+
-+cdef extern from "pycore_long.h":
-+    digit* ob_digit(py_long o)
-+    bint _PyLong_IsZero(py_long o)
-+    bint _PyLong_IsNegative(py_long o)
-+    bint _PyLong_IsPositive(py_long o)
-+    Py_ssize_t _PyLong_DigitCount(py_long o)
-+    void _PyLong_SetSignAndDigitCount(py_long o, int sign, Py_ssize_t size)
-diff --git a/src/sage/crypto/classical.py b/src/sage/crypto/classical.py
-index 616dc861652..be899c781e5 100644
---- a/src/sage/crypto/classical.py
-+++ b/src/sage/crypto/classical.py
-@@ -494,7 +494,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: A.rank_by_chi_square("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_chi_square(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -703,7 +703,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: A.rank_by_squared_differences("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_squared_differences(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -2114,7 +2114,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: S.rank_by_chi_square("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_chi_square(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-@@ -2351,7 +2351,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: S.rank_by_squared_differences("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_squared_differences(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/crypto/mq/mpolynomialsystemgenerator.py b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-index 9028dab1d98..4416d9ef7f6 100644
---- a/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-+++ b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-@@ -156,7 +156,7 @@ def sbox(self):
-             sage: msg.sbox()
-             Traceback (most recent call last):
-             ...
--            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'
-+            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'...
-         """
-         return self._sbox
- 
-diff --git a/src/sage/data_structures/bitset.pyx b/src/sage/data_structures/bitset.pyx
-index 446062554c1..d9906b5edd2 100644
---- a/src/sage/data_structures/bitset.pyx
-+++ b/src/sage/data_structures/bitset.pyx
-@@ -967,7 +967,7 @@ cdef class FrozenBitset:
-             sage: None | FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute '_union'
-+            AttributeError: 'NoneType' object has no attribute '_union'...
-         """
-         return self._union(other)
- 
-@@ -1037,7 +1037,7 @@ cdef class FrozenBitset:
-             sage: None & FrozenBitset("101011")
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'intersection'
-+            AttributeError: 'NoneType' object has no attribute 'intersection'...
-         """
-         return self.intersection(other)
- 
-@@ -1106,7 +1106,7 @@ cdef class FrozenBitset:
-             sage: None - FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'difference'
-+            AttributeError: 'NoneType' object has no attribute 'difference'...
-         """
-         return self.difference(other)
- 
-@@ -1179,7 +1179,7 @@ cdef class FrozenBitset:
-             sage: None ^^ FrozenBitset('11111' * 10)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'
-+            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'...
-         """
-         return self.symmetric_difference(other)
- 
-diff --git a/src/sage/doctest/reporting.py b/src/sage/doctest/reporting.py
-index 361fea344c2..a3947c07e01 100644
---- a/src/sage/doctest/reporting.py
-+++ b/src/sage/doctest/reporting.py
-@@ -368,7 +368,7 @@ def report(self, source, timeout, return_code, results, output, pid=None):
-             sage: DTR.report(None, None, None, None, None)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'basename'
-+            AttributeError: 'NoneType' object has no attribute 'basename'...
- 
-         The only-errors mode does not output anything on success::
- 
-diff --git a/src/sage/dynamics/finite_dynamical_system.py b/src/sage/dynamics/finite_dynamical_system.py
-index e5fbf568b7e..4295070615a 100644
---- a/src/sage/dynamics/finite_dynamical_system.py
-+++ b/src/sage/dynamics/finite_dynamical_system.py
-@@ -240,7 +240,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-@@ -252,7 +252,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-diff --git a/src/sage/geometry/cone.py b/src/sage/geometry/cone.py
-index f0a8620011a..53f78a4b7b6 100644
---- a/src/sage/geometry/cone.py
-+++ b/src/sage/geometry/cone.py
-@@ -340,7 +340,7 @@ def Cone(rays, lattice=None, check=True, normalize=True):
-         sage: Cone([(1,0), (0,1)], check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     You can construct different "not" cones: not full-dimensional, not
-     strictly convex, not containing any rays::
-diff --git a/src/sage/geometry/fan.py b/src/sage/geometry/fan.py
-index 258544012fe..3aecc84a55b 100644
---- a/src/sage/geometry/fan.py
-+++ b/src/sage/geometry/fan.py
-@@ -443,7 +443,7 @@ def Fan(cones, rays=None, lattice=None, check=True, normalize=True,
-         sage: P2c = Fan(cones, rays, check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     Yet another way is to use functions :func:`FaceFan` and :func:`NormalFan`
-     to construct fans from :class:`lattice polytopes
-diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-index f0ac1e774a7..f03f0f832ff 100644
---- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-+++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-@@ -351,7 +351,7 @@ cdef class FaceIterator_base(SageObject):
-             sage: FaceIterator_base(2)  # indirect doctest
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'...
-         """
-         cdef int i
-         sig_free(self.structure.atom_rep)
-@@ -1945,7 +1945,8 @@ cdef inline int next_face_loop(iter_t structure) nogil except -1:
-         # The function is not supposed to be called,
-         # just prevent it from crashing.
-         # Actually raising an error here results in a bad branch prediction.
--        return -1
-+        # But return -1 results in a crash with python 3.12
-+        raise StopIteration
- 
-     # Getting ``[faces, n_faces, n_visited_all]`` according to dimension.
-     cdef face_list_t* faces = &structure.new_faces[structure.current_dimension]
-diff --git a/src/sage/geometry/toric_plotter.py b/src/sage/geometry/toric_plotter.py
-index 50b4008eb0f..950e3ba7ff8 100644
---- a/src/sage/geometry/toric_plotter.py
-+++ b/src/sage/geometry/toric_plotter.py
-@@ -706,7 +706,7 @@ def set_rays(self, generators):
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ToricPlotter' object has no attribute 'rays'
-+            AttributeError: 'ToricPlotter' object has no attribute 'rays'...
-             sage: tp.set_rays([(0,1)])
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Graphics object consisting of 2 graphics primitives
-diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
-index d0ec214bb3b..c8098ad578a 100644
---- a/src/sage/groups/matrix_gps/finitely_generated.py
-+++ b/src/sage/groups/matrix_gps/finitely_generated.py
-@@ -268,7 +268,7 @@ def MatrixGroup(*gens, **kwds):
-         sage: SL2C.gens()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'
-+        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'...
-     """
-     if isinstance(gens[-1], dict):   # hack for unpickling
-         kwds.update(gens[-1])
-diff --git a/src/sage/homology/chains.py b/src/sage/homology/chains.py
-index 87c0947c0b0..b9a54940943 100644
---- a/src/sage/homology/chains.py
-+++ b/src/sage/homology/chains.py
-@@ -298,7 +298,7 @@ def is_cycle(self):
-                 sage: chain.is_cocycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -325,7 +325,7 @@ def is_boundary(self):
-                 sage: chain.is_coboundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -539,7 +539,7 @@ def is_cocycle(self):
-                 sage: cochain.is_cycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -566,7 +566,7 @@ def is_coboundary(self):
-                 sage: cochain.is_boundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -604,7 +604,7 @@ def eval(self, other):
-                 sage: z.eval(c) # z is not a cochain
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'...
-                 sage: c.eval(c) # can't evaluate a cochain on a cochain
-                 Traceback (most recent call last):
-                 ...
-diff --git a/src/sage/homology/free_resolution.py b/src/sage/homology/free_resolution.py
-index e3d38de4240..280a479b438 100644
---- a/src/sage/homology/free_resolution.py
-+++ b/src/sage/homology/free_resolution.py
-@@ -275,7 +275,7 @@ def differential(self, i):
-             sage: FreeResolution.differiental(r, 1)
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'FreeResolution' has no attribute 'differiental'
-+            AttributeError: type object 'FreeResolution' has no attribute 'differiental'...
-         """
- 
-     def target(self):
-diff --git a/src/sage/interfaces/magma.py b/src/sage/interfaces/magma.py
-index b7a0ac20d03..529bfbc349b 100644
---- a/src/sage/interfaces/magma.py
-+++ b/src/sage/interfaces/magma.py
-@@ -824,7 +824,7 @@ def _coerce_from_special_method(self, x):
-             sage: magma._coerce_from_special_method('2 + 3')  # optional - magma
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute '_magma_init_'
-+            AttributeError: 'str' object has no attribute '_magma_init_'...
-         """
-         s = x._magma_init_(self)
-         a = self(s)
-diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
-index 58499396d6c..16119d20815 100644
---- a/src/sage/lfunctions/dokchitser.py
-+++ b/src/sage/lfunctions/dokchitser.py
-@@ -418,8 +418,8 @@ def init_coeffs(self, v, cutoff=1,
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
-index bbf289aa21c..e4968866303 100644
---- a/src/sage/lfunctions/pari.py
-+++ b/src/sage/lfunctions/pari.py
-@@ -141,8 +141,8 @@ def init_coeffs(self, v, cutoff=None, w=1):
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
-index 478caf9f9d0..363024ae281 100644
---- a/src/sage/libs/gap/element.pyx
-+++ b/src/sage/libs/gap/element.pyx
-@@ -380,7 +380,7 @@ cdef GapElement make_GapElement(parent, Obj obj):
-         sage: libgap(None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute '_libgap_init_'
-+        AttributeError: 'NoneType' object has no attribute '_libgap_init_'...
-     """
-     cdef GapElement r = GapElement.__new__(GapElement)
-     r._initialize(parent, obj)
-diff --git a/src/sage/libs/gmp/pylong.pxd b/src/sage/libs/gmp/pylong.pxd
-index a73f1da6d6f..84e1bb8cd87 100644
---- a/src/sage/libs/gmp/pylong.pxd
-+++ b/src/sage/libs/gmp/pylong.pxd
-@@ -2,9 +2,10 @@
- Various functions to deal with conversion mpz <-> Python int/long
- """
- 
-+from cpython.longintrepr cimport py_long
- from sage.libs.gmp.types cimport *
- 
- cdef mpz_get_pylong(mpz_srcptr z)
- cdef mpz_get_pyintlong(mpz_srcptr z)
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1
- cdef Py_hash_t mpz_pythonhash(mpz_srcptr z)
-diff --git a/src/sage/libs/gmp/pylong.pyx b/src/sage/libs/gmp/pylong.pyx
-index d5993cca5a5..1a36c29d3fa 100644
---- a/src/sage/libs/gmp/pylong.pyx
-+++ b/src/sage/libs/gmp/pylong.pyx
-@@ -28,6 +28,8 @@ AUTHORS:
- from cpython.object cimport Py_SIZE
- from cpython.long cimport PyLong_FromLong
- from cpython.longintrepr cimport _PyLong_New, py_long, digit, PyLong_SHIFT
-+from sage.cpython.pycore_long cimport (ob_digit, _PyLong_IsNegative,
-+    _PyLong_DigitCount, _PyLong_SetSignAndDigitCount)
- from .mpz cimport *
- 
- cdef extern from *:
-@@ -60,12 +62,9 @@ cdef mpz_get_pylong_large(mpz_srcptr z):
-     """
-     cdef size_t nbits = mpz_sizeinbase(z, 2)
-     cdef size_t pylong_size = (nbits + PyLong_SHIFT - 1) // PyLong_SHIFT
--    L = _PyLong_New(pylong_size)
--    mpz_export(L.ob_digit, NULL,
--            -1, sizeof(digit), 0, PyLong_nails, z)
--    if mpz_sgn(z) < 0:
--        # Set correct size
--        Py_SET_SIZE(L, -pylong_size)
-+    cdef py_long L = _PyLong_New(pylong_size)
-+    mpz_export(ob_digit(L), NULL, -1, sizeof(digit), 0, PyLong_nails, z)
-+    _PyLong_SetSignAndDigitCount(L, mpz_sgn(z), pylong_size)
-     return L
- 
- 
-@@ -88,16 +87,13 @@ cdef mpz_get_pyintlong(mpz_srcptr z):
-     return mpz_get_pylong_large(z)
- 
- 
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1:
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1:
-     """
-     Convert a Python ``long`` `L` to an ``mpz``.
-     """
--    cdef Py_ssize_t pylong_size = Py_SIZE(L)
--    if pylong_size < 0:
--        pylong_size = -pylong_size
--    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails,
--            (<py_long>L).ob_digit)
--    if Py_SIZE(L) < 0:
-+    cdef Py_ssize_t pylong_size = _PyLong_DigitCount(L)
-+    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails, ob_digit(L))
-+    if _PyLong_IsNegative(L):
-         mpz_neg(z, z)
- 
- 
-diff --git a/src/sage/manifolds/calculus_method.py b/src/sage/manifolds/calculus_method.py
-index f5830c0bc45..303dde6cd13 100644
---- a/src/sage/manifolds/calculus_method.py
-+++ b/src/sage/manifolds/calculus_method.py
-@@ -257,7 +257,7 @@ def simplify(self, expression, method=None):
-             sage: cm.simplify(f)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'
-+            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'...
- 
-         In the present case, one should either transform ``f`` to a SymPy
-         object::
-diff --git a/src/sage/manifolds/differentiable/vectorfield_module.py b/src/sage/manifolds/differentiable/vectorfield_module.py
-index d954b5d4839..af4bfb0ceec 100644
---- a/src/sage/manifolds/differentiable/vectorfield_module.py
-+++ b/src/sage/manifolds/differentiable/vectorfield_module.py
-@@ -885,7 +885,7 @@ def tensor(self, *args, **kwds):
-             sage: XM.tensor(XM).tensor(XM.dual().tensor(XM.dual()))
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'
-+            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'...
- 
-         .. SEEALSO::
- 
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 86aca6e00d8..a5f6716e731 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15303,7 +15303,7 @@ cdef class Matrix(Matrix1):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
--            has no attribute 'conjugate'
-+            has no attribute 'conjugate'...
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/matrix/matrix_cyclo_dense.pyx b/src/sage/matrix/matrix_cyclo_dense.pyx
-index f54f3423ded..a49bb6240e6 100644
---- a/src/sage/matrix/matrix_cyclo_dense.pyx
-+++ b/src/sage/matrix/matrix_cyclo_dense.pyx
-@@ -847,7 +847,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense):
-             sage: A.set_mutable()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'
-+            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'...
-             sage: B = A.__copy__()
-             sage: B[0,0] = 20
-             sage: B[0,0]
-diff --git a/src/sage/matrix/matrix_gfpn_dense.pyx b/src/sage/matrix/matrix_gfpn_dense.pyx
-index 4cccf473de1..8e8e4d7336b 100644
---- a/src/sage/matrix/matrix_gfpn_dense.pyx
-+++ b/src/sage/matrix/matrix_gfpn_dense.pyx
-@@ -159,7 +159,7 @@ cdef class FieldConverter_class:
-             sage: C.field_to_fel('foo')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'to_integer'
-+            AttributeError: 'str' object has no attribute 'to_integer'...
-         """
-         return FfFromInt(x.to_integer())
- 
-diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py
-index 6aab58352be..b5e6f52349b 100644
---- a/src/sage/matrix/matrix_space.py
-+++ b/src/sage/matrix/matrix_space.py
-@@ -1619,7 +1619,7 @@ def __getitem__(self, x):
-             sage: MS[2]
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'
-+            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'...
-         """
-         if isinstance(x, (integer.Integer, int)):
-             return self.list()[x]
-diff --git a/src/sage/matroids/lean_matrix.pyx b/src/sage/matroids/lean_matrix.pyx
-index 54c68e637c0..a137cbf70e5 100644
---- a/src/sage/matroids/lean_matrix.pyx
-+++ b/src/sage/matroids/lean_matrix.pyx
-@@ -1,5 +1,4 @@
- # sage.doctest: optional - sage.rings.finite_rings
--# cython: profile=True
- """
- Lean matrices
- 
-diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx
-index 36f563aa433..318c82f2b64 100644
---- a/src/sage/matroids/linear_matroid.pyx
-+++ b/src/sage/matroids/linear_matroid.pyx
-@@ -1134,7 +1134,7 @@ cdef class LinearMatroid(BasisExchangeMatroid):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.matroids.basis_matroid.BasisMatroid' object
--            has no attribute 'base_ring'
-+            has no attribute 'base_ring'...
-             sage: from sage.matroids.advanced import *
-             sage: M4 = BinaryMatroid(Matrix(M1))
-             sage: M5 = LinearMatroid(reduced_matrix=Matrix(GF(2), [[-1, 0, 1],
-diff --git a/src/sage/misc/dev_tools.py b/src/sage/misc/dev_tools.py
-index e7bf176592c..3ece7db2894 100644
---- a/src/sage/misc/dev_tools.py
-+++ b/src/sage/misc/dev_tools.py
-@@ -171,6 +171,7 @@ def load_submodules(module=None, exclude_pattern=None):
-         load sage.geometry.polyhedron.ppl_lattice_polygon... succeeded
-     """
-     from .package_dir import walk_packages
-+    import importlib.util
- 
-     if module is None:
-         import sage
-@@ -194,8 +195,12 @@ def load_submodules(module=None, exclude_pattern=None):
-         try:
-             sys.stdout.write("load %s..." % module_name)
-             sys.stdout.flush()
--            loader = importer.find_module(module_name)
--            loader.load_module(module_name)
-+            # see
-+            # https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
-+            spec = importer.find_spec(module_name)
-+            module = importlib.util.module_from_spec(spec)
-+            sys.modules[module_name] = module
-+            spec.loader.exec_module(module)
-             sys.stdout.write(" succeeded\n")
-         except (ValueError, AttributeError, TypeError, ImportError):
-             # we might get error because of cython code that has been
-diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py
-index c922b8f6f12..03697f08b7c 100644
---- a/src/sage/misc/functional.py
-+++ b/src/sage/misc/functional.py
-@@ -86,7 +86,7 @@ def base_field(x):
-         sage: R.base_field()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'
-+        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'...
-     """
-     try:
-         return x.base_field()
-diff --git a/src/sage/misc/instancedoc.pyx b/src/sage/misc/instancedoc.pyx
-index d8e1e4ac536..44ee70f64ba 100644
---- a/src/sage/misc/instancedoc.pyx
-+++ b/src/sage/misc/instancedoc.pyx
-@@ -256,7 +256,7 @@ cdef class InstanceDocDescriptor:
-             sage: descr.__delete__(obj)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'X' object has no attribute '__doc__'
-+            AttributeError: 'X' object has no attribute '__doc__'...
- 
-             sage: descr.__delete__([])
-             Traceback (most recent call last):
-diff --git a/src/sage/misc/lazy_attribute.pyx b/src/sage/misc/lazy_attribute.pyx
-index bdbec3b3ba1..1f07870b8ec 100644
---- a/src/sage/misc/lazy_attribute.pyx
-+++ b/src/sage/misc/lazy_attribute.pyx
-@@ -441,37 +441,37 @@ class lazy_attribute(_lazy_attribute):
-             sage: B().unimplemented_A # todo: not implemented
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'super' object has no attribute 'unimplemented_A'
-+            AttributeError: 'super' object has no attribute 'unimplemented_A'...
- 
-     We now make some systematic checks::
- 
-         sage: B().unimplemented_A
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: B().unimplemented_B
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: B().unimplemented_AB
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: B().unimplemented_B_implemented_A
-         1
- 
-         sage: C().unimplemented_A()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: C().unimplemented_B()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: C().unimplemented_AB()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: C().unimplemented_B_implemented_A # todo: not implemented
-         1
-     """
-diff --git a/src/sage/misc/object_multiplexer.py b/src/sage/misc/object_multiplexer.py
-index d4e811ef16e..00fd89d6652 100644
---- a/src/sage/misc/object_multiplexer.py
-+++ b/src/sage/misc/object_multiplexer.py
-@@ -85,7 +85,7 @@ def __getattr__(self, name):
-             sage: m.__bork__
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Multiplex' has no attribute '__bork__'
-+            AttributeError: 'Multiplex' has no attribute '__bork__'...
-         """
-         if name.startswith("__"):
-             raise AttributeError("'Multiplex' has no attribute '%s'" % name)
-diff --git a/src/sage/misc/sage_input.py b/src/sage/misc/sage_input.py
-index 66e78ecccbc..00e8d96ee9e 100644
---- a/src/sage/misc/sage_input.py
-+++ b/src/sage/misc/sage_input.py
-@@ -3461,7 +3461,7 @@ def verify_same(a, b):
-         sage: verify_same(1, 1r)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_same(1r, 1)
-         Traceback (most recent call last):
-         ...
-@@ -3525,7 +3525,7 @@ def verify_si_answer(x, answer, preparse):
-         sage: verify_si_answer(1, '1', False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_si_answer(1, 'ZZ(1)', None)
-     """
-     from sage.misc.sage_eval import sage_eval
-diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py
-index f0545be7d81..811afc48755 100644
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -602,7 +602,7 @@ def visit_Num(self, node):
-             On Python 3 negative numbers are parsed first, for some reason, as
-             a UnaryOp node.
-         """
--        return node.n
-+        return node.value
- 
-     def visit_Str(self, node):
-         r"""
-@@ -624,7 +624,7 @@ def visit_Str(self, node):
-             sage: [vis(s) for s in ['"abstract"', "'syntax'", r'''r"tr\ee"''']]
-             ['abstract', 'syntax', 'tr\\ee']
-         """
--        return node.s
-+        return node.value
- 
-     def visit_List(self, node):
-         """
-diff --git a/src/sage/modules/fp_graded/steenrod/module.py b/src/sage/modules/fp_graded/steenrod/module.py
-index 18460b0e9a1..4acfa6b4002 100755
---- a/src/sage/modules/fp_graded/steenrod/module.py
-+++ b/src/sage/modules/fp_graded/steenrod/module.py
-@@ -70,7 +70,7 @@
-     sage: SteenrodFPModule(ZZ, [0])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'
-+    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'...
- 
- AUTHORS:
- 
-diff --git a/src/sage/monoids/trace_monoid.py b/src/sage/monoids/trace_monoid.py
-index 00baa4d14f8..f8176a1e1f2 100644
---- a/src/sage/monoids/trace_monoid.py
-+++ b/src/sage/monoids/trace_monoid.py
-@@ -40,7 +40,6 @@
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from collections import OrderedDict
- from itertools import repeat, chain, product
- 
- from sage.misc.cachefunc import cached_method
-@@ -633,14 +632,14 @@ def _compute_dependence_stack(self, x):
-             sage: x = b*a*d*a*c*b
-             sage: M._compute_dependence_stack(x)
-             ({a, b, c, d},
--             OrderedDict([(a, [False, False, True, True, False]),
--                          (b, [True, False, False, False, True]),
--                          (c, [True, False, False, False]),
--                          (d, [False, False, True, False])]))
-+             {a: [False, False, True, True, False],
-+              b: [True, False, False, False, True],
-+              c: [True, False, False, False],
-+              d: [False, False, True, False]})
-         """
-         independence = self._independence
-         generators_set = set(e for e, _ in x)
--        stacks = OrderedDict(sorted((g, []) for g in generators_set))
-+        stacks = dict(sorted((g, []) for g in generators_set))
-         for generator, times in reversed(list(x)):
-             stacks[generator].extend(repeat(True, times))
-             for other_gen in generators_set:
-diff --git a/src/sage/parallel/map_reduce.py b/src/sage/parallel/map_reduce.py
-index 11e0673ee91..5441943731d 100644
---- a/src/sage/parallel/map_reduce.py
-+++ b/src/sage/parallel/map_reduce.py
-@@ -1234,7 +1234,7 @@ def finish(self):
-             sage: S.print_communication_statistics()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'RESetMPExample' object has no attribute '_stats'
-+            AttributeError: 'RESetMPExample' object has no attribute '_stats'...
- 
-             sage: S.finish()
- 
-diff --git a/src/sage/plot/colors.py b/src/sage/plot/colors.py
-index 8c0db2b3c34..3281199400b 100644
---- a/src/sage/plot/colors.py
-+++ b/src/sage/plot/colors.py
-@@ -1099,7 +1099,7 @@ def __getattr__(self, name):
-             sage: cols.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ColorsDict' has no attribute or colormap punk
-+            AttributeError: 'ColorsDict' has no attribute or colormap punk...
-         """
-         try:
-             return self[name]
-@@ -1599,7 +1599,7 @@ def __getattr__(self, name):
-             sage: maps.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Colormaps' has no attribute or colormap punk
-+            AttributeError: 'Colormaps' has no attribute or colormap punk...
-             sage: maps['punk']
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/rings/asymptotic/asymptotic_ring.py b/src/sage/rings/asymptotic/asymptotic_ring.py
-index b07319382d3..994490e6616 100644
---- a/src/sage/rings/asymptotic/asymptotic_ring.py
-+++ b/src/sage/rings/asymptotic/asymptotic_ring.py
-@@ -1091,7 +1091,7 @@ def monomial_coefficient(self, monomial):
-             sage: O(n).monomial_coefficient(n)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'
-+            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'...
- 
-         The ``monomial`` must be exact::
- 
-diff --git a/src/sage/rings/asymptotic/growth_group.py b/src/sage/rings/asymptotic/growth_group.py
-index 27c14592bca..5be12537d62 100644
---- a/src/sage/rings/asymptotic/growth_group.py
-+++ b/src/sage/rings/asymptotic/growth_group.py
-@@ -1572,7 +1572,7 @@ def variable_names(self):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'GenericGrowthGroup_with_category.element_class' object
--            has no attribute 'is_one'
-+            has no attribute 'is_one'...
-         """
-         if self.is_one():
-             return tuple()
-diff --git a/src/sage/rings/ideal.py b/src/sage/rings/ideal.py
-index d36d9406f32..01c9fa3bf2d 100644
---- a/src/sage/rings/ideal.py
-+++ b/src/sage/rings/ideal.py
-@@ -1553,7 +1553,7 @@ def gcd(self, other):
-             sage: J.gcd(I)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Ideal_generic' object has no attribute 'gcd'
-+            AttributeError: 'Ideal_generic' object has no attribute 'gcd'...
- 
-         Note::
- 
-diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
-index 7fe89197011..8832d27e8ea 100644
---- a/src/sage/rings/number_field/number_field.py
-+++ b/src/sage/rings/number_field/number_field.py
-@@ -3823,7 +3823,7 @@ def primes_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
-         """
-         if degree is not None:
-             degree = ZZ(degree)
-@@ -3917,7 +3917,7 @@ def prime_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
- 
-         """
-         ids = self.primes_above(x, degree)
-@@ -5926,7 +5926,7 @@ def factor(self, n):
-             sage: L.factor(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'...
- 
-         AUTHORS:
- 
-@@ -12698,7 +12698,7 @@ def is_real_place(v):
-         sage: is_real_place(v_fin)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'
-+        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'...
- 
-     """
-     RR = sage.rings.real_mpfr.RealField(53)
-diff --git a/src/sage/rings/padics/generic_nodes.py b/src/sage/rings/padics/generic_nodes.py
-index 7047020edec..b6b514d4005 100644
---- a/src/sage/rings/padics/generic_nodes.py
-+++ b/src/sage/rings/padics/generic_nodes.py
-@@ -740,7 +740,7 @@ def _get_element_class(self, name=None):
-             sage: R._get_element_class("foobar")
-             Traceback (most recent call last):
-             ...
--            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'
-+            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'...
-         """
-         if name is None:
-             return self.Element
-diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx
-index c5a1129aecf..a5b7f937cfe 100644
---- a/src/sage/rings/polynomial/polynomial_element.pyx
-+++ b/src/sage/rings/polynomial/polynomial_element.pyx
-@@ -10793,7 +10793,7 @@ cdef class Polynomial(CommutativePolynomial):
-             sage: (y**2 + x).nth_root(2)
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... has no attribute 'nth_root'
-+            AttributeError: ... has no attribute 'nth_root'...
- 
-         TESTS::
- 
-@@ -11831,7 +11831,7 @@ cdef class Polynomial_generic_dense(Polynomial):
-             sage: int(1) // x  # check that this doesn't segfault
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'int' has no attribute 'base_ring'
-+            AttributeError: type object 'int' has no attribute 'base_ring'...
-         """
-         if have_same_parent(self, right):
-             return (<Polynomial_generic_dense>self)._floordiv_(<Polynomial_generic_dense>right)
-diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-index e372be888ee..aca4f08420f 100644
---- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
-+++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-@@ -2362,7 +2362,7 @@ def field_extension(self, names):
-             sage: F, g, h = S.field_extension('b')                                      # needs sage.rings.finite_rings
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'
-+            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'...
- 
-         Over a finite field, the corresponding field extension is not a
-         number field::
-diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx
-index 5273891a5b0..a6e999b8805 100644
---- a/src/sage/rings/ring.pyx
-+++ b/src/sage/rings/ring.pyx
-@@ -1734,7 +1734,7 @@ cdef class IntegralDomain(CommutativeRing):
-             sage: Z5.is_integrally_closed()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'
-+            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'...
-         """
-         raise NotImplementedError
- 
-diff --git a/src/sage/sat/solvers/satsolver.pyx b/src/sage/sat/solvers/satsolver.pyx
-index c2f41b18f55..1c4ac400cb6 100644
---- a/src/sage/sat/solvers/satsolver.pyx
-+++ b/src/sage/sat/solvers/satsolver.pyx
-@@ -375,10 +375,10 @@ def SAT(solver=None, *args, **kwds):
-         DIMACS Solver: 'kissat -q {input}'
-     """
-     if solver is None:
--        import pkgutil
--        if pkgutil.find_loader('pycryptosat') is not None:
-+        from importlib.util import find_spec
-+        if find_spec('pycryptosat') is not None:
-             solver = "cryptominisat"
--        elif pkgutil.find_loader('pycosat') is not None:
-+        elif find_spec('pycosat') is not None:
-             solver = "picosat"
-         else:
-             solver = "LP"
-diff --git a/src/sage/schemes/toric/morphism.py b/src/sage/schemes/toric/morphism.py
-index 1c8944b6dfc..5d64d632f97 100644
---- a/src/sage/schemes/toric/morphism.py
-+++ b/src/sage/schemes/toric/morphism.py
-@@ -246,7 +246,7 @@
-     Traceback (most recent call last):
-     ...
-     AttributeError: 'SchemeMorphism_fan_toric_variety' object
--    has no attribute 'fiber_generic'
-+    has no attribute 'fiber_generic'...
- 
- Let's use factorization mentioned above::
- 
-diff --git a/src/sage/sets/disjoint_union_enumerated_sets.py b/src/sage/sets/disjoint_union_enumerated_sets.py
-index 3dea567a779..5c5e08612f2 100644
---- a/src/sage/sets/disjoint_union_enumerated_sets.py
-+++ b/src/sage/sets/disjoint_union_enumerated_sets.py
-@@ -597,7 +597,7 @@ def Element(self):
-             sage: U.Element
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'
-+            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'...
-         """
-         if not self._facade:
-             return ElementWrapper
-diff --git a/src/sage/sets/set.py b/src/sage/sets/set.py
-index a1789c61300..112d3d8dc3b 100644
---- a/src/sage/sets/set.py
-+++ b/src/sage/sets/set.py
-@@ -163,7 +163,7 @@ def Set(X=None, category=None):
-         sage: sorted(B.list(), key=repr)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'Set_object_with_category' object has no attribute 'list'
-+        AttributeError: 'Set_object_with_category' object has no attribute 'list'...
-         sage: type(B)
-         <class 'sage.sets.set.Set_object_with_category'>
- 
-diff --git a/src/sage/structure/category_object.pyx b/src/sage/structure/category_object.pyx
-index b6a7eaecb5b..c06933494dc 100644
---- a/src/sage/structure/category_object.pyx
-+++ b/src/sage/structure/category_object.pyx
-@@ -836,7 +836,7 @@ cdef class CategoryObject(SageObject):
-             sage: Sets().example().sadfasdf
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'
-+            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'...
-         """
-         return self.getattr_from_category(name)
- 
-diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx
-index caae7e40ffc..543506e9a74 100644
---- a/src/sage/structure/element.pyx
-+++ b/src/sage/structure/element.pyx
-@@ -219,7 +219,7 @@ the parents::
-     sage: x._add_(x)
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-     sage: x + x
-     Traceback (most recent call last):
-     ...
-@@ -478,13 +478,13 @@ cdef class Element(SageObject):
-             sage: 1.blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'...
-             sage: Semigroups().example().an_element().is_idempotent
-             <bound method LeftZeroSemigroup.Element.is_idempotent of 42>
-             sage: Semigroups().example().an_element().blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'
-+            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'...
-         """
-         return self.getattr_from_category(name)
- 
-@@ -1269,7 +1269,7 @@ cdef class Element(SageObject):
-             sage: e._add_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-         """
-         try:
-             python_op = (<object>self)._add_
-@@ -1381,7 +1381,7 @@ cdef class Element(SageObject):
-             sage: e._sub_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'...
-         """
-         try:
-             python_op = (<object>self)._sub_
-@@ -1435,7 +1435,7 @@ cdef class Element(SageObject):
-             sage: e._neg_()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'...
-         """
-         try:
-             python_op = (<object>self)._neg_
-@@ -1549,7 +1549,7 @@ cdef class Element(SageObject):
-             sage: e._mul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'...
-         """
-         try:
-             python_op = (<object>self)._mul_
-@@ -1662,7 +1662,7 @@ cdef class Element(SageObject):
-             sage: e._matmul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'...
-         """
-         try:
-             python_op = (<object>self)._matmul_
-@@ -1765,7 +1765,7 @@ cdef class Element(SageObject):
-             sage: e._div_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'...
-         """
-         try:
-             python_op = (<object>self)._div_
-@@ -1865,7 +1865,7 @@ cdef class Element(SageObject):
-             sage: e._floordiv_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'...
-         """
-         try:
-             python_op = (<object>self)._floordiv_
-@@ -1965,7 +1965,7 @@ cdef class Element(SageObject):
-             sage: e._mod_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'...
-         """
-         try:
-             python_op = (<object>self)._mod_
-@@ -2092,7 +2092,7 @@ cdef class Element(SageObject):
-             sage: e._pow_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'...
-         """
-         try:
-             python_op = (<object>self)._pow_
-@@ -2122,7 +2122,7 @@ cdef class Element(SageObject):
-             sage: e._pow_int(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'...
-         """
-         try:
-             python_op = (<object>self)._pow_int
-@@ -2856,7 +2856,7 @@ cdef class RingElement(ModuleElement):
-             sage: m.is_nilpotent()                                                      # needs sage.modules
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... object has no attribute 'is_nilpotent'
-+            AttributeError: '...' object has no attribute 'is_nilpotent'...
-         """
-         if self.is_unit():
-             return False
-@@ -4671,7 +4671,7 @@ def coerce_binop(method):
-         sage: x.test_add(CC(2))
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'
-+        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'...
- 
-     TESTS:
- 
-diff --git a/src/sage/structure/sequence.py b/src/sage/structure/sequence.py
-index 0c700c1fb81..c3972532ac3 100644
---- a/src/sage/structure/sequence.py
-+++ b/src/sage/structure/sequence.py
-@@ -854,7 +854,7 @@ def __getattr__(self, name):
-             sage: S.universe()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'...
-             sage: S._Sequence__universe = 'foobar'
-             sage: S.universe()
-             'foobar'
-@@ -867,7 +867,7 @@ def __getattr__(self, name):
-             sage: hash(S)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'...
-             sage: S._Sequence__hash = int(34)
-             sage: hash(S)
-             34
-diff --git a/src/sage/symbolic/assumptions.py b/src/sage/symbolic/assumptions.py
-index 7dcb15f0d85..15f6fa07ce6 100644
---- a/src/sage/symbolic/assumptions.py
-+++ b/src/sage/symbolic/assumptions.py
-@@ -636,7 +636,7 @@ def assume(*args):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no
--        attribute 'assume'
-+        attribute 'assume'...
- 
-     Ensure that we can combine the two types of assumptions, as documented::
- 
-diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx
-index 0f251ac4e5c..66f624141b3 100644
---- a/src/sage/symbolic/expression.pyx
-+++ b/src/sage/symbolic/expression.pyx
-@@ -13712,7 +13712,7 @@ cdef get_dynamic_class_for_function(unsigned serial):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.symbolic.expression.Expression' object has no
--        attribute 'argp1'
-+        attribute 'argp1'...
-         sage: t = (e + 1).op[0]; t
-         tfunc(x)
-         sage: t
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index c4152e092e3..4bcf45e8793 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -67,6 +67,7 @@
- #include "archive.h"
- #include "tostring.h"
- #include "utils.h"
-+#include "../../cpython/pycore_long.h"
- 
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wdeprecated-register"
-@@ -706,18 +707,12 @@ static long _mpq_pythonhash(mpq_t the_rat)
- // Initialize an mpz_t from a Python long integer
- static void _mpz_set_pylong(mpz_t z, PyLongObject* l)
- {
--    Py_ssize_t pylong_size = Py_SIZE(l);
--    int sign = 1;
--
--    if (pylong_size < 0) {
--        pylong_size = -pylong_size;
--        sign = -1;
--    }
-+    Py_ssize_t pylong_size = _PyLong_DigitCount(l);
- 
-     mpz_import(z, pylong_size, -1, sizeof(digit), 0,
--               8*sizeof(digit) - PyLong_SHIFT, l->ob_digit);
-+               8*sizeof(digit) - PyLong_SHIFT, ob_digit(l));
- 
--    if (sign < 0)
-+    if (_PyLong_IsNegative(l))
-         mpz_neg(z, z);
- }
- 
-diff --git a/src/sage/symbolic/pynac_impl.pxi b/src/sage/symbolic/pynac_impl.pxi
-index 68c31dcfde7..7fd7c3b314b 100644
---- a/src/sage/symbolic/pynac_impl.pxi
-+++ b/src/sage/symbolic/pynac_impl.pxi
-@@ -619,7 +619,7 @@ def tolerant_is_symbol(a):
-         sage: None.is_symbol()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute 'is_symbol'
-+        AttributeError: 'NoneType' object has no attribute 'is_symbol'...
-     """
-     try:
-         return a.is_symbol()
diff --git a/srcpkgs/sagemath/patches/36506-notebook_7.patch b/srcpkgs/sagemath/patches/36506-notebook_7.patch
new file mode 100644
index 0000000000000..a7d93d52c1b4a
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36506-notebook_7.patch
@@ -0,0 +1,18 @@
+diff --git a/src/bin/sage-notebook b/src/bin/sage-notebook
+index 2e8b12e1a1c..801b0a6a6a3 100755
+--- a/src/bin/sage-notebook
++++ b/src/bin/sage-notebook
+@@ -29,7 +29,12 @@ class NotebookJupyter():
+     def __init__(self, argv):
+         self.print_banner()
+         try:
+-            from notebook.notebookapp import main
++            try:
++                # notebook 6
++                from notebook.notebookapp import main
++            except ImportError:
++                # notebook 7
++                from notebook.app import main
+         except ImportError:
+             import traceback
+             traceback.print_exc()
diff --git a/srcpkgs/sagemath/patches/36544-networkx_3.2.patch b/srcpkgs/sagemath/patches/36544-networkx_3.2.patch
new file mode 100644
index 0000000000000..efcc935ac5476
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36544-networkx_3.2.patch
@@ -0,0 +1,41 @@
+diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py
+index eedbc36bef3..3fdc241a1c4 100644
+--- a/src/sage/graphs/generic_graph.py
++++ b/src/sage/graphs/generic_graph.py
+@@ -5102,13 +5102,13 @@ def cycle_basis(self, output='vertex'):
+         A cycle basis in Petersen's Graph ::
+ 
+             sage: g = graphs.PetersenGraph()
+-            sage: g.cycle_basis()                                                       # needs networkx
++            sage: g.cycle_basis()                                                       # needs networkx, random (changes in networkx 3.2)
+             [[1, 6, 8, 5, 0], [4, 9, 6, 8, 5, 0], [7, 9, 6, 8, 5],
+              [4, 3, 8, 5, 0], [1, 2, 3, 8, 5, 0], [7, 2, 3, 8, 5]]
+ 
+         One can also get the result as a list of lists of edges::
+ 
+-            sage: g.cycle_basis(output='edge')                                          # needs networkx
++            sage: g.cycle_basis(output='edge')                                          # needs networkx, random (changes in networkx 3.2)
+             [[(1, 6, None), (6, 8, None), (8, 5, None), (5, 0, None),
+              (0, 1, None)], [(4, 9, None), (9, 6, None), (6, 8, None),
+              (8, 5, None), (5, 0, None), (0, 4, None)], [(7, 9, None),
+@@ -5273,9 +5273,9 @@ def minimum_cycle_basis(self, algorithm=None, weight_function=None, by_weight=Fa
+             [[1, 2, 3], [1, 2, 3, 4], [5, 6, 7]]
+             sage: sorted(g.minimum_cycle_basis(by_weight=False))
+             [[1, 2, 3], [1, 3, 4], [5, 6, 7]]
+-            sage: sorted(g.minimum_cycle_basis(by_weight=True, algorithm='NetworkX'))   # needs networkx
++            sage: sorted(g.minimum_cycle_basis(by_weight=True, algorithm='NetworkX'))   # needs networkx, random (changes in networkx 3.2)
+             [[1, 2, 3], [1, 2, 3, 4], [5, 6, 7]]
+-            sage: g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX')          # needs networkx
++            sage: g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX')          # needs networkx, random (changes in networkx 3.2)
+             [[1, 2, 3], [1, 3, 4], [5, 6, 7]]
+ 
+         ::
+@@ -5283,7 +5283,7 @@ def minimum_cycle_basis(self, algorithm=None, weight_function=None, by_weight=Fa
+             sage: g = Graph([(1, 2), (2, 3), (3, 4), (4, 5), (5, 1), (5, 3)])
+             sage: sorted(g.minimum_cycle_basis(by_weight=False))
+             [[1, 2, 3, 5], [3, 4, 5]]
+-            sage: sorted(g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX'))  # needs networkx
++            sage: sorted(g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX'))  # needs networkx, random (changes in networkx 3.2)
+             [[1, 2, 3, 5], [3, 4, 5]]
+ 
+         TESTS::
diff --git a/srcpkgs/sagemath/patches/get_patches b/srcpkgs/sagemath/patches/get_patches
index 95a6963432948..94992f4978f8c 100755
--- a/srcpkgs/sagemath/patches/get_patches
+++ b/srcpkgs/sagemath/patches/get_patches
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-version=10.1
+version=10.2.beta8
 
 URL_BASE_PR="https://github.com/sagemath/sage/pull/"
 URL_BASE_COMPARE="https://github.com/sagemath/sage/compare/${version}..."
@@ -20,24 +20,9 @@ get_pr() {
 # run from patches dir
 cd $(dirname "$0")
 
-# merged in 10.2.beta0
-#get_pr  36018   "singular 4.3.2p4" # included in #35934
-get_pr  36046   "fix memory leak"
-
-# merged in 10.2.beta1
-get_pr  35934   "singular 4.3.2p7"
-
-# merged in 10.2.beta2
-get_pr  36006   "gmp 6.3.0"
-
-# merged in 10.2.beta3
-get_pr  36235   "ecl 23.9.9"
-
-# merged in 10.2.beta4
-get_pr  36279   "matplotlib 3.8.0"
-
 # positive review
-#get_pr  36403   "python 3.12" # included in #36407
+get_pr  36506   "notebook 7"
 
 # needs review
-get_pr  36407   "python 3.12"
+get_pr  35848   "flintlib 3.0"
+get_pr  36544   "networkx 3.2"
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index a80d8b7187ece..eb0ad26438538 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,14 +1,14 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=10.1
-revision=4
+version=10.2.beta8
+revision=1
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
 _bindir=/usr/lib/sagemath/$version/bin
 make_install_args="--install-scripts=$_bindir"
-hostmakedepends="m4 pkg-config python3-Cython0.29 python3-Jinja2
+hostmakedepends="m4 pkg-config python3-Cython python3-Jinja2
  python3-pkgconfig python3-setuptools"
-makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
+makedepends="boost-devel brial-devel cliquer-devel ecl eclib-devel
  ecm-devel fflas-ffpack flintlib-devel gap-devel gd-devel giac-devel glpk-devel
  gsl-devel iml-devel lcalc-devel libbraiding-devel libhomfly-devel libmpc-devel
  libpng-devel linbox-devel m4ri-devel m4rie-devel mpfi-devel
@@ -18,7 +18,7 @@ makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
 depends="eclib-devel fflas-ffpack flintlib-devel gcc-fortran gd-devel
  gfan giac gsl-devel gzip libpng-devel linbox-devel m4ri-devel maxima-ecl
  mpfr-devel nauty ntl-devel palp pari-devel pari-elldata-small pari-galdata
- pari-galpol-small pari-seadata-small pkg-config python3-Cython0.29 python3-cypari2
+ pari-galpol-small pari-seadata-small pkg-config python3-Cython python3-cypari2
  python3-cysignals python3-devel python3-fpylll python3-ipython python3-lrcalc
  python3-ipython_ipykernel python3-jupyter_ipywidgets python3-matplotlib
  python3-memory_allocator python3-networkx python3-pip python3-pkgconfig
@@ -33,7 +33,7 @@ license="GPL-2.0-or-later"
 homepage="https://www.sagemath.org/"
 changelog="https://github.com/sagemath/sage/releases"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=a658612b1b2376ddaf207cc8ed0ef458d4c2880c16e19139bedbe8baa42ad62f
+checksum=3bb0d92f1deeadbe5108afb6e41d1c189c84898b063110507ec9f9c9a52d9ddb
 nocross="due to ntl (flintlib), fflas-ffpack, givaro, linbox, cysignals, sympow, maxima"
 
 post_patch() {

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

* Re: [PR PATCH] [Updated] [WIP] flintlib: update to 3.0.0.
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (2 preceding siblings ...)
  2023-10-30 19:23 ` [PR PATCH] [Updated] " tornaria
@ 2023-10-31  1:28 ` tornaria
  2023-10-31  1:43 ` [PR PATCH] [Updated] [WIP] flintlib: update to 3.0.0 / track sagemath-10.2 prereleases tornaria
                   ` (24 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: tornaria @ 2023-10-31  1:28 UTC (permalink / raw)
  To: ml

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

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

https://github.com/tornaria/void-packages flintlib
https://github.com/void-linux/void-packages/pull/46832

[WIP] flintlib: update to 3.0.0.
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **briefly**

This is a major update. A couple of packages need rebuilding (eclib, singular).

For sagemath, we need a patch (in progress: https://github.com/sagemath/sage/pull/35848).

Since backporting patches is a pain and we are not in a hurry, I'm instead targeting 10.2.beta8. Note this already moves sagemath to cython 3.

The goal is to merge flintlib 3.0 together with sagemath 10.2 when the latter is released.

<!--
#### 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/46832.patch is attached

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

From b87ce21651f4d14a27d322868edeb36dd8b4e75c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 11 Sep 2023 20:11:20 -0300
Subject: [PATCH 1/7] flintlib: update to 3.0.0.

---
 common/shlibs                                 |  3 +-
 srcpkgs/arb                                   |  1 +
 srcpkgs/arb-devel                             |  2 +-
 srcpkgs/arb/template                          | 24 ------------
 .../patches/1545-fix_openblas_detection.patch | 32 ++++++++++++++++
 ...6723b1d74e66605c111483756322ebb1bc8d.patch | 37 +++++++++++++++++++
 .../patches/fix-test-t-sdiv_qrnnd.patch       | 23 ------------
 srcpkgs/flintlib/template                     | 29 ++++++++++++---
 8 files changed, 96 insertions(+), 55 deletions(-)
 create mode 120000 srcpkgs/arb
 delete mode 100644 srcpkgs/arb/template
 create mode 100644 srcpkgs/flintlib/patches/1545-fix_openblas_detection.patch
 create mode 100644 srcpkgs/flintlib/patches/1546-fix_nmod32_in_i686-7d046723b1d74e66605c111483756322ebb1bc8d.patch
 delete mode 100644 srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch

diff --git a/common/shlibs b/common/shlibs
index 9036a675c1ae5..cc76d4e8cfafd 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3974,8 +3974,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.17 flintlib-2.9.0_1
-libarb.so.2 arb-2.20.0_1
+libflint.so.18 flintlib-3.0.0_1
 libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
diff --git a/srcpkgs/arb b/srcpkgs/arb
new file mode 120000
index 0000000000000..7c2633183069f
--- /dev/null
+++ b/srcpkgs/arb
@@ -0,0 +1 @@
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb-devel b/srcpkgs/arb-devel
index 456b9f00a86cd..7c2633183069f 120000
--- a/srcpkgs/arb-devel
+++ b/srcpkgs/arb-devel
@@ -1 +1 @@
-arb
\ No newline at end of file
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
deleted file mode 100644
index 84a62c7ffdba3..0000000000000
--- a/srcpkgs/arb/template
+++ /dev/null
@@ -1,24 +0,0 @@
-# Template file for 'arb'
-pkgname=arb
-version=2.23.0
-revision=1
-build_style=configure
-configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
-makedepends="flintlib-devel"
-short_desc="C library for arbitrary-precision interval arithmetic"
-maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
-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=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
-
-arb-devel_package() {
-	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"
-	short_desc+=" - development files"
-	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.a"
-		vmove "usr/lib/*.so"
-	}
-}
diff --git a/srcpkgs/flintlib/patches/1545-fix_openblas_detection.patch b/srcpkgs/flintlib/patches/1545-fix_openblas_detection.patch
new file mode 100644
index 0000000000000..133e93eb07341
--- /dev/null
+++ b/srcpkgs/flintlib/patches/1545-fix_openblas_detection.patch
@@ -0,0 +1,32 @@
+From d818f171ec1907d815bbf7ccbb80968ca5a024ec Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Fri, 20 Oct 2023 18:56:58 -0300
+Subject: [PATCH] Fix use of AC_SEARCH_LIBS to find cblas_dgemm
+
+Without this change, configure only tries with `-lcblas` since
+`AC_SEARCH_LIBS` caches the result based on function name.
+---
+ configure.ac | 8 ++------
+ 1 file changed, 2 insertions(+), 6 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 84ba9de832..676e5ff886 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -705,14 +705,10 @@ fi
+ 
+ if test "$with_blas" = "yes";
+ then
+-    AC_SEARCH_LIBS([cblas_dgemm],[cblas],[],
+-        [AC_SEARCH_LIBS([cblas_dgemm],[openblas],[],
+-            [AC_SEARCH_LIBS([cblas_dgemm],[blas],[],
+-                [AC_MSG_ERROR([BLAS library was not found.  If you indeed have BLAS installed, please
++    AC_SEARCH_LIBS([cblas_dgemm],[cblas openblas blas],[],
++        [AC_MSG_ERROR([BLAS library was not found.  If you indeed have BLAS installed, please
+ submit a bug report to <https://github.com/flintlib/flint/issues/> so
+ that we can either fix the issue or give a more proper error message.])]
+-            )]
+-        )]
+     )
+ fi
+ 
diff --git a/srcpkgs/flintlib/patches/1546-fix_nmod32_in_i686-7d046723b1d74e66605c111483756322ebb1bc8d.patch b/srcpkgs/flintlib/patches/1546-fix_nmod32_in_i686-7d046723b1d74e66605c111483756322ebb1bc8d.patch
new file mode 100644
index 0000000000000..f98882112f3f8
--- /dev/null
+++ b/srcpkgs/flintlib/patches/1546-fix_nmod32_in_i686-7d046723b1d74e66605c111483756322ebb1bc8d.patch
@@ -0,0 +1,37 @@
+From 7d046723b1d74e66605c111483756322ebb1bc8d Mon Sep 17 00:00:00 2001
+From: Fredrik Johansson <fredrik.johansson@gmail.com>
+Date: Sat, 21 Oct 2023 13:43:37 +0200
+Subject: [PATCH] fix nmod32 on 32-bit systems
+
+---
+ src/gr/nmod32.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/src/gr/nmod32.c b/src/gr/nmod32.c
+index fde79822ac..31ee4e0184 100644
+--- a/src/gr/nmod32.c
++++ b/src/gr/nmod32.c
+@@ -325,7 +325,11 @@ _nmod32_vec_add(nmod32_struct * res, const nmod32_struct * vec1, const nmod32_st
+     nmod_t mod = NMOD32_CTX(ctx);
+ 
+     for (i = 0; i < len; i++)
++#if FLINT_BITS == 64
+         res[i] = _nmod_add(vec1[i], vec2[i], mod);
++#else
++        res[i] = nmod_add(vec1[i], vec2[i], mod);
++#endif
+ 
+     return GR_SUCCESS;
+ }
+@@ -337,7 +341,11 @@ _nmod32_vec_sub(nmod32_struct * res, const nmod32_struct * vec1, const nmod32_st
+     nmod_t mod = NMOD32_CTX(ctx);
+ 
+     for (i = 0; i < len; i++)
++#if FLINT_BITS == 64
++        res[i] = _nmod_sub(vec1[i], vec2[i], mod);
++#else
+         res[i] = nmod_sub(vec1[i], vec2[i], mod);
++#endif
+ 
+     return GR_SUCCESS;
+ }
diff --git a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch b/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
deleted file mode 100644
index cfa109792892c..0000000000000
--- a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From fb8ddbcc06afa2a8f25637032fbb8211f6c6c122 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= <albin.ahlback@gmail.com>
-Date: Fri, 20 May 2022 14:16:38 +0200
-Subject: [PATCH] Fix bug in test code for GCC 12
-
----
- test/t-sdiv_qrnnd.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/test/t-sdiv_qrnnd.c b/test/t-sdiv_qrnnd.c
-index 2e9822e848..2676903826 100644
---- a/test/t-sdiv_qrnnd.c
-+++ b/test/t-sdiv_qrnnd.c
-@@ -33,7 +33,7 @@ int main(void)
-         {
-             d = n_randtest_not_zero(state);
-             nh = n_randtest(state);
--        } while ((FLINT_ABS(nh) >= FLINT_ABS(d)/2) || (nh == WORD_MIN));
-+        } while ((nh == WORD_MIN) || (FLINT_ABS(nh) >= FLINT_ABS(d)/2));
- 
-         nl = n_randtest(state);
- 
-
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index f7442c8052aaa..845ed41e25960 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,10 +1,11 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.9.0
+version=3.0.0
 revision=1
-build_style=configure
+build_style=gnu-configure
 configure_args="--prefix=/usr $(vopt_with ntl)
- $(vopt_if openblas --with-blas=${XBPS_CROSS_BASE}/usr/include/openblas)"
+ $(vopt_if openblas --with-blas-include=${XBPS_CROSS_BASE}/usr/include/openblas)"
+hostmakedepends="automake gettext-devel libtool"
 makedepends="mpfr-devel $(vopt_if ntl ntl-devel)
  $(vopt_if openblas openblas-devel)"
 short_desc="Fast Library for Number Theory"
@@ -12,8 +13,8 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 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=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
+distfiles="https://flintlib.org/flint-${version/.alpha/-alpha}.tar.gz"
+checksum=b9086e31e3dab89896d7edbf05a5b758d5b4b72183a1a3478f23eabdcaaae044
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
@@ -28,12 +29,30 @@ esac
 
 CFLAGS="-D_GNU_SOURCE" # needed for cpu_set_t
 
+post_patch() {
+	# run autoconf because we patched configure.ac
+	autoreconf
+}
+
 flintlib-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision} mpfr-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
+		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
 		vmove "usr/lib/*.so"
 	}
 }
+
+arb_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}
+
+arb-devel_package() {
+	depends="${sourcepkg}-devel>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From e73a0c352fb94c3387df97e3f79679d26214bf9b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:08:05 -0300
Subject: [PATCH 2/7] eclib: rebuild for flintlib-3.0.0

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

diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 1d4ad58f21b7b..12165ca788dd5 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
 version=20230424
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 makedepends="pari-devel ntl-devel flintlib-devel boost-devel"

From 8a0f3aca9c926207abc00a6cb95faeb858a641d8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:13:15 -0300
Subject: [PATCH 3/7] singular: update to 4.3.2p10.

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

diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index 036e19d470354..beb0e6d30118e 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,6 +1,6 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.2p7
+version=4.3.2p10
 revision=1
 _majver=${version%p*}
 build_style=gnu-configure
@@ -20,7 +20,7 @@ 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/${_majver//./-}/singular-${version}.tar.gz"
-checksum=aad23c30066b7fbc011138a98d60532565d76a847eec6bf2938410d93b272ca3
+checksum=28c2c9fcfee954e00dfa56eb1a7d418d5b1de67c4398d25a0f2b8f73e71552a8
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From 3044b743f7f93fea355633f9771d107ac97ea9ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 19 Jul 2023 21:04:33 -0300
Subject: [PATCH 4/7] python3-pplpy: use cython 3.

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

diff --git a/srcpkgs/python3-pplpy/template b/srcpkgs/python3-pplpy/template
index 4a9c987b2a859..d3b9aebdf2237 100644
--- a/srcpkgs/python3-pplpy/template
+++ b/srcpkgs/python3-pplpy/template
@@ -1,9 +1,9 @@
 # Template file for 'python3-pplpy'
 pkgname=python3-pplpy
 version=0.8.9
-revision=1
+revision=2
 build_style=python3-pep517
-hostmakedepends="python3-setuptools python3-wheel python3-Cython0.29
+hostmakedepends="python3-setuptools python3-wheel python3-Cython
  python3-cysignals python3-gmpy2"
 makedepends="python3-devel gmp-devel gmpxx-devel ppl-devel mpfr-devel
  libmpc-devel pari-devel"

From aa8694c953f8da4f0d320501233230b4afa6f7d0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Thu, 19 Oct 2023 08:52:15 -0300
Subject: [PATCH 5/7] python3-networkx: update to 3.2.1.

---
 srcpkgs/python3-networkx/template | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/python3-networkx/template b/srcpkgs/python3-networkx/template
index 186bf64f7bff9..29283d9e5a032 100644
--- a/srcpkgs/python3-networkx/template
+++ b/srcpkgs/python3-networkx/template
@@ -1,11 +1,11 @@
 # Template file for 'python3-networkx'
 pkgname=python3-networkx
-version=3.1
-revision=2
-build_style=python3-module
+version=3.2.1
+revision=1
+build_style=python3-pep517
 # failing in i686
 make_check_args="--deselect networkx/algorithms/approximation/tests/test_traveling_salesman.py::test_asadpour_tsp"
-hostmakedepends="python3-setuptools"
+hostmakedepends="python3-setuptools python3-wheel"
 depends="python3"
 checkdepends="python3-numpy python3-scipy python3-matplotlib python3-pandas
  python3-lxml python3-sympy python3-pytest-xdist"
@@ -15,7 +15,7 @@ license="BSD-3-Clause"
 homepage="https://networkx.org"
 changelog="https://github.com/networkx/networkx/raw/main/doc/release/release_${version}.rst"
 distfiles="${PYPI_SITE}/n/networkx/networkx-${version}.tar.gz"
-checksum=de346335408f84de0eada6ff9fafafff9bcda11f0a0dfaa931133debb146ab61
+checksum=9f1bb5cf3409bf324e0a722c20bdb4c20ee39bf1c30ce8ae499c8502b0b5e0c6
 
 post_install() {
 	vlicense LICENSE.txt

From c163ebd29248d8b68b078b5e4a6e9445ea163cc8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:50:44 -0300
Subject: [PATCH 6/7] sagemath: update to 10.2.beta8 (patch for
 flintlib-3.0.0).

---
 .../sagemath/patches/35848-flintlib_3.0.patch | 1738 ++++++++++++++++
 .../patches/35934-singular_4.3.2p7.patch      |  221 ---
 .../sagemath/patches/36006-gmp_6.3.0.patch    |   38 -
 .../patches/36046-fix_memory_leak.patch       |  740 -------
 .../sagemath/patches/36235-ecl_23.9.9.patch   |   39 -
 .../patches/36279-matplotlib_3.8.0.patch      |   24 -
 srcpkgs/sagemath/patches/36403-00pre.patch    |   29 -
 .../sagemath/patches/36407-python_3.12.patch  | 1744 -----------------
 .../sagemath/patches/36506-notebook_7.patch   |   18 +
 .../sagemath/patches/36544-networkx_3.2.patch |   41 +
 srcpkgs/sagemath/patches/get_patches          |   23 +-
 srcpkgs/sagemath/template                     |   12 +-
 12 files changed, 1807 insertions(+), 2860 deletions(-)
 create mode 100644 srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
 delete mode 100644 srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
 delete mode 100644 srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
 delete mode 100644 srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36403-00pre.patch
 delete mode 100644 srcpkgs/sagemath/patches/36407-python_3.12.patch
 create mode 100644 srcpkgs/sagemath/patches/36506-notebook_7.patch
 create mode 100644 srcpkgs/sagemath/patches/36544-networkx_3.2.patch

diff --git a/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
new file mode 100644
index 0000000000000..ed3d6d1913433
--- /dev/null
+++ b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
@@ -0,0 +1,1738 @@
+diff --git a/build/pkgs/antic/SPKG.rst b/build/pkgs/antic/SPKG.rst
+deleted file mode 100644
+index d6c32377957..00000000000
+--- a/build/pkgs/antic/SPKG.rst
++++ /dev/null
+@@ -1,18 +0,0 @@
+-antic: Algebraic Number Theory In C
+-===================================
+-
+-Description
+------------
+-
+-Algebraic Number Theory In C
+-
+-License
+--------
+-
+-LGPL 2.1
+-
+-Upstream Contact
+-----------------
+-
+-https://github.com/wbhart/antic
+-
+diff --git a/build/pkgs/antic/checksums.ini b/build/pkgs/antic/checksums.ini
+deleted file mode 100644
+index fc8711ecd13..00000000000
+--- a/build/pkgs/antic/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=antic-VERSION.tar.gz
+-sha1=940d8ea2c3512b9d49ee3101cf043f777764bd8f
+-md5=4e896420dd6344b53b307871efb2cbb4
+-cksum=1938565125
+-upstream_url=https://github.com/wbhart/antic/archive/refs/tags/vVERSION.tar.gz
+diff --git a/build/pkgs/antic/dependencies b/build/pkgs/antic/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/antic/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/antic/distros/arch.txt b/build/pkgs/antic/distros/arch.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/conda.txt b/build/pkgs/antic/distros/conda.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/debian.txt b/build/pkgs/antic/distros/debian.txt
+deleted file mode 100644
+index 8fdcd3e5721..00000000000
+--- a/build/pkgs/antic/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libantic-dev
+diff --git a/build/pkgs/antic/distros/fedora.txt b/build/pkgs/antic/distros/fedora.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/freebsd.txt b/build/pkgs/antic/distros/freebsd.txt
+deleted file mode 100644
+index 116ff3a26f3..00000000000
+--- a/build/pkgs/antic/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/antic
+diff --git a/build/pkgs/antic/distros/opensuse.txt b/build/pkgs/antic/distros/opensuse.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/repology.txt b/build/pkgs/antic/distros/repology.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/package-version.txt b/build/pkgs/antic/package-version.txt
+deleted file mode 100644
+index 3a4036fb450..00000000000
+--- a/build/pkgs/antic/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-0.2.5
+diff --git a/build/pkgs/antic/spkg-install.in b/build/pkgs/antic/spkg-install.in
+deleted file mode 100644
+index c57fa884a20..00000000000
+--- a/build/pkgs/antic/spkg-install.in
++++ /dev/null
+@@ -1,19 +0,0 @@
+-cd src
+-
+-# Copied from build/pkgs/flint/spkg-install.in:
+-#   Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-#   --with-ntl because otherwise FLINT's configure script uses
+-#   /usr/local, which is always wrong.
+-#   This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-#   The value $SAGE_LOCAL is always a safe choice even if the library
+-#   is coming from the system and is found using what is in
+-#   LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-flint="$SAGE_LOCAL"  || sdh_die "Error: Failed to configure antic."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/antic/type b/build/pkgs/antic/type
+deleted file mode 100644
+index 134d9bc32d5..00000000000
+--- a/build/pkgs/antic/type
++++ /dev/null
+@@ -1 +0,0 @@
+-optional
+diff --git a/build/pkgs/arb/SPKG.rst b/build/pkgs/arb/SPKG.rst
+deleted file mode 100644
+index cff49ddb95b..00000000000
+--- a/build/pkgs/arb/SPKG.rst
++++ /dev/null
+@@ -1,27 +0,0 @@
+-arb: Arbitrary-precision floating-point ball arithmetic
+-=======================================================
+-
+-Description
+------------
+-
+-Arb is a C library for arbitrary-precision floating-point ball
+-arithmetic, developed by Fredrik Johansson
+-(fredrik.johansson@gmail.com). It supports efficient high-precision
+-computation with polynomials, power series, matrices and special
+-functions over the real and complex numbers, with automatic, rigorous
+-error control.
+-
+-License
+--------
+-
+-GNU General Public License v2+
+-
+-
+-Upstream Contact
+-----------------
+-
+- - Fredrik Johansson: fredrik.johansson@gmail.com
+-
+- - https://arblib.org/
+-
+- - http://github.com/fredrik-johansson/arb/
+diff --git a/build/pkgs/arb/checksums.ini b/build/pkgs/arb/checksums.ini
+deleted file mode 100644
+index 80ef43dad5d..00000000000
+--- a/build/pkgs/arb/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=arb-VERSION.tar.gz
+-sha1=a1efe035dd3af3613dd685971a156f652b86ff63
+-md5=9b369e29f93cdf2d4f90b57a92526cce
+-cksum=64252121
+-upstream_url=https://github.com/fredrik-johansson/arb/archive/VERSION.tar.gz
+diff --git a/build/pkgs/arb/dependencies b/build/pkgs/arb/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/arb/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/arb/distros/arch.txt b/build/pkgs/arb/distros/arch.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/conda.txt b/build/pkgs/arb/distros/conda.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/debian.txt b/build/pkgs/arb/distros/debian.txt
+deleted file mode 100644
+index 9fe71110712..00000000000
+--- a/build/pkgs/arb/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libflint-arb-dev
+diff --git a/build/pkgs/arb/distros/fedora.txt b/build/pkgs/arb/distros/fedora.txt
+deleted file mode 100644
+index 76794404627..00000000000
+--- a/build/pkgs/arb/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb arb-devel
+diff --git a/build/pkgs/arb/distros/freebsd.txt b/build/pkgs/arb/distros/freebsd.txt
+deleted file mode 100644
+index 2ef8c7cec0f..00000000000
+--- a/build/pkgs/arb/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/arb
+diff --git a/build/pkgs/arb/distros/gentoo.txt b/build/pkgs/arb/distros/gentoo.txt
+deleted file mode 100644
+index 58e3d4f8008..00000000000
+--- a/build/pkgs/arb/distros/gentoo.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-sci-mathematics/arb
+diff --git a/build/pkgs/arb/distros/homebrew.txt b/build/pkgs/arb/distros/homebrew.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/homebrew.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/nix.txt b/build/pkgs/arb/distros/nix.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/nix.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/opensuse.txt b/build/pkgs/arb/distros/opensuse.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/distros/repology.txt b/build/pkgs/arb/distros/repology.txt
+deleted file mode 100644
+index 179c9d507e1..00000000000
+--- a/build/pkgs/arb/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-fp
+diff --git a/build/pkgs/arb/distros/void.txt b/build/pkgs/arb/distros/void.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/void.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/package-version.txt b/build/pkgs/arb/package-version.txt
+deleted file mode 100644
+index e9763f6bfed..00000000000
+--- a/build/pkgs/arb/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-2.23.0
+diff --git a/build/pkgs/arb/spkg-check.in b/build/pkgs/arb/spkg-check.in
+deleted file mode 100644
+index 27cd9419538..00000000000
+--- a/build/pkgs/arb/spkg-check.in
++++ /dev/null
+@@ -1,2 +0,0 @@
+-cd src
+-$MAKE check
+diff --git a/build/pkgs/arb/spkg-configure.m4 b/build/pkgs/arb/spkg-configure.m4
+deleted file mode 100644
+index ef2dd0aac4a..00000000000
+--- a/build/pkgs/arb/spkg-configure.m4
++++ /dev/null
+@@ -1,23 +0,0 @@
+-SAGE_SPKG_CONFIGURE([arb], [
+-    AC_REQUIRE([SAGE_SPKG_CONFIGURE_FLINT])
+-    SAGE_ARB_LIBRARY="arb"
+-    AC_MSG_CHECKING([installing flint? ])
+-    if test x$sage_spkg_install_flint = xyes; then
+-        AC_MSG_RESULT([yes; install arb as well])
+-        sage_spkg_install_arb=yes
+-    else
+-        AC_CHECK_HEADER(arb.h, [
+-        dnl below function added in version 2.16 of arb
+-            AC_CHECK_LIB([arb], [acb_mat_eig_simple], [],
+-              [dnl in Debian the name of dylib is different.
+-               AC_CHECK_LIB([flint-arb], [acb_mat_eig_simple],
+-                [SAGE_ARB_LIBRARY="flint-arb"], [sage_spkg_install_arb=yes])])
+-        ], [sage_spkg_install_arb=yes])
+-    fi
+-], [], [], [
+-    if test x$sage_spkg_install_arb = xyes; then
+-        AC_SUBST(SAGE_ARB_LIBRARY,["arb"])
+-    else
+-        AC_SUBST(SAGE_ARB_LIBRARY,[$SAGE_ARB_LIBRARY])
+-    fi
+-])
+diff --git a/build/pkgs/arb/spkg-install.in b/build/pkgs/arb/spkg-install.in
+deleted file mode 100644
+index 9322f04c912..00000000000
+--- a/build/pkgs/arb/spkg-install.in
++++ /dev/null
+@@ -1,17 +0,0 @@
+-cd src
+-
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-flint because otherwise ARB's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure --disable-static --prefix="$SAGE_LOCAL" \
+-        --with-gmp="$SAGE_LOCAL" \
+-        --with-mpfr="$SAGE_LOCAL" \
+-        --with-flint="$SAGE_LOCAL" || \
+-    sdh_die "Error configuring arb."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/arb/type b/build/pkgs/arb/type
+deleted file mode 100644
+index a6a7b9cd726..00000000000
+--- a/build/pkgs/arb/type
++++ /dev/null
+@@ -1 +0,0 @@
+-standard
+diff --git a/build/pkgs/e_antic/dependencies b/build/pkgs/e_antic/dependencies
+index fea1ffbda45..8e977a55c13 100644
+--- a/build/pkgs/e_antic/dependencies
++++ b/build/pkgs/e_antic/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) flint arb antic boost_cropped
++$(MP_LIBRARY) flint boost_cropped
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/SPKG.rst b/build/pkgs/flint/SPKG.rst
+index f91de70d1ff..d9dcea0903b 100644
+--- a/build/pkgs/flint/SPKG.rst
++++ b/build/pkgs/flint/SPKG.rst
+@@ -4,8 +4,8 @@ flint: Fast Library for Number Theory
+ Description
+ -----------
+ 
+-FLINT is a C library for doing number theory, maintained by William
+-Hart.
++FLINT is a C library for doing number theory, maintained by
++Fredrik Johansson.
+ 
+ Website: http://www.flintlib.org
+ 
+@@ -20,4 +20,4 @@ Upstream Contact
+ 
+ -  flint-devel Gougle Group
+    (http://groups.google.co.uk/group/flint-devel)
+--  William Hart
++-  Fredrik Johansson
+diff --git a/build/pkgs/flint/checksums.ini b/build/pkgs/flint/checksums.ini
+index 3d449d98064..2cec823bfb1 100644
+--- a/build/pkgs/flint/checksums.ini
++++ b/build/pkgs/flint/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=flint-VERSION.tar.gz
+-sha1=63d90f8242c8f8ab4011fbcfb44b86c154f43abd
+-md5=c2d3cec326438f159a530c66eb07fafe
+-cksum=4244948341
+-upstream_url=http://flintlib.org/flint-VERSION.tar.gz
++sha1=c548b1d5eb86a1805de9bef56629455b61e873f7
++md5=24551d4e475290ce6b831c78fafb5efb
++cksum=1567352998
++upstream_url=https://github.com/flintlib/flint/releases/download/vVERSION/flint-VERSION.tar.gz
+diff --git a/build/pkgs/flint/dependencies b/build/pkgs/flint/dependencies
+index 385df4faa7d..1108dc4fb21 100644
+--- a/build/pkgs/flint/dependencies
++++ b/build/pkgs/flint/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) mpfr ntl
++$(MP_LIBRARY) mpfr
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/package-version.txt b/build/pkgs/flint/package-version.txt
+index c8e38b61405..4a36342fcab 100644
+--- a/build/pkgs/flint/package-version.txt
++++ b/build/pkgs/flint/package-version.txt
+@@ -1 +1 @@
+-2.9.0
++3.0.0
+diff --git a/build/pkgs/flint/spkg-build.in b/build/pkgs/flint/spkg-build.in
+new file mode 100644
+index 00000000000..ffb822c8a97
+--- /dev/null
++++ b/build/pkgs/flint/spkg-build.in
+@@ -0,0 +1,3 @@
++cd src
++sdh_configure
++sdh_make
+diff --git a/build/pkgs/flint/spkg-configure.m4 b/build/pkgs/flint/spkg-configure.m4
+index a58108c9d6e..9576e4cc1e9 100644
+--- a/build/pkgs/flint/spkg-configure.m4
++++ b/build/pkgs/flint/spkg-configure.m4
+@@ -1,25 +1,8 @@
+ SAGE_SPKG_CONFIGURE([flint], [
+-    SAGE_SPKG_DEPCHECK([mpfr ntl], [
++    SAGE_SPKG_DEPCHECK([mpfr], [
+         AC_CHECK_HEADER(flint/flint.h, [
+-          dnl flint_parallel_binary_splitting appears in Flint 2.9.0, needed by arb 2.23
+-          AC_SEARCH_LIBS([flint_parallel_binary_splitting], [flint], [
+-            dnl check that NTL is linked in
+-            AC_SEARCH_LIBS([fmpz_poly_get_ZZX], [flint], [
+-
+-              AC_MSG_CHECKING([that GC is not enabled in Flint... ])
+-              AC_RUN_IFELSE([
+-                 AC_LANG_PROGRAM([[#include <flint/flint.h>]], [
+-                                  [#ifdef HAVE_GC]
+-                                     [return HAVE_GC;]
+-                                  [#else]
+-                                     [return 0;]
+-                                  [#endif]])],
+-                 [AC_MSG_RESULT([GC not enabled. Good.])],
+-                        [AC_MSG_RESULT([GC enabled. Incompatible with Sage.])
+-                         sage_spkg_install_flint=yes],
+-                 [AC_MSG_RESULT(["cross compiling. assuming GC is not enabled"])])
+-            ], [sage_spkg_install_flint=yes])
+-          ], [sage_spkg_install_flint=yes])
++          dnl gr_get_fexpr appears in Flint 3.0
++          AC_SEARCH_LIBS([gr_get_fexpr], [flint], [], [sage_spkg_install_flint=yes])
+         ], [sage_spkg_install_flint=yes])
+     ])
+ ], [], [], [
+diff --git a/build/pkgs/flint/spkg-install.in b/build/pkgs/flint/spkg-install.in
+index eacd7b6e491..3ea8c053669 100644
+--- a/build/pkgs/flint/spkg-install.in
++++ b/build/pkgs/flint/spkg-install.in
+@@ -1,36 +1,2 @@
+-###############################################################################
+-#
+-# FLINT Sage install script
+-#
+-###############################################################################
+-if [ "$SAGE_DEBUG" = "yes" ]; then
+-    echo "Building a debug version of FLINT."
+-    FLINT_TUNE=" $FLINT_TUNE"; export FLINT_TUNE
+-    FLINT_CONFIGURE="--enable-assert $FLINT_CONFIGURE"
+-fi
+-
+ cd src
+-
+-echo "Configuring FLINT."
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-ntl because otherwise FLINT's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-ntl="$SAGE_LOCAL" \
+-    $FLINT_CONFIGURE || sdh_die "Error: Failed to configure FLINT."
+-
+-sdh_make verbose
+-
+-echo "Deleting old FLINT files."
+-rm -f $SAGE_LOCAL/lib/libflint*
+-rm -rf $SAGE_LOCAL/include/flint
+-
+ sdh_make_install
+diff --git a/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+new file mode 100644
+index 00000000000..27a642a13b0
+--- /dev/null
++++ b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+@@ -0,0 +1,53 @@
++From fe730579476de0b2d4181a38efa7f63dff9c81d7 Mon Sep 17 00:00:00 2001
++From: Marc Mezzarobba <marc@mezzarobba.net>
++Date: Tue, 12 Sep 2023 08:23:08 +0200
++Subject: [PATCH] Make msolve build with flint3
++
++---
++ src/fglm/berlekamp_massey.c | 3 +++
++ src/fglm/data_fglm.c        | 7 +++++--
++ 2 files changed, 8 insertions(+), 2 deletions(-)
++
++diff --git a/src/fglm/berlekamp_massey.c b/src/fglm/berlekamp_massey.c
++index b0f2052..998af1c 100644
++--- a/src/fglm/berlekamp_massey.c
+++++ b/src/fglm/berlekamp_massey.c
++@@ -30,6 +30,9 @@
++ */
++ 
++ #include <stdlib.h>
+++#if __FLINT_VERSION >= 3
+++#  include <flint/nmod.h>
+++#endif
++ //#include "nmod_poly.h"
++ //#include "mpn_extras.h"
++ 
++diff --git a/src/fglm/data_fglm.c b/src/fglm/data_fglm.c
++index 0726760..0e1da6f 100644
++--- a/src/fglm/data_fglm.c
+++++ b/src/fglm/data_fglm.c
++@@ -24,6 +24,7 @@
++ #include <flint/mpn_extras.h>
++ #include <flint/nmod_poly.h>
++ #include <flint/nmod_poly_factor.h>
+++#include <flint/ulong_extras.h>
++ 
++ 
++ typedef uint32_t szmat_t;
++@@ -299,9 +300,11 @@ static inline void nmod_poly_set_prime(nmod_poly_t poly,
++   mp_limb_t ninv = n_preinvert_limb(prime);
++   poly->mod.n = prime;
++   poly->mod.ninv = ninv;
+++#if __FLINT_VERSION < 3
++   count_leading_zeros(poly->mod.norm, prime);
++-  /* poly->mod.norm = flint_clz(prime); */
++-
+++#else
+++  poly->mod.norm = flint_clz(prime);
+++#endif
++ }
++ 
++ static inline void fglm_param_set_prime(param_t *param, mp_limb_t prime){
++-- 
++2.40.1
++
+diff --git a/build/pkgs/sagelib/dependencies b/build/pkgs/sagelib/dependencies
+index 5dc2efe1d31..fa6e98df7db 100644
+--- a/build/pkgs/sagelib/dependencies
++++ b/build/pkgs/sagelib/dependencies
+@@ -1,4 +1,4 @@
+-FORCE $(SCRIPTS) arb boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
++FORCE $(SCRIPTS) boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/symengine/dependencies b/build/pkgs/symengine/dependencies
+index 1fc34963eda..7795d486018 100644
+--- a/build/pkgs/symengine/dependencies
++++ b/build/pkgs/symengine/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) arb ecm flint mpc mpfr | cmake
++$(MP_LIBRARY) ecm flint mpc mpfr | cmake
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/pkgs/sage-conf/_sage_conf/_conf.py.in b/pkgs/sage-conf/_sage_conf/_conf.py.in
+index 87b27ca05cb..895d6572d1e 100644
+--- a/pkgs/sage-conf/_sage_conf/_conf.py.in
++++ b/pkgs/sage-conf/_sage_conf/_conf.py.in
+@@ -19,8 +19,6 @@ MAXIMA_FAS = "@SAGE_MAXIMA_FAS@".replace('${prefix}', SAGE_LOCAL)
+ # Delete this line if your ECL can load Kenzo without further prodding.
+ KENZO_FAS = "@SAGE_KENZO_FAS@".replace('${prefix}', SAGE_LOCAL)
+ 
+-ARB_LIBRARY = "@SAGE_ARB_LIBRARY@"
+-
+ NTL_INCDIR = "@NTL_INCDIR@"
+ NTL_LIBDIR = "@NTL_LIBDIR@"
+ 
+diff --git a/src/sage/env.py b/src/sage/env.py
+index f4899639a6d..f6459313fd4 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -223,7 +223,6 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st
+ FOURTITWO_PPI = var("FOURTITWO_PPI")
+ FOURTITWO_CIRCUITS = var("FOURTITWO_CIRCUITS")
+ FOURTITWO_GROEBNER = var("FOURTITWO_GROEBNER")
+-ARB_LIBRARY = var("ARB_LIBRARY", "arb")
+ CBLAS_PC_MODULES = var("CBLAS_PC_MODULES", "cblas:openblas:blas")
+ ECL_CONFIG = var("ECL_CONFIG", "ecl-config")
+ NTL_INCDIR = var("NTL_INCDIR")
+@@ -356,8 +355,7 @@ def cython_aliases(required_modules=None,
+         sage: cython_aliases()
+         {...}
+         sage: sorted(cython_aliases().keys())
+-        ['ARB_LIBRARY',
+-         'CBLAS_CFLAGS',
++        ['CBLAS_CFLAGS',
+          ...,
+          'ZLIB_LIBRARIES']
+         sage: cython_aliases(required_modules=('module-that-is-assumed-to-not-exist'))
+@@ -475,8 +473,6 @@ def uname_specific(name, value, alternative):
+     if "LINBOX_CFLAGS" in aliases:
+         aliases["LINBOX_CFLAGS"].append("-std=gnu++11")
+ 
+-    aliases["ARB_LIBRARY"] = ARB_LIBRARY
+-
+     # TODO: Remove Cygwin hack by installing a suitable cblas.pc
+     if os.path.exists('/usr/lib/libblas.dll.a'):
+         aliases["CBLAS_LIBS"] = ['gslcblas']
+diff --git a/src/sage/features/sagemath.py b/src/sage/features/sagemath.py
+index 7404e6d0a8e..6037d097391 100644
+--- a/src/sage/features/sagemath.py
++++ b/src/sage/features/sagemath.py
+@@ -761,7 +761,7 @@ class sage__rings__number_field(JoinFeature):
+     A :class:`~sage.features.Feature` describing the presence of :mod:`sage.rings.number_field`.
+ 
+     Number fields are implemented in Sage using a complicated mixture of various libraries,
+-    including :ref:`arb <spkg_arb>`, :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
++    including :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
+     :ref:`MPFI <spkg_mpfi>`, :ref:`NTL <spkg_ntl>`, and :ref:`PARI <spkg_pari>`.
+ 
+     EXAMPLES:
+diff --git a/src/sage/libs/arb/acb.pxd b/src/sage/libs/arb/acb.pxd
+index 5148dc43991..851488d803a 100644
+--- a/src/sage/libs/arb/acb.pxd
++++ b/src/sage/libs/arb/acb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -152,10 +152,6 @@ cdef extern from "arb_wrap.h":
+     void acb_sech(acb_t s, const acb_t z, long prec)
+     void acb_csch(acb_t c, const acb_t z, long prec)
+ 
+-    void acb_rising_ui_bs(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui_rs(acb_t z, const acb_t x, unsigned long n, unsigned long step, long prec)
+-    void acb_rising_ui_rec(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui(acb_t z, const acb_t x, unsigned long n, long prec)
+     void acb_rising(acb_t z, const acb_t x, const acb_t n, long prec)
+ 
+     void acb_gamma(acb_t y, const acb_t x, long prec)
+diff --git a/src/sage/libs/arb/acb_calc.pxd b/src/sage/libs/arb/acb_calc.pxd
+index a5dbf360b5e..67bd2ed57dc 100644
+--- a/src/sage/libs/arb/acb_calc.pxd
++++ b/src/sage/libs/arb/acb_calc.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_calc.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_elliptic.pxd b/src/sage/libs/arb/acb_elliptic.pxd
+index 176f68df00e..e3480e9f73b 100644
+--- a/src/sage/libs/arb/acb_elliptic.pxd
++++ b/src/sage/libs/arb/acb_elliptic.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_elliptic.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_hypgeom.pxd b/src/sage/libs/arb/acb_hypgeom.pxd
+index 418e766f10d..c43e5c0623b 100644
+--- a/src/sage/libs/arb/acb_hypgeom.pxd
++++ b/src/sage/libs/arb/acb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_hypgeom.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_modular.pxd b/src/sage/libs/arb/acb_modular.pxd
+index c708e9bf97d..cdc413c92da 100644
+--- a/src/sage/libs/arb/acb_modular.pxd
++++ b/src/sage/libs/arb/acb_modular.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_modular.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_poly.pxd b/src/sage/libs/arb/acb_poly.pxd
+index 69f4320055b..ae02757ffd9 100644
+--- a/src/sage/libs/arb/acb_poly.pxd
++++ b/src/sage/libs/arb/acb_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -79,24 +79,10 @@ cdef extern from "arb_wrap.h":
+     void _acb_poly_divrem(acb_ptr Q, acb_ptr R, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec)
+     bint acb_poly_divrem(acb_poly_t Q, acb_poly_t R, const acb_poly_t A, const acb_poly_t B, long prec)
+     void _acb_poly_div_root(acb_ptr Q, acb_t R, acb_srcptr A, long len, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_horner(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_horner(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_divconquer(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_divconquer(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_convolution(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_convolution(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+     void _acb_poly_taylor_shift(acb_ptr g, const acb_t c, long n, long prec)
+     void acb_poly_taylor_shift(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_compose_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_divconquer(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_divconquer(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+     void _acb_poly_compose(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+     void acb_poly_compose(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_series_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+-    void _acb_poly_compose_series_brent_kung(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_brent_kung(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_compose_series(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+     void acb_poly_compose_series(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_revert_series_lagrange(acb_ptr h, acb_srcptr f, long flen, long n, long prec)
+@@ -161,10 +147,6 @@ cdef extern from "arb_wrap.h":
+     void acb_poly_exp_series_basecase(acb_poly_t f, const acb_poly_t h, long n, long prec)
+     void _acb_poly_exp_series(acb_ptr f, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_exp_series(acb_poly_t f, const acb_poly_t h, long n, long prec)
+-    void _acb_poly_sin_cos_series_basecase(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_basecase(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+-    void _acb_poly_sin_cos_series_tangent(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_tangent(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+     void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_sin_cos_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec)
+     void _acb_poly_sin_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec)
+diff --git a/src/sage/libs/arb/arb.pxd b/src/sage/libs/arb/arb.pxd
+index c82b94de30f..acd232ab816 100644
+--- a/src/sage/libs/arb/arb.pxd
++++ b/src/sage/libs/arb/arb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -224,15 +224,8 @@ cdef extern from "arb_wrap.h":
+ 
+     void arb_lambertw(arb_t res, const arb_t x, int flags, long prec)
+ 
+-    void arb_rising_ui_bs(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui_rs(arb_t z, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising_ui_rec(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui(arb_t z, const arb_t x, unsigned long n, long prec)
+     void arb_rising(arb_t z, const arb_t x, const arb_t n, long prec)
+     void arb_rising_fmpq_ui(arb_t z, const fmpq_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_bs(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_rs(arb_t u, arb_t v, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising2_ui(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+     void arb_fac_ui(arb_t z, unsigned long n, long prec)
+     void arb_bin_ui(arb_t z, const arb_t n, unsigned long k, long prec)
+     void arb_bin_uiui(arb_t z, unsigned long n, unsigned long k, long prec)
+diff --git a/src/sage/libs/arb/arb_fmpz_poly.pxd b/src/sage/libs/arb/arb_fmpz_poly.pxd
+index 079f76e9d9e..55daa705238 100644
+--- a/src/sage/libs/arb/arb_fmpz_poly.pxd
++++ b/src/sage/libs/arb/arb_fmpz_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_fmpz_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -22,5 +22,4 @@ cdef extern from "arb_wrap.h":
+     unsigned long arb_fmpz_poly_deflation(const fmpz_poly_t poly)
+     void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long deflation)
+     void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, long prec)
+-    void arb_fmpz_poly_cos_minpoly(fmpz_poly_t res, unsigned long n)
+     void arb_fmpz_poly_gauss_period_minpoly(fmpz_poly_t res, unsigned long q, unsigned long n)
+diff --git a/src/sage/libs/arb/arb_hypgeom.pxd b/src/sage/libs/arb/arb_hypgeom.pxd
+index fb1c40ddaa8..139b987d669 100644
+--- a/src/sage/libs/arb/arb_hypgeom.pxd
++++ b/src/sage/libs/arb/arb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_hypgeom.h
+ 
+ from sage.libs.flint.types cimport fmpz_t
+diff --git a/src/sage/libs/arb/arb_wrap.h b/src/sage/libs/arb/arb_wrap.h
+index 49997075ee5..488bb376d5e 100644
+--- a/src/sage/libs/arb/arb_wrap.h
++++ b/src/sage/libs/arb/arb_wrap.h
+@@ -5,25 +5,27 @@
+  * by arb, most of which rely on flint's ulong and slong defines.
+  */
+ 
++#include <mpfr.h>
++
+ #undef ulong
+ #undef slong
+ 
+ #define ulong mp_limb_t
+ #define slong mp_limb_signed_t
+ 
+-#include <acb.h>
+-#include <acb_calc.h>
+-#include <acb_elliptic.h>
+-#include <acb_hypgeom.h>
+-#include <acb_mat.h>
+-#include <acb_modular.h>
+-#include <acb_poly.h>
+-#include <arb.h>
+-#include <arb_fmpz_poly.h>
+-#include <arb_hypgeom.h>
+-#include <arf.h>
+-#include <bernoulli.h>
+-#include <mag.h>
++#include <flint/acb.h>
++#include <flint/acb_calc.h>
++#include <flint/acb_elliptic.h>
++#include <flint/acb_hypgeom.h>
++#include <flint/acb_mat.h>
++#include <flint/acb_modular.h>
++#include <flint/acb_poly.h>
++#include <flint/arb.h>
++#include <flint/arb_fmpz_poly.h>
++#include <flint/arb_hypgeom.h>
++#include <flint/arf.h>
++#include <flint/bernoulli.h>
++#include <flint/mag.h>
+ 
+ #undef ulong
+ #undef slong
+diff --git a/src/sage/libs/arb/arf.pxd b/src/sage/libs/arb/arf.pxd
+index b8b83fefcdc..84778fe9f09 100644
+--- a/src/sage/libs/arb/arf.pxd
++++ b/src/sage/libs/arb/arf.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arf.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -30,7 +30,6 @@ cdef extern from "arb_wrap.h":
+     void arf_set_ui(arf_t y, unsigned long x)
+     void arf_set_si(arf_t y, long x)
+     void arf_set_mpfr(arf_t y, const mpfr_t x)
+-    # void arf_set_fmpr(arf_t y, const fmpr_t x)
+     void arf_set_d(arf_t y, double x)
+     void arf_swap(arf_t y, arf_t x)
+     void arf_init_set_ui(arf_t y, unsigned long x)
+@@ -46,7 +45,6 @@ cdef extern from "arb_wrap.h":
+     int arf_set_round_fmpz_2exp(arf_t y, const fmpz_t x, const fmpz_t e, long prec, arf_rnd_t rnd)
+     void arf_get_fmpz_2exp(fmpz_t m, fmpz_t e, const arf_t x)
+     double arf_get_d(const arf_t x, arf_rnd_t rnd)
+-    # void arf_get_fmpr(fmpr_t y, const arf_t x)
+     int arf_get_mpfr(mpfr_t y, const arf_t x, mpfr_rnd_t rnd)
+     void arf_get_fmpz(fmpz_t z, const arf_t x, arf_rnd_t rnd)
+     long arf_get_si(const arf_t x, arf_rnd_t rnd)
+diff --git a/src/sage/libs/arb/bernoulli.pxd b/src/sage/libs/arb/bernoulli.pxd
+index 375b2b9bbcf..ea9340f4b15 100644
+--- a/src/sage/libs/arb/bernoulli.pxd
++++ b/src/sage/libs/arb/bernoulli.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = bernoulli.h
+ 
+ from ..flint.types cimport fmpq_t, ulong
+diff --git a/src/sage/libs/arb/mag.pxd b/src/sage/libs/arb/mag.pxd
+index d5d8693ea8f..69dfb990ae0 100644
+--- a/src/sage/libs/arb/mag.pxd
++++ b/src/sage/libs/arb/mag.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = mag.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -27,13 +27,11 @@ cdef extern from "arb_wrap.h":
+     # void mag_randtest(mag_t x, flint_rand_t state, long expbits)
+     # void mag_randtest_special(mag_t x, flint_rand_t state, long expbits)
+     void mag_set_d(mag_t y, double x)
+-    # void mag_set_fmpr(mag_t y, const fmpr_t x)
+     void mag_set_ui(mag_t y, unsigned long x)
+     void mag_set_fmpz(mag_t y, const fmpz_t x)
+     void mag_set_d_2exp_fmpz(mag_t z, double x, const fmpz_t y)
+     void mag_set_fmpz_2exp_fmpz(mag_t z, const fmpz_t x, const fmpz_t y)
+     void mag_set_ui_2exp_si(mag_t z, unsigned long x, long y)
+-    # void mag_get_fmpr(fmpr_t y, const mag_t x)
+     void mag_get_fmpq(fmpq_t y, const mag_t x)
+     void mag_set_ui_lower(mag_t z, unsigned long x)
+     void mag_set_fmpz_lower(mag_t z, const fmpz_t x)
+diff --git a/src/sage/libs/flint/flint_wrap.h b/src/sage/libs/flint/flint_wrap.h
+index 266535c3835..4db72b97660 100644
+--- a/src/sage/libs/flint/flint_wrap.h
++++ b/src/sage/libs/flint/flint_wrap.h
+@@ -15,6 +15,7 @@
+  */
+ 
+ #include <gmp.h>
++#include <mpfr.h>
+ 
+ /* Save previous definition of ulong if any, as pari also uses it */
+ /* Should work on GCC, clang, MSVC */
+@@ -33,6 +34,7 @@
+ 
+ #include <flint/arith.h>
+ #include <flint/fmpq.h>
++#include <flint/fmpq_vec.h>
+ #include <flint/fmpq_mat.h>
+ #include <flint/fmpq_poly.h>
+ #include <flint/fmpz.h>
+@@ -47,6 +49,7 @@
+ #include <flint/fq.h>
+ #include <flint/fq_nmod.h>
+ #include <flint/nmod_poly.h>
++#include <flint/nmod_poly_factor.h>
+ #include <flint/nmod_vec.h>
+ #include <flint/padic.h>
+ #include <flint/padic_poly.h>
+diff --git a/src/sage/libs/flint/fmpq.pxd b/src/sage/libs/flint/fmpq.pxd
+index 5e64c82102f..0616c0a7408 100644
+--- a/src/sage/libs/flint/fmpq.pxd
++++ b/src/sage/libs/flint/fmpq.pxd
+@@ -12,6 +12,8 @@ cdef extern from "flint_wrap.h":
+     fmpz * fmpq_denref(fmpq_t)
+     void fmpq_init(fmpq_t)
+     void fmpq_clear(fmpq_t)
++    void fmpq_init_set_readonly(fmpq_t, const mpq_t)
++    void fmpq_clear_readonly(fmpq_t)
+     void fmpq_one(fmpq_t)
+     void fmpq_zero(fmpq_t)
+     bint fmpq_is_zero(fmpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pxd b/src/sage/libs/flint/fmpq_poly.pxd
+index 20a797c0197..516f9e84cfc 100644
+--- a/src/sage/libs/flint/fmpq_poly.pxd
++++ b/src/sage/libs/flint/fmpq_poly.pxd
+@@ -30,6 +30,9 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_canonicalise(fmpq_poly_t)
+     int fmpq_poly_is_canonical(const fmpq_poly_t)
+ 
++    void _fmpq_poly_set_length(fmpq_poly_t, slong)
++    void _fmpq_poly_normalise(fmpq_poly_t)
++
+     # Polynomial parameters
+     slong fmpq_poly_degree(const fmpq_poly_t)
+     ulong fmpq_poly_length(const fmpq_poly_t)
+@@ -46,10 +49,7 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_ui(fmpq_poly_t, ulong)
+     void fmpq_poly_set_fmpz(fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_set_fmpq(fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+     void fmpq_poly_set_fmpz_poly(fmpq_poly_t, const fmpz_poly_t)
+-    void fmpq_poly_set_array_mpq(fmpq_poly_t, const mpq_t *, slong)
+ 
+     void fmpq_poly_set_str(fmpq_poly_t, const char *)
+     char *fmpq_poly_get_str(const fmpq_poly_t)
+@@ -67,7 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_reverse(fmpq_poly_t, const fmpq_poly_t, slong)
+ 
+     void fmpq_poly_get_coeff_fmpq(fmpq_t, const fmpq_poly_t, slong)
+-    void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_si(slong, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_ui(ulong, const fmpq_poly_t, slong)
+ 
+@@ -75,8 +74,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_coeff_ui(fmpq_poly_t, slong, ulong)
+     void fmpq_poly_set_coeff_fmpz(fmpq_poly_t, slong, const fmpz_t)
+     void fmpq_poly_set_coeff_fmpq(fmpq_poly_t, slong, const fmpq_t)
+-    void fmpq_poly_set_coeff_mpz(fmpq_poly_t, slong, const mpz_t)
+-    void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
+ 
+     # Comparison
+     int fmpq_poly_equal(const fmpq_poly_t, const fmpq_poly_t)
+@@ -100,8 +97,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_mul_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     void fmpq_poly_scalar_div_si(fmpq_poly_t, const fmpq_poly_t, slong)
+     void fmpq_poly_scalar_div_ui(fmpq_poly_t, const fmpq_poly_t, ulong)
+@@ -109,8 +104,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_div_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_div_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_div_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Multiplication
+     void fmpq_poly_mul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -155,8 +148,6 @@ cdef extern from "flint_wrap.h":
+     # Evaluation
+     void fmpq_poly_evaluate_fmpz(fmpq_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_evaluate_fmpq(fmpq_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_evaluate_mpz(mpq_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_evaluate_mpq(mpq_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Composition
+     void fmpq_poly_compose(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -189,3 +180,11 @@ cdef extern from "flint_wrap.h":
+ # since the fmpq_poly header seems to be lacking this inline function
+ cdef inline sage_fmpq_poly_max_limbs(const fmpq_poly_t poly):
+     return _fmpz_vec_max_limbs(fmpq_poly_numref(poly), fmpq_poly_length(poly))
++
++# functions removed from flint but still needed in sage
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
++cdef void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
++cdef void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pyx b/src/sage/libs/flint/fmpq_poly.pyx
+new file mode 100644
+index 00000000000..3b8a0cf0c51
+--- /dev/null
++++ b/src/sage/libs/flint/fmpq_poly.pyx
+@@ -0,0 +1,45 @@
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++from sage.libs.gmp.mpq cimport *
++from sage.libs.flint.fmpz cimport *
++from sage.libs.flint.fmpq cimport *
++
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t rop, const fmpq_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t rop, const fmpq_poly_t op, const mpq_t c):
++    cdef fmpq_t f
++    fmpq_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpq(rop, op, f)
++    fmpq_clear_readonly(f)
++
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t poly, slong n, const mpq_t x):
++    cdef fmpq_t t
++    fmpq_init_set_readonly(t, x)
++    fmpq_poly_set_coeff_fmpq(poly, n, t)
++    fmpq_clear_readonly(t)
++
++cdef void fmpq_poly_get_coeff_mpq(mpq_t x, const fmpq_poly_t poly, slong n):
++    cdef fmpq_t t
++    fmpq_init(t)
++    fmpq_poly_get_coeff_fmpq(t, poly, n)
++    fmpq_get_mpq(x, t)
++    fmpq_clear(t)
++
++cdef void fmpq_poly_set_mpq(fmpq_poly_t poly, const mpq_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), mpq_numref(x))
++    fmpz_set_mpz(fmpq_poly_denref(poly), mpq_denref(x))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
++
++cdef void fmpq_poly_set_mpz(fmpq_poly_t poly, const mpz_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), x)
++    fmpz_one(fmpq_poly_denref(poly))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz.pxd b/src/sage/libs/flint/fmpz.pxd
+index 01058d0f130..b97fbe1eae0 100644
+--- a/src/sage/libs/flint/fmpz.pxd
++++ b/src/sage/libs/flint/fmpz.pxd
+@@ -16,6 +16,9 @@ cdef extern from "flint_wrap.h":
+     void fmpz_init_set(fmpz_t, fmpz_t)
+     void fmpz_init_set_ui(fmpz_t, ulong)
+ 
++    void fmpz_init_set_readonly(fmpz_t, const mpz_t)
++    void fmpz_clear_readonly(fmpz_t)
++
+     # Conversion
+     void fmpz_set(fmpz_t f, fmpz_t g)
+     void fmpz_set_ui(fmpz_t, ulong)
+diff --git a/src/sage/libs/flint/fmpz_mod_poly.pxd b/src/sage/libs/flint/fmpz_mod_poly.pxd
+index 24b653eb3b7..2727246da98 100644
+--- a/src/sage/libs/flint/fmpz_mod_poly.pxd
++++ b/src/sage/libs/flint/fmpz_mod_poly.pxd
+@@ -67,13 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_get_coeff_fmpz(fmpz_t x, const fmpz_mod_poly_t poly,
+                                              slong n, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_set_coeff_mpz(fmpz_mod_poly_t poly,
+-                             slong n, const mpz_t x, const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_get_coeff_mpz(mpz_t x,
+-                 const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx)
+-
+-
+     void _fmpz_mod_poly_shift_left(fmpz * res, const fmpz * poly,
+                                                            slong len, slong n)
+ 
+@@ -194,14 +187,6 @@ cdef extern from "flint_wrap.h":
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_div_basecase(fmpz_mod_poly_t Q,
+-                            const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_div_newton_n_preinv(fmpz_mod_poly_t Q,
+-                         const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                         const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem_newton_n_preinv(fmpz_mod_poly_t Q,
+           fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                          const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+@@ -213,10 +198,6 @@ cdef extern from "flint_wrap.h":
+                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_divrem_divconquer(fmpz_mod_poly_t Q,
+-        fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem(fmpz_mod_poly_t Q, fmpz_mod_poly_t R,
+     const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+@@ -254,40 +235,13 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_make_monic_f(fmpz_t f, fmpz_mod_poly_t res,
+                          const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_euclidean(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_gcd_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_hgcd(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-
+     void fmpz_mod_poly_gcd(fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+ 
+-    void fmpz_mod_poly_xgcd_euclidean(fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_hgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S,
+-          fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_xgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                       const fmpz_mod_ctx_t ctx)
+@@ -361,14 +315,6 @@ cdef extern from "flint_wrap.h":
+                         const fmpz_mod_poly_t poly, const fmpz * xs, slong n,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_compose_horner(fmpz_mod_poly_t res,
+-                    const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_compose_divconquer(fmpz_mod_poly_t res,
+-                     const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_compose(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1,
+                          const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx)
+ 
+diff --git a/src/sage/libs/flint/fmpz_poly.pxd b/src/sage/libs/flint/fmpz_poly.pxd
+index 18b36672d30..c8bc6d3ca0a 100644
+--- a/src/sage/libs/flint/fmpz_poly.pxd
++++ b/src/sage/libs/flint/fmpz_poly.pxd
+@@ -28,7 +28,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_poly_set_ui(fmpz_poly_t, ulong)
+     void fmpz_poly_set_si(fmpz_poly_t, slong)
+     void fmpz_poly_set_fmpz(fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+     int fmpz_poly_set_str(fmpz_poly_t, const char *)
+ 
+     char *fmpz_poly_get_str(const fmpz_poly_t)
+@@ -70,7 +69,6 @@ cdef extern from "flint_wrap.h":
+     # Scalar multiplication and division
+     void fmpz_poly_scalar_mul_fmpz(
+             fmpz_poly_t, const fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+     void fmpz_poly_scalar_mul_si(fmpz_poly_t, const fmpz_poly_t, slong)
+     void fmpz_poly_scalar_mul_ui(fmpz_poly_t, const fmpz_poly_t, ulong)
+     void fmpz_poly_scalar_mul_2exp(fmpz_poly_t, const fmpz_poly_t, ulong)
+@@ -310,12 +308,14 @@ cdef extern from "flint_wrap.h":
+             fmpz_poly_t,
+                     const fmpz_poly_t, const fmpz_t, const nmod_poly_t, int)
+ 
+-    # Some functions for backwards compatibility
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
+-    void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++
++# functions removed from flint but still needed in sage
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
++cdef void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++cdef void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+ 
+ 
+ # Wrapper Cython class
+diff --git a/src/sage/libs/flint/fmpz_poly.pyx b/src/sage/libs/flint/fmpz_poly.pyx
+index 74915b37612..cfcbea9090c 100644
+--- a/src/sage/libs/flint/fmpz_poly.pyx
++++ b/src/sage/libs/flint/fmpz_poly.pyx
+@@ -25,10 +25,10 @@ from cysignals.memory cimport sig_free
+ 
+ from sage.arith.long cimport pyobject_to_long
+ from sage.cpython.string cimport char_to_str, str_to_bytes
++from sage.libs.flint.fmpz cimport *
+ from sage.structure.sage_object cimport SageObject
+ from sage.rings.integer cimport Integer
+ 
+-
+ cdef class Fmpz_poly(SageObject):
+ 
+     def __cinit__(self):
+@@ -455,3 +455,44 @@ cdef class Fmpz_poly(SageObject):
+         """
+         from sage.rings.integer_ring import ZZ
+         return ZZ[var](self.list())
++
++
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_divexact_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_fdiv_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t poly, slong n, const mpz_t x):
++    cdef fmpz_t t
++    fmpz_init_set_readonly(t, x)
++    fmpz_poly_set_coeff_fmpz(poly, n, t)
++    fmpz_clear_readonly(t)
++
++cdef void fmpz_poly_get_coeff_mpz(mpz_t x, const fmpz_poly_t poly, slong n):
++    cdef fmpz_t t
++    fmpz_init(t)
++    fmpz_poly_get_coeff_fmpz(t, poly, n)
++    fmpz_get_mpz(x, t)
++    fmpz_clear(t)
++
++cdef void fmpz_poly_set_mpz(fmpz_poly_t poly, const mpz_t x):
++    fmpz_poly_fit_length(poly, 1)
++    fmpz_set_mpz(poly.coeffs, x)
++    _fmpz_poly_set_length(poly, 1)
++    _fmpz_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz_poly_q.pxd b/src/sage/libs/flint/fmpz_poly_q.pxd
+index 846542dc0d8..63c13355bf6 100644
+--- a/src/sage/libs/flint/fmpz_poly_q.pxd
++++ b/src/sage/libs/flint/fmpz_poly_q.pxd
+@@ -49,11 +49,7 @@ cdef extern from "flint_wrap.h":
+ 
+     #* Scalar multiplication and division ****************************************/
+     void fmpz_poly_q_scalar_mul_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_mul_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_mul_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+     void fmpz_poly_q_scalar_div_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_div_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_div_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+ 
+     #* Multiplication and division ***********************************************/
+     void fmpz_poly_q_mul(fmpz_poly_q_t rop, 
+@@ -67,9 +63,6 @@ cdef extern from "flint_wrap.h":
+     #* Derivative ****************************************************************/
+     void fmpz_poly_q_derivative(fmpz_poly_q_t rop, const fmpz_poly_q_t op)
+ 
+-    #* Evaluation ****************************************************************/
+-    int fmpz_poly_q_evaluate(mpq_t rop, const fmpz_poly_q_t f, const mpq_t a)
+-
+     #* Input and output **********************************************************/
+     int fmpz_poly_q_set_str(fmpz_poly_q_t rop, const char *s)
+     char * fmpz_poly_q_get_str(const fmpz_poly_q_t op)
+diff --git a/src/sage/libs/linbox/linbox_flint_interface.pyx b/src/sage/libs/linbox/linbox_flint_interface.pyx
+index 415cd473947..83547f91cd2 100644
+--- a/src/sage/libs/linbox/linbox_flint_interface.pyx
++++ b/src/sage/libs/linbox/linbox_flint_interface.pyx
+@@ -33,6 +33,7 @@ and C. Pernet. The functions available are:
+ #                  https://www.gnu.org/licenses/
+ # ****************************************************************************
+ 
++from sage.libs.gmp.types cimport mpz_t
+ from sage.libs.flint.types cimport fmpz_t
+ from sage.libs.flint.fmpz cimport fmpz_get_mpz, fmpz_set_mpz
+ from sage.libs.flint.fmpz_mat cimport fmpz_mat_entry, fmpz_mat_nrows, fmpz_mat_ncols
+@@ -80,11 +81,13 @@ cdef void fmpz_poly_set_linbox(fmpz_poly_t p, PolynomialRing_integer.Element& q)
+     (the .pxd file) in order to keep the header C-compatible
+     """
+     cdef size_t i
++    cdef mpz_t tmp
+ 
+     fmpz_poly_fit_length(p, q.size())
+ 
+     for i in range(q.size()):
+-        fmpz_poly_set_coeff_mpz(p, i, q[i].get_mpz_const())
++        tmp = q[i].get_mpz_const()
++        fmpz_poly_set_coeff_mpz(p, i, tmp)
+ 
+     _fmpz_poly_set_length(p, q.size())
+ 
+diff --git a/src/sage/matrix/matrix_complex_ball_dense.pyx b/src/sage/matrix/matrix_complex_ball_dense.pyx
+index 3f56772a663..b1ece8a0e7b 100644
+--- a/src/sage/matrix/matrix_complex_ball_dense.pyx
++++ b/src/sage/matrix/matrix_complex_ball_dense.pyx
+@@ -1,4 +1,4 @@
+-# distutils: libraries = ARB_LIBRARY
++# distutils: libraries = flint
+ r"""
+ Arbitrary precision complex ball matrices using Arb
+ 
+diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx
+index f4320fcd914..b36ee300990 100644
+--- a/src/sage/matrix/matrix_integer_sparse.pyx
++++ b/src/sage/matrix/matrix_integer_sparse.pyx
+@@ -847,6 +847,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+             sage: matrix(ZZ, 1, 1, sparse=True)._charpoly_linbox()
+             x
+         """
++        cdef mpz_t tmp
+         if self._nrows != self._ncols:
+             raise ArithmeticError('only valid for square matrix')
+ 
+@@ -869,7 +870,8 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         cdef size_t i
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+@@ -966,9 +968,11 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         sig_off()
+ 
+         cdef size_t i
++        cdef mpz_t tmp
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
+index a22ce3c5e53..15be37734af 100644
+--- a/src/sage/rings/complex_arb.pyx
++++ b/src/sage/rings/complex_arb.pyx
+@@ -1360,12 +1360,13 @@ cdef class ComplexBall(RingElement):
+             sage: CBF100(-3r)
+             -3.000000000000000000000000000000
+ 
+-            sage: ComplexBall(CBF100, 10^100)
+-            1.000000000000000000000000000000e+100
+             sage: ComplexBall(CBF100, CIF(1, 2))
+             1.000000000000000000000000000000 + 2.000000000000000000000000000000*I
+             sage: ComplexBall(CBF100, RBF(1/3), RBF(1))
+             [0.3333333333333333 +/- ...e-17] + 1.000000000000000000000000000000*I
++            sage: ComplexBall(CBF100, 10^100)
++            [1.000000000000000000000000000000e+100 +/- ...]
++
+             sage: NF.<a> = QuadraticField(-1, embedding=CC(0, -1))
+             sage: CBF(a)
+             -1.000000000000000*I
+@@ -3009,7 +3010,7 @@ cdef class ComplexBall(RingElement):
+             sage: CBF(1).rising_factorial(2**64)
+             [+/- ...e+347382171326740403407]
+             sage: ComplexBallField(128)(1).rising_factorial(2**64)
+-            [2.343691126796861348e+347382171305201285713 +/- ...e+347382171305201285694]
++            [2.34369112679686134...e+347382171305201285713 +/- ...]
+             sage: CBF(1/2).rising_factorial(CBF(2,3)) # abs tol 1e-15
+             [-0.123060451458124 +/- 3.06e-16] + [0.0406412631676552 +/- 7.57e-17]*I
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+index b888b31d214..621d86f9bb8 100644
+--- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+@@ -222,7 +222,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef unsigned long n
+         cdef Rational c
+         cdef list L1
+-        cdef mpq_t * L2
++        cdef fmpq_t q
+ 
+         Polynomial.__init__(self, parent, is_gen=is_gen)
+ 
+@@ -253,14 +253,11 @@ cdef class Polynomial_rational_flint(Polynomial):
+             L1 = [e if isinstance(e, Rational) else Rational(e) for e in x]
+             n  = <unsigned long> len(x)
+             sig_on()
+-            L2 = <mpq_t *> check_allocarray(n, sizeof(mpq_t))
++            fmpq_poly_fit_length(self._poly, n)
+             for deg from 0 <= deg < n:
+-                mpq_init(L2[deg])
+-                mpq_set(L2[deg], (<Rational> L1[deg]).value)
+-            fmpq_poly_set_array_mpq(self._poly, L2, n)
+-            for deg from 0 <= deg < n:
+-                mpq_clear(L2[deg])
+-            sig_free(L2)
++                fmpq_init_set_readonly(q, (<Rational> L1[deg]).value)
++                fmpq_poly_set_coeff_fmpq(self._poly, deg, q)
++                fmpq_clear_readonly(q)
+             sig_off()
+ 
+ #           deg = 0
+@@ -435,6 +432,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         utmost care.
+         """
+         cdef bint do_sig = _do_sig(self._poly)
++        cdef fmpz_t tmpfz
+ 
+         if isinstance(value, int):
+             if do_sig: sig_str("FLINT exception")
+@@ -442,7 +440,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+             if do_sig: sig_off()
+         elif isinstance(value, Integer):
+             if do_sig: sig_str("FLINT exception")
+-            fmpq_poly_set_coeff_mpz(self._poly, n, (<Integer> value).value)
++            fmpz_init_set_readonly(tmpfz, (<Integer> value).value)
++            fmpq_poly_set_coeff_fmpz(self._poly, n, tmpfz)
++            fmpz_clear_readonly(tmpfz)
+             if do_sig: sig_off()
+         elif isinstance(value, Rational):
+             if do_sig: sig_str("FLINT exception")
+@@ -492,7 +492,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef Polynomial_rational_flint f
+         cdef Rational r
+         cdef fmpz_t tmpfz
+-        cdef fmpq_t tmpfq
++        cdef fmpq_t tmpfq, tmpfq1
+         cdef RealBall arb_a, arb_z
+         cdef ComplexBall acb_a, acb_z
+ 
+@@ -508,13 +508,23 @@ cdef class Polynomial_rational_flint(Polynomial):
+             elif isinstance(a, Rational):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpq(r.value, self._poly, (<Rational> a).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> a).value)
++                fmpq_init(tmpfq1)
++                fmpq_poly_evaluate_fmpq(tmpfq1, self._poly, tmpfq)
++                fmpq_get_mpq(r.value, tmpfq1)
++                fmpq_clear(tmpfq1)
++                fmpq_clear_readonly(tmpfq)
+                 sig_off()
+                 return r
+             elif isinstance(a, Integer):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpz(r.value, self._poly, (<Integer> a).value)
++                fmpz_init_set_readonly(tmpfz, (<Integer> a).value)
++                fmpq_init(tmpfq)
++                fmpq_poly_evaluate_fmpz(tmpfq, self._poly, tmpfz)
++                fmpq_get_mpq(r.value, tmpfq)
++                fmpq_clear(tmpfq)
++                fmpz_clear_readonly(tmpfz)
+                 sig_off()
+                 return r
+             elif isinstance(a, int):
+@@ -1321,6 +1331,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         """
+         cdef Polynomial_rational_flint res
+         cdef bint do_sig
++        cdef fmpq_t tmpfq
+ 
+         if right == 0:
+             raise ZeroDivisionError("division by zero polynomial")
+@@ -1331,8 +1342,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+                 do_sig = _do_sig(self._poly)
+ 
+                 if do_sig: sig_str("FLINT exception")
+-                fmpq_poly_scalar_div_mpq(res._poly, self._poly,
+-                                                  (<Rational> QQ(right)).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> QQ(right)).value)
++                fmpq_poly_scalar_div_fmpq(res._poly, self._poly, tmpfq)
++                fmpq_clear_readonly(tmpfq)
+                 if do_sig: sig_off()
+                 return res
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+index 4c480673861..780549af062 100644
+--- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+@@ -658,6 +658,11 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
+             ...
+             NotImplementedError: square free factorization of polynomials over rings with composite characteristic is not implemented
+ 
++        :trac:`20003`::
++
++            sage: P.<x> = GF(7)[]
++            sage: (6*x+3).squarefree_decomposition()
++            (6) * (x + 4)
+         """
+         if not self.base_ring().is_field():
+             raise NotImplementedError("square free factorization of polynomials over rings with composite characteristic is not implemented")
+diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
+index 17859068273..14baa5bc5aa 100644
+--- a/src/sage/rings/real_arb.pyx
++++ b/src/sage/rings/real_arb.pyx
+@@ -898,7 +898,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+             sage: RBF.gamma(5)
+             24.00000000000000
+             sage: RBF.gamma(10**20)
+-            [+/- ...e+1956570552410610660600]
++            [1.932849514310098...+1956570551809674817225 +/- ...]
+             sage: RBF.gamma(1/3)
+             [2.678938534707747 +/- ...e-16]
+             sage: RBF.gamma(-5)
+@@ -1102,7 +1102,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+              15.00000000000000,
+              48.00000000000000]
+             sage: RBF.double_factorial(2**20)
+-            [1.4483729903e+2928836 +/- ...e+2928825]
++            [1.448372990...e+2928836 +/- ...]
+             sage: RBF.double_factorial(2**1000)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/schemes/plane_conics/con_rational_function_field.py b/src/sage/schemes/plane_conics/con_rational_function_field.py
+index 1b3f0ac412a..485c9c71be3 100644
+--- a/src/sage/schemes/plane_conics/con_rational_function_field.py
++++ b/src/sage/schemes/plane_conics/con_rational_function_field.py
+@@ -198,38 +198,6 @@ def has_rational_point(self, point=False, algorithm='default',
+             Fraction Field of Univariate Polynomial Ring in u over Rational
+             Field with modulus v^2 - u^3 - 1
+ 
+-        ``has_rational_point`` fails for some conics over function fields
+-        over finite fields, due to :trac:`20003`::
+-
+-            sage: K.<t> = PolynomialRing(GF(7))
+-            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
+-            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
+-            sage: C.has_rational_point()
+-            Traceback (most recent call last):
+-            ...
+-            TypeError: self (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (-t^3 + 3*t^2 - 2*t - 2)/(t + 3)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (t^2 + 3*t + 3)*x*y + (-2*t^2 - 2)*y^2 + (-t^2 + 3*t + 2)*x*z + (-3*t + 3)*y*z + (-3*t^2 + t - 2)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x + (2*t - 2)/(t + 3)*y + (3*t^4 + 2*t^3 - 2*t^2 - 2*t + 3)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z
+-                     : y + (-t^3 - t^2 + 3*t - 1)/(t^3 - 3*t^2 + 2*t + 2)*z : z))
+-            domain must equal right (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^3 - t^2 + 3*t + 3)*x^2 + (t - 3)*y^2 + (-t^7 + 2*t^5 + t^4 + 2*t^3 + 3*t^2 - t - 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    -2/(t^3 - 3*t^2 + 2*t + 2)*x^2 + 1/(t^3 + 3*t^2 - 2*t + 1)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^9 - 2*t^8 + t^7 - t^6 + 3*t^5 - 3*t^3 + t^2 - 2*t + 3)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    ((t^3 - 3*t^2 + 2*t + 2)*x : (t^2 - 2)*y : (t^5 - 3*t^4 + t^2 + 3*t + 3)*z))
+-            codomain
+-
+-
+-
+         TESTS::
+ 
+             sage: K.<t> = FractionField(PolynomialRing(QQ, 't'))
+@@ -250,6 +218,16 @@ def has_rational_point(self, point=False, algorithm='default',
+             sage: C.has_rational_point(point = True) # long time (4 seconds)
+             (True,
+              ((-2/117*t^8 + 304/1053*t^7 + 40/117*t^6 - 1/27*t^5 - 110/351*t^4 - 2/195*t^3 + 11/351*t^2 + 1/117)/(t^4 + 2/39*t^3 + 4/117*t^2 + 2/39*t + 14/39) : -5/3*t^4 + 19*t^3 : 1))
++
++        ``has_rational_point`` used to fail for some conics over function fields
++        over finite fields, due to :trac:`20003`::
++
++            sage: K.<t> = PolynomialRing(GF(7))
++            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
++            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
++            sage: C.has_rational_point()
++            True
++
+         """
+         from .constructor import Conic
+ 
+diff --git a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+index a591cb4cd7c..a90f2050c59 100644
+--- a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
++++ b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+@@ -20,6 +20,7 @@
+ #include "utils.h"
+ 
+ #include "gmp.h"
++#include "flint/fmpz_poly.h"
+ #include "flint/fmpq_poly.h"
+ #include "flint/fmpq.h"
+ 
+@@ -63,7 +64,7 @@ static ex chebyt_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+@@ -122,7 +123,7 @@ static ex chebyu_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+diff --git a/src/sage/symbolic/ginac/useries.cpp b/src/sage/symbolic/ginac/useries.cpp
+index 40fbd7ab360..b9a8b867648 100644
+--- a/src/sage/symbolic/ginac/useries.cpp
++++ b/src/sage/symbolic/ginac/useries.cpp
+@@ -467,10 +467,17 @@ void add::useries(flint_series_t& fp, int order) const
+                 fmpq_poly_set_ui(fp.ft, 0);
+         else if (oc.is_long())
+                 fmpq_poly_set_si(fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ 
+         for (const auto & elem : seq) {
+ 		const ex& t = recombine_pair_to_ex(elem);
+@@ -505,10 +512,17 @@ void mul::useries(flint_series_t& fp, int order) const
+ 
+         if (oc.is_long())
+                 fmpq_poly_scalar_mul_si(fp.ft, fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_scalar_mul_mpz(fp.ft, fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_scalar_mul_mpq(fp.ft, fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_scalar_mul_fmpz(fp.ft, fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp.ft, fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ void power::useries(flint_series_t& fp, int order) const
+@@ -563,7 +577,10 @@ void power::useries(flint_series_t& fp, int order) const
+                 }
+                 check_poly_ccoeff_one(fp1);
+                 fmpq_poly_log_series(fp1.ft, fp1.ft, order);
+-                fmpq_poly_scalar_mul_mpq(fp1.ft, fp1.ft, nexp.as_mpq());
++                fmpq_t tmp;
++                fmpq_init_set_readonly(tmp, nexp.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp1.ft, fp1.ft, tmp);
++                fmpq_clear_readonly(tmp);
+                 fmpq_poly_exp_series(fp.ft, fp1.ft, order);
+                 return;
+         }
+@@ -608,10 +625,17 @@ void numeric::useries(flint_series_t& fp, int order) const
+ {
+         if (is_long())
+                 fmpq_poly_set_si(fp.ft, to_long());
+-        else if (is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, as_mpq());
++        else if (is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ } // namespace GiNaC
+diff --git a/src/sage_setup/library_order.py b/src/sage_setup/library_order.py
+index f40690f8d22..9ae0d2579a7 100644
+--- a/src/sage_setup/library_order.py
++++ b/src/sage_setup/library_order.py
+@@ -16,17 +16,12 @@
+ 
+ aliases = cython_aliases(required_modules=(), optional_modules=modules)
+ 
+-if "ARB_LIBRARY" in aliases:
+-    arb_dylib_names = [aliases["ARB_LIBRARY"]]
+-else:
+-    arb_dylib_names = []
+-
+ library_order_list = aliases.get("SINGULAR_LIBRARIES", []) + [
+     "giac", "intl", "curl",
+     "ec", "ecm"
+ ] + aliases.get("LINBOX_LIBRARIES", []) + aliases.get("FFLASFFPACK_LIBRARIES", []) + aliases.get("GSL_LIBRARIES", []) + [
+     "pari", "flint", "ecl", "glpk", "ppl",
+-] + arb_dylib_names + [
++] + [
+     "mpfi", "mpfr", "mpc", "ntl", "gmp", "gmpxx",
+     "brial",
+     "brial_groebner",
diff --git a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch b/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
deleted file mode 100644
index 7c55bce6e9bb4..0000000000000
--- a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
+++ /dev/null
@@ -1,221 +0,0 @@
-diff --git a/build/pkgs/singular/checksums.ini b/build/pkgs/singular/checksums.ini
-index 313463d2fea..1101fc55700 100644
---- a/build/pkgs/singular/checksums.ini
-+++ b/build/pkgs/singular/checksums.ini
-@@ -1,5 +1,5 @@
- tarball=singular-VERSION.tar.gz
--sha1=28bb3ee97ef48d04dfa96de182fd93eebe08426c
--md5=fc0a4f5720dadba45a52ee94324ce00c
--cksum=1573851737
--upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-1/singular-VERSION.tar.gz
-+sha1=df1997f412580f2073295aba569bb955ad227317
-+md5=50349213e206a18cdaa1bc410dde7ea4
-+cksum=376854707
-+upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-2/singular-VERSION.tar.gz
-diff --git a/build/pkgs/singular/package-version.txt b/build/pkgs/singular/package-version.txt
-index 66e2bede53a..9f1bf008217 100644
---- a/build/pkgs/singular/package-version.txt
-+++ b/build/pkgs/singular/package-version.txt
-@@ -1 +1 @@
--4.3.1p3
-+4.3.2p7
-diff --git a/build/pkgs/singular/spkg-configure.m4 b/build/pkgs/singular/spkg-configure.m4
-index 6a85631f624..f7621ec5fa1 100644
---- a/build/pkgs/singular/spkg-configure.m4
-+++ b/build/pkgs/singular/spkg-configure.m4
-@@ -6,14 +6,27 @@ SAGE_SPKG_CONFIGURE([singular], [
-     AS_IF([test -z "${SINGULAR_BIN}"], [sage_spkg_install_singular=yes], [
-       dnl Use pkg-config to ensure that Singular is new enough.
-       PKG_CHECK_MODULES([SINGULAR], [Singular >= 4.2.1], [
--       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)
--       ], [
--       AC_MSG_RESULT(no)
--       sage_spkg_install_singular=yes
--       ]
--      )], [
-+        AC_MSG_CHECKING([whether Singular is built with FLINT])
-+        AC_COMPILE_IFELSE([
-+          AC_LANG_PROGRAM([
-+            #include <singular/singularconfig.h>
-+            #if !defined(HAVE_FLINT)
-+            #  error "Need Singular compiled with FLINT"
-+          ], [])
-+        ], [
-+          AC_MSG_RESULT([yes])
-+          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)
-+          ], [
-+            AC_MSG_RESULT(no)
-+            sage_spkg_install_singular=yes
-+          ])
-+        ], [
-+          AC_MSG_RESULT([no])
-+          sage_spkg_install_singular=yes
-+        ])
-+      ], [
-       dnl pkg-config version check failed
-       sage_spkg_install_singular=yes
-       ])
-diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py
-index b15cc1c602c..4b5c76e2bfa 100644
---- a/src/sage/interfaces/singular.py
-+++ b/src/sage/interfaces/singular.py
-@@ -604,8 +604,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: i = singular.ideal(['x^2','y^2','z^2'])
-             sage: s = i.std()
-             sage: singular.eval('hilb(%s)'%(s.name()))
--            '// 1 t^0\n// -3 t^2\n// 3 t^4\n// -1 t^6\n\n// 1 t^0\n//
--            3 t^1\n// 3 t^2\n// 1 t^3\n// dimension (affine) = 0\n//
-+            '...// dimension (affine) = 0\n//
-             degree (affine) = 8'
- 
-         ::
-@@ -613,15 +612,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: from sage.misc.verbose import set_verbose
-             sage: set_verbose(1)
-             sage: o = singular.eval('hilb(%s)'%(s.name()))
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
- 
-         This is mainly useful if this method is called implicitly. Because
-@@ -631,15 +622,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-         ::
- 
-             sage: o = s.hilb()
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
-             // ** right side is not a datum, assignment ignored
-             ...
-diff --git a/src/sage/libs/singular/function.pyx b/src/sage/libs/singular/function.pyx
-index f40346d1fd0..c597c63aafe 100644
---- a/src/sage/libs/singular/function.pyx
-+++ b/src/sage/libs/singular/function.pyx
-@@ -1241,32 +1241,22 @@ cdef class SingularFunction(SageObject):
-             sage: I = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5])
-             sage: I = Ideal(I.groebner_basis())
-             sage: hilb = sage.libs.singular.function_factory.ff.hilb
--            sage: hilb(I) # Singular will print // ** _ is no standard basis
--            // ** _ is no standard basis
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: from sage.misc.sage_ostools import redirection
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I) # Singular will print // ** _ is no standard basis
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            True
- 
-         So we tell Singular that ``I`` is indeed a Groebner basis::
- 
--            sage: hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            False
- 
- 
-         TESTS:
-diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-index 22ada6de947..80352700872 100644
---- a/src/sage/rings/polynomial/multi_polynomial_ideal.py
-+++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-@@ -3132,13 +3132,16 @@ def hilbert_numerator(self, grading=None, algorithm='sage'):
-             sage: I.hilbert_numerator()                                                 # needs sage.rings.number_field
-             -t^5 + 1
- 
--        This example returns a wrong answer due to an integer overflow in Singular::
-+        This example returns a wrong answer in singular < 4.3.2p4 due to an integer overflow::
- 
-             sage: n=4; m=11; P = PolynomialRing(QQ, n*m, "x"); x = P.gens(); M = Matrix(n, x)
-             sage: I = P.ideal(M.minors(2))
-             sage: J = P * [m.lm() for m in I.groebner_basis()]
--            sage: J.hilbert_numerator(algorithm='singular')
--            ...120*t^33 - 3465*t^32 + 48180*t^31 - ...
-+            sage: J.hilbert_numerator(algorithm='singular') # known bug
-+            Traceback (most recent call last):
-+            ....
-+            RuntimeError: error in Singular function call 'hilb':
-+            overflow at t^22
- 
-         Our two algorithms should always agree; not tested until
-         :trac:`33178` is fixed::
-diff --git a/src/sage/sandpiles/sandpile.py b/src/sage/sandpiles/sandpile.py
-index 02d2021b2fb..c8e15e06f05 100644
---- a/src/sage/sandpiles/sandpile.py
-+++ b/src/sage/sandpiles/sandpile.py
-@@ -2493,9 +2493,15 @@ def _set_ideal(self):
-             sage: '_ideal' in S.__dict__
-             True
-         """
-+        from sage.libs.singular.function_factory import ff
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
-         R = self.ring()
--        I = self._unsaturated_ideal._singular_()
--        self._ideal = R.ideal(I.sat(prod(R.gens())._singular_())[1])
-+        I = self._unsaturated_ideal
-+        I_sat_gens = sat(I, prod(R.gens()))[0]
-+        self._ideal = R.ideal(I_sat_gens)
- 
-     def unsaturated_ideal(self):
-         r"""
-diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py
-index e6caf19ba74..afd6484d779 100644
---- a/src/sage/schemes/projective/projective_subscheme.py
-+++ b/src/sage/schemes/projective/projective_subscheme.py
-@@ -1001,7 +1001,10 @@ def dual(self):
-         for i in range(n + 1):
-             J = J + S.ideal(z[-1] * f_S.derivative(z[i]) - z[i + n + 1])
- 
--        sat = ff.elim__lib.sat
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
- 
-         max_ideal = S.ideal(z[n + 1: 2 * n + 2])
-         J_sat_gens = sat(J, max_ideal)[0]
diff --git a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch b/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
deleted file mode 100644
index 6a35ec3836550..0000000000000
--- a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-diff --git a/src/sage/ext/memory.pyx b/src/sage/ext/memory.pyx
-index 1de6dedab82..b95130b19dd 100644
---- a/src/sage/ext/memory.pyx
-+++ b/src/sage/ext/memory.pyx
-@@ -3,14 +3,14 @@ Low-level memory allocation functions
- 
- TESTS:
- 
--Check that a ``MemoryError`` is raised if we try to allocate a
-+Check that an error is raised if we try to allocate a
- ridiculously large integer, see :trac:`15363`::
- 
--    sage: 2^(2^63-3)
--    Traceback (most recent call last):
--    ...
--    OverflowError: exponent must be at most 2147483647         # 32-bit
--    RuntimeError: Aborted                                      # 64-bit
-+    sage: try:
-+    ....:     2^(2^63-3)
-+    ....: except (OverflowError, RuntimeError, FloatingPointError):
-+    ....:     print ('Overflow error')
-+    ...Overflow error
- 
- AUTHORS:
- 
-diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx
-index d5e87626d31..37ed9364845 100644
---- a/src/sage/rings/integer.pyx
-+++ b/src/sage/rings/integer.pyx
-@@ -6654,7 +6654,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
-             sage: try:
-             ....:     print('Possible error output from gmp', flush=True)
-             ....:     1 << (2^60)
--            ....: except (MemoryError, OverflowError, RuntimeError):
-+            ....: except (MemoryError, OverflowError, RuntimeError, FloatingPointError):
-             ....:     pass
-             ....: else:
-             ....:     print("Failed to raise exception")
diff --git a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch b/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
deleted file mode 100644
index 3d2a4bd9cd96f..0000000000000
--- a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
+++ /dev/null
@@ -1,740 +0,0 @@
-diff --git a/src/sage/ext_data/valgrind/valgrind-python.supp b/src/sage/ext_data/valgrind/valgrind-python.supp
-new file mode 100644
-index 00000000000..16aa2858484
---- /dev/null
-+++ b/src/sage/ext_data/valgrind/valgrind-python.supp
-@@ -0,0 +1,480 @@
-+# From the CPython repository with the suppressions for _PyObject_Free
-+# and _PyObject_Realloc enabled. See the upstream suppression file for
-+# details:
-+#
-+# https://github.com/python/cpython/blob/main/Misc/valgrind-python.supp
-+
-+# all tool names: Addrcheck,Memcheck,cachegrind,helgrind,massif
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 8 (x86_64 aka amd64)
-+   Memcheck:Value8
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:address_in_range
-+}
-+
-+#
-+# Leaks (including possible leaks)
-+#    Hmmm, I wonder if this masks some real leaks.  I think it does.
-+#    Will need to fix that.
-+#
-+
-+{
-+   Suppress leaking the GIL after a fork.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_allocate_lock
-+   fun:PyEval_ReInitThreads
-+}
-+
-+{
-+   Suppress leaking the autoTLSkey.  This looks like it shouldn't leak though.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_create_key
-+   fun:_PyGILState_Init
-+   fun:Py_InitializeEx
-+   fun:Py_Main
-+}
-+
-+{
-+   Hmmm, is this a real leak or like the GIL?
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_ReInitTLS
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:realloc
-+   fun:_PyObject_GC_Resize
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_New
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_NewVar
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+#
-+# Non-python specific leaks
-+#
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:calloc
-+   fun:allocate_dtv
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:memalign
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Realloc
-+}
-+
-+###
-+### All the suppressions below are for errors that occur within libraries
-+### that Python uses.  The problems to not appear to be related to Python's
-+### use of the libraries.
-+###
-+
-+{
-+   Generic ubuntu ld problems
-+   Memcheck:Addr8
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+}
-+
-+{
-+   Generic gentoo ld problems
-+   Memcheck:Cond
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_close
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Value8
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   GDBM problems, see test_gdbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   fun:gdbm_open
-+
-+}
-+
-+{
-+   Uninitialised byte(s) false alarm, see bpo-35561
-+   Memcheck:Param
-+   epoll_ctl(event)
-+   fun:epoll_ctl
-+   fun:pyepoll_internal_ctl
-+}
-+
-+{
-+   ZLIB problems, see test_gzip
-+   Memcheck:Cond
-+   obj:/lib/libz.so.1.2.3
-+   obj:/lib/libz.so.1.2.3
-+   fun:deflate
-+}
-+
-+{
-+   Avoid problems w/readline doing a putenv and leaking on exit
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:xmalloc
-+   fun:sh_set_lines_and_columns
-+   fun:_rl_get_screen_size
-+   fun:_rl_init_terminal_io
-+   obj:/lib/libreadline.so.4.3
-+   fun:rl_initialize
-+}
-+
-+# Valgrind emits "Conditional jump or move depends on uninitialised value(s)"
-+# false alarms on GCC builtin strcmp() function. The GCC code is correct.
-+#
-+# Valgrind bug: https://bugs.kde.org/show_bug.cgi?id=264936
-+{
-+   bpo-38118: Valgrind emits false alarm on GCC builtin strcmp()
-+   Memcheck:Cond
-+   fun:PyUnicode_Decode
-+}
-+
-+
-+###
-+### These occur from somewhere within the SSL, when running
-+###  test_socket_sll.  They are too general to leave on by default.
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:memset
-+###}
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:memset
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:MD5_Update
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:MD5_Update
-+###}
-+
-+# Fedora's package "openssl-1.0.1-0.1.beta2.fc17.x86_64" on x86_64
-+# See http://bugs.python.org/issue14171
-+{
-+   openssl 1.0.1 prng 1
-+   Memcheck:Cond
-+   fun:bcmp
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 2
-+   Memcheck:Cond
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 3
-+   Memcheck:Value8
-+   fun:_x86_64_AES_encrypt_compact
-+   fun:AES_encrypt
-+}
-+
-+#
-+# All of these problems come from using test_socket_ssl
-+#
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_bin2bn
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libcrypto.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_set_key_unchecked
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_encrypt2
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BUF_MEM_grow_clean
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:memcpy
-+   fun:ssl3_read_bytes
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:SHA1_Update
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:SHA1_Update
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-+{
-+   wcscmp_false_positive
-+   Memcheck:Addr8
-+   fun:wcscmp
-+   fun:_PyOS_GetOpt
-+   fun:Py_Main
-+   fun:main
-+}
-+
-+# Additional suppressions for the unified decimal tests:
-+{
-+   test_decimal
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_decimal2
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index b40ed64edb5..8c55861c147 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -1576,6 +1576,62 @@ const numeric numeric::div(const numeric &other) const {
-         }
- }
- 
-+
-+// Compute `a^b` as an integer, where a is an integer. Assign to ``res``` if it is integral, or return ``false``.
-+// The nonnegative real root is taken for even denominators. To be used inside numeric::integer_rational_power,
-+// to handle the special case of integral ``a``.
-+bool integer_rational_power_of_mpz(
-+        numeric& res,
-+        const numeric& a,
-+        const numeric& b
-+) {
-+        if (a.t != MPZ)
-+                throw std::runtime_error("integer_rational_power_of_mpz: bad input");
-+        mpz_t z;
-+        mpz_init(z);
-+        mpz_set_ui(z, 0);
-+        int sgn = mpz_sgn(a.v._bigint);
-+        if (mpz_cmp_ui(a.v._bigint, 1) == 0
-+            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
-+                mpz_set_ui(z, 1);
-+        else if (sgn == 0) {
-+                res = *_num0_p;
-+                mpz_clear(z);
-+                return true;
-+        }
-+        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1)) {
-+                mpz_clear(z);
-+                return false;
-+        } else {
-+                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-+                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat))) {
-+                        // too big to take roots/powers
-+                        mpz_clear(z);
-+                        return false;
-+                }
-+                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
-+                        if (mpz_perfect_square_p(a.v._bigint)) {
-+                                mpz_sqrt(z, a.v._bigint);
-+                        } else {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                else {
-+                        bool exact = mpz_root(z, a.v._bigint,
-+                                              mpz_get_ui(mpq_denref(b.v._bigrat)));
-+                        if (not exact) {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
-+        }
-+        res = numeric(z);   // transfers ownership, no mpz_clear
-+        return true;
-+}
-+
-+
- // Compute `a^b` as an integer, if it is integral, or return ``false``.
- // The nonnegative real root is taken for even denominators.
- bool numeric::integer_rational_power(numeric& res,
-@@ -1598,13 +1654,12 @@ bool numeric::integer_rational_power(numeric& res,
-                 if (a.v._long < 0
-                     and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
-                         return false;
--                long z;
-                 if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-                     or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
-                 // too big to take roots/powers
-                         return false;
-                 if (b.is_equal(*_num1_2_p)) {
--                        z = std::lround(std::sqrt(a.v._long));
-+                        long z = std::lround(std::sqrt(a.v._long));
-                         if (a.v._long == z*z) {
-                                 res = numeric(z);
-                                 return true;
-@@ -1613,44 +1668,11 @@ bool numeric::integer_rational_power(numeric& res,
-                 }
-                 return integer_rational_power(res, a.to_bigint(), b);
-         }
--        if (a.t != MPZ)
--                throw std::runtime_error("integer_rational_power: bad input");
--        int sgn = mpz_sgn(a.v._bigint);
--        mpz_t z;
--        mpz_init(z);
--        mpz_set_ui(z, 0);
--        if (mpz_cmp_ui(a.v._bigint, 1) == 0
--            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
--                mpz_set_ui(z, 1);
--        else if (sgn == 0) {
--                res = *_num0_p;
--                return true;
--        }
--        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
--                return false;
--        else {
--                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
--                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
--                // too big to take roots/powers
--                        return false;
--                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
--                        if (mpz_perfect_square_p(a.v._bigint))
--                                mpz_sqrt(z, a.v._bigint);
--                        else
--                                return false;
--                }
--                else {
--                        bool exact = mpz_root(z, a.v._bigint,
--                                        mpz_get_ui(mpq_denref(b.v._bigrat)));
--                        if (not exact)
--                                return false;
--                }
--                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
--        }
--        res = numeric(z);
--        return true;
-+        // otherwise: a is integer
-+        return integer_rational_power_of_mpz(res, a, b);
- }
- 
-+
- // for a^b return c,d such that a^b = c*d^b
- // only for MPZ/MPQ base and MPQ exponent
- void rational_power_parts(const numeric& a_orig, const numeric& b_orig,
-diff --git a/src/sage/tests/memcheck/__init__.py b/src/sage/tests/memcheck/__init__.py
-new file mode 100644
-index 00000000000..e69de29bb2d
-diff --git a/src/sage/tests/memcheck/run_tests.py b/src/sage/tests/memcheck/run_tests.py
-new file mode 100644
-index 00000000000..6ff4503a81b
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests.py
-@@ -0,0 +1,24 @@
-+import types
-+
-+
-+def run_tests() -> None:
-+    """
-+    Run all memcheck tests
-+    """
-+    from sage.tests.memcheck import symbolic_expression
-+    run_tests_in_module(symbolic_expression)
-+
-+
-+def run_tests_in_module(mod: types.ModuleType) -> None:
-+    """
-+    Run all memcheck tests in the given module
-+    """
-+    for entry in dir(mod):
-+        if not entry.startswith('test_'):
-+            continue
-+        test_func = getattr(mod, entry)
-+        test_func()
-+
-+
-+if __name__ == '__main__':
-+    run_tests()
-diff --git a/src/sage/tests/memcheck/run_tests_in_valgrind.py b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-new file mode 100644
-index 00000000000..df5ad0e92b2
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-@@ -0,0 +1,35 @@
-+"""
-+Launch valgrind and run the memory leak tests
-+
-+
-+From the commandline, run
-+
-+    sage -python -m sage.tests.memcheck.run_tests_in_valgrind
-+
-+to launch valgrind and execute the memory leak tests. Requires valgrind
-+to be installed. Alternatively, run as a unit test:
-+
-+    sage: from sage.tests.memcheck.run_tests_in_valgrind import run_tests_in_valgrind
-+    sage: run_tests_in_valgrind()    # optional - valgrind
-+"""
-+
-+import subprocess
-+
-+
-+def run_tests_in_valgrind() -> None:
-+    """
-+    Run the sage.tests.memcheck.run_tests module inside valgrind
-+    """
-+    subprocess.check_call([
-+        'valgrind',
-+        '--suppressions=src/sage/ext_data/valgrind/valgrind-python.supp',
-+        '--show-possibly-lost=no',
-+        '--show-reachable=no',
-+        './venv/bin/python',
-+        '-m',
-+        'sage.tests.memcheck.run_tests'
-+    ])
-+
-+
-+if __name__ == '__main__':
-+    run_tests_in_valgrind()
-diff --git a/src/sage/tests/memcheck/symbolic_expression.py b/src/sage/tests/memcheck/symbolic_expression.py
-new file mode 100644
-index 00000000000..52182fbe62d
---- /dev/null
-+++ b/src/sage/tests/memcheck/symbolic_expression.py
-@@ -0,0 +1,11 @@
-+from sage.tests.memcheck.verify_no_leak import verify_no_leak
-+
-+
-+def test_sqrt_sqrt_2() -> None:
-+    from sage.misc.functional import sqrt
-+    T2 = sqrt(2)
-+
-+    def sqrt_T2() -> None:
-+        sqrt(T2)
-+
-+    verify_no_leak(sqrt_T2)
-diff --git a/src/sage/tests/memcheck/verify_no_leak.py b/src/sage/tests/memcheck/verify_no_leak.py
-new file mode 100644
-index 00000000000..89ca90cf89c
---- /dev/null
-+++ b/src/sage/tests/memcheck/verify_no_leak.py
-@@ -0,0 +1,27 @@
-+from typing import Tuple, Sequence, List, Callable, Any
-+import valgrind
-+
-+
-+def verify_no_leak(callback: Callable[[], Any],
-+                   repeat: int = 10000,
-+                   fuzzy: int = 10,
-+                   ) -> None:
-+    """
-+    Verify that the callback does not generate new definitely lost blocks
-+
-+    Raises an assertion if the callback leaks memory
-+    """
-+    callback()   # warm_up
-+    initial_blocks = (0, 0, 0, 0)
-+    valgrind.memcheck_do_leak_check()
-+    initial_blocks = valgrind.memcheck_count_leak_blocks()
-+    for _ in range(repeat):
-+        callback()
-+    valgrind.memcheck_do_leak_check()
-+    leak_blocks = valgrind.memcheck_count_leak_blocks()
-+    leak = leak_blocks[0] - initial_blocks[0]
-+    if leak < repeat - fuzzy:
-+        return  # callback did not leak at least once per call
-+    blocks = round(leak / repeat, 2)
-+    message = f'{callback} leaked {blocks} block on average ({repeat} iterations)'
-+    raise AssertionError(message)
diff --git a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch b/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
deleted file mode 100644
index 684b62affaf5a..0000000000000
--- a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx
-index 8f46570313d..a8e73e57b52 100644
---- a/src/sage/libs/ecl.pyx
-+++ b/src/sage/libs/ecl.pyx
-@@ -563,15 +563,15 @@ cdef class EclObject:
-     Floats in Python are IEEE double, which LISP has as well. However,
-     the printing of floating point types in LISP depends on settings::
- 
--        sage: a = EclObject(float(10^40))
-+        sage: a = EclObject(float(1.234e40))
-         sage: ecl_eval("(setf *read-default-float-format* 'single-float)")
-         <ECL: SINGLE-FLOAT>
-         sage: a
--        <ECL: 1.d40>
-+        <ECL: 1.234d40>
-         sage: ecl_eval("(setf *read-default-float-format* 'double-float)")
-         <ECL: DOUBLE-FLOAT>
-         sage: a
--        <ECL: 1.e40>
-+        <ECL: 1.234e40>
- 
-     Tuples are translated to dotted lists::
- 
-diff --git a/src/sage/libs/eclsig.h b/src/sage/libs/eclsig.h
-index e249ccf6874..005b2d99d0b 100644
---- a/src/sage/libs/eclsig.h
-+++ b/src/sage/libs/eclsig.h
-@@ -45,7 +45,11 @@ static inline void ecl_sig_off(void)
-     sig_off();
- }
- 
-+#if ECL_VERSION_NUMBER < 230909
- #define ecl_mpz_from_bignum(obj) ((obj)->big.big_num)
-+#else
-+#define ecl_mpz_from_bignum(obj) ecl_bignum(obj)
-+#endif
- 
- cl_object ecl_bignum_from_mpz(mpz_t num)
- {
diff --git a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch b/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
deleted file mode 100644
index e858f2fd4a445..0000000000000
--- a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
-index 59f10f6b13f..adcccff059b 100644
---- a/src/sage/plot/graphics.py
-+++ b/src/sage/plot/graphics.py
-@@ -36,6 +36,7 @@
- # ****************************************************************************
- 
- import os
-+from numbers import Integral
- from collections.abc import Iterable
- from math import isnan
- import sage.misc.verbose
-@@ -2874,6 +2875,11 @@ def matplotlib(self, filename=None,
-                 weight=lopts.pop('font_weight', 'medium'),
-                 variant=lopts.pop('font_variant', 'normal'))
-             color = lopts.pop('back_color', 'white')
-+            if 'loc' in lopts:
-+                loc = lopts['loc']
-+                if isinstance(loc, Integral):
-+                    # matplotlib 3.8 doesn't support sage integers
-+                    lopts['loc'] = int(loc)
-             leg = subplot.legend(prop=prop, **lopts)
-             if leg is None:
-                 from warnings import warn
diff --git a/srcpkgs/sagemath/patches/36403-00pre.patch b/srcpkgs/sagemath/patches/36403-00pre.patch
deleted file mode 100644
index 060404d5430de..0000000000000
--- a/srcpkgs/sagemath/patches/36403-00pre.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-Minor patch so that #36403 applies cleanly over sagemath 10.1
-
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 2053bca80c3..86aca6e00d8 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15123,7 +15302,8 @@ cdef class Matrix(Matrix1):
-             sage: N.conjugate_transpose()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object has no attribute 'conjugate'
-+            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
-+            has no attribute 'conjugate'
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 525ea5aa934..52afed49d64 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -55,7 +55,7 @@ cdef class AttributeErrorMessage:
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-         sage: x = polygen(ZZ, 'x')
--        sage: QQ[x].gen().bla                                                           # optional - sage.libs.flint
-+        sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
diff --git a/srcpkgs/sagemath/patches/36407-python_3.12.patch b/srcpkgs/sagemath/patches/36407-python_3.12.patch
deleted file mode 100644
index c75c275c30764..0000000000000
--- a/srcpkgs/sagemath/patches/36407-python_3.12.patch
+++ /dev/null
@@ -1,1744 +0,0 @@
-diff --git a/build/sage_bootstrap/package.py b/build/sage_bootstrap/package.py
-index 15b342223c4..eb82f96e05f 100644
---- a/build/sage_bootstrap/package.py
-+++ b/build/sage_bootstrap/package.py
-@@ -303,7 +303,7 @@ def _init_checksum(self):
-         # Name of the directory containing the checksums.ini file
-         self.__tarball_package_name = os.path.realpath(checksums_ini).split(os.sep)[-2]
- 
--    VERSION_PATCHLEVEL = re.compile('(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
-+    VERSION_PATCHLEVEL = re.compile(r'(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
- 
-     def _init_version(self):
-         try:
-diff --git a/src/doc/en/thematic_tutorials/coercion_and_categories.rst b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-index bb23331c151..7f5712caea7 100644
---- a/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-+++ b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-@@ -1223,7 +1223,7 @@ However, only "elementary" construction functors have a rank::
-     sage: (Fract*Poly).rank
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'
-+    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'...
- 
- .. end of output
- 
-diff --git a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-index 553a946c4d8..3cd71a9bad4 100644
---- a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-+++ b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-@@ -318,7 +318,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: e.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'...
- 
-         sage: id4 = SymmetricGroup(4).one()
-         sage: type(id4)
-@@ -326,7 +326,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: id4.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'
-+        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'...
- 
- .. note::
- 
-diff --git a/src/sage/algebras/cluster_algebra.py b/src/sage/algebras/cluster_algebra.py
-index b72d2a12976..14669dfed5c 100644
---- a/src/sage/algebras/cluster_algebra.py
-+++ b/src/sage/algebras/cluster_algebra.py
-@@ -167,7 +167,7 @@
-     sage: (t*s).g_vector()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'
-+    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'...
-     sage: A = ClusterAlgebra(['A', 2], principal_coefficients=True)
-     sage: A.explore_to_depth(infinity)
-     sage: s = A.cluster_variable((0, -1)); s
-diff --git a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-index e4a91723558..343ee8a66f9 100644
---- a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-+++ b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-@@ -109,7 +109,7 @@ class WeylLieConformalAlgebra(LieConformalAlgebraWithStructureCoefficients):
-         sage: alpha0.degree()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'
-+        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'...
- 
-     TESTS::
- 
-diff --git a/src/sage/algebras/steenrod/steenrod_algebra.py b/src/sage/algebras/steenrod/steenrod_algebra.py
-index 978a3557a9d..7c4d444f81c 100644
---- a/src/sage/algebras/steenrod/steenrod_algebra.py
-+++ b/src/sage/algebras/steenrod/steenrod_algebra.py
-@@ -1080,7 +1080,7 @@ def homogeneous_component(self, n):
-             sage: a.antipode() # not defined
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'
-+            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'...
-             sage: A(a).antipode() # convert to elt of A, then compute antipode
-             Sq(2,1) + Sq(5)
- 
-diff --git a/src/sage/all__sagemath_repl.py b/src/sage/all__sagemath_repl.py
-index 8d0b43679ca..c31b206bcb8 100644
---- a/src/sage/all__sagemath_repl.py
-+++ b/src/sage/all__sagemath_repl.py
-@@ -79,6 +79,23 @@
-                         message=r"Use setlocale\(\), getencoding\(\) and getlocale\(\) instead",
-                         module='docutils.io')
- 
-+# triggered by dateutil 2.8.2 and sphinx 7.0.1 on Python 3.12
-+# see: https://github.com/dateutil/dateutil/pull/1285
-+# see: https://github.com/sphinx-doc/sphinx/pull/11468
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"datetime.datetime.utcfromtimestamp\(\) is deprecated",
-+                        module='dateutil.tz.tz|sphinx.(builders.gettext|util.i18n)')
-+
-+# triggered on Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"This process.* is multi-threaded, "
-+                                r"use of .*\(\) may lead to deadlocks in the child.")
-+
-+# pickling of itertools is deprecated in Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"Pickle, copy, and deepcopy support will be "
-+                                r"removed from itertools in Python 3.14.")
-+
- 
- from .all__sagemath_objects import *
- from .all__sagemath_environment import *
-diff --git a/src/sage/arith/long.pxd b/src/sage/arith/long.pxd
-index 0031a0ae337..3ea70cef571 100644
---- a/src/sage/arith/long.pxd
-+++ b/src/sage/arith/long.pxd
-@@ -19,6 +19,8 @@ from libc.limits cimport LONG_MIN, LONG_MAX
- from cpython.object cimport Py_SIZE
- from cpython.number cimport PyNumber_Index, PyIndex_Check
- from cpython.longintrepr cimport py_long, PyLong_SHIFT, digit
-+from sage.cpython.pycore_long cimport (
-+    ob_digit, _PyLong_IsNegative, _PyLong_DigitCount)
- 
- from sage.libs.gmp.mpz cimport mpz_fits_slong_p, mpz_get_si
- from sage.rings.integer_fake cimport is_Integer, Integer_AS_MPZ
-@@ -299,8 +301,11 @@ cdef inline bint integer_check_long_py(x, long* value, int* err):
-         return 0
- 
-     # x is a Python "int" (aka PyLongObject or py_long in cython)
--    cdef const digit* D = (<py_long>x).ob_digit
--    cdef Py_ssize_t size = Py_SIZE(x)
-+    cdef const digit* D = ob_digit(x)
-+    cdef Py_ssize_t size = _PyLong_DigitCount(x)
-+
-+    if _PyLong_IsNegative(x):
-+        size = -size
- 
-     # We assume PyLong_SHIFT <= BITS_IN_LONG <= 3 * PyLong_SHIFT.
-     # This is true in all the default configurations:
-diff --git a/src/sage/categories/category.py b/src/sage/categories/category.py
-index 57ef7f4184b..29bce8ee415 100644
---- a/src/sage/categories/category.py
-+++ b/src/sage/categories/category.py
-@@ -2129,7 +2129,7 @@ def _with_axioms(self, axioms):
-             sage: Semigroups().Inverse()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'
-+            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'...
-             sage: Semigroups()._with_axioms(["Inverse"])
-             Category of semigroups
- 
-diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py
-index 5227792e725..4775d4e5bf1 100644
---- a/src/sage/categories/category_with_axiom.py
-+++ b/src/sage/categories/category_with_axiom.py
-@@ -554,7 +554,7 @@ class from the base category class::
-     sage: Magmas.Unital.Associative
-     Traceback (most recent call last):
-     ...
--    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'
-+    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'...
- 
- The purpose of this section is to explain the design of the code
- layout and the rationale for this mismatch.
-@@ -769,7 +769,7 @@ def _(): return LazyImport('sage.categories.rngs', 'Rngs', at_startup=True)
-     sage: Semirings().NoZeroDivisors()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'
-+    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'...
- 
- Concretely, this is to be implemented by defining the new axiom in the
- (``SubcategoryMethods`` nested class of the) appropriate category with
-diff --git a/src/sage/categories/enumerated_sets.py b/src/sage/categories/enumerated_sets.py
-index a8bea53f907..b0ea05d0563 100644
---- a/src/sage/categories/enumerated_sets.py
-+++ b/src/sage/categories/enumerated_sets.py
-@@ -610,7 +610,7 @@ def _list_from_iterator(self):
-                 sage: (QQ^2).list()  # indirect test                                    # needs sage.modules
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'
-+                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'...
- 
-             Here we test that for an object that does not know whether it
-             is finite or not.  Calling ``x.list()`` simply tries to create
-@@ -622,11 +622,11 @@ def _list_from_iterator(self):
-                 sage: Q.is_finite()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'...
-                 sage: Q.list()   # indirect test
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'...
- 
-             Here is another example. We artificially create a version of
-             the ring of integers that does not know whether it is finite
-diff --git a/src/sage/categories/examples/sets_cat.py b/src/sage/categories/examples/sets_cat.py
-index e0853d63f94..fbadb9ca405 100644
---- a/src/sage/categories/examples/sets_cat.py
-+++ b/src/sage/categories/examples/sets_cat.py
-@@ -619,7 +619,7 @@ class PrimeNumbers_Facade(PrimeNumbers_Abstract):
-         sage: pf.next()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'...
- 
-     unlike in the other implementations::
- 
-diff --git a/src/sage/categories/homset.py b/src/sage/categories/homset.py
-index 22ba9d047fc..2a8b8aeedeb 100644
---- a/src/sage/categories/homset.py
-+++ b/src/sage/categories/homset.py
-@@ -632,7 +632,7 @@ def __init__(self, X, Y, category=None, base=None, check=True):
-             sage: H = MyHomset(X, Y, category=1, base = ZZ, check = False)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'...
-             sage: P.<t> = ZZ[]
-             sage: f = P.hom([1/2*t])
-             sage: f.parent().domain()
-diff --git a/src/sage/categories/modules_with_basis.py b/src/sage/categories/modules_with_basis.py
-index e97bf851388..c4933d0657f 100644
---- a/src/sage/categories/modules_with_basis.py
-+++ b/src/sage/categories/modules_with_basis.py
-@@ -2456,7 +2456,7 @@ def apply_multilinear_morphism(self, f, codomain=None):
-                     sage: tensor([a, b]).apply_multilinear_morphism(f)                  # needs sage.modules
-                     Traceback (most recent call last):
-                     ...
--                    AttributeError: 'int' object has no attribute 'parent'
-+                    AttributeError: 'int' object has no attribute 'parent'...
- 
-                 Here we consider an example where the codomain is a
-                 module with basis with a different base ring::
-diff --git a/src/sage/categories/monoids.py b/src/sage/categories/monoids.py
-index 38dd7248c9d..28474bd17b6 100644
---- a/src/sage/categories/monoids.py
-+++ b/src/sage/categories/monoids.py
-@@ -556,7 +556,7 @@ def algebra_generators(self):
-                     Traceback (most recent call last):
-                     ...
-                     AttributeError: 'IntegerModMonoid_with_category' object
--                    has no attribute 'monoid_generators'
-+                    has no attribute 'monoid_generators'...
-                     sage: Z12.semigroup_generators()
-                     Family (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
-                     sage: Z12.algebra(QQ).algebra_generators()                          # needs sage.modules
-diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py
-index 494e8154c80..ec5120e41e6 100644
---- a/src/sage/combinat/finite_state_machine.py
-+++ b/src/sage/combinat/finite_state_machine.py
-@@ -1835,7 +1835,7 @@ def __getstate__(self):
-             sage: T1.transitions
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'FSMState' object has no attribute 'transitions'
-+            AttributeError: 'FSMState' object has no attribute 'transitions'...
-             sage: A1 = loads(dumps(A))
-             sage: all(A.state(j) == A1.state(j) for j in [0, 1])
-             True
-diff --git a/src/sage/combinat/growth.py b/src/sage/combinat/growth.py
-index cf8d18c1764..766eea37917 100644
---- a/src/sage/combinat/growth.py
-+++ b/src/sage/combinat/growth.py
-@@ -371,7 +371,7 @@
-     sage: GrowthDiagram(RulePascal(), [3,1,2])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'RulePascal' object has no attribute 'forward_rule'
-+    AttributeError: 'RulePascal' object has no attribute 'forward_rule'...
- 
- We now re-implement the rule where we provide the dual graded graphs::
- 
-diff --git a/src/sage/combinat/integer_lists/lists.py b/src/sage/combinat/integer_lists/lists.py
-index 5143e5cb5e8..9117a6076f7 100644
---- a/src/sage/combinat/integer_lists/lists.py
-+++ b/src/sage/combinat/integer_lists/lists.py
-@@ -261,7 +261,7 @@ def __getattr__(self, name):
-             sage: L.foo
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'foo'
-+            AttributeError: 'NoneType' object has no attribute 'foo'...
-         """
-         return getattr(self.backend, name)
- 
-diff --git a/src/sage/combinat/posets/posets.py b/src/sage/combinat/posets/posets.py
-index c31597c72e9..c74bfc67cee 100644
---- a/src/sage/combinat/posets/posets.py
-+++ b/src/sage/combinat/posets/posets.py
-@@ -8825,7 +8825,7 @@ def is_induced_subposet(self, other):
-             sage: Poset().is_induced_subposet('junk')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'subposet'
-+            AttributeError: 'str' object has no attribute 'subposet'...
-         """
-         if (not self._is_facade or (isinstance(other, FinitePoset) and
-                                     not other._is_facade)):
-diff --git a/src/sage/cpython/atexit.pyx b/src/sage/cpython/atexit.pyx
-index 961aa348d0a..e5a82735137 100644
---- a/src/sage/cpython/atexit.pyx
-+++ b/src/sage/cpython/atexit.pyx
-@@ -154,6 +154,10 @@ cdef extern from *:
-     #undef _PyGC_FINALIZED
-     #include "internal/pycore_interp.h"
-     #include "internal/pycore_pystate.h"
-+    #if PY_VERSION_HEX >= 0x030c0000
-+    // struct atexit_callback was renamed in 3.12 to atexit_py_callback
-+    #define atexit_callback atexit_py_callback
-+    #endif
-     static atexit_callback ** _atexit_callbacks(PyObject *self) {
-         PyInterpreterState *interp = _PyInterpreterState_GET();
-         struct atexit_state state = interp->atexit;
-diff --git a/src/sage/cpython/debug.pyx b/src/sage/cpython/debug.pyx
-index 986abff2a99..cdaca3a4854 100644
---- a/src/sage/cpython/debug.pyx
-+++ b/src/sage/cpython/debug.pyx
-@@ -78,7 +78,7 @@ def getattr_debug(obj, name, default=_no_default):
- 
-     EXAMPLES::
- 
--        sage: _ = getattr_debug(list, "reverse")
-+        sage: _ = getattr_debug(list, "reverse")  # not tested - broken in python 3.12
-         getattr_debug(obj=<class 'list'>, name='reverse'):
-           type(obj) = <class 'type'>
-           object has __dict__ slot (<class 'dict'>)
-@@ -123,7 +123,7 @@ def getattr_debug(obj, name, default=_no_default):
-         sage: _ = getattr_debug(1, "foo")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'...
-         sage: _ = getattr_debug(1, "foo", "xyz")
-         getattr_debug(obj=1, name='foo'):
-           type(obj) = <class 'sage.rings.integer.Integer'>
-diff --git a/src/sage/cpython/dict_internal.h b/src/sage/cpython/dict_internal.h
-index 42a57bcb468..a5ee35bc198 100644
---- a/src/sage/cpython/dict_internal.h
-+++ b/src/sage/cpython/dict_internal.h
-@@ -169,6 +169,7 @@ dictkeys_set_index(PyDictKeysObject *keys, Py_ssize_t i, Py_ssize_t ix)
- #else   /* Python >= 3.11 */
- 
- #define Py_BUILD_CORE
-+#undef _PyGC_FINALIZED
- #include <internal/pycore_dict.h>
- 
- /************************************************************/
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 52afed49d64..1f49e5230c3 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -53,12 +53,12 @@ cdef class AttributeErrorMessage:
-         sage: 1.bla  #indirect doctest
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'...
-         sage: x = polygen(ZZ, 'x')
-         sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'...
- 
-     ::
- 
-@@ -144,7 +144,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(X, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: x = X()
-         sage: raw_getattr(x, "prop")
-         <property object at ...>
-@@ -173,7 +173,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(Y, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: y = Y()
-         sage: raw_getattr(y, "prop")
-         <property object at ...>
-@@ -278,7 +278,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     The integer ring is a parent, so, lazy attributes work::
- 
-@@ -289,7 +289,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(17, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     In general, descriptors are not yet well supported, because they
-     often do not accept to be cheated with the type of their instance::
-@@ -305,7 +305,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__weakref__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-     This was caught by :trac:`8296` for which we do a couple more tests::
- 
-@@ -314,7 +314,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: 1.__weakref__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-         sage: n = 1
-         sage: ip = get_ipython()                 # not tested: only works in interactive shell
-@@ -329,7 +329,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__call__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'...
- 
-     TESTS:
- 
-@@ -339,14 +339,14 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, type, "__name__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'...
- 
-     Non-strings as "name" are handled gracefully::
- 
-         sage: getattr_from_other_class(1, type, None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute None
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute None...
-     """
-     if not isinstance(cls, type):
-         raise TypeError(f"{cls!r} is not a type")
-diff --git a/src/sage/cpython/pycore_long.h b/src/sage/cpython/pycore_long.h
-new file mode 100644
-index 00000000000..ff1a73d097a
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.h
-@@ -0,0 +1,98 @@
-+#include "Python.h"
-+#include <stdbool.h>
-+
-+#if PY_VERSION_HEX >= 0x030C00A5
-+#define ob_digit(o)  (((PyLongObject*)o)->long_value.ob_digit)
-+#else
-+#define ob_digit(o)  (((PyLongObject*)o)->ob_digit)
-+#endif
-+
-+#if PY_VERSION_HEX >= 0x030C00A7
-+// taken from cpython:Include/internal/pycore_long.h @ 3.12
-+
-+/* Long value tag bits:
-+ * 0-1: Sign bits value = (1-sign), ie. negative=2, positive=0, zero=1.
-+ * 2: Reserved for immortality bit
-+ * 3+ Unsigned digit count
-+ */
-+#define SIGN_MASK 3
-+#define SIGN_ZERO 1
-+#define SIGN_NEGATIVE 2
-+#define NON_SIZE_BITS 3
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_ZERO;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_NEGATIVE;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    assert(PyLong_Check(op));
-+    return op->long_value.lv_tag >> NON_SIZE_BITS;
-+}
-+
-+#define TAG_FROM_SIGN_AND_SIZE(sign, size) ((1 - (sign)) | ((size) << NON_SIZE_BITS))
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+    assert(size >= 0);
-+    assert(-1 <= sign && sign <= 1);
-+    assert(sign != 0 || size == 0);
-+    op->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sign, (size_t)size);
-+}
-+
-+#else
-+// fallback for < 3.12
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) == 0;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) < 0;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) > 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    Py_ssize_t size = Py_SIZE(op);
-+    return size < 0 ? -size : size;
-+}
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION < 9)
-+// The function Py_SET_SIZE is defined starting with python 3.9.
-+    Py_SIZE(o) = size;
-+#else
-+    Py_SET_SIZE(op, sign < 0 ? -size : size);
-+#endif
-+}
-+
-+#endif
-diff --git a/src/sage/cpython/pycore_long.pxd b/src/sage/cpython/pycore_long.pxd
-new file mode 100644
-index 00000000000..41de637ff18
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.pxd
-@@ -0,0 +1,9 @@
-+from cpython.longintrepr cimport py_long, digit
-+
-+cdef extern from "pycore_long.h":
-+    digit* ob_digit(py_long o)
-+    bint _PyLong_IsZero(py_long o)
-+    bint _PyLong_IsNegative(py_long o)
-+    bint _PyLong_IsPositive(py_long o)
-+    Py_ssize_t _PyLong_DigitCount(py_long o)
-+    void _PyLong_SetSignAndDigitCount(py_long o, int sign, Py_ssize_t size)
-diff --git a/src/sage/crypto/classical.py b/src/sage/crypto/classical.py
-index 616dc861652..be899c781e5 100644
---- a/src/sage/crypto/classical.py
-+++ b/src/sage/crypto/classical.py
-@@ -494,7 +494,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: A.rank_by_chi_square("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_chi_square(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -703,7 +703,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: A.rank_by_squared_differences("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_squared_differences(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -2114,7 +2114,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: S.rank_by_chi_square("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_chi_square(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-@@ -2351,7 +2351,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: S.rank_by_squared_differences("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_squared_differences(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/crypto/mq/mpolynomialsystemgenerator.py b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-index 9028dab1d98..4416d9ef7f6 100644
---- a/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-+++ b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-@@ -156,7 +156,7 @@ def sbox(self):
-             sage: msg.sbox()
-             Traceback (most recent call last):
-             ...
--            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'
-+            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'...
-         """
-         return self._sbox
- 
-diff --git a/src/sage/data_structures/bitset.pyx b/src/sage/data_structures/bitset.pyx
-index 446062554c1..d9906b5edd2 100644
---- a/src/sage/data_structures/bitset.pyx
-+++ b/src/sage/data_structures/bitset.pyx
-@@ -967,7 +967,7 @@ cdef class FrozenBitset:
-             sage: None | FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute '_union'
-+            AttributeError: 'NoneType' object has no attribute '_union'...
-         """
-         return self._union(other)
- 
-@@ -1037,7 +1037,7 @@ cdef class FrozenBitset:
-             sage: None & FrozenBitset("101011")
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'intersection'
-+            AttributeError: 'NoneType' object has no attribute 'intersection'...
-         """
-         return self.intersection(other)
- 
-@@ -1106,7 +1106,7 @@ cdef class FrozenBitset:
-             sage: None - FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'difference'
-+            AttributeError: 'NoneType' object has no attribute 'difference'...
-         """
-         return self.difference(other)
- 
-@@ -1179,7 +1179,7 @@ cdef class FrozenBitset:
-             sage: None ^^ FrozenBitset('11111' * 10)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'
-+            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'...
-         """
-         return self.symmetric_difference(other)
- 
-diff --git a/src/sage/doctest/reporting.py b/src/sage/doctest/reporting.py
-index 361fea344c2..a3947c07e01 100644
---- a/src/sage/doctest/reporting.py
-+++ b/src/sage/doctest/reporting.py
-@@ -368,7 +368,7 @@ def report(self, source, timeout, return_code, results, output, pid=None):
-             sage: DTR.report(None, None, None, None, None)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'basename'
-+            AttributeError: 'NoneType' object has no attribute 'basename'...
- 
-         The only-errors mode does not output anything on success::
- 
-diff --git a/src/sage/dynamics/finite_dynamical_system.py b/src/sage/dynamics/finite_dynamical_system.py
-index e5fbf568b7e..4295070615a 100644
---- a/src/sage/dynamics/finite_dynamical_system.py
-+++ b/src/sage/dynamics/finite_dynamical_system.py
-@@ -240,7 +240,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-@@ -252,7 +252,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-diff --git a/src/sage/geometry/cone.py b/src/sage/geometry/cone.py
-index f0a8620011a..53f78a4b7b6 100644
---- a/src/sage/geometry/cone.py
-+++ b/src/sage/geometry/cone.py
-@@ -340,7 +340,7 @@ def Cone(rays, lattice=None, check=True, normalize=True):
-         sage: Cone([(1,0), (0,1)], check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     You can construct different "not" cones: not full-dimensional, not
-     strictly convex, not containing any rays::
-diff --git a/src/sage/geometry/fan.py b/src/sage/geometry/fan.py
-index 258544012fe..3aecc84a55b 100644
---- a/src/sage/geometry/fan.py
-+++ b/src/sage/geometry/fan.py
-@@ -443,7 +443,7 @@ def Fan(cones, rays=None, lattice=None, check=True, normalize=True,
-         sage: P2c = Fan(cones, rays, check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     Yet another way is to use functions :func:`FaceFan` and :func:`NormalFan`
-     to construct fans from :class:`lattice polytopes
-diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-index f0ac1e774a7..f03f0f832ff 100644
---- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-+++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-@@ -351,7 +351,7 @@ cdef class FaceIterator_base(SageObject):
-             sage: FaceIterator_base(2)  # indirect doctest
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'...
-         """
-         cdef int i
-         sig_free(self.structure.atom_rep)
-@@ -1945,7 +1945,8 @@ cdef inline int next_face_loop(iter_t structure) nogil except -1:
-         # The function is not supposed to be called,
-         # just prevent it from crashing.
-         # Actually raising an error here results in a bad branch prediction.
--        return -1
-+        # But return -1 results in a crash with python 3.12
-+        raise StopIteration
- 
-     # Getting ``[faces, n_faces, n_visited_all]`` according to dimension.
-     cdef face_list_t* faces = &structure.new_faces[structure.current_dimension]
-diff --git a/src/sage/geometry/toric_plotter.py b/src/sage/geometry/toric_plotter.py
-index 50b4008eb0f..950e3ba7ff8 100644
---- a/src/sage/geometry/toric_plotter.py
-+++ b/src/sage/geometry/toric_plotter.py
-@@ -706,7 +706,7 @@ def set_rays(self, generators):
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ToricPlotter' object has no attribute 'rays'
-+            AttributeError: 'ToricPlotter' object has no attribute 'rays'...
-             sage: tp.set_rays([(0,1)])
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Graphics object consisting of 2 graphics primitives
-diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
-index d0ec214bb3b..c8098ad578a 100644
---- a/src/sage/groups/matrix_gps/finitely_generated.py
-+++ b/src/sage/groups/matrix_gps/finitely_generated.py
-@@ -268,7 +268,7 @@ def MatrixGroup(*gens, **kwds):
-         sage: SL2C.gens()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'
-+        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'...
-     """
-     if isinstance(gens[-1], dict):   # hack for unpickling
-         kwds.update(gens[-1])
-diff --git a/src/sage/homology/chains.py b/src/sage/homology/chains.py
-index 87c0947c0b0..b9a54940943 100644
---- a/src/sage/homology/chains.py
-+++ b/src/sage/homology/chains.py
-@@ -298,7 +298,7 @@ def is_cycle(self):
-                 sage: chain.is_cocycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -325,7 +325,7 @@ def is_boundary(self):
-                 sage: chain.is_coboundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -539,7 +539,7 @@ def is_cocycle(self):
-                 sage: cochain.is_cycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -566,7 +566,7 @@ def is_coboundary(self):
-                 sage: cochain.is_boundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -604,7 +604,7 @@ def eval(self, other):
-                 sage: z.eval(c) # z is not a cochain
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'...
-                 sage: c.eval(c) # can't evaluate a cochain on a cochain
-                 Traceback (most recent call last):
-                 ...
-diff --git a/src/sage/homology/free_resolution.py b/src/sage/homology/free_resolution.py
-index e3d38de4240..280a479b438 100644
---- a/src/sage/homology/free_resolution.py
-+++ b/src/sage/homology/free_resolution.py
-@@ -275,7 +275,7 @@ def differential(self, i):
-             sage: FreeResolution.differiental(r, 1)
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'FreeResolution' has no attribute 'differiental'
-+            AttributeError: type object 'FreeResolution' has no attribute 'differiental'...
-         """
- 
-     def target(self):
-diff --git a/src/sage/interfaces/magma.py b/src/sage/interfaces/magma.py
-index b7a0ac20d03..529bfbc349b 100644
---- a/src/sage/interfaces/magma.py
-+++ b/src/sage/interfaces/magma.py
-@@ -824,7 +824,7 @@ def _coerce_from_special_method(self, x):
-             sage: magma._coerce_from_special_method('2 + 3')  # optional - magma
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute '_magma_init_'
-+            AttributeError: 'str' object has no attribute '_magma_init_'...
-         """
-         s = x._magma_init_(self)
-         a = self(s)
-diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
-index 58499396d6c..16119d20815 100644
---- a/src/sage/lfunctions/dokchitser.py
-+++ b/src/sage/lfunctions/dokchitser.py
-@@ -418,8 +418,8 @@ def init_coeffs(self, v, cutoff=1,
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
-index bbf289aa21c..e4968866303 100644
---- a/src/sage/lfunctions/pari.py
-+++ b/src/sage/lfunctions/pari.py
-@@ -141,8 +141,8 @@ def init_coeffs(self, v, cutoff=None, w=1):
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
-index 478caf9f9d0..363024ae281 100644
---- a/src/sage/libs/gap/element.pyx
-+++ b/src/sage/libs/gap/element.pyx
-@@ -380,7 +380,7 @@ cdef GapElement make_GapElement(parent, Obj obj):
-         sage: libgap(None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute '_libgap_init_'
-+        AttributeError: 'NoneType' object has no attribute '_libgap_init_'...
-     """
-     cdef GapElement r = GapElement.__new__(GapElement)
-     r._initialize(parent, obj)
-diff --git a/src/sage/libs/gmp/pylong.pxd b/src/sage/libs/gmp/pylong.pxd
-index a73f1da6d6f..84e1bb8cd87 100644
---- a/src/sage/libs/gmp/pylong.pxd
-+++ b/src/sage/libs/gmp/pylong.pxd
-@@ -2,9 +2,10 @@
- Various functions to deal with conversion mpz <-> Python int/long
- """
- 
-+from cpython.longintrepr cimport py_long
- from sage.libs.gmp.types cimport *
- 
- cdef mpz_get_pylong(mpz_srcptr z)
- cdef mpz_get_pyintlong(mpz_srcptr z)
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1
- cdef Py_hash_t mpz_pythonhash(mpz_srcptr z)
-diff --git a/src/sage/libs/gmp/pylong.pyx b/src/sage/libs/gmp/pylong.pyx
-index d5993cca5a5..1a36c29d3fa 100644
---- a/src/sage/libs/gmp/pylong.pyx
-+++ b/src/sage/libs/gmp/pylong.pyx
-@@ -28,6 +28,8 @@ AUTHORS:
- from cpython.object cimport Py_SIZE
- from cpython.long cimport PyLong_FromLong
- from cpython.longintrepr cimport _PyLong_New, py_long, digit, PyLong_SHIFT
-+from sage.cpython.pycore_long cimport (ob_digit, _PyLong_IsNegative,
-+    _PyLong_DigitCount, _PyLong_SetSignAndDigitCount)
- from .mpz cimport *
- 
- cdef extern from *:
-@@ -60,12 +62,9 @@ cdef mpz_get_pylong_large(mpz_srcptr z):
-     """
-     cdef size_t nbits = mpz_sizeinbase(z, 2)
-     cdef size_t pylong_size = (nbits + PyLong_SHIFT - 1) // PyLong_SHIFT
--    L = _PyLong_New(pylong_size)
--    mpz_export(L.ob_digit, NULL,
--            -1, sizeof(digit), 0, PyLong_nails, z)
--    if mpz_sgn(z) < 0:
--        # Set correct size
--        Py_SET_SIZE(L, -pylong_size)
-+    cdef py_long L = _PyLong_New(pylong_size)
-+    mpz_export(ob_digit(L), NULL, -1, sizeof(digit), 0, PyLong_nails, z)
-+    _PyLong_SetSignAndDigitCount(L, mpz_sgn(z), pylong_size)
-     return L
- 
- 
-@@ -88,16 +87,13 @@ cdef mpz_get_pyintlong(mpz_srcptr z):
-     return mpz_get_pylong_large(z)
- 
- 
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1:
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1:
-     """
-     Convert a Python ``long`` `L` to an ``mpz``.
-     """
--    cdef Py_ssize_t pylong_size = Py_SIZE(L)
--    if pylong_size < 0:
--        pylong_size = -pylong_size
--    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails,
--            (<py_long>L).ob_digit)
--    if Py_SIZE(L) < 0:
-+    cdef Py_ssize_t pylong_size = _PyLong_DigitCount(L)
-+    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails, ob_digit(L))
-+    if _PyLong_IsNegative(L):
-         mpz_neg(z, z)
- 
- 
-diff --git a/src/sage/manifolds/calculus_method.py b/src/sage/manifolds/calculus_method.py
-index f5830c0bc45..303dde6cd13 100644
---- a/src/sage/manifolds/calculus_method.py
-+++ b/src/sage/manifolds/calculus_method.py
-@@ -257,7 +257,7 @@ def simplify(self, expression, method=None):
-             sage: cm.simplify(f)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'
-+            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'...
- 
-         In the present case, one should either transform ``f`` to a SymPy
-         object::
-diff --git a/src/sage/manifolds/differentiable/vectorfield_module.py b/src/sage/manifolds/differentiable/vectorfield_module.py
-index d954b5d4839..af4bfb0ceec 100644
---- a/src/sage/manifolds/differentiable/vectorfield_module.py
-+++ b/src/sage/manifolds/differentiable/vectorfield_module.py
-@@ -885,7 +885,7 @@ def tensor(self, *args, **kwds):
-             sage: XM.tensor(XM).tensor(XM.dual().tensor(XM.dual()))
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'
-+            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'...
- 
-         .. SEEALSO::
- 
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 86aca6e00d8..a5f6716e731 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15303,7 +15303,7 @@ cdef class Matrix(Matrix1):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
--            has no attribute 'conjugate'
-+            has no attribute 'conjugate'...
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/matrix/matrix_cyclo_dense.pyx b/src/sage/matrix/matrix_cyclo_dense.pyx
-index f54f3423ded..a49bb6240e6 100644
---- a/src/sage/matrix/matrix_cyclo_dense.pyx
-+++ b/src/sage/matrix/matrix_cyclo_dense.pyx
-@@ -847,7 +847,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense):
-             sage: A.set_mutable()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'
-+            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'...
-             sage: B = A.__copy__()
-             sage: B[0,0] = 20
-             sage: B[0,0]
-diff --git a/src/sage/matrix/matrix_gfpn_dense.pyx b/src/sage/matrix/matrix_gfpn_dense.pyx
-index 4cccf473de1..8e8e4d7336b 100644
---- a/src/sage/matrix/matrix_gfpn_dense.pyx
-+++ b/src/sage/matrix/matrix_gfpn_dense.pyx
-@@ -159,7 +159,7 @@ cdef class FieldConverter_class:
-             sage: C.field_to_fel('foo')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'to_integer'
-+            AttributeError: 'str' object has no attribute 'to_integer'...
-         """
-         return FfFromInt(x.to_integer())
- 
-diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py
-index 6aab58352be..b5e6f52349b 100644
---- a/src/sage/matrix/matrix_space.py
-+++ b/src/sage/matrix/matrix_space.py
-@@ -1619,7 +1619,7 @@ def __getitem__(self, x):
-             sage: MS[2]
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'
-+            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'...
-         """
-         if isinstance(x, (integer.Integer, int)):
-             return self.list()[x]
-diff --git a/src/sage/matroids/lean_matrix.pyx b/src/sage/matroids/lean_matrix.pyx
-index 54c68e637c0..a137cbf70e5 100644
---- a/src/sage/matroids/lean_matrix.pyx
-+++ b/src/sage/matroids/lean_matrix.pyx
-@@ -1,5 +1,4 @@
- # sage.doctest: optional - sage.rings.finite_rings
--# cython: profile=True
- """
- Lean matrices
- 
-diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx
-index 36f563aa433..318c82f2b64 100644
---- a/src/sage/matroids/linear_matroid.pyx
-+++ b/src/sage/matroids/linear_matroid.pyx
-@@ -1134,7 +1134,7 @@ cdef class LinearMatroid(BasisExchangeMatroid):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.matroids.basis_matroid.BasisMatroid' object
--            has no attribute 'base_ring'
-+            has no attribute 'base_ring'...
-             sage: from sage.matroids.advanced import *
-             sage: M4 = BinaryMatroid(Matrix(M1))
-             sage: M5 = LinearMatroid(reduced_matrix=Matrix(GF(2), [[-1, 0, 1],
-diff --git a/src/sage/misc/dev_tools.py b/src/sage/misc/dev_tools.py
-index e7bf176592c..3ece7db2894 100644
---- a/src/sage/misc/dev_tools.py
-+++ b/src/sage/misc/dev_tools.py
-@@ -171,6 +171,7 @@ def load_submodules(module=None, exclude_pattern=None):
-         load sage.geometry.polyhedron.ppl_lattice_polygon... succeeded
-     """
-     from .package_dir import walk_packages
-+    import importlib.util
- 
-     if module is None:
-         import sage
-@@ -194,8 +195,12 @@ def load_submodules(module=None, exclude_pattern=None):
-         try:
-             sys.stdout.write("load %s..." % module_name)
-             sys.stdout.flush()
--            loader = importer.find_module(module_name)
--            loader.load_module(module_name)
-+            # see
-+            # https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
-+            spec = importer.find_spec(module_name)
-+            module = importlib.util.module_from_spec(spec)
-+            sys.modules[module_name] = module
-+            spec.loader.exec_module(module)
-             sys.stdout.write(" succeeded\n")
-         except (ValueError, AttributeError, TypeError, ImportError):
-             # we might get error because of cython code that has been
-diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py
-index c922b8f6f12..03697f08b7c 100644
---- a/src/sage/misc/functional.py
-+++ b/src/sage/misc/functional.py
-@@ -86,7 +86,7 @@ def base_field(x):
-         sage: R.base_field()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'
-+        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'...
-     """
-     try:
-         return x.base_field()
-diff --git a/src/sage/misc/instancedoc.pyx b/src/sage/misc/instancedoc.pyx
-index d8e1e4ac536..44ee70f64ba 100644
---- a/src/sage/misc/instancedoc.pyx
-+++ b/src/sage/misc/instancedoc.pyx
-@@ -256,7 +256,7 @@ cdef class InstanceDocDescriptor:
-             sage: descr.__delete__(obj)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'X' object has no attribute '__doc__'
-+            AttributeError: 'X' object has no attribute '__doc__'...
- 
-             sage: descr.__delete__([])
-             Traceback (most recent call last):
-diff --git a/src/sage/misc/lazy_attribute.pyx b/src/sage/misc/lazy_attribute.pyx
-index bdbec3b3ba1..1f07870b8ec 100644
---- a/src/sage/misc/lazy_attribute.pyx
-+++ b/src/sage/misc/lazy_attribute.pyx
-@@ -441,37 +441,37 @@ class lazy_attribute(_lazy_attribute):
-             sage: B().unimplemented_A # todo: not implemented
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'super' object has no attribute 'unimplemented_A'
-+            AttributeError: 'super' object has no attribute 'unimplemented_A'...
- 
-     We now make some systematic checks::
- 
-         sage: B().unimplemented_A
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: B().unimplemented_B
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: B().unimplemented_AB
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: B().unimplemented_B_implemented_A
-         1
- 
-         sage: C().unimplemented_A()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: C().unimplemented_B()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: C().unimplemented_AB()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: C().unimplemented_B_implemented_A # todo: not implemented
-         1
-     """
-diff --git a/src/sage/misc/object_multiplexer.py b/src/sage/misc/object_multiplexer.py
-index d4e811ef16e..00fd89d6652 100644
---- a/src/sage/misc/object_multiplexer.py
-+++ b/src/sage/misc/object_multiplexer.py
-@@ -85,7 +85,7 @@ def __getattr__(self, name):
-             sage: m.__bork__
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Multiplex' has no attribute '__bork__'
-+            AttributeError: 'Multiplex' has no attribute '__bork__'...
-         """
-         if name.startswith("__"):
-             raise AttributeError("'Multiplex' has no attribute '%s'" % name)
-diff --git a/src/sage/misc/sage_input.py b/src/sage/misc/sage_input.py
-index 66e78ecccbc..00e8d96ee9e 100644
---- a/src/sage/misc/sage_input.py
-+++ b/src/sage/misc/sage_input.py
-@@ -3461,7 +3461,7 @@ def verify_same(a, b):
-         sage: verify_same(1, 1r)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_same(1r, 1)
-         Traceback (most recent call last):
-         ...
-@@ -3525,7 +3525,7 @@ def verify_si_answer(x, answer, preparse):
-         sage: verify_si_answer(1, '1', False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_si_answer(1, 'ZZ(1)', None)
-     """
-     from sage.misc.sage_eval import sage_eval
-diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py
-index f0545be7d81..811afc48755 100644
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -602,7 +602,7 @@ def visit_Num(self, node):
-             On Python 3 negative numbers are parsed first, for some reason, as
-             a UnaryOp node.
-         """
--        return node.n
-+        return node.value
- 
-     def visit_Str(self, node):
-         r"""
-@@ -624,7 +624,7 @@ def visit_Str(self, node):
-             sage: [vis(s) for s in ['"abstract"', "'syntax'", r'''r"tr\ee"''']]
-             ['abstract', 'syntax', 'tr\\ee']
-         """
--        return node.s
-+        return node.value
- 
-     def visit_List(self, node):
-         """
-diff --git a/src/sage/modules/fp_graded/steenrod/module.py b/src/sage/modules/fp_graded/steenrod/module.py
-index 18460b0e9a1..4acfa6b4002 100755
---- a/src/sage/modules/fp_graded/steenrod/module.py
-+++ b/src/sage/modules/fp_graded/steenrod/module.py
-@@ -70,7 +70,7 @@
-     sage: SteenrodFPModule(ZZ, [0])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'
-+    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'...
- 
- AUTHORS:
- 
-diff --git a/src/sage/monoids/trace_monoid.py b/src/sage/monoids/trace_monoid.py
-index 00baa4d14f8..f8176a1e1f2 100644
---- a/src/sage/monoids/trace_monoid.py
-+++ b/src/sage/monoids/trace_monoid.py
-@@ -40,7 +40,6 @@
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from collections import OrderedDict
- from itertools import repeat, chain, product
- 
- from sage.misc.cachefunc import cached_method
-@@ -633,14 +632,14 @@ def _compute_dependence_stack(self, x):
-             sage: x = b*a*d*a*c*b
-             sage: M._compute_dependence_stack(x)
-             ({a, b, c, d},
--             OrderedDict([(a, [False, False, True, True, False]),
--                          (b, [True, False, False, False, True]),
--                          (c, [True, False, False, False]),
--                          (d, [False, False, True, False])]))
-+             {a: [False, False, True, True, False],
-+              b: [True, False, False, False, True],
-+              c: [True, False, False, False],
-+              d: [False, False, True, False]})
-         """
-         independence = self._independence
-         generators_set = set(e for e, _ in x)
--        stacks = OrderedDict(sorted((g, []) for g in generators_set))
-+        stacks = dict(sorted((g, []) for g in generators_set))
-         for generator, times in reversed(list(x)):
-             stacks[generator].extend(repeat(True, times))
-             for other_gen in generators_set:
-diff --git a/src/sage/parallel/map_reduce.py b/src/sage/parallel/map_reduce.py
-index 11e0673ee91..5441943731d 100644
---- a/src/sage/parallel/map_reduce.py
-+++ b/src/sage/parallel/map_reduce.py
-@@ -1234,7 +1234,7 @@ def finish(self):
-             sage: S.print_communication_statistics()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'RESetMPExample' object has no attribute '_stats'
-+            AttributeError: 'RESetMPExample' object has no attribute '_stats'...
- 
-             sage: S.finish()
- 
-diff --git a/src/sage/plot/colors.py b/src/sage/plot/colors.py
-index 8c0db2b3c34..3281199400b 100644
---- a/src/sage/plot/colors.py
-+++ b/src/sage/plot/colors.py
-@@ -1099,7 +1099,7 @@ def __getattr__(self, name):
-             sage: cols.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ColorsDict' has no attribute or colormap punk
-+            AttributeError: 'ColorsDict' has no attribute or colormap punk...
-         """
-         try:
-             return self[name]
-@@ -1599,7 +1599,7 @@ def __getattr__(self, name):
-             sage: maps.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Colormaps' has no attribute or colormap punk
-+            AttributeError: 'Colormaps' has no attribute or colormap punk...
-             sage: maps['punk']
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/rings/asymptotic/asymptotic_ring.py b/src/sage/rings/asymptotic/asymptotic_ring.py
-index b07319382d3..994490e6616 100644
---- a/src/sage/rings/asymptotic/asymptotic_ring.py
-+++ b/src/sage/rings/asymptotic/asymptotic_ring.py
-@@ -1091,7 +1091,7 @@ def monomial_coefficient(self, monomial):
-             sage: O(n).monomial_coefficient(n)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'
-+            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'...
- 
-         The ``monomial`` must be exact::
- 
-diff --git a/src/sage/rings/asymptotic/growth_group.py b/src/sage/rings/asymptotic/growth_group.py
-index 27c14592bca..5be12537d62 100644
---- a/src/sage/rings/asymptotic/growth_group.py
-+++ b/src/sage/rings/asymptotic/growth_group.py
-@@ -1572,7 +1572,7 @@ def variable_names(self):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'GenericGrowthGroup_with_category.element_class' object
--            has no attribute 'is_one'
-+            has no attribute 'is_one'...
-         """
-         if self.is_one():
-             return tuple()
-diff --git a/src/sage/rings/ideal.py b/src/sage/rings/ideal.py
-index d36d9406f32..01c9fa3bf2d 100644
---- a/src/sage/rings/ideal.py
-+++ b/src/sage/rings/ideal.py
-@@ -1553,7 +1553,7 @@ def gcd(self, other):
-             sage: J.gcd(I)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Ideal_generic' object has no attribute 'gcd'
-+            AttributeError: 'Ideal_generic' object has no attribute 'gcd'...
- 
-         Note::
- 
-diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
-index 7fe89197011..8832d27e8ea 100644
---- a/src/sage/rings/number_field/number_field.py
-+++ b/src/sage/rings/number_field/number_field.py
-@@ -3823,7 +3823,7 @@ def primes_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
-         """
-         if degree is not None:
-             degree = ZZ(degree)
-@@ -3917,7 +3917,7 @@ def prime_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
- 
-         """
-         ids = self.primes_above(x, degree)
-@@ -5926,7 +5926,7 @@ def factor(self, n):
-             sage: L.factor(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'...
- 
-         AUTHORS:
- 
-@@ -12698,7 +12698,7 @@ def is_real_place(v):
-         sage: is_real_place(v_fin)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'
-+        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'...
- 
-     """
-     RR = sage.rings.real_mpfr.RealField(53)
-diff --git a/src/sage/rings/padics/generic_nodes.py b/src/sage/rings/padics/generic_nodes.py
-index 7047020edec..b6b514d4005 100644
---- a/src/sage/rings/padics/generic_nodes.py
-+++ b/src/sage/rings/padics/generic_nodes.py
-@@ -740,7 +740,7 @@ def _get_element_class(self, name=None):
-             sage: R._get_element_class("foobar")
-             Traceback (most recent call last):
-             ...
--            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'
-+            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'...
-         """
-         if name is None:
-             return self.Element
-diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx
-index c5a1129aecf..a5b7f937cfe 100644
---- a/src/sage/rings/polynomial/polynomial_element.pyx
-+++ b/src/sage/rings/polynomial/polynomial_element.pyx
-@@ -10793,7 +10793,7 @@ cdef class Polynomial(CommutativePolynomial):
-             sage: (y**2 + x).nth_root(2)
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... has no attribute 'nth_root'
-+            AttributeError: ... has no attribute 'nth_root'...
- 
-         TESTS::
- 
-@@ -11831,7 +11831,7 @@ cdef class Polynomial_generic_dense(Polynomial):
-             sage: int(1) // x  # check that this doesn't segfault
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'int' has no attribute 'base_ring'
-+            AttributeError: type object 'int' has no attribute 'base_ring'...
-         """
-         if have_same_parent(self, right):
-             return (<Polynomial_generic_dense>self)._floordiv_(<Polynomial_generic_dense>right)
-diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-index e372be888ee..aca4f08420f 100644
---- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
-+++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-@@ -2362,7 +2362,7 @@ def field_extension(self, names):
-             sage: F, g, h = S.field_extension('b')                                      # needs sage.rings.finite_rings
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'
-+            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'...
- 
-         Over a finite field, the corresponding field extension is not a
-         number field::
-diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx
-index 5273891a5b0..a6e999b8805 100644
---- a/src/sage/rings/ring.pyx
-+++ b/src/sage/rings/ring.pyx
-@@ -1734,7 +1734,7 @@ cdef class IntegralDomain(CommutativeRing):
-             sage: Z5.is_integrally_closed()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'
-+            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'...
-         """
-         raise NotImplementedError
- 
-diff --git a/src/sage/sat/solvers/satsolver.pyx b/src/sage/sat/solvers/satsolver.pyx
-index c2f41b18f55..1c4ac400cb6 100644
---- a/src/sage/sat/solvers/satsolver.pyx
-+++ b/src/sage/sat/solvers/satsolver.pyx
-@@ -375,10 +375,10 @@ def SAT(solver=None, *args, **kwds):
-         DIMACS Solver: 'kissat -q {input}'
-     """
-     if solver is None:
--        import pkgutil
--        if pkgutil.find_loader('pycryptosat') is not None:
-+        from importlib.util import find_spec
-+        if find_spec('pycryptosat') is not None:
-             solver = "cryptominisat"
--        elif pkgutil.find_loader('pycosat') is not None:
-+        elif find_spec('pycosat') is not None:
-             solver = "picosat"
-         else:
-             solver = "LP"
-diff --git a/src/sage/schemes/toric/morphism.py b/src/sage/schemes/toric/morphism.py
-index 1c8944b6dfc..5d64d632f97 100644
---- a/src/sage/schemes/toric/morphism.py
-+++ b/src/sage/schemes/toric/morphism.py
-@@ -246,7 +246,7 @@
-     Traceback (most recent call last):
-     ...
-     AttributeError: 'SchemeMorphism_fan_toric_variety' object
--    has no attribute 'fiber_generic'
-+    has no attribute 'fiber_generic'...
- 
- Let's use factorization mentioned above::
- 
-diff --git a/src/sage/sets/disjoint_union_enumerated_sets.py b/src/sage/sets/disjoint_union_enumerated_sets.py
-index 3dea567a779..5c5e08612f2 100644
---- a/src/sage/sets/disjoint_union_enumerated_sets.py
-+++ b/src/sage/sets/disjoint_union_enumerated_sets.py
-@@ -597,7 +597,7 @@ def Element(self):
-             sage: U.Element
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'
-+            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'...
-         """
-         if not self._facade:
-             return ElementWrapper
-diff --git a/src/sage/sets/set.py b/src/sage/sets/set.py
-index a1789c61300..112d3d8dc3b 100644
---- a/src/sage/sets/set.py
-+++ b/src/sage/sets/set.py
-@@ -163,7 +163,7 @@ def Set(X=None, category=None):
-         sage: sorted(B.list(), key=repr)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'Set_object_with_category' object has no attribute 'list'
-+        AttributeError: 'Set_object_with_category' object has no attribute 'list'...
-         sage: type(B)
-         <class 'sage.sets.set.Set_object_with_category'>
- 
-diff --git a/src/sage/structure/category_object.pyx b/src/sage/structure/category_object.pyx
-index b6a7eaecb5b..c06933494dc 100644
---- a/src/sage/structure/category_object.pyx
-+++ b/src/sage/structure/category_object.pyx
-@@ -836,7 +836,7 @@ cdef class CategoryObject(SageObject):
-             sage: Sets().example().sadfasdf
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'
-+            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'...
-         """
-         return self.getattr_from_category(name)
- 
-diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx
-index caae7e40ffc..543506e9a74 100644
---- a/src/sage/structure/element.pyx
-+++ b/src/sage/structure/element.pyx
-@@ -219,7 +219,7 @@ the parents::
-     sage: x._add_(x)
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-     sage: x + x
-     Traceback (most recent call last):
-     ...
-@@ -478,13 +478,13 @@ cdef class Element(SageObject):
-             sage: 1.blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'...
-             sage: Semigroups().example().an_element().is_idempotent
-             <bound method LeftZeroSemigroup.Element.is_idempotent of 42>
-             sage: Semigroups().example().an_element().blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'
-+            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'...
-         """
-         return self.getattr_from_category(name)
- 
-@@ -1269,7 +1269,7 @@ cdef class Element(SageObject):
-             sage: e._add_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-         """
-         try:
-             python_op = (<object>self)._add_
-@@ -1381,7 +1381,7 @@ cdef class Element(SageObject):
-             sage: e._sub_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'...
-         """
-         try:
-             python_op = (<object>self)._sub_
-@@ -1435,7 +1435,7 @@ cdef class Element(SageObject):
-             sage: e._neg_()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'...
-         """
-         try:
-             python_op = (<object>self)._neg_
-@@ -1549,7 +1549,7 @@ cdef class Element(SageObject):
-             sage: e._mul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'...
-         """
-         try:
-             python_op = (<object>self)._mul_
-@@ -1662,7 +1662,7 @@ cdef class Element(SageObject):
-             sage: e._matmul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'...
-         """
-         try:
-             python_op = (<object>self)._matmul_
-@@ -1765,7 +1765,7 @@ cdef class Element(SageObject):
-             sage: e._div_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'...
-         """
-         try:
-             python_op = (<object>self)._div_
-@@ -1865,7 +1865,7 @@ cdef class Element(SageObject):
-             sage: e._floordiv_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'...
-         """
-         try:
-             python_op = (<object>self)._floordiv_
-@@ -1965,7 +1965,7 @@ cdef class Element(SageObject):
-             sage: e._mod_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'...
-         """
-         try:
-             python_op = (<object>self)._mod_
-@@ -2092,7 +2092,7 @@ cdef class Element(SageObject):
-             sage: e._pow_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'...
-         """
-         try:
-             python_op = (<object>self)._pow_
-@@ -2122,7 +2122,7 @@ cdef class Element(SageObject):
-             sage: e._pow_int(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'...
-         """
-         try:
-             python_op = (<object>self)._pow_int
-@@ -2856,7 +2856,7 @@ cdef class RingElement(ModuleElement):
-             sage: m.is_nilpotent()                                                      # needs sage.modules
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... object has no attribute 'is_nilpotent'
-+            AttributeError: '...' object has no attribute 'is_nilpotent'...
-         """
-         if self.is_unit():
-             return False
-@@ -4671,7 +4671,7 @@ def coerce_binop(method):
-         sage: x.test_add(CC(2))
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'
-+        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'...
- 
-     TESTS:
- 
-diff --git a/src/sage/structure/sequence.py b/src/sage/structure/sequence.py
-index 0c700c1fb81..c3972532ac3 100644
---- a/src/sage/structure/sequence.py
-+++ b/src/sage/structure/sequence.py
-@@ -854,7 +854,7 @@ def __getattr__(self, name):
-             sage: S.universe()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'...
-             sage: S._Sequence__universe = 'foobar'
-             sage: S.universe()
-             'foobar'
-@@ -867,7 +867,7 @@ def __getattr__(self, name):
-             sage: hash(S)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'...
-             sage: S._Sequence__hash = int(34)
-             sage: hash(S)
-             34
-diff --git a/src/sage/symbolic/assumptions.py b/src/sage/symbolic/assumptions.py
-index 7dcb15f0d85..15f6fa07ce6 100644
---- a/src/sage/symbolic/assumptions.py
-+++ b/src/sage/symbolic/assumptions.py
-@@ -636,7 +636,7 @@ def assume(*args):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no
--        attribute 'assume'
-+        attribute 'assume'...
- 
-     Ensure that we can combine the two types of assumptions, as documented::
- 
-diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx
-index 0f251ac4e5c..66f624141b3 100644
---- a/src/sage/symbolic/expression.pyx
-+++ b/src/sage/symbolic/expression.pyx
-@@ -13712,7 +13712,7 @@ cdef get_dynamic_class_for_function(unsigned serial):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.symbolic.expression.Expression' object has no
--        attribute 'argp1'
-+        attribute 'argp1'...
-         sage: t = (e + 1).op[0]; t
-         tfunc(x)
-         sage: t
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index c4152e092e3..4bcf45e8793 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -67,6 +67,7 @@
- #include "archive.h"
- #include "tostring.h"
- #include "utils.h"
-+#include "../../cpython/pycore_long.h"
- 
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wdeprecated-register"
-@@ -706,18 +707,12 @@ static long _mpq_pythonhash(mpq_t the_rat)
- // Initialize an mpz_t from a Python long integer
- static void _mpz_set_pylong(mpz_t z, PyLongObject* l)
- {
--    Py_ssize_t pylong_size = Py_SIZE(l);
--    int sign = 1;
--
--    if (pylong_size < 0) {
--        pylong_size = -pylong_size;
--        sign = -1;
--    }
-+    Py_ssize_t pylong_size = _PyLong_DigitCount(l);
- 
-     mpz_import(z, pylong_size, -1, sizeof(digit), 0,
--               8*sizeof(digit) - PyLong_SHIFT, l->ob_digit);
-+               8*sizeof(digit) - PyLong_SHIFT, ob_digit(l));
- 
--    if (sign < 0)
-+    if (_PyLong_IsNegative(l))
-         mpz_neg(z, z);
- }
- 
-diff --git a/src/sage/symbolic/pynac_impl.pxi b/src/sage/symbolic/pynac_impl.pxi
-index 68c31dcfde7..7fd7c3b314b 100644
---- a/src/sage/symbolic/pynac_impl.pxi
-+++ b/src/sage/symbolic/pynac_impl.pxi
-@@ -619,7 +619,7 @@ def tolerant_is_symbol(a):
-         sage: None.is_symbol()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute 'is_symbol'
-+        AttributeError: 'NoneType' object has no attribute 'is_symbol'...
-     """
-     try:
-         return a.is_symbol()
diff --git a/srcpkgs/sagemath/patches/36506-notebook_7.patch b/srcpkgs/sagemath/patches/36506-notebook_7.patch
new file mode 100644
index 0000000000000..a7d93d52c1b4a
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36506-notebook_7.patch
@@ -0,0 +1,18 @@
+diff --git a/src/bin/sage-notebook b/src/bin/sage-notebook
+index 2e8b12e1a1c..801b0a6a6a3 100755
+--- a/src/bin/sage-notebook
++++ b/src/bin/sage-notebook
+@@ -29,7 +29,12 @@ class NotebookJupyter():
+     def __init__(self, argv):
+         self.print_banner()
+         try:
+-            from notebook.notebookapp import main
++            try:
++                # notebook 6
++                from notebook.notebookapp import main
++            except ImportError:
++                # notebook 7
++                from notebook.app import main
+         except ImportError:
+             import traceback
+             traceback.print_exc()
diff --git a/srcpkgs/sagemath/patches/36544-networkx_3.2.patch b/srcpkgs/sagemath/patches/36544-networkx_3.2.patch
new file mode 100644
index 0000000000000..efcc935ac5476
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36544-networkx_3.2.patch
@@ -0,0 +1,41 @@
+diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py
+index eedbc36bef3..3fdc241a1c4 100644
+--- a/src/sage/graphs/generic_graph.py
++++ b/src/sage/graphs/generic_graph.py
+@@ -5102,13 +5102,13 @@ def cycle_basis(self, output='vertex'):
+         A cycle basis in Petersen's Graph ::
+ 
+             sage: g = graphs.PetersenGraph()
+-            sage: g.cycle_basis()                                                       # needs networkx
++            sage: g.cycle_basis()                                                       # needs networkx, random (changes in networkx 3.2)
+             [[1, 6, 8, 5, 0], [4, 9, 6, 8, 5, 0], [7, 9, 6, 8, 5],
+              [4, 3, 8, 5, 0], [1, 2, 3, 8, 5, 0], [7, 2, 3, 8, 5]]
+ 
+         One can also get the result as a list of lists of edges::
+ 
+-            sage: g.cycle_basis(output='edge')                                          # needs networkx
++            sage: g.cycle_basis(output='edge')                                          # needs networkx, random (changes in networkx 3.2)
+             [[(1, 6, None), (6, 8, None), (8, 5, None), (5, 0, None),
+              (0, 1, None)], [(4, 9, None), (9, 6, None), (6, 8, None),
+              (8, 5, None), (5, 0, None), (0, 4, None)], [(7, 9, None),
+@@ -5273,9 +5273,9 @@ def minimum_cycle_basis(self, algorithm=None, weight_function=None, by_weight=Fa
+             [[1, 2, 3], [1, 2, 3, 4], [5, 6, 7]]
+             sage: sorted(g.minimum_cycle_basis(by_weight=False))
+             [[1, 2, 3], [1, 3, 4], [5, 6, 7]]
+-            sage: sorted(g.minimum_cycle_basis(by_weight=True, algorithm='NetworkX'))   # needs networkx
++            sage: sorted(g.minimum_cycle_basis(by_weight=True, algorithm='NetworkX'))   # needs networkx, random (changes in networkx 3.2)
+             [[1, 2, 3], [1, 2, 3, 4], [5, 6, 7]]
+-            sage: g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX')          # needs networkx
++            sage: g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX')          # needs networkx, random (changes in networkx 3.2)
+             [[1, 2, 3], [1, 3, 4], [5, 6, 7]]
+ 
+         ::
+@@ -5283,7 +5283,7 @@ def minimum_cycle_basis(self, algorithm=None, weight_function=None, by_weight=Fa
+             sage: g = Graph([(1, 2), (2, 3), (3, 4), (4, 5), (5, 1), (5, 3)])
+             sage: sorted(g.minimum_cycle_basis(by_weight=False))
+             [[1, 2, 3, 5], [3, 4, 5]]
+-            sage: sorted(g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX'))  # needs networkx
++            sage: sorted(g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX'))  # needs networkx, random (changes in networkx 3.2)
+             [[1, 2, 3, 5], [3, 4, 5]]
+ 
+         TESTS::
diff --git a/srcpkgs/sagemath/patches/get_patches b/srcpkgs/sagemath/patches/get_patches
index 95a6963432948..94992f4978f8c 100755
--- a/srcpkgs/sagemath/patches/get_patches
+++ b/srcpkgs/sagemath/patches/get_patches
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-version=10.1
+version=10.2.beta8
 
 URL_BASE_PR="https://github.com/sagemath/sage/pull/"
 URL_BASE_COMPARE="https://github.com/sagemath/sage/compare/${version}..."
@@ -20,24 +20,9 @@ get_pr() {
 # run from patches dir
 cd $(dirname "$0")
 
-# merged in 10.2.beta0
-#get_pr  36018   "singular 4.3.2p4" # included in #35934
-get_pr  36046   "fix memory leak"
-
-# merged in 10.2.beta1
-get_pr  35934   "singular 4.3.2p7"
-
-# merged in 10.2.beta2
-get_pr  36006   "gmp 6.3.0"
-
-# merged in 10.2.beta3
-get_pr  36235   "ecl 23.9.9"
-
-# merged in 10.2.beta4
-get_pr  36279   "matplotlib 3.8.0"
-
 # positive review
-#get_pr  36403   "python 3.12" # included in #36407
+get_pr  36506   "notebook 7"
 
 # needs review
-get_pr  36407   "python 3.12"
+get_pr  35848   "flintlib 3.0"
+get_pr  36544   "networkx 3.2"
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index a80d8b7187ece..eb0ad26438538 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,14 +1,14 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=10.1
-revision=4
+version=10.2.beta8
+revision=1
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
 _bindir=/usr/lib/sagemath/$version/bin
 make_install_args="--install-scripts=$_bindir"
-hostmakedepends="m4 pkg-config python3-Cython0.29 python3-Jinja2
+hostmakedepends="m4 pkg-config python3-Cython python3-Jinja2
  python3-pkgconfig python3-setuptools"
-makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
+makedepends="boost-devel brial-devel cliquer-devel ecl eclib-devel
  ecm-devel fflas-ffpack flintlib-devel gap-devel gd-devel giac-devel glpk-devel
  gsl-devel iml-devel lcalc-devel libbraiding-devel libhomfly-devel libmpc-devel
  libpng-devel linbox-devel m4ri-devel m4rie-devel mpfi-devel
@@ -18,7 +18,7 @@ makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
 depends="eclib-devel fflas-ffpack flintlib-devel gcc-fortran gd-devel
  gfan giac gsl-devel gzip libpng-devel linbox-devel m4ri-devel maxima-ecl
  mpfr-devel nauty ntl-devel palp pari-devel pari-elldata-small pari-galdata
- pari-galpol-small pari-seadata-small pkg-config python3-Cython0.29 python3-cypari2
+ pari-galpol-small pari-seadata-small pkg-config python3-Cython python3-cypari2
  python3-cysignals python3-devel python3-fpylll python3-ipython python3-lrcalc
  python3-ipython_ipykernel python3-jupyter_ipywidgets python3-matplotlib
  python3-memory_allocator python3-networkx python3-pip python3-pkgconfig
@@ -33,7 +33,7 @@ license="GPL-2.0-or-later"
 homepage="https://www.sagemath.org/"
 changelog="https://github.com/sagemath/sage/releases"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=a658612b1b2376ddaf207cc8ed0ef458d4c2880c16e19139bedbe8baa42ad62f
+checksum=3bb0d92f1deeadbe5108afb6e41d1c189c84898b063110507ec9f9c9a52d9ddb
 nocross="due to ntl (flintlib), fflas-ffpack, givaro, linbox, cysignals, sympow, maxima"
 
 post_patch() {

From b829585b2b1516cf51335613e5b509162c357a3c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Sun, 29 Oct 2023 21:15:17 -0300
Subject: [PATCH 7/7] sagemath: update to 10.2.beta9.

---
 .../sagemath/patches/36506-notebook_7.patch   |  18 --
 .../patches/36543-cython_warning.patch        |  49 ++++
 .../sagemath/patches/36551-fix_qf.nbs.patch   |  85 +++++++
 .../patches/36573-relative_imports.patch      | 210 ++++++++++++++++++
 .../patches/36600-giac_1.9.0-67.patch         |  52 +++++
 srcpkgs/sagemath/patches/get_patches          |   9 +-
 srcpkgs/sagemath/template                     |   4 +-
 7 files changed, 404 insertions(+), 23 deletions(-)
 delete mode 100644 srcpkgs/sagemath/patches/36506-notebook_7.patch
 create mode 100644 srcpkgs/sagemath/patches/36543-cython_warning.patch
 create mode 100644 srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
 create mode 100644 srcpkgs/sagemath/patches/36573-relative_imports.patch
 create mode 100644 srcpkgs/sagemath/patches/36600-giac_1.9.0-67.patch

diff --git a/srcpkgs/sagemath/patches/36506-notebook_7.patch b/srcpkgs/sagemath/patches/36506-notebook_7.patch
deleted file mode 100644
index a7d93d52c1b4a..0000000000000
--- a/srcpkgs/sagemath/patches/36506-notebook_7.patch
+++ /dev/null
@@ -1,18 +0,0 @@
-diff --git a/src/bin/sage-notebook b/src/bin/sage-notebook
-index 2e8b12e1a1c..801b0a6a6a3 100755
---- a/src/bin/sage-notebook
-+++ b/src/bin/sage-notebook
-@@ -29,7 +29,12 @@ class NotebookJupyter():
-     def __init__(self, argv):
-         self.print_banner()
-         try:
--            from notebook.notebookapp import main
-+            try:
-+                # notebook 6
-+                from notebook.notebookapp import main
-+            except ImportError:
-+                # notebook 7
-+                from notebook.app import main
-         except ImportError:
-             import traceback
-             traceback.print_exc()
diff --git a/srcpkgs/sagemath/patches/36543-cython_warning.patch b/srcpkgs/sagemath/patches/36543-cython_warning.patch
new file mode 100644
index 0000000000000..f0e3d4114342f
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36543-cython_warning.patch
@@ -0,0 +1,49 @@
+diff --git a/src/sage/cpython/dict_del_by_value.pyx b/src/sage/cpython/dict_del_by_value.pyx
+index 19dd2bb2731..fdeb5fee8ff 100644
+--- a/src/sage/cpython/dict_del_by_value.pyx
++++ b/src/sage/cpython/dict_del_by_value.pyx
+@@ -46,31 +46,6 @@ cdef extern from "dict_internal.h":
+         PyObject * me_key
+         PyObject * me_value
+ 
+-
+-# dk_lookup was removed in python 3.11
+-DEF HAS_DK_LOOKUP = PY_VERSION_HEX < 0x30b0000
+-
+-IF HAS_DK_LOOKUP:
+-
+-    cdef extern from *:
+-        """
+-        #define DK_LOOKUP(dk) ((dk)->dk_lookup)
+-        """
+-        ctypedef void * dict_lookup_func  # Precise definition not needed
+-        dict_lookup_func DK_LOOKUP(PyDictKeysObject *mp)
+-
+-    cdef dict_lookup_func lookdict
+-
+-    def init_lookdict():
+-        global lookdict
+-        # A dict which a non-string key uses the generic "lookdict"
+-        # as lookup function
+-        cdef object D = {}
+-        D[0] = 0
+-        lookdict = DK_LOOKUP((<PyDictObject *>D).ma_keys)
+-
+-    init_lookdict()
+-
+ cdef int del_dictitem_by_exact_value(PyDictObject *mp, PyObject *value, Py_hash_t hash) except -1:
+     """
+     This is used in callbacks for the weak values of :class:`WeakValueDictionary`.
+@@ -147,12 +122,6 @@ cdef int del_dictitem_by_exact_value(PyDictObject *mp, PyObject *value, Py_hash_
+             return 0
+         ep = &(entries[ix])
+ 
+-    # We need the lookup function to be the generic lookdict, otherwise
+-    # deletions may not work correctly
+-    IF HAS_DK_LOOKUP:
+-        # Can this fail? In any case dk_lookup was removed in python 3.11
+-        assert DK_LOOKUP(keys) is lookdict
+-
+     T = PyList_New(2)
+     PyList_SetItem(T, 0, ep.me_key)
+     PyList_SetItem(T, 1, ep.me_value)
diff --git a/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch b/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
new file mode 100644
index 0000000000000..537edea9bfafa
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
@@ -0,0 +1,85 @@
+diff --git a/src/sage/quadratic_forms/quadratic_form__neighbors.py b/src/sage/quadratic_forms/quadratic_form__neighbors.py
+index 94f6559d51a..9bf5e2d7de6 100644
+--- a/src/sage/quadratic_forms/quadratic_form__neighbors.py
++++ b/src/sage/quadratic_forms/quadratic_form__neighbors.py
+@@ -74,6 +74,10 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+         sage: v = Q.find_primitive_p_divisible_vector__next(5, v); v
+         (1, 0)
+         sage: v = Q.find_primitive_p_divisible_vector__next(5, v); v
++        sage: v = Q.find_primitive_p_divisible_vector__next(2) ; v
++        (0, 1)
++        sage: v = Q.find_primitive_p_divisible_vector__next(2, v) ; v
++        (1, 0)
+         sage: Q = QuadraticForm(QQ, matrix.diagonal([1,1,1,1]))
+         sage: v = Q.find_primitive_p_divisible_vector__next(2)
+         sage: Q(v)
+@@ -83,6 +87,9 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+     n = self.dim()
+     if v is None:
+         w = vector(ZZ, [0] * (n - 1) + [1])
++        a = self(w)
++        if a in ZZ and (a % p == 0):
++            return w
+     else:
+         w = deepcopy(v)
+ 
+@@ -132,7 +139,7 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+             return w
+ 
+ 
+-def find_p_neighbor_from_vec(self, p, y):
++def find_p_neighbor_from_vec(self, p, y, return_matrix=False):
+     r"""
+     Return the `p`-neighbor of ``self`` defined by ``y``.
+ 
+@@ -147,25 +154,32 @@ def find_p_neighbor_from_vec(self, p, y):
+     - ``p`` -- a prime number
+     - ``y`` -- a vector with `q(y) \in p \ZZ`
+     - ``odd`` -- (default: ``False``) if `p=2`, return also odd neighbors
++    - ``return_matrix`` -- (boolean, default ``False``) return
++      the transformation matrix instead of the quadratic form
+ 
+     EXAMPLES::
+ 
++        sage: # needs sage.libs.pari
+         sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1,1])
+         sage: v = vector([0,2,1,1])
+-        sage: X = Q.find_p_neighbor_from_vec(3, v); X                                   # needs sage.libs.pari
++        sage: X = Q.find_p_neighbor_from_vec(3, v); X
+         Quadratic form in 4 variables over Integer Ring with coefficients:
+         [ 1 0 0 0 ]
+         [ * 1 4 4 ]
+         [ * * 5 12 ]
+         [ * * * 9 ]
++        sage: B = Q.find_p_neighbor_from_vec(3, v, return_matrix=True)
++        sage: Q(B) == X
++        True
+ 
+     Since the base ring and the domain are not yet separate,
+     for rational, half integral forms we just pretend
+     the base ring is `\ZZ`::
+ 
++        sage: # needs sage.libs.pari
+         sage: Q = QuadraticForm(QQ, matrix.diagonal([1,1,1,1]))
+         sage: v = vector([1,1,1,1])
+-        sage: Q.find_p_neighbor_from_vec(2, v)                                          # needs sage.libs.pari
++        sage: Q.find_p_neighbor_from_vec(2, v)
+         Quadratic form in 4 variables over Rational Field with coefficients:
+         [ 1/2 1 1 1 ]
+         [ * 1 1 2 ]
+@@ -227,9 +241,12 @@ def find_p_neighbor_from_vec(self, p, y):
+     # by definition this is the p-neighbor of L at y
+     # assert B.det().abs() == 1
+ 
+-    QF = self.parent()
+-    Gnew = (B*G*B.T).change_ring(R)
+-    return QF(Gnew)
++    if return_matrix:
++        return B.T
++    else:
++        QF = self.parent()
++        Gnew = (B*G*B.T).change_ring(R)
++        return QF(Gnew)
+ 
+ 
+ def neighbor_iteration(seeds, p, mass=None, max_classes=ZZ(10)**3,
diff --git a/srcpkgs/sagemath/patches/36573-relative_imports.patch b/srcpkgs/sagemath/patches/36573-relative_imports.patch
new file mode 100644
index 0000000000000..77481909d9fac
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36573-relative_imports.patch
@@ -0,0 +1,210 @@
+diff --git a/src/sage/structure/all.py b/src/sage/structure/all.py
+index 311bf869ef2..df0114c8382 100644
+--- a/src/sage/structure/all.py
++++ b/src/sage/structure/all.py
+@@ -1,12 +1,12 @@
+-from .factorization import Factorization
++from sage.structure.factorization import Factorization
+ 
+-from .sequence import Sequence, seq
++from sage.structure.sequence import Sequence, seq
+ 
+-from .unique_representation import UniqueRepresentation
++from sage.structure.unique_representation import UniqueRepresentation
+ 
+-from .sage_object import SageObject
++from sage.structure.sage_object import SageObject
+ 
+-from .element import (
++from sage.structure.element import (
+     canonical_coercion,
+     coercion_model,
+     get_coercion_model,
+@@ -14,16 +14,16 @@
+     parent
+     )
+ 
+-from .parent import Parent
++from sage.structure.parent import Parent
+ 
+-from .parent_gens import localvars
++from sage.structure.parent_gens import localvars
+ 
+-from .proof import all as proof
++from sage.structure.proof import all as proof
+ 
+ from sage.misc.lazy_import import lazy_import
+ lazy_import('sage.structure.formal_sum', ['FormalSums', 'FormalSum'])
+ del lazy_import
+ 
+-from .mutability import Mutability
++from sage.structure.mutability import Mutability
+ 
+-from .element_wrapper import ElementWrapper
++from sage.structure.element_wrapper import ElementWrapper
+diff --git a/src/sage/structure/coerce.pxd b/src/sage/structure/coerce.pxd
+index e070d1c32e4..812cb5d5c7c 100644
+--- a/src/sage/structure/coerce.pxd
++++ b/src/sage/structure/coerce.pxd
+@@ -1,5 +1,5 @@
+-from .parent cimport Parent
+-from .coerce_dict cimport TripleDict
++from sage.structure.parent cimport Parent
++from sage.structure.coerce_dict cimport TripleDict
+ 
+ cpdef py_scalar_parent(py_type)
+ cpdef py_scalar_to_element(py)
+diff --git a/src/sage/structure/coerce.pyx b/src/sage/structure/coerce.pyx
+index d8c3f684217..8f98085ba8d 100644
+--- a/src/sage/structure/coerce.pyx
++++ b/src/sage/structure/coerce.pyx
+@@ -84,11 +84,11 @@ cimport gmpy2
+ cdef mul, truediv
+ from operator import mul, truediv
+ 
+-from .richcmp cimport rich_to_bool, revop
+-from .sage_object cimport SageObject
+-from .parent cimport Parent_richcmp_element_without_coercion
+-from .element cimport bin_op_exception, parent, Element
+-from .coerce_exceptions import CoercionException
++from sage.structure.richcmp cimport rich_to_bool, revop
++from sage.structure.sage_object cimport SageObject
++from sage.structure.parent cimport Parent_richcmp_element_without_coercion
++from sage.structure.element cimport bin_op_exception, parent, Element
++from sage.structure.coerce_exceptions import CoercionException
+ from sage.rings.integer_fake cimport is_Integer
+ from sage.categories.map cimport Map
+ from sage.categories.morphism import IdentityMorphism
+diff --git a/src/sage/structure/coerce_actions.pyx b/src/sage/structure/coerce_actions.pyx
+index 6df2aec6695..3c17ac858e6 100644
+--- a/src/sage/structure/coerce_actions.pyx
++++ b/src/sage/structure/coerce_actions.pyx
+@@ -18,10 +18,10 @@ from cpython.long cimport *
+ from cpython.number cimport *
+ from cysignals.signals cimport sig_check
+ 
+-from .coerce cimport coercion_model
+-from .element cimport parent, Element, ModuleElement
+-from .parent cimport Parent
+-from .coerce_exceptions import CoercionException
++from sage.structure.coerce cimport coercion_model
++from sage.structure.element cimport parent, Element, ModuleElement
++from sage.structure.parent cimport Parent
++from sage.structure.coerce_exceptions import CoercionException
+ from sage.categories.action cimport InverseAction, PrecomposedAction
+ from sage.arith.long cimport integer_check_long
+ 
+diff --git a/src/sage/structure/element.pxd b/src/sage/structure/element.pxd
+index 20c556b985e..6be65bb1f50 100644
+--- a/src/sage/structure/element.pxd
++++ b/src/sage/structure/element.pxd
+@@ -1,5 +1,5 @@
+-from .sage_object cimport SageObject
+-from .parent cimport Parent
++from sage.structure.sage_object cimport SageObject
++from sage.structure.parent cimport Parent
+ from sage.misc.inherit_comparison cimport InheritComparisonMetaclass
+ 
+ 
+diff --git a/src/sage/structure/factory.pyx b/src/sage/structure/factory.pyx
+index ddb55501d94..50d5374e79e 100644
+--- a/src/sage/structure/factory.pyx
++++ b/src/sage/structure/factory.pyx
+@@ -56,7 +56,7 @@ AUTHORS:
+ 
+ import types
+ 
+-from .sage_object cimport SageObject
++from sage.structure.sage_object cimport SageObject
+ 
+ cdef sage_version
+ from sage.version import version as sage_version
+diff --git a/src/sage/structure/parent.pyx b/src/sage/structure/parent.pyx
+index 6548d8a3656..d40caa03307 100644
+--- a/src/sage/structure/parent.pyx
++++ b/src/sage/structure/parent.pyx
+@@ -119,13 +119,13 @@ from sage.misc.lazy_attribute import lazy_attribute
+ from sage.categories.sets_cat import Sets, EmptySetError
+ from sage.misc.lazy_string cimport _LazyString
+ from sage.sets.pythonclass cimport Set_PythonType_class
+-from .category_object import CategoryObject
+-from .coerce cimport coercion_model
+-from .coerce cimport parent_is_integers
+-from .coerce_exceptions import CoercionException
+-from .coerce_maps cimport (NamedConvertMap, DefaultConvertMap,
++from sage.structure.category_object import CategoryObject
++from sage.structure.coerce cimport coercion_model
++from sage.structure.coerce cimport parent_is_integers
++from sage.structure.coerce_exceptions import CoercionException
++from sage.structure.coerce_maps cimport (NamedConvertMap, DefaultConvertMap,
+                            DefaultConvertMap_unique, CallableConvertMap)
+-from .element cimport parent
++from sage.structure.element cimport parent
+ 
+ 
+ cdef _record_exception():
+diff --git a/src/sage/structure/parent_base.pxd b/src/sage/structure/parent_base.pxd
+index 225fccabcae..8ffac64eff2 100644
+--- a/src/sage/structure/parent_base.pxd
++++ b/src/sage/structure/parent_base.pxd
+@@ -6,7 +6,7 @@
+ #                  https://www.gnu.org/licenses/
+ ###############################################################################
+ 
+-from .parent_old cimport Parent as Parent_old
++from sage.structure.parent_old cimport Parent as Parent_old
+ 
+ cdef class ParentWithBase(Parent_old):
+     pass
+diff --git a/src/sage/structure/parent_base.pyx b/src/sage/structure/parent_base.pyx
+index dd697f90135..b41175b5bff 100644
+--- a/src/sage/structure/parent_base.pyx
++++ b/src/sage/structure/parent_base.pyx
+@@ -12,7 +12,7 @@ Base class for old-style parent objects with a base ring
+ # ****************************************************************************
+ 
+ cimport sage.structure.parent as parent
+-from .coerce_exceptions import CoercionException
++from sage.structure.coerce_exceptions import CoercionException
+ 
+ cdef inline check_old_coerce(parent.Parent p):
+     if p._element_constructor is not None:
+diff --git a/src/sage/structure/parent_gens.pxd b/src/sage/structure/parent_gens.pxd
+index 6ec0e6e83f0..cf3b416317f 100644
+--- a/src/sage/structure/parent_gens.pxd
++++ b/src/sage/structure/parent_gens.pxd
+@@ -12,7 +12,7 @@ Parent objects with generators
+ #                  http://www.gnu.org/licenses/
+ #*****************************************************************************
+ 
+-from .parent_base cimport ParentWithBase
++from sage.structure.parent_base cimport ParentWithBase
+ 
+ 
+ cdef class ParentWithGens(ParentWithBase):
+diff --git a/src/sage/structure/parent_old.pyx b/src/sage/structure/parent_old.pyx
+index 77a7888d3b8..82bf9ead04b 100644
+--- a/src/sage/structure/parent_old.pyx
++++ b/src/sage/structure/parent_old.pyx
+@@ -27,7 +27,7 @@ This came up in some subtle bug once::
+ #                  https://www.gnu.org/licenses/
+ # ****************************************************************************
+ from sage.misc.superseded import deprecation
+-from .coerce cimport py_scalar_parent
++from sage.structure.coerce cimport py_scalar_parent
+ from sage.ext.stdsage cimport HAS_DICTIONARY
+ from sage.sets.pythonclass cimport Set_PythonType, Set_PythonType_class
+ 
+diff --git a/src/sage/structure/sage_object_test.py b/src/sage/structure/sage_object_test.py
+index 0922545a62c..721c1ad7719 100644
+--- a/src/sage/structure/sage_object_test.py
++++ b/src/sage/structure/sage_object_test.py
+@@ -1,6 +1,7 @@
+ 
+ import pytest
+-from .sage_object import SageObject
++from sage.structure.sage_object import SageObject
++
+ 
+ class SageObjectTests:
+ 
diff --git a/srcpkgs/sagemath/patches/36600-giac_1.9.0-67.patch b/srcpkgs/sagemath/patches/36600-giac_1.9.0-67.patch
new file mode 100644
index 0000000000000..a1ad357828a56
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36600-giac_1.9.0-67.patch
@@ -0,0 +1,52 @@
+diff --git a/src/sage/libs/giac/__init__.py b/src/sage/libs/giac/__init__.py
+index 558cd894b13..e7d7bc67d14 100644
+--- a/src/sage/libs/giac/__init__.py
++++ b/src/sage/libs/giac/__init__.py
+@@ -172,9 +172,9 @@ def groebner_basis(gens, proba_epsilon=None, threads=None, prot=False,
+         sage: from sage.libs.giac import groebner_basis as gb_giac
+         sage: P = PolynomialRing(GF(previous_prime(2**31)), 6, 'x')
+         sage: I = sage.rings.ideal.Cyclic(P)
+-        sage: B=gb_giac(I.gens());B
+-        <BLANKLINE>
+-        // Groebner basis computation time ...
++        sage: B = gb_giac(I.gens())
++        ...
++        sage: B
+         Polynomial Sequence with 45 Polynomials in 6 Variables
+         sage: B.is_groebner()
+         True
+@@ -184,8 +184,7 @@ def groebner_basis(gens, proba_epsilon=None, threads=None, prot=False,
+         sage: P = PolynomialRing(GF(previous_prime(2**31)), 5, 'x')
+         sage: I = sage.rings.ideal.Cyclic(P)
+         sage: B = gb_giac(I.gens(), elim_variables=[P.gen(0), P.gen(2)])
+-        <BLANKLINE>
+-        // Groebner basis computation time ...
++        ...
+         sage: B.is_groebner()
+         True
+         sage: B.ideal() == I.elimination_ideal([P.gen(0), P.gen(2)])
+@@ -201,11 +200,10 @@ def groebner_basis(gens, proba_epsilon=None, threads=None, prot=False,
+         ...
+         sage: sage.structure.proof.all.polynomial(True)
+         sage: B2 = gb_giac(I.gens()) # long time (4s)
+-        <BLANKLINE>
+-        // Groebner basis computation time...
++        ...
+         sage: B1 == B2 # long time
+         True
+-        sage: B1.is_groebner() # long time (20s)
++        sage: B1.is_groebner() # not tested, too long time (50s)
+         True
+ 
+     * multi threaded operations::
+@@ -253,9 +251,7 @@ def groebner_basis(gens, proba_epsilon=None, threads=None, prot=False,
+         sage: libgiac.purge('x2'),libgiac.purge('x4')
+         (22, whywouldyoudothis)
+         sage: gb_giac(I) # long time (3s)
+-        <BLANKLINE>
+-        // Groebner basis computation time...
+-        Polynomial Sequence with 74 Polynomials in 8 Variables
++        ...Polynomial Sequence with 74 Polynomials in 8 Variables
+ 
+         sage: I = ideal(P(0),P(0))
+         sage: I.groebner_basis() == gb_giac(I)
diff --git a/srcpkgs/sagemath/patches/get_patches b/srcpkgs/sagemath/patches/get_patches
index 94992f4978f8c..ea4d23c49f3ed 100755
--- a/srcpkgs/sagemath/patches/get_patches
+++ b/srcpkgs/sagemath/patches/get_patches
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-version=10.2.beta8
+version=10.2.beta9
 
 URL_BASE_PR="https://github.com/sagemath/sage/pull/"
 URL_BASE_COMPARE="https://github.com/sagemath/sage/compare/${version}..."
@@ -21,8 +21,11 @@ get_pr() {
 cd $(dirname "$0")
 
 # positive review
-get_pr  36506   "notebook 7"
+get_pr  36544   "networkx 3.2"
 
 # needs review
 get_pr  35848   "flintlib 3.0"
-get_pr  36544   "networkx 3.2"
+get_pr  36543   "cython warning"
+get_pr  36551   "fix qf.nbs"
+get_pr  36573   "relative imports"
+get_pr  36600   "giac 1.9.0-67"
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index eb0ad26438538..75f39fe5b0374 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,6 +1,6 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=10.2.beta8
+version=10.2.beta9
 revision=1
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
@@ -33,7 +33,7 @@ license="GPL-2.0-or-later"
 homepage="https://www.sagemath.org/"
 changelog="https://github.com/sagemath/sage/releases"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=3bb0d92f1deeadbe5108afb6e41d1c189c84898b063110507ec9f9c9a52d9ddb
+checksum=e6899566ca0c7c45984738aaf3378930d0f1746381daab8f61fb2e4b78af7394
 nocross="due to ntl (flintlib), fflas-ffpack, givaro, linbox, cysignals, sympow, maxima"
 
 post_patch() {

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

* Re: [PR PATCH] [Updated] [WIP] flintlib: update to 3.0.0 / track sagemath-10.2 prereleases
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (3 preceding siblings ...)
  2023-10-31  1:28 ` tornaria
@ 2023-10-31  1:43 ` tornaria
  2023-11-07  2:21 ` tornaria
                   ` (23 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: tornaria @ 2023-10-31  1:43 UTC (permalink / raw)
  To: ml

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

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

https://github.com/tornaria/void-packages flintlib
https://github.com/void-linux/void-packages/pull/46832

[WIP] flintlib: update to 3.0.0 / track sagemath-10.2 prereleases
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **briefly**

This is a major update. A couple of packages need rebuilding (eclib, singular).

For sagemath, we need a patch (in progress: https://github.com/sagemath/sage/pull/35848).

Since backporting patches is a pain and we are not in a hurry, I'm instead targeting 10.2.beta8. Note this already moves sagemath to cython 3.

The goal is to merge flintlib 3.0 together with sagemath 10.2 when the latter is released.

<!--
#### 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/46832.patch is attached

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

From b87ce21651f4d14a27d322868edeb36dd8b4e75c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 11 Sep 2023 20:11:20 -0300
Subject: [PATCH 1/7] flintlib: update to 3.0.0.

---
 common/shlibs                                 |  3 +-
 srcpkgs/arb                                   |  1 +
 srcpkgs/arb-devel                             |  2 +-
 srcpkgs/arb/template                          | 24 ------------
 .../patches/1545-fix_openblas_detection.patch | 32 ++++++++++++++++
 ...6723b1d74e66605c111483756322ebb1bc8d.patch | 37 +++++++++++++++++++
 .../patches/fix-test-t-sdiv_qrnnd.patch       | 23 ------------
 srcpkgs/flintlib/template                     | 29 ++++++++++++---
 8 files changed, 96 insertions(+), 55 deletions(-)
 create mode 120000 srcpkgs/arb
 delete mode 100644 srcpkgs/arb/template
 create mode 100644 srcpkgs/flintlib/patches/1545-fix_openblas_detection.patch
 create mode 100644 srcpkgs/flintlib/patches/1546-fix_nmod32_in_i686-7d046723b1d74e66605c111483756322ebb1bc8d.patch
 delete mode 100644 srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch

diff --git a/common/shlibs b/common/shlibs
index 9036a675c1ae5..cc76d4e8cfafd 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3974,8 +3974,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.17 flintlib-2.9.0_1
-libarb.so.2 arb-2.20.0_1
+libflint.so.18 flintlib-3.0.0_1
 libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
diff --git a/srcpkgs/arb b/srcpkgs/arb
new file mode 120000
index 0000000000000..7c2633183069f
--- /dev/null
+++ b/srcpkgs/arb
@@ -0,0 +1 @@
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb-devel b/srcpkgs/arb-devel
index 456b9f00a86cd..7c2633183069f 120000
--- a/srcpkgs/arb-devel
+++ b/srcpkgs/arb-devel
@@ -1 +1 @@
-arb
\ No newline at end of file
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
deleted file mode 100644
index 84a62c7ffdba3..0000000000000
--- a/srcpkgs/arb/template
+++ /dev/null
@@ -1,24 +0,0 @@
-# Template file for 'arb'
-pkgname=arb
-version=2.23.0
-revision=1
-build_style=configure
-configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
-makedepends="flintlib-devel"
-short_desc="C library for arbitrary-precision interval arithmetic"
-maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
-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=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
-
-arb-devel_package() {
-	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"
-	short_desc+=" - development files"
-	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.a"
-		vmove "usr/lib/*.so"
-	}
-}
diff --git a/srcpkgs/flintlib/patches/1545-fix_openblas_detection.patch b/srcpkgs/flintlib/patches/1545-fix_openblas_detection.patch
new file mode 100644
index 0000000000000..133e93eb07341
--- /dev/null
+++ b/srcpkgs/flintlib/patches/1545-fix_openblas_detection.patch
@@ -0,0 +1,32 @@
+From d818f171ec1907d815bbf7ccbb80968ca5a024ec Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Fri, 20 Oct 2023 18:56:58 -0300
+Subject: [PATCH] Fix use of AC_SEARCH_LIBS to find cblas_dgemm
+
+Without this change, configure only tries with `-lcblas` since
+`AC_SEARCH_LIBS` caches the result based on function name.
+---
+ configure.ac | 8 ++------
+ 1 file changed, 2 insertions(+), 6 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 84ba9de832..676e5ff886 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -705,14 +705,10 @@ fi
+ 
+ if test "$with_blas" = "yes";
+ then
+-    AC_SEARCH_LIBS([cblas_dgemm],[cblas],[],
+-        [AC_SEARCH_LIBS([cblas_dgemm],[openblas],[],
+-            [AC_SEARCH_LIBS([cblas_dgemm],[blas],[],
+-                [AC_MSG_ERROR([BLAS library was not found.  If you indeed have BLAS installed, please
++    AC_SEARCH_LIBS([cblas_dgemm],[cblas openblas blas],[],
++        [AC_MSG_ERROR([BLAS library was not found.  If you indeed have BLAS installed, please
+ submit a bug report to <https://github.com/flintlib/flint/issues/> so
+ that we can either fix the issue or give a more proper error message.])]
+-            )]
+-        )]
+     )
+ fi
+ 
diff --git a/srcpkgs/flintlib/patches/1546-fix_nmod32_in_i686-7d046723b1d74e66605c111483756322ebb1bc8d.patch b/srcpkgs/flintlib/patches/1546-fix_nmod32_in_i686-7d046723b1d74e66605c111483756322ebb1bc8d.patch
new file mode 100644
index 0000000000000..f98882112f3f8
--- /dev/null
+++ b/srcpkgs/flintlib/patches/1546-fix_nmod32_in_i686-7d046723b1d74e66605c111483756322ebb1bc8d.patch
@@ -0,0 +1,37 @@
+From 7d046723b1d74e66605c111483756322ebb1bc8d Mon Sep 17 00:00:00 2001
+From: Fredrik Johansson <fredrik.johansson@gmail.com>
+Date: Sat, 21 Oct 2023 13:43:37 +0200
+Subject: [PATCH] fix nmod32 on 32-bit systems
+
+---
+ src/gr/nmod32.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/src/gr/nmod32.c b/src/gr/nmod32.c
+index fde79822ac..31ee4e0184 100644
+--- a/src/gr/nmod32.c
++++ b/src/gr/nmod32.c
+@@ -325,7 +325,11 @@ _nmod32_vec_add(nmod32_struct * res, const nmod32_struct * vec1, const nmod32_st
+     nmod_t mod = NMOD32_CTX(ctx);
+ 
+     for (i = 0; i < len; i++)
++#if FLINT_BITS == 64
+         res[i] = _nmod_add(vec1[i], vec2[i], mod);
++#else
++        res[i] = nmod_add(vec1[i], vec2[i], mod);
++#endif
+ 
+     return GR_SUCCESS;
+ }
+@@ -337,7 +341,11 @@ _nmod32_vec_sub(nmod32_struct * res, const nmod32_struct * vec1, const nmod32_st
+     nmod_t mod = NMOD32_CTX(ctx);
+ 
+     for (i = 0; i < len; i++)
++#if FLINT_BITS == 64
++        res[i] = _nmod_sub(vec1[i], vec2[i], mod);
++#else
+         res[i] = nmod_sub(vec1[i], vec2[i], mod);
++#endif
+ 
+     return GR_SUCCESS;
+ }
diff --git a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch b/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
deleted file mode 100644
index cfa109792892c..0000000000000
--- a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From fb8ddbcc06afa2a8f25637032fbb8211f6c6c122 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= <albin.ahlback@gmail.com>
-Date: Fri, 20 May 2022 14:16:38 +0200
-Subject: [PATCH] Fix bug in test code for GCC 12
-
----
- test/t-sdiv_qrnnd.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/test/t-sdiv_qrnnd.c b/test/t-sdiv_qrnnd.c
-index 2e9822e848..2676903826 100644
---- a/test/t-sdiv_qrnnd.c
-+++ b/test/t-sdiv_qrnnd.c
-@@ -33,7 +33,7 @@ int main(void)
-         {
-             d = n_randtest_not_zero(state);
-             nh = n_randtest(state);
--        } while ((FLINT_ABS(nh) >= FLINT_ABS(d)/2) || (nh == WORD_MIN));
-+        } while ((nh == WORD_MIN) || (FLINT_ABS(nh) >= FLINT_ABS(d)/2));
- 
-         nl = n_randtest(state);
- 
-
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index f7442c8052aaa..845ed41e25960 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,10 +1,11 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.9.0
+version=3.0.0
 revision=1
-build_style=configure
+build_style=gnu-configure
 configure_args="--prefix=/usr $(vopt_with ntl)
- $(vopt_if openblas --with-blas=${XBPS_CROSS_BASE}/usr/include/openblas)"
+ $(vopt_if openblas --with-blas-include=${XBPS_CROSS_BASE}/usr/include/openblas)"
+hostmakedepends="automake gettext-devel libtool"
 makedepends="mpfr-devel $(vopt_if ntl ntl-devel)
  $(vopt_if openblas openblas-devel)"
 short_desc="Fast Library for Number Theory"
@@ -12,8 +13,8 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 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=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
+distfiles="https://flintlib.org/flint-${version/.alpha/-alpha}.tar.gz"
+checksum=b9086e31e3dab89896d7edbf05a5b758d5b4b72183a1a3478f23eabdcaaae044
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
@@ -28,12 +29,30 @@ esac
 
 CFLAGS="-D_GNU_SOURCE" # needed for cpu_set_t
 
+post_patch() {
+	# run autoconf because we patched configure.ac
+	autoreconf
+}
+
 flintlib-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision} mpfr-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
+		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
 		vmove "usr/lib/*.so"
 	}
 }
+
+arb_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}
+
+arb-devel_package() {
+	depends="${sourcepkg}-devel>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From e73a0c352fb94c3387df97e3f79679d26214bf9b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:08:05 -0300
Subject: [PATCH 2/7] eclib: rebuild for flintlib-3.0.0

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

diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 1d4ad58f21b7b..12165ca788dd5 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
 version=20230424
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 makedepends="pari-devel ntl-devel flintlib-devel boost-devel"

From 8a0f3aca9c926207abc00a6cb95faeb858a641d8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:13:15 -0300
Subject: [PATCH 3/7] singular: update to 4.3.2p10.

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

diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index 036e19d470354..beb0e6d30118e 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,6 +1,6 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.2p7
+version=4.3.2p10
 revision=1
 _majver=${version%p*}
 build_style=gnu-configure
@@ -20,7 +20,7 @@ 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/${_majver//./-}/singular-${version}.tar.gz"
-checksum=aad23c30066b7fbc011138a98d60532565d76a847eec6bf2938410d93b272ca3
+checksum=28c2c9fcfee954e00dfa56eb1a7d418d5b1de67c4398d25a0f2b8f73e71552a8
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From 3044b743f7f93fea355633f9771d107ac97ea9ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 19 Jul 2023 21:04:33 -0300
Subject: [PATCH 4/7] python3-pplpy: use cython 3.

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

diff --git a/srcpkgs/python3-pplpy/template b/srcpkgs/python3-pplpy/template
index 4a9c987b2a859..d3b9aebdf2237 100644
--- a/srcpkgs/python3-pplpy/template
+++ b/srcpkgs/python3-pplpy/template
@@ -1,9 +1,9 @@
 # Template file for 'python3-pplpy'
 pkgname=python3-pplpy
 version=0.8.9
-revision=1
+revision=2
 build_style=python3-pep517
-hostmakedepends="python3-setuptools python3-wheel python3-Cython0.29
+hostmakedepends="python3-setuptools python3-wheel python3-Cython
  python3-cysignals python3-gmpy2"
 makedepends="python3-devel gmp-devel gmpxx-devel ppl-devel mpfr-devel
  libmpc-devel pari-devel"

From aa8694c953f8da4f0d320501233230b4afa6f7d0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Thu, 19 Oct 2023 08:52:15 -0300
Subject: [PATCH 5/7] python3-networkx: update to 3.2.1.

---
 srcpkgs/python3-networkx/template | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/python3-networkx/template b/srcpkgs/python3-networkx/template
index 186bf64f7bff9..29283d9e5a032 100644
--- a/srcpkgs/python3-networkx/template
+++ b/srcpkgs/python3-networkx/template
@@ -1,11 +1,11 @@
 # Template file for 'python3-networkx'
 pkgname=python3-networkx
-version=3.1
-revision=2
-build_style=python3-module
+version=3.2.1
+revision=1
+build_style=python3-pep517
 # failing in i686
 make_check_args="--deselect networkx/algorithms/approximation/tests/test_traveling_salesman.py::test_asadpour_tsp"
-hostmakedepends="python3-setuptools"
+hostmakedepends="python3-setuptools python3-wheel"
 depends="python3"
 checkdepends="python3-numpy python3-scipy python3-matplotlib python3-pandas
  python3-lxml python3-sympy python3-pytest-xdist"
@@ -15,7 +15,7 @@ license="BSD-3-Clause"
 homepage="https://networkx.org"
 changelog="https://github.com/networkx/networkx/raw/main/doc/release/release_${version}.rst"
 distfiles="${PYPI_SITE}/n/networkx/networkx-${version}.tar.gz"
-checksum=de346335408f84de0eada6ff9fafafff9bcda11f0a0dfaa931133debb146ab61
+checksum=9f1bb5cf3409bf324e0a722c20bdb4c20ee39bf1c30ce8ae499c8502b0b5e0c6
 
 post_install() {
 	vlicense LICENSE.txt

From c163ebd29248d8b68b078b5e4a6e9445ea163cc8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:50:44 -0300
Subject: [PATCH 6/7] sagemath: update to 10.2.beta8 (patch for
 flintlib-3.0.0).

---
 .../sagemath/patches/35848-flintlib_3.0.patch | 1738 ++++++++++++++++
 .../patches/35934-singular_4.3.2p7.patch      |  221 ---
 .../sagemath/patches/36006-gmp_6.3.0.patch    |   38 -
 .../patches/36046-fix_memory_leak.patch       |  740 -------
 .../sagemath/patches/36235-ecl_23.9.9.patch   |   39 -
 .../patches/36279-matplotlib_3.8.0.patch      |   24 -
 srcpkgs/sagemath/patches/36403-00pre.patch    |   29 -
 .../sagemath/patches/36407-python_3.12.patch  | 1744 -----------------
 .../sagemath/patches/36506-notebook_7.patch   |   18 +
 .../sagemath/patches/36544-networkx_3.2.patch |   41 +
 srcpkgs/sagemath/patches/get_patches          |   23 +-
 srcpkgs/sagemath/template                     |   12 +-
 12 files changed, 1807 insertions(+), 2860 deletions(-)
 create mode 100644 srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
 delete mode 100644 srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
 delete mode 100644 srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
 delete mode 100644 srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36403-00pre.patch
 delete mode 100644 srcpkgs/sagemath/patches/36407-python_3.12.patch
 create mode 100644 srcpkgs/sagemath/patches/36506-notebook_7.patch
 create mode 100644 srcpkgs/sagemath/patches/36544-networkx_3.2.patch

diff --git a/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
new file mode 100644
index 0000000000000..ed3d6d1913433
--- /dev/null
+++ b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
@@ -0,0 +1,1738 @@
+diff --git a/build/pkgs/antic/SPKG.rst b/build/pkgs/antic/SPKG.rst
+deleted file mode 100644
+index d6c32377957..00000000000
+--- a/build/pkgs/antic/SPKG.rst
++++ /dev/null
+@@ -1,18 +0,0 @@
+-antic: Algebraic Number Theory In C
+-===================================
+-
+-Description
+------------
+-
+-Algebraic Number Theory In C
+-
+-License
+--------
+-
+-LGPL 2.1
+-
+-Upstream Contact
+-----------------
+-
+-https://github.com/wbhart/antic
+-
+diff --git a/build/pkgs/antic/checksums.ini b/build/pkgs/antic/checksums.ini
+deleted file mode 100644
+index fc8711ecd13..00000000000
+--- a/build/pkgs/antic/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=antic-VERSION.tar.gz
+-sha1=940d8ea2c3512b9d49ee3101cf043f777764bd8f
+-md5=4e896420dd6344b53b307871efb2cbb4
+-cksum=1938565125
+-upstream_url=https://github.com/wbhart/antic/archive/refs/tags/vVERSION.tar.gz
+diff --git a/build/pkgs/antic/dependencies b/build/pkgs/antic/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/antic/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/antic/distros/arch.txt b/build/pkgs/antic/distros/arch.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/conda.txt b/build/pkgs/antic/distros/conda.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/debian.txt b/build/pkgs/antic/distros/debian.txt
+deleted file mode 100644
+index 8fdcd3e5721..00000000000
+--- a/build/pkgs/antic/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libantic-dev
+diff --git a/build/pkgs/antic/distros/fedora.txt b/build/pkgs/antic/distros/fedora.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/freebsd.txt b/build/pkgs/antic/distros/freebsd.txt
+deleted file mode 100644
+index 116ff3a26f3..00000000000
+--- a/build/pkgs/antic/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/antic
+diff --git a/build/pkgs/antic/distros/opensuse.txt b/build/pkgs/antic/distros/opensuse.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/repology.txt b/build/pkgs/antic/distros/repology.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/package-version.txt b/build/pkgs/antic/package-version.txt
+deleted file mode 100644
+index 3a4036fb450..00000000000
+--- a/build/pkgs/antic/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-0.2.5
+diff --git a/build/pkgs/antic/spkg-install.in b/build/pkgs/antic/spkg-install.in
+deleted file mode 100644
+index c57fa884a20..00000000000
+--- a/build/pkgs/antic/spkg-install.in
++++ /dev/null
+@@ -1,19 +0,0 @@
+-cd src
+-
+-# Copied from build/pkgs/flint/spkg-install.in:
+-#   Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-#   --with-ntl because otherwise FLINT's configure script uses
+-#   /usr/local, which is always wrong.
+-#   This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-#   The value $SAGE_LOCAL is always a safe choice even if the library
+-#   is coming from the system and is found using what is in
+-#   LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-flint="$SAGE_LOCAL"  || sdh_die "Error: Failed to configure antic."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/antic/type b/build/pkgs/antic/type
+deleted file mode 100644
+index 134d9bc32d5..00000000000
+--- a/build/pkgs/antic/type
++++ /dev/null
+@@ -1 +0,0 @@
+-optional
+diff --git a/build/pkgs/arb/SPKG.rst b/build/pkgs/arb/SPKG.rst
+deleted file mode 100644
+index cff49ddb95b..00000000000
+--- a/build/pkgs/arb/SPKG.rst
++++ /dev/null
+@@ -1,27 +0,0 @@
+-arb: Arbitrary-precision floating-point ball arithmetic
+-=======================================================
+-
+-Description
+------------
+-
+-Arb is a C library for arbitrary-precision floating-point ball
+-arithmetic, developed by Fredrik Johansson
+-(fredrik.johansson@gmail.com). It supports efficient high-precision
+-computation with polynomials, power series, matrices and special
+-functions over the real and complex numbers, with automatic, rigorous
+-error control.
+-
+-License
+--------
+-
+-GNU General Public License v2+
+-
+-
+-Upstream Contact
+-----------------
+-
+- - Fredrik Johansson: fredrik.johansson@gmail.com
+-
+- - https://arblib.org/
+-
+- - http://github.com/fredrik-johansson/arb/
+diff --git a/build/pkgs/arb/checksums.ini b/build/pkgs/arb/checksums.ini
+deleted file mode 100644
+index 80ef43dad5d..00000000000
+--- a/build/pkgs/arb/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=arb-VERSION.tar.gz
+-sha1=a1efe035dd3af3613dd685971a156f652b86ff63
+-md5=9b369e29f93cdf2d4f90b57a92526cce
+-cksum=64252121
+-upstream_url=https://github.com/fredrik-johansson/arb/archive/VERSION.tar.gz
+diff --git a/build/pkgs/arb/dependencies b/build/pkgs/arb/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/arb/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/arb/distros/arch.txt b/build/pkgs/arb/distros/arch.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/conda.txt b/build/pkgs/arb/distros/conda.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/debian.txt b/build/pkgs/arb/distros/debian.txt
+deleted file mode 100644
+index 9fe71110712..00000000000
+--- a/build/pkgs/arb/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libflint-arb-dev
+diff --git a/build/pkgs/arb/distros/fedora.txt b/build/pkgs/arb/distros/fedora.txt
+deleted file mode 100644
+index 76794404627..00000000000
+--- a/build/pkgs/arb/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb arb-devel
+diff --git a/build/pkgs/arb/distros/freebsd.txt b/build/pkgs/arb/distros/freebsd.txt
+deleted file mode 100644
+index 2ef8c7cec0f..00000000000
+--- a/build/pkgs/arb/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/arb
+diff --git a/build/pkgs/arb/distros/gentoo.txt b/build/pkgs/arb/distros/gentoo.txt
+deleted file mode 100644
+index 58e3d4f8008..00000000000
+--- a/build/pkgs/arb/distros/gentoo.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-sci-mathematics/arb
+diff --git a/build/pkgs/arb/distros/homebrew.txt b/build/pkgs/arb/distros/homebrew.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/homebrew.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/nix.txt b/build/pkgs/arb/distros/nix.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/nix.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/opensuse.txt b/build/pkgs/arb/distros/opensuse.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/distros/repology.txt b/build/pkgs/arb/distros/repology.txt
+deleted file mode 100644
+index 179c9d507e1..00000000000
+--- a/build/pkgs/arb/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-fp
+diff --git a/build/pkgs/arb/distros/void.txt b/build/pkgs/arb/distros/void.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/void.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/package-version.txt b/build/pkgs/arb/package-version.txt
+deleted file mode 100644
+index e9763f6bfed..00000000000
+--- a/build/pkgs/arb/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-2.23.0
+diff --git a/build/pkgs/arb/spkg-check.in b/build/pkgs/arb/spkg-check.in
+deleted file mode 100644
+index 27cd9419538..00000000000
+--- a/build/pkgs/arb/spkg-check.in
++++ /dev/null
+@@ -1,2 +0,0 @@
+-cd src
+-$MAKE check
+diff --git a/build/pkgs/arb/spkg-configure.m4 b/build/pkgs/arb/spkg-configure.m4
+deleted file mode 100644
+index ef2dd0aac4a..00000000000
+--- a/build/pkgs/arb/spkg-configure.m4
++++ /dev/null
+@@ -1,23 +0,0 @@
+-SAGE_SPKG_CONFIGURE([arb], [
+-    AC_REQUIRE([SAGE_SPKG_CONFIGURE_FLINT])
+-    SAGE_ARB_LIBRARY="arb"
+-    AC_MSG_CHECKING([installing flint? ])
+-    if test x$sage_spkg_install_flint = xyes; then
+-        AC_MSG_RESULT([yes; install arb as well])
+-        sage_spkg_install_arb=yes
+-    else
+-        AC_CHECK_HEADER(arb.h, [
+-        dnl below function added in version 2.16 of arb
+-            AC_CHECK_LIB([arb], [acb_mat_eig_simple], [],
+-              [dnl in Debian the name of dylib is different.
+-               AC_CHECK_LIB([flint-arb], [acb_mat_eig_simple],
+-                [SAGE_ARB_LIBRARY="flint-arb"], [sage_spkg_install_arb=yes])])
+-        ], [sage_spkg_install_arb=yes])
+-    fi
+-], [], [], [
+-    if test x$sage_spkg_install_arb = xyes; then
+-        AC_SUBST(SAGE_ARB_LIBRARY,["arb"])
+-    else
+-        AC_SUBST(SAGE_ARB_LIBRARY,[$SAGE_ARB_LIBRARY])
+-    fi
+-])
+diff --git a/build/pkgs/arb/spkg-install.in b/build/pkgs/arb/spkg-install.in
+deleted file mode 100644
+index 9322f04c912..00000000000
+--- a/build/pkgs/arb/spkg-install.in
++++ /dev/null
+@@ -1,17 +0,0 @@
+-cd src
+-
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-flint because otherwise ARB's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure --disable-static --prefix="$SAGE_LOCAL" \
+-        --with-gmp="$SAGE_LOCAL" \
+-        --with-mpfr="$SAGE_LOCAL" \
+-        --with-flint="$SAGE_LOCAL" || \
+-    sdh_die "Error configuring arb."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/arb/type b/build/pkgs/arb/type
+deleted file mode 100644
+index a6a7b9cd726..00000000000
+--- a/build/pkgs/arb/type
++++ /dev/null
+@@ -1 +0,0 @@
+-standard
+diff --git a/build/pkgs/e_antic/dependencies b/build/pkgs/e_antic/dependencies
+index fea1ffbda45..8e977a55c13 100644
+--- a/build/pkgs/e_antic/dependencies
++++ b/build/pkgs/e_antic/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) flint arb antic boost_cropped
++$(MP_LIBRARY) flint boost_cropped
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/SPKG.rst b/build/pkgs/flint/SPKG.rst
+index f91de70d1ff..d9dcea0903b 100644
+--- a/build/pkgs/flint/SPKG.rst
++++ b/build/pkgs/flint/SPKG.rst
+@@ -4,8 +4,8 @@ flint: Fast Library for Number Theory
+ Description
+ -----------
+ 
+-FLINT is a C library for doing number theory, maintained by William
+-Hart.
++FLINT is a C library for doing number theory, maintained by
++Fredrik Johansson.
+ 
+ Website: http://www.flintlib.org
+ 
+@@ -20,4 +20,4 @@ Upstream Contact
+ 
+ -  flint-devel Gougle Group
+    (http://groups.google.co.uk/group/flint-devel)
+--  William Hart
++-  Fredrik Johansson
+diff --git a/build/pkgs/flint/checksums.ini b/build/pkgs/flint/checksums.ini
+index 3d449d98064..2cec823bfb1 100644
+--- a/build/pkgs/flint/checksums.ini
++++ b/build/pkgs/flint/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=flint-VERSION.tar.gz
+-sha1=63d90f8242c8f8ab4011fbcfb44b86c154f43abd
+-md5=c2d3cec326438f159a530c66eb07fafe
+-cksum=4244948341
+-upstream_url=http://flintlib.org/flint-VERSION.tar.gz
++sha1=c548b1d5eb86a1805de9bef56629455b61e873f7
++md5=24551d4e475290ce6b831c78fafb5efb
++cksum=1567352998
++upstream_url=https://github.com/flintlib/flint/releases/download/vVERSION/flint-VERSION.tar.gz
+diff --git a/build/pkgs/flint/dependencies b/build/pkgs/flint/dependencies
+index 385df4faa7d..1108dc4fb21 100644
+--- a/build/pkgs/flint/dependencies
++++ b/build/pkgs/flint/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) mpfr ntl
++$(MP_LIBRARY) mpfr
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/package-version.txt b/build/pkgs/flint/package-version.txt
+index c8e38b61405..4a36342fcab 100644
+--- a/build/pkgs/flint/package-version.txt
++++ b/build/pkgs/flint/package-version.txt
+@@ -1 +1 @@
+-2.9.0
++3.0.0
+diff --git a/build/pkgs/flint/spkg-build.in b/build/pkgs/flint/spkg-build.in
+new file mode 100644
+index 00000000000..ffb822c8a97
+--- /dev/null
++++ b/build/pkgs/flint/spkg-build.in
+@@ -0,0 +1,3 @@
++cd src
++sdh_configure
++sdh_make
+diff --git a/build/pkgs/flint/spkg-configure.m4 b/build/pkgs/flint/spkg-configure.m4
+index a58108c9d6e..9576e4cc1e9 100644
+--- a/build/pkgs/flint/spkg-configure.m4
++++ b/build/pkgs/flint/spkg-configure.m4
+@@ -1,25 +1,8 @@
+ SAGE_SPKG_CONFIGURE([flint], [
+-    SAGE_SPKG_DEPCHECK([mpfr ntl], [
++    SAGE_SPKG_DEPCHECK([mpfr], [
+         AC_CHECK_HEADER(flint/flint.h, [
+-          dnl flint_parallel_binary_splitting appears in Flint 2.9.0, needed by arb 2.23
+-          AC_SEARCH_LIBS([flint_parallel_binary_splitting], [flint], [
+-            dnl check that NTL is linked in
+-            AC_SEARCH_LIBS([fmpz_poly_get_ZZX], [flint], [
+-
+-              AC_MSG_CHECKING([that GC is not enabled in Flint... ])
+-              AC_RUN_IFELSE([
+-                 AC_LANG_PROGRAM([[#include <flint/flint.h>]], [
+-                                  [#ifdef HAVE_GC]
+-                                     [return HAVE_GC;]
+-                                  [#else]
+-                                     [return 0;]
+-                                  [#endif]])],
+-                 [AC_MSG_RESULT([GC not enabled. Good.])],
+-                        [AC_MSG_RESULT([GC enabled. Incompatible with Sage.])
+-                         sage_spkg_install_flint=yes],
+-                 [AC_MSG_RESULT(["cross compiling. assuming GC is not enabled"])])
+-            ], [sage_spkg_install_flint=yes])
+-          ], [sage_spkg_install_flint=yes])
++          dnl gr_get_fexpr appears in Flint 3.0
++          AC_SEARCH_LIBS([gr_get_fexpr], [flint], [], [sage_spkg_install_flint=yes])
+         ], [sage_spkg_install_flint=yes])
+     ])
+ ], [], [], [
+diff --git a/build/pkgs/flint/spkg-install.in b/build/pkgs/flint/spkg-install.in
+index eacd7b6e491..3ea8c053669 100644
+--- a/build/pkgs/flint/spkg-install.in
++++ b/build/pkgs/flint/spkg-install.in
+@@ -1,36 +1,2 @@
+-###############################################################################
+-#
+-# FLINT Sage install script
+-#
+-###############################################################################
+-if [ "$SAGE_DEBUG" = "yes" ]; then
+-    echo "Building a debug version of FLINT."
+-    FLINT_TUNE=" $FLINT_TUNE"; export FLINT_TUNE
+-    FLINT_CONFIGURE="--enable-assert $FLINT_CONFIGURE"
+-fi
+-
+ cd src
+-
+-echo "Configuring FLINT."
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-ntl because otherwise FLINT's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-ntl="$SAGE_LOCAL" \
+-    $FLINT_CONFIGURE || sdh_die "Error: Failed to configure FLINT."
+-
+-sdh_make verbose
+-
+-echo "Deleting old FLINT files."
+-rm -f $SAGE_LOCAL/lib/libflint*
+-rm -rf $SAGE_LOCAL/include/flint
+-
+ sdh_make_install
+diff --git a/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+new file mode 100644
+index 00000000000..27a642a13b0
+--- /dev/null
++++ b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+@@ -0,0 +1,53 @@
++From fe730579476de0b2d4181a38efa7f63dff9c81d7 Mon Sep 17 00:00:00 2001
++From: Marc Mezzarobba <marc@mezzarobba.net>
++Date: Tue, 12 Sep 2023 08:23:08 +0200
++Subject: [PATCH] Make msolve build with flint3
++
++---
++ src/fglm/berlekamp_massey.c | 3 +++
++ src/fglm/data_fglm.c        | 7 +++++--
++ 2 files changed, 8 insertions(+), 2 deletions(-)
++
++diff --git a/src/fglm/berlekamp_massey.c b/src/fglm/berlekamp_massey.c
++index b0f2052..998af1c 100644
++--- a/src/fglm/berlekamp_massey.c
+++++ b/src/fglm/berlekamp_massey.c
++@@ -30,6 +30,9 @@
++ */
++ 
++ #include <stdlib.h>
+++#if __FLINT_VERSION >= 3
+++#  include <flint/nmod.h>
+++#endif
++ //#include "nmod_poly.h"
++ //#include "mpn_extras.h"
++ 
++diff --git a/src/fglm/data_fglm.c b/src/fglm/data_fglm.c
++index 0726760..0e1da6f 100644
++--- a/src/fglm/data_fglm.c
+++++ b/src/fglm/data_fglm.c
++@@ -24,6 +24,7 @@
++ #include <flint/mpn_extras.h>
++ #include <flint/nmod_poly.h>
++ #include <flint/nmod_poly_factor.h>
+++#include <flint/ulong_extras.h>
++ 
++ 
++ typedef uint32_t szmat_t;
++@@ -299,9 +300,11 @@ static inline void nmod_poly_set_prime(nmod_poly_t poly,
++   mp_limb_t ninv = n_preinvert_limb(prime);
++   poly->mod.n = prime;
++   poly->mod.ninv = ninv;
+++#if __FLINT_VERSION < 3
++   count_leading_zeros(poly->mod.norm, prime);
++-  /* poly->mod.norm = flint_clz(prime); */
++-
+++#else
+++  poly->mod.norm = flint_clz(prime);
+++#endif
++ }
++ 
++ static inline void fglm_param_set_prime(param_t *param, mp_limb_t prime){
++-- 
++2.40.1
++
+diff --git a/build/pkgs/sagelib/dependencies b/build/pkgs/sagelib/dependencies
+index 5dc2efe1d31..fa6e98df7db 100644
+--- a/build/pkgs/sagelib/dependencies
++++ b/build/pkgs/sagelib/dependencies
+@@ -1,4 +1,4 @@
+-FORCE $(SCRIPTS) arb boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
++FORCE $(SCRIPTS) boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/symengine/dependencies b/build/pkgs/symengine/dependencies
+index 1fc34963eda..7795d486018 100644
+--- a/build/pkgs/symengine/dependencies
++++ b/build/pkgs/symengine/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) arb ecm flint mpc mpfr | cmake
++$(MP_LIBRARY) ecm flint mpc mpfr | cmake
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/pkgs/sage-conf/_sage_conf/_conf.py.in b/pkgs/sage-conf/_sage_conf/_conf.py.in
+index 87b27ca05cb..895d6572d1e 100644
+--- a/pkgs/sage-conf/_sage_conf/_conf.py.in
++++ b/pkgs/sage-conf/_sage_conf/_conf.py.in
+@@ -19,8 +19,6 @@ MAXIMA_FAS = "@SAGE_MAXIMA_FAS@".replace('${prefix}', SAGE_LOCAL)
+ # Delete this line if your ECL can load Kenzo without further prodding.
+ KENZO_FAS = "@SAGE_KENZO_FAS@".replace('${prefix}', SAGE_LOCAL)
+ 
+-ARB_LIBRARY = "@SAGE_ARB_LIBRARY@"
+-
+ NTL_INCDIR = "@NTL_INCDIR@"
+ NTL_LIBDIR = "@NTL_LIBDIR@"
+ 
+diff --git a/src/sage/env.py b/src/sage/env.py
+index f4899639a6d..f6459313fd4 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -223,7 +223,6 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st
+ FOURTITWO_PPI = var("FOURTITWO_PPI")
+ FOURTITWO_CIRCUITS = var("FOURTITWO_CIRCUITS")
+ FOURTITWO_GROEBNER = var("FOURTITWO_GROEBNER")
+-ARB_LIBRARY = var("ARB_LIBRARY", "arb")
+ CBLAS_PC_MODULES = var("CBLAS_PC_MODULES", "cblas:openblas:blas")
+ ECL_CONFIG = var("ECL_CONFIG", "ecl-config")
+ NTL_INCDIR = var("NTL_INCDIR")
+@@ -356,8 +355,7 @@ def cython_aliases(required_modules=None,
+         sage: cython_aliases()
+         {...}
+         sage: sorted(cython_aliases().keys())
+-        ['ARB_LIBRARY',
+-         'CBLAS_CFLAGS',
++        ['CBLAS_CFLAGS',
+          ...,
+          'ZLIB_LIBRARIES']
+         sage: cython_aliases(required_modules=('module-that-is-assumed-to-not-exist'))
+@@ -475,8 +473,6 @@ def uname_specific(name, value, alternative):
+     if "LINBOX_CFLAGS" in aliases:
+         aliases["LINBOX_CFLAGS"].append("-std=gnu++11")
+ 
+-    aliases["ARB_LIBRARY"] = ARB_LIBRARY
+-
+     # TODO: Remove Cygwin hack by installing a suitable cblas.pc
+     if os.path.exists('/usr/lib/libblas.dll.a'):
+         aliases["CBLAS_LIBS"] = ['gslcblas']
+diff --git a/src/sage/features/sagemath.py b/src/sage/features/sagemath.py
+index 7404e6d0a8e..6037d097391 100644
+--- a/src/sage/features/sagemath.py
++++ b/src/sage/features/sagemath.py
+@@ -761,7 +761,7 @@ class sage__rings__number_field(JoinFeature):
+     A :class:`~sage.features.Feature` describing the presence of :mod:`sage.rings.number_field`.
+ 
+     Number fields are implemented in Sage using a complicated mixture of various libraries,
+-    including :ref:`arb <spkg_arb>`, :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
++    including :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
+     :ref:`MPFI <spkg_mpfi>`, :ref:`NTL <spkg_ntl>`, and :ref:`PARI <spkg_pari>`.
+ 
+     EXAMPLES:
+diff --git a/src/sage/libs/arb/acb.pxd b/src/sage/libs/arb/acb.pxd
+index 5148dc43991..851488d803a 100644
+--- a/src/sage/libs/arb/acb.pxd
++++ b/src/sage/libs/arb/acb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -152,10 +152,6 @@ cdef extern from "arb_wrap.h":
+     void acb_sech(acb_t s, const acb_t z, long prec)
+     void acb_csch(acb_t c, const acb_t z, long prec)
+ 
+-    void acb_rising_ui_bs(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui_rs(acb_t z, const acb_t x, unsigned long n, unsigned long step, long prec)
+-    void acb_rising_ui_rec(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui(acb_t z, const acb_t x, unsigned long n, long prec)
+     void acb_rising(acb_t z, const acb_t x, const acb_t n, long prec)
+ 
+     void acb_gamma(acb_t y, const acb_t x, long prec)
+diff --git a/src/sage/libs/arb/acb_calc.pxd b/src/sage/libs/arb/acb_calc.pxd
+index a5dbf360b5e..67bd2ed57dc 100644
+--- a/src/sage/libs/arb/acb_calc.pxd
++++ b/src/sage/libs/arb/acb_calc.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_calc.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_elliptic.pxd b/src/sage/libs/arb/acb_elliptic.pxd
+index 176f68df00e..e3480e9f73b 100644
+--- a/src/sage/libs/arb/acb_elliptic.pxd
++++ b/src/sage/libs/arb/acb_elliptic.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_elliptic.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_hypgeom.pxd b/src/sage/libs/arb/acb_hypgeom.pxd
+index 418e766f10d..c43e5c0623b 100644
+--- a/src/sage/libs/arb/acb_hypgeom.pxd
++++ b/src/sage/libs/arb/acb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_hypgeom.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_modular.pxd b/src/sage/libs/arb/acb_modular.pxd
+index c708e9bf97d..cdc413c92da 100644
+--- a/src/sage/libs/arb/acb_modular.pxd
++++ b/src/sage/libs/arb/acb_modular.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_modular.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_poly.pxd b/src/sage/libs/arb/acb_poly.pxd
+index 69f4320055b..ae02757ffd9 100644
+--- a/src/sage/libs/arb/acb_poly.pxd
++++ b/src/sage/libs/arb/acb_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -79,24 +79,10 @@ cdef extern from "arb_wrap.h":
+     void _acb_poly_divrem(acb_ptr Q, acb_ptr R, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec)
+     bint acb_poly_divrem(acb_poly_t Q, acb_poly_t R, const acb_poly_t A, const acb_poly_t B, long prec)
+     void _acb_poly_div_root(acb_ptr Q, acb_t R, acb_srcptr A, long len, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_horner(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_horner(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_divconquer(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_divconquer(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_convolution(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_convolution(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+     void _acb_poly_taylor_shift(acb_ptr g, const acb_t c, long n, long prec)
+     void acb_poly_taylor_shift(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_compose_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_divconquer(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_divconquer(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+     void _acb_poly_compose(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+     void acb_poly_compose(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_series_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+-    void _acb_poly_compose_series_brent_kung(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_brent_kung(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_compose_series(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+     void acb_poly_compose_series(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_revert_series_lagrange(acb_ptr h, acb_srcptr f, long flen, long n, long prec)
+@@ -161,10 +147,6 @@ cdef extern from "arb_wrap.h":
+     void acb_poly_exp_series_basecase(acb_poly_t f, const acb_poly_t h, long n, long prec)
+     void _acb_poly_exp_series(acb_ptr f, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_exp_series(acb_poly_t f, const acb_poly_t h, long n, long prec)
+-    void _acb_poly_sin_cos_series_basecase(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_basecase(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+-    void _acb_poly_sin_cos_series_tangent(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_tangent(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+     void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_sin_cos_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec)
+     void _acb_poly_sin_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec)
+diff --git a/src/sage/libs/arb/arb.pxd b/src/sage/libs/arb/arb.pxd
+index c82b94de30f..acd232ab816 100644
+--- a/src/sage/libs/arb/arb.pxd
++++ b/src/sage/libs/arb/arb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -224,15 +224,8 @@ cdef extern from "arb_wrap.h":
+ 
+     void arb_lambertw(arb_t res, const arb_t x, int flags, long prec)
+ 
+-    void arb_rising_ui_bs(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui_rs(arb_t z, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising_ui_rec(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui(arb_t z, const arb_t x, unsigned long n, long prec)
+     void arb_rising(arb_t z, const arb_t x, const arb_t n, long prec)
+     void arb_rising_fmpq_ui(arb_t z, const fmpq_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_bs(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_rs(arb_t u, arb_t v, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising2_ui(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+     void arb_fac_ui(arb_t z, unsigned long n, long prec)
+     void arb_bin_ui(arb_t z, const arb_t n, unsigned long k, long prec)
+     void arb_bin_uiui(arb_t z, unsigned long n, unsigned long k, long prec)
+diff --git a/src/sage/libs/arb/arb_fmpz_poly.pxd b/src/sage/libs/arb/arb_fmpz_poly.pxd
+index 079f76e9d9e..55daa705238 100644
+--- a/src/sage/libs/arb/arb_fmpz_poly.pxd
++++ b/src/sage/libs/arb/arb_fmpz_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_fmpz_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -22,5 +22,4 @@ cdef extern from "arb_wrap.h":
+     unsigned long arb_fmpz_poly_deflation(const fmpz_poly_t poly)
+     void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long deflation)
+     void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, long prec)
+-    void arb_fmpz_poly_cos_minpoly(fmpz_poly_t res, unsigned long n)
+     void arb_fmpz_poly_gauss_period_minpoly(fmpz_poly_t res, unsigned long q, unsigned long n)
+diff --git a/src/sage/libs/arb/arb_hypgeom.pxd b/src/sage/libs/arb/arb_hypgeom.pxd
+index fb1c40ddaa8..139b987d669 100644
+--- a/src/sage/libs/arb/arb_hypgeom.pxd
++++ b/src/sage/libs/arb/arb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_hypgeom.h
+ 
+ from sage.libs.flint.types cimport fmpz_t
+diff --git a/src/sage/libs/arb/arb_wrap.h b/src/sage/libs/arb/arb_wrap.h
+index 49997075ee5..488bb376d5e 100644
+--- a/src/sage/libs/arb/arb_wrap.h
++++ b/src/sage/libs/arb/arb_wrap.h
+@@ -5,25 +5,27 @@
+  * by arb, most of which rely on flint's ulong and slong defines.
+  */
+ 
++#include <mpfr.h>
++
+ #undef ulong
+ #undef slong
+ 
+ #define ulong mp_limb_t
+ #define slong mp_limb_signed_t
+ 
+-#include <acb.h>
+-#include <acb_calc.h>
+-#include <acb_elliptic.h>
+-#include <acb_hypgeom.h>
+-#include <acb_mat.h>
+-#include <acb_modular.h>
+-#include <acb_poly.h>
+-#include <arb.h>
+-#include <arb_fmpz_poly.h>
+-#include <arb_hypgeom.h>
+-#include <arf.h>
+-#include <bernoulli.h>
+-#include <mag.h>
++#include <flint/acb.h>
++#include <flint/acb_calc.h>
++#include <flint/acb_elliptic.h>
++#include <flint/acb_hypgeom.h>
++#include <flint/acb_mat.h>
++#include <flint/acb_modular.h>
++#include <flint/acb_poly.h>
++#include <flint/arb.h>
++#include <flint/arb_fmpz_poly.h>
++#include <flint/arb_hypgeom.h>
++#include <flint/arf.h>
++#include <flint/bernoulli.h>
++#include <flint/mag.h>
+ 
+ #undef ulong
+ #undef slong
+diff --git a/src/sage/libs/arb/arf.pxd b/src/sage/libs/arb/arf.pxd
+index b8b83fefcdc..84778fe9f09 100644
+--- a/src/sage/libs/arb/arf.pxd
++++ b/src/sage/libs/arb/arf.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arf.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -30,7 +30,6 @@ cdef extern from "arb_wrap.h":
+     void arf_set_ui(arf_t y, unsigned long x)
+     void arf_set_si(arf_t y, long x)
+     void arf_set_mpfr(arf_t y, const mpfr_t x)
+-    # void arf_set_fmpr(arf_t y, const fmpr_t x)
+     void arf_set_d(arf_t y, double x)
+     void arf_swap(arf_t y, arf_t x)
+     void arf_init_set_ui(arf_t y, unsigned long x)
+@@ -46,7 +45,6 @@ cdef extern from "arb_wrap.h":
+     int arf_set_round_fmpz_2exp(arf_t y, const fmpz_t x, const fmpz_t e, long prec, arf_rnd_t rnd)
+     void arf_get_fmpz_2exp(fmpz_t m, fmpz_t e, const arf_t x)
+     double arf_get_d(const arf_t x, arf_rnd_t rnd)
+-    # void arf_get_fmpr(fmpr_t y, const arf_t x)
+     int arf_get_mpfr(mpfr_t y, const arf_t x, mpfr_rnd_t rnd)
+     void arf_get_fmpz(fmpz_t z, const arf_t x, arf_rnd_t rnd)
+     long arf_get_si(const arf_t x, arf_rnd_t rnd)
+diff --git a/src/sage/libs/arb/bernoulli.pxd b/src/sage/libs/arb/bernoulli.pxd
+index 375b2b9bbcf..ea9340f4b15 100644
+--- a/src/sage/libs/arb/bernoulli.pxd
++++ b/src/sage/libs/arb/bernoulli.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = bernoulli.h
+ 
+ from ..flint.types cimport fmpq_t, ulong
+diff --git a/src/sage/libs/arb/mag.pxd b/src/sage/libs/arb/mag.pxd
+index d5d8693ea8f..69dfb990ae0 100644
+--- a/src/sage/libs/arb/mag.pxd
++++ b/src/sage/libs/arb/mag.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = mag.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -27,13 +27,11 @@ cdef extern from "arb_wrap.h":
+     # void mag_randtest(mag_t x, flint_rand_t state, long expbits)
+     # void mag_randtest_special(mag_t x, flint_rand_t state, long expbits)
+     void mag_set_d(mag_t y, double x)
+-    # void mag_set_fmpr(mag_t y, const fmpr_t x)
+     void mag_set_ui(mag_t y, unsigned long x)
+     void mag_set_fmpz(mag_t y, const fmpz_t x)
+     void mag_set_d_2exp_fmpz(mag_t z, double x, const fmpz_t y)
+     void mag_set_fmpz_2exp_fmpz(mag_t z, const fmpz_t x, const fmpz_t y)
+     void mag_set_ui_2exp_si(mag_t z, unsigned long x, long y)
+-    # void mag_get_fmpr(fmpr_t y, const mag_t x)
+     void mag_get_fmpq(fmpq_t y, const mag_t x)
+     void mag_set_ui_lower(mag_t z, unsigned long x)
+     void mag_set_fmpz_lower(mag_t z, const fmpz_t x)
+diff --git a/src/sage/libs/flint/flint_wrap.h b/src/sage/libs/flint/flint_wrap.h
+index 266535c3835..4db72b97660 100644
+--- a/src/sage/libs/flint/flint_wrap.h
++++ b/src/sage/libs/flint/flint_wrap.h
+@@ -15,6 +15,7 @@
+  */
+ 
+ #include <gmp.h>
++#include <mpfr.h>
+ 
+ /* Save previous definition of ulong if any, as pari also uses it */
+ /* Should work on GCC, clang, MSVC */
+@@ -33,6 +34,7 @@
+ 
+ #include <flint/arith.h>
+ #include <flint/fmpq.h>
++#include <flint/fmpq_vec.h>
+ #include <flint/fmpq_mat.h>
+ #include <flint/fmpq_poly.h>
+ #include <flint/fmpz.h>
+@@ -47,6 +49,7 @@
+ #include <flint/fq.h>
+ #include <flint/fq_nmod.h>
+ #include <flint/nmod_poly.h>
++#include <flint/nmod_poly_factor.h>
+ #include <flint/nmod_vec.h>
+ #include <flint/padic.h>
+ #include <flint/padic_poly.h>
+diff --git a/src/sage/libs/flint/fmpq.pxd b/src/sage/libs/flint/fmpq.pxd
+index 5e64c82102f..0616c0a7408 100644
+--- a/src/sage/libs/flint/fmpq.pxd
++++ b/src/sage/libs/flint/fmpq.pxd
+@@ -12,6 +12,8 @@ cdef extern from "flint_wrap.h":
+     fmpz * fmpq_denref(fmpq_t)
+     void fmpq_init(fmpq_t)
+     void fmpq_clear(fmpq_t)
++    void fmpq_init_set_readonly(fmpq_t, const mpq_t)
++    void fmpq_clear_readonly(fmpq_t)
+     void fmpq_one(fmpq_t)
+     void fmpq_zero(fmpq_t)
+     bint fmpq_is_zero(fmpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pxd b/src/sage/libs/flint/fmpq_poly.pxd
+index 20a797c0197..516f9e84cfc 100644
+--- a/src/sage/libs/flint/fmpq_poly.pxd
++++ b/src/sage/libs/flint/fmpq_poly.pxd
+@@ -30,6 +30,9 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_canonicalise(fmpq_poly_t)
+     int fmpq_poly_is_canonical(const fmpq_poly_t)
+ 
++    void _fmpq_poly_set_length(fmpq_poly_t, slong)
++    void _fmpq_poly_normalise(fmpq_poly_t)
++
+     # Polynomial parameters
+     slong fmpq_poly_degree(const fmpq_poly_t)
+     ulong fmpq_poly_length(const fmpq_poly_t)
+@@ -46,10 +49,7 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_ui(fmpq_poly_t, ulong)
+     void fmpq_poly_set_fmpz(fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_set_fmpq(fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+     void fmpq_poly_set_fmpz_poly(fmpq_poly_t, const fmpz_poly_t)
+-    void fmpq_poly_set_array_mpq(fmpq_poly_t, const mpq_t *, slong)
+ 
+     void fmpq_poly_set_str(fmpq_poly_t, const char *)
+     char *fmpq_poly_get_str(const fmpq_poly_t)
+@@ -67,7 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_reverse(fmpq_poly_t, const fmpq_poly_t, slong)
+ 
+     void fmpq_poly_get_coeff_fmpq(fmpq_t, const fmpq_poly_t, slong)
+-    void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_si(slong, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_ui(ulong, const fmpq_poly_t, slong)
+ 
+@@ -75,8 +74,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_coeff_ui(fmpq_poly_t, slong, ulong)
+     void fmpq_poly_set_coeff_fmpz(fmpq_poly_t, slong, const fmpz_t)
+     void fmpq_poly_set_coeff_fmpq(fmpq_poly_t, slong, const fmpq_t)
+-    void fmpq_poly_set_coeff_mpz(fmpq_poly_t, slong, const mpz_t)
+-    void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
+ 
+     # Comparison
+     int fmpq_poly_equal(const fmpq_poly_t, const fmpq_poly_t)
+@@ -100,8 +97,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_mul_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     void fmpq_poly_scalar_div_si(fmpq_poly_t, const fmpq_poly_t, slong)
+     void fmpq_poly_scalar_div_ui(fmpq_poly_t, const fmpq_poly_t, ulong)
+@@ -109,8 +104,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_div_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_div_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_div_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Multiplication
+     void fmpq_poly_mul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -155,8 +148,6 @@ cdef extern from "flint_wrap.h":
+     # Evaluation
+     void fmpq_poly_evaluate_fmpz(fmpq_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_evaluate_fmpq(fmpq_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_evaluate_mpz(mpq_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_evaluate_mpq(mpq_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Composition
+     void fmpq_poly_compose(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -189,3 +180,11 @@ cdef extern from "flint_wrap.h":
+ # since the fmpq_poly header seems to be lacking this inline function
+ cdef inline sage_fmpq_poly_max_limbs(const fmpq_poly_t poly):
+     return _fmpz_vec_max_limbs(fmpq_poly_numref(poly), fmpq_poly_length(poly))
++
++# functions removed from flint but still needed in sage
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
++cdef void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
++cdef void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pyx b/src/sage/libs/flint/fmpq_poly.pyx
+new file mode 100644
+index 00000000000..3b8a0cf0c51
+--- /dev/null
++++ b/src/sage/libs/flint/fmpq_poly.pyx
+@@ -0,0 +1,45 @@
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++from sage.libs.gmp.mpq cimport *
++from sage.libs.flint.fmpz cimport *
++from sage.libs.flint.fmpq cimport *
++
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t rop, const fmpq_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t rop, const fmpq_poly_t op, const mpq_t c):
++    cdef fmpq_t f
++    fmpq_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpq(rop, op, f)
++    fmpq_clear_readonly(f)
++
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t poly, slong n, const mpq_t x):
++    cdef fmpq_t t
++    fmpq_init_set_readonly(t, x)
++    fmpq_poly_set_coeff_fmpq(poly, n, t)
++    fmpq_clear_readonly(t)
++
++cdef void fmpq_poly_get_coeff_mpq(mpq_t x, const fmpq_poly_t poly, slong n):
++    cdef fmpq_t t
++    fmpq_init(t)
++    fmpq_poly_get_coeff_fmpq(t, poly, n)
++    fmpq_get_mpq(x, t)
++    fmpq_clear(t)
++
++cdef void fmpq_poly_set_mpq(fmpq_poly_t poly, const mpq_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), mpq_numref(x))
++    fmpz_set_mpz(fmpq_poly_denref(poly), mpq_denref(x))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
++
++cdef void fmpq_poly_set_mpz(fmpq_poly_t poly, const mpz_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), x)
++    fmpz_one(fmpq_poly_denref(poly))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz.pxd b/src/sage/libs/flint/fmpz.pxd
+index 01058d0f130..b97fbe1eae0 100644
+--- a/src/sage/libs/flint/fmpz.pxd
++++ b/src/sage/libs/flint/fmpz.pxd
+@@ -16,6 +16,9 @@ cdef extern from "flint_wrap.h":
+     void fmpz_init_set(fmpz_t, fmpz_t)
+     void fmpz_init_set_ui(fmpz_t, ulong)
+ 
++    void fmpz_init_set_readonly(fmpz_t, const mpz_t)
++    void fmpz_clear_readonly(fmpz_t)
++
+     # Conversion
+     void fmpz_set(fmpz_t f, fmpz_t g)
+     void fmpz_set_ui(fmpz_t, ulong)
+diff --git a/src/sage/libs/flint/fmpz_mod_poly.pxd b/src/sage/libs/flint/fmpz_mod_poly.pxd
+index 24b653eb3b7..2727246da98 100644
+--- a/src/sage/libs/flint/fmpz_mod_poly.pxd
++++ b/src/sage/libs/flint/fmpz_mod_poly.pxd
+@@ -67,13 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_get_coeff_fmpz(fmpz_t x, const fmpz_mod_poly_t poly,
+                                              slong n, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_set_coeff_mpz(fmpz_mod_poly_t poly,
+-                             slong n, const mpz_t x, const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_get_coeff_mpz(mpz_t x,
+-                 const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx)
+-
+-
+     void _fmpz_mod_poly_shift_left(fmpz * res, const fmpz * poly,
+                                                            slong len, slong n)
+ 
+@@ -194,14 +187,6 @@ cdef extern from "flint_wrap.h":
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_div_basecase(fmpz_mod_poly_t Q,
+-                            const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_div_newton_n_preinv(fmpz_mod_poly_t Q,
+-                         const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                         const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem_newton_n_preinv(fmpz_mod_poly_t Q,
+           fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                          const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+@@ -213,10 +198,6 @@ cdef extern from "flint_wrap.h":
+                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_divrem_divconquer(fmpz_mod_poly_t Q,
+-        fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem(fmpz_mod_poly_t Q, fmpz_mod_poly_t R,
+     const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+@@ -254,40 +235,13 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_make_monic_f(fmpz_t f, fmpz_mod_poly_t res,
+                          const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_euclidean(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_gcd_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_hgcd(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-
+     void fmpz_mod_poly_gcd(fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+ 
+-    void fmpz_mod_poly_xgcd_euclidean(fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_hgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S,
+-          fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_xgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                       const fmpz_mod_ctx_t ctx)
+@@ -361,14 +315,6 @@ cdef extern from "flint_wrap.h":
+                         const fmpz_mod_poly_t poly, const fmpz * xs, slong n,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_compose_horner(fmpz_mod_poly_t res,
+-                    const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_compose_divconquer(fmpz_mod_poly_t res,
+-                     const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_compose(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1,
+                          const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx)
+ 
+diff --git a/src/sage/libs/flint/fmpz_poly.pxd b/src/sage/libs/flint/fmpz_poly.pxd
+index 18b36672d30..c8bc6d3ca0a 100644
+--- a/src/sage/libs/flint/fmpz_poly.pxd
++++ b/src/sage/libs/flint/fmpz_poly.pxd
+@@ -28,7 +28,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_poly_set_ui(fmpz_poly_t, ulong)
+     void fmpz_poly_set_si(fmpz_poly_t, slong)
+     void fmpz_poly_set_fmpz(fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+     int fmpz_poly_set_str(fmpz_poly_t, const char *)
+ 
+     char *fmpz_poly_get_str(const fmpz_poly_t)
+@@ -70,7 +69,6 @@ cdef extern from "flint_wrap.h":
+     # Scalar multiplication and division
+     void fmpz_poly_scalar_mul_fmpz(
+             fmpz_poly_t, const fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+     void fmpz_poly_scalar_mul_si(fmpz_poly_t, const fmpz_poly_t, slong)
+     void fmpz_poly_scalar_mul_ui(fmpz_poly_t, const fmpz_poly_t, ulong)
+     void fmpz_poly_scalar_mul_2exp(fmpz_poly_t, const fmpz_poly_t, ulong)
+@@ -310,12 +308,14 @@ cdef extern from "flint_wrap.h":
+             fmpz_poly_t,
+                     const fmpz_poly_t, const fmpz_t, const nmod_poly_t, int)
+ 
+-    # Some functions for backwards compatibility
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
+-    void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++
++# functions removed from flint but still needed in sage
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
++cdef void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++cdef void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+ 
+ 
+ # Wrapper Cython class
+diff --git a/src/sage/libs/flint/fmpz_poly.pyx b/src/sage/libs/flint/fmpz_poly.pyx
+index 74915b37612..cfcbea9090c 100644
+--- a/src/sage/libs/flint/fmpz_poly.pyx
++++ b/src/sage/libs/flint/fmpz_poly.pyx
+@@ -25,10 +25,10 @@ from cysignals.memory cimport sig_free
+ 
+ from sage.arith.long cimport pyobject_to_long
+ from sage.cpython.string cimport char_to_str, str_to_bytes
++from sage.libs.flint.fmpz cimport *
+ from sage.structure.sage_object cimport SageObject
+ from sage.rings.integer cimport Integer
+ 
+-
+ cdef class Fmpz_poly(SageObject):
+ 
+     def __cinit__(self):
+@@ -455,3 +455,44 @@ cdef class Fmpz_poly(SageObject):
+         """
+         from sage.rings.integer_ring import ZZ
+         return ZZ[var](self.list())
++
++
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_divexact_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_fdiv_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t poly, slong n, const mpz_t x):
++    cdef fmpz_t t
++    fmpz_init_set_readonly(t, x)
++    fmpz_poly_set_coeff_fmpz(poly, n, t)
++    fmpz_clear_readonly(t)
++
++cdef void fmpz_poly_get_coeff_mpz(mpz_t x, const fmpz_poly_t poly, slong n):
++    cdef fmpz_t t
++    fmpz_init(t)
++    fmpz_poly_get_coeff_fmpz(t, poly, n)
++    fmpz_get_mpz(x, t)
++    fmpz_clear(t)
++
++cdef void fmpz_poly_set_mpz(fmpz_poly_t poly, const mpz_t x):
++    fmpz_poly_fit_length(poly, 1)
++    fmpz_set_mpz(poly.coeffs, x)
++    _fmpz_poly_set_length(poly, 1)
++    _fmpz_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz_poly_q.pxd b/src/sage/libs/flint/fmpz_poly_q.pxd
+index 846542dc0d8..63c13355bf6 100644
+--- a/src/sage/libs/flint/fmpz_poly_q.pxd
++++ b/src/sage/libs/flint/fmpz_poly_q.pxd
+@@ -49,11 +49,7 @@ cdef extern from "flint_wrap.h":
+ 
+     #* Scalar multiplication and division ****************************************/
+     void fmpz_poly_q_scalar_mul_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_mul_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_mul_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+     void fmpz_poly_q_scalar_div_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_div_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_div_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+ 
+     #* Multiplication and division ***********************************************/
+     void fmpz_poly_q_mul(fmpz_poly_q_t rop, 
+@@ -67,9 +63,6 @@ cdef extern from "flint_wrap.h":
+     #* Derivative ****************************************************************/
+     void fmpz_poly_q_derivative(fmpz_poly_q_t rop, const fmpz_poly_q_t op)
+ 
+-    #* Evaluation ****************************************************************/
+-    int fmpz_poly_q_evaluate(mpq_t rop, const fmpz_poly_q_t f, const mpq_t a)
+-
+     #* Input and output **********************************************************/
+     int fmpz_poly_q_set_str(fmpz_poly_q_t rop, const char *s)
+     char * fmpz_poly_q_get_str(const fmpz_poly_q_t op)
+diff --git a/src/sage/libs/linbox/linbox_flint_interface.pyx b/src/sage/libs/linbox/linbox_flint_interface.pyx
+index 415cd473947..83547f91cd2 100644
+--- a/src/sage/libs/linbox/linbox_flint_interface.pyx
++++ b/src/sage/libs/linbox/linbox_flint_interface.pyx
+@@ -33,6 +33,7 @@ and C. Pernet. The functions available are:
+ #                  https://www.gnu.org/licenses/
+ # ****************************************************************************
+ 
++from sage.libs.gmp.types cimport mpz_t
+ from sage.libs.flint.types cimport fmpz_t
+ from sage.libs.flint.fmpz cimport fmpz_get_mpz, fmpz_set_mpz
+ from sage.libs.flint.fmpz_mat cimport fmpz_mat_entry, fmpz_mat_nrows, fmpz_mat_ncols
+@@ -80,11 +81,13 @@ cdef void fmpz_poly_set_linbox(fmpz_poly_t p, PolynomialRing_integer.Element& q)
+     (the .pxd file) in order to keep the header C-compatible
+     """
+     cdef size_t i
++    cdef mpz_t tmp
+ 
+     fmpz_poly_fit_length(p, q.size())
+ 
+     for i in range(q.size()):
+-        fmpz_poly_set_coeff_mpz(p, i, q[i].get_mpz_const())
++        tmp = q[i].get_mpz_const()
++        fmpz_poly_set_coeff_mpz(p, i, tmp)
+ 
+     _fmpz_poly_set_length(p, q.size())
+ 
+diff --git a/src/sage/matrix/matrix_complex_ball_dense.pyx b/src/sage/matrix/matrix_complex_ball_dense.pyx
+index 3f56772a663..b1ece8a0e7b 100644
+--- a/src/sage/matrix/matrix_complex_ball_dense.pyx
++++ b/src/sage/matrix/matrix_complex_ball_dense.pyx
+@@ -1,4 +1,4 @@
+-# distutils: libraries = ARB_LIBRARY
++# distutils: libraries = flint
+ r"""
+ Arbitrary precision complex ball matrices using Arb
+ 
+diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx
+index f4320fcd914..b36ee300990 100644
+--- a/src/sage/matrix/matrix_integer_sparse.pyx
++++ b/src/sage/matrix/matrix_integer_sparse.pyx
+@@ -847,6 +847,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+             sage: matrix(ZZ, 1, 1, sparse=True)._charpoly_linbox()
+             x
+         """
++        cdef mpz_t tmp
+         if self._nrows != self._ncols:
+             raise ArithmeticError('only valid for square matrix')
+ 
+@@ -869,7 +870,8 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         cdef size_t i
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+@@ -966,9 +968,11 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         sig_off()
+ 
+         cdef size_t i
++        cdef mpz_t tmp
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
+index a22ce3c5e53..15be37734af 100644
+--- a/src/sage/rings/complex_arb.pyx
++++ b/src/sage/rings/complex_arb.pyx
+@@ -1360,12 +1360,13 @@ cdef class ComplexBall(RingElement):
+             sage: CBF100(-3r)
+             -3.000000000000000000000000000000
+ 
+-            sage: ComplexBall(CBF100, 10^100)
+-            1.000000000000000000000000000000e+100
+             sage: ComplexBall(CBF100, CIF(1, 2))
+             1.000000000000000000000000000000 + 2.000000000000000000000000000000*I
+             sage: ComplexBall(CBF100, RBF(1/3), RBF(1))
+             [0.3333333333333333 +/- ...e-17] + 1.000000000000000000000000000000*I
++            sage: ComplexBall(CBF100, 10^100)
++            [1.000000000000000000000000000000e+100 +/- ...]
++
+             sage: NF.<a> = QuadraticField(-1, embedding=CC(0, -1))
+             sage: CBF(a)
+             -1.000000000000000*I
+@@ -3009,7 +3010,7 @@ cdef class ComplexBall(RingElement):
+             sage: CBF(1).rising_factorial(2**64)
+             [+/- ...e+347382171326740403407]
+             sage: ComplexBallField(128)(1).rising_factorial(2**64)
+-            [2.343691126796861348e+347382171305201285713 +/- ...e+347382171305201285694]
++            [2.34369112679686134...e+347382171305201285713 +/- ...]
+             sage: CBF(1/2).rising_factorial(CBF(2,3)) # abs tol 1e-15
+             [-0.123060451458124 +/- 3.06e-16] + [0.0406412631676552 +/- 7.57e-17]*I
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+index b888b31d214..621d86f9bb8 100644
+--- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+@@ -222,7 +222,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef unsigned long n
+         cdef Rational c
+         cdef list L1
+-        cdef mpq_t * L2
++        cdef fmpq_t q
+ 
+         Polynomial.__init__(self, parent, is_gen=is_gen)
+ 
+@@ -253,14 +253,11 @@ cdef class Polynomial_rational_flint(Polynomial):
+             L1 = [e if isinstance(e, Rational) else Rational(e) for e in x]
+             n  = <unsigned long> len(x)
+             sig_on()
+-            L2 = <mpq_t *> check_allocarray(n, sizeof(mpq_t))
++            fmpq_poly_fit_length(self._poly, n)
+             for deg from 0 <= deg < n:
+-                mpq_init(L2[deg])
+-                mpq_set(L2[deg], (<Rational> L1[deg]).value)
+-            fmpq_poly_set_array_mpq(self._poly, L2, n)
+-            for deg from 0 <= deg < n:
+-                mpq_clear(L2[deg])
+-            sig_free(L2)
++                fmpq_init_set_readonly(q, (<Rational> L1[deg]).value)
++                fmpq_poly_set_coeff_fmpq(self._poly, deg, q)
++                fmpq_clear_readonly(q)
+             sig_off()
+ 
+ #           deg = 0
+@@ -435,6 +432,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         utmost care.
+         """
+         cdef bint do_sig = _do_sig(self._poly)
++        cdef fmpz_t tmpfz
+ 
+         if isinstance(value, int):
+             if do_sig: sig_str("FLINT exception")
+@@ -442,7 +440,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+             if do_sig: sig_off()
+         elif isinstance(value, Integer):
+             if do_sig: sig_str("FLINT exception")
+-            fmpq_poly_set_coeff_mpz(self._poly, n, (<Integer> value).value)
++            fmpz_init_set_readonly(tmpfz, (<Integer> value).value)
++            fmpq_poly_set_coeff_fmpz(self._poly, n, tmpfz)
++            fmpz_clear_readonly(tmpfz)
+             if do_sig: sig_off()
+         elif isinstance(value, Rational):
+             if do_sig: sig_str("FLINT exception")
+@@ -492,7 +492,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef Polynomial_rational_flint f
+         cdef Rational r
+         cdef fmpz_t tmpfz
+-        cdef fmpq_t tmpfq
++        cdef fmpq_t tmpfq, tmpfq1
+         cdef RealBall arb_a, arb_z
+         cdef ComplexBall acb_a, acb_z
+ 
+@@ -508,13 +508,23 @@ cdef class Polynomial_rational_flint(Polynomial):
+             elif isinstance(a, Rational):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpq(r.value, self._poly, (<Rational> a).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> a).value)
++                fmpq_init(tmpfq1)
++                fmpq_poly_evaluate_fmpq(tmpfq1, self._poly, tmpfq)
++                fmpq_get_mpq(r.value, tmpfq1)
++                fmpq_clear(tmpfq1)
++                fmpq_clear_readonly(tmpfq)
+                 sig_off()
+                 return r
+             elif isinstance(a, Integer):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpz(r.value, self._poly, (<Integer> a).value)
++                fmpz_init_set_readonly(tmpfz, (<Integer> a).value)
++                fmpq_init(tmpfq)
++                fmpq_poly_evaluate_fmpz(tmpfq, self._poly, tmpfz)
++                fmpq_get_mpq(r.value, tmpfq)
++                fmpq_clear(tmpfq)
++                fmpz_clear_readonly(tmpfz)
+                 sig_off()
+                 return r
+             elif isinstance(a, int):
+@@ -1321,6 +1331,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         """
+         cdef Polynomial_rational_flint res
+         cdef bint do_sig
++        cdef fmpq_t tmpfq
+ 
+         if right == 0:
+             raise ZeroDivisionError("division by zero polynomial")
+@@ -1331,8 +1342,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+                 do_sig = _do_sig(self._poly)
+ 
+                 if do_sig: sig_str("FLINT exception")
+-                fmpq_poly_scalar_div_mpq(res._poly, self._poly,
+-                                                  (<Rational> QQ(right)).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> QQ(right)).value)
++                fmpq_poly_scalar_div_fmpq(res._poly, self._poly, tmpfq)
++                fmpq_clear_readonly(tmpfq)
+                 if do_sig: sig_off()
+                 return res
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+index 4c480673861..780549af062 100644
+--- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+@@ -658,6 +658,11 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
+             ...
+             NotImplementedError: square free factorization of polynomials over rings with composite characteristic is not implemented
+ 
++        :trac:`20003`::
++
++            sage: P.<x> = GF(7)[]
++            sage: (6*x+3).squarefree_decomposition()
++            (6) * (x + 4)
+         """
+         if not self.base_ring().is_field():
+             raise NotImplementedError("square free factorization of polynomials over rings with composite characteristic is not implemented")
+diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
+index 17859068273..14baa5bc5aa 100644
+--- a/src/sage/rings/real_arb.pyx
++++ b/src/sage/rings/real_arb.pyx
+@@ -898,7 +898,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+             sage: RBF.gamma(5)
+             24.00000000000000
+             sage: RBF.gamma(10**20)
+-            [+/- ...e+1956570552410610660600]
++            [1.932849514310098...+1956570551809674817225 +/- ...]
+             sage: RBF.gamma(1/3)
+             [2.678938534707747 +/- ...e-16]
+             sage: RBF.gamma(-5)
+@@ -1102,7 +1102,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+              15.00000000000000,
+              48.00000000000000]
+             sage: RBF.double_factorial(2**20)
+-            [1.4483729903e+2928836 +/- ...e+2928825]
++            [1.448372990...e+2928836 +/- ...]
+             sage: RBF.double_factorial(2**1000)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/schemes/plane_conics/con_rational_function_field.py b/src/sage/schemes/plane_conics/con_rational_function_field.py
+index 1b3f0ac412a..485c9c71be3 100644
+--- a/src/sage/schemes/plane_conics/con_rational_function_field.py
++++ b/src/sage/schemes/plane_conics/con_rational_function_field.py
+@@ -198,38 +198,6 @@ def has_rational_point(self, point=False, algorithm='default',
+             Fraction Field of Univariate Polynomial Ring in u over Rational
+             Field with modulus v^2 - u^3 - 1
+ 
+-        ``has_rational_point`` fails for some conics over function fields
+-        over finite fields, due to :trac:`20003`::
+-
+-            sage: K.<t> = PolynomialRing(GF(7))
+-            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
+-            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
+-            sage: C.has_rational_point()
+-            Traceback (most recent call last):
+-            ...
+-            TypeError: self (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (-t^3 + 3*t^2 - 2*t - 2)/(t + 3)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (t^2 + 3*t + 3)*x*y + (-2*t^2 - 2)*y^2 + (-t^2 + 3*t + 2)*x*z + (-3*t + 3)*y*z + (-3*t^2 + t - 2)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x + (2*t - 2)/(t + 3)*y + (3*t^4 + 2*t^3 - 2*t^2 - 2*t + 3)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z
+-                     : y + (-t^3 - t^2 + 3*t - 1)/(t^3 - 3*t^2 + 2*t + 2)*z : z))
+-            domain must equal right (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^3 - t^2 + 3*t + 3)*x^2 + (t - 3)*y^2 + (-t^7 + 2*t^5 + t^4 + 2*t^3 + 3*t^2 - t - 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    -2/(t^3 - 3*t^2 + 2*t + 2)*x^2 + 1/(t^3 + 3*t^2 - 2*t + 1)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^9 - 2*t^8 + t^7 - t^6 + 3*t^5 - 3*t^3 + t^2 - 2*t + 3)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    ((t^3 - 3*t^2 + 2*t + 2)*x : (t^2 - 2)*y : (t^5 - 3*t^4 + t^2 + 3*t + 3)*z))
+-            codomain
+-
+-
+-
+         TESTS::
+ 
+             sage: K.<t> = FractionField(PolynomialRing(QQ, 't'))
+@@ -250,6 +218,16 @@ def has_rational_point(self, point=False, algorithm='default',
+             sage: C.has_rational_point(point = True) # long time (4 seconds)
+             (True,
+              ((-2/117*t^8 + 304/1053*t^7 + 40/117*t^6 - 1/27*t^5 - 110/351*t^4 - 2/195*t^3 + 11/351*t^2 + 1/117)/(t^4 + 2/39*t^3 + 4/117*t^2 + 2/39*t + 14/39) : -5/3*t^4 + 19*t^3 : 1))
++
++        ``has_rational_point`` used to fail for some conics over function fields
++        over finite fields, due to :trac:`20003`::
++
++            sage: K.<t> = PolynomialRing(GF(7))
++            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
++            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
++            sage: C.has_rational_point()
++            True
++
+         """
+         from .constructor import Conic
+ 
+diff --git a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+index a591cb4cd7c..a90f2050c59 100644
+--- a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
++++ b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+@@ -20,6 +20,7 @@
+ #include "utils.h"
+ 
+ #include "gmp.h"
++#include "flint/fmpz_poly.h"
+ #include "flint/fmpq_poly.h"
+ #include "flint/fmpq.h"
+ 
+@@ -63,7 +64,7 @@ static ex chebyt_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+@@ -122,7 +123,7 @@ static ex chebyu_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+diff --git a/src/sage/symbolic/ginac/useries.cpp b/src/sage/symbolic/ginac/useries.cpp
+index 40fbd7ab360..b9a8b867648 100644
+--- a/src/sage/symbolic/ginac/useries.cpp
++++ b/src/sage/symbolic/ginac/useries.cpp
+@@ -467,10 +467,17 @@ void add::useries(flint_series_t& fp, int order) const
+                 fmpq_poly_set_ui(fp.ft, 0);
+         else if (oc.is_long())
+                 fmpq_poly_set_si(fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ 
+         for (const auto & elem : seq) {
+ 		const ex& t = recombine_pair_to_ex(elem);
+@@ -505,10 +512,17 @@ void mul::useries(flint_series_t& fp, int order) const
+ 
+         if (oc.is_long())
+                 fmpq_poly_scalar_mul_si(fp.ft, fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_scalar_mul_mpz(fp.ft, fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_scalar_mul_mpq(fp.ft, fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_scalar_mul_fmpz(fp.ft, fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp.ft, fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ void power::useries(flint_series_t& fp, int order) const
+@@ -563,7 +577,10 @@ void power::useries(flint_series_t& fp, int order) const
+                 }
+                 check_poly_ccoeff_one(fp1);
+                 fmpq_poly_log_series(fp1.ft, fp1.ft, order);
+-                fmpq_poly_scalar_mul_mpq(fp1.ft, fp1.ft, nexp.as_mpq());
++                fmpq_t tmp;
++                fmpq_init_set_readonly(tmp, nexp.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp1.ft, fp1.ft, tmp);
++                fmpq_clear_readonly(tmp);
+                 fmpq_poly_exp_series(fp.ft, fp1.ft, order);
+                 return;
+         }
+@@ -608,10 +625,17 @@ void numeric::useries(flint_series_t& fp, int order) const
+ {
+         if (is_long())
+                 fmpq_poly_set_si(fp.ft, to_long());
+-        else if (is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, as_mpq());
++        else if (is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ } // namespace GiNaC
+diff --git a/src/sage_setup/library_order.py b/src/sage_setup/library_order.py
+index f40690f8d22..9ae0d2579a7 100644
+--- a/src/sage_setup/library_order.py
++++ b/src/sage_setup/library_order.py
+@@ -16,17 +16,12 @@
+ 
+ aliases = cython_aliases(required_modules=(), optional_modules=modules)
+ 
+-if "ARB_LIBRARY" in aliases:
+-    arb_dylib_names = [aliases["ARB_LIBRARY"]]
+-else:
+-    arb_dylib_names = []
+-
+ library_order_list = aliases.get("SINGULAR_LIBRARIES", []) + [
+     "giac", "intl", "curl",
+     "ec", "ecm"
+ ] + aliases.get("LINBOX_LIBRARIES", []) + aliases.get("FFLASFFPACK_LIBRARIES", []) + aliases.get("GSL_LIBRARIES", []) + [
+     "pari", "flint", "ecl", "glpk", "ppl",
+-] + arb_dylib_names + [
++] + [
+     "mpfi", "mpfr", "mpc", "ntl", "gmp", "gmpxx",
+     "brial",
+     "brial_groebner",
diff --git a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch b/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
deleted file mode 100644
index 7c55bce6e9bb4..0000000000000
--- a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
+++ /dev/null
@@ -1,221 +0,0 @@
-diff --git a/build/pkgs/singular/checksums.ini b/build/pkgs/singular/checksums.ini
-index 313463d2fea..1101fc55700 100644
---- a/build/pkgs/singular/checksums.ini
-+++ b/build/pkgs/singular/checksums.ini
-@@ -1,5 +1,5 @@
- tarball=singular-VERSION.tar.gz
--sha1=28bb3ee97ef48d04dfa96de182fd93eebe08426c
--md5=fc0a4f5720dadba45a52ee94324ce00c
--cksum=1573851737
--upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-1/singular-VERSION.tar.gz
-+sha1=df1997f412580f2073295aba569bb955ad227317
-+md5=50349213e206a18cdaa1bc410dde7ea4
-+cksum=376854707
-+upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-2/singular-VERSION.tar.gz
-diff --git a/build/pkgs/singular/package-version.txt b/build/pkgs/singular/package-version.txt
-index 66e2bede53a..9f1bf008217 100644
---- a/build/pkgs/singular/package-version.txt
-+++ b/build/pkgs/singular/package-version.txt
-@@ -1 +1 @@
--4.3.1p3
-+4.3.2p7
-diff --git a/build/pkgs/singular/spkg-configure.m4 b/build/pkgs/singular/spkg-configure.m4
-index 6a85631f624..f7621ec5fa1 100644
---- a/build/pkgs/singular/spkg-configure.m4
-+++ b/build/pkgs/singular/spkg-configure.m4
-@@ -6,14 +6,27 @@ SAGE_SPKG_CONFIGURE([singular], [
-     AS_IF([test -z "${SINGULAR_BIN}"], [sage_spkg_install_singular=yes], [
-       dnl Use pkg-config to ensure that Singular is new enough.
-       PKG_CHECK_MODULES([SINGULAR], [Singular >= 4.2.1], [
--       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)
--       ], [
--       AC_MSG_RESULT(no)
--       sage_spkg_install_singular=yes
--       ]
--      )], [
-+        AC_MSG_CHECKING([whether Singular is built with FLINT])
-+        AC_COMPILE_IFELSE([
-+          AC_LANG_PROGRAM([
-+            #include <singular/singularconfig.h>
-+            #if !defined(HAVE_FLINT)
-+            #  error "Need Singular compiled with FLINT"
-+          ], [])
-+        ], [
-+          AC_MSG_RESULT([yes])
-+          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)
-+          ], [
-+            AC_MSG_RESULT(no)
-+            sage_spkg_install_singular=yes
-+          ])
-+        ], [
-+          AC_MSG_RESULT([no])
-+          sage_spkg_install_singular=yes
-+        ])
-+      ], [
-       dnl pkg-config version check failed
-       sage_spkg_install_singular=yes
-       ])
-diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py
-index b15cc1c602c..4b5c76e2bfa 100644
---- a/src/sage/interfaces/singular.py
-+++ b/src/sage/interfaces/singular.py
-@@ -604,8 +604,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: i = singular.ideal(['x^2','y^2','z^2'])
-             sage: s = i.std()
-             sage: singular.eval('hilb(%s)'%(s.name()))
--            '// 1 t^0\n// -3 t^2\n// 3 t^4\n// -1 t^6\n\n// 1 t^0\n//
--            3 t^1\n// 3 t^2\n// 1 t^3\n// dimension (affine) = 0\n//
-+            '...// dimension (affine) = 0\n//
-             degree (affine) = 8'
- 
-         ::
-@@ -613,15 +612,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: from sage.misc.verbose import set_verbose
-             sage: set_verbose(1)
-             sage: o = singular.eval('hilb(%s)'%(s.name()))
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
- 
-         This is mainly useful if this method is called implicitly. Because
-@@ -631,15 +622,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-         ::
- 
-             sage: o = s.hilb()
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
-             // ** right side is not a datum, assignment ignored
-             ...
-diff --git a/src/sage/libs/singular/function.pyx b/src/sage/libs/singular/function.pyx
-index f40346d1fd0..c597c63aafe 100644
---- a/src/sage/libs/singular/function.pyx
-+++ b/src/sage/libs/singular/function.pyx
-@@ -1241,32 +1241,22 @@ cdef class SingularFunction(SageObject):
-             sage: I = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5])
-             sage: I = Ideal(I.groebner_basis())
-             sage: hilb = sage.libs.singular.function_factory.ff.hilb
--            sage: hilb(I) # Singular will print // ** _ is no standard basis
--            // ** _ is no standard basis
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: from sage.misc.sage_ostools import redirection
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I) # Singular will print // ** _ is no standard basis
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            True
- 
-         So we tell Singular that ``I`` is indeed a Groebner basis::
- 
--            sage: hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            False
- 
- 
-         TESTS:
-diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-index 22ada6de947..80352700872 100644
---- a/src/sage/rings/polynomial/multi_polynomial_ideal.py
-+++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-@@ -3132,13 +3132,16 @@ def hilbert_numerator(self, grading=None, algorithm='sage'):
-             sage: I.hilbert_numerator()                                                 # needs sage.rings.number_field
-             -t^5 + 1
- 
--        This example returns a wrong answer due to an integer overflow in Singular::
-+        This example returns a wrong answer in singular < 4.3.2p4 due to an integer overflow::
- 
-             sage: n=4; m=11; P = PolynomialRing(QQ, n*m, "x"); x = P.gens(); M = Matrix(n, x)
-             sage: I = P.ideal(M.minors(2))
-             sage: J = P * [m.lm() for m in I.groebner_basis()]
--            sage: J.hilbert_numerator(algorithm='singular')
--            ...120*t^33 - 3465*t^32 + 48180*t^31 - ...
-+            sage: J.hilbert_numerator(algorithm='singular') # known bug
-+            Traceback (most recent call last):
-+            ....
-+            RuntimeError: error in Singular function call 'hilb':
-+            overflow at t^22
- 
-         Our two algorithms should always agree; not tested until
-         :trac:`33178` is fixed::
-diff --git a/src/sage/sandpiles/sandpile.py b/src/sage/sandpiles/sandpile.py
-index 02d2021b2fb..c8e15e06f05 100644
---- a/src/sage/sandpiles/sandpile.py
-+++ b/src/sage/sandpiles/sandpile.py
-@@ -2493,9 +2493,15 @@ def _set_ideal(self):
-             sage: '_ideal' in S.__dict__
-             True
-         """
-+        from sage.libs.singular.function_factory import ff
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
-         R = self.ring()
--        I = self._unsaturated_ideal._singular_()
--        self._ideal = R.ideal(I.sat(prod(R.gens())._singular_())[1])
-+        I = self._unsaturated_ideal
-+        I_sat_gens = sat(I, prod(R.gens()))[0]
-+        self._ideal = R.ideal(I_sat_gens)
- 
-     def unsaturated_ideal(self):
-         r"""
-diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py
-index e6caf19ba74..afd6484d779 100644
---- a/src/sage/schemes/projective/projective_subscheme.py
-+++ b/src/sage/schemes/projective/projective_subscheme.py
-@@ -1001,7 +1001,10 @@ def dual(self):
-         for i in range(n + 1):
-             J = J + S.ideal(z[-1] * f_S.derivative(z[i]) - z[i + n + 1])
- 
--        sat = ff.elim__lib.sat
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
- 
-         max_ideal = S.ideal(z[n + 1: 2 * n + 2])
-         J_sat_gens = sat(J, max_ideal)[0]
diff --git a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch b/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
deleted file mode 100644
index 6a35ec3836550..0000000000000
--- a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-diff --git a/src/sage/ext/memory.pyx b/src/sage/ext/memory.pyx
-index 1de6dedab82..b95130b19dd 100644
---- a/src/sage/ext/memory.pyx
-+++ b/src/sage/ext/memory.pyx
-@@ -3,14 +3,14 @@ Low-level memory allocation functions
- 
- TESTS:
- 
--Check that a ``MemoryError`` is raised if we try to allocate a
-+Check that an error is raised if we try to allocate a
- ridiculously large integer, see :trac:`15363`::
- 
--    sage: 2^(2^63-3)
--    Traceback (most recent call last):
--    ...
--    OverflowError: exponent must be at most 2147483647         # 32-bit
--    RuntimeError: Aborted                                      # 64-bit
-+    sage: try:
-+    ....:     2^(2^63-3)
-+    ....: except (OverflowError, RuntimeError, FloatingPointError):
-+    ....:     print ('Overflow error')
-+    ...Overflow error
- 
- AUTHORS:
- 
-diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx
-index d5e87626d31..37ed9364845 100644
---- a/src/sage/rings/integer.pyx
-+++ b/src/sage/rings/integer.pyx
-@@ -6654,7 +6654,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
-             sage: try:
-             ....:     print('Possible error output from gmp', flush=True)
-             ....:     1 << (2^60)
--            ....: except (MemoryError, OverflowError, RuntimeError):
-+            ....: except (MemoryError, OverflowError, RuntimeError, FloatingPointError):
-             ....:     pass
-             ....: else:
-             ....:     print("Failed to raise exception")
diff --git a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch b/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
deleted file mode 100644
index 3d2a4bd9cd96f..0000000000000
--- a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
+++ /dev/null
@@ -1,740 +0,0 @@
-diff --git a/src/sage/ext_data/valgrind/valgrind-python.supp b/src/sage/ext_data/valgrind/valgrind-python.supp
-new file mode 100644
-index 00000000000..16aa2858484
---- /dev/null
-+++ b/src/sage/ext_data/valgrind/valgrind-python.supp
-@@ -0,0 +1,480 @@
-+# From the CPython repository with the suppressions for _PyObject_Free
-+# and _PyObject_Realloc enabled. See the upstream suppression file for
-+# details:
-+#
-+# https://github.com/python/cpython/blob/main/Misc/valgrind-python.supp
-+
-+# all tool names: Addrcheck,Memcheck,cachegrind,helgrind,massif
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 8 (x86_64 aka amd64)
-+   Memcheck:Value8
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:address_in_range
-+}
-+
-+#
-+# Leaks (including possible leaks)
-+#    Hmmm, I wonder if this masks some real leaks.  I think it does.
-+#    Will need to fix that.
-+#
-+
-+{
-+   Suppress leaking the GIL after a fork.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_allocate_lock
-+   fun:PyEval_ReInitThreads
-+}
-+
-+{
-+   Suppress leaking the autoTLSkey.  This looks like it shouldn't leak though.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_create_key
-+   fun:_PyGILState_Init
-+   fun:Py_InitializeEx
-+   fun:Py_Main
-+}
-+
-+{
-+   Hmmm, is this a real leak or like the GIL?
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_ReInitTLS
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:realloc
-+   fun:_PyObject_GC_Resize
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_New
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_NewVar
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+#
-+# Non-python specific leaks
-+#
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:calloc
-+   fun:allocate_dtv
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:memalign
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Realloc
-+}
-+
-+###
-+### All the suppressions below are for errors that occur within libraries
-+### that Python uses.  The problems to not appear to be related to Python's
-+### use of the libraries.
-+###
-+
-+{
-+   Generic ubuntu ld problems
-+   Memcheck:Addr8
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+}
-+
-+{
-+   Generic gentoo ld problems
-+   Memcheck:Cond
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_close
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Value8
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   GDBM problems, see test_gdbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   fun:gdbm_open
-+
-+}
-+
-+{
-+   Uninitialised byte(s) false alarm, see bpo-35561
-+   Memcheck:Param
-+   epoll_ctl(event)
-+   fun:epoll_ctl
-+   fun:pyepoll_internal_ctl
-+}
-+
-+{
-+   ZLIB problems, see test_gzip
-+   Memcheck:Cond
-+   obj:/lib/libz.so.1.2.3
-+   obj:/lib/libz.so.1.2.3
-+   fun:deflate
-+}
-+
-+{
-+   Avoid problems w/readline doing a putenv and leaking on exit
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:xmalloc
-+   fun:sh_set_lines_and_columns
-+   fun:_rl_get_screen_size
-+   fun:_rl_init_terminal_io
-+   obj:/lib/libreadline.so.4.3
-+   fun:rl_initialize
-+}
-+
-+# Valgrind emits "Conditional jump or move depends on uninitialised value(s)"
-+# false alarms on GCC builtin strcmp() function. The GCC code is correct.
-+#
-+# Valgrind bug: https://bugs.kde.org/show_bug.cgi?id=264936
-+{
-+   bpo-38118: Valgrind emits false alarm on GCC builtin strcmp()
-+   Memcheck:Cond
-+   fun:PyUnicode_Decode
-+}
-+
-+
-+###
-+### These occur from somewhere within the SSL, when running
-+###  test_socket_sll.  They are too general to leave on by default.
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:memset
-+###}
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:memset
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:MD5_Update
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:MD5_Update
-+###}
-+
-+# Fedora's package "openssl-1.0.1-0.1.beta2.fc17.x86_64" on x86_64
-+# See http://bugs.python.org/issue14171
-+{
-+   openssl 1.0.1 prng 1
-+   Memcheck:Cond
-+   fun:bcmp
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 2
-+   Memcheck:Cond
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 3
-+   Memcheck:Value8
-+   fun:_x86_64_AES_encrypt_compact
-+   fun:AES_encrypt
-+}
-+
-+#
-+# All of these problems come from using test_socket_ssl
-+#
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_bin2bn
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libcrypto.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_set_key_unchecked
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_encrypt2
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BUF_MEM_grow_clean
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:memcpy
-+   fun:ssl3_read_bytes
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:SHA1_Update
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:SHA1_Update
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-+{
-+   wcscmp_false_positive
-+   Memcheck:Addr8
-+   fun:wcscmp
-+   fun:_PyOS_GetOpt
-+   fun:Py_Main
-+   fun:main
-+}
-+
-+# Additional suppressions for the unified decimal tests:
-+{
-+   test_decimal
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_decimal2
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index b40ed64edb5..8c55861c147 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -1576,6 +1576,62 @@ const numeric numeric::div(const numeric &other) const {
-         }
- }
- 
-+
-+// Compute `a^b` as an integer, where a is an integer. Assign to ``res``` if it is integral, or return ``false``.
-+// The nonnegative real root is taken for even denominators. To be used inside numeric::integer_rational_power,
-+// to handle the special case of integral ``a``.
-+bool integer_rational_power_of_mpz(
-+        numeric& res,
-+        const numeric& a,
-+        const numeric& b
-+) {
-+        if (a.t != MPZ)
-+                throw std::runtime_error("integer_rational_power_of_mpz: bad input");
-+        mpz_t z;
-+        mpz_init(z);
-+        mpz_set_ui(z, 0);
-+        int sgn = mpz_sgn(a.v._bigint);
-+        if (mpz_cmp_ui(a.v._bigint, 1) == 0
-+            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
-+                mpz_set_ui(z, 1);
-+        else if (sgn == 0) {
-+                res = *_num0_p;
-+                mpz_clear(z);
-+                return true;
-+        }
-+        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1)) {
-+                mpz_clear(z);
-+                return false;
-+        } else {
-+                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-+                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat))) {
-+                        // too big to take roots/powers
-+                        mpz_clear(z);
-+                        return false;
-+                }
-+                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
-+                        if (mpz_perfect_square_p(a.v._bigint)) {
-+                                mpz_sqrt(z, a.v._bigint);
-+                        } else {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                else {
-+                        bool exact = mpz_root(z, a.v._bigint,
-+                                              mpz_get_ui(mpq_denref(b.v._bigrat)));
-+                        if (not exact) {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
-+        }
-+        res = numeric(z);   // transfers ownership, no mpz_clear
-+        return true;
-+}
-+
-+
- // Compute `a^b` as an integer, if it is integral, or return ``false``.
- // The nonnegative real root is taken for even denominators.
- bool numeric::integer_rational_power(numeric& res,
-@@ -1598,13 +1654,12 @@ bool numeric::integer_rational_power(numeric& res,
-                 if (a.v._long < 0
-                     and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
-                         return false;
--                long z;
-                 if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-                     or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
-                 // too big to take roots/powers
-                         return false;
-                 if (b.is_equal(*_num1_2_p)) {
--                        z = std::lround(std::sqrt(a.v._long));
-+                        long z = std::lround(std::sqrt(a.v._long));
-                         if (a.v._long == z*z) {
-                                 res = numeric(z);
-                                 return true;
-@@ -1613,44 +1668,11 @@ bool numeric::integer_rational_power(numeric& res,
-                 }
-                 return integer_rational_power(res, a.to_bigint(), b);
-         }
--        if (a.t != MPZ)
--                throw std::runtime_error("integer_rational_power: bad input");
--        int sgn = mpz_sgn(a.v._bigint);
--        mpz_t z;
--        mpz_init(z);
--        mpz_set_ui(z, 0);
--        if (mpz_cmp_ui(a.v._bigint, 1) == 0
--            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
--                mpz_set_ui(z, 1);
--        else if (sgn == 0) {
--                res = *_num0_p;
--                return true;
--        }
--        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
--                return false;
--        else {
--                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
--                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
--                // too big to take roots/powers
--                        return false;
--                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
--                        if (mpz_perfect_square_p(a.v._bigint))
--                                mpz_sqrt(z, a.v._bigint);
--                        else
--                                return false;
--                }
--                else {
--                        bool exact = mpz_root(z, a.v._bigint,
--                                        mpz_get_ui(mpq_denref(b.v._bigrat)));
--                        if (not exact)
--                                return false;
--                }
--                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
--        }
--        res = numeric(z);
--        return true;
-+        // otherwise: a is integer
-+        return integer_rational_power_of_mpz(res, a, b);
- }
- 
-+
- // for a^b return c,d such that a^b = c*d^b
- // only for MPZ/MPQ base and MPQ exponent
- void rational_power_parts(const numeric& a_orig, const numeric& b_orig,
-diff --git a/src/sage/tests/memcheck/__init__.py b/src/sage/tests/memcheck/__init__.py
-new file mode 100644
-index 00000000000..e69de29bb2d
-diff --git a/src/sage/tests/memcheck/run_tests.py b/src/sage/tests/memcheck/run_tests.py
-new file mode 100644
-index 00000000000..6ff4503a81b
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests.py
-@@ -0,0 +1,24 @@
-+import types
-+
-+
-+def run_tests() -> None:
-+    """
-+    Run all memcheck tests
-+    """
-+    from sage.tests.memcheck import symbolic_expression
-+    run_tests_in_module(symbolic_expression)
-+
-+
-+def run_tests_in_module(mod: types.ModuleType) -> None:
-+    """
-+    Run all memcheck tests in the given module
-+    """
-+    for entry in dir(mod):
-+        if not entry.startswith('test_'):
-+            continue
-+        test_func = getattr(mod, entry)
-+        test_func()
-+
-+
-+if __name__ == '__main__':
-+    run_tests()
-diff --git a/src/sage/tests/memcheck/run_tests_in_valgrind.py b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-new file mode 100644
-index 00000000000..df5ad0e92b2
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-@@ -0,0 +1,35 @@
-+"""
-+Launch valgrind and run the memory leak tests
-+
-+
-+From the commandline, run
-+
-+    sage -python -m sage.tests.memcheck.run_tests_in_valgrind
-+
-+to launch valgrind and execute the memory leak tests. Requires valgrind
-+to be installed. Alternatively, run as a unit test:
-+
-+    sage: from sage.tests.memcheck.run_tests_in_valgrind import run_tests_in_valgrind
-+    sage: run_tests_in_valgrind()    # optional - valgrind
-+"""
-+
-+import subprocess
-+
-+
-+def run_tests_in_valgrind() -> None:
-+    """
-+    Run the sage.tests.memcheck.run_tests module inside valgrind
-+    """
-+    subprocess.check_call([
-+        'valgrind',
-+        '--suppressions=src/sage/ext_data/valgrind/valgrind-python.supp',
-+        '--show-possibly-lost=no',
-+        '--show-reachable=no',
-+        './venv/bin/python',
-+        '-m',
-+        'sage.tests.memcheck.run_tests'
-+    ])
-+
-+
-+if __name__ == '__main__':
-+    run_tests_in_valgrind()
-diff --git a/src/sage/tests/memcheck/symbolic_expression.py b/src/sage/tests/memcheck/symbolic_expression.py
-new file mode 100644
-index 00000000000..52182fbe62d
---- /dev/null
-+++ b/src/sage/tests/memcheck/symbolic_expression.py
-@@ -0,0 +1,11 @@
-+from sage.tests.memcheck.verify_no_leak import verify_no_leak
-+
-+
-+def test_sqrt_sqrt_2() -> None:
-+    from sage.misc.functional import sqrt
-+    T2 = sqrt(2)
-+
-+    def sqrt_T2() -> None:
-+        sqrt(T2)
-+
-+    verify_no_leak(sqrt_T2)
-diff --git a/src/sage/tests/memcheck/verify_no_leak.py b/src/sage/tests/memcheck/verify_no_leak.py
-new file mode 100644
-index 00000000000..89ca90cf89c
---- /dev/null
-+++ b/src/sage/tests/memcheck/verify_no_leak.py
-@@ -0,0 +1,27 @@
-+from typing import Tuple, Sequence, List, Callable, Any
-+import valgrind
-+
-+
-+def verify_no_leak(callback: Callable[[], Any],
-+                   repeat: int = 10000,
-+                   fuzzy: int = 10,
-+                   ) -> None:
-+    """
-+    Verify that the callback does not generate new definitely lost blocks
-+
-+    Raises an assertion if the callback leaks memory
-+    """
-+    callback()   # warm_up
-+    initial_blocks = (0, 0, 0, 0)
-+    valgrind.memcheck_do_leak_check()
-+    initial_blocks = valgrind.memcheck_count_leak_blocks()
-+    for _ in range(repeat):
-+        callback()
-+    valgrind.memcheck_do_leak_check()
-+    leak_blocks = valgrind.memcheck_count_leak_blocks()
-+    leak = leak_blocks[0] - initial_blocks[0]
-+    if leak < repeat - fuzzy:
-+        return  # callback did not leak at least once per call
-+    blocks = round(leak / repeat, 2)
-+    message = f'{callback} leaked {blocks} block on average ({repeat} iterations)'
-+    raise AssertionError(message)
diff --git a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch b/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
deleted file mode 100644
index 684b62affaf5a..0000000000000
--- a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx
-index 8f46570313d..a8e73e57b52 100644
---- a/src/sage/libs/ecl.pyx
-+++ b/src/sage/libs/ecl.pyx
-@@ -563,15 +563,15 @@ cdef class EclObject:
-     Floats in Python are IEEE double, which LISP has as well. However,
-     the printing of floating point types in LISP depends on settings::
- 
--        sage: a = EclObject(float(10^40))
-+        sage: a = EclObject(float(1.234e40))
-         sage: ecl_eval("(setf *read-default-float-format* 'single-float)")
-         <ECL: SINGLE-FLOAT>
-         sage: a
--        <ECL: 1.d40>
-+        <ECL: 1.234d40>
-         sage: ecl_eval("(setf *read-default-float-format* 'double-float)")
-         <ECL: DOUBLE-FLOAT>
-         sage: a
--        <ECL: 1.e40>
-+        <ECL: 1.234e40>
- 
-     Tuples are translated to dotted lists::
- 
-diff --git a/src/sage/libs/eclsig.h b/src/sage/libs/eclsig.h
-index e249ccf6874..005b2d99d0b 100644
---- a/src/sage/libs/eclsig.h
-+++ b/src/sage/libs/eclsig.h
-@@ -45,7 +45,11 @@ static inline void ecl_sig_off(void)
-     sig_off();
- }
- 
-+#if ECL_VERSION_NUMBER < 230909
- #define ecl_mpz_from_bignum(obj) ((obj)->big.big_num)
-+#else
-+#define ecl_mpz_from_bignum(obj) ecl_bignum(obj)
-+#endif
- 
- cl_object ecl_bignum_from_mpz(mpz_t num)
- {
diff --git a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch b/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
deleted file mode 100644
index e858f2fd4a445..0000000000000
--- a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
-index 59f10f6b13f..adcccff059b 100644
---- a/src/sage/plot/graphics.py
-+++ b/src/sage/plot/graphics.py
-@@ -36,6 +36,7 @@
- # ****************************************************************************
- 
- import os
-+from numbers import Integral
- from collections.abc import Iterable
- from math import isnan
- import sage.misc.verbose
-@@ -2874,6 +2875,11 @@ def matplotlib(self, filename=None,
-                 weight=lopts.pop('font_weight', 'medium'),
-                 variant=lopts.pop('font_variant', 'normal'))
-             color = lopts.pop('back_color', 'white')
-+            if 'loc' in lopts:
-+                loc = lopts['loc']
-+                if isinstance(loc, Integral):
-+                    # matplotlib 3.8 doesn't support sage integers
-+                    lopts['loc'] = int(loc)
-             leg = subplot.legend(prop=prop, **lopts)
-             if leg is None:
-                 from warnings import warn
diff --git a/srcpkgs/sagemath/patches/36403-00pre.patch b/srcpkgs/sagemath/patches/36403-00pre.patch
deleted file mode 100644
index 060404d5430de..0000000000000
--- a/srcpkgs/sagemath/patches/36403-00pre.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-Minor patch so that #36403 applies cleanly over sagemath 10.1
-
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 2053bca80c3..86aca6e00d8 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15123,7 +15302,8 @@ cdef class Matrix(Matrix1):
-             sage: N.conjugate_transpose()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object has no attribute 'conjugate'
-+            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
-+            has no attribute 'conjugate'
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 525ea5aa934..52afed49d64 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -55,7 +55,7 @@ cdef class AttributeErrorMessage:
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-         sage: x = polygen(ZZ, 'x')
--        sage: QQ[x].gen().bla                                                           # optional - sage.libs.flint
-+        sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
diff --git a/srcpkgs/sagemath/patches/36407-python_3.12.patch b/srcpkgs/sagemath/patches/36407-python_3.12.patch
deleted file mode 100644
index c75c275c30764..0000000000000
--- a/srcpkgs/sagemath/patches/36407-python_3.12.patch
+++ /dev/null
@@ -1,1744 +0,0 @@
-diff --git a/build/sage_bootstrap/package.py b/build/sage_bootstrap/package.py
-index 15b342223c4..eb82f96e05f 100644
---- a/build/sage_bootstrap/package.py
-+++ b/build/sage_bootstrap/package.py
-@@ -303,7 +303,7 @@ def _init_checksum(self):
-         # Name of the directory containing the checksums.ini file
-         self.__tarball_package_name = os.path.realpath(checksums_ini).split(os.sep)[-2]
- 
--    VERSION_PATCHLEVEL = re.compile('(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
-+    VERSION_PATCHLEVEL = re.compile(r'(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
- 
-     def _init_version(self):
-         try:
-diff --git a/src/doc/en/thematic_tutorials/coercion_and_categories.rst b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-index bb23331c151..7f5712caea7 100644
---- a/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-+++ b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-@@ -1223,7 +1223,7 @@ However, only "elementary" construction functors have a rank::
-     sage: (Fract*Poly).rank
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'
-+    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'...
- 
- .. end of output
- 
-diff --git a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-index 553a946c4d8..3cd71a9bad4 100644
---- a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-+++ b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-@@ -318,7 +318,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: e.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'...
- 
-         sage: id4 = SymmetricGroup(4).one()
-         sage: type(id4)
-@@ -326,7 +326,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: id4.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'
-+        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'...
- 
- .. note::
- 
-diff --git a/src/sage/algebras/cluster_algebra.py b/src/sage/algebras/cluster_algebra.py
-index b72d2a12976..14669dfed5c 100644
---- a/src/sage/algebras/cluster_algebra.py
-+++ b/src/sage/algebras/cluster_algebra.py
-@@ -167,7 +167,7 @@
-     sage: (t*s).g_vector()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'
-+    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'...
-     sage: A = ClusterAlgebra(['A', 2], principal_coefficients=True)
-     sage: A.explore_to_depth(infinity)
-     sage: s = A.cluster_variable((0, -1)); s
-diff --git a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-index e4a91723558..343ee8a66f9 100644
---- a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-+++ b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-@@ -109,7 +109,7 @@ class WeylLieConformalAlgebra(LieConformalAlgebraWithStructureCoefficients):
-         sage: alpha0.degree()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'
-+        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'...
- 
-     TESTS::
- 
-diff --git a/src/sage/algebras/steenrod/steenrod_algebra.py b/src/sage/algebras/steenrod/steenrod_algebra.py
-index 978a3557a9d..7c4d444f81c 100644
---- a/src/sage/algebras/steenrod/steenrod_algebra.py
-+++ b/src/sage/algebras/steenrod/steenrod_algebra.py
-@@ -1080,7 +1080,7 @@ def homogeneous_component(self, n):
-             sage: a.antipode() # not defined
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'
-+            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'...
-             sage: A(a).antipode() # convert to elt of A, then compute antipode
-             Sq(2,1) + Sq(5)
- 
-diff --git a/src/sage/all__sagemath_repl.py b/src/sage/all__sagemath_repl.py
-index 8d0b43679ca..c31b206bcb8 100644
---- a/src/sage/all__sagemath_repl.py
-+++ b/src/sage/all__sagemath_repl.py
-@@ -79,6 +79,23 @@
-                         message=r"Use setlocale\(\), getencoding\(\) and getlocale\(\) instead",
-                         module='docutils.io')
- 
-+# triggered by dateutil 2.8.2 and sphinx 7.0.1 on Python 3.12
-+# see: https://github.com/dateutil/dateutil/pull/1285
-+# see: https://github.com/sphinx-doc/sphinx/pull/11468
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"datetime.datetime.utcfromtimestamp\(\) is deprecated",
-+                        module='dateutil.tz.tz|sphinx.(builders.gettext|util.i18n)')
-+
-+# triggered on Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"This process.* is multi-threaded, "
-+                                r"use of .*\(\) may lead to deadlocks in the child.")
-+
-+# pickling of itertools is deprecated in Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"Pickle, copy, and deepcopy support will be "
-+                                r"removed from itertools in Python 3.14.")
-+
- 
- from .all__sagemath_objects import *
- from .all__sagemath_environment import *
-diff --git a/src/sage/arith/long.pxd b/src/sage/arith/long.pxd
-index 0031a0ae337..3ea70cef571 100644
---- a/src/sage/arith/long.pxd
-+++ b/src/sage/arith/long.pxd
-@@ -19,6 +19,8 @@ from libc.limits cimport LONG_MIN, LONG_MAX
- from cpython.object cimport Py_SIZE
- from cpython.number cimport PyNumber_Index, PyIndex_Check
- from cpython.longintrepr cimport py_long, PyLong_SHIFT, digit
-+from sage.cpython.pycore_long cimport (
-+    ob_digit, _PyLong_IsNegative, _PyLong_DigitCount)
- 
- from sage.libs.gmp.mpz cimport mpz_fits_slong_p, mpz_get_si
- from sage.rings.integer_fake cimport is_Integer, Integer_AS_MPZ
-@@ -299,8 +301,11 @@ cdef inline bint integer_check_long_py(x, long* value, int* err):
-         return 0
- 
-     # x is a Python "int" (aka PyLongObject or py_long in cython)
--    cdef const digit* D = (<py_long>x).ob_digit
--    cdef Py_ssize_t size = Py_SIZE(x)
-+    cdef const digit* D = ob_digit(x)
-+    cdef Py_ssize_t size = _PyLong_DigitCount(x)
-+
-+    if _PyLong_IsNegative(x):
-+        size = -size
- 
-     # We assume PyLong_SHIFT <= BITS_IN_LONG <= 3 * PyLong_SHIFT.
-     # This is true in all the default configurations:
-diff --git a/src/sage/categories/category.py b/src/sage/categories/category.py
-index 57ef7f4184b..29bce8ee415 100644
---- a/src/sage/categories/category.py
-+++ b/src/sage/categories/category.py
-@@ -2129,7 +2129,7 @@ def _with_axioms(self, axioms):
-             sage: Semigroups().Inverse()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'
-+            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'...
-             sage: Semigroups()._with_axioms(["Inverse"])
-             Category of semigroups
- 
-diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py
-index 5227792e725..4775d4e5bf1 100644
---- a/src/sage/categories/category_with_axiom.py
-+++ b/src/sage/categories/category_with_axiom.py
-@@ -554,7 +554,7 @@ class from the base category class::
-     sage: Magmas.Unital.Associative
-     Traceback (most recent call last):
-     ...
--    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'
-+    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'...
- 
- The purpose of this section is to explain the design of the code
- layout and the rationale for this mismatch.
-@@ -769,7 +769,7 @@ def _(): return LazyImport('sage.categories.rngs', 'Rngs', at_startup=True)
-     sage: Semirings().NoZeroDivisors()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'
-+    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'...
- 
- Concretely, this is to be implemented by defining the new axiom in the
- (``SubcategoryMethods`` nested class of the) appropriate category with
-diff --git a/src/sage/categories/enumerated_sets.py b/src/sage/categories/enumerated_sets.py
-index a8bea53f907..b0ea05d0563 100644
---- a/src/sage/categories/enumerated_sets.py
-+++ b/src/sage/categories/enumerated_sets.py
-@@ -610,7 +610,7 @@ def _list_from_iterator(self):
-                 sage: (QQ^2).list()  # indirect test                                    # needs sage.modules
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'
-+                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'...
- 
-             Here we test that for an object that does not know whether it
-             is finite or not.  Calling ``x.list()`` simply tries to create
-@@ -622,11 +622,11 @@ def _list_from_iterator(self):
-                 sage: Q.is_finite()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'...
-                 sage: Q.list()   # indirect test
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'...
- 
-             Here is another example. We artificially create a version of
-             the ring of integers that does not know whether it is finite
-diff --git a/src/sage/categories/examples/sets_cat.py b/src/sage/categories/examples/sets_cat.py
-index e0853d63f94..fbadb9ca405 100644
---- a/src/sage/categories/examples/sets_cat.py
-+++ b/src/sage/categories/examples/sets_cat.py
-@@ -619,7 +619,7 @@ class PrimeNumbers_Facade(PrimeNumbers_Abstract):
-         sage: pf.next()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'...
- 
-     unlike in the other implementations::
- 
-diff --git a/src/sage/categories/homset.py b/src/sage/categories/homset.py
-index 22ba9d047fc..2a8b8aeedeb 100644
---- a/src/sage/categories/homset.py
-+++ b/src/sage/categories/homset.py
-@@ -632,7 +632,7 @@ def __init__(self, X, Y, category=None, base=None, check=True):
-             sage: H = MyHomset(X, Y, category=1, base = ZZ, check = False)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'...
-             sage: P.<t> = ZZ[]
-             sage: f = P.hom([1/2*t])
-             sage: f.parent().domain()
-diff --git a/src/sage/categories/modules_with_basis.py b/src/sage/categories/modules_with_basis.py
-index e97bf851388..c4933d0657f 100644
---- a/src/sage/categories/modules_with_basis.py
-+++ b/src/sage/categories/modules_with_basis.py
-@@ -2456,7 +2456,7 @@ def apply_multilinear_morphism(self, f, codomain=None):
-                     sage: tensor([a, b]).apply_multilinear_morphism(f)                  # needs sage.modules
-                     Traceback (most recent call last):
-                     ...
--                    AttributeError: 'int' object has no attribute 'parent'
-+                    AttributeError: 'int' object has no attribute 'parent'...
- 
-                 Here we consider an example where the codomain is a
-                 module with basis with a different base ring::
-diff --git a/src/sage/categories/monoids.py b/src/sage/categories/monoids.py
-index 38dd7248c9d..28474bd17b6 100644
---- a/src/sage/categories/monoids.py
-+++ b/src/sage/categories/monoids.py
-@@ -556,7 +556,7 @@ def algebra_generators(self):
-                     Traceback (most recent call last):
-                     ...
-                     AttributeError: 'IntegerModMonoid_with_category' object
--                    has no attribute 'monoid_generators'
-+                    has no attribute 'monoid_generators'...
-                     sage: Z12.semigroup_generators()
-                     Family (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
-                     sage: Z12.algebra(QQ).algebra_generators()                          # needs sage.modules
-diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py
-index 494e8154c80..ec5120e41e6 100644
---- a/src/sage/combinat/finite_state_machine.py
-+++ b/src/sage/combinat/finite_state_machine.py
-@@ -1835,7 +1835,7 @@ def __getstate__(self):
-             sage: T1.transitions
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'FSMState' object has no attribute 'transitions'
-+            AttributeError: 'FSMState' object has no attribute 'transitions'...
-             sage: A1 = loads(dumps(A))
-             sage: all(A.state(j) == A1.state(j) for j in [0, 1])
-             True
-diff --git a/src/sage/combinat/growth.py b/src/sage/combinat/growth.py
-index cf8d18c1764..766eea37917 100644
---- a/src/sage/combinat/growth.py
-+++ b/src/sage/combinat/growth.py
-@@ -371,7 +371,7 @@
-     sage: GrowthDiagram(RulePascal(), [3,1,2])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'RulePascal' object has no attribute 'forward_rule'
-+    AttributeError: 'RulePascal' object has no attribute 'forward_rule'...
- 
- We now re-implement the rule where we provide the dual graded graphs::
- 
-diff --git a/src/sage/combinat/integer_lists/lists.py b/src/sage/combinat/integer_lists/lists.py
-index 5143e5cb5e8..9117a6076f7 100644
---- a/src/sage/combinat/integer_lists/lists.py
-+++ b/src/sage/combinat/integer_lists/lists.py
-@@ -261,7 +261,7 @@ def __getattr__(self, name):
-             sage: L.foo
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'foo'
-+            AttributeError: 'NoneType' object has no attribute 'foo'...
-         """
-         return getattr(self.backend, name)
- 
-diff --git a/src/sage/combinat/posets/posets.py b/src/sage/combinat/posets/posets.py
-index c31597c72e9..c74bfc67cee 100644
---- a/src/sage/combinat/posets/posets.py
-+++ b/src/sage/combinat/posets/posets.py
-@@ -8825,7 +8825,7 @@ def is_induced_subposet(self, other):
-             sage: Poset().is_induced_subposet('junk')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'subposet'
-+            AttributeError: 'str' object has no attribute 'subposet'...
-         """
-         if (not self._is_facade or (isinstance(other, FinitePoset) and
-                                     not other._is_facade)):
-diff --git a/src/sage/cpython/atexit.pyx b/src/sage/cpython/atexit.pyx
-index 961aa348d0a..e5a82735137 100644
---- a/src/sage/cpython/atexit.pyx
-+++ b/src/sage/cpython/atexit.pyx
-@@ -154,6 +154,10 @@ cdef extern from *:
-     #undef _PyGC_FINALIZED
-     #include "internal/pycore_interp.h"
-     #include "internal/pycore_pystate.h"
-+    #if PY_VERSION_HEX >= 0x030c0000
-+    // struct atexit_callback was renamed in 3.12 to atexit_py_callback
-+    #define atexit_callback atexit_py_callback
-+    #endif
-     static atexit_callback ** _atexit_callbacks(PyObject *self) {
-         PyInterpreterState *interp = _PyInterpreterState_GET();
-         struct atexit_state state = interp->atexit;
-diff --git a/src/sage/cpython/debug.pyx b/src/sage/cpython/debug.pyx
-index 986abff2a99..cdaca3a4854 100644
---- a/src/sage/cpython/debug.pyx
-+++ b/src/sage/cpython/debug.pyx
-@@ -78,7 +78,7 @@ def getattr_debug(obj, name, default=_no_default):
- 
-     EXAMPLES::
- 
--        sage: _ = getattr_debug(list, "reverse")
-+        sage: _ = getattr_debug(list, "reverse")  # not tested - broken in python 3.12
-         getattr_debug(obj=<class 'list'>, name='reverse'):
-           type(obj) = <class 'type'>
-           object has __dict__ slot (<class 'dict'>)
-@@ -123,7 +123,7 @@ def getattr_debug(obj, name, default=_no_default):
-         sage: _ = getattr_debug(1, "foo")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'...
-         sage: _ = getattr_debug(1, "foo", "xyz")
-         getattr_debug(obj=1, name='foo'):
-           type(obj) = <class 'sage.rings.integer.Integer'>
-diff --git a/src/sage/cpython/dict_internal.h b/src/sage/cpython/dict_internal.h
-index 42a57bcb468..a5ee35bc198 100644
---- a/src/sage/cpython/dict_internal.h
-+++ b/src/sage/cpython/dict_internal.h
-@@ -169,6 +169,7 @@ dictkeys_set_index(PyDictKeysObject *keys, Py_ssize_t i, Py_ssize_t ix)
- #else   /* Python >= 3.11 */
- 
- #define Py_BUILD_CORE
-+#undef _PyGC_FINALIZED
- #include <internal/pycore_dict.h>
- 
- /************************************************************/
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 52afed49d64..1f49e5230c3 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -53,12 +53,12 @@ cdef class AttributeErrorMessage:
-         sage: 1.bla  #indirect doctest
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'...
-         sage: x = polygen(ZZ, 'x')
-         sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'...
- 
-     ::
- 
-@@ -144,7 +144,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(X, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: x = X()
-         sage: raw_getattr(x, "prop")
-         <property object at ...>
-@@ -173,7 +173,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(Y, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: y = Y()
-         sage: raw_getattr(y, "prop")
-         <property object at ...>
-@@ -278,7 +278,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     The integer ring is a parent, so, lazy attributes work::
- 
-@@ -289,7 +289,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(17, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     In general, descriptors are not yet well supported, because they
-     often do not accept to be cheated with the type of their instance::
-@@ -305,7 +305,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__weakref__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-     This was caught by :trac:`8296` for which we do a couple more tests::
- 
-@@ -314,7 +314,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: 1.__weakref__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-         sage: n = 1
-         sage: ip = get_ipython()                 # not tested: only works in interactive shell
-@@ -329,7 +329,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__call__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'...
- 
-     TESTS:
- 
-@@ -339,14 +339,14 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, type, "__name__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'...
- 
-     Non-strings as "name" are handled gracefully::
- 
-         sage: getattr_from_other_class(1, type, None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute None
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute None...
-     """
-     if not isinstance(cls, type):
-         raise TypeError(f"{cls!r} is not a type")
-diff --git a/src/sage/cpython/pycore_long.h b/src/sage/cpython/pycore_long.h
-new file mode 100644
-index 00000000000..ff1a73d097a
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.h
-@@ -0,0 +1,98 @@
-+#include "Python.h"
-+#include <stdbool.h>
-+
-+#if PY_VERSION_HEX >= 0x030C00A5
-+#define ob_digit(o)  (((PyLongObject*)o)->long_value.ob_digit)
-+#else
-+#define ob_digit(o)  (((PyLongObject*)o)->ob_digit)
-+#endif
-+
-+#if PY_VERSION_HEX >= 0x030C00A7
-+// taken from cpython:Include/internal/pycore_long.h @ 3.12
-+
-+/* Long value tag bits:
-+ * 0-1: Sign bits value = (1-sign), ie. negative=2, positive=0, zero=1.
-+ * 2: Reserved for immortality bit
-+ * 3+ Unsigned digit count
-+ */
-+#define SIGN_MASK 3
-+#define SIGN_ZERO 1
-+#define SIGN_NEGATIVE 2
-+#define NON_SIZE_BITS 3
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_ZERO;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_NEGATIVE;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    assert(PyLong_Check(op));
-+    return op->long_value.lv_tag >> NON_SIZE_BITS;
-+}
-+
-+#define TAG_FROM_SIGN_AND_SIZE(sign, size) ((1 - (sign)) | ((size) << NON_SIZE_BITS))
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+    assert(size >= 0);
-+    assert(-1 <= sign && sign <= 1);
-+    assert(sign != 0 || size == 0);
-+    op->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sign, (size_t)size);
-+}
-+
-+#else
-+// fallback for < 3.12
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) == 0;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) < 0;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) > 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    Py_ssize_t size = Py_SIZE(op);
-+    return size < 0 ? -size : size;
-+}
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION < 9)
-+// The function Py_SET_SIZE is defined starting with python 3.9.
-+    Py_SIZE(o) = size;
-+#else
-+    Py_SET_SIZE(op, sign < 0 ? -size : size);
-+#endif
-+}
-+
-+#endif
-diff --git a/src/sage/cpython/pycore_long.pxd b/src/sage/cpython/pycore_long.pxd
-new file mode 100644
-index 00000000000..41de637ff18
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.pxd
-@@ -0,0 +1,9 @@
-+from cpython.longintrepr cimport py_long, digit
-+
-+cdef extern from "pycore_long.h":
-+    digit* ob_digit(py_long o)
-+    bint _PyLong_IsZero(py_long o)
-+    bint _PyLong_IsNegative(py_long o)
-+    bint _PyLong_IsPositive(py_long o)
-+    Py_ssize_t _PyLong_DigitCount(py_long o)
-+    void _PyLong_SetSignAndDigitCount(py_long o, int sign, Py_ssize_t size)
-diff --git a/src/sage/crypto/classical.py b/src/sage/crypto/classical.py
-index 616dc861652..be899c781e5 100644
---- a/src/sage/crypto/classical.py
-+++ b/src/sage/crypto/classical.py
-@@ -494,7 +494,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: A.rank_by_chi_square("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_chi_square(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -703,7 +703,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: A.rank_by_squared_differences("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_squared_differences(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -2114,7 +2114,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: S.rank_by_chi_square("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_chi_square(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-@@ -2351,7 +2351,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: S.rank_by_squared_differences("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_squared_differences(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/crypto/mq/mpolynomialsystemgenerator.py b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-index 9028dab1d98..4416d9ef7f6 100644
---- a/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-+++ b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-@@ -156,7 +156,7 @@ def sbox(self):
-             sage: msg.sbox()
-             Traceback (most recent call last):
-             ...
--            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'
-+            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'...
-         """
-         return self._sbox
- 
-diff --git a/src/sage/data_structures/bitset.pyx b/src/sage/data_structures/bitset.pyx
-index 446062554c1..d9906b5edd2 100644
---- a/src/sage/data_structures/bitset.pyx
-+++ b/src/sage/data_structures/bitset.pyx
-@@ -967,7 +967,7 @@ cdef class FrozenBitset:
-             sage: None | FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute '_union'
-+            AttributeError: 'NoneType' object has no attribute '_union'...
-         """
-         return self._union(other)
- 
-@@ -1037,7 +1037,7 @@ cdef class FrozenBitset:
-             sage: None & FrozenBitset("101011")
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'intersection'
-+            AttributeError: 'NoneType' object has no attribute 'intersection'...
-         """
-         return self.intersection(other)
- 
-@@ -1106,7 +1106,7 @@ cdef class FrozenBitset:
-             sage: None - FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'difference'
-+            AttributeError: 'NoneType' object has no attribute 'difference'...
-         """
-         return self.difference(other)
- 
-@@ -1179,7 +1179,7 @@ cdef class FrozenBitset:
-             sage: None ^^ FrozenBitset('11111' * 10)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'
-+            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'...
-         """
-         return self.symmetric_difference(other)
- 
-diff --git a/src/sage/doctest/reporting.py b/src/sage/doctest/reporting.py
-index 361fea344c2..a3947c07e01 100644
---- a/src/sage/doctest/reporting.py
-+++ b/src/sage/doctest/reporting.py
-@@ -368,7 +368,7 @@ def report(self, source, timeout, return_code, results, output, pid=None):
-             sage: DTR.report(None, None, None, None, None)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'basename'
-+            AttributeError: 'NoneType' object has no attribute 'basename'...
- 
-         The only-errors mode does not output anything on success::
- 
-diff --git a/src/sage/dynamics/finite_dynamical_system.py b/src/sage/dynamics/finite_dynamical_system.py
-index e5fbf568b7e..4295070615a 100644
---- a/src/sage/dynamics/finite_dynamical_system.py
-+++ b/src/sage/dynamics/finite_dynamical_system.py
-@@ -240,7 +240,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-@@ -252,7 +252,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-diff --git a/src/sage/geometry/cone.py b/src/sage/geometry/cone.py
-index f0a8620011a..53f78a4b7b6 100644
---- a/src/sage/geometry/cone.py
-+++ b/src/sage/geometry/cone.py
-@@ -340,7 +340,7 @@ def Cone(rays, lattice=None, check=True, normalize=True):
-         sage: Cone([(1,0), (0,1)], check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     You can construct different "not" cones: not full-dimensional, not
-     strictly convex, not containing any rays::
-diff --git a/src/sage/geometry/fan.py b/src/sage/geometry/fan.py
-index 258544012fe..3aecc84a55b 100644
---- a/src/sage/geometry/fan.py
-+++ b/src/sage/geometry/fan.py
-@@ -443,7 +443,7 @@ def Fan(cones, rays=None, lattice=None, check=True, normalize=True,
-         sage: P2c = Fan(cones, rays, check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     Yet another way is to use functions :func:`FaceFan` and :func:`NormalFan`
-     to construct fans from :class:`lattice polytopes
-diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-index f0ac1e774a7..f03f0f832ff 100644
---- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-+++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-@@ -351,7 +351,7 @@ cdef class FaceIterator_base(SageObject):
-             sage: FaceIterator_base(2)  # indirect doctest
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'...
-         """
-         cdef int i
-         sig_free(self.structure.atom_rep)
-@@ -1945,7 +1945,8 @@ cdef inline int next_face_loop(iter_t structure) nogil except -1:
-         # The function is not supposed to be called,
-         # just prevent it from crashing.
-         # Actually raising an error here results in a bad branch prediction.
--        return -1
-+        # But return -1 results in a crash with python 3.12
-+        raise StopIteration
- 
-     # Getting ``[faces, n_faces, n_visited_all]`` according to dimension.
-     cdef face_list_t* faces = &structure.new_faces[structure.current_dimension]
-diff --git a/src/sage/geometry/toric_plotter.py b/src/sage/geometry/toric_plotter.py
-index 50b4008eb0f..950e3ba7ff8 100644
---- a/src/sage/geometry/toric_plotter.py
-+++ b/src/sage/geometry/toric_plotter.py
-@@ -706,7 +706,7 @@ def set_rays(self, generators):
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ToricPlotter' object has no attribute 'rays'
-+            AttributeError: 'ToricPlotter' object has no attribute 'rays'...
-             sage: tp.set_rays([(0,1)])
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Graphics object consisting of 2 graphics primitives
-diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
-index d0ec214bb3b..c8098ad578a 100644
---- a/src/sage/groups/matrix_gps/finitely_generated.py
-+++ b/src/sage/groups/matrix_gps/finitely_generated.py
-@@ -268,7 +268,7 @@ def MatrixGroup(*gens, **kwds):
-         sage: SL2C.gens()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'
-+        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'...
-     """
-     if isinstance(gens[-1], dict):   # hack for unpickling
-         kwds.update(gens[-1])
-diff --git a/src/sage/homology/chains.py b/src/sage/homology/chains.py
-index 87c0947c0b0..b9a54940943 100644
---- a/src/sage/homology/chains.py
-+++ b/src/sage/homology/chains.py
-@@ -298,7 +298,7 @@ def is_cycle(self):
-                 sage: chain.is_cocycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -325,7 +325,7 @@ def is_boundary(self):
-                 sage: chain.is_coboundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -539,7 +539,7 @@ def is_cocycle(self):
-                 sage: cochain.is_cycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -566,7 +566,7 @@ def is_coboundary(self):
-                 sage: cochain.is_boundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -604,7 +604,7 @@ def eval(self, other):
-                 sage: z.eval(c) # z is not a cochain
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'...
-                 sage: c.eval(c) # can't evaluate a cochain on a cochain
-                 Traceback (most recent call last):
-                 ...
-diff --git a/src/sage/homology/free_resolution.py b/src/sage/homology/free_resolution.py
-index e3d38de4240..280a479b438 100644
---- a/src/sage/homology/free_resolution.py
-+++ b/src/sage/homology/free_resolution.py
-@@ -275,7 +275,7 @@ def differential(self, i):
-             sage: FreeResolution.differiental(r, 1)
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'FreeResolution' has no attribute 'differiental'
-+            AttributeError: type object 'FreeResolution' has no attribute 'differiental'...
-         """
- 
-     def target(self):
-diff --git a/src/sage/interfaces/magma.py b/src/sage/interfaces/magma.py
-index b7a0ac20d03..529bfbc349b 100644
---- a/src/sage/interfaces/magma.py
-+++ b/src/sage/interfaces/magma.py
-@@ -824,7 +824,7 @@ def _coerce_from_special_method(self, x):
-             sage: magma._coerce_from_special_method('2 + 3')  # optional - magma
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute '_magma_init_'
-+            AttributeError: 'str' object has no attribute '_magma_init_'...
-         """
-         s = x._magma_init_(self)
-         a = self(s)
-diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
-index 58499396d6c..16119d20815 100644
---- a/src/sage/lfunctions/dokchitser.py
-+++ b/src/sage/lfunctions/dokchitser.py
-@@ -418,8 +418,8 @@ def init_coeffs(self, v, cutoff=1,
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
-index bbf289aa21c..e4968866303 100644
---- a/src/sage/lfunctions/pari.py
-+++ b/src/sage/lfunctions/pari.py
-@@ -141,8 +141,8 @@ def init_coeffs(self, v, cutoff=None, w=1):
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
-index 478caf9f9d0..363024ae281 100644
---- a/src/sage/libs/gap/element.pyx
-+++ b/src/sage/libs/gap/element.pyx
-@@ -380,7 +380,7 @@ cdef GapElement make_GapElement(parent, Obj obj):
-         sage: libgap(None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute '_libgap_init_'
-+        AttributeError: 'NoneType' object has no attribute '_libgap_init_'...
-     """
-     cdef GapElement r = GapElement.__new__(GapElement)
-     r._initialize(parent, obj)
-diff --git a/src/sage/libs/gmp/pylong.pxd b/src/sage/libs/gmp/pylong.pxd
-index a73f1da6d6f..84e1bb8cd87 100644
---- a/src/sage/libs/gmp/pylong.pxd
-+++ b/src/sage/libs/gmp/pylong.pxd
-@@ -2,9 +2,10 @@
- Various functions to deal with conversion mpz <-> Python int/long
- """
- 
-+from cpython.longintrepr cimport py_long
- from sage.libs.gmp.types cimport *
- 
- cdef mpz_get_pylong(mpz_srcptr z)
- cdef mpz_get_pyintlong(mpz_srcptr z)
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1
- cdef Py_hash_t mpz_pythonhash(mpz_srcptr z)
-diff --git a/src/sage/libs/gmp/pylong.pyx b/src/sage/libs/gmp/pylong.pyx
-index d5993cca5a5..1a36c29d3fa 100644
---- a/src/sage/libs/gmp/pylong.pyx
-+++ b/src/sage/libs/gmp/pylong.pyx
-@@ -28,6 +28,8 @@ AUTHORS:
- from cpython.object cimport Py_SIZE
- from cpython.long cimport PyLong_FromLong
- from cpython.longintrepr cimport _PyLong_New, py_long, digit, PyLong_SHIFT
-+from sage.cpython.pycore_long cimport (ob_digit, _PyLong_IsNegative,
-+    _PyLong_DigitCount, _PyLong_SetSignAndDigitCount)
- from .mpz cimport *
- 
- cdef extern from *:
-@@ -60,12 +62,9 @@ cdef mpz_get_pylong_large(mpz_srcptr z):
-     """
-     cdef size_t nbits = mpz_sizeinbase(z, 2)
-     cdef size_t pylong_size = (nbits + PyLong_SHIFT - 1) // PyLong_SHIFT
--    L = _PyLong_New(pylong_size)
--    mpz_export(L.ob_digit, NULL,
--            -1, sizeof(digit), 0, PyLong_nails, z)
--    if mpz_sgn(z) < 0:
--        # Set correct size
--        Py_SET_SIZE(L, -pylong_size)
-+    cdef py_long L = _PyLong_New(pylong_size)
-+    mpz_export(ob_digit(L), NULL, -1, sizeof(digit), 0, PyLong_nails, z)
-+    _PyLong_SetSignAndDigitCount(L, mpz_sgn(z), pylong_size)
-     return L
- 
- 
-@@ -88,16 +87,13 @@ cdef mpz_get_pyintlong(mpz_srcptr z):
-     return mpz_get_pylong_large(z)
- 
- 
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1:
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1:
-     """
-     Convert a Python ``long`` `L` to an ``mpz``.
-     """
--    cdef Py_ssize_t pylong_size = Py_SIZE(L)
--    if pylong_size < 0:
--        pylong_size = -pylong_size
--    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails,
--            (<py_long>L).ob_digit)
--    if Py_SIZE(L) < 0:
-+    cdef Py_ssize_t pylong_size = _PyLong_DigitCount(L)
-+    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails, ob_digit(L))
-+    if _PyLong_IsNegative(L):
-         mpz_neg(z, z)
- 
- 
-diff --git a/src/sage/manifolds/calculus_method.py b/src/sage/manifolds/calculus_method.py
-index f5830c0bc45..303dde6cd13 100644
---- a/src/sage/manifolds/calculus_method.py
-+++ b/src/sage/manifolds/calculus_method.py
-@@ -257,7 +257,7 @@ def simplify(self, expression, method=None):
-             sage: cm.simplify(f)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'
-+            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'...
- 
-         In the present case, one should either transform ``f`` to a SymPy
-         object::
-diff --git a/src/sage/manifolds/differentiable/vectorfield_module.py b/src/sage/manifolds/differentiable/vectorfield_module.py
-index d954b5d4839..af4bfb0ceec 100644
---- a/src/sage/manifolds/differentiable/vectorfield_module.py
-+++ b/src/sage/manifolds/differentiable/vectorfield_module.py
-@@ -885,7 +885,7 @@ def tensor(self, *args, **kwds):
-             sage: XM.tensor(XM).tensor(XM.dual().tensor(XM.dual()))
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'
-+            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'...
- 
-         .. SEEALSO::
- 
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 86aca6e00d8..a5f6716e731 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15303,7 +15303,7 @@ cdef class Matrix(Matrix1):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
--            has no attribute 'conjugate'
-+            has no attribute 'conjugate'...
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/matrix/matrix_cyclo_dense.pyx b/src/sage/matrix/matrix_cyclo_dense.pyx
-index f54f3423ded..a49bb6240e6 100644
---- a/src/sage/matrix/matrix_cyclo_dense.pyx
-+++ b/src/sage/matrix/matrix_cyclo_dense.pyx
-@@ -847,7 +847,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense):
-             sage: A.set_mutable()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'
-+            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'...
-             sage: B = A.__copy__()
-             sage: B[0,0] = 20
-             sage: B[0,0]
-diff --git a/src/sage/matrix/matrix_gfpn_dense.pyx b/src/sage/matrix/matrix_gfpn_dense.pyx
-index 4cccf473de1..8e8e4d7336b 100644
---- a/src/sage/matrix/matrix_gfpn_dense.pyx
-+++ b/src/sage/matrix/matrix_gfpn_dense.pyx
-@@ -159,7 +159,7 @@ cdef class FieldConverter_class:
-             sage: C.field_to_fel('foo')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'to_integer'
-+            AttributeError: 'str' object has no attribute 'to_integer'...
-         """
-         return FfFromInt(x.to_integer())
- 
-diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py
-index 6aab58352be..b5e6f52349b 100644
---- a/src/sage/matrix/matrix_space.py
-+++ b/src/sage/matrix/matrix_space.py
-@@ -1619,7 +1619,7 @@ def __getitem__(self, x):
-             sage: MS[2]
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'
-+            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'...
-         """
-         if isinstance(x, (integer.Integer, int)):
-             return self.list()[x]
-diff --git a/src/sage/matroids/lean_matrix.pyx b/src/sage/matroids/lean_matrix.pyx
-index 54c68e637c0..a137cbf70e5 100644
---- a/src/sage/matroids/lean_matrix.pyx
-+++ b/src/sage/matroids/lean_matrix.pyx
-@@ -1,5 +1,4 @@
- # sage.doctest: optional - sage.rings.finite_rings
--# cython: profile=True
- """
- Lean matrices
- 
-diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx
-index 36f563aa433..318c82f2b64 100644
---- a/src/sage/matroids/linear_matroid.pyx
-+++ b/src/sage/matroids/linear_matroid.pyx
-@@ -1134,7 +1134,7 @@ cdef class LinearMatroid(BasisExchangeMatroid):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.matroids.basis_matroid.BasisMatroid' object
--            has no attribute 'base_ring'
-+            has no attribute 'base_ring'...
-             sage: from sage.matroids.advanced import *
-             sage: M4 = BinaryMatroid(Matrix(M1))
-             sage: M5 = LinearMatroid(reduced_matrix=Matrix(GF(2), [[-1, 0, 1],
-diff --git a/src/sage/misc/dev_tools.py b/src/sage/misc/dev_tools.py
-index e7bf176592c..3ece7db2894 100644
---- a/src/sage/misc/dev_tools.py
-+++ b/src/sage/misc/dev_tools.py
-@@ -171,6 +171,7 @@ def load_submodules(module=None, exclude_pattern=None):
-         load sage.geometry.polyhedron.ppl_lattice_polygon... succeeded
-     """
-     from .package_dir import walk_packages
-+    import importlib.util
- 
-     if module is None:
-         import sage
-@@ -194,8 +195,12 @@ def load_submodules(module=None, exclude_pattern=None):
-         try:
-             sys.stdout.write("load %s..." % module_name)
-             sys.stdout.flush()
--            loader = importer.find_module(module_name)
--            loader.load_module(module_name)
-+            # see
-+            # https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
-+            spec = importer.find_spec(module_name)
-+            module = importlib.util.module_from_spec(spec)
-+            sys.modules[module_name] = module
-+            spec.loader.exec_module(module)
-             sys.stdout.write(" succeeded\n")
-         except (ValueError, AttributeError, TypeError, ImportError):
-             # we might get error because of cython code that has been
-diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py
-index c922b8f6f12..03697f08b7c 100644
---- a/src/sage/misc/functional.py
-+++ b/src/sage/misc/functional.py
-@@ -86,7 +86,7 @@ def base_field(x):
-         sage: R.base_field()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'
-+        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'...
-     """
-     try:
-         return x.base_field()
-diff --git a/src/sage/misc/instancedoc.pyx b/src/sage/misc/instancedoc.pyx
-index d8e1e4ac536..44ee70f64ba 100644
---- a/src/sage/misc/instancedoc.pyx
-+++ b/src/sage/misc/instancedoc.pyx
-@@ -256,7 +256,7 @@ cdef class InstanceDocDescriptor:
-             sage: descr.__delete__(obj)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'X' object has no attribute '__doc__'
-+            AttributeError: 'X' object has no attribute '__doc__'...
- 
-             sage: descr.__delete__([])
-             Traceback (most recent call last):
-diff --git a/src/sage/misc/lazy_attribute.pyx b/src/sage/misc/lazy_attribute.pyx
-index bdbec3b3ba1..1f07870b8ec 100644
---- a/src/sage/misc/lazy_attribute.pyx
-+++ b/src/sage/misc/lazy_attribute.pyx
-@@ -441,37 +441,37 @@ class lazy_attribute(_lazy_attribute):
-             sage: B().unimplemented_A # todo: not implemented
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'super' object has no attribute 'unimplemented_A'
-+            AttributeError: 'super' object has no attribute 'unimplemented_A'...
- 
-     We now make some systematic checks::
- 
-         sage: B().unimplemented_A
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: B().unimplemented_B
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: B().unimplemented_AB
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: B().unimplemented_B_implemented_A
-         1
- 
-         sage: C().unimplemented_A()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: C().unimplemented_B()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: C().unimplemented_AB()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: C().unimplemented_B_implemented_A # todo: not implemented
-         1
-     """
-diff --git a/src/sage/misc/object_multiplexer.py b/src/sage/misc/object_multiplexer.py
-index d4e811ef16e..00fd89d6652 100644
---- a/src/sage/misc/object_multiplexer.py
-+++ b/src/sage/misc/object_multiplexer.py
-@@ -85,7 +85,7 @@ def __getattr__(self, name):
-             sage: m.__bork__
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Multiplex' has no attribute '__bork__'
-+            AttributeError: 'Multiplex' has no attribute '__bork__'...
-         """
-         if name.startswith("__"):
-             raise AttributeError("'Multiplex' has no attribute '%s'" % name)
-diff --git a/src/sage/misc/sage_input.py b/src/sage/misc/sage_input.py
-index 66e78ecccbc..00e8d96ee9e 100644
---- a/src/sage/misc/sage_input.py
-+++ b/src/sage/misc/sage_input.py
-@@ -3461,7 +3461,7 @@ def verify_same(a, b):
-         sage: verify_same(1, 1r)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_same(1r, 1)
-         Traceback (most recent call last):
-         ...
-@@ -3525,7 +3525,7 @@ def verify_si_answer(x, answer, preparse):
-         sage: verify_si_answer(1, '1', False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_si_answer(1, 'ZZ(1)', None)
-     """
-     from sage.misc.sage_eval import sage_eval
-diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py
-index f0545be7d81..811afc48755 100644
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -602,7 +602,7 @@ def visit_Num(self, node):
-             On Python 3 negative numbers are parsed first, for some reason, as
-             a UnaryOp node.
-         """
--        return node.n
-+        return node.value
- 
-     def visit_Str(self, node):
-         r"""
-@@ -624,7 +624,7 @@ def visit_Str(self, node):
-             sage: [vis(s) for s in ['"abstract"', "'syntax'", r'''r"tr\ee"''']]
-             ['abstract', 'syntax', 'tr\\ee']
-         """
--        return node.s
-+        return node.value
- 
-     def visit_List(self, node):
-         """
-diff --git a/src/sage/modules/fp_graded/steenrod/module.py b/src/sage/modules/fp_graded/steenrod/module.py
-index 18460b0e9a1..4acfa6b4002 100755
---- a/src/sage/modules/fp_graded/steenrod/module.py
-+++ b/src/sage/modules/fp_graded/steenrod/module.py
-@@ -70,7 +70,7 @@
-     sage: SteenrodFPModule(ZZ, [0])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'
-+    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'...
- 
- AUTHORS:
- 
-diff --git a/src/sage/monoids/trace_monoid.py b/src/sage/monoids/trace_monoid.py
-index 00baa4d14f8..f8176a1e1f2 100644
---- a/src/sage/monoids/trace_monoid.py
-+++ b/src/sage/monoids/trace_monoid.py
-@@ -40,7 +40,6 @@
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from collections import OrderedDict
- from itertools import repeat, chain, product
- 
- from sage.misc.cachefunc import cached_method
-@@ -633,14 +632,14 @@ def _compute_dependence_stack(self, x):
-             sage: x = b*a*d*a*c*b
-             sage: M._compute_dependence_stack(x)
-             ({a, b, c, d},
--             OrderedDict([(a, [False, False, True, True, False]),
--                          (b, [True, False, False, False, True]),
--                          (c, [True, False, False, False]),
--                          (d, [False, False, True, False])]))
-+             {a: [False, False, True, True, False],
-+              b: [True, False, False, False, True],
-+              c: [True, False, False, False],
-+              d: [False, False, True, False]})
-         """
-         independence = self._independence
-         generators_set = set(e for e, _ in x)
--        stacks = OrderedDict(sorted((g, []) for g in generators_set))
-+        stacks = dict(sorted((g, []) for g in generators_set))
-         for generator, times in reversed(list(x)):
-             stacks[generator].extend(repeat(True, times))
-             for other_gen in generators_set:
-diff --git a/src/sage/parallel/map_reduce.py b/src/sage/parallel/map_reduce.py
-index 11e0673ee91..5441943731d 100644
---- a/src/sage/parallel/map_reduce.py
-+++ b/src/sage/parallel/map_reduce.py
-@@ -1234,7 +1234,7 @@ def finish(self):
-             sage: S.print_communication_statistics()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'RESetMPExample' object has no attribute '_stats'
-+            AttributeError: 'RESetMPExample' object has no attribute '_stats'...
- 
-             sage: S.finish()
- 
-diff --git a/src/sage/plot/colors.py b/src/sage/plot/colors.py
-index 8c0db2b3c34..3281199400b 100644
---- a/src/sage/plot/colors.py
-+++ b/src/sage/plot/colors.py
-@@ -1099,7 +1099,7 @@ def __getattr__(self, name):
-             sage: cols.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ColorsDict' has no attribute or colormap punk
-+            AttributeError: 'ColorsDict' has no attribute or colormap punk...
-         """
-         try:
-             return self[name]
-@@ -1599,7 +1599,7 @@ def __getattr__(self, name):
-             sage: maps.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Colormaps' has no attribute or colormap punk
-+            AttributeError: 'Colormaps' has no attribute or colormap punk...
-             sage: maps['punk']
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/rings/asymptotic/asymptotic_ring.py b/src/sage/rings/asymptotic/asymptotic_ring.py
-index b07319382d3..994490e6616 100644
---- a/src/sage/rings/asymptotic/asymptotic_ring.py
-+++ b/src/sage/rings/asymptotic/asymptotic_ring.py
-@@ -1091,7 +1091,7 @@ def monomial_coefficient(self, monomial):
-             sage: O(n).monomial_coefficient(n)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'
-+            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'...
- 
-         The ``monomial`` must be exact::
- 
-diff --git a/src/sage/rings/asymptotic/growth_group.py b/src/sage/rings/asymptotic/growth_group.py
-index 27c14592bca..5be12537d62 100644
---- a/src/sage/rings/asymptotic/growth_group.py
-+++ b/src/sage/rings/asymptotic/growth_group.py
-@@ -1572,7 +1572,7 @@ def variable_names(self):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'GenericGrowthGroup_with_category.element_class' object
--            has no attribute 'is_one'
-+            has no attribute 'is_one'...
-         """
-         if self.is_one():
-             return tuple()
-diff --git a/src/sage/rings/ideal.py b/src/sage/rings/ideal.py
-index d36d9406f32..01c9fa3bf2d 100644
---- a/src/sage/rings/ideal.py
-+++ b/src/sage/rings/ideal.py
-@@ -1553,7 +1553,7 @@ def gcd(self, other):
-             sage: J.gcd(I)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Ideal_generic' object has no attribute 'gcd'
-+            AttributeError: 'Ideal_generic' object has no attribute 'gcd'...
- 
-         Note::
- 
-diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
-index 7fe89197011..8832d27e8ea 100644
---- a/src/sage/rings/number_field/number_field.py
-+++ b/src/sage/rings/number_field/number_field.py
-@@ -3823,7 +3823,7 @@ def primes_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
-         """
-         if degree is not None:
-             degree = ZZ(degree)
-@@ -3917,7 +3917,7 @@ def prime_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
- 
-         """
-         ids = self.primes_above(x, degree)
-@@ -5926,7 +5926,7 @@ def factor(self, n):
-             sage: L.factor(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'...
- 
-         AUTHORS:
- 
-@@ -12698,7 +12698,7 @@ def is_real_place(v):
-         sage: is_real_place(v_fin)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'
-+        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'...
- 
-     """
-     RR = sage.rings.real_mpfr.RealField(53)
-diff --git a/src/sage/rings/padics/generic_nodes.py b/src/sage/rings/padics/generic_nodes.py
-index 7047020edec..b6b514d4005 100644
---- a/src/sage/rings/padics/generic_nodes.py
-+++ b/src/sage/rings/padics/generic_nodes.py
-@@ -740,7 +740,7 @@ def _get_element_class(self, name=None):
-             sage: R._get_element_class("foobar")
-             Traceback (most recent call last):
-             ...
--            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'
-+            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'...
-         """
-         if name is None:
-             return self.Element
-diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx
-index c5a1129aecf..a5b7f937cfe 100644
---- a/src/sage/rings/polynomial/polynomial_element.pyx
-+++ b/src/sage/rings/polynomial/polynomial_element.pyx
-@@ -10793,7 +10793,7 @@ cdef class Polynomial(CommutativePolynomial):
-             sage: (y**2 + x).nth_root(2)
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... has no attribute 'nth_root'
-+            AttributeError: ... has no attribute 'nth_root'...
- 
-         TESTS::
- 
-@@ -11831,7 +11831,7 @@ cdef class Polynomial_generic_dense(Polynomial):
-             sage: int(1) // x  # check that this doesn't segfault
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'int' has no attribute 'base_ring'
-+            AttributeError: type object 'int' has no attribute 'base_ring'...
-         """
-         if have_same_parent(self, right):
-             return (<Polynomial_generic_dense>self)._floordiv_(<Polynomial_generic_dense>right)
-diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-index e372be888ee..aca4f08420f 100644
---- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
-+++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-@@ -2362,7 +2362,7 @@ def field_extension(self, names):
-             sage: F, g, h = S.field_extension('b')                                      # needs sage.rings.finite_rings
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'
-+            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'...
- 
-         Over a finite field, the corresponding field extension is not a
-         number field::
-diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx
-index 5273891a5b0..a6e999b8805 100644
---- a/src/sage/rings/ring.pyx
-+++ b/src/sage/rings/ring.pyx
-@@ -1734,7 +1734,7 @@ cdef class IntegralDomain(CommutativeRing):
-             sage: Z5.is_integrally_closed()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'
-+            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'...
-         """
-         raise NotImplementedError
- 
-diff --git a/src/sage/sat/solvers/satsolver.pyx b/src/sage/sat/solvers/satsolver.pyx
-index c2f41b18f55..1c4ac400cb6 100644
---- a/src/sage/sat/solvers/satsolver.pyx
-+++ b/src/sage/sat/solvers/satsolver.pyx
-@@ -375,10 +375,10 @@ def SAT(solver=None, *args, **kwds):
-         DIMACS Solver: 'kissat -q {input}'
-     """
-     if solver is None:
--        import pkgutil
--        if pkgutil.find_loader('pycryptosat') is not None:
-+        from importlib.util import find_spec
-+        if find_spec('pycryptosat') is not None:
-             solver = "cryptominisat"
--        elif pkgutil.find_loader('pycosat') is not None:
-+        elif find_spec('pycosat') is not None:
-             solver = "picosat"
-         else:
-             solver = "LP"
-diff --git a/src/sage/schemes/toric/morphism.py b/src/sage/schemes/toric/morphism.py
-index 1c8944b6dfc..5d64d632f97 100644
---- a/src/sage/schemes/toric/morphism.py
-+++ b/src/sage/schemes/toric/morphism.py
-@@ -246,7 +246,7 @@
-     Traceback (most recent call last):
-     ...
-     AttributeError: 'SchemeMorphism_fan_toric_variety' object
--    has no attribute 'fiber_generic'
-+    has no attribute 'fiber_generic'...
- 
- Let's use factorization mentioned above::
- 
-diff --git a/src/sage/sets/disjoint_union_enumerated_sets.py b/src/sage/sets/disjoint_union_enumerated_sets.py
-index 3dea567a779..5c5e08612f2 100644
---- a/src/sage/sets/disjoint_union_enumerated_sets.py
-+++ b/src/sage/sets/disjoint_union_enumerated_sets.py
-@@ -597,7 +597,7 @@ def Element(self):
-             sage: U.Element
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'
-+            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'...
-         """
-         if not self._facade:
-             return ElementWrapper
-diff --git a/src/sage/sets/set.py b/src/sage/sets/set.py
-index a1789c61300..112d3d8dc3b 100644
---- a/src/sage/sets/set.py
-+++ b/src/sage/sets/set.py
-@@ -163,7 +163,7 @@ def Set(X=None, category=None):
-         sage: sorted(B.list(), key=repr)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'Set_object_with_category' object has no attribute 'list'
-+        AttributeError: 'Set_object_with_category' object has no attribute 'list'...
-         sage: type(B)
-         <class 'sage.sets.set.Set_object_with_category'>
- 
-diff --git a/src/sage/structure/category_object.pyx b/src/sage/structure/category_object.pyx
-index b6a7eaecb5b..c06933494dc 100644
---- a/src/sage/structure/category_object.pyx
-+++ b/src/sage/structure/category_object.pyx
-@@ -836,7 +836,7 @@ cdef class CategoryObject(SageObject):
-             sage: Sets().example().sadfasdf
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'
-+            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'...
-         """
-         return self.getattr_from_category(name)
- 
-diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx
-index caae7e40ffc..543506e9a74 100644
---- a/src/sage/structure/element.pyx
-+++ b/src/sage/structure/element.pyx
-@@ -219,7 +219,7 @@ the parents::
-     sage: x._add_(x)
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-     sage: x + x
-     Traceback (most recent call last):
-     ...
-@@ -478,13 +478,13 @@ cdef class Element(SageObject):
-             sage: 1.blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'...
-             sage: Semigroups().example().an_element().is_idempotent
-             <bound method LeftZeroSemigroup.Element.is_idempotent of 42>
-             sage: Semigroups().example().an_element().blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'
-+            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'...
-         """
-         return self.getattr_from_category(name)
- 
-@@ -1269,7 +1269,7 @@ cdef class Element(SageObject):
-             sage: e._add_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-         """
-         try:
-             python_op = (<object>self)._add_
-@@ -1381,7 +1381,7 @@ cdef class Element(SageObject):
-             sage: e._sub_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'...
-         """
-         try:
-             python_op = (<object>self)._sub_
-@@ -1435,7 +1435,7 @@ cdef class Element(SageObject):
-             sage: e._neg_()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'...
-         """
-         try:
-             python_op = (<object>self)._neg_
-@@ -1549,7 +1549,7 @@ cdef class Element(SageObject):
-             sage: e._mul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'...
-         """
-         try:
-             python_op = (<object>self)._mul_
-@@ -1662,7 +1662,7 @@ cdef class Element(SageObject):
-             sage: e._matmul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'...
-         """
-         try:
-             python_op = (<object>self)._matmul_
-@@ -1765,7 +1765,7 @@ cdef class Element(SageObject):
-             sage: e._div_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'...
-         """
-         try:
-             python_op = (<object>self)._div_
-@@ -1865,7 +1865,7 @@ cdef class Element(SageObject):
-             sage: e._floordiv_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'...
-         """
-         try:
-             python_op = (<object>self)._floordiv_
-@@ -1965,7 +1965,7 @@ cdef class Element(SageObject):
-             sage: e._mod_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'...
-         """
-         try:
-             python_op = (<object>self)._mod_
-@@ -2092,7 +2092,7 @@ cdef class Element(SageObject):
-             sage: e._pow_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'...
-         """
-         try:
-             python_op = (<object>self)._pow_
-@@ -2122,7 +2122,7 @@ cdef class Element(SageObject):
-             sage: e._pow_int(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'...
-         """
-         try:
-             python_op = (<object>self)._pow_int
-@@ -2856,7 +2856,7 @@ cdef class RingElement(ModuleElement):
-             sage: m.is_nilpotent()                                                      # needs sage.modules
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... object has no attribute 'is_nilpotent'
-+            AttributeError: '...' object has no attribute 'is_nilpotent'...
-         """
-         if self.is_unit():
-             return False
-@@ -4671,7 +4671,7 @@ def coerce_binop(method):
-         sage: x.test_add(CC(2))
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'
-+        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'...
- 
-     TESTS:
- 
-diff --git a/src/sage/structure/sequence.py b/src/sage/structure/sequence.py
-index 0c700c1fb81..c3972532ac3 100644
---- a/src/sage/structure/sequence.py
-+++ b/src/sage/structure/sequence.py
-@@ -854,7 +854,7 @@ def __getattr__(self, name):
-             sage: S.universe()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'...
-             sage: S._Sequence__universe = 'foobar'
-             sage: S.universe()
-             'foobar'
-@@ -867,7 +867,7 @@ def __getattr__(self, name):
-             sage: hash(S)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'...
-             sage: S._Sequence__hash = int(34)
-             sage: hash(S)
-             34
-diff --git a/src/sage/symbolic/assumptions.py b/src/sage/symbolic/assumptions.py
-index 7dcb15f0d85..15f6fa07ce6 100644
---- a/src/sage/symbolic/assumptions.py
-+++ b/src/sage/symbolic/assumptions.py
-@@ -636,7 +636,7 @@ def assume(*args):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no
--        attribute 'assume'
-+        attribute 'assume'...
- 
-     Ensure that we can combine the two types of assumptions, as documented::
- 
-diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx
-index 0f251ac4e5c..66f624141b3 100644
---- a/src/sage/symbolic/expression.pyx
-+++ b/src/sage/symbolic/expression.pyx
-@@ -13712,7 +13712,7 @@ cdef get_dynamic_class_for_function(unsigned serial):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.symbolic.expression.Expression' object has no
--        attribute 'argp1'
-+        attribute 'argp1'...
-         sage: t = (e + 1).op[0]; t
-         tfunc(x)
-         sage: t
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index c4152e092e3..4bcf45e8793 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -67,6 +67,7 @@
- #include "archive.h"
- #include "tostring.h"
- #include "utils.h"
-+#include "../../cpython/pycore_long.h"
- 
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wdeprecated-register"
-@@ -706,18 +707,12 @@ static long _mpq_pythonhash(mpq_t the_rat)
- // Initialize an mpz_t from a Python long integer
- static void _mpz_set_pylong(mpz_t z, PyLongObject* l)
- {
--    Py_ssize_t pylong_size = Py_SIZE(l);
--    int sign = 1;
--
--    if (pylong_size < 0) {
--        pylong_size = -pylong_size;
--        sign = -1;
--    }
-+    Py_ssize_t pylong_size = _PyLong_DigitCount(l);
- 
-     mpz_import(z, pylong_size, -1, sizeof(digit), 0,
--               8*sizeof(digit) - PyLong_SHIFT, l->ob_digit);
-+               8*sizeof(digit) - PyLong_SHIFT, ob_digit(l));
- 
--    if (sign < 0)
-+    if (_PyLong_IsNegative(l))
-         mpz_neg(z, z);
- }
- 
-diff --git a/src/sage/symbolic/pynac_impl.pxi b/src/sage/symbolic/pynac_impl.pxi
-index 68c31dcfde7..7fd7c3b314b 100644
---- a/src/sage/symbolic/pynac_impl.pxi
-+++ b/src/sage/symbolic/pynac_impl.pxi
-@@ -619,7 +619,7 @@ def tolerant_is_symbol(a):
-         sage: None.is_symbol()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute 'is_symbol'
-+        AttributeError: 'NoneType' object has no attribute 'is_symbol'...
-     """
-     try:
-         return a.is_symbol()
diff --git a/srcpkgs/sagemath/patches/36506-notebook_7.patch b/srcpkgs/sagemath/patches/36506-notebook_7.patch
new file mode 100644
index 0000000000000..a7d93d52c1b4a
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36506-notebook_7.patch
@@ -0,0 +1,18 @@
+diff --git a/src/bin/sage-notebook b/src/bin/sage-notebook
+index 2e8b12e1a1c..801b0a6a6a3 100755
+--- a/src/bin/sage-notebook
++++ b/src/bin/sage-notebook
+@@ -29,7 +29,12 @@ class NotebookJupyter():
+     def __init__(self, argv):
+         self.print_banner()
+         try:
+-            from notebook.notebookapp import main
++            try:
++                # notebook 6
++                from notebook.notebookapp import main
++            except ImportError:
++                # notebook 7
++                from notebook.app import main
+         except ImportError:
+             import traceback
+             traceback.print_exc()
diff --git a/srcpkgs/sagemath/patches/36544-networkx_3.2.patch b/srcpkgs/sagemath/patches/36544-networkx_3.2.patch
new file mode 100644
index 0000000000000..efcc935ac5476
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36544-networkx_3.2.patch
@@ -0,0 +1,41 @@
+diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py
+index eedbc36bef3..3fdc241a1c4 100644
+--- a/src/sage/graphs/generic_graph.py
++++ b/src/sage/graphs/generic_graph.py
+@@ -5102,13 +5102,13 @@ def cycle_basis(self, output='vertex'):
+         A cycle basis in Petersen's Graph ::
+ 
+             sage: g = graphs.PetersenGraph()
+-            sage: g.cycle_basis()                                                       # needs networkx
++            sage: g.cycle_basis()                                                       # needs networkx, random (changes in networkx 3.2)
+             [[1, 6, 8, 5, 0], [4, 9, 6, 8, 5, 0], [7, 9, 6, 8, 5],
+              [4, 3, 8, 5, 0], [1, 2, 3, 8, 5, 0], [7, 2, 3, 8, 5]]
+ 
+         One can also get the result as a list of lists of edges::
+ 
+-            sage: g.cycle_basis(output='edge')                                          # needs networkx
++            sage: g.cycle_basis(output='edge')                                          # needs networkx, random (changes in networkx 3.2)
+             [[(1, 6, None), (6, 8, None), (8, 5, None), (5, 0, None),
+              (0, 1, None)], [(4, 9, None), (9, 6, None), (6, 8, None),
+              (8, 5, None), (5, 0, None), (0, 4, None)], [(7, 9, None),
+@@ -5273,9 +5273,9 @@ def minimum_cycle_basis(self, algorithm=None, weight_function=None, by_weight=Fa
+             [[1, 2, 3], [1, 2, 3, 4], [5, 6, 7]]
+             sage: sorted(g.minimum_cycle_basis(by_weight=False))
+             [[1, 2, 3], [1, 3, 4], [5, 6, 7]]
+-            sage: sorted(g.minimum_cycle_basis(by_weight=True, algorithm='NetworkX'))   # needs networkx
++            sage: sorted(g.minimum_cycle_basis(by_weight=True, algorithm='NetworkX'))   # needs networkx, random (changes in networkx 3.2)
+             [[1, 2, 3], [1, 2, 3, 4], [5, 6, 7]]
+-            sage: g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX')          # needs networkx
++            sage: g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX')          # needs networkx, random (changes in networkx 3.2)
+             [[1, 2, 3], [1, 3, 4], [5, 6, 7]]
+ 
+         ::
+@@ -5283,7 +5283,7 @@ def minimum_cycle_basis(self, algorithm=None, weight_function=None, by_weight=Fa
+             sage: g = Graph([(1, 2), (2, 3), (3, 4), (4, 5), (5, 1), (5, 3)])
+             sage: sorted(g.minimum_cycle_basis(by_weight=False))
+             [[1, 2, 3, 5], [3, 4, 5]]
+-            sage: sorted(g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX'))  # needs networkx
++            sage: sorted(g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX'))  # needs networkx, random (changes in networkx 3.2)
+             [[1, 2, 3, 5], [3, 4, 5]]
+ 
+         TESTS::
diff --git a/srcpkgs/sagemath/patches/get_patches b/srcpkgs/sagemath/patches/get_patches
index 95a6963432948..94992f4978f8c 100755
--- a/srcpkgs/sagemath/patches/get_patches
+++ b/srcpkgs/sagemath/patches/get_patches
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-version=10.1
+version=10.2.beta8
 
 URL_BASE_PR="https://github.com/sagemath/sage/pull/"
 URL_BASE_COMPARE="https://github.com/sagemath/sage/compare/${version}..."
@@ -20,24 +20,9 @@ get_pr() {
 # run from patches dir
 cd $(dirname "$0")
 
-# merged in 10.2.beta0
-#get_pr  36018   "singular 4.3.2p4" # included in #35934
-get_pr  36046   "fix memory leak"
-
-# merged in 10.2.beta1
-get_pr  35934   "singular 4.3.2p7"
-
-# merged in 10.2.beta2
-get_pr  36006   "gmp 6.3.0"
-
-# merged in 10.2.beta3
-get_pr  36235   "ecl 23.9.9"
-
-# merged in 10.2.beta4
-get_pr  36279   "matplotlib 3.8.0"
-
 # positive review
-#get_pr  36403   "python 3.12" # included in #36407
+get_pr  36506   "notebook 7"
 
 # needs review
-get_pr  36407   "python 3.12"
+get_pr  35848   "flintlib 3.0"
+get_pr  36544   "networkx 3.2"
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index a80d8b7187ece..eb0ad26438538 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,14 +1,14 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=10.1
-revision=4
+version=10.2.beta8
+revision=1
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
 _bindir=/usr/lib/sagemath/$version/bin
 make_install_args="--install-scripts=$_bindir"
-hostmakedepends="m4 pkg-config python3-Cython0.29 python3-Jinja2
+hostmakedepends="m4 pkg-config python3-Cython python3-Jinja2
  python3-pkgconfig python3-setuptools"
-makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
+makedepends="boost-devel brial-devel cliquer-devel ecl eclib-devel
  ecm-devel fflas-ffpack flintlib-devel gap-devel gd-devel giac-devel glpk-devel
  gsl-devel iml-devel lcalc-devel libbraiding-devel libhomfly-devel libmpc-devel
  libpng-devel linbox-devel m4ri-devel m4rie-devel mpfi-devel
@@ -18,7 +18,7 @@ makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
 depends="eclib-devel fflas-ffpack flintlib-devel gcc-fortran gd-devel
  gfan giac gsl-devel gzip libpng-devel linbox-devel m4ri-devel maxima-ecl
  mpfr-devel nauty ntl-devel palp pari-devel pari-elldata-small pari-galdata
- pari-galpol-small pari-seadata-small pkg-config python3-Cython0.29 python3-cypari2
+ pari-galpol-small pari-seadata-small pkg-config python3-Cython python3-cypari2
  python3-cysignals python3-devel python3-fpylll python3-ipython python3-lrcalc
  python3-ipython_ipykernel python3-jupyter_ipywidgets python3-matplotlib
  python3-memory_allocator python3-networkx python3-pip python3-pkgconfig
@@ -33,7 +33,7 @@ license="GPL-2.0-or-later"
 homepage="https://www.sagemath.org/"
 changelog="https://github.com/sagemath/sage/releases"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=a658612b1b2376ddaf207cc8ed0ef458d4c2880c16e19139bedbe8baa42ad62f
+checksum=3bb0d92f1deeadbe5108afb6e41d1c189c84898b063110507ec9f9c9a52d9ddb
 nocross="due to ntl (flintlib), fflas-ffpack, givaro, linbox, cysignals, sympow, maxima"
 
 post_patch() {

From 13c6450c75968a49170c72899f516f01b382b55e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Sun, 29 Oct 2023 21:15:17 -0300
Subject: [PATCH 7/7] sagemath: update to 10.2.beta9.

---
 .../sagemath/patches/35848-flintlib_3.0.patch |   4 +-
 .../sagemath/patches/36506-notebook_7.patch   |  18 --
 .../patches/36543-cython_warning.patch        |  49 ++++
 .../sagemath/patches/36551-fix_qf.nbs.patch   |  85 +++++++
 .../patches/36573-relative_imports.patch      | 210 ++++++++++++++++++
 .../patches/36600-giac_1.9.0-67.patch         |  52 +++++
 srcpkgs/sagemath/patches/get_patches          |   9 +-
 srcpkgs/sagemath/template                     |   4 +-
 8 files changed, 406 insertions(+), 25 deletions(-)
 delete mode 100644 srcpkgs/sagemath/patches/36506-notebook_7.patch
 create mode 100644 srcpkgs/sagemath/patches/36543-cython_warning.patch
 create mode 100644 srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
 create mode 100644 srcpkgs/sagemath/patches/36573-relative_imports.patch
 create mode 100644 srcpkgs/sagemath/patches/36600-giac_1.9.0-67.patch

diff --git a/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
index ed3d6d1913433..e812e0d842cca 100644
--- a/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
+++ b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
@@ -1555,7 +1555,7 @@ index 1b3f0ac412a..485c9c71be3 100644
 -            sage: K.<t> = PolynomialRing(GF(7))
 -            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
 -            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
--            sage: C.has_rational_point()
+-            sage: C.has_rational_point()                                                # needs sage.libs.singular
 -            Traceback (most recent call last):
 -            ...
 -            TypeError: self (=Scheme morphism:
@@ -1585,7 +1585,7 @@ index 1b3f0ac412a..485c9c71be3 100644
  
              sage: K.<t> = FractionField(PolynomialRing(QQ, 't'))
 @@ -250,6 +218,16 @@ def has_rational_point(self, point=False, algorithm='default',
-             sage: C.has_rational_point(point = True) # long time (4 seconds)
+             sage: C.has_rational_point(point=True)  # long time (4 seconds)             # needs sage.libs.singular
              (True,
               ((-2/117*t^8 + 304/1053*t^7 + 40/117*t^6 - 1/27*t^5 - 110/351*t^4 - 2/195*t^3 + 11/351*t^2 + 1/117)/(t^4 + 2/39*t^3 + 4/117*t^2 + 2/39*t + 14/39) : -5/3*t^4 + 19*t^3 : 1))
 +
diff --git a/srcpkgs/sagemath/patches/36506-notebook_7.patch b/srcpkgs/sagemath/patches/36506-notebook_7.patch
deleted file mode 100644
index a7d93d52c1b4a..0000000000000
--- a/srcpkgs/sagemath/patches/36506-notebook_7.patch
+++ /dev/null
@@ -1,18 +0,0 @@
-diff --git a/src/bin/sage-notebook b/src/bin/sage-notebook
-index 2e8b12e1a1c..801b0a6a6a3 100755
---- a/src/bin/sage-notebook
-+++ b/src/bin/sage-notebook
-@@ -29,7 +29,12 @@ class NotebookJupyter():
-     def __init__(self, argv):
-         self.print_banner()
-         try:
--            from notebook.notebookapp import main
-+            try:
-+                # notebook 6
-+                from notebook.notebookapp import main
-+            except ImportError:
-+                # notebook 7
-+                from notebook.app import main
-         except ImportError:
-             import traceback
-             traceback.print_exc()
diff --git a/srcpkgs/sagemath/patches/36543-cython_warning.patch b/srcpkgs/sagemath/patches/36543-cython_warning.patch
new file mode 100644
index 0000000000000..f0e3d4114342f
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36543-cython_warning.patch
@@ -0,0 +1,49 @@
+diff --git a/src/sage/cpython/dict_del_by_value.pyx b/src/sage/cpython/dict_del_by_value.pyx
+index 19dd2bb2731..fdeb5fee8ff 100644
+--- a/src/sage/cpython/dict_del_by_value.pyx
++++ b/src/sage/cpython/dict_del_by_value.pyx
+@@ -46,31 +46,6 @@ cdef extern from "dict_internal.h":
+         PyObject * me_key
+         PyObject * me_value
+ 
+-
+-# dk_lookup was removed in python 3.11
+-DEF HAS_DK_LOOKUP = PY_VERSION_HEX < 0x30b0000
+-
+-IF HAS_DK_LOOKUP:
+-
+-    cdef extern from *:
+-        """
+-        #define DK_LOOKUP(dk) ((dk)->dk_lookup)
+-        """
+-        ctypedef void * dict_lookup_func  # Precise definition not needed
+-        dict_lookup_func DK_LOOKUP(PyDictKeysObject *mp)
+-
+-    cdef dict_lookup_func lookdict
+-
+-    def init_lookdict():
+-        global lookdict
+-        # A dict which a non-string key uses the generic "lookdict"
+-        # as lookup function
+-        cdef object D = {}
+-        D[0] = 0
+-        lookdict = DK_LOOKUP((<PyDictObject *>D).ma_keys)
+-
+-    init_lookdict()
+-
+ cdef int del_dictitem_by_exact_value(PyDictObject *mp, PyObject *value, Py_hash_t hash) except -1:
+     """
+     This is used in callbacks for the weak values of :class:`WeakValueDictionary`.
+@@ -147,12 +122,6 @@ cdef int del_dictitem_by_exact_value(PyDictObject *mp, PyObject *value, Py_hash_
+             return 0
+         ep = &(entries[ix])
+ 
+-    # We need the lookup function to be the generic lookdict, otherwise
+-    # deletions may not work correctly
+-    IF HAS_DK_LOOKUP:
+-        # Can this fail? In any case dk_lookup was removed in python 3.11
+-        assert DK_LOOKUP(keys) is lookdict
+-
+     T = PyList_New(2)
+     PyList_SetItem(T, 0, ep.me_key)
+     PyList_SetItem(T, 1, ep.me_value)
diff --git a/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch b/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
new file mode 100644
index 0000000000000..537edea9bfafa
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
@@ -0,0 +1,85 @@
+diff --git a/src/sage/quadratic_forms/quadratic_form__neighbors.py b/src/sage/quadratic_forms/quadratic_form__neighbors.py
+index 94f6559d51a..9bf5e2d7de6 100644
+--- a/src/sage/quadratic_forms/quadratic_form__neighbors.py
++++ b/src/sage/quadratic_forms/quadratic_form__neighbors.py
+@@ -74,6 +74,10 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+         sage: v = Q.find_primitive_p_divisible_vector__next(5, v); v
+         (1, 0)
+         sage: v = Q.find_primitive_p_divisible_vector__next(5, v); v
++        sage: v = Q.find_primitive_p_divisible_vector__next(2) ; v
++        (0, 1)
++        sage: v = Q.find_primitive_p_divisible_vector__next(2, v) ; v
++        (1, 0)
+         sage: Q = QuadraticForm(QQ, matrix.diagonal([1,1,1,1]))
+         sage: v = Q.find_primitive_p_divisible_vector__next(2)
+         sage: Q(v)
+@@ -83,6 +87,9 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+     n = self.dim()
+     if v is None:
+         w = vector(ZZ, [0] * (n - 1) + [1])
++        a = self(w)
++        if a in ZZ and (a % p == 0):
++            return w
+     else:
+         w = deepcopy(v)
+ 
+@@ -132,7 +139,7 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+             return w
+ 
+ 
+-def find_p_neighbor_from_vec(self, p, y):
++def find_p_neighbor_from_vec(self, p, y, return_matrix=False):
+     r"""
+     Return the `p`-neighbor of ``self`` defined by ``y``.
+ 
+@@ -147,25 +154,32 @@ def find_p_neighbor_from_vec(self, p, y):
+     - ``p`` -- a prime number
+     - ``y`` -- a vector with `q(y) \in p \ZZ`
+     - ``odd`` -- (default: ``False``) if `p=2`, return also odd neighbors
++    - ``return_matrix`` -- (boolean, default ``False``) return
++      the transformation matrix instead of the quadratic form
+ 
+     EXAMPLES::
+ 
++        sage: # needs sage.libs.pari
+         sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1,1])
+         sage: v = vector([0,2,1,1])
+-        sage: X = Q.find_p_neighbor_from_vec(3, v); X                                   # needs sage.libs.pari
++        sage: X = Q.find_p_neighbor_from_vec(3, v); X
+         Quadratic form in 4 variables over Integer Ring with coefficients:
+         [ 1 0 0 0 ]
+         [ * 1 4 4 ]
+         [ * * 5 12 ]
+         [ * * * 9 ]
++        sage: B = Q.find_p_neighbor_from_vec(3, v, return_matrix=True)
++        sage: Q(B) == X
++        True
+ 
+     Since the base ring and the domain are not yet separate,
+     for rational, half integral forms we just pretend
+     the base ring is `\ZZ`::
+ 
++        sage: # needs sage.libs.pari
+         sage: Q = QuadraticForm(QQ, matrix.diagonal([1,1,1,1]))
+         sage: v = vector([1,1,1,1])
+-        sage: Q.find_p_neighbor_from_vec(2, v)                                          # needs sage.libs.pari
++        sage: Q.find_p_neighbor_from_vec(2, v)
+         Quadratic form in 4 variables over Rational Field with coefficients:
+         [ 1/2 1 1 1 ]
+         [ * 1 1 2 ]
+@@ -227,9 +241,12 @@ def find_p_neighbor_from_vec(self, p, y):
+     # by definition this is the p-neighbor of L at y
+     # assert B.det().abs() == 1
+ 
+-    QF = self.parent()
+-    Gnew = (B*G*B.T).change_ring(R)
+-    return QF(Gnew)
++    if return_matrix:
++        return B.T
++    else:
++        QF = self.parent()
++        Gnew = (B*G*B.T).change_ring(R)
++        return QF(Gnew)
+ 
+ 
+ def neighbor_iteration(seeds, p, mass=None, max_classes=ZZ(10)**3,
diff --git a/srcpkgs/sagemath/patches/36573-relative_imports.patch b/srcpkgs/sagemath/patches/36573-relative_imports.patch
new file mode 100644
index 0000000000000..77481909d9fac
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36573-relative_imports.patch
@@ -0,0 +1,210 @@
+diff --git a/src/sage/structure/all.py b/src/sage/structure/all.py
+index 311bf869ef2..df0114c8382 100644
+--- a/src/sage/structure/all.py
++++ b/src/sage/structure/all.py
+@@ -1,12 +1,12 @@
+-from .factorization import Factorization
++from sage.structure.factorization import Factorization
+ 
+-from .sequence import Sequence, seq
++from sage.structure.sequence import Sequence, seq
+ 
+-from .unique_representation import UniqueRepresentation
++from sage.structure.unique_representation import UniqueRepresentation
+ 
+-from .sage_object import SageObject
++from sage.structure.sage_object import SageObject
+ 
+-from .element import (
++from sage.structure.element import (
+     canonical_coercion,
+     coercion_model,
+     get_coercion_model,
+@@ -14,16 +14,16 @@
+     parent
+     )
+ 
+-from .parent import Parent
++from sage.structure.parent import Parent
+ 
+-from .parent_gens import localvars
++from sage.structure.parent_gens import localvars
+ 
+-from .proof import all as proof
++from sage.structure.proof import all as proof
+ 
+ from sage.misc.lazy_import import lazy_import
+ lazy_import('sage.structure.formal_sum', ['FormalSums', 'FormalSum'])
+ del lazy_import
+ 
+-from .mutability import Mutability
++from sage.structure.mutability import Mutability
+ 
+-from .element_wrapper import ElementWrapper
++from sage.structure.element_wrapper import ElementWrapper
+diff --git a/src/sage/structure/coerce.pxd b/src/sage/structure/coerce.pxd
+index e070d1c32e4..812cb5d5c7c 100644
+--- a/src/sage/structure/coerce.pxd
++++ b/src/sage/structure/coerce.pxd
+@@ -1,5 +1,5 @@
+-from .parent cimport Parent
+-from .coerce_dict cimport TripleDict
++from sage.structure.parent cimport Parent
++from sage.structure.coerce_dict cimport TripleDict
+ 
+ cpdef py_scalar_parent(py_type)
+ cpdef py_scalar_to_element(py)
+diff --git a/src/sage/structure/coerce.pyx b/src/sage/structure/coerce.pyx
+index d8c3f684217..8f98085ba8d 100644
+--- a/src/sage/structure/coerce.pyx
++++ b/src/sage/structure/coerce.pyx
+@@ -84,11 +84,11 @@ cimport gmpy2
+ cdef mul, truediv
+ from operator import mul, truediv
+ 
+-from .richcmp cimport rich_to_bool, revop
+-from .sage_object cimport SageObject
+-from .parent cimport Parent_richcmp_element_without_coercion
+-from .element cimport bin_op_exception, parent, Element
+-from .coerce_exceptions import CoercionException
++from sage.structure.richcmp cimport rich_to_bool, revop
++from sage.structure.sage_object cimport SageObject
++from sage.structure.parent cimport Parent_richcmp_element_without_coercion
++from sage.structure.element cimport bin_op_exception, parent, Element
++from sage.structure.coerce_exceptions import CoercionException
+ from sage.rings.integer_fake cimport is_Integer
+ from sage.categories.map cimport Map
+ from sage.categories.morphism import IdentityMorphism
+diff --git a/src/sage/structure/coerce_actions.pyx b/src/sage/structure/coerce_actions.pyx
+index 6df2aec6695..3c17ac858e6 100644
+--- a/src/sage/structure/coerce_actions.pyx
++++ b/src/sage/structure/coerce_actions.pyx
+@@ -18,10 +18,10 @@ from cpython.long cimport *
+ from cpython.number cimport *
+ from cysignals.signals cimport sig_check
+ 
+-from .coerce cimport coercion_model
+-from .element cimport parent, Element, ModuleElement
+-from .parent cimport Parent
+-from .coerce_exceptions import CoercionException
++from sage.structure.coerce cimport coercion_model
++from sage.structure.element cimport parent, Element, ModuleElement
++from sage.structure.parent cimport Parent
++from sage.structure.coerce_exceptions import CoercionException
+ from sage.categories.action cimport InverseAction, PrecomposedAction
+ from sage.arith.long cimport integer_check_long
+ 
+diff --git a/src/sage/structure/element.pxd b/src/sage/structure/element.pxd
+index 20c556b985e..6be65bb1f50 100644
+--- a/src/sage/structure/element.pxd
++++ b/src/sage/structure/element.pxd
+@@ -1,5 +1,5 @@
+-from .sage_object cimport SageObject
+-from .parent cimport Parent
++from sage.structure.sage_object cimport SageObject
++from sage.structure.parent cimport Parent
+ from sage.misc.inherit_comparison cimport InheritComparisonMetaclass
+ 
+ 
+diff --git a/src/sage/structure/factory.pyx b/src/sage/structure/factory.pyx
+index ddb55501d94..50d5374e79e 100644
+--- a/src/sage/structure/factory.pyx
++++ b/src/sage/structure/factory.pyx
+@@ -56,7 +56,7 @@ AUTHORS:
+ 
+ import types
+ 
+-from .sage_object cimport SageObject
++from sage.structure.sage_object cimport SageObject
+ 
+ cdef sage_version
+ from sage.version import version as sage_version
+diff --git a/src/sage/structure/parent.pyx b/src/sage/structure/parent.pyx
+index 6548d8a3656..d40caa03307 100644
+--- a/src/sage/structure/parent.pyx
++++ b/src/sage/structure/parent.pyx
+@@ -119,13 +119,13 @@ from sage.misc.lazy_attribute import lazy_attribute
+ from sage.categories.sets_cat import Sets, EmptySetError
+ from sage.misc.lazy_string cimport _LazyString
+ from sage.sets.pythonclass cimport Set_PythonType_class
+-from .category_object import CategoryObject
+-from .coerce cimport coercion_model
+-from .coerce cimport parent_is_integers
+-from .coerce_exceptions import CoercionException
+-from .coerce_maps cimport (NamedConvertMap, DefaultConvertMap,
++from sage.structure.category_object import CategoryObject
++from sage.structure.coerce cimport coercion_model
++from sage.structure.coerce cimport parent_is_integers
++from sage.structure.coerce_exceptions import CoercionException
++from sage.structure.coerce_maps cimport (NamedConvertMap, DefaultConvertMap,
+                            DefaultConvertMap_unique, CallableConvertMap)
+-from .element cimport parent
++from sage.structure.element cimport parent
+ 
+ 
+ cdef _record_exception():
+diff --git a/src/sage/structure/parent_base.pxd b/src/sage/structure/parent_base.pxd
+index 225fccabcae..8ffac64eff2 100644
+--- a/src/sage/structure/parent_base.pxd
++++ b/src/sage/structure/parent_base.pxd
+@@ -6,7 +6,7 @@
+ #                  https://www.gnu.org/licenses/
+ ###############################################################################
+ 
+-from .parent_old cimport Parent as Parent_old
++from sage.structure.parent_old cimport Parent as Parent_old
+ 
+ cdef class ParentWithBase(Parent_old):
+     pass
+diff --git a/src/sage/structure/parent_base.pyx b/src/sage/structure/parent_base.pyx
+index dd697f90135..b41175b5bff 100644
+--- a/src/sage/structure/parent_base.pyx
++++ b/src/sage/structure/parent_base.pyx
+@@ -12,7 +12,7 @@ Base class for old-style parent objects with a base ring
+ # ****************************************************************************
+ 
+ cimport sage.structure.parent as parent
+-from .coerce_exceptions import CoercionException
++from sage.structure.coerce_exceptions import CoercionException
+ 
+ cdef inline check_old_coerce(parent.Parent p):
+     if p._element_constructor is not None:
+diff --git a/src/sage/structure/parent_gens.pxd b/src/sage/structure/parent_gens.pxd
+index 6ec0e6e83f0..cf3b416317f 100644
+--- a/src/sage/structure/parent_gens.pxd
++++ b/src/sage/structure/parent_gens.pxd
+@@ -12,7 +12,7 @@ Parent objects with generators
+ #                  http://www.gnu.org/licenses/
+ #*****************************************************************************
+ 
+-from .parent_base cimport ParentWithBase
++from sage.structure.parent_base cimport ParentWithBase
+ 
+ 
+ cdef class ParentWithGens(ParentWithBase):
+diff --git a/src/sage/structure/parent_old.pyx b/src/sage/structure/parent_old.pyx
+index 77a7888d3b8..82bf9ead04b 100644
+--- a/src/sage/structure/parent_old.pyx
++++ b/src/sage/structure/parent_old.pyx
+@@ -27,7 +27,7 @@ This came up in some subtle bug once::
+ #                  https://www.gnu.org/licenses/
+ # ****************************************************************************
+ from sage.misc.superseded import deprecation
+-from .coerce cimport py_scalar_parent
++from sage.structure.coerce cimport py_scalar_parent
+ from sage.ext.stdsage cimport HAS_DICTIONARY
+ from sage.sets.pythonclass cimport Set_PythonType, Set_PythonType_class
+ 
+diff --git a/src/sage/structure/sage_object_test.py b/src/sage/structure/sage_object_test.py
+index 0922545a62c..721c1ad7719 100644
+--- a/src/sage/structure/sage_object_test.py
++++ b/src/sage/structure/sage_object_test.py
+@@ -1,6 +1,7 @@
+ 
+ import pytest
+-from .sage_object import SageObject
++from sage.structure.sage_object import SageObject
++
+ 
+ class SageObjectTests:
+ 
diff --git a/srcpkgs/sagemath/patches/36600-giac_1.9.0-67.patch b/srcpkgs/sagemath/patches/36600-giac_1.9.0-67.patch
new file mode 100644
index 0000000000000..a1ad357828a56
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36600-giac_1.9.0-67.patch
@@ -0,0 +1,52 @@
+diff --git a/src/sage/libs/giac/__init__.py b/src/sage/libs/giac/__init__.py
+index 558cd894b13..e7d7bc67d14 100644
+--- a/src/sage/libs/giac/__init__.py
++++ b/src/sage/libs/giac/__init__.py
+@@ -172,9 +172,9 @@ def groebner_basis(gens, proba_epsilon=None, threads=None, prot=False,
+         sage: from sage.libs.giac import groebner_basis as gb_giac
+         sage: P = PolynomialRing(GF(previous_prime(2**31)), 6, 'x')
+         sage: I = sage.rings.ideal.Cyclic(P)
+-        sage: B=gb_giac(I.gens());B
+-        <BLANKLINE>
+-        // Groebner basis computation time ...
++        sage: B = gb_giac(I.gens())
++        ...
++        sage: B
+         Polynomial Sequence with 45 Polynomials in 6 Variables
+         sage: B.is_groebner()
+         True
+@@ -184,8 +184,7 @@ def groebner_basis(gens, proba_epsilon=None, threads=None, prot=False,
+         sage: P = PolynomialRing(GF(previous_prime(2**31)), 5, 'x')
+         sage: I = sage.rings.ideal.Cyclic(P)
+         sage: B = gb_giac(I.gens(), elim_variables=[P.gen(0), P.gen(2)])
+-        <BLANKLINE>
+-        // Groebner basis computation time ...
++        ...
+         sage: B.is_groebner()
+         True
+         sage: B.ideal() == I.elimination_ideal([P.gen(0), P.gen(2)])
+@@ -201,11 +200,10 @@ def groebner_basis(gens, proba_epsilon=None, threads=None, prot=False,
+         ...
+         sage: sage.structure.proof.all.polynomial(True)
+         sage: B2 = gb_giac(I.gens()) # long time (4s)
+-        <BLANKLINE>
+-        // Groebner basis computation time...
++        ...
+         sage: B1 == B2 # long time
+         True
+-        sage: B1.is_groebner() # long time (20s)
++        sage: B1.is_groebner() # not tested, too long time (50s)
+         True
+ 
+     * multi threaded operations::
+@@ -253,9 +251,7 @@ def groebner_basis(gens, proba_epsilon=None, threads=None, prot=False,
+         sage: libgiac.purge('x2'),libgiac.purge('x4')
+         (22, whywouldyoudothis)
+         sage: gb_giac(I) # long time (3s)
+-        <BLANKLINE>
+-        // Groebner basis computation time...
+-        Polynomial Sequence with 74 Polynomials in 8 Variables
++        ...Polynomial Sequence with 74 Polynomials in 8 Variables
+ 
+         sage: I = ideal(P(0),P(0))
+         sage: I.groebner_basis() == gb_giac(I)
diff --git a/srcpkgs/sagemath/patches/get_patches b/srcpkgs/sagemath/patches/get_patches
index 94992f4978f8c..ea4d23c49f3ed 100755
--- a/srcpkgs/sagemath/patches/get_patches
+++ b/srcpkgs/sagemath/patches/get_patches
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-version=10.2.beta8
+version=10.2.beta9
 
 URL_BASE_PR="https://github.com/sagemath/sage/pull/"
 URL_BASE_COMPARE="https://github.com/sagemath/sage/compare/${version}..."
@@ -21,8 +21,11 @@ get_pr() {
 cd $(dirname "$0")
 
 # positive review
-get_pr  36506   "notebook 7"
+get_pr  36544   "networkx 3.2"
 
 # needs review
 get_pr  35848   "flintlib 3.0"
-get_pr  36544   "networkx 3.2"
+get_pr  36543   "cython warning"
+get_pr  36551   "fix qf.nbs"
+get_pr  36573   "relative imports"
+get_pr  36600   "giac 1.9.0-67"
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index eb0ad26438538..75f39fe5b0374 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,6 +1,6 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=10.2.beta8
+version=10.2.beta9
 revision=1
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
@@ -33,7 +33,7 @@ license="GPL-2.0-or-later"
 homepage="https://www.sagemath.org/"
 changelog="https://github.com/sagemath/sage/releases"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=3bb0d92f1deeadbe5108afb6e41d1c189c84898b063110507ec9f9c9a52d9ddb
+checksum=e6899566ca0c7c45984738aaf3378930d0f1746381daab8f61fb2e4b78af7394
 nocross="due to ntl (flintlib), fflas-ffpack, givaro, linbox, cysignals, sympow, maxima"
 
 post_patch() {

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

* Re: [PR PATCH] [Updated] [WIP] flintlib: update to 3.0.0 / track sagemath-10.2 prereleases
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (4 preceding siblings ...)
  2023-10-31  1:43 ` [PR PATCH] [Updated] [WIP] flintlib: update to 3.0.0 / track sagemath-10.2 prereleases tornaria
@ 2023-11-07  2:21 ` tornaria
  2023-11-10 23:49 ` [PR PATCH] [Updated] [RC] sagemath: update to 10.2, flintlib: update to 3.0.1 tornaria
                   ` (22 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: tornaria @ 2023-11-07  2:21 UTC (permalink / raw)
  To: ml

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

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

https://github.com/tornaria/void-packages flintlib
https://github.com/void-linux/void-packages/pull/46832

[WIP] flintlib: update to 3.0.0 / track sagemath-10.2 prereleases
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **briefly**

This is a major update. A couple of packages need rebuilding (eclib, singular).

For sagemath, we need a patch (in progress: https://github.com/sagemath/sage/pull/35848).

Since backporting patches is a pain and we are not in a hurry, I'm instead targeting 10.2.beta8. Note this already moves sagemath to cython 3.

The goal is to merge flintlib 3.0 together with sagemath 10.2 when the latter is released.

<!--
#### 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/46832.patch is attached

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

From bbf2bb877589c34836d363ef70d132d283c6b83d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 11 Sep 2023 20:11:20 -0300
Subject: [PATCH 1/8] flintlib: update to 3.0.0.

---
 common/shlibs                                 |  3 +-
 srcpkgs/arb                                   |  1 +
 srcpkgs/arb-devel                             |  2 +-
 srcpkgs/arb/template                          | 24 ------------
 .../patches/1545-fix_openblas_detection.patch | 32 ++++++++++++++++
 ...6723b1d74e66605c111483756322ebb1bc8d.patch | 37 +++++++++++++++++++
 .../patches/fix-test-t-sdiv_qrnnd.patch       | 23 ------------
 srcpkgs/flintlib/template                     | 27 ++++++++++++--
 8 files changed, 95 insertions(+), 54 deletions(-)
 create mode 120000 srcpkgs/arb
 delete mode 100644 srcpkgs/arb/template
 create mode 100644 srcpkgs/flintlib/patches/1545-fix_openblas_detection.patch
 create mode 100644 srcpkgs/flintlib/patches/1546-fix_nmod32_in_i686-7d046723b1d74e66605c111483756322ebb1bc8d.patch
 delete mode 100644 srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch

diff --git a/common/shlibs b/common/shlibs
index 9036a675c1ae5..cc76d4e8cfafd 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3974,8 +3974,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.17 flintlib-2.9.0_1
-libarb.so.2 arb-2.20.0_1
+libflint.so.18 flintlib-3.0.0_1
 libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
diff --git a/srcpkgs/arb b/srcpkgs/arb
new file mode 120000
index 0000000000000..7c2633183069f
--- /dev/null
+++ b/srcpkgs/arb
@@ -0,0 +1 @@
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb-devel b/srcpkgs/arb-devel
index 456b9f00a86cd..7c2633183069f 120000
--- a/srcpkgs/arb-devel
+++ b/srcpkgs/arb-devel
@@ -1 +1 @@
-arb
\ No newline at end of file
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
deleted file mode 100644
index 84a62c7ffdba3..0000000000000
--- a/srcpkgs/arb/template
+++ /dev/null
@@ -1,24 +0,0 @@
-# Template file for 'arb'
-pkgname=arb
-version=2.23.0
-revision=1
-build_style=configure
-configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
-makedepends="flintlib-devel"
-short_desc="C library for arbitrary-precision interval arithmetic"
-maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
-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=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
-
-arb-devel_package() {
-	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"
-	short_desc+=" - development files"
-	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.a"
-		vmove "usr/lib/*.so"
-	}
-}
diff --git a/srcpkgs/flintlib/patches/1545-fix_openblas_detection.patch b/srcpkgs/flintlib/patches/1545-fix_openblas_detection.patch
new file mode 100644
index 0000000000000..133e93eb07341
--- /dev/null
+++ b/srcpkgs/flintlib/patches/1545-fix_openblas_detection.patch
@@ -0,0 +1,32 @@
+From d818f171ec1907d815bbf7ccbb80968ca5a024ec Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Fri, 20 Oct 2023 18:56:58 -0300
+Subject: [PATCH] Fix use of AC_SEARCH_LIBS to find cblas_dgemm
+
+Without this change, configure only tries with `-lcblas` since
+`AC_SEARCH_LIBS` caches the result based on function name.
+---
+ configure.ac | 8 ++------
+ 1 file changed, 2 insertions(+), 6 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 84ba9de832..676e5ff886 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -705,14 +705,10 @@ fi
+ 
+ if test "$with_blas" = "yes";
+ then
+-    AC_SEARCH_LIBS([cblas_dgemm],[cblas],[],
+-        [AC_SEARCH_LIBS([cblas_dgemm],[openblas],[],
+-            [AC_SEARCH_LIBS([cblas_dgemm],[blas],[],
+-                [AC_MSG_ERROR([BLAS library was not found.  If you indeed have BLAS installed, please
++    AC_SEARCH_LIBS([cblas_dgemm],[cblas openblas blas],[],
++        [AC_MSG_ERROR([BLAS library was not found.  If you indeed have BLAS installed, please
+ submit a bug report to <https://github.com/flintlib/flint/issues/> so
+ that we can either fix the issue or give a more proper error message.])]
+-            )]
+-        )]
+     )
+ fi
+ 
diff --git a/srcpkgs/flintlib/patches/1546-fix_nmod32_in_i686-7d046723b1d74e66605c111483756322ebb1bc8d.patch b/srcpkgs/flintlib/patches/1546-fix_nmod32_in_i686-7d046723b1d74e66605c111483756322ebb1bc8d.patch
new file mode 100644
index 0000000000000..f98882112f3f8
--- /dev/null
+++ b/srcpkgs/flintlib/patches/1546-fix_nmod32_in_i686-7d046723b1d74e66605c111483756322ebb1bc8d.patch
@@ -0,0 +1,37 @@
+From 7d046723b1d74e66605c111483756322ebb1bc8d Mon Sep 17 00:00:00 2001
+From: Fredrik Johansson <fredrik.johansson@gmail.com>
+Date: Sat, 21 Oct 2023 13:43:37 +0200
+Subject: [PATCH] fix nmod32 on 32-bit systems
+
+---
+ src/gr/nmod32.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/src/gr/nmod32.c b/src/gr/nmod32.c
+index fde79822ac..31ee4e0184 100644
+--- a/src/gr/nmod32.c
++++ b/src/gr/nmod32.c
+@@ -325,7 +325,11 @@ _nmod32_vec_add(nmod32_struct * res, const nmod32_struct * vec1, const nmod32_st
+     nmod_t mod = NMOD32_CTX(ctx);
+ 
+     for (i = 0; i < len; i++)
++#if FLINT_BITS == 64
+         res[i] = _nmod_add(vec1[i], vec2[i], mod);
++#else
++        res[i] = nmod_add(vec1[i], vec2[i], mod);
++#endif
+ 
+     return GR_SUCCESS;
+ }
+@@ -337,7 +341,11 @@ _nmod32_vec_sub(nmod32_struct * res, const nmod32_struct * vec1, const nmod32_st
+     nmod_t mod = NMOD32_CTX(ctx);
+ 
+     for (i = 0; i < len; i++)
++#if FLINT_BITS == 64
++        res[i] = _nmod_sub(vec1[i], vec2[i], mod);
++#else
+         res[i] = nmod_sub(vec1[i], vec2[i], mod);
++#endif
+ 
+     return GR_SUCCESS;
+ }
diff --git a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch b/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
deleted file mode 100644
index cfa109792892c..0000000000000
--- a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From fb8ddbcc06afa2a8f25637032fbb8211f6c6c122 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= <albin.ahlback@gmail.com>
-Date: Fri, 20 May 2022 14:16:38 +0200
-Subject: [PATCH] Fix bug in test code for GCC 12
-
----
- test/t-sdiv_qrnnd.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/test/t-sdiv_qrnnd.c b/test/t-sdiv_qrnnd.c
-index 2e9822e848..2676903826 100644
---- a/test/t-sdiv_qrnnd.c
-+++ b/test/t-sdiv_qrnnd.c
-@@ -33,7 +33,7 @@ int main(void)
-         {
-             d = n_randtest_not_zero(state);
-             nh = n_randtest(state);
--        } while ((FLINT_ABS(nh) >= FLINT_ABS(d)/2) || (nh == WORD_MIN));
-+        } while ((nh == WORD_MIN) || (FLINT_ABS(nh) >= FLINT_ABS(d)/2));
- 
-         nl = n_randtest(state);
- 
-
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index f7442c8052aaa..9d143ab889f66 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,10 +1,11 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.9.0
+version=3.0.0
 revision=1
-build_style=configure
+build_style=gnu-configure
 configure_args="--prefix=/usr $(vopt_with ntl)
- $(vopt_if openblas --with-blas=${XBPS_CROSS_BASE}/usr/include/openblas)"
+ $(vopt_if openblas --with-blas-include=${XBPS_CROSS_BASE}/usr/include/openblas)"
+hostmakedepends="automake gettext-devel libtool"
 makedepends="mpfr-devel $(vopt_if ntl ntl-devel)
  $(vopt_if openblas openblas-devel)"
 short_desc="Fast Library for Number Theory"
@@ -13,7 +14,7 @@ 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=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
+checksum=b9086e31e3dab89896d7edbf05a5b758d5b4b72183a1a3478f23eabdcaaae044
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
@@ -28,12 +29,30 @@ esac
 
 CFLAGS="-D_GNU_SOURCE" # needed for cpu_set_t
 
+post_patch() {
+	# run autoconf because we patched configure.ac
+	autoreconf
+}
+
 flintlib-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision} mpfr-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
+		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
 		vmove "usr/lib/*.so"
 	}
 }
+
+arb_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}
+
+arb-devel_package() {
+	depends="${sourcepkg}-devel>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From fdc98b0a33e8d70d61242f1bf1f823c76eeb38a4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:08:05 -0300
Subject: [PATCH 2/8] eclib: rebuild for flintlib-3.0.0

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

diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 1d4ad58f21b7b..12165ca788dd5 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
 version=20230424
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 makedepends="pari-devel ntl-devel flintlib-devel boost-devel"

From fec08336f27c6ca782176a32eaab28f59156ce44 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:13:15 -0300
Subject: [PATCH 3/8] singular: update to 4.3.2p10.

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

diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index 036e19d470354..beb0e6d30118e 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,6 +1,6 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.2p7
+version=4.3.2p10
 revision=1
 _majver=${version%p*}
 build_style=gnu-configure
@@ -20,7 +20,7 @@ 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/${_majver//./-}/singular-${version}.tar.gz"
-checksum=aad23c30066b7fbc011138a98d60532565d76a847eec6bf2938410d93b272ca3
+checksum=28c2c9fcfee954e00dfa56eb1a7d418d5b1de67c4398d25a0f2b8f73e71552a8
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From ccd038487a8cdbef082ef7846a456f5dc91ec969 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 19 Jul 2023 21:04:33 -0300
Subject: [PATCH 4/8] python3-pplpy: use cython 3.

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

diff --git a/srcpkgs/python3-pplpy/template b/srcpkgs/python3-pplpy/template
index 4a9c987b2a859..d3b9aebdf2237 100644
--- a/srcpkgs/python3-pplpy/template
+++ b/srcpkgs/python3-pplpy/template
@@ -1,9 +1,9 @@
 # Template file for 'python3-pplpy'
 pkgname=python3-pplpy
 version=0.8.9
-revision=1
+revision=2
 build_style=python3-pep517
-hostmakedepends="python3-setuptools python3-wheel python3-Cython0.29
+hostmakedepends="python3-setuptools python3-wheel python3-Cython
  python3-cysignals python3-gmpy2"
 makedepends="python3-devel gmp-devel gmpxx-devel ppl-devel mpfr-devel
  libmpc-devel pari-devel"

From 8d3d32fbe5c79bbb60a1874933260fa8554e4576 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Thu, 19 Oct 2023 08:52:15 -0300
Subject: [PATCH 5/8] python3-networkx: update to 3.2.1.

---
 srcpkgs/python3-networkx/template | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/python3-networkx/template b/srcpkgs/python3-networkx/template
index 186bf64f7bff9..29283d9e5a032 100644
--- a/srcpkgs/python3-networkx/template
+++ b/srcpkgs/python3-networkx/template
@@ -1,11 +1,11 @@
 # Template file for 'python3-networkx'
 pkgname=python3-networkx
-version=3.1
-revision=2
-build_style=python3-module
+version=3.2.1
+revision=1
+build_style=python3-pep517
 # failing in i686
 make_check_args="--deselect networkx/algorithms/approximation/tests/test_traveling_salesman.py::test_asadpour_tsp"
-hostmakedepends="python3-setuptools"
+hostmakedepends="python3-setuptools python3-wheel"
 depends="python3"
 checkdepends="python3-numpy python3-scipy python3-matplotlib python3-pandas
  python3-lxml python3-sympy python3-pytest-xdist"
@@ -15,7 +15,7 @@ license="BSD-3-Clause"
 homepage="https://networkx.org"
 changelog="https://github.com/networkx/networkx/raw/main/doc/release/release_${version}.rst"
 distfiles="${PYPI_SITE}/n/networkx/networkx-${version}.tar.gz"
-checksum=de346335408f84de0eada6ff9fafafff9bcda11f0a0dfaa931133debb146ab61
+checksum=9f1bb5cf3409bf324e0a722c20bdb4c20ee39bf1c30ce8ae499c8502b0b5e0c6
 
 post_install() {
 	vlicense LICENSE.txt

From 6138b1cf60e5f42609810683e9027860e500a60a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:50:44 -0300
Subject: [PATCH 6/8] sagemath: update to 10.2.beta8 (patch for
 flintlib-3.0.0).

---
 .../sagemath/patches/35848-flintlib_3.0.patch | 1738 ++++++++++++++++
 .../patches/35934-singular_4.3.2p7.patch      |  221 ---
 .../sagemath/patches/36006-gmp_6.3.0.patch    |   38 -
 .../patches/36046-fix_memory_leak.patch       |  740 -------
 .../sagemath/patches/36235-ecl_23.9.9.patch   |   39 -
 .../patches/36279-matplotlib_3.8.0.patch      |   24 -
 srcpkgs/sagemath/patches/36403-00pre.patch    |   29 -
 .../sagemath/patches/36407-python_3.12.patch  | 1744 -----------------
 .../sagemath/patches/36506-notebook_7.patch   |   18 +
 .../sagemath/patches/36544-networkx_3.2.patch |   41 +
 srcpkgs/sagemath/patches/get_patches          |   23 +-
 srcpkgs/sagemath/template                     |   12 +-
 12 files changed, 1807 insertions(+), 2860 deletions(-)
 create mode 100644 srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
 delete mode 100644 srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
 delete mode 100644 srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
 delete mode 100644 srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36403-00pre.patch
 delete mode 100644 srcpkgs/sagemath/patches/36407-python_3.12.patch
 create mode 100644 srcpkgs/sagemath/patches/36506-notebook_7.patch
 create mode 100644 srcpkgs/sagemath/patches/36544-networkx_3.2.patch

diff --git a/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
new file mode 100644
index 0000000000000..ed3d6d1913433
--- /dev/null
+++ b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
@@ -0,0 +1,1738 @@
+diff --git a/build/pkgs/antic/SPKG.rst b/build/pkgs/antic/SPKG.rst
+deleted file mode 100644
+index d6c32377957..00000000000
+--- a/build/pkgs/antic/SPKG.rst
++++ /dev/null
+@@ -1,18 +0,0 @@
+-antic: Algebraic Number Theory In C
+-===================================
+-
+-Description
+------------
+-
+-Algebraic Number Theory In C
+-
+-License
+--------
+-
+-LGPL 2.1
+-
+-Upstream Contact
+-----------------
+-
+-https://github.com/wbhart/antic
+-
+diff --git a/build/pkgs/antic/checksums.ini b/build/pkgs/antic/checksums.ini
+deleted file mode 100644
+index fc8711ecd13..00000000000
+--- a/build/pkgs/antic/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=antic-VERSION.tar.gz
+-sha1=940d8ea2c3512b9d49ee3101cf043f777764bd8f
+-md5=4e896420dd6344b53b307871efb2cbb4
+-cksum=1938565125
+-upstream_url=https://github.com/wbhart/antic/archive/refs/tags/vVERSION.tar.gz
+diff --git a/build/pkgs/antic/dependencies b/build/pkgs/antic/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/antic/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/antic/distros/arch.txt b/build/pkgs/antic/distros/arch.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/conda.txt b/build/pkgs/antic/distros/conda.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/debian.txt b/build/pkgs/antic/distros/debian.txt
+deleted file mode 100644
+index 8fdcd3e5721..00000000000
+--- a/build/pkgs/antic/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libantic-dev
+diff --git a/build/pkgs/antic/distros/fedora.txt b/build/pkgs/antic/distros/fedora.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/freebsd.txt b/build/pkgs/antic/distros/freebsd.txt
+deleted file mode 100644
+index 116ff3a26f3..00000000000
+--- a/build/pkgs/antic/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/antic
+diff --git a/build/pkgs/antic/distros/opensuse.txt b/build/pkgs/antic/distros/opensuse.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/repology.txt b/build/pkgs/antic/distros/repology.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/package-version.txt b/build/pkgs/antic/package-version.txt
+deleted file mode 100644
+index 3a4036fb450..00000000000
+--- a/build/pkgs/antic/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-0.2.5
+diff --git a/build/pkgs/antic/spkg-install.in b/build/pkgs/antic/spkg-install.in
+deleted file mode 100644
+index c57fa884a20..00000000000
+--- a/build/pkgs/antic/spkg-install.in
++++ /dev/null
+@@ -1,19 +0,0 @@
+-cd src
+-
+-# Copied from build/pkgs/flint/spkg-install.in:
+-#   Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-#   --with-ntl because otherwise FLINT's configure script uses
+-#   /usr/local, which is always wrong.
+-#   This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-#   The value $SAGE_LOCAL is always a safe choice even if the library
+-#   is coming from the system and is found using what is in
+-#   LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-flint="$SAGE_LOCAL"  || sdh_die "Error: Failed to configure antic."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/antic/type b/build/pkgs/antic/type
+deleted file mode 100644
+index 134d9bc32d5..00000000000
+--- a/build/pkgs/antic/type
++++ /dev/null
+@@ -1 +0,0 @@
+-optional
+diff --git a/build/pkgs/arb/SPKG.rst b/build/pkgs/arb/SPKG.rst
+deleted file mode 100644
+index cff49ddb95b..00000000000
+--- a/build/pkgs/arb/SPKG.rst
++++ /dev/null
+@@ -1,27 +0,0 @@
+-arb: Arbitrary-precision floating-point ball arithmetic
+-=======================================================
+-
+-Description
+------------
+-
+-Arb is a C library for arbitrary-precision floating-point ball
+-arithmetic, developed by Fredrik Johansson
+-(fredrik.johansson@gmail.com). It supports efficient high-precision
+-computation with polynomials, power series, matrices and special
+-functions over the real and complex numbers, with automatic, rigorous
+-error control.
+-
+-License
+--------
+-
+-GNU General Public License v2+
+-
+-
+-Upstream Contact
+-----------------
+-
+- - Fredrik Johansson: fredrik.johansson@gmail.com
+-
+- - https://arblib.org/
+-
+- - http://github.com/fredrik-johansson/arb/
+diff --git a/build/pkgs/arb/checksums.ini b/build/pkgs/arb/checksums.ini
+deleted file mode 100644
+index 80ef43dad5d..00000000000
+--- a/build/pkgs/arb/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=arb-VERSION.tar.gz
+-sha1=a1efe035dd3af3613dd685971a156f652b86ff63
+-md5=9b369e29f93cdf2d4f90b57a92526cce
+-cksum=64252121
+-upstream_url=https://github.com/fredrik-johansson/arb/archive/VERSION.tar.gz
+diff --git a/build/pkgs/arb/dependencies b/build/pkgs/arb/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/arb/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/arb/distros/arch.txt b/build/pkgs/arb/distros/arch.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/conda.txt b/build/pkgs/arb/distros/conda.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/debian.txt b/build/pkgs/arb/distros/debian.txt
+deleted file mode 100644
+index 9fe71110712..00000000000
+--- a/build/pkgs/arb/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libflint-arb-dev
+diff --git a/build/pkgs/arb/distros/fedora.txt b/build/pkgs/arb/distros/fedora.txt
+deleted file mode 100644
+index 76794404627..00000000000
+--- a/build/pkgs/arb/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb arb-devel
+diff --git a/build/pkgs/arb/distros/freebsd.txt b/build/pkgs/arb/distros/freebsd.txt
+deleted file mode 100644
+index 2ef8c7cec0f..00000000000
+--- a/build/pkgs/arb/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/arb
+diff --git a/build/pkgs/arb/distros/gentoo.txt b/build/pkgs/arb/distros/gentoo.txt
+deleted file mode 100644
+index 58e3d4f8008..00000000000
+--- a/build/pkgs/arb/distros/gentoo.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-sci-mathematics/arb
+diff --git a/build/pkgs/arb/distros/homebrew.txt b/build/pkgs/arb/distros/homebrew.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/homebrew.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/nix.txt b/build/pkgs/arb/distros/nix.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/nix.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/opensuse.txt b/build/pkgs/arb/distros/opensuse.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/distros/repology.txt b/build/pkgs/arb/distros/repology.txt
+deleted file mode 100644
+index 179c9d507e1..00000000000
+--- a/build/pkgs/arb/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-fp
+diff --git a/build/pkgs/arb/distros/void.txt b/build/pkgs/arb/distros/void.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/void.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/package-version.txt b/build/pkgs/arb/package-version.txt
+deleted file mode 100644
+index e9763f6bfed..00000000000
+--- a/build/pkgs/arb/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-2.23.0
+diff --git a/build/pkgs/arb/spkg-check.in b/build/pkgs/arb/spkg-check.in
+deleted file mode 100644
+index 27cd9419538..00000000000
+--- a/build/pkgs/arb/spkg-check.in
++++ /dev/null
+@@ -1,2 +0,0 @@
+-cd src
+-$MAKE check
+diff --git a/build/pkgs/arb/spkg-configure.m4 b/build/pkgs/arb/spkg-configure.m4
+deleted file mode 100644
+index ef2dd0aac4a..00000000000
+--- a/build/pkgs/arb/spkg-configure.m4
++++ /dev/null
+@@ -1,23 +0,0 @@
+-SAGE_SPKG_CONFIGURE([arb], [
+-    AC_REQUIRE([SAGE_SPKG_CONFIGURE_FLINT])
+-    SAGE_ARB_LIBRARY="arb"
+-    AC_MSG_CHECKING([installing flint? ])
+-    if test x$sage_spkg_install_flint = xyes; then
+-        AC_MSG_RESULT([yes; install arb as well])
+-        sage_spkg_install_arb=yes
+-    else
+-        AC_CHECK_HEADER(arb.h, [
+-        dnl below function added in version 2.16 of arb
+-            AC_CHECK_LIB([arb], [acb_mat_eig_simple], [],
+-              [dnl in Debian the name of dylib is different.
+-               AC_CHECK_LIB([flint-arb], [acb_mat_eig_simple],
+-                [SAGE_ARB_LIBRARY="flint-arb"], [sage_spkg_install_arb=yes])])
+-        ], [sage_spkg_install_arb=yes])
+-    fi
+-], [], [], [
+-    if test x$sage_spkg_install_arb = xyes; then
+-        AC_SUBST(SAGE_ARB_LIBRARY,["arb"])
+-    else
+-        AC_SUBST(SAGE_ARB_LIBRARY,[$SAGE_ARB_LIBRARY])
+-    fi
+-])
+diff --git a/build/pkgs/arb/spkg-install.in b/build/pkgs/arb/spkg-install.in
+deleted file mode 100644
+index 9322f04c912..00000000000
+--- a/build/pkgs/arb/spkg-install.in
++++ /dev/null
+@@ -1,17 +0,0 @@
+-cd src
+-
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-flint because otherwise ARB's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure --disable-static --prefix="$SAGE_LOCAL" \
+-        --with-gmp="$SAGE_LOCAL" \
+-        --with-mpfr="$SAGE_LOCAL" \
+-        --with-flint="$SAGE_LOCAL" || \
+-    sdh_die "Error configuring arb."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/arb/type b/build/pkgs/arb/type
+deleted file mode 100644
+index a6a7b9cd726..00000000000
+--- a/build/pkgs/arb/type
++++ /dev/null
+@@ -1 +0,0 @@
+-standard
+diff --git a/build/pkgs/e_antic/dependencies b/build/pkgs/e_antic/dependencies
+index fea1ffbda45..8e977a55c13 100644
+--- a/build/pkgs/e_antic/dependencies
++++ b/build/pkgs/e_antic/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) flint arb antic boost_cropped
++$(MP_LIBRARY) flint boost_cropped
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/SPKG.rst b/build/pkgs/flint/SPKG.rst
+index f91de70d1ff..d9dcea0903b 100644
+--- a/build/pkgs/flint/SPKG.rst
++++ b/build/pkgs/flint/SPKG.rst
+@@ -4,8 +4,8 @@ flint: Fast Library for Number Theory
+ Description
+ -----------
+ 
+-FLINT is a C library for doing number theory, maintained by William
+-Hart.
++FLINT is a C library for doing number theory, maintained by
++Fredrik Johansson.
+ 
+ Website: http://www.flintlib.org
+ 
+@@ -20,4 +20,4 @@ Upstream Contact
+ 
+ -  flint-devel Gougle Group
+    (http://groups.google.co.uk/group/flint-devel)
+--  William Hart
++-  Fredrik Johansson
+diff --git a/build/pkgs/flint/checksums.ini b/build/pkgs/flint/checksums.ini
+index 3d449d98064..2cec823bfb1 100644
+--- a/build/pkgs/flint/checksums.ini
++++ b/build/pkgs/flint/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=flint-VERSION.tar.gz
+-sha1=63d90f8242c8f8ab4011fbcfb44b86c154f43abd
+-md5=c2d3cec326438f159a530c66eb07fafe
+-cksum=4244948341
+-upstream_url=http://flintlib.org/flint-VERSION.tar.gz
++sha1=c548b1d5eb86a1805de9bef56629455b61e873f7
++md5=24551d4e475290ce6b831c78fafb5efb
++cksum=1567352998
++upstream_url=https://github.com/flintlib/flint/releases/download/vVERSION/flint-VERSION.tar.gz
+diff --git a/build/pkgs/flint/dependencies b/build/pkgs/flint/dependencies
+index 385df4faa7d..1108dc4fb21 100644
+--- a/build/pkgs/flint/dependencies
++++ b/build/pkgs/flint/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) mpfr ntl
++$(MP_LIBRARY) mpfr
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/package-version.txt b/build/pkgs/flint/package-version.txt
+index c8e38b61405..4a36342fcab 100644
+--- a/build/pkgs/flint/package-version.txt
++++ b/build/pkgs/flint/package-version.txt
+@@ -1 +1 @@
+-2.9.0
++3.0.0
+diff --git a/build/pkgs/flint/spkg-build.in b/build/pkgs/flint/spkg-build.in
+new file mode 100644
+index 00000000000..ffb822c8a97
+--- /dev/null
++++ b/build/pkgs/flint/spkg-build.in
+@@ -0,0 +1,3 @@
++cd src
++sdh_configure
++sdh_make
+diff --git a/build/pkgs/flint/spkg-configure.m4 b/build/pkgs/flint/spkg-configure.m4
+index a58108c9d6e..9576e4cc1e9 100644
+--- a/build/pkgs/flint/spkg-configure.m4
++++ b/build/pkgs/flint/spkg-configure.m4
+@@ -1,25 +1,8 @@
+ SAGE_SPKG_CONFIGURE([flint], [
+-    SAGE_SPKG_DEPCHECK([mpfr ntl], [
++    SAGE_SPKG_DEPCHECK([mpfr], [
+         AC_CHECK_HEADER(flint/flint.h, [
+-          dnl flint_parallel_binary_splitting appears in Flint 2.9.0, needed by arb 2.23
+-          AC_SEARCH_LIBS([flint_parallel_binary_splitting], [flint], [
+-            dnl check that NTL is linked in
+-            AC_SEARCH_LIBS([fmpz_poly_get_ZZX], [flint], [
+-
+-              AC_MSG_CHECKING([that GC is not enabled in Flint... ])
+-              AC_RUN_IFELSE([
+-                 AC_LANG_PROGRAM([[#include <flint/flint.h>]], [
+-                                  [#ifdef HAVE_GC]
+-                                     [return HAVE_GC;]
+-                                  [#else]
+-                                     [return 0;]
+-                                  [#endif]])],
+-                 [AC_MSG_RESULT([GC not enabled. Good.])],
+-                        [AC_MSG_RESULT([GC enabled. Incompatible with Sage.])
+-                         sage_spkg_install_flint=yes],
+-                 [AC_MSG_RESULT(["cross compiling. assuming GC is not enabled"])])
+-            ], [sage_spkg_install_flint=yes])
+-          ], [sage_spkg_install_flint=yes])
++          dnl gr_get_fexpr appears in Flint 3.0
++          AC_SEARCH_LIBS([gr_get_fexpr], [flint], [], [sage_spkg_install_flint=yes])
+         ], [sage_spkg_install_flint=yes])
+     ])
+ ], [], [], [
+diff --git a/build/pkgs/flint/spkg-install.in b/build/pkgs/flint/spkg-install.in
+index eacd7b6e491..3ea8c053669 100644
+--- a/build/pkgs/flint/spkg-install.in
++++ b/build/pkgs/flint/spkg-install.in
+@@ -1,36 +1,2 @@
+-###############################################################################
+-#
+-# FLINT Sage install script
+-#
+-###############################################################################
+-if [ "$SAGE_DEBUG" = "yes" ]; then
+-    echo "Building a debug version of FLINT."
+-    FLINT_TUNE=" $FLINT_TUNE"; export FLINT_TUNE
+-    FLINT_CONFIGURE="--enable-assert $FLINT_CONFIGURE"
+-fi
+-
+ cd src
+-
+-echo "Configuring FLINT."
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-ntl because otherwise FLINT's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-ntl="$SAGE_LOCAL" \
+-    $FLINT_CONFIGURE || sdh_die "Error: Failed to configure FLINT."
+-
+-sdh_make verbose
+-
+-echo "Deleting old FLINT files."
+-rm -f $SAGE_LOCAL/lib/libflint*
+-rm -rf $SAGE_LOCAL/include/flint
+-
+ sdh_make_install
+diff --git a/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+new file mode 100644
+index 00000000000..27a642a13b0
+--- /dev/null
++++ b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+@@ -0,0 +1,53 @@
++From fe730579476de0b2d4181a38efa7f63dff9c81d7 Mon Sep 17 00:00:00 2001
++From: Marc Mezzarobba <marc@mezzarobba.net>
++Date: Tue, 12 Sep 2023 08:23:08 +0200
++Subject: [PATCH] Make msolve build with flint3
++
++---
++ src/fglm/berlekamp_massey.c | 3 +++
++ src/fglm/data_fglm.c        | 7 +++++--
++ 2 files changed, 8 insertions(+), 2 deletions(-)
++
++diff --git a/src/fglm/berlekamp_massey.c b/src/fglm/berlekamp_massey.c
++index b0f2052..998af1c 100644
++--- a/src/fglm/berlekamp_massey.c
+++++ b/src/fglm/berlekamp_massey.c
++@@ -30,6 +30,9 @@
++ */
++ 
++ #include <stdlib.h>
+++#if __FLINT_VERSION >= 3
+++#  include <flint/nmod.h>
+++#endif
++ //#include "nmod_poly.h"
++ //#include "mpn_extras.h"
++ 
++diff --git a/src/fglm/data_fglm.c b/src/fglm/data_fglm.c
++index 0726760..0e1da6f 100644
++--- a/src/fglm/data_fglm.c
+++++ b/src/fglm/data_fglm.c
++@@ -24,6 +24,7 @@
++ #include <flint/mpn_extras.h>
++ #include <flint/nmod_poly.h>
++ #include <flint/nmod_poly_factor.h>
+++#include <flint/ulong_extras.h>
++ 
++ 
++ typedef uint32_t szmat_t;
++@@ -299,9 +300,11 @@ static inline void nmod_poly_set_prime(nmod_poly_t poly,
++   mp_limb_t ninv = n_preinvert_limb(prime);
++   poly->mod.n = prime;
++   poly->mod.ninv = ninv;
+++#if __FLINT_VERSION < 3
++   count_leading_zeros(poly->mod.norm, prime);
++-  /* poly->mod.norm = flint_clz(prime); */
++-
+++#else
+++  poly->mod.norm = flint_clz(prime);
+++#endif
++ }
++ 
++ static inline void fglm_param_set_prime(param_t *param, mp_limb_t prime){
++-- 
++2.40.1
++
+diff --git a/build/pkgs/sagelib/dependencies b/build/pkgs/sagelib/dependencies
+index 5dc2efe1d31..fa6e98df7db 100644
+--- a/build/pkgs/sagelib/dependencies
++++ b/build/pkgs/sagelib/dependencies
+@@ -1,4 +1,4 @@
+-FORCE $(SCRIPTS) arb boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
++FORCE $(SCRIPTS) boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/symengine/dependencies b/build/pkgs/symengine/dependencies
+index 1fc34963eda..7795d486018 100644
+--- a/build/pkgs/symengine/dependencies
++++ b/build/pkgs/symengine/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) arb ecm flint mpc mpfr | cmake
++$(MP_LIBRARY) ecm flint mpc mpfr | cmake
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/pkgs/sage-conf/_sage_conf/_conf.py.in b/pkgs/sage-conf/_sage_conf/_conf.py.in
+index 87b27ca05cb..895d6572d1e 100644
+--- a/pkgs/sage-conf/_sage_conf/_conf.py.in
++++ b/pkgs/sage-conf/_sage_conf/_conf.py.in
+@@ -19,8 +19,6 @@ MAXIMA_FAS = "@SAGE_MAXIMA_FAS@".replace('${prefix}', SAGE_LOCAL)
+ # Delete this line if your ECL can load Kenzo without further prodding.
+ KENZO_FAS = "@SAGE_KENZO_FAS@".replace('${prefix}', SAGE_LOCAL)
+ 
+-ARB_LIBRARY = "@SAGE_ARB_LIBRARY@"
+-
+ NTL_INCDIR = "@NTL_INCDIR@"
+ NTL_LIBDIR = "@NTL_LIBDIR@"
+ 
+diff --git a/src/sage/env.py b/src/sage/env.py
+index f4899639a6d..f6459313fd4 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -223,7 +223,6 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st
+ FOURTITWO_PPI = var("FOURTITWO_PPI")
+ FOURTITWO_CIRCUITS = var("FOURTITWO_CIRCUITS")
+ FOURTITWO_GROEBNER = var("FOURTITWO_GROEBNER")
+-ARB_LIBRARY = var("ARB_LIBRARY", "arb")
+ CBLAS_PC_MODULES = var("CBLAS_PC_MODULES", "cblas:openblas:blas")
+ ECL_CONFIG = var("ECL_CONFIG", "ecl-config")
+ NTL_INCDIR = var("NTL_INCDIR")
+@@ -356,8 +355,7 @@ def cython_aliases(required_modules=None,
+         sage: cython_aliases()
+         {...}
+         sage: sorted(cython_aliases().keys())
+-        ['ARB_LIBRARY',
+-         'CBLAS_CFLAGS',
++        ['CBLAS_CFLAGS',
+          ...,
+          'ZLIB_LIBRARIES']
+         sage: cython_aliases(required_modules=('module-that-is-assumed-to-not-exist'))
+@@ -475,8 +473,6 @@ def uname_specific(name, value, alternative):
+     if "LINBOX_CFLAGS" in aliases:
+         aliases["LINBOX_CFLAGS"].append("-std=gnu++11")
+ 
+-    aliases["ARB_LIBRARY"] = ARB_LIBRARY
+-
+     # TODO: Remove Cygwin hack by installing a suitable cblas.pc
+     if os.path.exists('/usr/lib/libblas.dll.a'):
+         aliases["CBLAS_LIBS"] = ['gslcblas']
+diff --git a/src/sage/features/sagemath.py b/src/sage/features/sagemath.py
+index 7404e6d0a8e..6037d097391 100644
+--- a/src/sage/features/sagemath.py
++++ b/src/sage/features/sagemath.py
+@@ -761,7 +761,7 @@ class sage__rings__number_field(JoinFeature):
+     A :class:`~sage.features.Feature` describing the presence of :mod:`sage.rings.number_field`.
+ 
+     Number fields are implemented in Sage using a complicated mixture of various libraries,
+-    including :ref:`arb <spkg_arb>`, :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
++    including :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
+     :ref:`MPFI <spkg_mpfi>`, :ref:`NTL <spkg_ntl>`, and :ref:`PARI <spkg_pari>`.
+ 
+     EXAMPLES:
+diff --git a/src/sage/libs/arb/acb.pxd b/src/sage/libs/arb/acb.pxd
+index 5148dc43991..851488d803a 100644
+--- a/src/sage/libs/arb/acb.pxd
++++ b/src/sage/libs/arb/acb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -152,10 +152,6 @@ cdef extern from "arb_wrap.h":
+     void acb_sech(acb_t s, const acb_t z, long prec)
+     void acb_csch(acb_t c, const acb_t z, long prec)
+ 
+-    void acb_rising_ui_bs(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui_rs(acb_t z, const acb_t x, unsigned long n, unsigned long step, long prec)
+-    void acb_rising_ui_rec(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui(acb_t z, const acb_t x, unsigned long n, long prec)
+     void acb_rising(acb_t z, const acb_t x, const acb_t n, long prec)
+ 
+     void acb_gamma(acb_t y, const acb_t x, long prec)
+diff --git a/src/sage/libs/arb/acb_calc.pxd b/src/sage/libs/arb/acb_calc.pxd
+index a5dbf360b5e..67bd2ed57dc 100644
+--- a/src/sage/libs/arb/acb_calc.pxd
++++ b/src/sage/libs/arb/acb_calc.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_calc.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_elliptic.pxd b/src/sage/libs/arb/acb_elliptic.pxd
+index 176f68df00e..e3480e9f73b 100644
+--- a/src/sage/libs/arb/acb_elliptic.pxd
++++ b/src/sage/libs/arb/acb_elliptic.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_elliptic.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_hypgeom.pxd b/src/sage/libs/arb/acb_hypgeom.pxd
+index 418e766f10d..c43e5c0623b 100644
+--- a/src/sage/libs/arb/acb_hypgeom.pxd
++++ b/src/sage/libs/arb/acb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_hypgeom.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_modular.pxd b/src/sage/libs/arb/acb_modular.pxd
+index c708e9bf97d..cdc413c92da 100644
+--- a/src/sage/libs/arb/acb_modular.pxd
++++ b/src/sage/libs/arb/acb_modular.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_modular.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_poly.pxd b/src/sage/libs/arb/acb_poly.pxd
+index 69f4320055b..ae02757ffd9 100644
+--- a/src/sage/libs/arb/acb_poly.pxd
++++ b/src/sage/libs/arb/acb_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -79,24 +79,10 @@ cdef extern from "arb_wrap.h":
+     void _acb_poly_divrem(acb_ptr Q, acb_ptr R, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec)
+     bint acb_poly_divrem(acb_poly_t Q, acb_poly_t R, const acb_poly_t A, const acb_poly_t B, long prec)
+     void _acb_poly_div_root(acb_ptr Q, acb_t R, acb_srcptr A, long len, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_horner(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_horner(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_divconquer(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_divconquer(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_convolution(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_convolution(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+     void _acb_poly_taylor_shift(acb_ptr g, const acb_t c, long n, long prec)
+     void acb_poly_taylor_shift(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_compose_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_divconquer(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_divconquer(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+     void _acb_poly_compose(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+     void acb_poly_compose(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_series_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+-    void _acb_poly_compose_series_brent_kung(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_brent_kung(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_compose_series(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+     void acb_poly_compose_series(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_revert_series_lagrange(acb_ptr h, acb_srcptr f, long flen, long n, long prec)
+@@ -161,10 +147,6 @@ cdef extern from "arb_wrap.h":
+     void acb_poly_exp_series_basecase(acb_poly_t f, const acb_poly_t h, long n, long prec)
+     void _acb_poly_exp_series(acb_ptr f, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_exp_series(acb_poly_t f, const acb_poly_t h, long n, long prec)
+-    void _acb_poly_sin_cos_series_basecase(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_basecase(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+-    void _acb_poly_sin_cos_series_tangent(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_tangent(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+     void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_sin_cos_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec)
+     void _acb_poly_sin_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec)
+diff --git a/src/sage/libs/arb/arb.pxd b/src/sage/libs/arb/arb.pxd
+index c82b94de30f..acd232ab816 100644
+--- a/src/sage/libs/arb/arb.pxd
++++ b/src/sage/libs/arb/arb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -224,15 +224,8 @@ cdef extern from "arb_wrap.h":
+ 
+     void arb_lambertw(arb_t res, const arb_t x, int flags, long prec)
+ 
+-    void arb_rising_ui_bs(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui_rs(arb_t z, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising_ui_rec(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui(arb_t z, const arb_t x, unsigned long n, long prec)
+     void arb_rising(arb_t z, const arb_t x, const arb_t n, long prec)
+     void arb_rising_fmpq_ui(arb_t z, const fmpq_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_bs(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_rs(arb_t u, arb_t v, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising2_ui(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+     void arb_fac_ui(arb_t z, unsigned long n, long prec)
+     void arb_bin_ui(arb_t z, const arb_t n, unsigned long k, long prec)
+     void arb_bin_uiui(arb_t z, unsigned long n, unsigned long k, long prec)
+diff --git a/src/sage/libs/arb/arb_fmpz_poly.pxd b/src/sage/libs/arb/arb_fmpz_poly.pxd
+index 079f76e9d9e..55daa705238 100644
+--- a/src/sage/libs/arb/arb_fmpz_poly.pxd
++++ b/src/sage/libs/arb/arb_fmpz_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_fmpz_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -22,5 +22,4 @@ cdef extern from "arb_wrap.h":
+     unsigned long arb_fmpz_poly_deflation(const fmpz_poly_t poly)
+     void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long deflation)
+     void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, long prec)
+-    void arb_fmpz_poly_cos_minpoly(fmpz_poly_t res, unsigned long n)
+     void arb_fmpz_poly_gauss_period_minpoly(fmpz_poly_t res, unsigned long q, unsigned long n)
+diff --git a/src/sage/libs/arb/arb_hypgeom.pxd b/src/sage/libs/arb/arb_hypgeom.pxd
+index fb1c40ddaa8..139b987d669 100644
+--- a/src/sage/libs/arb/arb_hypgeom.pxd
++++ b/src/sage/libs/arb/arb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_hypgeom.h
+ 
+ from sage.libs.flint.types cimport fmpz_t
+diff --git a/src/sage/libs/arb/arb_wrap.h b/src/sage/libs/arb/arb_wrap.h
+index 49997075ee5..488bb376d5e 100644
+--- a/src/sage/libs/arb/arb_wrap.h
++++ b/src/sage/libs/arb/arb_wrap.h
+@@ -5,25 +5,27 @@
+  * by arb, most of which rely on flint's ulong and slong defines.
+  */
+ 
++#include <mpfr.h>
++
+ #undef ulong
+ #undef slong
+ 
+ #define ulong mp_limb_t
+ #define slong mp_limb_signed_t
+ 
+-#include <acb.h>
+-#include <acb_calc.h>
+-#include <acb_elliptic.h>
+-#include <acb_hypgeom.h>
+-#include <acb_mat.h>
+-#include <acb_modular.h>
+-#include <acb_poly.h>
+-#include <arb.h>
+-#include <arb_fmpz_poly.h>
+-#include <arb_hypgeom.h>
+-#include <arf.h>
+-#include <bernoulli.h>
+-#include <mag.h>
++#include <flint/acb.h>
++#include <flint/acb_calc.h>
++#include <flint/acb_elliptic.h>
++#include <flint/acb_hypgeom.h>
++#include <flint/acb_mat.h>
++#include <flint/acb_modular.h>
++#include <flint/acb_poly.h>
++#include <flint/arb.h>
++#include <flint/arb_fmpz_poly.h>
++#include <flint/arb_hypgeom.h>
++#include <flint/arf.h>
++#include <flint/bernoulli.h>
++#include <flint/mag.h>
+ 
+ #undef ulong
+ #undef slong
+diff --git a/src/sage/libs/arb/arf.pxd b/src/sage/libs/arb/arf.pxd
+index b8b83fefcdc..84778fe9f09 100644
+--- a/src/sage/libs/arb/arf.pxd
++++ b/src/sage/libs/arb/arf.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arf.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -30,7 +30,6 @@ cdef extern from "arb_wrap.h":
+     void arf_set_ui(arf_t y, unsigned long x)
+     void arf_set_si(arf_t y, long x)
+     void arf_set_mpfr(arf_t y, const mpfr_t x)
+-    # void arf_set_fmpr(arf_t y, const fmpr_t x)
+     void arf_set_d(arf_t y, double x)
+     void arf_swap(arf_t y, arf_t x)
+     void arf_init_set_ui(arf_t y, unsigned long x)
+@@ -46,7 +45,6 @@ cdef extern from "arb_wrap.h":
+     int arf_set_round_fmpz_2exp(arf_t y, const fmpz_t x, const fmpz_t e, long prec, arf_rnd_t rnd)
+     void arf_get_fmpz_2exp(fmpz_t m, fmpz_t e, const arf_t x)
+     double arf_get_d(const arf_t x, arf_rnd_t rnd)
+-    # void arf_get_fmpr(fmpr_t y, const arf_t x)
+     int arf_get_mpfr(mpfr_t y, const arf_t x, mpfr_rnd_t rnd)
+     void arf_get_fmpz(fmpz_t z, const arf_t x, arf_rnd_t rnd)
+     long arf_get_si(const arf_t x, arf_rnd_t rnd)
+diff --git a/src/sage/libs/arb/bernoulli.pxd b/src/sage/libs/arb/bernoulli.pxd
+index 375b2b9bbcf..ea9340f4b15 100644
+--- a/src/sage/libs/arb/bernoulli.pxd
++++ b/src/sage/libs/arb/bernoulli.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = bernoulli.h
+ 
+ from ..flint.types cimport fmpq_t, ulong
+diff --git a/src/sage/libs/arb/mag.pxd b/src/sage/libs/arb/mag.pxd
+index d5d8693ea8f..69dfb990ae0 100644
+--- a/src/sage/libs/arb/mag.pxd
++++ b/src/sage/libs/arb/mag.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = mag.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -27,13 +27,11 @@ cdef extern from "arb_wrap.h":
+     # void mag_randtest(mag_t x, flint_rand_t state, long expbits)
+     # void mag_randtest_special(mag_t x, flint_rand_t state, long expbits)
+     void mag_set_d(mag_t y, double x)
+-    # void mag_set_fmpr(mag_t y, const fmpr_t x)
+     void mag_set_ui(mag_t y, unsigned long x)
+     void mag_set_fmpz(mag_t y, const fmpz_t x)
+     void mag_set_d_2exp_fmpz(mag_t z, double x, const fmpz_t y)
+     void mag_set_fmpz_2exp_fmpz(mag_t z, const fmpz_t x, const fmpz_t y)
+     void mag_set_ui_2exp_si(mag_t z, unsigned long x, long y)
+-    # void mag_get_fmpr(fmpr_t y, const mag_t x)
+     void mag_get_fmpq(fmpq_t y, const mag_t x)
+     void mag_set_ui_lower(mag_t z, unsigned long x)
+     void mag_set_fmpz_lower(mag_t z, const fmpz_t x)
+diff --git a/src/sage/libs/flint/flint_wrap.h b/src/sage/libs/flint/flint_wrap.h
+index 266535c3835..4db72b97660 100644
+--- a/src/sage/libs/flint/flint_wrap.h
++++ b/src/sage/libs/flint/flint_wrap.h
+@@ -15,6 +15,7 @@
+  */
+ 
+ #include <gmp.h>
++#include <mpfr.h>
+ 
+ /* Save previous definition of ulong if any, as pari also uses it */
+ /* Should work on GCC, clang, MSVC */
+@@ -33,6 +34,7 @@
+ 
+ #include <flint/arith.h>
+ #include <flint/fmpq.h>
++#include <flint/fmpq_vec.h>
+ #include <flint/fmpq_mat.h>
+ #include <flint/fmpq_poly.h>
+ #include <flint/fmpz.h>
+@@ -47,6 +49,7 @@
+ #include <flint/fq.h>
+ #include <flint/fq_nmod.h>
+ #include <flint/nmod_poly.h>
++#include <flint/nmod_poly_factor.h>
+ #include <flint/nmod_vec.h>
+ #include <flint/padic.h>
+ #include <flint/padic_poly.h>
+diff --git a/src/sage/libs/flint/fmpq.pxd b/src/sage/libs/flint/fmpq.pxd
+index 5e64c82102f..0616c0a7408 100644
+--- a/src/sage/libs/flint/fmpq.pxd
++++ b/src/sage/libs/flint/fmpq.pxd
+@@ -12,6 +12,8 @@ cdef extern from "flint_wrap.h":
+     fmpz * fmpq_denref(fmpq_t)
+     void fmpq_init(fmpq_t)
+     void fmpq_clear(fmpq_t)
++    void fmpq_init_set_readonly(fmpq_t, const mpq_t)
++    void fmpq_clear_readonly(fmpq_t)
+     void fmpq_one(fmpq_t)
+     void fmpq_zero(fmpq_t)
+     bint fmpq_is_zero(fmpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pxd b/src/sage/libs/flint/fmpq_poly.pxd
+index 20a797c0197..516f9e84cfc 100644
+--- a/src/sage/libs/flint/fmpq_poly.pxd
++++ b/src/sage/libs/flint/fmpq_poly.pxd
+@@ -30,6 +30,9 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_canonicalise(fmpq_poly_t)
+     int fmpq_poly_is_canonical(const fmpq_poly_t)
+ 
++    void _fmpq_poly_set_length(fmpq_poly_t, slong)
++    void _fmpq_poly_normalise(fmpq_poly_t)
++
+     # Polynomial parameters
+     slong fmpq_poly_degree(const fmpq_poly_t)
+     ulong fmpq_poly_length(const fmpq_poly_t)
+@@ -46,10 +49,7 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_ui(fmpq_poly_t, ulong)
+     void fmpq_poly_set_fmpz(fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_set_fmpq(fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+     void fmpq_poly_set_fmpz_poly(fmpq_poly_t, const fmpz_poly_t)
+-    void fmpq_poly_set_array_mpq(fmpq_poly_t, const mpq_t *, slong)
+ 
+     void fmpq_poly_set_str(fmpq_poly_t, const char *)
+     char *fmpq_poly_get_str(const fmpq_poly_t)
+@@ -67,7 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_reverse(fmpq_poly_t, const fmpq_poly_t, slong)
+ 
+     void fmpq_poly_get_coeff_fmpq(fmpq_t, const fmpq_poly_t, slong)
+-    void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_si(slong, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_ui(ulong, const fmpq_poly_t, slong)
+ 
+@@ -75,8 +74,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_coeff_ui(fmpq_poly_t, slong, ulong)
+     void fmpq_poly_set_coeff_fmpz(fmpq_poly_t, slong, const fmpz_t)
+     void fmpq_poly_set_coeff_fmpq(fmpq_poly_t, slong, const fmpq_t)
+-    void fmpq_poly_set_coeff_mpz(fmpq_poly_t, slong, const mpz_t)
+-    void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
+ 
+     # Comparison
+     int fmpq_poly_equal(const fmpq_poly_t, const fmpq_poly_t)
+@@ -100,8 +97,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_mul_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     void fmpq_poly_scalar_div_si(fmpq_poly_t, const fmpq_poly_t, slong)
+     void fmpq_poly_scalar_div_ui(fmpq_poly_t, const fmpq_poly_t, ulong)
+@@ -109,8 +104,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_div_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_div_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_div_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Multiplication
+     void fmpq_poly_mul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -155,8 +148,6 @@ cdef extern from "flint_wrap.h":
+     # Evaluation
+     void fmpq_poly_evaluate_fmpz(fmpq_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_evaluate_fmpq(fmpq_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_evaluate_mpz(mpq_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_evaluate_mpq(mpq_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Composition
+     void fmpq_poly_compose(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -189,3 +180,11 @@ cdef extern from "flint_wrap.h":
+ # since the fmpq_poly header seems to be lacking this inline function
+ cdef inline sage_fmpq_poly_max_limbs(const fmpq_poly_t poly):
+     return _fmpz_vec_max_limbs(fmpq_poly_numref(poly), fmpq_poly_length(poly))
++
++# functions removed from flint but still needed in sage
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
++cdef void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
++cdef void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pyx b/src/sage/libs/flint/fmpq_poly.pyx
+new file mode 100644
+index 00000000000..3b8a0cf0c51
+--- /dev/null
++++ b/src/sage/libs/flint/fmpq_poly.pyx
+@@ -0,0 +1,45 @@
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++from sage.libs.gmp.mpq cimport *
++from sage.libs.flint.fmpz cimport *
++from sage.libs.flint.fmpq cimport *
++
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t rop, const fmpq_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t rop, const fmpq_poly_t op, const mpq_t c):
++    cdef fmpq_t f
++    fmpq_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpq(rop, op, f)
++    fmpq_clear_readonly(f)
++
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t poly, slong n, const mpq_t x):
++    cdef fmpq_t t
++    fmpq_init_set_readonly(t, x)
++    fmpq_poly_set_coeff_fmpq(poly, n, t)
++    fmpq_clear_readonly(t)
++
++cdef void fmpq_poly_get_coeff_mpq(mpq_t x, const fmpq_poly_t poly, slong n):
++    cdef fmpq_t t
++    fmpq_init(t)
++    fmpq_poly_get_coeff_fmpq(t, poly, n)
++    fmpq_get_mpq(x, t)
++    fmpq_clear(t)
++
++cdef void fmpq_poly_set_mpq(fmpq_poly_t poly, const mpq_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), mpq_numref(x))
++    fmpz_set_mpz(fmpq_poly_denref(poly), mpq_denref(x))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
++
++cdef void fmpq_poly_set_mpz(fmpq_poly_t poly, const mpz_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), x)
++    fmpz_one(fmpq_poly_denref(poly))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz.pxd b/src/sage/libs/flint/fmpz.pxd
+index 01058d0f130..b97fbe1eae0 100644
+--- a/src/sage/libs/flint/fmpz.pxd
++++ b/src/sage/libs/flint/fmpz.pxd
+@@ -16,6 +16,9 @@ cdef extern from "flint_wrap.h":
+     void fmpz_init_set(fmpz_t, fmpz_t)
+     void fmpz_init_set_ui(fmpz_t, ulong)
+ 
++    void fmpz_init_set_readonly(fmpz_t, const mpz_t)
++    void fmpz_clear_readonly(fmpz_t)
++
+     # Conversion
+     void fmpz_set(fmpz_t f, fmpz_t g)
+     void fmpz_set_ui(fmpz_t, ulong)
+diff --git a/src/sage/libs/flint/fmpz_mod_poly.pxd b/src/sage/libs/flint/fmpz_mod_poly.pxd
+index 24b653eb3b7..2727246da98 100644
+--- a/src/sage/libs/flint/fmpz_mod_poly.pxd
++++ b/src/sage/libs/flint/fmpz_mod_poly.pxd
+@@ -67,13 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_get_coeff_fmpz(fmpz_t x, const fmpz_mod_poly_t poly,
+                                              slong n, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_set_coeff_mpz(fmpz_mod_poly_t poly,
+-                             slong n, const mpz_t x, const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_get_coeff_mpz(mpz_t x,
+-                 const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx)
+-
+-
+     void _fmpz_mod_poly_shift_left(fmpz * res, const fmpz * poly,
+                                                            slong len, slong n)
+ 
+@@ -194,14 +187,6 @@ cdef extern from "flint_wrap.h":
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_div_basecase(fmpz_mod_poly_t Q,
+-                            const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_div_newton_n_preinv(fmpz_mod_poly_t Q,
+-                         const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                         const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem_newton_n_preinv(fmpz_mod_poly_t Q,
+           fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                          const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+@@ -213,10 +198,6 @@ cdef extern from "flint_wrap.h":
+                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_divrem_divconquer(fmpz_mod_poly_t Q,
+-        fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem(fmpz_mod_poly_t Q, fmpz_mod_poly_t R,
+     const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+@@ -254,40 +235,13 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_make_monic_f(fmpz_t f, fmpz_mod_poly_t res,
+                          const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_euclidean(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_gcd_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_hgcd(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-
+     void fmpz_mod_poly_gcd(fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+ 
+-    void fmpz_mod_poly_xgcd_euclidean(fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_hgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S,
+-          fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_xgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                       const fmpz_mod_ctx_t ctx)
+@@ -361,14 +315,6 @@ cdef extern from "flint_wrap.h":
+                         const fmpz_mod_poly_t poly, const fmpz * xs, slong n,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_compose_horner(fmpz_mod_poly_t res,
+-                    const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_compose_divconquer(fmpz_mod_poly_t res,
+-                     const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_compose(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1,
+                          const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx)
+ 
+diff --git a/src/sage/libs/flint/fmpz_poly.pxd b/src/sage/libs/flint/fmpz_poly.pxd
+index 18b36672d30..c8bc6d3ca0a 100644
+--- a/src/sage/libs/flint/fmpz_poly.pxd
++++ b/src/sage/libs/flint/fmpz_poly.pxd
+@@ -28,7 +28,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_poly_set_ui(fmpz_poly_t, ulong)
+     void fmpz_poly_set_si(fmpz_poly_t, slong)
+     void fmpz_poly_set_fmpz(fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+     int fmpz_poly_set_str(fmpz_poly_t, const char *)
+ 
+     char *fmpz_poly_get_str(const fmpz_poly_t)
+@@ -70,7 +69,6 @@ cdef extern from "flint_wrap.h":
+     # Scalar multiplication and division
+     void fmpz_poly_scalar_mul_fmpz(
+             fmpz_poly_t, const fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+     void fmpz_poly_scalar_mul_si(fmpz_poly_t, const fmpz_poly_t, slong)
+     void fmpz_poly_scalar_mul_ui(fmpz_poly_t, const fmpz_poly_t, ulong)
+     void fmpz_poly_scalar_mul_2exp(fmpz_poly_t, const fmpz_poly_t, ulong)
+@@ -310,12 +308,14 @@ cdef extern from "flint_wrap.h":
+             fmpz_poly_t,
+                     const fmpz_poly_t, const fmpz_t, const nmod_poly_t, int)
+ 
+-    # Some functions for backwards compatibility
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
+-    void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++
++# functions removed from flint but still needed in sage
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
++cdef void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++cdef void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+ 
+ 
+ # Wrapper Cython class
+diff --git a/src/sage/libs/flint/fmpz_poly.pyx b/src/sage/libs/flint/fmpz_poly.pyx
+index 74915b37612..cfcbea9090c 100644
+--- a/src/sage/libs/flint/fmpz_poly.pyx
++++ b/src/sage/libs/flint/fmpz_poly.pyx
+@@ -25,10 +25,10 @@ from cysignals.memory cimport sig_free
+ 
+ from sage.arith.long cimport pyobject_to_long
+ from sage.cpython.string cimport char_to_str, str_to_bytes
++from sage.libs.flint.fmpz cimport *
+ from sage.structure.sage_object cimport SageObject
+ from sage.rings.integer cimport Integer
+ 
+-
+ cdef class Fmpz_poly(SageObject):
+ 
+     def __cinit__(self):
+@@ -455,3 +455,44 @@ cdef class Fmpz_poly(SageObject):
+         """
+         from sage.rings.integer_ring import ZZ
+         return ZZ[var](self.list())
++
++
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_divexact_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_fdiv_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t poly, slong n, const mpz_t x):
++    cdef fmpz_t t
++    fmpz_init_set_readonly(t, x)
++    fmpz_poly_set_coeff_fmpz(poly, n, t)
++    fmpz_clear_readonly(t)
++
++cdef void fmpz_poly_get_coeff_mpz(mpz_t x, const fmpz_poly_t poly, slong n):
++    cdef fmpz_t t
++    fmpz_init(t)
++    fmpz_poly_get_coeff_fmpz(t, poly, n)
++    fmpz_get_mpz(x, t)
++    fmpz_clear(t)
++
++cdef void fmpz_poly_set_mpz(fmpz_poly_t poly, const mpz_t x):
++    fmpz_poly_fit_length(poly, 1)
++    fmpz_set_mpz(poly.coeffs, x)
++    _fmpz_poly_set_length(poly, 1)
++    _fmpz_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz_poly_q.pxd b/src/sage/libs/flint/fmpz_poly_q.pxd
+index 846542dc0d8..63c13355bf6 100644
+--- a/src/sage/libs/flint/fmpz_poly_q.pxd
++++ b/src/sage/libs/flint/fmpz_poly_q.pxd
+@@ -49,11 +49,7 @@ cdef extern from "flint_wrap.h":
+ 
+     #* Scalar multiplication and division ****************************************/
+     void fmpz_poly_q_scalar_mul_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_mul_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_mul_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+     void fmpz_poly_q_scalar_div_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_div_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_div_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+ 
+     #* Multiplication and division ***********************************************/
+     void fmpz_poly_q_mul(fmpz_poly_q_t rop, 
+@@ -67,9 +63,6 @@ cdef extern from "flint_wrap.h":
+     #* Derivative ****************************************************************/
+     void fmpz_poly_q_derivative(fmpz_poly_q_t rop, const fmpz_poly_q_t op)
+ 
+-    #* Evaluation ****************************************************************/
+-    int fmpz_poly_q_evaluate(mpq_t rop, const fmpz_poly_q_t f, const mpq_t a)
+-
+     #* Input and output **********************************************************/
+     int fmpz_poly_q_set_str(fmpz_poly_q_t rop, const char *s)
+     char * fmpz_poly_q_get_str(const fmpz_poly_q_t op)
+diff --git a/src/sage/libs/linbox/linbox_flint_interface.pyx b/src/sage/libs/linbox/linbox_flint_interface.pyx
+index 415cd473947..83547f91cd2 100644
+--- a/src/sage/libs/linbox/linbox_flint_interface.pyx
++++ b/src/sage/libs/linbox/linbox_flint_interface.pyx
+@@ -33,6 +33,7 @@ and C. Pernet. The functions available are:
+ #                  https://www.gnu.org/licenses/
+ # ****************************************************************************
+ 
++from sage.libs.gmp.types cimport mpz_t
+ from sage.libs.flint.types cimport fmpz_t
+ from sage.libs.flint.fmpz cimport fmpz_get_mpz, fmpz_set_mpz
+ from sage.libs.flint.fmpz_mat cimport fmpz_mat_entry, fmpz_mat_nrows, fmpz_mat_ncols
+@@ -80,11 +81,13 @@ cdef void fmpz_poly_set_linbox(fmpz_poly_t p, PolynomialRing_integer.Element& q)
+     (the .pxd file) in order to keep the header C-compatible
+     """
+     cdef size_t i
++    cdef mpz_t tmp
+ 
+     fmpz_poly_fit_length(p, q.size())
+ 
+     for i in range(q.size()):
+-        fmpz_poly_set_coeff_mpz(p, i, q[i].get_mpz_const())
++        tmp = q[i].get_mpz_const()
++        fmpz_poly_set_coeff_mpz(p, i, tmp)
+ 
+     _fmpz_poly_set_length(p, q.size())
+ 
+diff --git a/src/sage/matrix/matrix_complex_ball_dense.pyx b/src/sage/matrix/matrix_complex_ball_dense.pyx
+index 3f56772a663..b1ece8a0e7b 100644
+--- a/src/sage/matrix/matrix_complex_ball_dense.pyx
++++ b/src/sage/matrix/matrix_complex_ball_dense.pyx
+@@ -1,4 +1,4 @@
+-# distutils: libraries = ARB_LIBRARY
++# distutils: libraries = flint
+ r"""
+ Arbitrary precision complex ball matrices using Arb
+ 
+diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx
+index f4320fcd914..b36ee300990 100644
+--- a/src/sage/matrix/matrix_integer_sparse.pyx
++++ b/src/sage/matrix/matrix_integer_sparse.pyx
+@@ -847,6 +847,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+             sage: matrix(ZZ, 1, 1, sparse=True)._charpoly_linbox()
+             x
+         """
++        cdef mpz_t tmp
+         if self._nrows != self._ncols:
+             raise ArithmeticError('only valid for square matrix')
+ 
+@@ -869,7 +870,8 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         cdef size_t i
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+@@ -966,9 +968,11 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         sig_off()
+ 
+         cdef size_t i
++        cdef mpz_t tmp
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
+index a22ce3c5e53..15be37734af 100644
+--- a/src/sage/rings/complex_arb.pyx
++++ b/src/sage/rings/complex_arb.pyx
+@@ -1360,12 +1360,13 @@ cdef class ComplexBall(RingElement):
+             sage: CBF100(-3r)
+             -3.000000000000000000000000000000
+ 
+-            sage: ComplexBall(CBF100, 10^100)
+-            1.000000000000000000000000000000e+100
+             sage: ComplexBall(CBF100, CIF(1, 2))
+             1.000000000000000000000000000000 + 2.000000000000000000000000000000*I
+             sage: ComplexBall(CBF100, RBF(1/3), RBF(1))
+             [0.3333333333333333 +/- ...e-17] + 1.000000000000000000000000000000*I
++            sage: ComplexBall(CBF100, 10^100)
++            [1.000000000000000000000000000000e+100 +/- ...]
++
+             sage: NF.<a> = QuadraticField(-1, embedding=CC(0, -1))
+             sage: CBF(a)
+             -1.000000000000000*I
+@@ -3009,7 +3010,7 @@ cdef class ComplexBall(RingElement):
+             sage: CBF(1).rising_factorial(2**64)
+             [+/- ...e+347382171326740403407]
+             sage: ComplexBallField(128)(1).rising_factorial(2**64)
+-            [2.343691126796861348e+347382171305201285713 +/- ...e+347382171305201285694]
++            [2.34369112679686134...e+347382171305201285713 +/- ...]
+             sage: CBF(1/2).rising_factorial(CBF(2,3)) # abs tol 1e-15
+             [-0.123060451458124 +/- 3.06e-16] + [0.0406412631676552 +/- 7.57e-17]*I
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+index b888b31d214..621d86f9bb8 100644
+--- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+@@ -222,7 +222,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef unsigned long n
+         cdef Rational c
+         cdef list L1
+-        cdef mpq_t * L2
++        cdef fmpq_t q
+ 
+         Polynomial.__init__(self, parent, is_gen=is_gen)
+ 
+@@ -253,14 +253,11 @@ cdef class Polynomial_rational_flint(Polynomial):
+             L1 = [e if isinstance(e, Rational) else Rational(e) for e in x]
+             n  = <unsigned long> len(x)
+             sig_on()
+-            L2 = <mpq_t *> check_allocarray(n, sizeof(mpq_t))
++            fmpq_poly_fit_length(self._poly, n)
+             for deg from 0 <= deg < n:
+-                mpq_init(L2[deg])
+-                mpq_set(L2[deg], (<Rational> L1[deg]).value)
+-            fmpq_poly_set_array_mpq(self._poly, L2, n)
+-            for deg from 0 <= deg < n:
+-                mpq_clear(L2[deg])
+-            sig_free(L2)
++                fmpq_init_set_readonly(q, (<Rational> L1[deg]).value)
++                fmpq_poly_set_coeff_fmpq(self._poly, deg, q)
++                fmpq_clear_readonly(q)
+             sig_off()
+ 
+ #           deg = 0
+@@ -435,6 +432,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         utmost care.
+         """
+         cdef bint do_sig = _do_sig(self._poly)
++        cdef fmpz_t tmpfz
+ 
+         if isinstance(value, int):
+             if do_sig: sig_str("FLINT exception")
+@@ -442,7 +440,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+             if do_sig: sig_off()
+         elif isinstance(value, Integer):
+             if do_sig: sig_str("FLINT exception")
+-            fmpq_poly_set_coeff_mpz(self._poly, n, (<Integer> value).value)
++            fmpz_init_set_readonly(tmpfz, (<Integer> value).value)
++            fmpq_poly_set_coeff_fmpz(self._poly, n, tmpfz)
++            fmpz_clear_readonly(tmpfz)
+             if do_sig: sig_off()
+         elif isinstance(value, Rational):
+             if do_sig: sig_str("FLINT exception")
+@@ -492,7 +492,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef Polynomial_rational_flint f
+         cdef Rational r
+         cdef fmpz_t tmpfz
+-        cdef fmpq_t tmpfq
++        cdef fmpq_t tmpfq, tmpfq1
+         cdef RealBall arb_a, arb_z
+         cdef ComplexBall acb_a, acb_z
+ 
+@@ -508,13 +508,23 @@ cdef class Polynomial_rational_flint(Polynomial):
+             elif isinstance(a, Rational):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpq(r.value, self._poly, (<Rational> a).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> a).value)
++                fmpq_init(tmpfq1)
++                fmpq_poly_evaluate_fmpq(tmpfq1, self._poly, tmpfq)
++                fmpq_get_mpq(r.value, tmpfq1)
++                fmpq_clear(tmpfq1)
++                fmpq_clear_readonly(tmpfq)
+                 sig_off()
+                 return r
+             elif isinstance(a, Integer):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpz(r.value, self._poly, (<Integer> a).value)
++                fmpz_init_set_readonly(tmpfz, (<Integer> a).value)
++                fmpq_init(tmpfq)
++                fmpq_poly_evaluate_fmpz(tmpfq, self._poly, tmpfz)
++                fmpq_get_mpq(r.value, tmpfq)
++                fmpq_clear(tmpfq)
++                fmpz_clear_readonly(tmpfz)
+                 sig_off()
+                 return r
+             elif isinstance(a, int):
+@@ -1321,6 +1331,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         """
+         cdef Polynomial_rational_flint res
+         cdef bint do_sig
++        cdef fmpq_t tmpfq
+ 
+         if right == 0:
+             raise ZeroDivisionError("division by zero polynomial")
+@@ -1331,8 +1342,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+                 do_sig = _do_sig(self._poly)
+ 
+                 if do_sig: sig_str("FLINT exception")
+-                fmpq_poly_scalar_div_mpq(res._poly, self._poly,
+-                                                  (<Rational> QQ(right)).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> QQ(right)).value)
++                fmpq_poly_scalar_div_fmpq(res._poly, self._poly, tmpfq)
++                fmpq_clear_readonly(tmpfq)
+                 if do_sig: sig_off()
+                 return res
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+index 4c480673861..780549af062 100644
+--- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+@@ -658,6 +658,11 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
+             ...
+             NotImplementedError: square free factorization of polynomials over rings with composite characteristic is not implemented
+ 
++        :trac:`20003`::
++
++            sage: P.<x> = GF(7)[]
++            sage: (6*x+3).squarefree_decomposition()
++            (6) * (x + 4)
+         """
+         if not self.base_ring().is_field():
+             raise NotImplementedError("square free factorization of polynomials over rings with composite characteristic is not implemented")
+diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
+index 17859068273..14baa5bc5aa 100644
+--- a/src/sage/rings/real_arb.pyx
++++ b/src/sage/rings/real_arb.pyx
+@@ -898,7 +898,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+             sage: RBF.gamma(5)
+             24.00000000000000
+             sage: RBF.gamma(10**20)
+-            [+/- ...e+1956570552410610660600]
++            [1.932849514310098...+1956570551809674817225 +/- ...]
+             sage: RBF.gamma(1/3)
+             [2.678938534707747 +/- ...e-16]
+             sage: RBF.gamma(-5)
+@@ -1102,7 +1102,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+              15.00000000000000,
+              48.00000000000000]
+             sage: RBF.double_factorial(2**20)
+-            [1.4483729903e+2928836 +/- ...e+2928825]
++            [1.448372990...e+2928836 +/- ...]
+             sage: RBF.double_factorial(2**1000)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/schemes/plane_conics/con_rational_function_field.py b/src/sage/schemes/plane_conics/con_rational_function_field.py
+index 1b3f0ac412a..485c9c71be3 100644
+--- a/src/sage/schemes/plane_conics/con_rational_function_field.py
++++ b/src/sage/schemes/plane_conics/con_rational_function_field.py
+@@ -198,38 +198,6 @@ def has_rational_point(self, point=False, algorithm='default',
+             Fraction Field of Univariate Polynomial Ring in u over Rational
+             Field with modulus v^2 - u^3 - 1
+ 
+-        ``has_rational_point`` fails for some conics over function fields
+-        over finite fields, due to :trac:`20003`::
+-
+-            sage: K.<t> = PolynomialRing(GF(7))
+-            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
+-            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
+-            sage: C.has_rational_point()
+-            Traceback (most recent call last):
+-            ...
+-            TypeError: self (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (-t^3 + 3*t^2 - 2*t - 2)/(t + 3)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (t^2 + 3*t + 3)*x*y + (-2*t^2 - 2)*y^2 + (-t^2 + 3*t + 2)*x*z + (-3*t + 3)*y*z + (-3*t^2 + t - 2)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x + (2*t - 2)/(t + 3)*y + (3*t^4 + 2*t^3 - 2*t^2 - 2*t + 3)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z
+-                     : y + (-t^3 - t^2 + 3*t - 1)/(t^3 - 3*t^2 + 2*t + 2)*z : z))
+-            domain must equal right (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^3 - t^2 + 3*t + 3)*x^2 + (t - 3)*y^2 + (-t^7 + 2*t^5 + t^4 + 2*t^3 + 3*t^2 - t - 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    -2/(t^3 - 3*t^2 + 2*t + 2)*x^2 + 1/(t^3 + 3*t^2 - 2*t + 1)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^9 - 2*t^8 + t^7 - t^6 + 3*t^5 - 3*t^3 + t^2 - 2*t + 3)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    ((t^3 - 3*t^2 + 2*t + 2)*x : (t^2 - 2)*y : (t^5 - 3*t^4 + t^2 + 3*t + 3)*z))
+-            codomain
+-
+-
+-
+         TESTS::
+ 
+             sage: K.<t> = FractionField(PolynomialRing(QQ, 't'))
+@@ -250,6 +218,16 @@ def has_rational_point(self, point=False, algorithm='default',
+             sage: C.has_rational_point(point = True) # long time (4 seconds)
+             (True,
+              ((-2/117*t^8 + 304/1053*t^7 + 40/117*t^6 - 1/27*t^5 - 110/351*t^4 - 2/195*t^3 + 11/351*t^2 + 1/117)/(t^4 + 2/39*t^3 + 4/117*t^2 + 2/39*t + 14/39) : -5/3*t^4 + 19*t^3 : 1))
++
++        ``has_rational_point`` used to fail for some conics over function fields
++        over finite fields, due to :trac:`20003`::
++
++            sage: K.<t> = PolynomialRing(GF(7))
++            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
++            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
++            sage: C.has_rational_point()
++            True
++
+         """
+         from .constructor import Conic
+ 
+diff --git a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+index a591cb4cd7c..a90f2050c59 100644
+--- a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
++++ b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+@@ -20,6 +20,7 @@
+ #include "utils.h"
+ 
+ #include "gmp.h"
++#include "flint/fmpz_poly.h"
+ #include "flint/fmpq_poly.h"
+ #include "flint/fmpq.h"
+ 
+@@ -63,7 +64,7 @@ static ex chebyt_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+@@ -122,7 +123,7 @@ static ex chebyu_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+diff --git a/src/sage/symbolic/ginac/useries.cpp b/src/sage/symbolic/ginac/useries.cpp
+index 40fbd7ab360..b9a8b867648 100644
+--- a/src/sage/symbolic/ginac/useries.cpp
++++ b/src/sage/symbolic/ginac/useries.cpp
+@@ -467,10 +467,17 @@ void add::useries(flint_series_t& fp, int order) const
+                 fmpq_poly_set_ui(fp.ft, 0);
+         else if (oc.is_long())
+                 fmpq_poly_set_si(fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ 
+         for (const auto & elem : seq) {
+ 		const ex& t = recombine_pair_to_ex(elem);
+@@ -505,10 +512,17 @@ void mul::useries(flint_series_t& fp, int order) const
+ 
+         if (oc.is_long())
+                 fmpq_poly_scalar_mul_si(fp.ft, fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_scalar_mul_mpz(fp.ft, fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_scalar_mul_mpq(fp.ft, fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_scalar_mul_fmpz(fp.ft, fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp.ft, fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ void power::useries(flint_series_t& fp, int order) const
+@@ -563,7 +577,10 @@ void power::useries(flint_series_t& fp, int order) const
+                 }
+                 check_poly_ccoeff_one(fp1);
+                 fmpq_poly_log_series(fp1.ft, fp1.ft, order);
+-                fmpq_poly_scalar_mul_mpq(fp1.ft, fp1.ft, nexp.as_mpq());
++                fmpq_t tmp;
++                fmpq_init_set_readonly(tmp, nexp.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp1.ft, fp1.ft, tmp);
++                fmpq_clear_readonly(tmp);
+                 fmpq_poly_exp_series(fp.ft, fp1.ft, order);
+                 return;
+         }
+@@ -608,10 +625,17 @@ void numeric::useries(flint_series_t& fp, int order) const
+ {
+         if (is_long())
+                 fmpq_poly_set_si(fp.ft, to_long());
+-        else if (is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, as_mpq());
++        else if (is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ } // namespace GiNaC
+diff --git a/src/sage_setup/library_order.py b/src/sage_setup/library_order.py
+index f40690f8d22..9ae0d2579a7 100644
+--- a/src/sage_setup/library_order.py
++++ b/src/sage_setup/library_order.py
+@@ -16,17 +16,12 @@
+ 
+ aliases = cython_aliases(required_modules=(), optional_modules=modules)
+ 
+-if "ARB_LIBRARY" in aliases:
+-    arb_dylib_names = [aliases["ARB_LIBRARY"]]
+-else:
+-    arb_dylib_names = []
+-
+ library_order_list = aliases.get("SINGULAR_LIBRARIES", []) + [
+     "giac", "intl", "curl",
+     "ec", "ecm"
+ ] + aliases.get("LINBOX_LIBRARIES", []) + aliases.get("FFLASFFPACK_LIBRARIES", []) + aliases.get("GSL_LIBRARIES", []) + [
+     "pari", "flint", "ecl", "glpk", "ppl",
+-] + arb_dylib_names + [
++] + [
+     "mpfi", "mpfr", "mpc", "ntl", "gmp", "gmpxx",
+     "brial",
+     "brial_groebner",
diff --git a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch b/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
deleted file mode 100644
index 7c55bce6e9bb4..0000000000000
--- a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
+++ /dev/null
@@ -1,221 +0,0 @@
-diff --git a/build/pkgs/singular/checksums.ini b/build/pkgs/singular/checksums.ini
-index 313463d2fea..1101fc55700 100644
---- a/build/pkgs/singular/checksums.ini
-+++ b/build/pkgs/singular/checksums.ini
-@@ -1,5 +1,5 @@
- tarball=singular-VERSION.tar.gz
--sha1=28bb3ee97ef48d04dfa96de182fd93eebe08426c
--md5=fc0a4f5720dadba45a52ee94324ce00c
--cksum=1573851737
--upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-1/singular-VERSION.tar.gz
-+sha1=df1997f412580f2073295aba569bb955ad227317
-+md5=50349213e206a18cdaa1bc410dde7ea4
-+cksum=376854707
-+upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-2/singular-VERSION.tar.gz
-diff --git a/build/pkgs/singular/package-version.txt b/build/pkgs/singular/package-version.txt
-index 66e2bede53a..9f1bf008217 100644
---- a/build/pkgs/singular/package-version.txt
-+++ b/build/pkgs/singular/package-version.txt
-@@ -1 +1 @@
--4.3.1p3
-+4.3.2p7
-diff --git a/build/pkgs/singular/spkg-configure.m4 b/build/pkgs/singular/spkg-configure.m4
-index 6a85631f624..f7621ec5fa1 100644
---- a/build/pkgs/singular/spkg-configure.m4
-+++ b/build/pkgs/singular/spkg-configure.m4
-@@ -6,14 +6,27 @@ SAGE_SPKG_CONFIGURE([singular], [
-     AS_IF([test -z "${SINGULAR_BIN}"], [sage_spkg_install_singular=yes], [
-       dnl Use pkg-config to ensure that Singular is new enough.
-       PKG_CHECK_MODULES([SINGULAR], [Singular >= 4.2.1], [
--       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)
--       ], [
--       AC_MSG_RESULT(no)
--       sage_spkg_install_singular=yes
--       ]
--      )], [
-+        AC_MSG_CHECKING([whether Singular is built with FLINT])
-+        AC_COMPILE_IFELSE([
-+          AC_LANG_PROGRAM([
-+            #include <singular/singularconfig.h>
-+            #if !defined(HAVE_FLINT)
-+            #  error "Need Singular compiled with FLINT"
-+          ], [])
-+        ], [
-+          AC_MSG_RESULT([yes])
-+          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)
-+          ], [
-+            AC_MSG_RESULT(no)
-+            sage_spkg_install_singular=yes
-+          ])
-+        ], [
-+          AC_MSG_RESULT([no])
-+          sage_spkg_install_singular=yes
-+        ])
-+      ], [
-       dnl pkg-config version check failed
-       sage_spkg_install_singular=yes
-       ])
-diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py
-index b15cc1c602c..4b5c76e2bfa 100644
---- a/src/sage/interfaces/singular.py
-+++ b/src/sage/interfaces/singular.py
-@@ -604,8 +604,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: i = singular.ideal(['x^2','y^2','z^2'])
-             sage: s = i.std()
-             sage: singular.eval('hilb(%s)'%(s.name()))
--            '// 1 t^0\n// -3 t^2\n// 3 t^4\n// -1 t^6\n\n// 1 t^0\n//
--            3 t^1\n// 3 t^2\n// 1 t^3\n// dimension (affine) = 0\n//
-+            '...// dimension (affine) = 0\n//
-             degree (affine) = 8'
- 
-         ::
-@@ -613,15 +612,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: from sage.misc.verbose import set_verbose
-             sage: set_verbose(1)
-             sage: o = singular.eval('hilb(%s)'%(s.name()))
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
- 
-         This is mainly useful if this method is called implicitly. Because
-@@ -631,15 +622,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-         ::
- 
-             sage: o = s.hilb()
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
-             // ** right side is not a datum, assignment ignored
-             ...
-diff --git a/src/sage/libs/singular/function.pyx b/src/sage/libs/singular/function.pyx
-index f40346d1fd0..c597c63aafe 100644
---- a/src/sage/libs/singular/function.pyx
-+++ b/src/sage/libs/singular/function.pyx
-@@ -1241,32 +1241,22 @@ cdef class SingularFunction(SageObject):
-             sage: I = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5])
-             sage: I = Ideal(I.groebner_basis())
-             sage: hilb = sage.libs.singular.function_factory.ff.hilb
--            sage: hilb(I) # Singular will print // ** _ is no standard basis
--            // ** _ is no standard basis
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: from sage.misc.sage_ostools import redirection
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I) # Singular will print // ** _ is no standard basis
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            True
- 
-         So we tell Singular that ``I`` is indeed a Groebner basis::
- 
--            sage: hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            False
- 
- 
-         TESTS:
-diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-index 22ada6de947..80352700872 100644
---- a/src/sage/rings/polynomial/multi_polynomial_ideal.py
-+++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-@@ -3132,13 +3132,16 @@ def hilbert_numerator(self, grading=None, algorithm='sage'):
-             sage: I.hilbert_numerator()                                                 # needs sage.rings.number_field
-             -t^5 + 1
- 
--        This example returns a wrong answer due to an integer overflow in Singular::
-+        This example returns a wrong answer in singular < 4.3.2p4 due to an integer overflow::
- 
-             sage: n=4; m=11; P = PolynomialRing(QQ, n*m, "x"); x = P.gens(); M = Matrix(n, x)
-             sage: I = P.ideal(M.minors(2))
-             sage: J = P * [m.lm() for m in I.groebner_basis()]
--            sage: J.hilbert_numerator(algorithm='singular')
--            ...120*t^33 - 3465*t^32 + 48180*t^31 - ...
-+            sage: J.hilbert_numerator(algorithm='singular') # known bug
-+            Traceback (most recent call last):
-+            ....
-+            RuntimeError: error in Singular function call 'hilb':
-+            overflow at t^22
- 
-         Our two algorithms should always agree; not tested until
-         :trac:`33178` is fixed::
-diff --git a/src/sage/sandpiles/sandpile.py b/src/sage/sandpiles/sandpile.py
-index 02d2021b2fb..c8e15e06f05 100644
---- a/src/sage/sandpiles/sandpile.py
-+++ b/src/sage/sandpiles/sandpile.py
-@@ -2493,9 +2493,15 @@ def _set_ideal(self):
-             sage: '_ideal' in S.__dict__
-             True
-         """
-+        from sage.libs.singular.function_factory import ff
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
-         R = self.ring()
--        I = self._unsaturated_ideal._singular_()
--        self._ideal = R.ideal(I.sat(prod(R.gens())._singular_())[1])
-+        I = self._unsaturated_ideal
-+        I_sat_gens = sat(I, prod(R.gens()))[0]
-+        self._ideal = R.ideal(I_sat_gens)
- 
-     def unsaturated_ideal(self):
-         r"""
-diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py
-index e6caf19ba74..afd6484d779 100644
---- a/src/sage/schemes/projective/projective_subscheme.py
-+++ b/src/sage/schemes/projective/projective_subscheme.py
-@@ -1001,7 +1001,10 @@ def dual(self):
-         for i in range(n + 1):
-             J = J + S.ideal(z[-1] * f_S.derivative(z[i]) - z[i + n + 1])
- 
--        sat = ff.elim__lib.sat
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
- 
-         max_ideal = S.ideal(z[n + 1: 2 * n + 2])
-         J_sat_gens = sat(J, max_ideal)[0]
diff --git a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch b/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
deleted file mode 100644
index 6a35ec3836550..0000000000000
--- a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-diff --git a/src/sage/ext/memory.pyx b/src/sage/ext/memory.pyx
-index 1de6dedab82..b95130b19dd 100644
---- a/src/sage/ext/memory.pyx
-+++ b/src/sage/ext/memory.pyx
-@@ -3,14 +3,14 @@ Low-level memory allocation functions
- 
- TESTS:
- 
--Check that a ``MemoryError`` is raised if we try to allocate a
-+Check that an error is raised if we try to allocate a
- ridiculously large integer, see :trac:`15363`::
- 
--    sage: 2^(2^63-3)
--    Traceback (most recent call last):
--    ...
--    OverflowError: exponent must be at most 2147483647         # 32-bit
--    RuntimeError: Aborted                                      # 64-bit
-+    sage: try:
-+    ....:     2^(2^63-3)
-+    ....: except (OverflowError, RuntimeError, FloatingPointError):
-+    ....:     print ('Overflow error')
-+    ...Overflow error
- 
- AUTHORS:
- 
-diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx
-index d5e87626d31..37ed9364845 100644
---- a/src/sage/rings/integer.pyx
-+++ b/src/sage/rings/integer.pyx
-@@ -6654,7 +6654,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
-             sage: try:
-             ....:     print('Possible error output from gmp', flush=True)
-             ....:     1 << (2^60)
--            ....: except (MemoryError, OverflowError, RuntimeError):
-+            ....: except (MemoryError, OverflowError, RuntimeError, FloatingPointError):
-             ....:     pass
-             ....: else:
-             ....:     print("Failed to raise exception")
diff --git a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch b/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
deleted file mode 100644
index 3d2a4bd9cd96f..0000000000000
--- a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
+++ /dev/null
@@ -1,740 +0,0 @@
-diff --git a/src/sage/ext_data/valgrind/valgrind-python.supp b/src/sage/ext_data/valgrind/valgrind-python.supp
-new file mode 100644
-index 00000000000..16aa2858484
---- /dev/null
-+++ b/src/sage/ext_data/valgrind/valgrind-python.supp
-@@ -0,0 +1,480 @@
-+# From the CPython repository with the suppressions for _PyObject_Free
-+# and _PyObject_Realloc enabled. See the upstream suppression file for
-+# details:
-+#
-+# https://github.com/python/cpython/blob/main/Misc/valgrind-python.supp
-+
-+# all tool names: Addrcheck,Memcheck,cachegrind,helgrind,massif
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 8 (x86_64 aka amd64)
-+   Memcheck:Value8
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:address_in_range
-+}
-+
-+#
-+# Leaks (including possible leaks)
-+#    Hmmm, I wonder if this masks some real leaks.  I think it does.
-+#    Will need to fix that.
-+#
-+
-+{
-+   Suppress leaking the GIL after a fork.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_allocate_lock
-+   fun:PyEval_ReInitThreads
-+}
-+
-+{
-+   Suppress leaking the autoTLSkey.  This looks like it shouldn't leak though.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_create_key
-+   fun:_PyGILState_Init
-+   fun:Py_InitializeEx
-+   fun:Py_Main
-+}
-+
-+{
-+   Hmmm, is this a real leak or like the GIL?
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_ReInitTLS
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:realloc
-+   fun:_PyObject_GC_Resize
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_New
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_NewVar
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+#
-+# Non-python specific leaks
-+#
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:calloc
-+   fun:allocate_dtv
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:memalign
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Realloc
-+}
-+
-+###
-+### All the suppressions below are for errors that occur within libraries
-+### that Python uses.  The problems to not appear to be related to Python's
-+### use of the libraries.
-+###
-+
-+{
-+   Generic ubuntu ld problems
-+   Memcheck:Addr8
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+}
-+
-+{
-+   Generic gentoo ld problems
-+   Memcheck:Cond
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_close
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Value8
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   GDBM problems, see test_gdbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   fun:gdbm_open
-+
-+}
-+
-+{
-+   Uninitialised byte(s) false alarm, see bpo-35561
-+   Memcheck:Param
-+   epoll_ctl(event)
-+   fun:epoll_ctl
-+   fun:pyepoll_internal_ctl
-+}
-+
-+{
-+   ZLIB problems, see test_gzip
-+   Memcheck:Cond
-+   obj:/lib/libz.so.1.2.3
-+   obj:/lib/libz.so.1.2.3
-+   fun:deflate
-+}
-+
-+{
-+   Avoid problems w/readline doing a putenv and leaking on exit
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:xmalloc
-+   fun:sh_set_lines_and_columns
-+   fun:_rl_get_screen_size
-+   fun:_rl_init_terminal_io
-+   obj:/lib/libreadline.so.4.3
-+   fun:rl_initialize
-+}
-+
-+# Valgrind emits "Conditional jump or move depends on uninitialised value(s)"
-+# false alarms on GCC builtin strcmp() function. The GCC code is correct.
-+#
-+# Valgrind bug: https://bugs.kde.org/show_bug.cgi?id=264936
-+{
-+   bpo-38118: Valgrind emits false alarm on GCC builtin strcmp()
-+   Memcheck:Cond
-+   fun:PyUnicode_Decode
-+}
-+
-+
-+###
-+### These occur from somewhere within the SSL, when running
-+###  test_socket_sll.  They are too general to leave on by default.
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:memset
-+###}
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:memset
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:MD5_Update
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:MD5_Update
-+###}
-+
-+# Fedora's package "openssl-1.0.1-0.1.beta2.fc17.x86_64" on x86_64
-+# See http://bugs.python.org/issue14171
-+{
-+   openssl 1.0.1 prng 1
-+   Memcheck:Cond
-+   fun:bcmp
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 2
-+   Memcheck:Cond
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 3
-+   Memcheck:Value8
-+   fun:_x86_64_AES_encrypt_compact
-+   fun:AES_encrypt
-+}
-+
-+#
-+# All of these problems come from using test_socket_ssl
-+#
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_bin2bn
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libcrypto.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_set_key_unchecked
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_encrypt2
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BUF_MEM_grow_clean
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:memcpy
-+   fun:ssl3_read_bytes
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:SHA1_Update
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:SHA1_Update
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-+{
-+   wcscmp_false_positive
-+   Memcheck:Addr8
-+   fun:wcscmp
-+   fun:_PyOS_GetOpt
-+   fun:Py_Main
-+   fun:main
-+}
-+
-+# Additional suppressions for the unified decimal tests:
-+{
-+   test_decimal
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_decimal2
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index b40ed64edb5..8c55861c147 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -1576,6 +1576,62 @@ const numeric numeric::div(const numeric &other) const {
-         }
- }
- 
-+
-+// Compute `a^b` as an integer, where a is an integer. Assign to ``res``` if it is integral, or return ``false``.
-+// The nonnegative real root is taken for even denominators. To be used inside numeric::integer_rational_power,
-+// to handle the special case of integral ``a``.
-+bool integer_rational_power_of_mpz(
-+        numeric& res,
-+        const numeric& a,
-+        const numeric& b
-+) {
-+        if (a.t != MPZ)
-+                throw std::runtime_error("integer_rational_power_of_mpz: bad input");
-+        mpz_t z;
-+        mpz_init(z);
-+        mpz_set_ui(z, 0);
-+        int sgn = mpz_sgn(a.v._bigint);
-+        if (mpz_cmp_ui(a.v._bigint, 1) == 0
-+            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
-+                mpz_set_ui(z, 1);
-+        else if (sgn == 0) {
-+                res = *_num0_p;
-+                mpz_clear(z);
-+                return true;
-+        }
-+        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1)) {
-+                mpz_clear(z);
-+                return false;
-+        } else {
-+                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-+                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat))) {
-+                        // too big to take roots/powers
-+                        mpz_clear(z);
-+                        return false;
-+                }
-+                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
-+                        if (mpz_perfect_square_p(a.v._bigint)) {
-+                                mpz_sqrt(z, a.v._bigint);
-+                        } else {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                else {
-+                        bool exact = mpz_root(z, a.v._bigint,
-+                                              mpz_get_ui(mpq_denref(b.v._bigrat)));
-+                        if (not exact) {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
-+        }
-+        res = numeric(z);   // transfers ownership, no mpz_clear
-+        return true;
-+}
-+
-+
- // Compute `a^b` as an integer, if it is integral, or return ``false``.
- // The nonnegative real root is taken for even denominators.
- bool numeric::integer_rational_power(numeric& res,
-@@ -1598,13 +1654,12 @@ bool numeric::integer_rational_power(numeric& res,
-                 if (a.v._long < 0
-                     and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
-                         return false;
--                long z;
-                 if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-                     or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
-                 // too big to take roots/powers
-                         return false;
-                 if (b.is_equal(*_num1_2_p)) {
--                        z = std::lround(std::sqrt(a.v._long));
-+                        long z = std::lround(std::sqrt(a.v._long));
-                         if (a.v._long == z*z) {
-                                 res = numeric(z);
-                                 return true;
-@@ -1613,44 +1668,11 @@ bool numeric::integer_rational_power(numeric& res,
-                 }
-                 return integer_rational_power(res, a.to_bigint(), b);
-         }
--        if (a.t != MPZ)
--                throw std::runtime_error("integer_rational_power: bad input");
--        int sgn = mpz_sgn(a.v._bigint);
--        mpz_t z;
--        mpz_init(z);
--        mpz_set_ui(z, 0);
--        if (mpz_cmp_ui(a.v._bigint, 1) == 0
--            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
--                mpz_set_ui(z, 1);
--        else if (sgn == 0) {
--                res = *_num0_p;
--                return true;
--        }
--        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
--                return false;
--        else {
--                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
--                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
--                // too big to take roots/powers
--                        return false;
--                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
--                        if (mpz_perfect_square_p(a.v._bigint))
--                                mpz_sqrt(z, a.v._bigint);
--                        else
--                                return false;
--                }
--                else {
--                        bool exact = mpz_root(z, a.v._bigint,
--                                        mpz_get_ui(mpq_denref(b.v._bigrat)));
--                        if (not exact)
--                                return false;
--                }
--                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
--        }
--        res = numeric(z);
--        return true;
-+        // otherwise: a is integer
-+        return integer_rational_power_of_mpz(res, a, b);
- }
- 
-+
- // for a^b return c,d such that a^b = c*d^b
- // only for MPZ/MPQ base and MPQ exponent
- void rational_power_parts(const numeric& a_orig, const numeric& b_orig,
-diff --git a/src/sage/tests/memcheck/__init__.py b/src/sage/tests/memcheck/__init__.py
-new file mode 100644
-index 00000000000..e69de29bb2d
-diff --git a/src/sage/tests/memcheck/run_tests.py b/src/sage/tests/memcheck/run_tests.py
-new file mode 100644
-index 00000000000..6ff4503a81b
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests.py
-@@ -0,0 +1,24 @@
-+import types
-+
-+
-+def run_tests() -> None:
-+    """
-+    Run all memcheck tests
-+    """
-+    from sage.tests.memcheck import symbolic_expression
-+    run_tests_in_module(symbolic_expression)
-+
-+
-+def run_tests_in_module(mod: types.ModuleType) -> None:
-+    """
-+    Run all memcheck tests in the given module
-+    """
-+    for entry in dir(mod):
-+        if not entry.startswith('test_'):
-+            continue
-+        test_func = getattr(mod, entry)
-+        test_func()
-+
-+
-+if __name__ == '__main__':
-+    run_tests()
-diff --git a/src/sage/tests/memcheck/run_tests_in_valgrind.py b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-new file mode 100644
-index 00000000000..df5ad0e92b2
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-@@ -0,0 +1,35 @@
-+"""
-+Launch valgrind and run the memory leak tests
-+
-+
-+From the commandline, run
-+
-+    sage -python -m sage.tests.memcheck.run_tests_in_valgrind
-+
-+to launch valgrind and execute the memory leak tests. Requires valgrind
-+to be installed. Alternatively, run as a unit test:
-+
-+    sage: from sage.tests.memcheck.run_tests_in_valgrind import run_tests_in_valgrind
-+    sage: run_tests_in_valgrind()    # optional - valgrind
-+"""
-+
-+import subprocess
-+
-+
-+def run_tests_in_valgrind() -> None:
-+    """
-+    Run the sage.tests.memcheck.run_tests module inside valgrind
-+    """
-+    subprocess.check_call([
-+        'valgrind',
-+        '--suppressions=src/sage/ext_data/valgrind/valgrind-python.supp',
-+        '--show-possibly-lost=no',
-+        '--show-reachable=no',
-+        './venv/bin/python',
-+        '-m',
-+        'sage.tests.memcheck.run_tests'
-+    ])
-+
-+
-+if __name__ == '__main__':
-+    run_tests_in_valgrind()
-diff --git a/src/sage/tests/memcheck/symbolic_expression.py b/src/sage/tests/memcheck/symbolic_expression.py
-new file mode 100644
-index 00000000000..52182fbe62d
---- /dev/null
-+++ b/src/sage/tests/memcheck/symbolic_expression.py
-@@ -0,0 +1,11 @@
-+from sage.tests.memcheck.verify_no_leak import verify_no_leak
-+
-+
-+def test_sqrt_sqrt_2() -> None:
-+    from sage.misc.functional import sqrt
-+    T2 = sqrt(2)
-+
-+    def sqrt_T2() -> None:
-+        sqrt(T2)
-+
-+    verify_no_leak(sqrt_T2)
-diff --git a/src/sage/tests/memcheck/verify_no_leak.py b/src/sage/tests/memcheck/verify_no_leak.py
-new file mode 100644
-index 00000000000..89ca90cf89c
---- /dev/null
-+++ b/src/sage/tests/memcheck/verify_no_leak.py
-@@ -0,0 +1,27 @@
-+from typing import Tuple, Sequence, List, Callable, Any
-+import valgrind
-+
-+
-+def verify_no_leak(callback: Callable[[], Any],
-+                   repeat: int = 10000,
-+                   fuzzy: int = 10,
-+                   ) -> None:
-+    """
-+    Verify that the callback does not generate new definitely lost blocks
-+
-+    Raises an assertion if the callback leaks memory
-+    """
-+    callback()   # warm_up
-+    initial_blocks = (0, 0, 0, 0)
-+    valgrind.memcheck_do_leak_check()
-+    initial_blocks = valgrind.memcheck_count_leak_blocks()
-+    for _ in range(repeat):
-+        callback()
-+    valgrind.memcheck_do_leak_check()
-+    leak_blocks = valgrind.memcheck_count_leak_blocks()
-+    leak = leak_blocks[0] - initial_blocks[0]
-+    if leak < repeat - fuzzy:
-+        return  # callback did not leak at least once per call
-+    blocks = round(leak / repeat, 2)
-+    message = f'{callback} leaked {blocks} block on average ({repeat} iterations)'
-+    raise AssertionError(message)
diff --git a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch b/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
deleted file mode 100644
index 684b62affaf5a..0000000000000
--- a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx
-index 8f46570313d..a8e73e57b52 100644
---- a/src/sage/libs/ecl.pyx
-+++ b/src/sage/libs/ecl.pyx
-@@ -563,15 +563,15 @@ cdef class EclObject:
-     Floats in Python are IEEE double, which LISP has as well. However,
-     the printing of floating point types in LISP depends on settings::
- 
--        sage: a = EclObject(float(10^40))
-+        sage: a = EclObject(float(1.234e40))
-         sage: ecl_eval("(setf *read-default-float-format* 'single-float)")
-         <ECL: SINGLE-FLOAT>
-         sage: a
--        <ECL: 1.d40>
-+        <ECL: 1.234d40>
-         sage: ecl_eval("(setf *read-default-float-format* 'double-float)")
-         <ECL: DOUBLE-FLOAT>
-         sage: a
--        <ECL: 1.e40>
-+        <ECL: 1.234e40>
- 
-     Tuples are translated to dotted lists::
- 
-diff --git a/src/sage/libs/eclsig.h b/src/sage/libs/eclsig.h
-index e249ccf6874..005b2d99d0b 100644
---- a/src/sage/libs/eclsig.h
-+++ b/src/sage/libs/eclsig.h
-@@ -45,7 +45,11 @@ static inline void ecl_sig_off(void)
-     sig_off();
- }
- 
-+#if ECL_VERSION_NUMBER < 230909
- #define ecl_mpz_from_bignum(obj) ((obj)->big.big_num)
-+#else
-+#define ecl_mpz_from_bignum(obj) ecl_bignum(obj)
-+#endif
- 
- cl_object ecl_bignum_from_mpz(mpz_t num)
- {
diff --git a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch b/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
deleted file mode 100644
index e858f2fd4a445..0000000000000
--- a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
-index 59f10f6b13f..adcccff059b 100644
---- a/src/sage/plot/graphics.py
-+++ b/src/sage/plot/graphics.py
-@@ -36,6 +36,7 @@
- # ****************************************************************************
- 
- import os
-+from numbers import Integral
- from collections.abc import Iterable
- from math import isnan
- import sage.misc.verbose
-@@ -2874,6 +2875,11 @@ def matplotlib(self, filename=None,
-                 weight=lopts.pop('font_weight', 'medium'),
-                 variant=lopts.pop('font_variant', 'normal'))
-             color = lopts.pop('back_color', 'white')
-+            if 'loc' in lopts:
-+                loc = lopts['loc']
-+                if isinstance(loc, Integral):
-+                    # matplotlib 3.8 doesn't support sage integers
-+                    lopts['loc'] = int(loc)
-             leg = subplot.legend(prop=prop, **lopts)
-             if leg is None:
-                 from warnings import warn
diff --git a/srcpkgs/sagemath/patches/36403-00pre.patch b/srcpkgs/sagemath/patches/36403-00pre.patch
deleted file mode 100644
index 060404d5430de..0000000000000
--- a/srcpkgs/sagemath/patches/36403-00pre.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-Minor patch so that #36403 applies cleanly over sagemath 10.1
-
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 2053bca80c3..86aca6e00d8 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15123,7 +15302,8 @@ cdef class Matrix(Matrix1):
-             sage: N.conjugate_transpose()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object has no attribute 'conjugate'
-+            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
-+            has no attribute 'conjugate'
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 525ea5aa934..52afed49d64 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -55,7 +55,7 @@ cdef class AttributeErrorMessage:
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-         sage: x = polygen(ZZ, 'x')
--        sage: QQ[x].gen().bla                                                           # optional - sage.libs.flint
-+        sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
diff --git a/srcpkgs/sagemath/patches/36407-python_3.12.patch b/srcpkgs/sagemath/patches/36407-python_3.12.patch
deleted file mode 100644
index c75c275c30764..0000000000000
--- a/srcpkgs/sagemath/patches/36407-python_3.12.patch
+++ /dev/null
@@ -1,1744 +0,0 @@
-diff --git a/build/sage_bootstrap/package.py b/build/sage_bootstrap/package.py
-index 15b342223c4..eb82f96e05f 100644
---- a/build/sage_bootstrap/package.py
-+++ b/build/sage_bootstrap/package.py
-@@ -303,7 +303,7 @@ def _init_checksum(self):
-         # Name of the directory containing the checksums.ini file
-         self.__tarball_package_name = os.path.realpath(checksums_ini).split(os.sep)[-2]
- 
--    VERSION_PATCHLEVEL = re.compile('(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
-+    VERSION_PATCHLEVEL = re.compile(r'(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
- 
-     def _init_version(self):
-         try:
-diff --git a/src/doc/en/thematic_tutorials/coercion_and_categories.rst b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-index bb23331c151..7f5712caea7 100644
---- a/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-+++ b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-@@ -1223,7 +1223,7 @@ However, only "elementary" construction functors have a rank::
-     sage: (Fract*Poly).rank
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'
-+    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'...
- 
- .. end of output
- 
-diff --git a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-index 553a946c4d8..3cd71a9bad4 100644
---- a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-+++ b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-@@ -318,7 +318,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: e.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'...
- 
-         sage: id4 = SymmetricGroup(4).one()
-         sage: type(id4)
-@@ -326,7 +326,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: id4.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'
-+        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'...
- 
- .. note::
- 
-diff --git a/src/sage/algebras/cluster_algebra.py b/src/sage/algebras/cluster_algebra.py
-index b72d2a12976..14669dfed5c 100644
---- a/src/sage/algebras/cluster_algebra.py
-+++ b/src/sage/algebras/cluster_algebra.py
-@@ -167,7 +167,7 @@
-     sage: (t*s).g_vector()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'
-+    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'...
-     sage: A = ClusterAlgebra(['A', 2], principal_coefficients=True)
-     sage: A.explore_to_depth(infinity)
-     sage: s = A.cluster_variable((0, -1)); s
-diff --git a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-index e4a91723558..343ee8a66f9 100644
---- a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-+++ b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-@@ -109,7 +109,7 @@ class WeylLieConformalAlgebra(LieConformalAlgebraWithStructureCoefficients):
-         sage: alpha0.degree()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'
-+        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'...
- 
-     TESTS::
- 
-diff --git a/src/sage/algebras/steenrod/steenrod_algebra.py b/src/sage/algebras/steenrod/steenrod_algebra.py
-index 978a3557a9d..7c4d444f81c 100644
---- a/src/sage/algebras/steenrod/steenrod_algebra.py
-+++ b/src/sage/algebras/steenrod/steenrod_algebra.py
-@@ -1080,7 +1080,7 @@ def homogeneous_component(self, n):
-             sage: a.antipode() # not defined
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'
-+            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'...
-             sage: A(a).antipode() # convert to elt of A, then compute antipode
-             Sq(2,1) + Sq(5)
- 
-diff --git a/src/sage/all__sagemath_repl.py b/src/sage/all__sagemath_repl.py
-index 8d0b43679ca..c31b206bcb8 100644
---- a/src/sage/all__sagemath_repl.py
-+++ b/src/sage/all__sagemath_repl.py
-@@ -79,6 +79,23 @@
-                         message=r"Use setlocale\(\), getencoding\(\) and getlocale\(\) instead",
-                         module='docutils.io')
- 
-+# triggered by dateutil 2.8.2 and sphinx 7.0.1 on Python 3.12
-+# see: https://github.com/dateutil/dateutil/pull/1285
-+# see: https://github.com/sphinx-doc/sphinx/pull/11468
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"datetime.datetime.utcfromtimestamp\(\) is deprecated",
-+                        module='dateutil.tz.tz|sphinx.(builders.gettext|util.i18n)')
-+
-+# triggered on Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"This process.* is multi-threaded, "
-+                                r"use of .*\(\) may lead to deadlocks in the child.")
-+
-+# pickling of itertools is deprecated in Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"Pickle, copy, and deepcopy support will be "
-+                                r"removed from itertools in Python 3.14.")
-+
- 
- from .all__sagemath_objects import *
- from .all__sagemath_environment import *
-diff --git a/src/sage/arith/long.pxd b/src/sage/arith/long.pxd
-index 0031a0ae337..3ea70cef571 100644
---- a/src/sage/arith/long.pxd
-+++ b/src/sage/arith/long.pxd
-@@ -19,6 +19,8 @@ from libc.limits cimport LONG_MIN, LONG_MAX
- from cpython.object cimport Py_SIZE
- from cpython.number cimport PyNumber_Index, PyIndex_Check
- from cpython.longintrepr cimport py_long, PyLong_SHIFT, digit
-+from sage.cpython.pycore_long cimport (
-+    ob_digit, _PyLong_IsNegative, _PyLong_DigitCount)
- 
- from sage.libs.gmp.mpz cimport mpz_fits_slong_p, mpz_get_si
- from sage.rings.integer_fake cimport is_Integer, Integer_AS_MPZ
-@@ -299,8 +301,11 @@ cdef inline bint integer_check_long_py(x, long* value, int* err):
-         return 0
- 
-     # x is a Python "int" (aka PyLongObject or py_long in cython)
--    cdef const digit* D = (<py_long>x).ob_digit
--    cdef Py_ssize_t size = Py_SIZE(x)
-+    cdef const digit* D = ob_digit(x)
-+    cdef Py_ssize_t size = _PyLong_DigitCount(x)
-+
-+    if _PyLong_IsNegative(x):
-+        size = -size
- 
-     # We assume PyLong_SHIFT <= BITS_IN_LONG <= 3 * PyLong_SHIFT.
-     # This is true in all the default configurations:
-diff --git a/src/sage/categories/category.py b/src/sage/categories/category.py
-index 57ef7f4184b..29bce8ee415 100644
---- a/src/sage/categories/category.py
-+++ b/src/sage/categories/category.py
-@@ -2129,7 +2129,7 @@ def _with_axioms(self, axioms):
-             sage: Semigroups().Inverse()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'
-+            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'...
-             sage: Semigroups()._with_axioms(["Inverse"])
-             Category of semigroups
- 
-diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py
-index 5227792e725..4775d4e5bf1 100644
---- a/src/sage/categories/category_with_axiom.py
-+++ b/src/sage/categories/category_with_axiom.py
-@@ -554,7 +554,7 @@ class from the base category class::
-     sage: Magmas.Unital.Associative
-     Traceback (most recent call last):
-     ...
--    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'
-+    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'...
- 
- The purpose of this section is to explain the design of the code
- layout and the rationale for this mismatch.
-@@ -769,7 +769,7 @@ def _(): return LazyImport('sage.categories.rngs', 'Rngs', at_startup=True)
-     sage: Semirings().NoZeroDivisors()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'
-+    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'...
- 
- Concretely, this is to be implemented by defining the new axiom in the
- (``SubcategoryMethods`` nested class of the) appropriate category with
-diff --git a/src/sage/categories/enumerated_sets.py b/src/sage/categories/enumerated_sets.py
-index a8bea53f907..b0ea05d0563 100644
---- a/src/sage/categories/enumerated_sets.py
-+++ b/src/sage/categories/enumerated_sets.py
-@@ -610,7 +610,7 @@ def _list_from_iterator(self):
-                 sage: (QQ^2).list()  # indirect test                                    # needs sage.modules
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'
-+                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'...
- 
-             Here we test that for an object that does not know whether it
-             is finite or not.  Calling ``x.list()`` simply tries to create
-@@ -622,11 +622,11 @@ def _list_from_iterator(self):
-                 sage: Q.is_finite()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'...
-                 sage: Q.list()   # indirect test
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'...
- 
-             Here is another example. We artificially create a version of
-             the ring of integers that does not know whether it is finite
-diff --git a/src/sage/categories/examples/sets_cat.py b/src/sage/categories/examples/sets_cat.py
-index e0853d63f94..fbadb9ca405 100644
---- a/src/sage/categories/examples/sets_cat.py
-+++ b/src/sage/categories/examples/sets_cat.py
-@@ -619,7 +619,7 @@ class PrimeNumbers_Facade(PrimeNumbers_Abstract):
-         sage: pf.next()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'...
- 
-     unlike in the other implementations::
- 
-diff --git a/src/sage/categories/homset.py b/src/sage/categories/homset.py
-index 22ba9d047fc..2a8b8aeedeb 100644
---- a/src/sage/categories/homset.py
-+++ b/src/sage/categories/homset.py
-@@ -632,7 +632,7 @@ def __init__(self, X, Y, category=None, base=None, check=True):
-             sage: H = MyHomset(X, Y, category=1, base = ZZ, check = False)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'...
-             sage: P.<t> = ZZ[]
-             sage: f = P.hom([1/2*t])
-             sage: f.parent().domain()
-diff --git a/src/sage/categories/modules_with_basis.py b/src/sage/categories/modules_with_basis.py
-index e97bf851388..c4933d0657f 100644
---- a/src/sage/categories/modules_with_basis.py
-+++ b/src/sage/categories/modules_with_basis.py
-@@ -2456,7 +2456,7 @@ def apply_multilinear_morphism(self, f, codomain=None):
-                     sage: tensor([a, b]).apply_multilinear_morphism(f)                  # needs sage.modules
-                     Traceback (most recent call last):
-                     ...
--                    AttributeError: 'int' object has no attribute 'parent'
-+                    AttributeError: 'int' object has no attribute 'parent'...
- 
-                 Here we consider an example where the codomain is a
-                 module with basis with a different base ring::
-diff --git a/src/sage/categories/monoids.py b/src/sage/categories/monoids.py
-index 38dd7248c9d..28474bd17b6 100644
---- a/src/sage/categories/monoids.py
-+++ b/src/sage/categories/monoids.py
-@@ -556,7 +556,7 @@ def algebra_generators(self):
-                     Traceback (most recent call last):
-                     ...
-                     AttributeError: 'IntegerModMonoid_with_category' object
--                    has no attribute 'monoid_generators'
-+                    has no attribute 'monoid_generators'...
-                     sage: Z12.semigroup_generators()
-                     Family (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
-                     sage: Z12.algebra(QQ).algebra_generators()                          # needs sage.modules
-diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py
-index 494e8154c80..ec5120e41e6 100644
---- a/src/sage/combinat/finite_state_machine.py
-+++ b/src/sage/combinat/finite_state_machine.py
-@@ -1835,7 +1835,7 @@ def __getstate__(self):
-             sage: T1.transitions
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'FSMState' object has no attribute 'transitions'
-+            AttributeError: 'FSMState' object has no attribute 'transitions'...
-             sage: A1 = loads(dumps(A))
-             sage: all(A.state(j) == A1.state(j) for j in [0, 1])
-             True
-diff --git a/src/sage/combinat/growth.py b/src/sage/combinat/growth.py
-index cf8d18c1764..766eea37917 100644
---- a/src/sage/combinat/growth.py
-+++ b/src/sage/combinat/growth.py
-@@ -371,7 +371,7 @@
-     sage: GrowthDiagram(RulePascal(), [3,1,2])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'RulePascal' object has no attribute 'forward_rule'
-+    AttributeError: 'RulePascal' object has no attribute 'forward_rule'...
- 
- We now re-implement the rule where we provide the dual graded graphs::
- 
-diff --git a/src/sage/combinat/integer_lists/lists.py b/src/sage/combinat/integer_lists/lists.py
-index 5143e5cb5e8..9117a6076f7 100644
---- a/src/sage/combinat/integer_lists/lists.py
-+++ b/src/sage/combinat/integer_lists/lists.py
-@@ -261,7 +261,7 @@ def __getattr__(self, name):
-             sage: L.foo
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'foo'
-+            AttributeError: 'NoneType' object has no attribute 'foo'...
-         """
-         return getattr(self.backend, name)
- 
-diff --git a/src/sage/combinat/posets/posets.py b/src/sage/combinat/posets/posets.py
-index c31597c72e9..c74bfc67cee 100644
---- a/src/sage/combinat/posets/posets.py
-+++ b/src/sage/combinat/posets/posets.py
-@@ -8825,7 +8825,7 @@ def is_induced_subposet(self, other):
-             sage: Poset().is_induced_subposet('junk')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'subposet'
-+            AttributeError: 'str' object has no attribute 'subposet'...
-         """
-         if (not self._is_facade or (isinstance(other, FinitePoset) and
-                                     not other._is_facade)):
-diff --git a/src/sage/cpython/atexit.pyx b/src/sage/cpython/atexit.pyx
-index 961aa348d0a..e5a82735137 100644
---- a/src/sage/cpython/atexit.pyx
-+++ b/src/sage/cpython/atexit.pyx
-@@ -154,6 +154,10 @@ cdef extern from *:
-     #undef _PyGC_FINALIZED
-     #include "internal/pycore_interp.h"
-     #include "internal/pycore_pystate.h"
-+    #if PY_VERSION_HEX >= 0x030c0000
-+    // struct atexit_callback was renamed in 3.12 to atexit_py_callback
-+    #define atexit_callback atexit_py_callback
-+    #endif
-     static atexit_callback ** _atexit_callbacks(PyObject *self) {
-         PyInterpreterState *interp = _PyInterpreterState_GET();
-         struct atexit_state state = interp->atexit;
-diff --git a/src/sage/cpython/debug.pyx b/src/sage/cpython/debug.pyx
-index 986abff2a99..cdaca3a4854 100644
---- a/src/sage/cpython/debug.pyx
-+++ b/src/sage/cpython/debug.pyx
-@@ -78,7 +78,7 @@ def getattr_debug(obj, name, default=_no_default):
- 
-     EXAMPLES::
- 
--        sage: _ = getattr_debug(list, "reverse")
-+        sage: _ = getattr_debug(list, "reverse")  # not tested - broken in python 3.12
-         getattr_debug(obj=<class 'list'>, name='reverse'):
-           type(obj) = <class 'type'>
-           object has __dict__ slot (<class 'dict'>)
-@@ -123,7 +123,7 @@ def getattr_debug(obj, name, default=_no_default):
-         sage: _ = getattr_debug(1, "foo")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'...
-         sage: _ = getattr_debug(1, "foo", "xyz")
-         getattr_debug(obj=1, name='foo'):
-           type(obj) = <class 'sage.rings.integer.Integer'>
-diff --git a/src/sage/cpython/dict_internal.h b/src/sage/cpython/dict_internal.h
-index 42a57bcb468..a5ee35bc198 100644
---- a/src/sage/cpython/dict_internal.h
-+++ b/src/sage/cpython/dict_internal.h
-@@ -169,6 +169,7 @@ dictkeys_set_index(PyDictKeysObject *keys, Py_ssize_t i, Py_ssize_t ix)
- #else   /* Python >= 3.11 */
- 
- #define Py_BUILD_CORE
-+#undef _PyGC_FINALIZED
- #include <internal/pycore_dict.h>
- 
- /************************************************************/
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 52afed49d64..1f49e5230c3 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -53,12 +53,12 @@ cdef class AttributeErrorMessage:
-         sage: 1.bla  #indirect doctest
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'...
-         sage: x = polygen(ZZ, 'x')
-         sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'...
- 
-     ::
- 
-@@ -144,7 +144,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(X, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: x = X()
-         sage: raw_getattr(x, "prop")
-         <property object at ...>
-@@ -173,7 +173,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(Y, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: y = Y()
-         sage: raw_getattr(y, "prop")
-         <property object at ...>
-@@ -278,7 +278,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     The integer ring is a parent, so, lazy attributes work::
- 
-@@ -289,7 +289,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(17, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     In general, descriptors are not yet well supported, because they
-     often do not accept to be cheated with the type of their instance::
-@@ -305,7 +305,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__weakref__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-     This was caught by :trac:`8296` for which we do a couple more tests::
- 
-@@ -314,7 +314,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: 1.__weakref__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-         sage: n = 1
-         sage: ip = get_ipython()                 # not tested: only works in interactive shell
-@@ -329,7 +329,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__call__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'...
- 
-     TESTS:
- 
-@@ -339,14 +339,14 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, type, "__name__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'...
- 
-     Non-strings as "name" are handled gracefully::
- 
-         sage: getattr_from_other_class(1, type, None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute None
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute None...
-     """
-     if not isinstance(cls, type):
-         raise TypeError(f"{cls!r} is not a type")
-diff --git a/src/sage/cpython/pycore_long.h b/src/sage/cpython/pycore_long.h
-new file mode 100644
-index 00000000000..ff1a73d097a
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.h
-@@ -0,0 +1,98 @@
-+#include "Python.h"
-+#include <stdbool.h>
-+
-+#if PY_VERSION_HEX >= 0x030C00A5
-+#define ob_digit(o)  (((PyLongObject*)o)->long_value.ob_digit)
-+#else
-+#define ob_digit(o)  (((PyLongObject*)o)->ob_digit)
-+#endif
-+
-+#if PY_VERSION_HEX >= 0x030C00A7
-+// taken from cpython:Include/internal/pycore_long.h @ 3.12
-+
-+/* Long value tag bits:
-+ * 0-1: Sign bits value = (1-sign), ie. negative=2, positive=0, zero=1.
-+ * 2: Reserved for immortality bit
-+ * 3+ Unsigned digit count
-+ */
-+#define SIGN_MASK 3
-+#define SIGN_ZERO 1
-+#define SIGN_NEGATIVE 2
-+#define NON_SIZE_BITS 3
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_ZERO;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_NEGATIVE;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    assert(PyLong_Check(op));
-+    return op->long_value.lv_tag >> NON_SIZE_BITS;
-+}
-+
-+#define TAG_FROM_SIGN_AND_SIZE(sign, size) ((1 - (sign)) | ((size) << NON_SIZE_BITS))
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+    assert(size >= 0);
-+    assert(-1 <= sign && sign <= 1);
-+    assert(sign != 0 || size == 0);
-+    op->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sign, (size_t)size);
-+}
-+
-+#else
-+// fallback for < 3.12
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) == 0;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) < 0;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) > 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    Py_ssize_t size = Py_SIZE(op);
-+    return size < 0 ? -size : size;
-+}
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION < 9)
-+// The function Py_SET_SIZE is defined starting with python 3.9.
-+    Py_SIZE(o) = size;
-+#else
-+    Py_SET_SIZE(op, sign < 0 ? -size : size);
-+#endif
-+}
-+
-+#endif
-diff --git a/src/sage/cpython/pycore_long.pxd b/src/sage/cpython/pycore_long.pxd
-new file mode 100644
-index 00000000000..41de637ff18
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.pxd
-@@ -0,0 +1,9 @@
-+from cpython.longintrepr cimport py_long, digit
-+
-+cdef extern from "pycore_long.h":
-+    digit* ob_digit(py_long o)
-+    bint _PyLong_IsZero(py_long o)
-+    bint _PyLong_IsNegative(py_long o)
-+    bint _PyLong_IsPositive(py_long o)
-+    Py_ssize_t _PyLong_DigitCount(py_long o)
-+    void _PyLong_SetSignAndDigitCount(py_long o, int sign, Py_ssize_t size)
-diff --git a/src/sage/crypto/classical.py b/src/sage/crypto/classical.py
-index 616dc861652..be899c781e5 100644
---- a/src/sage/crypto/classical.py
-+++ b/src/sage/crypto/classical.py
-@@ -494,7 +494,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: A.rank_by_chi_square("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_chi_square(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -703,7 +703,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: A.rank_by_squared_differences("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_squared_differences(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -2114,7 +2114,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: S.rank_by_chi_square("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_chi_square(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-@@ -2351,7 +2351,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: S.rank_by_squared_differences("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_squared_differences(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/crypto/mq/mpolynomialsystemgenerator.py b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-index 9028dab1d98..4416d9ef7f6 100644
---- a/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-+++ b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-@@ -156,7 +156,7 @@ def sbox(self):
-             sage: msg.sbox()
-             Traceback (most recent call last):
-             ...
--            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'
-+            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'...
-         """
-         return self._sbox
- 
-diff --git a/src/sage/data_structures/bitset.pyx b/src/sage/data_structures/bitset.pyx
-index 446062554c1..d9906b5edd2 100644
---- a/src/sage/data_structures/bitset.pyx
-+++ b/src/sage/data_structures/bitset.pyx
-@@ -967,7 +967,7 @@ cdef class FrozenBitset:
-             sage: None | FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute '_union'
-+            AttributeError: 'NoneType' object has no attribute '_union'...
-         """
-         return self._union(other)
- 
-@@ -1037,7 +1037,7 @@ cdef class FrozenBitset:
-             sage: None & FrozenBitset("101011")
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'intersection'
-+            AttributeError: 'NoneType' object has no attribute 'intersection'...
-         """
-         return self.intersection(other)
- 
-@@ -1106,7 +1106,7 @@ cdef class FrozenBitset:
-             sage: None - FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'difference'
-+            AttributeError: 'NoneType' object has no attribute 'difference'...
-         """
-         return self.difference(other)
- 
-@@ -1179,7 +1179,7 @@ cdef class FrozenBitset:
-             sage: None ^^ FrozenBitset('11111' * 10)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'
-+            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'...
-         """
-         return self.symmetric_difference(other)
- 
-diff --git a/src/sage/doctest/reporting.py b/src/sage/doctest/reporting.py
-index 361fea344c2..a3947c07e01 100644
---- a/src/sage/doctest/reporting.py
-+++ b/src/sage/doctest/reporting.py
-@@ -368,7 +368,7 @@ def report(self, source, timeout, return_code, results, output, pid=None):
-             sage: DTR.report(None, None, None, None, None)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'basename'
-+            AttributeError: 'NoneType' object has no attribute 'basename'...
- 
-         The only-errors mode does not output anything on success::
- 
-diff --git a/src/sage/dynamics/finite_dynamical_system.py b/src/sage/dynamics/finite_dynamical_system.py
-index e5fbf568b7e..4295070615a 100644
---- a/src/sage/dynamics/finite_dynamical_system.py
-+++ b/src/sage/dynamics/finite_dynamical_system.py
-@@ -240,7 +240,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-@@ -252,7 +252,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-diff --git a/src/sage/geometry/cone.py b/src/sage/geometry/cone.py
-index f0a8620011a..53f78a4b7b6 100644
---- a/src/sage/geometry/cone.py
-+++ b/src/sage/geometry/cone.py
-@@ -340,7 +340,7 @@ def Cone(rays, lattice=None, check=True, normalize=True):
-         sage: Cone([(1,0), (0,1)], check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     You can construct different "not" cones: not full-dimensional, not
-     strictly convex, not containing any rays::
-diff --git a/src/sage/geometry/fan.py b/src/sage/geometry/fan.py
-index 258544012fe..3aecc84a55b 100644
---- a/src/sage/geometry/fan.py
-+++ b/src/sage/geometry/fan.py
-@@ -443,7 +443,7 @@ def Fan(cones, rays=None, lattice=None, check=True, normalize=True,
-         sage: P2c = Fan(cones, rays, check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     Yet another way is to use functions :func:`FaceFan` and :func:`NormalFan`
-     to construct fans from :class:`lattice polytopes
-diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-index f0ac1e774a7..f03f0f832ff 100644
---- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-+++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-@@ -351,7 +351,7 @@ cdef class FaceIterator_base(SageObject):
-             sage: FaceIterator_base(2)  # indirect doctest
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'...
-         """
-         cdef int i
-         sig_free(self.structure.atom_rep)
-@@ -1945,7 +1945,8 @@ cdef inline int next_face_loop(iter_t structure) nogil except -1:
-         # The function is not supposed to be called,
-         # just prevent it from crashing.
-         # Actually raising an error here results in a bad branch prediction.
--        return -1
-+        # But return -1 results in a crash with python 3.12
-+        raise StopIteration
- 
-     # Getting ``[faces, n_faces, n_visited_all]`` according to dimension.
-     cdef face_list_t* faces = &structure.new_faces[structure.current_dimension]
-diff --git a/src/sage/geometry/toric_plotter.py b/src/sage/geometry/toric_plotter.py
-index 50b4008eb0f..950e3ba7ff8 100644
---- a/src/sage/geometry/toric_plotter.py
-+++ b/src/sage/geometry/toric_plotter.py
-@@ -706,7 +706,7 @@ def set_rays(self, generators):
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ToricPlotter' object has no attribute 'rays'
-+            AttributeError: 'ToricPlotter' object has no attribute 'rays'...
-             sage: tp.set_rays([(0,1)])
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Graphics object consisting of 2 graphics primitives
-diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
-index d0ec214bb3b..c8098ad578a 100644
---- a/src/sage/groups/matrix_gps/finitely_generated.py
-+++ b/src/sage/groups/matrix_gps/finitely_generated.py
-@@ -268,7 +268,7 @@ def MatrixGroup(*gens, **kwds):
-         sage: SL2C.gens()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'
-+        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'...
-     """
-     if isinstance(gens[-1], dict):   # hack for unpickling
-         kwds.update(gens[-1])
-diff --git a/src/sage/homology/chains.py b/src/sage/homology/chains.py
-index 87c0947c0b0..b9a54940943 100644
---- a/src/sage/homology/chains.py
-+++ b/src/sage/homology/chains.py
-@@ -298,7 +298,7 @@ def is_cycle(self):
-                 sage: chain.is_cocycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -325,7 +325,7 @@ def is_boundary(self):
-                 sage: chain.is_coboundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -539,7 +539,7 @@ def is_cocycle(self):
-                 sage: cochain.is_cycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -566,7 +566,7 @@ def is_coboundary(self):
-                 sage: cochain.is_boundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -604,7 +604,7 @@ def eval(self, other):
-                 sage: z.eval(c) # z is not a cochain
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'...
-                 sage: c.eval(c) # can't evaluate a cochain on a cochain
-                 Traceback (most recent call last):
-                 ...
-diff --git a/src/sage/homology/free_resolution.py b/src/sage/homology/free_resolution.py
-index e3d38de4240..280a479b438 100644
---- a/src/sage/homology/free_resolution.py
-+++ b/src/sage/homology/free_resolution.py
-@@ -275,7 +275,7 @@ def differential(self, i):
-             sage: FreeResolution.differiental(r, 1)
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'FreeResolution' has no attribute 'differiental'
-+            AttributeError: type object 'FreeResolution' has no attribute 'differiental'...
-         """
- 
-     def target(self):
-diff --git a/src/sage/interfaces/magma.py b/src/sage/interfaces/magma.py
-index b7a0ac20d03..529bfbc349b 100644
---- a/src/sage/interfaces/magma.py
-+++ b/src/sage/interfaces/magma.py
-@@ -824,7 +824,7 @@ def _coerce_from_special_method(self, x):
-             sage: magma._coerce_from_special_method('2 + 3')  # optional - magma
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute '_magma_init_'
-+            AttributeError: 'str' object has no attribute '_magma_init_'...
-         """
-         s = x._magma_init_(self)
-         a = self(s)
-diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
-index 58499396d6c..16119d20815 100644
---- a/src/sage/lfunctions/dokchitser.py
-+++ b/src/sage/lfunctions/dokchitser.py
-@@ -418,8 +418,8 @@ def init_coeffs(self, v, cutoff=1,
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
-index bbf289aa21c..e4968866303 100644
---- a/src/sage/lfunctions/pari.py
-+++ b/src/sage/lfunctions/pari.py
-@@ -141,8 +141,8 @@ def init_coeffs(self, v, cutoff=None, w=1):
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
-index 478caf9f9d0..363024ae281 100644
---- a/src/sage/libs/gap/element.pyx
-+++ b/src/sage/libs/gap/element.pyx
-@@ -380,7 +380,7 @@ cdef GapElement make_GapElement(parent, Obj obj):
-         sage: libgap(None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute '_libgap_init_'
-+        AttributeError: 'NoneType' object has no attribute '_libgap_init_'...
-     """
-     cdef GapElement r = GapElement.__new__(GapElement)
-     r._initialize(parent, obj)
-diff --git a/src/sage/libs/gmp/pylong.pxd b/src/sage/libs/gmp/pylong.pxd
-index a73f1da6d6f..84e1bb8cd87 100644
---- a/src/sage/libs/gmp/pylong.pxd
-+++ b/src/sage/libs/gmp/pylong.pxd
-@@ -2,9 +2,10 @@
- Various functions to deal with conversion mpz <-> Python int/long
- """
- 
-+from cpython.longintrepr cimport py_long
- from sage.libs.gmp.types cimport *
- 
- cdef mpz_get_pylong(mpz_srcptr z)
- cdef mpz_get_pyintlong(mpz_srcptr z)
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1
- cdef Py_hash_t mpz_pythonhash(mpz_srcptr z)
-diff --git a/src/sage/libs/gmp/pylong.pyx b/src/sage/libs/gmp/pylong.pyx
-index d5993cca5a5..1a36c29d3fa 100644
---- a/src/sage/libs/gmp/pylong.pyx
-+++ b/src/sage/libs/gmp/pylong.pyx
-@@ -28,6 +28,8 @@ AUTHORS:
- from cpython.object cimport Py_SIZE
- from cpython.long cimport PyLong_FromLong
- from cpython.longintrepr cimport _PyLong_New, py_long, digit, PyLong_SHIFT
-+from sage.cpython.pycore_long cimport (ob_digit, _PyLong_IsNegative,
-+    _PyLong_DigitCount, _PyLong_SetSignAndDigitCount)
- from .mpz cimport *
- 
- cdef extern from *:
-@@ -60,12 +62,9 @@ cdef mpz_get_pylong_large(mpz_srcptr z):
-     """
-     cdef size_t nbits = mpz_sizeinbase(z, 2)
-     cdef size_t pylong_size = (nbits + PyLong_SHIFT - 1) // PyLong_SHIFT
--    L = _PyLong_New(pylong_size)
--    mpz_export(L.ob_digit, NULL,
--            -1, sizeof(digit), 0, PyLong_nails, z)
--    if mpz_sgn(z) < 0:
--        # Set correct size
--        Py_SET_SIZE(L, -pylong_size)
-+    cdef py_long L = _PyLong_New(pylong_size)
-+    mpz_export(ob_digit(L), NULL, -1, sizeof(digit), 0, PyLong_nails, z)
-+    _PyLong_SetSignAndDigitCount(L, mpz_sgn(z), pylong_size)
-     return L
- 
- 
-@@ -88,16 +87,13 @@ cdef mpz_get_pyintlong(mpz_srcptr z):
-     return mpz_get_pylong_large(z)
- 
- 
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1:
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1:
-     """
-     Convert a Python ``long`` `L` to an ``mpz``.
-     """
--    cdef Py_ssize_t pylong_size = Py_SIZE(L)
--    if pylong_size < 0:
--        pylong_size = -pylong_size
--    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails,
--            (<py_long>L).ob_digit)
--    if Py_SIZE(L) < 0:
-+    cdef Py_ssize_t pylong_size = _PyLong_DigitCount(L)
-+    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails, ob_digit(L))
-+    if _PyLong_IsNegative(L):
-         mpz_neg(z, z)
- 
- 
-diff --git a/src/sage/manifolds/calculus_method.py b/src/sage/manifolds/calculus_method.py
-index f5830c0bc45..303dde6cd13 100644
---- a/src/sage/manifolds/calculus_method.py
-+++ b/src/sage/manifolds/calculus_method.py
-@@ -257,7 +257,7 @@ def simplify(self, expression, method=None):
-             sage: cm.simplify(f)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'
-+            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'...
- 
-         In the present case, one should either transform ``f`` to a SymPy
-         object::
-diff --git a/src/sage/manifolds/differentiable/vectorfield_module.py b/src/sage/manifolds/differentiable/vectorfield_module.py
-index d954b5d4839..af4bfb0ceec 100644
---- a/src/sage/manifolds/differentiable/vectorfield_module.py
-+++ b/src/sage/manifolds/differentiable/vectorfield_module.py
-@@ -885,7 +885,7 @@ def tensor(self, *args, **kwds):
-             sage: XM.tensor(XM).tensor(XM.dual().tensor(XM.dual()))
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'
-+            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'...
- 
-         .. SEEALSO::
- 
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 86aca6e00d8..a5f6716e731 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15303,7 +15303,7 @@ cdef class Matrix(Matrix1):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
--            has no attribute 'conjugate'
-+            has no attribute 'conjugate'...
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/matrix/matrix_cyclo_dense.pyx b/src/sage/matrix/matrix_cyclo_dense.pyx
-index f54f3423ded..a49bb6240e6 100644
---- a/src/sage/matrix/matrix_cyclo_dense.pyx
-+++ b/src/sage/matrix/matrix_cyclo_dense.pyx
-@@ -847,7 +847,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense):
-             sage: A.set_mutable()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'
-+            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'...
-             sage: B = A.__copy__()
-             sage: B[0,0] = 20
-             sage: B[0,0]
-diff --git a/src/sage/matrix/matrix_gfpn_dense.pyx b/src/sage/matrix/matrix_gfpn_dense.pyx
-index 4cccf473de1..8e8e4d7336b 100644
---- a/src/sage/matrix/matrix_gfpn_dense.pyx
-+++ b/src/sage/matrix/matrix_gfpn_dense.pyx
-@@ -159,7 +159,7 @@ cdef class FieldConverter_class:
-             sage: C.field_to_fel('foo')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'to_integer'
-+            AttributeError: 'str' object has no attribute 'to_integer'...
-         """
-         return FfFromInt(x.to_integer())
- 
-diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py
-index 6aab58352be..b5e6f52349b 100644
---- a/src/sage/matrix/matrix_space.py
-+++ b/src/sage/matrix/matrix_space.py
-@@ -1619,7 +1619,7 @@ def __getitem__(self, x):
-             sage: MS[2]
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'
-+            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'...
-         """
-         if isinstance(x, (integer.Integer, int)):
-             return self.list()[x]
-diff --git a/src/sage/matroids/lean_matrix.pyx b/src/sage/matroids/lean_matrix.pyx
-index 54c68e637c0..a137cbf70e5 100644
---- a/src/sage/matroids/lean_matrix.pyx
-+++ b/src/sage/matroids/lean_matrix.pyx
-@@ -1,5 +1,4 @@
- # sage.doctest: optional - sage.rings.finite_rings
--# cython: profile=True
- """
- Lean matrices
- 
-diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx
-index 36f563aa433..318c82f2b64 100644
---- a/src/sage/matroids/linear_matroid.pyx
-+++ b/src/sage/matroids/linear_matroid.pyx
-@@ -1134,7 +1134,7 @@ cdef class LinearMatroid(BasisExchangeMatroid):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.matroids.basis_matroid.BasisMatroid' object
--            has no attribute 'base_ring'
-+            has no attribute 'base_ring'...
-             sage: from sage.matroids.advanced import *
-             sage: M4 = BinaryMatroid(Matrix(M1))
-             sage: M5 = LinearMatroid(reduced_matrix=Matrix(GF(2), [[-1, 0, 1],
-diff --git a/src/sage/misc/dev_tools.py b/src/sage/misc/dev_tools.py
-index e7bf176592c..3ece7db2894 100644
---- a/src/sage/misc/dev_tools.py
-+++ b/src/sage/misc/dev_tools.py
-@@ -171,6 +171,7 @@ def load_submodules(module=None, exclude_pattern=None):
-         load sage.geometry.polyhedron.ppl_lattice_polygon... succeeded
-     """
-     from .package_dir import walk_packages
-+    import importlib.util
- 
-     if module is None:
-         import sage
-@@ -194,8 +195,12 @@ def load_submodules(module=None, exclude_pattern=None):
-         try:
-             sys.stdout.write("load %s..." % module_name)
-             sys.stdout.flush()
--            loader = importer.find_module(module_name)
--            loader.load_module(module_name)
-+            # see
-+            # https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
-+            spec = importer.find_spec(module_name)
-+            module = importlib.util.module_from_spec(spec)
-+            sys.modules[module_name] = module
-+            spec.loader.exec_module(module)
-             sys.stdout.write(" succeeded\n")
-         except (ValueError, AttributeError, TypeError, ImportError):
-             # we might get error because of cython code that has been
-diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py
-index c922b8f6f12..03697f08b7c 100644
---- a/src/sage/misc/functional.py
-+++ b/src/sage/misc/functional.py
-@@ -86,7 +86,7 @@ def base_field(x):
-         sage: R.base_field()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'
-+        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'...
-     """
-     try:
-         return x.base_field()
-diff --git a/src/sage/misc/instancedoc.pyx b/src/sage/misc/instancedoc.pyx
-index d8e1e4ac536..44ee70f64ba 100644
---- a/src/sage/misc/instancedoc.pyx
-+++ b/src/sage/misc/instancedoc.pyx
-@@ -256,7 +256,7 @@ cdef class InstanceDocDescriptor:
-             sage: descr.__delete__(obj)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'X' object has no attribute '__doc__'
-+            AttributeError: 'X' object has no attribute '__doc__'...
- 
-             sage: descr.__delete__([])
-             Traceback (most recent call last):
-diff --git a/src/sage/misc/lazy_attribute.pyx b/src/sage/misc/lazy_attribute.pyx
-index bdbec3b3ba1..1f07870b8ec 100644
---- a/src/sage/misc/lazy_attribute.pyx
-+++ b/src/sage/misc/lazy_attribute.pyx
-@@ -441,37 +441,37 @@ class lazy_attribute(_lazy_attribute):
-             sage: B().unimplemented_A # todo: not implemented
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'super' object has no attribute 'unimplemented_A'
-+            AttributeError: 'super' object has no attribute 'unimplemented_A'...
- 
-     We now make some systematic checks::
- 
-         sage: B().unimplemented_A
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: B().unimplemented_B
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: B().unimplemented_AB
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: B().unimplemented_B_implemented_A
-         1
- 
-         sage: C().unimplemented_A()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: C().unimplemented_B()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: C().unimplemented_AB()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: C().unimplemented_B_implemented_A # todo: not implemented
-         1
-     """
-diff --git a/src/sage/misc/object_multiplexer.py b/src/sage/misc/object_multiplexer.py
-index d4e811ef16e..00fd89d6652 100644
---- a/src/sage/misc/object_multiplexer.py
-+++ b/src/sage/misc/object_multiplexer.py
-@@ -85,7 +85,7 @@ def __getattr__(self, name):
-             sage: m.__bork__
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Multiplex' has no attribute '__bork__'
-+            AttributeError: 'Multiplex' has no attribute '__bork__'...
-         """
-         if name.startswith("__"):
-             raise AttributeError("'Multiplex' has no attribute '%s'" % name)
-diff --git a/src/sage/misc/sage_input.py b/src/sage/misc/sage_input.py
-index 66e78ecccbc..00e8d96ee9e 100644
---- a/src/sage/misc/sage_input.py
-+++ b/src/sage/misc/sage_input.py
-@@ -3461,7 +3461,7 @@ def verify_same(a, b):
-         sage: verify_same(1, 1r)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_same(1r, 1)
-         Traceback (most recent call last):
-         ...
-@@ -3525,7 +3525,7 @@ def verify_si_answer(x, answer, preparse):
-         sage: verify_si_answer(1, '1', False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_si_answer(1, 'ZZ(1)', None)
-     """
-     from sage.misc.sage_eval import sage_eval
-diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py
-index f0545be7d81..811afc48755 100644
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -602,7 +602,7 @@ def visit_Num(self, node):
-             On Python 3 negative numbers are parsed first, for some reason, as
-             a UnaryOp node.
-         """
--        return node.n
-+        return node.value
- 
-     def visit_Str(self, node):
-         r"""
-@@ -624,7 +624,7 @@ def visit_Str(self, node):
-             sage: [vis(s) for s in ['"abstract"', "'syntax'", r'''r"tr\ee"''']]
-             ['abstract', 'syntax', 'tr\\ee']
-         """
--        return node.s
-+        return node.value
- 
-     def visit_List(self, node):
-         """
-diff --git a/src/sage/modules/fp_graded/steenrod/module.py b/src/sage/modules/fp_graded/steenrod/module.py
-index 18460b0e9a1..4acfa6b4002 100755
---- a/src/sage/modules/fp_graded/steenrod/module.py
-+++ b/src/sage/modules/fp_graded/steenrod/module.py
-@@ -70,7 +70,7 @@
-     sage: SteenrodFPModule(ZZ, [0])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'
-+    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'...
- 
- AUTHORS:
- 
-diff --git a/src/sage/monoids/trace_monoid.py b/src/sage/monoids/trace_monoid.py
-index 00baa4d14f8..f8176a1e1f2 100644
---- a/src/sage/monoids/trace_monoid.py
-+++ b/src/sage/monoids/trace_monoid.py
-@@ -40,7 +40,6 @@
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from collections import OrderedDict
- from itertools import repeat, chain, product
- 
- from sage.misc.cachefunc import cached_method
-@@ -633,14 +632,14 @@ def _compute_dependence_stack(self, x):
-             sage: x = b*a*d*a*c*b
-             sage: M._compute_dependence_stack(x)
-             ({a, b, c, d},
--             OrderedDict([(a, [False, False, True, True, False]),
--                          (b, [True, False, False, False, True]),
--                          (c, [True, False, False, False]),
--                          (d, [False, False, True, False])]))
-+             {a: [False, False, True, True, False],
-+              b: [True, False, False, False, True],
-+              c: [True, False, False, False],
-+              d: [False, False, True, False]})
-         """
-         independence = self._independence
-         generators_set = set(e for e, _ in x)
--        stacks = OrderedDict(sorted((g, []) for g in generators_set))
-+        stacks = dict(sorted((g, []) for g in generators_set))
-         for generator, times in reversed(list(x)):
-             stacks[generator].extend(repeat(True, times))
-             for other_gen in generators_set:
-diff --git a/src/sage/parallel/map_reduce.py b/src/sage/parallel/map_reduce.py
-index 11e0673ee91..5441943731d 100644
---- a/src/sage/parallel/map_reduce.py
-+++ b/src/sage/parallel/map_reduce.py
-@@ -1234,7 +1234,7 @@ def finish(self):
-             sage: S.print_communication_statistics()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'RESetMPExample' object has no attribute '_stats'
-+            AttributeError: 'RESetMPExample' object has no attribute '_stats'...
- 
-             sage: S.finish()
- 
-diff --git a/src/sage/plot/colors.py b/src/sage/plot/colors.py
-index 8c0db2b3c34..3281199400b 100644
---- a/src/sage/plot/colors.py
-+++ b/src/sage/plot/colors.py
-@@ -1099,7 +1099,7 @@ def __getattr__(self, name):
-             sage: cols.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ColorsDict' has no attribute or colormap punk
-+            AttributeError: 'ColorsDict' has no attribute or colormap punk...
-         """
-         try:
-             return self[name]
-@@ -1599,7 +1599,7 @@ def __getattr__(self, name):
-             sage: maps.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Colormaps' has no attribute or colormap punk
-+            AttributeError: 'Colormaps' has no attribute or colormap punk...
-             sage: maps['punk']
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/rings/asymptotic/asymptotic_ring.py b/src/sage/rings/asymptotic/asymptotic_ring.py
-index b07319382d3..994490e6616 100644
---- a/src/sage/rings/asymptotic/asymptotic_ring.py
-+++ b/src/sage/rings/asymptotic/asymptotic_ring.py
-@@ -1091,7 +1091,7 @@ def monomial_coefficient(self, monomial):
-             sage: O(n).monomial_coefficient(n)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'
-+            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'...
- 
-         The ``monomial`` must be exact::
- 
-diff --git a/src/sage/rings/asymptotic/growth_group.py b/src/sage/rings/asymptotic/growth_group.py
-index 27c14592bca..5be12537d62 100644
---- a/src/sage/rings/asymptotic/growth_group.py
-+++ b/src/sage/rings/asymptotic/growth_group.py
-@@ -1572,7 +1572,7 @@ def variable_names(self):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'GenericGrowthGroup_with_category.element_class' object
--            has no attribute 'is_one'
-+            has no attribute 'is_one'...
-         """
-         if self.is_one():
-             return tuple()
-diff --git a/src/sage/rings/ideal.py b/src/sage/rings/ideal.py
-index d36d9406f32..01c9fa3bf2d 100644
---- a/src/sage/rings/ideal.py
-+++ b/src/sage/rings/ideal.py
-@@ -1553,7 +1553,7 @@ def gcd(self, other):
-             sage: J.gcd(I)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Ideal_generic' object has no attribute 'gcd'
-+            AttributeError: 'Ideal_generic' object has no attribute 'gcd'...
- 
-         Note::
- 
-diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
-index 7fe89197011..8832d27e8ea 100644
---- a/src/sage/rings/number_field/number_field.py
-+++ b/src/sage/rings/number_field/number_field.py
-@@ -3823,7 +3823,7 @@ def primes_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
-         """
-         if degree is not None:
-             degree = ZZ(degree)
-@@ -3917,7 +3917,7 @@ def prime_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
- 
-         """
-         ids = self.primes_above(x, degree)
-@@ -5926,7 +5926,7 @@ def factor(self, n):
-             sage: L.factor(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'...
- 
-         AUTHORS:
- 
-@@ -12698,7 +12698,7 @@ def is_real_place(v):
-         sage: is_real_place(v_fin)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'
-+        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'...
- 
-     """
-     RR = sage.rings.real_mpfr.RealField(53)
-diff --git a/src/sage/rings/padics/generic_nodes.py b/src/sage/rings/padics/generic_nodes.py
-index 7047020edec..b6b514d4005 100644
---- a/src/sage/rings/padics/generic_nodes.py
-+++ b/src/sage/rings/padics/generic_nodes.py
-@@ -740,7 +740,7 @@ def _get_element_class(self, name=None):
-             sage: R._get_element_class("foobar")
-             Traceback (most recent call last):
-             ...
--            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'
-+            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'...
-         """
-         if name is None:
-             return self.Element
-diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx
-index c5a1129aecf..a5b7f937cfe 100644
---- a/src/sage/rings/polynomial/polynomial_element.pyx
-+++ b/src/sage/rings/polynomial/polynomial_element.pyx
-@@ -10793,7 +10793,7 @@ cdef class Polynomial(CommutativePolynomial):
-             sage: (y**2 + x).nth_root(2)
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... has no attribute 'nth_root'
-+            AttributeError: ... has no attribute 'nth_root'...
- 
-         TESTS::
- 
-@@ -11831,7 +11831,7 @@ cdef class Polynomial_generic_dense(Polynomial):
-             sage: int(1) // x  # check that this doesn't segfault
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'int' has no attribute 'base_ring'
-+            AttributeError: type object 'int' has no attribute 'base_ring'...
-         """
-         if have_same_parent(self, right):
-             return (<Polynomial_generic_dense>self)._floordiv_(<Polynomial_generic_dense>right)
-diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-index e372be888ee..aca4f08420f 100644
---- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
-+++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-@@ -2362,7 +2362,7 @@ def field_extension(self, names):
-             sage: F, g, h = S.field_extension('b')                                      # needs sage.rings.finite_rings
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'
-+            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'...
- 
-         Over a finite field, the corresponding field extension is not a
-         number field::
-diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx
-index 5273891a5b0..a6e999b8805 100644
---- a/src/sage/rings/ring.pyx
-+++ b/src/sage/rings/ring.pyx
-@@ -1734,7 +1734,7 @@ cdef class IntegralDomain(CommutativeRing):
-             sage: Z5.is_integrally_closed()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'
-+            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'...
-         """
-         raise NotImplementedError
- 
-diff --git a/src/sage/sat/solvers/satsolver.pyx b/src/sage/sat/solvers/satsolver.pyx
-index c2f41b18f55..1c4ac400cb6 100644
---- a/src/sage/sat/solvers/satsolver.pyx
-+++ b/src/sage/sat/solvers/satsolver.pyx
-@@ -375,10 +375,10 @@ def SAT(solver=None, *args, **kwds):
-         DIMACS Solver: 'kissat -q {input}'
-     """
-     if solver is None:
--        import pkgutil
--        if pkgutil.find_loader('pycryptosat') is not None:
-+        from importlib.util import find_spec
-+        if find_spec('pycryptosat') is not None:
-             solver = "cryptominisat"
--        elif pkgutil.find_loader('pycosat') is not None:
-+        elif find_spec('pycosat') is not None:
-             solver = "picosat"
-         else:
-             solver = "LP"
-diff --git a/src/sage/schemes/toric/morphism.py b/src/sage/schemes/toric/morphism.py
-index 1c8944b6dfc..5d64d632f97 100644
---- a/src/sage/schemes/toric/morphism.py
-+++ b/src/sage/schemes/toric/morphism.py
-@@ -246,7 +246,7 @@
-     Traceback (most recent call last):
-     ...
-     AttributeError: 'SchemeMorphism_fan_toric_variety' object
--    has no attribute 'fiber_generic'
-+    has no attribute 'fiber_generic'...
- 
- Let's use factorization mentioned above::
- 
-diff --git a/src/sage/sets/disjoint_union_enumerated_sets.py b/src/sage/sets/disjoint_union_enumerated_sets.py
-index 3dea567a779..5c5e08612f2 100644
---- a/src/sage/sets/disjoint_union_enumerated_sets.py
-+++ b/src/sage/sets/disjoint_union_enumerated_sets.py
-@@ -597,7 +597,7 @@ def Element(self):
-             sage: U.Element
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'
-+            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'...
-         """
-         if not self._facade:
-             return ElementWrapper
-diff --git a/src/sage/sets/set.py b/src/sage/sets/set.py
-index a1789c61300..112d3d8dc3b 100644
---- a/src/sage/sets/set.py
-+++ b/src/sage/sets/set.py
-@@ -163,7 +163,7 @@ def Set(X=None, category=None):
-         sage: sorted(B.list(), key=repr)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'Set_object_with_category' object has no attribute 'list'
-+        AttributeError: 'Set_object_with_category' object has no attribute 'list'...
-         sage: type(B)
-         <class 'sage.sets.set.Set_object_with_category'>
- 
-diff --git a/src/sage/structure/category_object.pyx b/src/sage/structure/category_object.pyx
-index b6a7eaecb5b..c06933494dc 100644
---- a/src/sage/structure/category_object.pyx
-+++ b/src/sage/structure/category_object.pyx
-@@ -836,7 +836,7 @@ cdef class CategoryObject(SageObject):
-             sage: Sets().example().sadfasdf
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'
-+            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'...
-         """
-         return self.getattr_from_category(name)
- 
-diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx
-index caae7e40ffc..543506e9a74 100644
---- a/src/sage/structure/element.pyx
-+++ b/src/sage/structure/element.pyx
-@@ -219,7 +219,7 @@ the parents::
-     sage: x._add_(x)
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-     sage: x + x
-     Traceback (most recent call last):
-     ...
-@@ -478,13 +478,13 @@ cdef class Element(SageObject):
-             sage: 1.blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'...
-             sage: Semigroups().example().an_element().is_idempotent
-             <bound method LeftZeroSemigroup.Element.is_idempotent of 42>
-             sage: Semigroups().example().an_element().blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'
-+            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'...
-         """
-         return self.getattr_from_category(name)
- 
-@@ -1269,7 +1269,7 @@ cdef class Element(SageObject):
-             sage: e._add_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-         """
-         try:
-             python_op = (<object>self)._add_
-@@ -1381,7 +1381,7 @@ cdef class Element(SageObject):
-             sage: e._sub_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'...
-         """
-         try:
-             python_op = (<object>self)._sub_
-@@ -1435,7 +1435,7 @@ cdef class Element(SageObject):
-             sage: e._neg_()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'...
-         """
-         try:
-             python_op = (<object>self)._neg_
-@@ -1549,7 +1549,7 @@ cdef class Element(SageObject):
-             sage: e._mul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'...
-         """
-         try:
-             python_op = (<object>self)._mul_
-@@ -1662,7 +1662,7 @@ cdef class Element(SageObject):
-             sage: e._matmul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'...
-         """
-         try:
-             python_op = (<object>self)._matmul_
-@@ -1765,7 +1765,7 @@ cdef class Element(SageObject):
-             sage: e._div_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'...
-         """
-         try:
-             python_op = (<object>self)._div_
-@@ -1865,7 +1865,7 @@ cdef class Element(SageObject):
-             sage: e._floordiv_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'...
-         """
-         try:
-             python_op = (<object>self)._floordiv_
-@@ -1965,7 +1965,7 @@ cdef class Element(SageObject):
-             sage: e._mod_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'...
-         """
-         try:
-             python_op = (<object>self)._mod_
-@@ -2092,7 +2092,7 @@ cdef class Element(SageObject):
-             sage: e._pow_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'...
-         """
-         try:
-             python_op = (<object>self)._pow_
-@@ -2122,7 +2122,7 @@ cdef class Element(SageObject):
-             sage: e._pow_int(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'...
-         """
-         try:
-             python_op = (<object>self)._pow_int
-@@ -2856,7 +2856,7 @@ cdef class RingElement(ModuleElement):
-             sage: m.is_nilpotent()                                                      # needs sage.modules
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... object has no attribute 'is_nilpotent'
-+            AttributeError: '...' object has no attribute 'is_nilpotent'...
-         """
-         if self.is_unit():
-             return False
-@@ -4671,7 +4671,7 @@ def coerce_binop(method):
-         sage: x.test_add(CC(2))
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'
-+        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'...
- 
-     TESTS:
- 
-diff --git a/src/sage/structure/sequence.py b/src/sage/structure/sequence.py
-index 0c700c1fb81..c3972532ac3 100644
---- a/src/sage/structure/sequence.py
-+++ b/src/sage/structure/sequence.py
-@@ -854,7 +854,7 @@ def __getattr__(self, name):
-             sage: S.universe()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'...
-             sage: S._Sequence__universe = 'foobar'
-             sage: S.universe()
-             'foobar'
-@@ -867,7 +867,7 @@ def __getattr__(self, name):
-             sage: hash(S)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'...
-             sage: S._Sequence__hash = int(34)
-             sage: hash(S)
-             34
-diff --git a/src/sage/symbolic/assumptions.py b/src/sage/symbolic/assumptions.py
-index 7dcb15f0d85..15f6fa07ce6 100644
---- a/src/sage/symbolic/assumptions.py
-+++ b/src/sage/symbolic/assumptions.py
-@@ -636,7 +636,7 @@ def assume(*args):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no
--        attribute 'assume'
-+        attribute 'assume'...
- 
-     Ensure that we can combine the two types of assumptions, as documented::
- 
-diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx
-index 0f251ac4e5c..66f624141b3 100644
---- a/src/sage/symbolic/expression.pyx
-+++ b/src/sage/symbolic/expression.pyx
-@@ -13712,7 +13712,7 @@ cdef get_dynamic_class_for_function(unsigned serial):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.symbolic.expression.Expression' object has no
--        attribute 'argp1'
-+        attribute 'argp1'...
-         sage: t = (e + 1).op[0]; t
-         tfunc(x)
-         sage: t
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index c4152e092e3..4bcf45e8793 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -67,6 +67,7 @@
- #include "archive.h"
- #include "tostring.h"
- #include "utils.h"
-+#include "../../cpython/pycore_long.h"
- 
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wdeprecated-register"
-@@ -706,18 +707,12 @@ static long _mpq_pythonhash(mpq_t the_rat)
- // Initialize an mpz_t from a Python long integer
- static void _mpz_set_pylong(mpz_t z, PyLongObject* l)
- {
--    Py_ssize_t pylong_size = Py_SIZE(l);
--    int sign = 1;
--
--    if (pylong_size < 0) {
--        pylong_size = -pylong_size;
--        sign = -1;
--    }
-+    Py_ssize_t pylong_size = _PyLong_DigitCount(l);
- 
-     mpz_import(z, pylong_size, -1, sizeof(digit), 0,
--               8*sizeof(digit) - PyLong_SHIFT, l->ob_digit);
-+               8*sizeof(digit) - PyLong_SHIFT, ob_digit(l));
- 
--    if (sign < 0)
-+    if (_PyLong_IsNegative(l))
-         mpz_neg(z, z);
- }
- 
-diff --git a/src/sage/symbolic/pynac_impl.pxi b/src/sage/symbolic/pynac_impl.pxi
-index 68c31dcfde7..7fd7c3b314b 100644
---- a/src/sage/symbolic/pynac_impl.pxi
-+++ b/src/sage/symbolic/pynac_impl.pxi
-@@ -619,7 +619,7 @@ def tolerant_is_symbol(a):
-         sage: None.is_symbol()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute 'is_symbol'
-+        AttributeError: 'NoneType' object has no attribute 'is_symbol'...
-     """
-     try:
-         return a.is_symbol()
diff --git a/srcpkgs/sagemath/patches/36506-notebook_7.patch b/srcpkgs/sagemath/patches/36506-notebook_7.patch
new file mode 100644
index 0000000000000..a7d93d52c1b4a
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36506-notebook_7.patch
@@ -0,0 +1,18 @@
+diff --git a/src/bin/sage-notebook b/src/bin/sage-notebook
+index 2e8b12e1a1c..801b0a6a6a3 100755
+--- a/src/bin/sage-notebook
++++ b/src/bin/sage-notebook
+@@ -29,7 +29,12 @@ class NotebookJupyter():
+     def __init__(self, argv):
+         self.print_banner()
+         try:
+-            from notebook.notebookapp import main
++            try:
++                # notebook 6
++                from notebook.notebookapp import main
++            except ImportError:
++                # notebook 7
++                from notebook.app import main
+         except ImportError:
+             import traceback
+             traceback.print_exc()
diff --git a/srcpkgs/sagemath/patches/36544-networkx_3.2.patch b/srcpkgs/sagemath/patches/36544-networkx_3.2.patch
new file mode 100644
index 0000000000000..efcc935ac5476
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36544-networkx_3.2.patch
@@ -0,0 +1,41 @@
+diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py
+index eedbc36bef3..3fdc241a1c4 100644
+--- a/src/sage/graphs/generic_graph.py
++++ b/src/sage/graphs/generic_graph.py
+@@ -5102,13 +5102,13 @@ def cycle_basis(self, output='vertex'):
+         A cycle basis in Petersen's Graph ::
+ 
+             sage: g = graphs.PetersenGraph()
+-            sage: g.cycle_basis()                                                       # needs networkx
++            sage: g.cycle_basis()                                                       # needs networkx, random (changes in networkx 3.2)
+             [[1, 6, 8, 5, 0], [4, 9, 6, 8, 5, 0], [7, 9, 6, 8, 5],
+              [4, 3, 8, 5, 0], [1, 2, 3, 8, 5, 0], [7, 2, 3, 8, 5]]
+ 
+         One can also get the result as a list of lists of edges::
+ 
+-            sage: g.cycle_basis(output='edge')                                          # needs networkx
++            sage: g.cycle_basis(output='edge')                                          # needs networkx, random (changes in networkx 3.2)
+             [[(1, 6, None), (6, 8, None), (8, 5, None), (5, 0, None),
+              (0, 1, None)], [(4, 9, None), (9, 6, None), (6, 8, None),
+              (8, 5, None), (5, 0, None), (0, 4, None)], [(7, 9, None),
+@@ -5273,9 +5273,9 @@ def minimum_cycle_basis(self, algorithm=None, weight_function=None, by_weight=Fa
+             [[1, 2, 3], [1, 2, 3, 4], [5, 6, 7]]
+             sage: sorted(g.minimum_cycle_basis(by_weight=False))
+             [[1, 2, 3], [1, 3, 4], [5, 6, 7]]
+-            sage: sorted(g.minimum_cycle_basis(by_weight=True, algorithm='NetworkX'))   # needs networkx
++            sage: sorted(g.minimum_cycle_basis(by_weight=True, algorithm='NetworkX'))   # needs networkx, random (changes in networkx 3.2)
+             [[1, 2, 3], [1, 2, 3, 4], [5, 6, 7]]
+-            sage: g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX')          # needs networkx
++            sage: g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX')          # needs networkx, random (changes in networkx 3.2)
+             [[1, 2, 3], [1, 3, 4], [5, 6, 7]]
+ 
+         ::
+@@ -5283,7 +5283,7 @@ def minimum_cycle_basis(self, algorithm=None, weight_function=None, by_weight=Fa
+             sage: g = Graph([(1, 2), (2, 3), (3, 4), (4, 5), (5, 1), (5, 3)])
+             sage: sorted(g.minimum_cycle_basis(by_weight=False))
+             [[1, 2, 3, 5], [3, 4, 5]]
+-            sage: sorted(g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX'))  # needs networkx
++            sage: sorted(g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX'))  # needs networkx, random (changes in networkx 3.2)
+             [[1, 2, 3, 5], [3, 4, 5]]
+ 
+         TESTS::
diff --git a/srcpkgs/sagemath/patches/get_patches b/srcpkgs/sagemath/patches/get_patches
index 95a6963432948..94992f4978f8c 100755
--- a/srcpkgs/sagemath/patches/get_patches
+++ b/srcpkgs/sagemath/patches/get_patches
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-version=10.1
+version=10.2.beta8
 
 URL_BASE_PR="https://github.com/sagemath/sage/pull/"
 URL_BASE_COMPARE="https://github.com/sagemath/sage/compare/${version}..."
@@ -20,24 +20,9 @@ get_pr() {
 # run from patches dir
 cd $(dirname "$0")
 
-# merged in 10.2.beta0
-#get_pr  36018   "singular 4.3.2p4" # included in #35934
-get_pr  36046   "fix memory leak"
-
-# merged in 10.2.beta1
-get_pr  35934   "singular 4.3.2p7"
-
-# merged in 10.2.beta2
-get_pr  36006   "gmp 6.3.0"
-
-# merged in 10.2.beta3
-get_pr  36235   "ecl 23.9.9"
-
-# merged in 10.2.beta4
-get_pr  36279   "matplotlib 3.8.0"
-
 # positive review
-#get_pr  36403   "python 3.12" # included in #36407
+get_pr  36506   "notebook 7"
 
 # needs review
-get_pr  36407   "python 3.12"
+get_pr  35848   "flintlib 3.0"
+get_pr  36544   "networkx 3.2"
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index a80d8b7187ece..eb0ad26438538 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,14 +1,14 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=10.1
-revision=4
+version=10.2.beta8
+revision=1
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
 _bindir=/usr/lib/sagemath/$version/bin
 make_install_args="--install-scripts=$_bindir"
-hostmakedepends="m4 pkg-config python3-Cython0.29 python3-Jinja2
+hostmakedepends="m4 pkg-config python3-Cython python3-Jinja2
  python3-pkgconfig python3-setuptools"
-makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
+makedepends="boost-devel brial-devel cliquer-devel ecl eclib-devel
  ecm-devel fflas-ffpack flintlib-devel gap-devel gd-devel giac-devel glpk-devel
  gsl-devel iml-devel lcalc-devel libbraiding-devel libhomfly-devel libmpc-devel
  libpng-devel linbox-devel m4ri-devel m4rie-devel mpfi-devel
@@ -18,7 +18,7 @@ makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
 depends="eclib-devel fflas-ffpack flintlib-devel gcc-fortran gd-devel
  gfan giac gsl-devel gzip libpng-devel linbox-devel m4ri-devel maxima-ecl
  mpfr-devel nauty ntl-devel palp pari-devel pari-elldata-small pari-galdata
- pari-galpol-small pari-seadata-small pkg-config python3-Cython0.29 python3-cypari2
+ pari-galpol-small pari-seadata-small pkg-config python3-Cython python3-cypari2
  python3-cysignals python3-devel python3-fpylll python3-ipython python3-lrcalc
  python3-ipython_ipykernel python3-jupyter_ipywidgets python3-matplotlib
  python3-memory_allocator python3-networkx python3-pip python3-pkgconfig
@@ -33,7 +33,7 @@ license="GPL-2.0-or-later"
 homepage="https://www.sagemath.org/"
 changelog="https://github.com/sagemath/sage/releases"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=a658612b1b2376ddaf207cc8ed0ef458d4c2880c16e19139bedbe8baa42ad62f
+checksum=3bb0d92f1deeadbe5108afb6e41d1c189c84898b063110507ec9f9c9a52d9ddb
 nocross="due to ntl (flintlib), fflas-ffpack, givaro, linbox, cysignals, sympow, maxima"
 
 post_patch() {

From 5e5db55626db61b5da23a52ed3caa0a32818bfcb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Sun, 29 Oct 2023 21:15:17 -0300
Subject: [PATCH 7/8] sagemath: update to 10.2.beta9.

---
 .../sagemath/patches/35848-flintlib_3.0.patch |   4 +-
 .../sagemath/patches/36506-notebook_7.patch   |  18 --
 .../patches/36543-cython_warning.patch        |  49 ++++
 .../sagemath/patches/36551-fix_qf.nbs.patch   |  85 +++++++
 .../patches/36573-relative_imports.patch      | 210 ++++++++++++++++++
 .../patches/36600-giac_1.9.0-67.patch         |  52 +++++
 srcpkgs/sagemath/patches/get_patches          |   9 +-
 srcpkgs/sagemath/template                     |   4 +-
 8 files changed, 406 insertions(+), 25 deletions(-)
 delete mode 100644 srcpkgs/sagemath/patches/36506-notebook_7.patch
 create mode 100644 srcpkgs/sagemath/patches/36543-cython_warning.patch
 create mode 100644 srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
 create mode 100644 srcpkgs/sagemath/patches/36573-relative_imports.patch
 create mode 100644 srcpkgs/sagemath/patches/36600-giac_1.9.0-67.patch

diff --git a/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
index ed3d6d1913433..e812e0d842cca 100644
--- a/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
+++ b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
@@ -1555,7 +1555,7 @@ index 1b3f0ac412a..485c9c71be3 100644
 -            sage: K.<t> = PolynomialRing(GF(7))
 -            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
 -            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
--            sage: C.has_rational_point()
+-            sage: C.has_rational_point()                                                # needs sage.libs.singular
 -            Traceback (most recent call last):
 -            ...
 -            TypeError: self (=Scheme morphism:
@@ -1585,7 +1585,7 @@ index 1b3f0ac412a..485c9c71be3 100644
  
              sage: K.<t> = FractionField(PolynomialRing(QQ, 't'))
 @@ -250,6 +218,16 @@ def has_rational_point(self, point=False, algorithm='default',
-             sage: C.has_rational_point(point = True) # long time (4 seconds)
+             sage: C.has_rational_point(point=True)  # long time (4 seconds)             # needs sage.libs.singular
              (True,
               ((-2/117*t^8 + 304/1053*t^7 + 40/117*t^6 - 1/27*t^5 - 110/351*t^4 - 2/195*t^3 + 11/351*t^2 + 1/117)/(t^4 + 2/39*t^3 + 4/117*t^2 + 2/39*t + 14/39) : -5/3*t^4 + 19*t^3 : 1))
 +
diff --git a/srcpkgs/sagemath/patches/36506-notebook_7.patch b/srcpkgs/sagemath/patches/36506-notebook_7.patch
deleted file mode 100644
index a7d93d52c1b4a..0000000000000
--- a/srcpkgs/sagemath/patches/36506-notebook_7.patch
+++ /dev/null
@@ -1,18 +0,0 @@
-diff --git a/src/bin/sage-notebook b/src/bin/sage-notebook
-index 2e8b12e1a1c..801b0a6a6a3 100755
---- a/src/bin/sage-notebook
-+++ b/src/bin/sage-notebook
-@@ -29,7 +29,12 @@ class NotebookJupyter():
-     def __init__(self, argv):
-         self.print_banner()
-         try:
--            from notebook.notebookapp import main
-+            try:
-+                # notebook 6
-+                from notebook.notebookapp import main
-+            except ImportError:
-+                # notebook 7
-+                from notebook.app import main
-         except ImportError:
-             import traceback
-             traceback.print_exc()
diff --git a/srcpkgs/sagemath/patches/36543-cython_warning.patch b/srcpkgs/sagemath/patches/36543-cython_warning.patch
new file mode 100644
index 0000000000000..f0e3d4114342f
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36543-cython_warning.patch
@@ -0,0 +1,49 @@
+diff --git a/src/sage/cpython/dict_del_by_value.pyx b/src/sage/cpython/dict_del_by_value.pyx
+index 19dd2bb2731..fdeb5fee8ff 100644
+--- a/src/sage/cpython/dict_del_by_value.pyx
++++ b/src/sage/cpython/dict_del_by_value.pyx
+@@ -46,31 +46,6 @@ cdef extern from "dict_internal.h":
+         PyObject * me_key
+         PyObject * me_value
+ 
+-
+-# dk_lookup was removed in python 3.11
+-DEF HAS_DK_LOOKUP = PY_VERSION_HEX < 0x30b0000
+-
+-IF HAS_DK_LOOKUP:
+-
+-    cdef extern from *:
+-        """
+-        #define DK_LOOKUP(dk) ((dk)->dk_lookup)
+-        """
+-        ctypedef void * dict_lookup_func  # Precise definition not needed
+-        dict_lookup_func DK_LOOKUP(PyDictKeysObject *mp)
+-
+-    cdef dict_lookup_func lookdict
+-
+-    def init_lookdict():
+-        global lookdict
+-        # A dict which a non-string key uses the generic "lookdict"
+-        # as lookup function
+-        cdef object D = {}
+-        D[0] = 0
+-        lookdict = DK_LOOKUP((<PyDictObject *>D).ma_keys)
+-
+-    init_lookdict()
+-
+ cdef int del_dictitem_by_exact_value(PyDictObject *mp, PyObject *value, Py_hash_t hash) except -1:
+     """
+     This is used in callbacks for the weak values of :class:`WeakValueDictionary`.
+@@ -147,12 +122,6 @@ cdef int del_dictitem_by_exact_value(PyDictObject *mp, PyObject *value, Py_hash_
+             return 0
+         ep = &(entries[ix])
+ 
+-    # We need the lookup function to be the generic lookdict, otherwise
+-    # deletions may not work correctly
+-    IF HAS_DK_LOOKUP:
+-        # Can this fail? In any case dk_lookup was removed in python 3.11
+-        assert DK_LOOKUP(keys) is lookdict
+-
+     T = PyList_New(2)
+     PyList_SetItem(T, 0, ep.me_key)
+     PyList_SetItem(T, 1, ep.me_value)
diff --git a/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch b/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
new file mode 100644
index 0000000000000..537edea9bfafa
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
@@ -0,0 +1,85 @@
+diff --git a/src/sage/quadratic_forms/quadratic_form__neighbors.py b/src/sage/quadratic_forms/quadratic_form__neighbors.py
+index 94f6559d51a..9bf5e2d7de6 100644
+--- a/src/sage/quadratic_forms/quadratic_form__neighbors.py
++++ b/src/sage/quadratic_forms/quadratic_form__neighbors.py
+@@ -74,6 +74,10 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+         sage: v = Q.find_primitive_p_divisible_vector__next(5, v); v
+         (1, 0)
+         sage: v = Q.find_primitive_p_divisible_vector__next(5, v); v
++        sage: v = Q.find_primitive_p_divisible_vector__next(2) ; v
++        (0, 1)
++        sage: v = Q.find_primitive_p_divisible_vector__next(2, v) ; v
++        (1, 0)
+         sage: Q = QuadraticForm(QQ, matrix.diagonal([1,1,1,1]))
+         sage: v = Q.find_primitive_p_divisible_vector__next(2)
+         sage: Q(v)
+@@ -83,6 +87,9 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+     n = self.dim()
+     if v is None:
+         w = vector(ZZ, [0] * (n - 1) + [1])
++        a = self(w)
++        if a in ZZ and (a % p == 0):
++            return w
+     else:
+         w = deepcopy(v)
+ 
+@@ -132,7 +139,7 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+             return w
+ 
+ 
+-def find_p_neighbor_from_vec(self, p, y):
++def find_p_neighbor_from_vec(self, p, y, return_matrix=False):
+     r"""
+     Return the `p`-neighbor of ``self`` defined by ``y``.
+ 
+@@ -147,25 +154,32 @@ def find_p_neighbor_from_vec(self, p, y):
+     - ``p`` -- a prime number
+     - ``y`` -- a vector with `q(y) \in p \ZZ`
+     - ``odd`` -- (default: ``False``) if `p=2`, return also odd neighbors
++    - ``return_matrix`` -- (boolean, default ``False``) return
++      the transformation matrix instead of the quadratic form
+ 
+     EXAMPLES::
+ 
++        sage: # needs sage.libs.pari
+         sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1,1])
+         sage: v = vector([0,2,1,1])
+-        sage: X = Q.find_p_neighbor_from_vec(3, v); X                                   # needs sage.libs.pari
++        sage: X = Q.find_p_neighbor_from_vec(3, v); X
+         Quadratic form in 4 variables over Integer Ring with coefficients:
+         [ 1 0 0 0 ]
+         [ * 1 4 4 ]
+         [ * * 5 12 ]
+         [ * * * 9 ]
++        sage: B = Q.find_p_neighbor_from_vec(3, v, return_matrix=True)
++        sage: Q(B) == X
++        True
+ 
+     Since the base ring and the domain are not yet separate,
+     for rational, half integral forms we just pretend
+     the base ring is `\ZZ`::
+ 
++        sage: # needs sage.libs.pari
+         sage: Q = QuadraticForm(QQ, matrix.diagonal([1,1,1,1]))
+         sage: v = vector([1,1,1,1])
+-        sage: Q.find_p_neighbor_from_vec(2, v)                                          # needs sage.libs.pari
++        sage: Q.find_p_neighbor_from_vec(2, v)
+         Quadratic form in 4 variables over Rational Field with coefficients:
+         [ 1/2 1 1 1 ]
+         [ * 1 1 2 ]
+@@ -227,9 +241,12 @@ def find_p_neighbor_from_vec(self, p, y):
+     # by definition this is the p-neighbor of L at y
+     # assert B.det().abs() == 1
+ 
+-    QF = self.parent()
+-    Gnew = (B*G*B.T).change_ring(R)
+-    return QF(Gnew)
++    if return_matrix:
++        return B.T
++    else:
++        QF = self.parent()
++        Gnew = (B*G*B.T).change_ring(R)
++        return QF(Gnew)
+ 
+ 
+ def neighbor_iteration(seeds, p, mass=None, max_classes=ZZ(10)**3,
diff --git a/srcpkgs/sagemath/patches/36573-relative_imports.patch b/srcpkgs/sagemath/patches/36573-relative_imports.patch
new file mode 100644
index 0000000000000..77481909d9fac
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36573-relative_imports.patch
@@ -0,0 +1,210 @@
+diff --git a/src/sage/structure/all.py b/src/sage/structure/all.py
+index 311bf869ef2..df0114c8382 100644
+--- a/src/sage/structure/all.py
++++ b/src/sage/structure/all.py
+@@ -1,12 +1,12 @@
+-from .factorization import Factorization
++from sage.structure.factorization import Factorization
+ 
+-from .sequence import Sequence, seq
++from sage.structure.sequence import Sequence, seq
+ 
+-from .unique_representation import UniqueRepresentation
++from sage.structure.unique_representation import UniqueRepresentation
+ 
+-from .sage_object import SageObject
++from sage.structure.sage_object import SageObject
+ 
+-from .element import (
++from sage.structure.element import (
+     canonical_coercion,
+     coercion_model,
+     get_coercion_model,
+@@ -14,16 +14,16 @@
+     parent
+     )
+ 
+-from .parent import Parent
++from sage.structure.parent import Parent
+ 
+-from .parent_gens import localvars
++from sage.structure.parent_gens import localvars
+ 
+-from .proof import all as proof
++from sage.structure.proof import all as proof
+ 
+ from sage.misc.lazy_import import lazy_import
+ lazy_import('sage.structure.formal_sum', ['FormalSums', 'FormalSum'])
+ del lazy_import
+ 
+-from .mutability import Mutability
++from sage.structure.mutability import Mutability
+ 
+-from .element_wrapper import ElementWrapper
++from sage.structure.element_wrapper import ElementWrapper
+diff --git a/src/sage/structure/coerce.pxd b/src/sage/structure/coerce.pxd
+index e070d1c32e4..812cb5d5c7c 100644
+--- a/src/sage/structure/coerce.pxd
++++ b/src/sage/structure/coerce.pxd
+@@ -1,5 +1,5 @@
+-from .parent cimport Parent
+-from .coerce_dict cimport TripleDict
++from sage.structure.parent cimport Parent
++from sage.structure.coerce_dict cimport TripleDict
+ 
+ cpdef py_scalar_parent(py_type)
+ cpdef py_scalar_to_element(py)
+diff --git a/src/sage/structure/coerce.pyx b/src/sage/structure/coerce.pyx
+index d8c3f684217..8f98085ba8d 100644
+--- a/src/sage/structure/coerce.pyx
++++ b/src/sage/structure/coerce.pyx
+@@ -84,11 +84,11 @@ cimport gmpy2
+ cdef mul, truediv
+ from operator import mul, truediv
+ 
+-from .richcmp cimport rich_to_bool, revop
+-from .sage_object cimport SageObject
+-from .parent cimport Parent_richcmp_element_without_coercion
+-from .element cimport bin_op_exception, parent, Element
+-from .coerce_exceptions import CoercionException
++from sage.structure.richcmp cimport rich_to_bool, revop
++from sage.structure.sage_object cimport SageObject
++from sage.structure.parent cimport Parent_richcmp_element_without_coercion
++from sage.structure.element cimport bin_op_exception, parent, Element
++from sage.structure.coerce_exceptions import CoercionException
+ from sage.rings.integer_fake cimport is_Integer
+ from sage.categories.map cimport Map
+ from sage.categories.morphism import IdentityMorphism
+diff --git a/src/sage/structure/coerce_actions.pyx b/src/sage/structure/coerce_actions.pyx
+index 6df2aec6695..3c17ac858e6 100644
+--- a/src/sage/structure/coerce_actions.pyx
++++ b/src/sage/structure/coerce_actions.pyx
+@@ -18,10 +18,10 @@ from cpython.long cimport *
+ from cpython.number cimport *
+ from cysignals.signals cimport sig_check
+ 
+-from .coerce cimport coercion_model
+-from .element cimport parent, Element, ModuleElement
+-from .parent cimport Parent
+-from .coerce_exceptions import CoercionException
++from sage.structure.coerce cimport coercion_model
++from sage.structure.element cimport parent, Element, ModuleElement
++from sage.structure.parent cimport Parent
++from sage.structure.coerce_exceptions import CoercionException
+ from sage.categories.action cimport InverseAction, PrecomposedAction
+ from sage.arith.long cimport integer_check_long
+ 
+diff --git a/src/sage/structure/element.pxd b/src/sage/structure/element.pxd
+index 20c556b985e..6be65bb1f50 100644
+--- a/src/sage/structure/element.pxd
++++ b/src/sage/structure/element.pxd
+@@ -1,5 +1,5 @@
+-from .sage_object cimport SageObject
+-from .parent cimport Parent
++from sage.structure.sage_object cimport SageObject
++from sage.structure.parent cimport Parent
+ from sage.misc.inherit_comparison cimport InheritComparisonMetaclass
+ 
+ 
+diff --git a/src/sage/structure/factory.pyx b/src/sage/structure/factory.pyx
+index ddb55501d94..50d5374e79e 100644
+--- a/src/sage/structure/factory.pyx
++++ b/src/sage/structure/factory.pyx
+@@ -56,7 +56,7 @@ AUTHORS:
+ 
+ import types
+ 
+-from .sage_object cimport SageObject
++from sage.structure.sage_object cimport SageObject
+ 
+ cdef sage_version
+ from sage.version import version as sage_version
+diff --git a/src/sage/structure/parent.pyx b/src/sage/structure/parent.pyx
+index 6548d8a3656..d40caa03307 100644
+--- a/src/sage/structure/parent.pyx
++++ b/src/sage/structure/parent.pyx
+@@ -119,13 +119,13 @@ from sage.misc.lazy_attribute import lazy_attribute
+ from sage.categories.sets_cat import Sets, EmptySetError
+ from sage.misc.lazy_string cimport _LazyString
+ from sage.sets.pythonclass cimport Set_PythonType_class
+-from .category_object import CategoryObject
+-from .coerce cimport coercion_model
+-from .coerce cimport parent_is_integers
+-from .coerce_exceptions import CoercionException
+-from .coerce_maps cimport (NamedConvertMap, DefaultConvertMap,
++from sage.structure.category_object import CategoryObject
++from sage.structure.coerce cimport coercion_model
++from sage.structure.coerce cimport parent_is_integers
++from sage.structure.coerce_exceptions import CoercionException
++from sage.structure.coerce_maps cimport (NamedConvertMap, DefaultConvertMap,
+                            DefaultConvertMap_unique, CallableConvertMap)
+-from .element cimport parent
++from sage.structure.element cimport parent
+ 
+ 
+ cdef _record_exception():
+diff --git a/src/sage/structure/parent_base.pxd b/src/sage/structure/parent_base.pxd
+index 225fccabcae..8ffac64eff2 100644
+--- a/src/sage/structure/parent_base.pxd
++++ b/src/sage/structure/parent_base.pxd
+@@ -6,7 +6,7 @@
+ #                  https://www.gnu.org/licenses/
+ ###############################################################################
+ 
+-from .parent_old cimport Parent as Parent_old
++from sage.structure.parent_old cimport Parent as Parent_old
+ 
+ cdef class ParentWithBase(Parent_old):
+     pass
+diff --git a/src/sage/structure/parent_base.pyx b/src/sage/structure/parent_base.pyx
+index dd697f90135..b41175b5bff 100644
+--- a/src/sage/structure/parent_base.pyx
++++ b/src/sage/structure/parent_base.pyx
+@@ -12,7 +12,7 @@ Base class for old-style parent objects with a base ring
+ # ****************************************************************************
+ 
+ cimport sage.structure.parent as parent
+-from .coerce_exceptions import CoercionException
++from sage.structure.coerce_exceptions import CoercionException
+ 
+ cdef inline check_old_coerce(parent.Parent p):
+     if p._element_constructor is not None:
+diff --git a/src/sage/structure/parent_gens.pxd b/src/sage/structure/parent_gens.pxd
+index 6ec0e6e83f0..cf3b416317f 100644
+--- a/src/sage/structure/parent_gens.pxd
++++ b/src/sage/structure/parent_gens.pxd
+@@ -12,7 +12,7 @@ Parent objects with generators
+ #                  http://www.gnu.org/licenses/
+ #*****************************************************************************
+ 
+-from .parent_base cimport ParentWithBase
++from sage.structure.parent_base cimport ParentWithBase
+ 
+ 
+ cdef class ParentWithGens(ParentWithBase):
+diff --git a/src/sage/structure/parent_old.pyx b/src/sage/structure/parent_old.pyx
+index 77a7888d3b8..82bf9ead04b 100644
+--- a/src/sage/structure/parent_old.pyx
++++ b/src/sage/structure/parent_old.pyx
+@@ -27,7 +27,7 @@ This came up in some subtle bug once::
+ #                  https://www.gnu.org/licenses/
+ # ****************************************************************************
+ from sage.misc.superseded import deprecation
+-from .coerce cimport py_scalar_parent
++from sage.structure.coerce cimport py_scalar_parent
+ from sage.ext.stdsage cimport HAS_DICTIONARY
+ from sage.sets.pythonclass cimport Set_PythonType, Set_PythonType_class
+ 
+diff --git a/src/sage/structure/sage_object_test.py b/src/sage/structure/sage_object_test.py
+index 0922545a62c..721c1ad7719 100644
+--- a/src/sage/structure/sage_object_test.py
++++ b/src/sage/structure/sage_object_test.py
+@@ -1,6 +1,7 @@
+ 
+ import pytest
+-from .sage_object import SageObject
++from sage.structure.sage_object import SageObject
++
+ 
+ class SageObjectTests:
+ 
diff --git a/srcpkgs/sagemath/patches/36600-giac_1.9.0-67.patch b/srcpkgs/sagemath/patches/36600-giac_1.9.0-67.patch
new file mode 100644
index 0000000000000..a1ad357828a56
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36600-giac_1.9.0-67.patch
@@ -0,0 +1,52 @@
+diff --git a/src/sage/libs/giac/__init__.py b/src/sage/libs/giac/__init__.py
+index 558cd894b13..e7d7bc67d14 100644
+--- a/src/sage/libs/giac/__init__.py
++++ b/src/sage/libs/giac/__init__.py
+@@ -172,9 +172,9 @@ def groebner_basis(gens, proba_epsilon=None, threads=None, prot=False,
+         sage: from sage.libs.giac import groebner_basis as gb_giac
+         sage: P = PolynomialRing(GF(previous_prime(2**31)), 6, 'x')
+         sage: I = sage.rings.ideal.Cyclic(P)
+-        sage: B=gb_giac(I.gens());B
+-        <BLANKLINE>
+-        // Groebner basis computation time ...
++        sage: B = gb_giac(I.gens())
++        ...
++        sage: B
+         Polynomial Sequence with 45 Polynomials in 6 Variables
+         sage: B.is_groebner()
+         True
+@@ -184,8 +184,7 @@ def groebner_basis(gens, proba_epsilon=None, threads=None, prot=False,
+         sage: P = PolynomialRing(GF(previous_prime(2**31)), 5, 'x')
+         sage: I = sage.rings.ideal.Cyclic(P)
+         sage: B = gb_giac(I.gens(), elim_variables=[P.gen(0), P.gen(2)])
+-        <BLANKLINE>
+-        // Groebner basis computation time ...
++        ...
+         sage: B.is_groebner()
+         True
+         sage: B.ideal() == I.elimination_ideal([P.gen(0), P.gen(2)])
+@@ -201,11 +200,10 @@ def groebner_basis(gens, proba_epsilon=None, threads=None, prot=False,
+         ...
+         sage: sage.structure.proof.all.polynomial(True)
+         sage: B2 = gb_giac(I.gens()) # long time (4s)
+-        <BLANKLINE>
+-        // Groebner basis computation time...
++        ...
+         sage: B1 == B2 # long time
+         True
+-        sage: B1.is_groebner() # long time (20s)
++        sage: B1.is_groebner() # not tested, too long time (50s)
+         True
+ 
+     * multi threaded operations::
+@@ -253,9 +251,7 @@ def groebner_basis(gens, proba_epsilon=None, threads=None, prot=False,
+         sage: libgiac.purge('x2'),libgiac.purge('x4')
+         (22, whywouldyoudothis)
+         sage: gb_giac(I) # long time (3s)
+-        <BLANKLINE>
+-        // Groebner basis computation time...
+-        Polynomial Sequence with 74 Polynomials in 8 Variables
++        ...Polynomial Sequence with 74 Polynomials in 8 Variables
+ 
+         sage: I = ideal(P(0),P(0))
+         sage: I.groebner_basis() == gb_giac(I)
diff --git a/srcpkgs/sagemath/patches/get_patches b/srcpkgs/sagemath/patches/get_patches
index 94992f4978f8c..ea4d23c49f3ed 100755
--- a/srcpkgs/sagemath/patches/get_patches
+++ b/srcpkgs/sagemath/patches/get_patches
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-version=10.2.beta8
+version=10.2.beta9
 
 URL_BASE_PR="https://github.com/sagemath/sage/pull/"
 URL_BASE_COMPARE="https://github.com/sagemath/sage/compare/${version}..."
@@ -21,8 +21,11 @@ get_pr() {
 cd $(dirname "$0")
 
 # positive review
-get_pr  36506   "notebook 7"
+get_pr  36544   "networkx 3.2"
 
 # needs review
 get_pr  35848   "flintlib 3.0"
-get_pr  36544   "networkx 3.2"
+get_pr  36543   "cython warning"
+get_pr  36551   "fix qf.nbs"
+get_pr  36573   "relative imports"
+get_pr  36600   "giac 1.9.0-67"
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index eb0ad26438538..75f39fe5b0374 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,6 +1,6 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=10.2.beta8
+version=10.2.beta9
 revision=1
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
@@ -33,7 +33,7 @@ license="GPL-2.0-or-later"
 homepage="https://www.sagemath.org/"
 changelog="https://github.com/sagemath/sage/releases"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=3bb0d92f1deeadbe5108afb6e41d1c189c84898b063110507ec9f9c9a52d9ddb
+checksum=e6899566ca0c7c45984738aaf3378930d0f1746381daab8f61fb2e4b78af7394
 nocross="due to ntl (flintlib), fflas-ffpack, givaro, linbox, cysignals, sympow, maxima"
 
 post_patch() {

From dec44abd989375521a062e39fb0cc01cd81f61a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 6 Nov 2023 18:11:50 -0300
Subject: [PATCH 8/8] sagemath: update to 10.2.rc0.

---
 .../patches/36543-cython_warning.patch        |  49 ----
 .../sagemath/patches/36544-networkx_3.2.patch |  41 ----
 .../patches/36573-relative_imports.patch      | 210 ------------------
 .../patches/36600-giac_1.9.0-67.patch         |  52 -----
 srcpkgs/sagemath/patches/get_patches          |  10 +-
 srcpkgs/sagemath/template                     |   4 +-
 srcpkgs/sagemath/update                       |   3 +-
 7 files changed, 10 insertions(+), 359 deletions(-)
 delete mode 100644 srcpkgs/sagemath/patches/36543-cython_warning.patch
 delete mode 100644 srcpkgs/sagemath/patches/36544-networkx_3.2.patch
 delete mode 100644 srcpkgs/sagemath/patches/36573-relative_imports.patch
 delete mode 100644 srcpkgs/sagemath/patches/36600-giac_1.9.0-67.patch

diff --git a/srcpkgs/sagemath/patches/36543-cython_warning.patch b/srcpkgs/sagemath/patches/36543-cython_warning.patch
deleted file mode 100644
index f0e3d4114342f..0000000000000
--- a/srcpkgs/sagemath/patches/36543-cython_warning.patch
+++ /dev/null
@@ -1,49 +0,0 @@
-diff --git a/src/sage/cpython/dict_del_by_value.pyx b/src/sage/cpython/dict_del_by_value.pyx
-index 19dd2bb2731..fdeb5fee8ff 100644
---- a/src/sage/cpython/dict_del_by_value.pyx
-+++ b/src/sage/cpython/dict_del_by_value.pyx
-@@ -46,31 +46,6 @@ cdef extern from "dict_internal.h":
-         PyObject * me_key
-         PyObject * me_value
- 
--
--# dk_lookup was removed in python 3.11
--DEF HAS_DK_LOOKUP = PY_VERSION_HEX < 0x30b0000
--
--IF HAS_DK_LOOKUP:
--
--    cdef extern from *:
--        """
--        #define DK_LOOKUP(dk) ((dk)->dk_lookup)
--        """
--        ctypedef void * dict_lookup_func  # Precise definition not needed
--        dict_lookup_func DK_LOOKUP(PyDictKeysObject *mp)
--
--    cdef dict_lookup_func lookdict
--
--    def init_lookdict():
--        global lookdict
--        # A dict which a non-string key uses the generic "lookdict"
--        # as lookup function
--        cdef object D = {}
--        D[0] = 0
--        lookdict = DK_LOOKUP((<PyDictObject *>D).ma_keys)
--
--    init_lookdict()
--
- cdef int del_dictitem_by_exact_value(PyDictObject *mp, PyObject *value, Py_hash_t hash) except -1:
-     """
-     This is used in callbacks for the weak values of :class:`WeakValueDictionary`.
-@@ -147,12 +122,6 @@ cdef int del_dictitem_by_exact_value(PyDictObject *mp, PyObject *value, Py_hash_
-             return 0
-         ep = &(entries[ix])
- 
--    # We need the lookup function to be the generic lookdict, otherwise
--    # deletions may not work correctly
--    IF HAS_DK_LOOKUP:
--        # Can this fail? In any case dk_lookup was removed in python 3.11
--        assert DK_LOOKUP(keys) is lookdict
--
-     T = PyList_New(2)
-     PyList_SetItem(T, 0, ep.me_key)
-     PyList_SetItem(T, 1, ep.me_value)
diff --git a/srcpkgs/sagemath/patches/36544-networkx_3.2.patch b/srcpkgs/sagemath/patches/36544-networkx_3.2.patch
deleted file mode 100644
index efcc935ac5476..0000000000000
--- a/srcpkgs/sagemath/patches/36544-networkx_3.2.patch
+++ /dev/null
@@ -1,41 +0,0 @@
-diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py
-index eedbc36bef3..3fdc241a1c4 100644
---- a/src/sage/graphs/generic_graph.py
-+++ b/src/sage/graphs/generic_graph.py
-@@ -5102,13 +5102,13 @@ def cycle_basis(self, output='vertex'):
-         A cycle basis in Petersen's Graph ::
- 
-             sage: g = graphs.PetersenGraph()
--            sage: g.cycle_basis()                                                       # needs networkx
-+            sage: g.cycle_basis()                                                       # needs networkx, random (changes in networkx 3.2)
-             [[1, 6, 8, 5, 0], [4, 9, 6, 8, 5, 0], [7, 9, 6, 8, 5],
-              [4, 3, 8, 5, 0], [1, 2, 3, 8, 5, 0], [7, 2, 3, 8, 5]]
- 
-         One can also get the result as a list of lists of edges::
- 
--            sage: g.cycle_basis(output='edge')                                          # needs networkx
-+            sage: g.cycle_basis(output='edge')                                          # needs networkx, random (changes in networkx 3.2)
-             [[(1, 6, None), (6, 8, None), (8, 5, None), (5, 0, None),
-              (0, 1, None)], [(4, 9, None), (9, 6, None), (6, 8, None),
-              (8, 5, None), (5, 0, None), (0, 4, None)], [(7, 9, None),
-@@ -5273,9 +5273,9 @@ def minimum_cycle_basis(self, algorithm=None, weight_function=None, by_weight=Fa
-             [[1, 2, 3], [1, 2, 3, 4], [5, 6, 7]]
-             sage: sorted(g.minimum_cycle_basis(by_weight=False))
-             [[1, 2, 3], [1, 3, 4], [5, 6, 7]]
--            sage: sorted(g.minimum_cycle_basis(by_weight=True, algorithm='NetworkX'))   # needs networkx
-+            sage: sorted(g.minimum_cycle_basis(by_weight=True, algorithm='NetworkX'))   # needs networkx, random (changes in networkx 3.2)
-             [[1, 2, 3], [1, 2, 3, 4], [5, 6, 7]]
--            sage: g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX')          # needs networkx
-+            sage: g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX')          # needs networkx, random (changes in networkx 3.2)
-             [[1, 2, 3], [1, 3, 4], [5, 6, 7]]
- 
-         ::
-@@ -5283,7 +5283,7 @@ def minimum_cycle_basis(self, algorithm=None, weight_function=None, by_weight=Fa
-             sage: g = Graph([(1, 2), (2, 3), (3, 4), (4, 5), (5, 1), (5, 3)])
-             sage: sorted(g.minimum_cycle_basis(by_weight=False))
-             [[1, 2, 3, 5], [3, 4, 5]]
--            sage: sorted(g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX'))  # needs networkx
-+            sage: sorted(g.minimum_cycle_basis(by_weight=False, algorithm='NetworkX'))  # needs networkx, random (changes in networkx 3.2)
-             [[1, 2, 3, 5], [3, 4, 5]]
- 
-         TESTS::
diff --git a/srcpkgs/sagemath/patches/36573-relative_imports.patch b/srcpkgs/sagemath/patches/36573-relative_imports.patch
deleted file mode 100644
index 77481909d9fac..0000000000000
--- a/srcpkgs/sagemath/patches/36573-relative_imports.patch
+++ /dev/null
@@ -1,210 +0,0 @@
-diff --git a/src/sage/structure/all.py b/src/sage/structure/all.py
-index 311bf869ef2..df0114c8382 100644
---- a/src/sage/structure/all.py
-+++ b/src/sage/structure/all.py
-@@ -1,12 +1,12 @@
--from .factorization import Factorization
-+from sage.structure.factorization import Factorization
- 
--from .sequence import Sequence, seq
-+from sage.structure.sequence import Sequence, seq
- 
--from .unique_representation import UniqueRepresentation
-+from sage.structure.unique_representation import UniqueRepresentation
- 
--from .sage_object import SageObject
-+from sage.structure.sage_object import SageObject
- 
--from .element import (
-+from sage.structure.element import (
-     canonical_coercion,
-     coercion_model,
-     get_coercion_model,
-@@ -14,16 +14,16 @@
-     parent
-     )
- 
--from .parent import Parent
-+from sage.structure.parent import Parent
- 
--from .parent_gens import localvars
-+from sage.structure.parent_gens import localvars
- 
--from .proof import all as proof
-+from sage.structure.proof import all as proof
- 
- from sage.misc.lazy_import import lazy_import
- lazy_import('sage.structure.formal_sum', ['FormalSums', 'FormalSum'])
- del lazy_import
- 
--from .mutability import Mutability
-+from sage.structure.mutability import Mutability
- 
--from .element_wrapper import ElementWrapper
-+from sage.structure.element_wrapper import ElementWrapper
-diff --git a/src/sage/structure/coerce.pxd b/src/sage/structure/coerce.pxd
-index e070d1c32e4..812cb5d5c7c 100644
---- a/src/sage/structure/coerce.pxd
-+++ b/src/sage/structure/coerce.pxd
-@@ -1,5 +1,5 @@
--from .parent cimport Parent
--from .coerce_dict cimport TripleDict
-+from sage.structure.parent cimport Parent
-+from sage.structure.coerce_dict cimport TripleDict
- 
- cpdef py_scalar_parent(py_type)
- cpdef py_scalar_to_element(py)
-diff --git a/src/sage/structure/coerce.pyx b/src/sage/structure/coerce.pyx
-index d8c3f684217..8f98085ba8d 100644
---- a/src/sage/structure/coerce.pyx
-+++ b/src/sage/structure/coerce.pyx
-@@ -84,11 +84,11 @@ cimport gmpy2
- cdef mul, truediv
- from operator import mul, truediv
- 
--from .richcmp cimport rich_to_bool, revop
--from .sage_object cimport SageObject
--from .parent cimport Parent_richcmp_element_without_coercion
--from .element cimport bin_op_exception, parent, Element
--from .coerce_exceptions import CoercionException
-+from sage.structure.richcmp cimport rich_to_bool, revop
-+from sage.structure.sage_object cimport SageObject
-+from sage.structure.parent cimport Parent_richcmp_element_without_coercion
-+from sage.structure.element cimport bin_op_exception, parent, Element
-+from sage.structure.coerce_exceptions import CoercionException
- from sage.rings.integer_fake cimport is_Integer
- from sage.categories.map cimport Map
- from sage.categories.morphism import IdentityMorphism
-diff --git a/src/sage/structure/coerce_actions.pyx b/src/sage/structure/coerce_actions.pyx
-index 6df2aec6695..3c17ac858e6 100644
---- a/src/sage/structure/coerce_actions.pyx
-+++ b/src/sage/structure/coerce_actions.pyx
-@@ -18,10 +18,10 @@ from cpython.long cimport *
- from cpython.number cimport *
- from cysignals.signals cimport sig_check
- 
--from .coerce cimport coercion_model
--from .element cimport parent, Element, ModuleElement
--from .parent cimport Parent
--from .coerce_exceptions import CoercionException
-+from sage.structure.coerce cimport coercion_model
-+from sage.structure.element cimport parent, Element, ModuleElement
-+from sage.structure.parent cimport Parent
-+from sage.structure.coerce_exceptions import CoercionException
- from sage.categories.action cimport InverseAction, PrecomposedAction
- from sage.arith.long cimport integer_check_long
- 
-diff --git a/src/sage/structure/element.pxd b/src/sage/structure/element.pxd
-index 20c556b985e..6be65bb1f50 100644
---- a/src/sage/structure/element.pxd
-+++ b/src/sage/structure/element.pxd
-@@ -1,5 +1,5 @@
--from .sage_object cimport SageObject
--from .parent cimport Parent
-+from sage.structure.sage_object cimport SageObject
-+from sage.structure.parent cimport Parent
- from sage.misc.inherit_comparison cimport InheritComparisonMetaclass
- 
- 
-diff --git a/src/sage/structure/factory.pyx b/src/sage/structure/factory.pyx
-index ddb55501d94..50d5374e79e 100644
---- a/src/sage/structure/factory.pyx
-+++ b/src/sage/structure/factory.pyx
-@@ -56,7 +56,7 @@ AUTHORS:
- 
- import types
- 
--from .sage_object cimport SageObject
-+from sage.structure.sage_object cimport SageObject
- 
- cdef sage_version
- from sage.version import version as sage_version
-diff --git a/src/sage/structure/parent.pyx b/src/sage/structure/parent.pyx
-index 6548d8a3656..d40caa03307 100644
---- a/src/sage/structure/parent.pyx
-+++ b/src/sage/structure/parent.pyx
-@@ -119,13 +119,13 @@ from sage.misc.lazy_attribute import lazy_attribute
- from sage.categories.sets_cat import Sets, EmptySetError
- from sage.misc.lazy_string cimport _LazyString
- from sage.sets.pythonclass cimport Set_PythonType_class
--from .category_object import CategoryObject
--from .coerce cimport coercion_model
--from .coerce cimport parent_is_integers
--from .coerce_exceptions import CoercionException
--from .coerce_maps cimport (NamedConvertMap, DefaultConvertMap,
-+from sage.structure.category_object import CategoryObject
-+from sage.structure.coerce cimport coercion_model
-+from sage.structure.coerce cimport parent_is_integers
-+from sage.structure.coerce_exceptions import CoercionException
-+from sage.structure.coerce_maps cimport (NamedConvertMap, DefaultConvertMap,
-                            DefaultConvertMap_unique, CallableConvertMap)
--from .element cimport parent
-+from sage.structure.element cimport parent
- 
- 
- cdef _record_exception():
-diff --git a/src/sage/structure/parent_base.pxd b/src/sage/structure/parent_base.pxd
-index 225fccabcae..8ffac64eff2 100644
---- a/src/sage/structure/parent_base.pxd
-+++ b/src/sage/structure/parent_base.pxd
-@@ -6,7 +6,7 @@
- #                  https://www.gnu.org/licenses/
- ###############################################################################
- 
--from .parent_old cimport Parent as Parent_old
-+from sage.structure.parent_old cimport Parent as Parent_old
- 
- cdef class ParentWithBase(Parent_old):
-     pass
-diff --git a/src/sage/structure/parent_base.pyx b/src/sage/structure/parent_base.pyx
-index dd697f90135..b41175b5bff 100644
---- a/src/sage/structure/parent_base.pyx
-+++ b/src/sage/structure/parent_base.pyx
-@@ -12,7 +12,7 @@ Base class for old-style parent objects with a base ring
- # ****************************************************************************
- 
- cimport sage.structure.parent as parent
--from .coerce_exceptions import CoercionException
-+from sage.structure.coerce_exceptions import CoercionException
- 
- cdef inline check_old_coerce(parent.Parent p):
-     if p._element_constructor is not None:
-diff --git a/src/sage/structure/parent_gens.pxd b/src/sage/structure/parent_gens.pxd
-index 6ec0e6e83f0..cf3b416317f 100644
---- a/src/sage/structure/parent_gens.pxd
-+++ b/src/sage/structure/parent_gens.pxd
-@@ -12,7 +12,7 @@ Parent objects with generators
- #                  http://www.gnu.org/licenses/
- #*****************************************************************************
- 
--from .parent_base cimport ParentWithBase
-+from sage.structure.parent_base cimport ParentWithBase
- 
- 
- cdef class ParentWithGens(ParentWithBase):
-diff --git a/src/sage/structure/parent_old.pyx b/src/sage/structure/parent_old.pyx
-index 77a7888d3b8..82bf9ead04b 100644
---- a/src/sage/structure/parent_old.pyx
-+++ b/src/sage/structure/parent_old.pyx
-@@ -27,7 +27,7 @@ This came up in some subtle bug once::
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- from sage.misc.superseded import deprecation
--from .coerce cimport py_scalar_parent
-+from sage.structure.coerce cimport py_scalar_parent
- from sage.ext.stdsage cimport HAS_DICTIONARY
- from sage.sets.pythonclass cimport Set_PythonType, Set_PythonType_class
- 
-diff --git a/src/sage/structure/sage_object_test.py b/src/sage/structure/sage_object_test.py
-index 0922545a62c..721c1ad7719 100644
---- a/src/sage/structure/sage_object_test.py
-+++ b/src/sage/structure/sage_object_test.py
-@@ -1,6 +1,7 @@
- 
- import pytest
--from .sage_object import SageObject
-+from sage.structure.sage_object import SageObject
-+
- 
- class SageObjectTests:
- 
diff --git a/srcpkgs/sagemath/patches/36600-giac_1.9.0-67.patch b/srcpkgs/sagemath/patches/36600-giac_1.9.0-67.patch
deleted file mode 100644
index a1ad357828a56..0000000000000
--- a/srcpkgs/sagemath/patches/36600-giac_1.9.0-67.patch
+++ /dev/null
@@ -1,52 +0,0 @@
-diff --git a/src/sage/libs/giac/__init__.py b/src/sage/libs/giac/__init__.py
-index 558cd894b13..e7d7bc67d14 100644
---- a/src/sage/libs/giac/__init__.py
-+++ b/src/sage/libs/giac/__init__.py
-@@ -172,9 +172,9 @@ def groebner_basis(gens, proba_epsilon=None, threads=None, prot=False,
-         sage: from sage.libs.giac import groebner_basis as gb_giac
-         sage: P = PolynomialRing(GF(previous_prime(2**31)), 6, 'x')
-         sage: I = sage.rings.ideal.Cyclic(P)
--        sage: B=gb_giac(I.gens());B
--        <BLANKLINE>
--        // Groebner basis computation time ...
-+        sage: B = gb_giac(I.gens())
-+        ...
-+        sage: B
-         Polynomial Sequence with 45 Polynomials in 6 Variables
-         sage: B.is_groebner()
-         True
-@@ -184,8 +184,7 @@ def groebner_basis(gens, proba_epsilon=None, threads=None, prot=False,
-         sage: P = PolynomialRing(GF(previous_prime(2**31)), 5, 'x')
-         sage: I = sage.rings.ideal.Cyclic(P)
-         sage: B = gb_giac(I.gens(), elim_variables=[P.gen(0), P.gen(2)])
--        <BLANKLINE>
--        // Groebner basis computation time ...
-+        ...
-         sage: B.is_groebner()
-         True
-         sage: B.ideal() == I.elimination_ideal([P.gen(0), P.gen(2)])
-@@ -201,11 +200,10 @@ def groebner_basis(gens, proba_epsilon=None, threads=None, prot=False,
-         ...
-         sage: sage.structure.proof.all.polynomial(True)
-         sage: B2 = gb_giac(I.gens()) # long time (4s)
--        <BLANKLINE>
--        // Groebner basis computation time...
-+        ...
-         sage: B1 == B2 # long time
-         True
--        sage: B1.is_groebner() # long time (20s)
-+        sage: B1.is_groebner() # not tested, too long time (50s)
-         True
- 
-     * multi threaded operations::
-@@ -253,9 +251,7 @@ def groebner_basis(gens, proba_epsilon=None, threads=None, prot=False,
-         sage: libgiac.purge('x2'),libgiac.purge('x4')
-         (22, whywouldyoudothis)
-         sage: gb_giac(I) # long time (3s)
--        <BLANKLINE>
--        // Groebner basis computation time...
--        Polynomial Sequence with 74 Polynomials in 8 Variables
-+        ...Polynomial Sequence with 74 Polynomials in 8 Variables
- 
-         sage: I = ideal(P(0),P(0))
-         sage: I.groebner_basis() == gb_giac(I)
diff --git a/srcpkgs/sagemath/patches/get_patches b/srcpkgs/sagemath/patches/get_patches
index ea4d23c49f3ed..ff7a9eacc2d46 100755
--- a/srcpkgs/sagemath/patches/get_patches
+++ b/srcpkgs/sagemath/patches/get_patches
@@ -20,12 +20,14 @@ get_pr() {
 # run from patches dir
 cd $(dirname "$0")
 
+# merged in 10.2.rc0
+#get_pr  36544   "networkx 3.2"
+#get_pr  36543   "cython warning"
+#get_pr  36573   "relative imports"
+#get_pr  36600   "giac 1.9.0-67"
+
 # positive review
-get_pr  36544   "networkx 3.2"
 
 # needs review
 get_pr  35848   "flintlib 3.0"
-get_pr  36543   "cython warning"
 get_pr  36551   "fix qf.nbs"
-get_pr  36573   "relative imports"
-get_pr  36600   "giac 1.9.0-67"
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 75f39fe5b0374..92c617a882f0e 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,6 +1,6 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=10.2.beta9
+version=10.2.rc0
 revision=1
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
@@ -33,7 +33,7 @@ license="GPL-2.0-or-later"
 homepage="https://www.sagemath.org/"
 changelog="https://github.com/sagemath/sage/releases"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=e6899566ca0c7c45984738aaf3378930d0f1746381daab8f61fb2e4b78af7394
+checksum=9b068fda468dc196aefe2b9ff5c98e9be3b1e85010d3cfa193b36c06ef8ef6e1
 nocross="due to ntl (flintlib), fflas-ffpack, givaro, linbox, cysignals, sympow, maxima"
 
 post_patch() {
diff --git a/srcpkgs/sagemath/update b/srcpkgs/sagemath/update
index 68be3c5752d06..4e62503e2f8f4 100644
--- a/srcpkgs/sagemath/update
+++ b/srcpkgs/sagemath/update
@@ -1,2 +1,3 @@
 pkgname="sage"
-site="https://mirrors.mit.edu/sage/src/index.html"
+site="https://mirrors.mit.edu/sage/src/
+https://mirrors.mit.edu/sage/devel/"

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

* Re: [PR PATCH] [Updated] [RC] sagemath: update to 10.2, flintlib: update to 3.0.1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (5 preceding siblings ...)
  2023-11-07  2:21 ` tornaria
@ 2023-11-10 23:49 ` tornaria
  2023-11-11 12:21 ` tornaria
                   ` (21 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: tornaria @ 2023-11-10 23:49 UTC (permalink / raw)
  To: ml

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

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

https://github.com/tornaria/void-packages flintlib
https://github.com/void-linux/void-packages/pull/46832

[RC] sagemath: update to 10.2, flintlib: update to 3.0.1
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **briefly**

This is a major update. A couple of packages need rebuilding (eclib, singular).

For sagemath, we need a patch (in progress: https://github.com/sagemath/sage/pull/35848).

Since backporting patches is a pain and we are not in a hurry, I'm instead targeting 10.2.beta8. Note this already moves sagemath to cython 3.

The goal is to merge flintlib 3.0 together with sagemath 10.2 when the latter is released.

<!--
#### 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/46832.patch is attached

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

From 2297107f9e9913715e096d36754d76e22d213966 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 11 Sep 2023 20:11:20 -0300
Subject: [PATCH 1/6] flintlib: update to 3.0.1.

---
 common/shlibs                                 |  3 +--
 srcpkgs/arb                                   |  1 +
 srcpkgs/arb-devel                             |  2 +-
 srcpkgs/arb/template                          | 24 -----------------
 .../patches/fix-test-t-sdiv_qrnnd.patch       | 23 ----------------
 srcpkgs/flintlib/template                     | 27 ++++++++++++++++---
 6 files changed, 26 insertions(+), 54 deletions(-)
 create mode 120000 srcpkgs/arb
 delete mode 100644 srcpkgs/arb/template
 delete mode 100644 srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch

diff --git a/common/shlibs b/common/shlibs
index 7e9cee83f8417..7037e1d730f79 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3972,8 +3972,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.17 flintlib-2.9.0_1
-libarb.so.2 arb-2.20.0_1
+libflint.so.18 flintlib-3.0.0_1
 libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
diff --git a/srcpkgs/arb b/srcpkgs/arb
new file mode 120000
index 0000000000000..7c2633183069f
--- /dev/null
+++ b/srcpkgs/arb
@@ -0,0 +1 @@
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb-devel b/srcpkgs/arb-devel
index 456b9f00a86cd..7c2633183069f 120000
--- a/srcpkgs/arb-devel
+++ b/srcpkgs/arb-devel
@@ -1 +1 @@
-arb
\ No newline at end of file
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
deleted file mode 100644
index 84a62c7ffdba3..0000000000000
--- a/srcpkgs/arb/template
+++ /dev/null
@@ -1,24 +0,0 @@
-# Template file for 'arb'
-pkgname=arb
-version=2.23.0
-revision=1
-build_style=configure
-configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
-makedepends="flintlib-devel"
-short_desc="C library for arbitrary-precision interval arithmetic"
-maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
-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=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
-
-arb-devel_package() {
-	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"
-	short_desc+=" - development files"
-	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.a"
-		vmove "usr/lib/*.so"
-	}
-}
diff --git a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch b/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
deleted file mode 100644
index cfa109792892c..0000000000000
--- a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From fb8ddbcc06afa2a8f25637032fbb8211f6c6c122 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= <albin.ahlback@gmail.com>
-Date: Fri, 20 May 2022 14:16:38 +0200
-Subject: [PATCH] Fix bug in test code for GCC 12
-
----
- test/t-sdiv_qrnnd.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/test/t-sdiv_qrnnd.c b/test/t-sdiv_qrnnd.c
-index 2e9822e848..2676903826 100644
---- a/test/t-sdiv_qrnnd.c
-+++ b/test/t-sdiv_qrnnd.c
-@@ -33,7 +33,7 @@ int main(void)
-         {
-             d = n_randtest_not_zero(state);
-             nh = n_randtest(state);
--        } while ((FLINT_ABS(nh) >= FLINT_ABS(d)/2) || (nh == WORD_MIN));
-+        } while ((nh == WORD_MIN) || (FLINT_ABS(nh) >= FLINT_ABS(d)/2));
- 
-         nl = n_randtest(state);
- 
-
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index f7442c8052aaa..cbb73ee5f1438 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,10 +1,11 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.9.0
+version=3.0.1
 revision=1
-build_style=configure
+build_style=gnu-configure
 configure_args="--prefix=/usr $(vopt_with ntl)
- $(vopt_if openblas --with-blas=${XBPS_CROSS_BASE}/usr/include/openblas)"
+ $(vopt_if openblas --with-blas-include=${XBPS_CROSS_BASE}/usr/include/openblas)"
+hostmakedepends="automake gettext-devel libtool"
 makedepends="mpfr-devel $(vopt_if ntl ntl-devel)
  $(vopt_if openblas openblas-devel)"
 short_desc="Fast Library for Number Theory"
@@ -13,7 +14,7 @@ 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=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
+checksum=7b311a00503a863881eb8177dbeb84322f29399f3d7d72f3b1a4c9ba1d5794b4
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
@@ -28,12 +29,30 @@ esac
 
 CFLAGS="-D_GNU_SOURCE" # needed for cpu_set_t
 
+post_patch() {
+	# run autoconf because we patched configure.ac
+	autoreconf
+}
+
 flintlib-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision} mpfr-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
+		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
 		vmove "usr/lib/*.so"
 	}
 }
+
+arb_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}
+
+arb-devel_package() {
+	depends="${sourcepkg}-devel>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From dea3d70ea28ddffe7daf31c2306369a180467918 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:08:05 -0300
Subject: [PATCH 2/6] eclib: rebuild for flintlib-3.0.1

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

diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 1d4ad58f21b7b..12165ca788dd5 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
 version=20230424
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 makedepends="pari-devel ntl-devel flintlib-devel boost-devel"

From 4bc4983aa54a6371ffe09d41a7724b694116c4dd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:13:15 -0300
Subject: [PATCH 3/6] singular: update to 4.3.2p10.

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

diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index 036e19d470354..beb0e6d30118e 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,6 +1,6 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.2p7
+version=4.3.2p10
 revision=1
 _majver=${version%p*}
 build_style=gnu-configure
@@ -20,7 +20,7 @@ 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/${_majver//./-}/singular-${version}.tar.gz"
-checksum=aad23c30066b7fbc011138a98d60532565d76a847eec6bf2938410d93b272ca3
+checksum=28c2c9fcfee954e00dfa56eb1a7d418d5b1de67c4398d25a0f2b8f73e71552a8
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From e325d20d7f5f3052ae346b570c30e2cb25c44b37 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 19 Jul 2023 21:04:33 -0300
Subject: [PATCH 4/6] python3-pplpy: use cython 3.

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

diff --git a/srcpkgs/python3-pplpy/template b/srcpkgs/python3-pplpy/template
index 4a9c987b2a859..d3b9aebdf2237 100644
--- a/srcpkgs/python3-pplpy/template
+++ b/srcpkgs/python3-pplpy/template
@@ -1,9 +1,9 @@
 # Template file for 'python3-pplpy'
 pkgname=python3-pplpy
 version=0.8.9
-revision=1
+revision=2
 build_style=python3-pep517
-hostmakedepends="python3-setuptools python3-wheel python3-Cython0.29
+hostmakedepends="python3-setuptools python3-wheel python3-Cython
  python3-cysignals python3-gmpy2"
 makedepends="python3-devel gmp-devel gmpxx-devel ppl-devel mpfr-devel
  libmpc-devel pari-devel"

From b93610992b6576c2627ba32cdd7c2cc6c3295b87 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Thu, 19 Oct 2023 08:52:15 -0300
Subject: [PATCH 5/6] python3-networkx: update to 3.2.1.

---
 srcpkgs/python3-networkx/template | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/python3-networkx/template b/srcpkgs/python3-networkx/template
index 186bf64f7bff9..29283d9e5a032 100644
--- a/srcpkgs/python3-networkx/template
+++ b/srcpkgs/python3-networkx/template
@@ -1,11 +1,11 @@
 # Template file for 'python3-networkx'
 pkgname=python3-networkx
-version=3.1
-revision=2
-build_style=python3-module
+version=3.2.1
+revision=1
+build_style=python3-pep517
 # failing in i686
 make_check_args="--deselect networkx/algorithms/approximation/tests/test_traveling_salesman.py::test_asadpour_tsp"
-hostmakedepends="python3-setuptools"
+hostmakedepends="python3-setuptools python3-wheel"
 depends="python3"
 checkdepends="python3-numpy python3-scipy python3-matplotlib python3-pandas
  python3-lxml python3-sympy python3-pytest-xdist"
@@ -15,7 +15,7 @@ license="BSD-3-Clause"
 homepage="https://networkx.org"
 changelog="https://github.com/networkx/networkx/raw/main/doc/release/release_${version}.rst"
 distfiles="${PYPI_SITE}/n/networkx/networkx-${version}.tar.gz"
-checksum=de346335408f84de0eada6ff9fafafff9bcda11f0a0dfaa931133debb146ab61
+checksum=9f1bb5cf3409bf324e0a722c20bdb4c20ee39bf1c30ce8ae499c8502b0b5e0c6
 
 post_install() {
 	vlicense LICENSE.txt

From 77c975419c94395da6dc522417c95b30f5a484a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:50:44 -0300
Subject: [PATCH 6/6] sagemath: update to 10.2.rc1.

---
 .../sagemath/patches/35848-flintlib_3.0.patch | 1738 ++++++++++++++++
 .../patches/35934-singular_4.3.2p7.patch      |  221 ---
 .../sagemath/patches/36006-gmp_6.3.0.patch    |   38 -
 .../patches/36046-fix_memory_leak.patch       |  740 -------
 .../sagemath/patches/36235-ecl_23.9.9.patch   |   39 -
 .../patches/36279-matplotlib_3.8.0.patch      |   24 -
 srcpkgs/sagemath/patches/36403-00pre.patch    |   29 -
 .../sagemath/patches/36407-python_3.12.patch  | 1744 -----------------
 .../sagemath/patches/36551-fix_qf.nbs.patch   |  134 ++
 .../patches/36696-fix_SSL_timeout.patch       |   33 +
 srcpkgs/sagemath/patches/get_patches          |   27 +-
 srcpkgs/sagemath/template                     |   12 +-
 srcpkgs/sagemath/update                       |    3 +-
 13 files changed, 1922 insertions(+), 2860 deletions(-)
 create mode 100644 srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
 delete mode 100644 srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
 delete mode 100644 srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
 delete mode 100644 srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36403-00pre.patch
 delete mode 100644 srcpkgs/sagemath/patches/36407-python_3.12.patch
 create mode 100644 srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
 create mode 100644 srcpkgs/sagemath/patches/36696-fix_SSL_timeout.patch

diff --git a/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
new file mode 100644
index 0000000000000..c1e33e6a3c717
--- /dev/null
+++ b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
@@ -0,0 +1,1738 @@
+diff --git a/build/pkgs/antic/SPKG.rst b/build/pkgs/antic/SPKG.rst
+deleted file mode 100644
+index d6c32377957..00000000000
+--- a/build/pkgs/antic/SPKG.rst
++++ /dev/null
+@@ -1,18 +0,0 @@
+-antic: Algebraic Number Theory In C
+-===================================
+-
+-Description
+------------
+-
+-Algebraic Number Theory In C
+-
+-License
+--------
+-
+-LGPL 2.1
+-
+-Upstream Contact
+-----------------
+-
+-https://github.com/wbhart/antic
+-
+diff --git a/build/pkgs/antic/checksums.ini b/build/pkgs/antic/checksums.ini
+deleted file mode 100644
+index fc8711ecd13..00000000000
+--- a/build/pkgs/antic/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=antic-VERSION.tar.gz
+-sha1=940d8ea2c3512b9d49ee3101cf043f777764bd8f
+-md5=4e896420dd6344b53b307871efb2cbb4
+-cksum=1938565125
+-upstream_url=https://github.com/wbhart/antic/archive/refs/tags/vVERSION.tar.gz
+diff --git a/build/pkgs/antic/dependencies b/build/pkgs/antic/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/antic/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/antic/distros/arch.txt b/build/pkgs/antic/distros/arch.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/conda.txt b/build/pkgs/antic/distros/conda.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/debian.txt b/build/pkgs/antic/distros/debian.txt
+deleted file mode 100644
+index 8fdcd3e5721..00000000000
+--- a/build/pkgs/antic/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libantic-dev
+diff --git a/build/pkgs/antic/distros/fedora.txt b/build/pkgs/antic/distros/fedora.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/freebsd.txt b/build/pkgs/antic/distros/freebsd.txt
+deleted file mode 100644
+index 116ff3a26f3..00000000000
+--- a/build/pkgs/antic/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/antic
+diff --git a/build/pkgs/antic/distros/opensuse.txt b/build/pkgs/antic/distros/opensuse.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/repology.txt b/build/pkgs/antic/distros/repology.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/package-version.txt b/build/pkgs/antic/package-version.txt
+deleted file mode 100644
+index 3a4036fb450..00000000000
+--- a/build/pkgs/antic/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-0.2.5
+diff --git a/build/pkgs/antic/spkg-install.in b/build/pkgs/antic/spkg-install.in
+deleted file mode 100644
+index c57fa884a20..00000000000
+--- a/build/pkgs/antic/spkg-install.in
++++ /dev/null
+@@ -1,19 +0,0 @@
+-cd src
+-
+-# Copied from build/pkgs/flint/spkg-install.in:
+-#   Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-#   --with-ntl because otherwise FLINT's configure script uses
+-#   /usr/local, which is always wrong.
+-#   This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-#   The value $SAGE_LOCAL is always a safe choice even if the library
+-#   is coming from the system and is found using what is in
+-#   LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-flint="$SAGE_LOCAL"  || sdh_die "Error: Failed to configure antic."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/antic/type b/build/pkgs/antic/type
+deleted file mode 100644
+index 134d9bc32d5..00000000000
+--- a/build/pkgs/antic/type
++++ /dev/null
+@@ -1 +0,0 @@
+-optional
+diff --git a/build/pkgs/arb/SPKG.rst b/build/pkgs/arb/SPKG.rst
+deleted file mode 100644
+index cff49ddb95b..00000000000
+--- a/build/pkgs/arb/SPKG.rst
++++ /dev/null
+@@ -1,27 +0,0 @@
+-arb: Arbitrary-precision floating-point ball arithmetic
+-=======================================================
+-
+-Description
+------------
+-
+-Arb is a C library for arbitrary-precision floating-point ball
+-arithmetic, developed by Fredrik Johansson
+-(fredrik.johansson@gmail.com). It supports efficient high-precision
+-computation with polynomials, power series, matrices and special
+-functions over the real and complex numbers, with automatic, rigorous
+-error control.
+-
+-License
+--------
+-
+-GNU General Public License v2+
+-
+-
+-Upstream Contact
+-----------------
+-
+- - Fredrik Johansson: fredrik.johansson@gmail.com
+-
+- - https://arblib.org/
+-
+- - http://github.com/fredrik-johansson/arb/
+diff --git a/build/pkgs/arb/checksums.ini b/build/pkgs/arb/checksums.ini
+deleted file mode 100644
+index 80ef43dad5d..00000000000
+--- a/build/pkgs/arb/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=arb-VERSION.tar.gz
+-sha1=a1efe035dd3af3613dd685971a156f652b86ff63
+-md5=9b369e29f93cdf2d4f90b57a92526cce
+-cksum=64252121
+-upstream_url=https://github.com/fredrik-johansson/arb/archive/VERSION.tar.gz
+diff --git a/build/pkgs/arb/dependencies b/build/pkgs/arb/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/arb/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/arb/distros/arch.txt b/build/pkgs/arb/distros/arch.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/conda.txt b/build/pkgs/arb/distros/conda.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/debian.txt b/build/pkgs/arb/distros/debian.txt
+deleted file mode 100644
+index 9fe71110712..00000000000
+--- a/build/pkgs/arb/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libflint-arb-dev
+diff --git a/build/pkgs/arb/distros/fedora.txt b/build/pkgs/arb/distros/fedora.txt
+deleted file mode 100644
+index 76794404627..00000000000
+--- a/build/pkgs/arb/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb arb-devel
+diff --git a/build/pkgs/arb/distros/freebsd.txt b/build/pkgs/arb/distros/freebsd.txt
+deleted file mode 100644
+index 2ef8c7cec0f..00000000000
+--- a/build/pkgs/arb/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/arb
+diff --git a/build/pkgs/arb/distros/gentoo.txt b/build/pkgs/arb/distros/gentoo.txt
+deleted file mode 100644
+index 58e3d4f8008..00000000000
+--- a/build/pkgs/arb/distros/gentoo.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-sci-mathematics/arb
+diff --git a/build/pkgs/arb/distros/homebrew.txt b/build/pkgs/arb/distros/homebrew.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/homebrew.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/nix.txt b/build/pkgs/arb/distros/nix.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/nix.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/opensuse.txt b/build/pkgs/arb/distros/opensuse.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/distros/repology.txt b/build/pkgs/arb/distros/repology.txt
+deleted file mode 100644
+index 179c9d507e1..00000000000
+--- a/build/pkgs/arb/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-fp
+diff --git a/build/pkgs/arb/distros/void.txt b/build/pkgs/arb/distros/void.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/void.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/package-version.txt b/build/pkgs/arb/package-version.txt
+deleted file mode 100644
+index e9763f6bfed..00000000000
+--- a/build/pkgs/arb/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-2.23.0
+diff --git a/build/pkgs/arb/spkg-check.in b/build/pkgs/arb/spkg-check.in
+deleted file mode 100644
+index 27cd9419538..00000000000
+--- a/build/pkgs/arb/spkg-check.in
++++ /dev/null
+@@ -1,2 +0,0 @@
+-cd src
+-$MAKE check
+diff --git a/build/pkgs/arb/spkg-configure.m4 b/build/pkgs/arb/spkg-configure.m4
+deleted file mode 100644
+index ef2dd0aac4a..00000000000
+--- a/build/pkgs/arb/spkg-configure.m4
++++ /dev/null
+@@ -1,23 +0,0 @@
+-SAGE_SPKG_CONFIGURE([arb], [
+-    AC_REQUIRE([SAGE_SPKG_CONFIGURE_FLINT])
+-    SAGE_ARB_LIBRARY="arb"
+-    AC_MSG_CHECKING([installing flint? ])
+-    if test x$sage_spkg_install_flint = xyes; then
+-        AC_MSG_RESULT([yes; install arb as well])
+-        sage_spkg_install_arb=yes
+-    else
+-        AC_CHECK_HEADER(arb.h, [
+-        dnl below function added in version 2.16 of arb
+-            AC_CHECK_LIB([arb], [acb_mat_eig_simple], [],
+-              [dnl in Debian the name of dylib is different.
+-               AC_CHECK_LIB([flint-arb], [acb_mat_eig_simple],
+-                [SAGE_ARB_LIBRARY="flint-arb"], [sage_spkg_install_arb=yes])])
+-        ], [sage_spkg_install_arb=yes])
+-    fi
+-], [], [], [
+-    if test x$sage_spkg_install_arb = xyes; then
+-        AC_SUBST(SAGE_ARB_LIBRARY,["arb"])
+-    else
+-        AC_SUBST(SAGE_ARB_LIBRARY,[$SAGE_ARB_LIBRARY])
+-    fi
+-])
+diff --git a/build/pkgs/arb/spkg-install.in b/build/pkgs/arb/spkg-install.in
+deleted file mode 100644
+index 9322f04c912..00000000000
+--- a/build/pkgs/arb/spkg-install.in
++++ /dev/null
+@@ -1,17 +0,0 @@
+-cd src
+-
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-flint because otherwise ARB's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure --disable-static --prefix="$SAGE_LOCAL" \
+-        --with-gmp="$SAGE_LOCAL" \
+-        --with-mpfr="$SAGE_LOCAL" \
+-        --with-flint="$SAGE_LOCAL" || \
+-    sdh_die "Error configuring arb."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/arb/type b/build/pkgs/arb/type
+deleted file mode 100644
+index a6a7b9cd726..00000000000
+--- a/build/pkgs/arb/type
++++ /dev/null
+@@ -1 +0,0 @@
+-standard
+diff --git a/build/pkgs/e_antic/dependencies b/build/pkgs/e_antic/dependencies
+index fea1ffbda45..8e977a55c13 100644
+--- a/build/pkgs/e_antic/dependencies
++++ b/build/pkgs/e_antic/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) flint arb antic boost_cropped
++$(MP_LIBRARY) flint boost_cropped
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/SPKG.rst b/build/pkgs/flint/SPKG.rst
+index f91de70d1ff..d9dcea0903b 100644
+--- a/build/pkgs/flint/SPKG.rst
++++ b/build/pkgs/flint/SPKG.rst
+@@ -4,8 +4,8 @@ flint: Fast Library for Number Theory
+ Description
+ -----------
+ 
+-FLINT is a C library for doing number theory, maintained by William
+-Hart.
++FLINT is a C library for doing number theory, maintained by
++Fredrik Johansson.
+ 
+ Website: http://www.flintlib.org
+ 
+@@ -20,4 +20,4 @@ Upstream Contact
+ 
+ -  flint-devel Gougle Group
+    (http://groups.google.co.uk/group/flint-devel)
+--  William Hart
++-  Fredrik Johansson
+diff --git a/build/pkgs/flint/checksums.ini b/build/pkgs/flint/checksums.ini
+index 3d449d98064..2cec823bfb1 100644
+--- a/build/pkgs/flint/checksums.ini
++++ b/build/pkgs/flint/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=flint-VERSION.tar.gz
+-sha1=63d90f8242c8f8ab4011fbcfb44b86c154f43abd
+-md5=c2d3cec326438f159a530c66eb07fafe
+-cksum=4244948341
+-upstream_url=http://flintlib.org/flint-VERSION.tar.gz
++sha1=c548b1d5eb86a1805de9bef56629455b61e873f7
++md5=24551d4e475290ce6b831c78fafb5efb
++cksum=1567352998
++upstream_url=https://github.com/flintlib/flint/releases/download/vVERSION/flint-VERSION.tar.gz
+diff --git a/build/pkgs/flint/dependencies b/build/pkgs/flint/dependencies
+index 385df4faa7d..1108dc4fb21 100644
+--- a/build/pkgs/flint/dependencies
++++ b/build/pkgs/flint/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) mpfr ntl
++$(MP_LIBRARY) mpfr
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/package-version.txt b/build/pkgs/flint/package-version.txt
+index c8e38b61405..4a36342fcab 100644
+--- a/build/pkgs/flint/package-version.txt
++++ b/build/pkgs/flint/package-version.txt
+@@ -1 +1 @@
+-2.9.0
++3.0.0
+diff --git a/build/pkgs/flint/spkg-build.in b/build/pkgs/flint/spkg-build.in
+new file mode 100644
+index 00000000000..ffb822c8a97
+--- /dev/null
++++ b/build/pkgs/flint/spkg-build.in
+@@ -0,0 +1,3 @@
++cd src
++sdh_configure
++sdh_make
+diff --git a/build/pkgs/flint/spkg-configure.m4 b/build/pkgs/flint/spkg-configure.m4
+index a58108c9d6e..9576e4cc1e9 100644
+--- a/build/pkgs/flint/spkg-configure.m4
++++ b/build/pkgs/flint/spkg-configure.m4
+@@ -1,25 +1,8 @@
+ SAGE_SPKG_CONFIGURE([flint], [
+-    SAGE_SPKG_DEPCHECK([mpfr ntl], [
++    SAGE_SPKG_DEPCHECK([mpfr], [
+         AC_CHECK_HEADER(flint/flint.h, [
+-          dnl flint_parallel_binary_splitting appears in Flint 2.9.0, needed by arb 2.23
+-          AC_SEARCH_LIBS([flint_parallel_binary_splitting], [flint], [
+-            dnl check that NTL is linked in
+-            AC_SEARCH_LIBS([fmpz_poly_get_ZZX], [flint], [
+-
+-              AC_MSG_CHECKING([that GC is not enabled in Flint... ])
+-              AC_RUN_IFELSE([
+-                 AC_LANG_PROGRAM([[#include <flint/flint.h>]], [
+-                                  [#ifdef HAVE_GC]
+-                                     [return HAVE_GC;]
+-                                  [#else]
+-                                     [return 0;]
+-                                  [#endif]])],
+-                 [AC_MSG_RESULT([GC not enabled. Good.])],
+-                        [AC_MSG_RESULT([GC enabled. Incompatible with Sage.])
+-                         sage_spkg_install_flint=yes],
+-                 [AC_MSG_RESULT(["cross compiling. assuming GC is not enabled"])])
+-            ], [sage_spkg_install_flint=yes])
+-          ], [sage_spkg_install_flint=yes])
++          dnl gr_get_fexpr appears in Flint 3.0
++          AC_SEARCH_LIBS([gr_get_fexpr], [flint], [], [sage_spkg_install_flint=yes])
+         ], [sage_spkg_install_flint=yes])
+     ])
+ ], [], [], [
+diff --git a/build/pkgs/flint/spkg-install.in b/build/pkgs/flint/spkg-install.in
+index eacd7b6e491..3ea8c053669 100644
+--- a/build/pkgs/flint/spkg-install.in
++++ b/build/pkgs/flint/spkg-install.in
+@@ -1,36 +1,2 @@
+-###############################################################################
+-#
+-# FLINT Sage install script
+-#
+-###############################################################################
+-if [ "$SAGE_DEBUG" = "yes" ]; then
+-    echo "Building a debug version of FLINT."
+-    FLINT_TUNE=" $FLINT_TUNE"; export FLINT_TUNE
+-    FLINT_CONFIGURE="--enable-assert $FLINT_CONFIGURE"
+-fi
+-
+ cd src
+-
+-echo "Configuring FLINT."
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-ntl because otherwise FLINT's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-ntl="$SAGE_LOCAL" \
+-    $FLINT_CONFIGURE || sdh_die "Error: Failed to configure FLINT."
+-
+-sdh_make verbose
+-
+-echo "Deleting old FLINT files."
+-rm -f $SAGE_LOCAL/lib/libflint*
+-rm -rf $SAGE_LOCAL/include/flint
+-
+ sdh_make_install
+diff --git a/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+new file mode 100644
+index 00000000000..27a642a13b0
+--- /dev/null
++++ b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+@@ -0,0 +1,53 @@
++From fe730579476de0b2d4181a38efa7f63dff9c81d7 Mon Sep 17 00:00:00 2001
++From: Marc Mezzarobba <marc@mezzarobba.net>
++Date: Tue, 12 Sep 2023 08:23:08 +0200
++Subject: [PATCH] Make msolve build with flint3
++
++---
++ src/fglm/berlekamp_massey.c | 3 +++
++ src/fglm/data_fglm.c        | 7 +++++--
++ 2 files changed, 8 insertions(+), 2 deletions(-)
++
++diff --git a/src/fglm/berlekamp_massey.c b/src/fglm/berlekamp_massey.c
++index b0f2052..998af1c 100644
++--- a/src/fglm/berlekamp_massey.c
+++++ b/src/fglm/berlekamp_massey.c
++@@ -30,6 +30,9 @@
++ */
++ 
++ #include <stdlib.h>
+++#if __FLINT_VERSION >= 3
+++#  include <flint/nmod.h>
+++#endif
++ //#include "nmod_poly.h"
++ //#include "mpn_extras.h"
++ 
++diff --git a/src/fglm/data_fglm.c b/src/fglm/data_fglm.c
++index 0726760..0e1da6f 100644
++--- a/src/fglm/data_fglm.c
+++++ b/src/fglm/data_fglm.c
++@@ -24,6 +24,7 @@
++ #include <flint/mpn_extras.h>
++ #include <flint/nmod_poly.h>
++ #include <flint/nmod_poly_factor.h>
+++#include <flint/ulong_extras.h>
++ 
++ 
++ typedef uint32_t szmat_t;
++@@ -299,9 +300,11 @@ static inline void nmod_poly_set_prime(nmod_poly_t poly,
++   mp_limb_t ninv = n_preinvert_limb(prime);
++   poly->mod.n = prime;
++   poly->mod.ninv = ninv;
+++#if __FLINT_VERSION < 3
++   count_leading_zeros(poly->mod.norm, prime);
++-  /* poly->mod.norm = flint_clz(prime); */
++-
+++#else
+++  poly->mod.norm = flint_clz(prime);
+++#endif
++ }
++ 
++ static inline void fglm_param_set_prime(param_t *param, mp_limb_t prime){
++-- 
++2.40.1
++
+diff --git a/build/pkgs/sagelib/dependencies b/build/pkgs/sagelib/dependencies
+index 5dc2efe1d31..fa6e98df7db 100644
+--- a/build/pkgs/sagelib/dependencies
++++ b/build/pkgs/sagelib/dependencies
+@@ -1,4 +1,4 @@
+-FORCE $(SCRIPTS) arb boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
++FORCE $(SCRIPTS) boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/symengine/dependencies b/build/pkgs/symengine/dependencies
+index 1fc34963eda..7795d486018 100644
+--- a/build/pkgs/symengine/dependencies
++++ b/build/pkgs/symengine/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) arb ecm flint mpc mpfr | cmake
++$(MP_LIBRARY) ecm flint mpc mpfr | cmake
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/pkgs/sage-conf/_sage_conf/_conf.py.in b/pkgs/sage-conf/_sage_conf/_conf.py.in
+index 87b27ca05cb..895d6572d1e 100644
+--- a/pkgs/sage-conf/_sage_conf/_conf.py.in
++++ b/pkgs/sage-conf/_sage_conf/_conf.py.in
+@@ -19,8 +19,6 @@ MAXIMA_FAS = "@SAGE_MAXIMA_FAS@".replace('${prefix}', SAGE_LOCAL)
+ # Delete this line if your ECL can load Kenzo without further prodding.
+ KENZO_FAS = "@SAGE_KENZO_FAS@".replace('${prefix}', SAGE_LOCAL)
+ 
+-ARB_LIBRARY = "@SAGE_ARB_LIBRARY@"
+-
+ NTL_INCDIR = "@NTL_INCDIR@"
+ NTL_LIBDIR = "@NTL_LIBDIR@"
+ 
+diff --git a/src/sage/env.py b/src/sage/env.py
+index b1fe9a89cd1..9197fc3a703 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -223,7 +223,6 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st
+ FOURTITWO_PPI = var("FOURTITWO_PPI")
+ FOURTITWO_CIRCUITS = var("FOURTITWO_CIRCUITS")
+ FOURTITWO_GROEBNER = var("FOURTITWO_GROEBNER")
+-ARB_LIBRARY = var("ARB_LIBRARY", "arb")
+ CBLAS_PC_MODULES = var("CBLAS_PC_MODULES", "cblas:openblas:blas")
+ ECL_CONFIG = var("ECL_CONFIG", "ecl-config")
+ NTL_INCDIR = var("NTL_INCDIR")
+@@ -356,8 +355,7 @@ def cython_aliases(required_modules=None,
+         sage: cython_aliases()
+         {...}
+         sage: sorted(cython_aliases().keys())
+-        ['ARB_LIBRARY',
+-         'CBLAS_CFLAGS',
++        ['CBLAS_CFLAGS',
+          ...,
+          'ZLIB_LIBRARIES']
+         sage: cython_aliases(required_modules=('module-that-is-assumed-to-not-exist'))
+@@ -475,8 +473,6 @@ def uname_specific(name, value, alternative):
+     if "LINBOX_CFLAGS" in aliases:
+         aliases["LINBOX_CFLAGS"].append("-std=gnu++11")
+ 
+-    aliases["ARB_LIBRARY"] = ARB_LIBRARY
+-
+     # TODO: Remove Cygwin hack by installing a suitable cblas.pc
+     if os.path.exists('/usr/lib/libblas.dll.a'):
+         aliases["CBLAS_LIBS"] = ['gslcblas']
+diff --git a/src/sage/features/sagemath.py b/src/sage/features/sagemath.py
+index 7404e6d0a8e..6037d097391 100644
+--- a/src/sage/features/sagemath.py
++++ b/src/sage/features/sagemath.py
+@@ -761,7 +761,7 @@ class sage__rings__number_field(JoinFeature):
+     A :class:`~sage.features.Feature` describing the presence of :mod:`sage.rings.number_field`.
+ 
+     Number fields are implemented in Sage using a complicated mixture of various libraries,
+-    including :ref:`arb <spkg_arb>`, :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
++    including :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
+     :ref:`MPFI <spkg_mpfi>`, :ref:`NTL <spkg_ntl>`, and :ref:`PARI <spkg_pari>`.
+ 
+     EXAMPLES:
+diff --git a/src/sage/libs/arb/acb.pxd b/src/sage/libs/arb/acb.pxd
+index 5148dc43991..851488d803a 100644
+--- a/src/sage/libs/arb/acb.pxd
++++ b/src/sage/libs/arb/acb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -152,10 +152,6 @@ cdef extern from "arb_wrap.h":
+     void acb_sech(acb_t s, const acb_t z, long prec)
+     void acb_csch(acb_t c, const acb_t z, long prec)
+ 
+-    void acb_rising_ui_bs(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui_rs(acb_t z, const acb_t x, unsigned long n, unsigned long step, long prec)
+-    void acb_rising_ui_rec(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui(acb_t z, const acb_t x, unsigned long n, long prec)
+     void acb_rising(acb_t z, const acb_t x, const acb_t n, long prec)
+ 
+     void acb_gamma(acb_t y, const acb_t x, long prec)
+diff --git a/src/sage/libs/arb/acb_calc.pxd b/src/sage/libs/arb/acb_calc.pxd
+index a5dbf360b5e..67bd2ed57dc 100644
+--- a/src/sage/libs/arb/acb_calc.pxd
++++ b/src/sage/libs/arb/acb_calc.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_calc.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_elliptic.pxd b/src/sage/libs/arb/acb_elliptic.pxd
+index 176f68df00e..e3480e9f73b 100644
+--- a/src/sage/libs/arb/acb_elliptic.pxd
++++ b/src/sage/libs/arb/acb_elliptic.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_elliptic.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_hypgeom.pxd b/src/sage/libs/arb/acb_hypgeom.pxd
+index 418e766f10d..c43e5c0623b 100644
+--- a/src/sage/libs/arb/acb_hypgeom.pxd
++++ b/src/sage/libs/arb/acb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_hypgeom.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_modular.pxd b/src/sage/libs/arb/acb_modular.pxd
+index c708e9bf97d..cdc413c92da 100644
+--- a/src/sage/libs/arb/acb_modular.pxd
++++ b/src/sage/libs/arb/acb_modular.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_modular.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_poly.pxd b/src/sage/libs/arb/acb_poly.pxd
+index 69f4320055b..ae02757ffd9 100644
+--- a/src/sage/libs/arb/acb_poly.pxd
++++ b/src/sage/libs/arb/acb_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -79,24 +79,10 @@ cdef extern from "arb_wrap.h":
+     void _acb_poly_divrem(acb_ptr Q, acb_ptr R, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec)
+     bint acb_poly_divrem(acb_poly_t Q, acb_poly_t R, const acb_poly_t A, const acb_poly_t B, long prec)
+     void _acb_poly_div_root(acb_ptr Q, acb_t R, acb_srcptr A, long len, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_horner(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_horner(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_divconquer(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_divconquer(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_convolution(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_convolution(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+     void _acb_poly_taylor_shift(acb_ptr g, const acb_t c, long n, long prec)
+     void acb_poly_taylor_shift(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_compose_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_divconquer(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_divconquer(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+     void _acb_poly_compose(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+     void acb_poly_compose(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_series_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+-    void _acb_poly_compose_series_brent_kung(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_brent_kung(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_compose_series(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+     void acb_poly_compose_series(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_revert_series_lagrange(acb_ptr h, acb_srcptr f, long flen, long n, long prec)
+@@ -161,10 +147,6 @@ cdef extern from "arb_wrap.h":
+     void acb_poly_exp_series_basecase(acb_poly_t f, const acb_poly_t h, long n, long prec)
+     void _acb_poly_exp_series(acb_ptr f, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_exp_series(acb_poly_t f, const acb_poly_t h, long n, long prec)
+-    void _acb_poly_sin_cos_series_basecase(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_basecase(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+-    void _acb_poly_sin_cos_series_tangent(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_tangent(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+     void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_sin_cos_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec)
+     void _acb_poly_sin_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec)
+diff --git a/src/sage/libs/arb/arb.pxd b/src/sage/libs/arb/arb.pxd
+index c82b94de30f..acd232ab816 100644
+--- a/src/sage/libs/arb/arb.pxd
++++ b/src/sage/libs/arb/arb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -224,15 +224,8 @@ cdef extern from "arb_wrap.h":
+ 
+     void arb_lambertw(arb_t res, const arb_t x, int flags, long prec)
+ 
+-    void arb_rising_ui_bs(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui_rs(arb_t z, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising_ui_rec(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui(arb_t z, const arb_t x, unsigned long n, long prec)
+     void arb_rising(arb_t z, const arb_t x, const arb_t n, long prec)
+     void arb_rising_fmpq_ui(arb_t z, const fmpq_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_bs(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_rs(arb_t u, arb_t v, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising2_ui(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+     void arb_fac_ui(arb_t z, unsigned long n, long prec)
+     void arb_bin_ui(arb_t z, const arb_t n, unsigned long k, long prec)
+     void arb_bin_uiui(arb_t z, unsigned long n, unsigned long k, long prec)
+diff --git a/src/sage/libs/arb/arb_fmpz_poly.pxd b/src/sage/libs/arb/arb_fmpz_poly.pxd
+index 079f76e9d9e..55daa705238 100644
+--- a/src/sage/libs/arb/arb_fmpz_poly.pxd
++++ b/src/sage/libs/arb/arb_fmpz_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_fmpz_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -22,5 +22,4 @@ cdef extern from "arb_wrap.h":
+     unsigned long arb_fmpz_poly_deflation(const fmpz_poly_t poly)
+     void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long deflation)
+     void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, long prec)
+-    void arb_fmpz_poly_cos_minpoly(fmpz_poly_t res, unsigned long n)
+     void arb_fmpz_poly_gauss_period_minpoly(fmpz_poly_t res, unsigned long q, unsigned long n)
+diff --git a/src/sage/libs/arb/arb_hypgeom.pxd b/src/sage/libs/arb/arb_hypgeom.pxd
+index fb1c40ddaa8..139b987d669 100644
+--- a/src/sage/libs/arb/arb_hypgeom.pxd
++++ b/src/sage/libs/arb/arb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_hypgeom.h
+ 
+ from sage.libs.flint.types cimport fmpz_t
+diff --git a/src/sage/libs/arb/arb_wrap.h b/src/sage/libs/arb/arb_wrap.h
+index 49997075ee5..488bb376d5e 100644
+--- a/src/sage/libs/arb/arb_wrap.h
++++ b/src/sage/libs/arb/arb_wrap.h
+@@ -5,25 +5,27 @@
+  * by arb, most of which rely on flint's ulong and slong defines.
+  */
+ 
++#include <mpfr.h>
++
+ #undef ulong
+ #undef slong
+ 
+ #define ulong mp_limb_t
+ #define slong mp_limb_signed_t
+ 
+-#include <acb.h>
+-#include <acb_calc.h>
+-#include <acb_elliptic.h>
+-#include <acb_hypgeom.h>
+-#include <acb_mat.h>
+-#include <acb_modular.h>
+-#include <acb_poly.h>
+-#include <arb.h>
+-#include <arb_fmpz_poly.h>
+-#include <arb_hypgeom.h>
+-#include <arf.h>
+-#include <bernoulli.h>
+-#include <mag.h>
++#include <flint/acb.h>
++#include <flint/acb_calc.h>
++#include <flint/acb_elliptic.h>
++#include <flint/acb_hypgeom.h>
++#include <flint/acb_mat.h>
++#include <flint/acb_modular.h>
++#include <flint/acb_poly.h>
++#include <flint/arb.h>
++#include <flint/arb_fmpz_poly.h>
++#include <flint/arb_hypgeom.h>
++#include <flint/arf.h>
++#include <flint/bernoulli.h>
++#include <flint/mag.h>
+ 
+ #undef ulong
+ #undef slong
+diff --git a/src/sage/libs/arb/arf.pxd b/src/sage/libs/arb/arf.pxd
+index b8b83fefcdc..84778fe9f09 100644
+--- a/src/sage/libs/arb/arf.pxd
++++ b/src/sage/libs/arb/arf.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arf.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -30,7 +30,6 @@ cdef extern from "arb_wrap.h":
+     void arf_set_ui(arf_t y, unsigned long x)
+     void arf_set_si(arf_t y, long x)
+     void arf_set_mpfr(arf_t y, const mpfr_t x)
+-    # void arf_set_fmpr(arf_t y, const fmpr_t x)
+     void arf_set_d(arf_t y, double x)
+     void arf_swap(arf_t y, arf_t x)
+     void arf_init_set_ui(arf_t y, unsigned long x)
+@@ -46,7 +45,6 @@ cdef extern from "arb_wrap.h":
+     int arf_set_round_fmpz_2exp(arf_t y, const fmpz_t x, const fmpz_t e, long prec, arf_rnd_t rnd)
+     void arf_get_fmpz_2exp(fmpz_t m, fmpz_t e, const arf_t x)
+     double arf_get_d(const arf_t x, arf_rnd_t rnd)
+-    # void arf_get_fmpr(fmpr_t y, const arf_t x)
+     int arf_get_mpfr(mpfr_t y, const arf_t x, mpfr_rnd_t rnd)
+     void arf_get_fmpz(fmpz_t z, const arf_t x, arf_rnd_t rnd)
+     long arf_get_si(const arf_t x, arf_rnd_t rnd)
+diff --git a/src/sage/libs/arb/bernoulli.pxd b/src/sage/libs/arb/bernoulli.pxd
+index 375b2b9bbcf..ea9340f4b15 100644
+--- a/src/sage/libs/arb/bernoulli.pxd
++++ b/src/sage/libs/arb/bernoulli.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = bernoulli.h
+ 
+ from ..flint.types cimport fmpq_t, ulong
+diff --git a/src/sage/libs/arb/mag.pxd b/src/sage/libs/arb/mag.pxd
+index d5d8693ea8f..69dfb990ae0 100644
+--- a/src/sage/libs/arb/mag.pxd
++++ b/src/sage/libs/arb/mag.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = mag.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -27,13 +27,11 @@ cdef extern from "arb_wrap.h":
+     # void mag_randtest(mag_t x, flint_rand_t state, long expbits)
+     # void mag_randtest_special(mag_t x, flint_rand_t state, long expbits)
+     void mag_set_d(mag_t y, double x)
+-    # void mag_set_fmpr(mag_t y, const fmpr_t x)
+     void mag_set_ui(mag_t y, unsigned long x)
+     void mag_set_fmpz(mag_t y, const fmpz_t x)
+     void mag_set_d_2exp_fmpz(mag_t z, double x, const fmpz_t y)
+     void mag_set_fmpz_2exp_fmpz(mag_t z, const fmpz_t x, const fmpz_t y)
+     void mag_set_ui_2exp_si(mag_t z, unsigned long x, long y)
+-    # void mag_get_fmpr(fmpr_t y, const mag_t x)
+     void mag_get_fmpq(fmpq_t y, const mag_t x)
+     void mag_set_ui_lower(mag_t z, unsigned long x)
+     void mag_set_fmpz_lower(mag_t z, const fmpz_t x)
+diff --git a/src/sage/libs/flint/flint_wrap.h b/src/sage/libs/flint/flint_wrap.h
+index 266535c3835..4db72b97660 100644
+--- a/src/sage/libs/flint/flint_wrap.h
++++ b/src/sage/libs/flint/flint_wrap.h
+@@ -15,6 +15,7 @@
+  */
+ 
+ #include <gmp.h>
++#include <mpfr.h>
+ 
+ /* Save previous definition of ulong if any, as pari also uses it */
+ /* Should work on GCC, clang, MSVC */
+@@ -33,6 +34,7 @@
+ 
+ #include <flint/arith.h>
+ #include <flint/fmpq.h>
++#include <flint/fmpq_vec.h>
+ #include <flint/fmpq_mat.h>
+ #include <flint/fmpq_poly.h>
+ #include <flint/fmpz.h>
+@@ -47,6 +49,7 @@
+ #include <flint/fq.h>
+ #include <flint/fq_nmod.h>
+ #include <flint/nmod_poly.h>
++#include <flint/nmod_poly_factor.h>
+ #include <flint/nmod_vec.h>
+ #include <flint/padic.h>
+ #include <flint/padic_poly.h>
+diff --git a/src/sage/libs/flint/fmpq.pxd b/src/sage/libs/flint/fmpq.pxd
+index 5e64c82102f..0616c0a7408 100644
+--- a/src/sage/libs/flint/fmpq.pxd
++++ b/src/sage/libs/flint/fmpq.pxd
+@@ -12,6 +12,8 @@ cdef extern from "flint_wrap.h":
+     fmpz * fmpq_denref(fmpq_t)
+     void fmpq_init(fmpq_t)
+     void fmpq_clear(fmpq_t)
++    void fmpq_init_set_readonly(fmpq_t, const mpq_t)
++    void fmpq_clear_readonly(fmpq_t)
+     void fmpq_one(fmpq_t)
+     void fmpq_zero(fmpq_t)
+     bint fmpq_is_zero(fmpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pxd b/src/sage/libs/flint/fmpq_poly.pxd
+index 6050c487835..afa16e5bbdd 100644
+--- a/src/sage/libs/flint/fmpq_poly.pxd
++++ b/src/sage/libs/flint/fmpq_poly.pxd
+@@ -30,6 +30,9 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_canonicalise(fmpq_poly_t)
+     int fmpq_poly_is_canonical(const fmpq_poly_t)
+ 
++    void _fmpq_poly_set_length(fmpq_poly_t, slong)
++    void _fmpq_poly_normalise(fmpq_poly_t)
++
+     # Polynomial parameters
+     slong fmpq_poly_degree(const fmpq_poly_t)
+     ulong fmpq_poly_length(const fmpq_poly_t)
+@@ -46,10 +49,7 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_ui(fmpq_poly_t, ulong)
+     void fmpq_poly_set_fmpz(fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_set_fmpq(fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+     void fmpq_poly_set_fmpz_poly(fmpq_poly_t, const fmpz_poly_t)
+-    void fmpq_poly_set_array_mpq(fmpq_poly_t, const mpq_t *, slong)
+ 
+     void fmpq_poly_set_str(fmpq_poly_t, const char *)
+     char *fmpq_poly_get_str(const fmpq_poly_t)
+@@ -67,7 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_reverse(fmpq_poly_t, const fmpq_poly_t, slong)
+ 
+     void fmpq_poly_get_coeff_fmpq(fmpq_t, const fmpq_poly_t, slong)
+-    void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_si(slong, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_ui(ulong, const fmpq_poly_t, slong)
+ 
+@@ -75,8 +74,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_coeff_ui(fmpq_poly_t, slong, ulong)
+     void fmpq_poly_set_coeff_fmpz(fmpq_poly_t, slong, const fmpz_t)
+     void fmpq_poly_set_coeff_fmpq(fmpq_poly_t, slong, const fmpq_t)
+-    void fmpq_poly_set_coeff_mpz(fmpq_poly_t, slong, const mpz_t)
+-    void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
+ 
+     # Comparison
+     int fmpq_poly_equal(const fmpq_poly_t, const fmpq_poly_t)
+@@ -100,8 +97,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_mul_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     void fmpq_poly_scalar_div_si(fmpq_poly_t, const fmpq_poly_t, slong)
+     void fmpq_poly_scalar_div_ui(fmpq_poly_t, const fmpq_poly_t, ulong)
+@@ -109,8 +104,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_div_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_div_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_div_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Multiplication
+     void fmpq_poly_mul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -155,8 +148,6 @@ cdef extern from "flint_wrap.h":
+     # Evaluation
+     void fmpq_poly_evaluate_fmpz(fmpq_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_evaluate_fmpq(fmpq_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_evaluate_mpz(mpq_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_evaluate_mpq(mpq_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Composition
+     void fmpq_poly_compose(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -189,3 +180,11 @@ cdef extern from "flint_wrap.h":
+ # since the fmpq_poly header seems to be lacking this inline function
+ cdef inline sage_fmpq_poly_max_limbs(const fmpq_poly_t poly) noexcept:
+     return _fmpz_vec_max_limbs(fmpq_poly_numref(poly), fmpq_poly_length(poly))
++
++# functions removed from flint but still needed in sage
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
++cdef void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
++cdef void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pyx b/src/sage/libs/flint/fmpq_poly.pyx
+new file mode 100644
+index 00000000000..3b8a0cf0c51
+--- /dev/null
++++ b/src/sage/libs/flint/fmpq_poly.pyx
+@@ -0,0 +1,45 @@
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++from sage.libs.gmp.mpq cimport *
++from sage.libs.flint.fmpz cimport *
++from sage.libs.flint.fmpq cimport *
++
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t rop, const fmpq_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t rop, const fmpq_poly_t op, const mpq_t c):
++    cdef fmpq_t f
++    fmpq_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpq(rop, op, f)
++    fmpq_clear_readonly(f)
++
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t poly, slong n, const mpq_t x):
++    cdef fmpq_t t
++    fmpq_init_set_readonly(t, x)
++    fmpq_poly_set_coeff_fmpq(poly, n, t)
++    fmpq_clear_readonly(t)
++
++cdef void fmpq_poly_get_coeff_mpq(mpq_t x, const fmpq_poly_t poly, slong n):
++    cdef fmpq_t t
++    fmpq_init(t)
++    fmpq_poly_get_coeff_fmpq(t, poly, n)
++    fmpq_get_mpq(x, t)
++    fmpq_clear(t)
++
++cdef void fmpq_poly_set_mpq(fmpq_poly_t poly, const mpq_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), mpq_numref(x))
++    fmpz_set_mpz(fmpq_poly_denref(poly), mpq_denref(x))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
++
++cdef void fmpq_poly_set_mpz(fmpq_poly_t poly, const mpz_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), x)
++    fmpz_one(fmpq_poly_denref(poly))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz.pxd b/src/sage/libs/flint/fmpz.pxd
+index 01058d0f130..b97fbe1eae0 100644
+--- a/src/sage/libs/flint/fmpz.pxd
++++ b/src/sage/libs/flint/fmpz.pxd
+@@ -16,6 +16,9 @@ cdef extern from "flint_wrap.h":
+     void fmpz_init_set(fmpz_t, fmpz_t)
+     void fmpz_init_set_ui(fmpz_t, ulong)
+ 
++    void fmpz_init_set_readonly(fmpz_t, const mpz_t)
++    void fmpz_clear_readonly(fmpz_t)
++
+     # Conversion
+     void fmpz_set(fmpz_t f, fmpz_t g)
+     void fmpz_set_ui(fmpz_t, ulong)
+diff --git a/src/sage/libs/flint/fmpz_mod_poly.pxd b/src/sage/libs/flint/fmpz_mod_poly.pxd
+index 24b653eb3b7..2727246da98 100644
+--- a/src/sage/libs/flint/fmpz_mod_poly.pxd
++++ b/src/sage/libs/flint/fmpz_mod_poly.pxd
+@@ -67,13 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_get_coeff_fmpz(fmpz_t x, const fmpz_mod_poly_t poly,
+                                              slong n, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_set_coeff_mpz(fmpz_mod_poly_t poly,
+-                             slong n, const mpz_t x, const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_get_coeff_mpz(mpz_t x,
+-                 const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx)
+-
+-
+     void _fmpz_mod_poly_shift_left(fmpz * res, const fmpz * poly,
+                                                            slong len, slong n)
+ 
+@@ -194,14 +187,6 @@ cdef extern from "flint_wrap.h":
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_div_basecase(fmpz_mod_poly_t Q,
+-                            const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_div_newton_n_preinv(fmpz_mod_poly_t Q,
+-                         const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                         const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem_newton_n_preinv(fmpz_mod_poly_t Q,
+           fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                          const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+@@ -213,10 +198,6 @@ cdef extern from "flint_wrap.h":
+                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_divrem_divconquer(fmpz_mod_poly_t Q,
+-        fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem(fmpz_mod_poly_t Q, fmpz_mod_poly_t R,
+     const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+@@ -254,40 +235,13 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_make_monic_f(fmpz_t f, fmpz_mod_poly_t res,
+                          const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_euclidean(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_gcd_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_hgcd(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-
+     void fmpz_mod_poly_gcd(fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+ 
+-    void fmpz_mod_poly_xgcd_euclidean(fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_hgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S,
+-          fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_xgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                       const fmpz_mod_ctx_t ctx)
+@@ -361,14 +315,6 @@ cdef extern from "flint_wrap.h":
+                         const fmpz_mod_poly_t poly, const fmpz * xs, slong n,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_compose_horner(fmpz_mod_poly_t res,
+-                    const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_compose_divconquer(fmpz_mod_poly_t res,
+-                     const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_compose(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1,
+                          const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx)
+ 
+diff --git a/src/sage/libs/flint/fmpz_poly.pxd b/src/sage/libs/flint/fmpz_poly.pxd
+index 18b36672d30..c8bc6d3ca0a 100644
+--- a/src/sage/libs/flint/fmpz_poly.pxd
++++ b/src/sage/libs/flint/fmpz_poly.pxd
+@@ -28,7 +28,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_poly_set_ui(fmpz_poly_t, ulong)
+     void fmpz_poly_set_si(fmpz_poly_t, slong)
+     void fmpz_poly_set_fmpz(fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+     int fmpz_poly_set_str(fmpz_poly_t, const char *)
+ 
+     char *fmpz_poly_get_str(const fmpz_poly_t)
+@@ -70,7 +69,6 @@ cdef extern from "flint_wrap.h":
+     # Scalar multiplication and division
+     void fmpz_poly_scalar_mul_fmpz(
+             fmpz_poly_t, const fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+     void fmpz_poly_scalar_mul_si(fmpz_poly_t, const fmpz_poly_t, slong)
+     void fmpz_poly_scalar_mul_ui(fmpz_poly_t, const fmpz_poly_t, ulong)
+     void fmpz_poly_scalar_mul_2exp(fmpz_poly_t, const fmpz_poly_t, ulong)
+@@ -310,12 +308,14 @@ cdef extern from "flint_wrap.h":
+             fmpz_poly_t,
+                     const fmpz_poly_t, const fmpz_t, const nmod_poly_t, int)
+ 
+-    # Some functions for backwards compatibility
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
+-    void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++
++# functions removed from flint but still needed in sage
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
++cdef void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++cdef void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+ 
+ 
+ # Wrapper Cython class
+diff --git a/src/sage/libs/flint/fmpz_poly.pyx b/src/sage/libs/flint/fmpz_poly.pyx
+index 74915b37612..cfcbea9090c 100644
+--- a/src/sage/libs/flint/fmpz_poly.pyx
++++ b/src/sage/libs/flint/fmpz_poly.pyx
+@@ -25,10 +25,10 @@ from cysignals.memory cimport sig_free
+ 
+ from sage.arith.long cimport pyobject_to_long
+ from sage.cpython.string cimport char_to_str, str_to_bytes
++from sage.libs.flint.fmpz cimport *
+ from sage.structure.sage_object cimport SageObject
+ from sage.rings.integer cimport Integer
+ 
+-
+ cdef class Fmpz_poly(SageObject):
+ 
+     def __cinit__(self):
+@@ -455,3 +455,44 @@ cdef class Fmpz_poly(SageObject):
+         """
+         from sage.rings.integer_ring import ZZ
+         return ZZ[var](self.list())
++
++
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_divexact_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_fdiv_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t poly, slong n, const mpz_t x):
++    cdef fmpz_t t
++    fmpz_init_set_readonly(t, x)
++    fmpz_poly_set_coeff_fmpz(poly, n, t)
++    fmpz_clear_readonly(t)
++
++cdef void fmpz_poly_get_coeff_mpz(mpz_t x, const fmpz_poly_t poly, slong n):
++    cdef fmpz_t t
++    fmpz_init(t)
++    fmpz_poly_get_coeff_fmpz(t, poly, n)
++    fmpz_get_mpz(x, t)
++    fmpz_clear(t)
++
++cdef void fmpz_poly_set_mpz(fmpz_poly_t poly, const mpz_t x):
++    fmpz_poly_fit_length(poly, 1)
++    fmpz_set_mpz(poly.coeffs, x)
++    _fmpz_poly_set_length(poly, 1)
++    _fmpz_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz_poly_q.pxd b/src/sage/libs/flint/fmpz_poly_q.pxd
+index 846542dc0d8..63c13355bf6 100644
+--- a/src/sage/libs/flint/fmpz_poly_q.pxd
++++ b/src/sage/libs/flint/fmpz_poly_q.pxd
+@@ -49,11 +49,7 @@ cdef extern from "flint_wrap.h":
+ 
+     #* Scalar multiplication and division ****************************************/
+     void fmpz_poly_q_scalar_mul_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_mul_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_mul_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+     void fmpz_poly_q_scalar_div_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_div_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_div_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+ 
+     #* Multiplication and division ***********************************************/
+     void fmpz_poly_q_mul(fmpz_poly_q_t rop, 
+@@ -67,9 +63,6 @@ cdef extern from "flint_wrap.h":
+     #* Derivative ****************************************************************/
+     void fmpz_poly_q_derivative(fmpz_poly_q_t rop, const fmpz_poly_q_t op)
+ 
+-    #* Evaluation ****************************************************************/
+-    int fmpz_poly_q_evaluate(mpq_t rop, const fmpz_poly_q_t f, const mpq_t a)
+-
+     #* Input and output **********************************************************/
+     int fmpz_poly_q_set_str(fmpz_poly_q_t rop, const char *s)
+     char * fmpz_poly_q_get_str(const fmpz_poly_q_t op)
+diff --git a/src/sage/libs/linbox/linbox_flint_interface.pyx b/src/sage/libs/linbox/linbox_flint_interface.pyx
+index dabd375c2b8..3ca65afc514 100644
+--- a/src/sage/libs/linbox/linbox_flint_interface.pyx
++++ b/src/sage/libs/linbox/linbox_flint_interface.pyx
+@@ -33,6 +33,7 @@ and C. Pernet. The functions available are:
+ #                  https://www.gnu.org/licenses/
+ # ****************************************************************************
+ 
++from sage.libs.gmp.types cimport mpz_t
+ from sage.libs.flint.types cimport fmpz_t
+ from sage.libs.flint.fmpz cimport fmpz_get_mpz, fmpz_set_mpz
+ from sage.libs.flint.fmpz_mat cimport fmpz_mat_entry, fmpz_mat_nrows, fmpz_mat_ncols
+@@ -80,11 +81,13 @@ cdef void fmpz_poly_set_linbox(fmpz_poly_t p, PolynomialRing_integer.Element& q)
+     (the .pxd file) in order to keep the header C-compatible
+     """
+     cdef size_t i
++    cdef mpz_t tmp
+ 
+     fmpz_poly_fit_length(p, q.size())
+ 
+     for i in range(q.size()):
+-        fmpz_poly_set_coeff_mpz(p, i, q[i].get_mpz_const())
++        tmp = q[i].get_mpz_const()
++        fmpz_poly_set_coeff_mpz(p, i, tmp)
+ 
+     _fmpz_poly_set_length(p, q.size())
+ 
+diff --git a/src/sage/matrix/matrix_complex_ball_dense.pyx b/src/sage/matrix/matrix_complex_ball_dense.pyx
+index 22366b5f1f2..7fdf3f2aa36 100644
+--- a/src/sage/matrix/matrix_complex_ball_dense.pyx
++++ b/src/sage/matrix/matrix_complex_ball_dense.pyx
+@@ -1,4 +1,4 @@
+-# distutils: libraries = ARB_LIBRARY
++# distutils: libraries = flint
+ r"""
+ Arbitrary precision complex ball matrices using Arb
+ 
+diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx
+index 0712500e67d..daba89d5c43 100644
+--- a/src/sage/matrix/matrix_integer_sparse.pyx
++++ b/src/sage/matrix/matrix_integer_sparse.pyx
+@@ -847,6 +847,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+             sage: matrix(ZZ, 1, 1, sparse=True)._charpoly_linbox()
+             x
+         """
++        cdef mpz_t tmp
+         if self._nrows != self._ncols:
+             raise ArithmeticError('only valid for square matrix')
+ 
+@@ -869,7 +870,8 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         cdef size_t i
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+@@ -966,9 +968,11 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         sig_off()
+ 
+         cdef size_t i
++        cdef mpz_t tmp
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
+index f36a89bb229..20a06f7eaa3 100644
+--- a/src/sage/rings/complex_arb.pyx
++++ b/src/sage/rings/complex_arb.pyx
+@@ -1360,12 +1360,13 @@ cdef class ComplexBall(RingElement):
+             sage: CBF100(-3r)
+             -3.000000000000000000000000000000
+ 
+-            sage: ComplexBall(CBF100, 10^100)
+-            1.000000000000000000000000000000e+100
+             sage: ComplexBall(CBF100, CIF(1, 2))
+             1.000000000000000000000000000000 + 2.000000000000000000000000000000*I
+             sage: ComplexBall(CBF100, RBF(1/3), RBF(1))
+             [0.3333333333333333 +/- ...e-17] + 1.000000000000000000000000000000*I
++            sage: ComplexBall(CBF100, 10^100)
++            [1.000000000000000000000000000000e+100 +/- ...]
++
+             sage: NF.<a> = QuadraticField(-1, embedding=CC(0, -1))
+             sage: CBF(a)
+             -1.000000000000000*I
+@@ -3009,7 +3010,7 @@ cdef class ComplexBall(RingElement):
+             sage: CBF(1).rising_factorial(2**64)
+             [+/- ...e+347382171326740403407]
+             sage: ComplexBallField(128)(1).rising_factorial(2**64)
+-            [2.343691126796861348e+347382171305201285713 +/- ...e+347382171305201285694]
++            [2.34369112679686134...e+347382171305201285713 +/- ...]
+             sage: CBF(1/2).rising_factorial(CBF(2,3)) # abs tol 1e-15
+             [-0.123060451458124 +/- 3.06e-16] + [0.0406412631676552 +/- 7.57e-17]*I
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+index f651c9f3512..c68246d2142 100644
+--- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+@@ -222,7 +222,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef unsigned long n
+         cdef Rational c
+         cdef list L1
+-        cdef mpq_t * L2
++        cdef fmpq_t q
+ 
+         Polynomial.__init__(self, parent, is_gen=is_gen)
+ 
+@@ -253,14 +253,11 @@ cdef class Polynomial_rational_flint(Polynomial):
+             L1 = [e if isinstance(e, Rational) else Rational(e) for e in x]
+             n  = <unsigned long> len(x)
+             sig_on()
+-            L2 = <mpq_t *> check_allocarray(n, sizeof(mpq_t))
++            fmpq_poly_fit_length(self._poly, n)
+             for deg from 0 <= deg < n:
+-                mpq_init(L2[deg])
+-                mpq_set(L2[deg], (<Rational> L1[deg]).value)
+-            fmpq_poly_set_array_mpq(self._poly, L2, n)
+-            for deg from 0 <= deg < n:
+-                mpq_clear(L2[deg])
+-            sig_free(L2)
++                fmpq_init_set_readonly(q, (<Rational> L1[deg]).value)
++                fmpq_poly_set_coeff_fmpq(self._poly, deg, q)
++                fmpq_clear_readonly(q)
+             sig_off()
+ 
+ #           deg = 0
+@@ -435,6 +432,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         utmost care.
+         """
+         cdef bint do_sig = _do_sig(self._poly)
++        cdef fmpz_t tmpfz
+ 
+         if isinstance(value, int):
+             if do_sig: sig_str("FLINT exception")
+@@ -442,7 +440,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+             if do_sig: sig_off()
+         elif isinstance(value, Integer):
+             if do_sig: sig_str("FLINT exception")
+-            fmpq_poly_set_coeff_mpz(self._poly, n, (<Integer> value).value)
++            fmpz_init_set_readonly(tmpfz, (<Integer> value).value)
++            fmpq_poly_set_coeff_fmpz(self._poly, n, tmpfz)
++            fmpz_clear_readonly(tmpfz)
+             if do_sig: sig_off()
+         elif isinstance(value, Rational):
+             if do_sig: sig_str("FLINT exception")
+@@ -492,7 +492,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef Polynomial_rational_flint f
+         cdef Rational r
+         cdef fmpz_t tmpfz
+-        cdef fmpq_t tmpfq
++        cdef fmpq_t tmpfq, tmpfq1
+         cdef RealBall arb_a, arb_z
+         cdef ComplexBall acb_a, acb_z
+ 
+@@ -508,13 +508,23 @@ cdef class Polynomial_rational_flint(Polynomial):
+             elif isinstance(a, Rational):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpq(r.value, self._poly, (<Rational> a).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> a).value)
++                fmpq_init(tmpfq1)
++                fmpq_poly_evaluate_fmpq(tmpfq1, self._poly, tmpfq)
++                fmpq_get_mpq(r.value, tmpfq1)
++                fmpq_clear(tmpfq1)
++                fmpq_clear_readonly(tmpfq)
+                 sig_off()
+                 return r
+             elif isinstance(a, Integer):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpz(r.value, self._poly, (<Integer> a).value)
++                fmpz_init_set_readonly(tmpfz, (<Integer> a).value)
++                fmpq_init(tmpfq)
++                fmpq_poly_evaluate_fmpz(tmpfq, self._poly, tmpfz)
++                fmpq_get_mpq(r.value, tmpfq)
++                fmpq_clear(tmpfq)
++                fmpz_clear_readonly(tmpfz)
+                 sig_off()
+                 return r
+             elif isinstance(a, int):
+@@ -1321,6 +1331,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         """
+         cdef Polynomial_rational_flint res
+         cdef bint do_sig
++        cdef fmpq_t tmpfq
+ 
+         if right == 0:
+             raise ZeroDivisionError("division by zero polynomial")
+@@ -1331,8 +1342,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+                 do_sig = _do_sig(self._poly)
+ 
+                 if do_sig: sig_str("FLINT exception")
+-                fmpq_poly_scalar_div_mpq(res._poly, self._poly,
+-                                                  (<Rational> QQ(right)).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> QQ(right)).value)
++                fmpq_poly_scalar_div_fmpq(res._poly, self._poly, tmpfq)
++                fmpq_clear_readonly(tmpfq)
+                 if do_sig: sig_off()
+                 return res
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+index 6e7f7498329..3a66198d568 100644
+--- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+@@ -658,6 +658,11 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
+             ...
+             NotImplementedError: square free factorization of polynomials over rings with composite characteristic is not implemented
+ 
++        :trac:`20003`::
++
++            sage: P.<x> = GF(7)[]
++            sage: (6*x+3).squarefree_decomposition()
++            (6) * (x + 4)
+         """
+         if not self.base_ring().is_field():
+             raise NotImplementedError("square free factorization of polynomials over rings with composite characteristic is not implemented")
+diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
+index a9ce06d14ca..affe11e4376 100644
+--- a/src/sage/rings/real_arb.pyx
++++ b/src/sage/rings/real_arb.pyx
+@@ -898,7 +898,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+             sage: RBF.gamma(5)
+             24.00000000000000
+             sage: RBF.gamma(10**20)
+-            [+/- ...e+1956570552410610660600]
++            [1.932849514310098...+1956570551809674817225 +/- ...]
+             sage: RBF.gamma(1/3)
+             [2.678938534707747 +/- ...e-16]
+             sage: RBF.gamma(-5)
+@@ -1102,7 +1102,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+              15.00000000000000,
+              48.00000000000000]
+             sage: RBF.double_factorial(2**20)
+-            [1.4483729903e+2928836 +/- ...e+2928825]
++            [1.448372990...e+2928836 +/- ...]
+             sage: RBF.double_factorial(2**1000)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/schemes/plane_conics/con_rational_function_field.py b/src/sage/schemes/plane_conics/con_rational_function_field.py
+index 05d24e78a85..581102b5c5b 100644
+--- a/src/sage/schemes/plane_conics/con_rational_function_field.py
++++ b/src/sage/schemes/plane_conics/con_rational_function_field.py
+@@ -198,38 +198,6 @@ def has_rational_point(self, point=False, algorithm='default',
+             Fraction Field of Univariate Polynomial Ring in u over Rational
+             Field with modulus v^2 - u^3 - 1
+ 
+-        ``has_rational_point`` fails for some conics over function fields
+-        over finite fields, due to :trac:`20003`::
+-
+-            sage: K.<t> = PolynomialRing(GF(7))
+-            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
+-            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
+-            sage: C.has_rational_point()                                                # needs sage.libs.singular
+-            Traceback (most recent call last):
+-            ...
+-            TypeError: self (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (-t^3 + 3*t^2 - 2*t - 2)/(t + 3)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (t^2 + 3*t + 3)*x*y + (-2*t^2 - 2)*y^2 + (-t^2 + 3*t + 2)*x*z + (-3*t + 3)*y*z + (-3*t^2 + t - 2)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x + (2*t - 2)/(t + 3)*y + (3*t^4 + 2*t^3 - 2*t^2 - 2*t + 3)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z
+-                     : y + (-t^3 - t^2 + 3*t - 1)/(t^3 - 3*t^2 + 2*t + 2)*z : z))
+-            domain must equal right (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^3 - t^2 + 3*t + 3)*x^2 + (t - 3)*y^2 + (-t^7 + 2*t^5 + t^4 + 2*t^3 + 3*t^2 - t - 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    -2/(t^3 - 3*t^2 + 2*t + 2)*x^2 + 1/(t^3 + 3*t^2 - 2*t + 1)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^9 - 2*t^8 + t^7 - t^6 + 3*t^5 - 3*t^3 + t^2 - 2*t + 3)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    ((t^3 - 3*t^2 + 2*t + 2)*x : (t^2 - 2)*y : (t^5 - 3*t^4 + t^2 + 3*t + 3)*z))
+-            codomain
+-
+-
+-
+         TESTS::
+ 
+             sage: K.<t> = FractionField(PolynomialRing(QQ, 't'))
+@@ -250,6 +218,16 @@ def has_rational_point(self, point=False, algorithm='default',
+             sage: C.has_rational_point(point=True)  # long time (4 seconds)             # needs sage.libs.singular
+             (True,
+              ((-2/117*t^8 + 304/1053*t^7 + 40/117*t^6 - 1/27*t^5 - 110/351*t^4 - 2/195*t^3 + 11/351*t^2 + 1/117)/(t^4 + 2/39*t^3 + 4/117*t^2 + 2/39*t + 14/39) : -5/3*t^4 + 19*t^3 : 1))
++
++        ``has_rational_point`` used to fail for some conics over function fields
++        over finite fields, due to :trac:`20003`::
++
++            sage: K.<t> = PolynomialRing(GF(7))
++            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
++            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
++            sage: C.has_rational_point()
++            True
++
+         """
+         from .constructor import Conic
+ 
+diff --git a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+index a591cb4cd7c..a90f2050c59 100644
+--- a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
++++ b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+@@ -20,6 +20,7 @@
+ #include "utils.h"
+ 
+ #include "gmp.h"
++#include "flint/fmpz_poly.h"
+ #include "flint/fmpq_poly.h"
+ #include "flint/fmpq.h"
+ 
+@@ -63,7 +64,7 @@ static ex chebyt_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+@@ -122,7 +123,7 @@ static ex chebyu_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+diff --git a/src/sage/symbolic/ginac/useries.cpp b/src/sage/symbolic/ginac/useries.cpp
+index 40fbd7ab360..b9a8b867648 100644
+--- a/src/sage/symbolic/ginac/useries.cpp
++++ b/src/sage/symbolic/ginac/useries.cpp
+@@ -467,10 +467,17 @@ void add::useries(flint_series_t& fp, int order) const
+                 fmpq_poly_set_ui(fp.ft, 0);
+         else if (oc.is_long())
+                 fmpq_poly_set_si(fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ 
+         for (const auto & elem : seq) {
+ 		const ex& t = recombine_pair_to_ex(elem);
+@@ -505,10 +512,17 @@ void mul::useries(flint_series_t& fp, int order) const
+ 
+         if (oc.is_long())
+                 fmpq_poly_scalar_mul_si(fp.ft, fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_scalar_mul_mpz(fp.ft, fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_scalar_mul_mpq(fp.ft, fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_scalar_mul_fmpz(fp.ft, fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp.ft, fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ void power::useries(flint_series_t& fp, int order) const
+@@ -563,7 +577,10 @@ void power::useries(flint_series_t& fp, int order) const
+                 }
+                 check_poly_ccoeff_one(fp1);
+                 fmpq_poly_log_series(fp1.ft, fp1.ft, order);
+-                fmpq_poly_scalar_mul_mpq(fp1.ft, fp1.ft, nexp.as_mpq());
++                fmpq_t tmp;
++                fmpq_init_set_readonly(tmp, nexp.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp1.ft, fp1.ft, tmp);
++                fmpq_clear_readonly(tmp);
+                 fmpq_poly_exp_series(fp.ft, fp1.ft, order);
+                 return;
+         }
+@@ -608,10 +625,17 @@ void numeric::useries(flint_series_t& fp, int order) const
+ {
+         if (is_long())
+                 fmpq_poly_set_si(fp.ft, to_long());
+-        else if (is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, as_mpq());
++        else if (is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ } // namespace GiNaC
+diff --git a/src/sage_setup/library_order.py b/src/sage_setup/library_order.py
+index f40690f8d22..9ae0d2579a7 100644
+--- a/src/sage_setup/library_order.py
++++ b/src/sage_setup/library_order.py
+@@ -16,17 +16,12 @@
+ 
+ aliases = cython_aliases(required_modules=(), optional_modules=modules)
+ 
+-if "ARB_LIBRARY" in aliases:
+-    arb_dylib_names = [aliases["ARB_LIBRARY"]]
+-else:
+-    arb_dylib_names = []
+-
+ library_order_list = aliases.get("SINGULAR_LIBRARIES", []) + [
+     "giac", "intl", "curl",
+     "ec", "ecm"
+ ] + aliases.get("LINBOX_LIBRARIES", []) + aliases.get("FFLASFFPACK_LIBRARIES", []) + aliases.get("GSL_LIBRARIES", []) + [
+     "pari", "flint", "ecl", "glpk", "ppl",
+-] + arb_dylib_names + [
++] + [
+     "mpfi", "mpfr", "mpc", "ntl", "gmp", "gmpxx",
+     "brial",
+     "brial_groebner",
diff --git a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch b/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
deleted file mode 100644
index 7c55bce6e9bb4..0000000000000
--- a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
+++ /dev/null
@@ -1,221 +0,0 @@
-diff --git a/build/pkgs/singular/checksums.ini b/build/pkgs/singular/checksums.ini
-index 313463d2fea..1101fc55700 100644
---- a/build/pkgs/singular/checksums.ini
-+++ b/build/pkgs/singular/checksums.ini
-@@ -1,5 +1,5 @@
- tarball=singular-VERSION.tar.gz
--sha1=28bb3ee97ef48d04dfa96de182fd93eebe08426c
--md5=fc0a4f5720dadba45a52ee94324ce00c
--cksum=1573851737
--upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-1/singular-VERSION.tar.gz
-+sha1=df1997f412580f2073295aba569bb955ad227317
-+md5=50349213e206a18cdaa1bc410dde7ea4
-+cksum=376854707
-+upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-2/singular-VERSION.tar.gz
-diff --git a/build/pkgs/singular/package-version.txt b/build/pkgs/singular/package-version.txt
-index 66e2bede53a..9f1bf008217 100644
---- a/build/pkgs/singular/package-version.txt
-+++ b/build/pkgs/singular/package-version.txt
-@@ -1 +1 @@
--4.3.1p3
-+4.3.2p7
-diff --git a/build/pkgs/singular/spkg-configure.m4 b/build/pkgs/singular/spkg-configure.m4
-index 6a85631f624..f7621ec5fa1 100644
---- a/build/pkgs/singular/spkg-configure.m4
-+++ b/build/pkgs/singular/spkg-configure.m4
-@@ -6,14 +6,27 @@ SAGE_SPKG_CONFIGURE([singular], [
-     AS_IF([test -z "${SINGULAR_BIN}"], [sage_spkg_install_singular=yes], [
-       dnl Use pkg-config to ensure that Singular is new enough.
-       PKG_CHECK_MODULES([SINGULAR], [Singular >= 4.2.1], [
--       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)
--       ], [
--       AC_MSG_RESULT(no)
--       sage_spkg_install_singular=yes
--       ]
--      )], [
-+        AC_MSG_CHECKING([whether Singular is built with FLINT])
-+        AC_COMPILE_IFELSE([
-+          AC_LANG_PROGRAM([
-+            #include <singular/singularconfig.h>
-+            #if !defined(HAVE_FLINT)
-+            #  error "Need Singular compiled with FLINT"
-+          ], [])
-+        ], [
-+          AC_MSG_RESULT([yes])
-+          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)
-+          ], [
-+            AC_MSG_RESULT(no)
-+            sage_spkg_install_singular=yes
-+          ])
-+        ], [
-+          AC_MSG_RESULT([no])
-+          sage_spkg_install_singular=yes
-+        ])
-+      ], [
-       dnl pkg-config version check failed
-       sage_spkg_install_singular=yes
-       ])
-diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py
-index b15cc1c602c..4b5c76e2bfa 100644
---- a/src/sage/interfaces/singular.py
-+++ b/src/sage/interfaces/singular.py
-@@ -604,8 +604,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: i = singular.ideal(['x^2','y^2','z^2'])
-             sage: s = i.std()
-             sage: singular.eval('hilb(%s)'%(s.name()))
--            '// 1 t^0\n// -3 t^2\n// 3 t^4\n// -1 t^6\n\n// 1 t^0\n//
--            3 t^1\n// 3 t^2\n// 1 t^3\n// dimension (affine) = 0\n//
-+            '...// dimension (affine) = 0\n//
-             degree (affine) = 8'
- 
-         ::
-@@ -613,15 +612,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: from sage.misc.verbose import set_verbose
-             sage: set_verbose(1)
-             sage: o = singular.eval('hilb(%s)'%(s.name()))
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
- 
-         This is mainly useful if this method is called implicitly. Because
-@@ -631,15 +622,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-         ::
- 
-             sage: o = s.hilb()
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
-             // ** right side is not a datum, assignment ignored
-             ...
-diff --git a/src/sage/libs/singular/function.pyx b/src/sage/libs/singular/function.pyx
-index f40346d1fd0..c597c63aafe 100644
---- a/src/sage/libs/singular/function.pyx
-+++ b/src/sage/libs/singular/function.pyx
-@@ -1241,32 +1241,22 @@ cdef class SingularFunction(SageObject):
-             sage: I = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5])
-             sage: I = Ideal(I.groebner_basis())
-             sage: hilb = sage.libs.singular.function_factory.ff.hilb
--            sage: hilb(I) # Singular will print // ** _ is no standard basis
--            // ** _ is no standard basis
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: from sage.misc.sage_ostools import redirection
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I) # Singular will print // ** _ is no standard basis
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            True
- 
-         So we tell Singular that ``I`` is indeed a Groebner basis::
- 
--            sage: hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            False
- 
- 
-         TESTS:
-diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-index 22ada6de947..80352700872 100644
---- a/src/sage/rings/polynomial/multi_polynomial_ideal.py
-+++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-@@ -3132,13 +3132,16 @@ def hilbert_numerator(self, grading=None, algorithm='sage'):
-             sage: I.hilbert_numerator()                                                 # needs sage.rings.number_field
-             -t^5 + 1
- 
--        This example returns a wrong answer due to an integer overflow in Singular::
-+        This example returns a wrong answer in singular < 4.3.2p4 due to an integer overflow::
- 
-             sage: n=4; m=11; P = PolynomialRing(QQ, n*m, "x"); x = P.gens(); M = Matrix(n, x)
-             sage: I = P.ideal(M.minors(2))
-             sage: J = P * [m.lm() for m in I.groebner_basis()]
--            sage: J.hilbert_numerator(algorithm='singular')
--            ...120*t^33 - 3465*t^32 + 48180*t^31 - ...
-+            sage: J.hilbert_numerator(algorithm='singular') # known bug
-+            Traceback (most recent call last):
-+            ....
-+            RuntimeError: error in Singular function call 'hilb':
-+            overflow at t^22
- 
-         Our two algorithms should always agree; not tested until
-         :trac:`33178` is fixed::
-diff --git a/src/sage/sandpiles/sandpile.py b/src/sage/sandpiles/sandpile.py
-index 02d2021b2fb..c8e15e06f05 100644
---- a/src/sage/sandpiles/sandpile.py
-+++ b/src/sage/sandpiles/sandpile.py
-@@ -2493,9 +2493,15 @@ def _set_ideal(self):
-             sage: '_ideal' in S.__dict__
-             True
-         """
-+        from sage.libs.singular.function_factory import ff
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
-         R = self.ring()
--        I = self._unsaturated_ideal._singular_()
--        self._ideal = R.ideal(I.sat(prod(R.gens())._singular_())[1])
-+        I = self._unsaturated_ideal
-+        I_sat_gens = sat(I, prod(R.gens()))[0]
-+        self._ideal = R.ideal(I_sat_gens)
- 
-     def unsaturated_ideal(self):
-         r"""
-diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py
-index e6caf19ba74..afd6484d779 100644
---- a/src/sage/schemes/projective/projective_subscheme.py
-+++ b/src/sage/schemes/projective/projective_subscheme.py
-@@ -1001,7 +1001,10 @@ def dual(self):
-         for i in range(n + 1):
-             J = J + S.ideal(z[-1] * f_S.derivative(z[i]) - z[i + n + 1])
- 
--        sat = ff.elim__lib.sat
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
- 
-         max_ideal = S.ideal(z[n + 1: 2 * n + 2])
-         J_sat_gens = sat(J, max_ideal)[0]
diff --git a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch b/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
deleted file mode 100644
index 6a35ec3836550..0000000000000
--- a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-diff --git a/src/sage/ext/memory.pyx b/src/sage/ext/memory.pyx
-index 1de6dedab82..b95130b19dd 100644
---- a/src/sage/ext/memory.pyx
-+++ b/src/sage/ext/memory.pyx
-@@ -3,14 +3,14 @@ Low-level memory allocation functions
- 
- TESTS:
- 
--Check that a ``MemoryError`` is raised if we try to allocate a
-+Check that an error is raised if we try to allocate a
- ridiculously large integer, see :trac:`15363`::
- 
--    sage: 2^(2^63-3)
--    Traceback (most recent call last):
--    ...
--    OverflowError: exponent must be at most 2147483647         # 32-bit
--    RuntimeError: Aborted                                      # 64-bit
-+    sage: try:
-+    ....:     2^(2^63-3)
-+    ....: except (OverflowError, RuntimeError, FloatingPointError):
-+    ....:     print ('Overflow error')
-+    ...Overflow error
- 
- AUTHORS:
- 
-diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx
-index d5e87626d31..37ed9364845 100644
---- a/src/sage/rings/integer.pyx
-+++ b/src/sage/rings/integer.pyx
-@@ -6654,7 +6654,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
-             sage: try:
-             ....:     print('Possible error output from gmp', flush=True)
-             ....:     1 << (2^60)
--            ....: except (MemoryError, OverflowError, RuntimeError):
-+            ....: except (MemoryError, OverflowError, RuntimeError, FloatingPointError):
-             ....:     pass
-             ....: else:
-             ....:     print("Failed to raise exception")
diff --git a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch b/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
deleted file mode 100644
index 3d2a4bd9cd96f..0000000000000
--- a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
+++ /dev/null
@@ -1,740 +0,0 @@
-diff --git a/src/sage/ext_data/valgrind/valgrind-python.supp b/src/sage/ext_data/valgrind/valgrind-python.supp
-new file mode 100644
-index 00000000000..16aa2858484
---- /dev/null
-+++ b/src/sage/ext_data/valgrind/valgrind-python.supp
-@@ -0,0 +1,480 @@
-+# From the CPython repository with the suppressions for _PyObject_Free
-+# and _PyObject_Realloc enabled. See the upstream suppression file for
-+# details:
-+#
-+# https://github.com/python/cpython/blob/main/Misc/valgrind-python.supp
-+
-+# all tool names: Addrcheck,Memcheck,cachegrind,helgrind,massif
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 8 (x86_64 aka amd64)
-+   Memcheck:Value8
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:address_in_range
-+}
-+
-+#
-+# Leaks (including possible leaks)
-+#    Hmmm, I wonder if this masks some real leaks.  I think it does.
-+#    Will need to fix that.
-+#
-+
-+{
-+   Suppress leaking the GIL after a fork.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_allocate_lock
-+   fun:PyEval_ReInitThreads
-+}
-+
-+{
-+   Suppress leaking the autoTLSkey.  This looks like it shouldn't leak though.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_create_key
-+   fun:_PyGILState_Init
-+   fun:Py_InitializeEx
-+   fun:Py_Main
-+}
-+
-+{
-+   Hmmm, is this a real leak or like the GIL?
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_ReInitTLS
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:realloc
-+   fun:_PyObject_GC_Resize
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_New
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_NewVar
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+#
-+# Non-python specific leaks
-+#
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:calloc
-+   fun:allocate_dtv
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:memalign
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Realloc
-+}
-+
-+###
-+### All the suppressions below are for errors that occur within libraries
-+### that Python uses.  The problems to not appear to be related to Python's
-+### use of the libraries.
-+###
-+
-+{
-+   Generic ubuntu ld problems
-+   Memcheck:Addr8
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+}
-+
-+{
-+   Generic gentoo ld problems
-+   Memcheck:Cond
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_close
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Value8
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   GDBM problems, see test_gdbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   fun:gdbm_open
-+
-+}
-+
-+{
-+   Uninitialised byte(s) false alarm, see bpo-35561
-+   Memcheck:Param
-+   epoll_ctl(event)
-+   fun:epoll_ctl
-+   fun:pyepoll_internal_ctl
-+}
-+
-+{
-+   ZLIB problems, see test_gzip
-+   Memcheck:Cond
-+   obj:/lib/libz.so.1.2.3
-+   obj:/lib/libz.so.1.2.3
-+   fun:deflate
-+}
-+
-+{
-+   Avoid problems w/readline doing a putenv and leaking on exit
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:xmalloc
-+   fun:sh_set_lines_and_columns
-+   fun:_rl_get_screen_size
-+   fun:_rl_init_terminal_io
-+   obj:/lib/libreadline.so.4.3
-+   fun:rl_initialize
-+}
-+
-+# Valgrind emits "Conditional jump or move depends on uninitialised value(s)"
-+# false alarms on GCC builtin strcmp() function. The GCC code is correct.
-+#
-+# Valgrind bug: https://bugs.kde.org/show_bug.cgi?id=264936
-+{
-+   bpo-38118: Valgrind emits false alarm on GCC builtin strcmp()
-+   Memcheck:Cond
-+   fun:PyUnicode_Decode
-+}
-+
-+
-+###
-+### These occur from somewhere within the SSL, when running
-+###  test_socket_sll.  They are too general to leave on by default.
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:memset
-+###}
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:memset
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:MD5_Update
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:MD5_Update
-+###}
-+
-+# Fedora's package "openssl-1.0.1-0.1.beta2.fc17.x86_64" on x86_64
-+# See http://bugs.python.org/issue14171
-+{
-+   openssl 1.0.1 prng 1
-+   Memcheck:Cond
-+   fun:bcmp
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 2
-+   Memcheck:Cond
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 3
-+   Memcheck:Value8
-+   fun:_x86_64_AES_encrypt_compact
-+   fun:AES_encrypt
-+}
-+
-+#
-+# All of these problems come from using test_socket_ssl
-+#
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_bin2bn
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libcrypto.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_set_key_unchecked
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_encrypt2
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BUF_MEM_grow_clean
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:memcpy
-+   fun:ssl3_read_bytes
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:SHA1_Update
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:SHA1_Update
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-+{
-+   wcscmp_false_positive
-+   Memcheck:Addr8
-+   fun:wcscmp
-+   fun:_PyOS_GetOpt
-+   fun:Py_Main
-+   fun:main
-+}
-+
-+# Additional suppressions for the unified decimal tests:
-+{
-+   test_decimal
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_decimal2
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index b40ed64edb5..8c55861c147 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -1576,6 +1576,62 @@ const numeric numeric::div(const numeric &other) const {
-         }
- }
- 
-+
-+// Compute `a^b` as an integer, where a is an integer. Assign to ``res``` if it is integral, or return ``false``.
-+// The nonnegative real root is taken for even denominators. To be used inside numeric::integer_rational_power,
-+// to handle the special case of integral ``a``.
-+bool integer_rational_power_of_mpz(
-+        numeric& res,
-+        const numeric& a,
-+        const numeric& b
-+) {
-+        if (a.t != MPZ)
-+                throw std::runtime_error("integer_rational_power_of_mpz: bad input");
-+        mpz_t z;
-+        mpz_init(z);
-+        mpz_set_ui(z, 0);
-+        int sgn = mpz_sgn(a.v._bigint);
-+        if (mpz_cmp_ui(a.v._bigint, 1) == 0
-+            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
-+                mpz_set_ui(z, 1);
-+        else if (sgn == 0) {
-+                res = *_num0_p;
-+                mpz_clear(z);
-+                return true;
-+        }
-+        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1)) {
-+                mpz_clear(z);
-+                return false;
-+        } else {
-+                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-+                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat))) {
-+                        // too big to take roots/powers
-+                        mpz_clear(z);
-+                        return false;
-+                }
-+                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
-+                        if (mpz_perfect_square_p(a.v._bigint)) {
-+                                mpz_sqrt(z, a.v._bigint);
-+                        } else {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                else {
-+                        bool exact = mpz_root(z, a.v._bigint,
-+                                              mpz_get_ui(mpq_denref(b.v._bigrat)));
-+                        if (not exact) {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
-+        }
-+        res = numeric(z);   // transfers ownership, no mpz_clear
-+        return true;
-+}
-+
-+
- // Compute `a^b` as an integer, if it is integral, or return ``false``.
- // The nonnegative real root is taken for even denominators.
- bool numeric::integer_rational_power(numeric& res,
-@@ -1598,13 +1654,12 @@ bool numeric::integer_rational_power(numeric& res,
-                 if (a.v._long < 0
-                     and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
-                         return false;
--                long z;
-                 if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-                     or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
-                 // too big to take roots/powers
-                         return false;
-                 if (b.is_equal(*_num1_2_p)) {
--                        z = std::lround(std::sqrt(a.v._long));
-+                        long z = std::lround(std::sqrt(a.v._long));
-                         if (a.v._long == z*z) {
-                                 res = numeric(z);
-                                 return true;
-@@ -1613,44 +1668,11 @@ bool numeric::integer_rational_power(numeric& res,
-                 }
-                 return integer_rational_power(res, a.to_bigint(), b);
-         }
--        if (a.t != MPZ)
--                throw std::runtime_error("integer_rational_power: bad input");
--        int sgn = mpz_sgn(a.v._bigint);
--        mpz_t z;
--        mpz_init(z);
--        mpz_set_ui(z, 0);
--        if (mpz_cmp_ui(a.v._bigint, 1) == 0
--            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
--                mpz_set_ui(z, 1);
--        else if (sgn == 0) {
--                res = *_num0_p;
--                return true;
--        }
--        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
--                return false;
--        else {
--                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
--                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
--                // too big to take roots/powers
--                        return false;
--                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
--                        if (mpz_perfect_square_p(a.v._bigint))
--                                mpz_sqrt(z, a.v._bigint);
--                        else
--                                return false;
--                }
--                else {
--                        bool exact = mpz_root(z, a.v._bigint,
--                                        mpz_get_ui(mpq_denref(b.v._bigrat)));
--                        if (not exact)
--                                return false;
--                }
--                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
--        }
--        res = numeric(z);
--        return true;
-+        // otherwise: a is integer
-+        return integer_rational_power_of_mpz(res, a, b);
- }
- 
-+
- // for a^b return c,d such that a^b = c*d^b
- // only for MPZ/MPQ base and MPQ exponent
- void rational_power_parts(const numeric& a_orig, const numeric& b_orig,
-diff --git a/src/sage/tests/memcheck/__init__.py b/src/sage/tests/memcheck/__init__.py
-new file mode 100644
-index 00000000000..e69de29bb2d
-diff --git a/src/sage/tests/memcheck/run_tests.py b/src/sage/tests/memcheck/run_tests.py
-new file mode 100644
-index 00000000000..6ff4503a81b
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests.py
-@@ -0,0 +1,24 @@
-+import types
-+
-+
-+def run_tests() -> None:
-+    """
-+    Run all memcheck tests
-+    """
-+    from sage.tests.memcheck import symbolic_expression
-+    run_tests_in_module(symbolic_expression)
-+
-+
-+def run_tests_in_module(mod: types.ModuleType) -> None:
-+    """
-+    Run all memcheck tests in the given module
-+    """
-+    for entry in dir(mod):
-+        if not entry.startswith('test_'):
-+            continue
-+        test_func = getattr(mod, entry)
-+        test_func()
-+
-+
-+if __name__ == '__main__':
-+    run_tests()
-diff --git a/src/sage/tests/memcheck/run_tests_in_valgrind.py b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-new file mode 100644
-index 00000000000..df5ad0e92b2
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-@@ -0,0 +1,35 @@
-+"""
-+Launch valgrind and run the memory leak tests
-+
-+
-+From the commandline, run
-+
-+    sage -python -m sage.tests.memcheck.run_tests_in_valgrind
-+
-+to launch valgrind and execute the memory leak tests. Requires valgrind
-+to be installed. Alternatively, run as a unit test:
-+
-+    sage: from sage.tests.memcheck.run_tests_in_valgrind import run_tests_in_valgrind
-+    sage: run_tests_in_valgrind()    # optional - valgrind
-+"""
-+
-+import subprocess
-+
-+
-+def run_tests_in_valgrind() -> None:
-+    """
-+    Run the sage.tests.memcheck.run_tests module inside valgrind
-+    """
-+    subprocess.check_call([
-+        'valgrind',
-+        '--suppressions=src/sage/ext_data/valgrind/valgrind-python.supp',
-+        '--show-possibly-lost=no',
-+        '--show-reachable=no',
-+        './venv/bin/python',
-+        '-m',
-+        'sage.tests.memcheck.run_tests'
-+    ])
-+
-+
-+if __name__ == '__main__':
-+    run_tests_in_valgrind()
-diff --git a/src/sage/tests/memcheck/symbolic_expression.py b/src/sage/tests/memcheck/symbolic_expression.py
-new file mode 100644
-index 00000000000..52182fbe62d
---- /dev/null
-+++ b/src/sage/tests/memcheck/symbolic_expression.py
-@@ -0,0 +1,11 @@
-+from sage.tests.memcheck.verify_no_leak import verify_no_leak
-+
-+
-+def test_sqrt_sqrt_2() -> None:
-+    from sage.misc.functional import sqrt
-+    T2 = sqrt(2)
-+
-+    def sqrt_T2() -> None:
-+        sqrt(T2)
-+
-+    verify_no_leak(sqrt_T2)
-diff --git a/src/sage/tests/memcheck/verify_no_leak.py b/src/sage/tests/memcheck/verify_no_leak.py
-new file mode 100644
-index 00000000000..89ca90cf89c
---- /dev/null
-+++ b/src/sage/tests/memcheck/verify_no_leak.py
-@@ -0,0 +1,27 @@
-+from typing import Tuple, Sequence, List, Callable, Any
-+import valgrind
-+
-+
-+def verify_no_leak(callback: Callable[[], Any],
-+                   repeat: int = 10000,
-+                   fuzzy: int = 10,
-+                   ) -> None:
-+    """
-+    Verify that the callback does not generate new definitely lost blocks
-+
-+    Raises an assertion if the callback leaks memory
-+    """
-+    callback()   # warm_up
-+    initial_blocks = (0, 0, 0, 0)
-+    valgrind.memcheck_do_leak_check()
-+    initial_blocks = valgrind.memcheck_count_leak_blocks()
-+    for _ in range(repeat):
-+        callback()
-+    valgrind.memcheck_do_leak_check()
-+    leak_blocks = valgrind.memcheck_count_leak_blocks()
-+    leak = leak_blocks[0] - initial_blocks[0]
-+    if leak < repeat - fuzzy:
-+        return  # callback did not leak at least once per call
-+    blocks = round(leak / repeat, 2)
-+    message = f'{callback} leaked {blocks} block on average ({repeat} iterations)'
-+    raise AssertionError(message)
diff --git a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch b/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
deleted file mode 100644
index 684b62affaf5a..0000000000000
--- a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx
-index 8f46570313d..a8e73e57b52 100644
---- a/src/sage/libs/ecl.pyx
-+++ b/src/sage/libs/ecl.pyx
-@@ -563,15 +563,15 @@ cdef class EclObject:
-     Floats in Python are IEEE double, which LISP has as well. However,
-     the printing of floating point types in LISP depends on settings::
- 
--        sage: a = EclObject(float(10^40))
-+        sage: a = EclObject(float(1.234e40))
-         sage: ecl_eval("(setf *read-default-float-format* 'single-float)")
-         <ECL: SINGLE-FLOAT>
-         sage: a
--        <ECL: 1.d40>
-+        <ECL: 1.234d40>
-         sage: ecl_eval("(setf *read-default-float-format* 'double-float)")
-         <ECL: DOUBLE-FLOAT>
-         sage: a
--        <ECL: 1.e40>
-+        <ECL: 1.234e40>
- 
-     Tuples are translated to dotted lists::
- 
-diff --git a/src/sage/libs/eclsig.h b/src/sage/libs/eclsig.h
-index e249ccf6874..005b2d99d0b 100644
---- a/src/sage/libs/eclsig.h
-+++ b/src/sage/libs/eclsig.h
-@@ -45,7 +45,11 @@ static inline void ecl_sig_off(void)
-     sig_off();
- }
- 
-+#if ECL_VERSION_NUMBER < 230909
- #define ecl_mpz_from_bignum(obj) ((obj)->big.big_num)
-+#else
-+#define ecl_mpz_from_bignum(obj) ecl_bignum(obj)
-+#endif
- 
- cl_object ecl_bignum_from_mpz(mpz_t num)
- {
diff --git a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch b/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
deleted file mode 100644
index e858f2fd4a445..0000000000000
--- a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
-index 59f10f6b13f..adcccff059b 100644
---- a/src/sage/plot/graphics.py
-+++ b/src/sage/plot/graphics.py
-@@ -36,6 +36,7 @@
- # ****************************************************************************
- 
- import os
-+from numbers import Integral
- from collections.abc import Iterable
- from math import isnan
- import sage.misc.verbose
-@@ -2874,6 +2875,11 @@ def matplotlib(self, filename=None,
-                 weight=lopts.pop('font_weight', 'medium'),
-                 variant=lopts.pop('font_variant', 'normal'))
-             color = lopts.pop('back_color', 'white')
-+            if 'loc' in lopts:
-+                loc = lopts['loc']
-+                if isinstance(loc, Integral):
-+                    # matplotlib 3.8 doesn't support sage integers
-+                    lopts['loc'] = int(loc)
-             leg = subplot.legend(prop=prop, **lopts)
-             if leg is None:
-                 from warnings import warn
diff --git a/srcpkgs/sagemath/patches/36403-00pre.patch b/srcpkgs/sagemath/patches/36403-00pre.patch
deleted file mode 100644
index 060404d5430de..0000000000000
--- a/srcpkgs/sagemath/patches/36403-00pre.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-Minor patch so that #36403 applies cleanly over sagemath 10.1
-
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 2053bca80c3..86aca6e00d8 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15123,7 +15302,8 @@ cdef class Matrix(Matrix1):
-             sage: N.conjugate_transpose()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object has no attribute 'conjugate'
-+            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
-+            has no attribute 'conjugate'
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 525ea5aa934..52afed49d64 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -55,7 +55,7 @@ cdef class AttributeErrorMessage:
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-         sage: x = polygen(ZZ, 'x')
--        sage: QQ[x].gen().bla                                                           # optional - sage.libs.flint
-+        sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
diff --git a/srcpkgs/sagemath/patches/36407-python_3.12.patch b/srcpkgs/sagemath/patches/36407-python_3.12.patch
deleted file mode 100644
index c75c275c30764..0000000000000
--- a/srcpkgs/sagemath/patches/36407-python_3.12.patch
+++ /dev/null
@@ -1,1744 +0,0 @@
-diff --git a/build/sage_bootstrap/package.py b/build/sage_bootstrap/package.py
-index 15b342223c4..eb82f96e05f 100644
---- a/build/sage_bootstrap/package.py
-+++ b/build/sage_bootstrap/package.py
-@@ -303,7 +303,7 @@ def _init_checksum(self):
-         # Name of the directory containing the checksums.ini file
-         self.__tarball_package_name = os.path.realpath(checksums_ini).split(os.sep)[-2]
- 
--    VERSION_PATCHLEVEL = re.compile('(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
-+    VERSION_PATCHLEVEL = re.compile(r'(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
- 
-     def _init_version(self):
-         try:
-diff --git a/src/doc/en/thematic_tutorials/coercion_and_categories.rst b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-index bb23331c151..7f5712caea7 100644
---- a/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-+++ b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-@@ -1223,7 +1223,7 @@ However, only "elementary" construction functors have a rank::
-     sage: (Fract*Poly).rank
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'
-+    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'...
- 
- .. end of output
- 
-diff --git a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-index 553a946c4d8..3cd71a9bad4 100644
---- a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-+++ b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-@@ -318,7 +318,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: e.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'...
- 
-         sage: id4 = SymmetricGroup(4).one()
-         sage: type(id4)
-@@ -326,7 +326,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: id4.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'
-+        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'...
- 
- .. note::
- 
-diff --git a/src/sage/algebras/cluster_algebra.py b/src/sage/algebras/cluster_algebra.py
-index b72d2a12976..14669dfed5c 100644
---- a/src/sage/algebras/cluster_algebra.py
-+++ b/src/sage/algebras/cluster_algebra.py
-@@ -167,7 +167,7 @@
-     sage: (t*s).g_vector()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'
-+    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'...
-     sage: A = ClusterAlgebra(['A', 2], principal_coefficients=True)
-     sage: A.explore_to_depth(infinity)
-     sage: s = A.cluster_variable((0, -1)); s
-diff --git a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-index e4a91723558..343ee8a66f9 100644
---- a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-+++ b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-@@ -109,7 +109,7 @@ class WeylLieConformalAlgebra(LieConformalAlgebraWithStructureCoefficients):
-         sage: alpha0.degree()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'
-+        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'...
- 
-     TESTS::
- 
-diff --git a/src/sage/algebras/steenrod/steenrod_algebra.py b/src/sage/algebras/steenrod/steenrod_algebra.py
-index 978a3557a9d..7c4d444f81c 100644
---- a/src/sage/algebras/steenrod/steenrod_algebra.py
-+++ b/src/sage/algebras/steenrod/steenrod_algebra.py
-@@ -1080,7 +1080,7 @@ def homogeneous_component(self, n):
-             sage: a.antipode() # not defined
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'
-+            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'...
-             sage: A(a).antipode() # convert to elt of A, then compute antipode
-             Sq(2,1) + Sq(5)
- 
-diff --git a/src/sage/all__sagemath_repl.py b/src/sage/all__sagemath_repl.py
-index 8d0b43679ca..c31b206bcb8 100644
---- a/src/sage/all__sagemath_repl.py
-+++ b/src/sage/all__sagemath_repl.py
-@@ -79,6 +79,23 @@
-                         message=r"Use setlocale\(\), getencoding\(\) and getlocale\(\) instead",
-                         module='docutils.io')
- 
-+# triggered by dateutil 2.8.2 and sphinx 7.0.1 on Python 3.12
-+# see: https://github.com/dateutil/dateutil/pull/1285
-+# see: https://github.com/sphinx-doc/sphinx/pull/11468
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"datetime.datetime.utcfromtimestamp\(\) is deprecated",
-+                        module='dateutil.tz.tz|sphinx.(builders.gettext|util.i18n)')
-+
-+# triggered on Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"This process.* is multi-threaded, "
-+                                r"use of .*\(\) may lead to deadlocks in the child.")
-+
-+# pickling of itertools is deprecated in Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"Pickle, copy, and deepcopy support will be "
-+                                r"removed from itertools in Python 3.14.")
-+
- 
- from .all__sagemath_objects import *
- from .all__sagemath_environment import *
-diff --git a/src/sage/arith/long.pxd b/src/sage/arith/long.pxd
-index 0031a0ae337..3ea70cef571 100644
---- a/src/sage/arith/long.pxd
-+++ b/src/sage/arith/long.pxd
-@@ -19,6 +19,8 @@ from libc.limits cimport LONG_MIN, LONG_MAX
- from cpython.object cimport Py_SIZE
- from cpython.number cimport PyNumber_Index, PyIndex_Check
- from cpython.longintrepr cimport py_long, PyLong_SHIFT, digit
-+from sage.cpython.pycore_long cimport (
-+    ob_digit, _PyLong_IsNegative, _PyLong_DigitCount)
- 
- from sage.libs.gmp.mpz cimport mpz_fits_slong_p, mpz_get_si
- from sage.rings.integer_fake cimport is_Integer, Integer_AS_MPZ
-@@ -299,8 +301,11 @@ cdef inline bint integer_check_long_py(x, long* value, int* err):
-         return 0
- 
-     # x is a Python "int" (aka PyLongObject or py_long in cython)
--    cdef const digit* D = (<py_long>x).ob_digit
--    cdef Py_ssize_t size = Py_SIZE(x)
-+    cdef const digit* D = ob_digit(x)
-+    cdef Py_ssize_t size = _PyLong_DigitCount(x)
-+
-+    if _PyLong_IsNegative(x):
-+        size = -size
- 
-     # We assume PyLong_SHIFT <= BITS_IN_LONG <= 3 * PyLong_SHIFT.
-     # This is true in all the default configurations:
-diff --git a/src/sage/categories/category.py b/src/sage/categories/category.py
-index 57ef7f4184b..29bce8ee415 100644
---- a/src/sage/categories/category.py
-+++ b/src/sage/categories/category.py
-@@ -2129,7 +2129,7 @@ def _with_axioms(self, axioms):
-             sage: Semigroups().Inverse()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'
-+            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'...
-             sage: Semigroups()._with_axioms(["Inverse"])
-             Category of semigroups
- 
-diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py
-index 5227792e725..4775d4e5bf1 100644
---- a/src/sage/categories/category_with_axiom.py
-+++ b/src/sage/categories/category_with_axiom.py
-@@ -554,7 +554,7 @@ class from the base category class::
-     sage: Magmas.Unital.Associative
-     Traceback (most recent call last):
-     ...
--    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'
-+    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'...
- 
- The purpose of this section is to explain the design of the code
- layout and the rationale for this mismatch.
-@@ -769,7 +769,7 @@ def _(): return LazyImport('sage.categories.rngs', 'Rngs', at_startup=True)
-     sage: Semirings().NoZeroDivisors()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'
-+    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'...
- 
- Concretely, this is to be implemented by defining the new axiom in the
- (``SubcategoryMethods`` nested class of the) appropriate category with
-diff --git a/src/sage/categories/enumerated_sets.py b/src/sage/categories/enumerated_sets.py
-index a8bea53f907..b0ea05d0563 100644
---- a/src/sage/categories/enumerated_sets.py
-+++ b/src/sage/categories/enumerated_sets.py
-@@ -610,7 +610,7 @@ def _list_from_iterator(self):
-                 sage: (QQ^2).list()  # indirect test                                    # needs sage.modules
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'
-+                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'...
- 
-             Here we test that for an object that does not know whether it
-             is finite or not.  Calling ``x.list()`` simply tries to create
-@@ -622,11 +622,11 @@ def _list_from_iterator(self):
-                 sage: Q.is_finite()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'...
-                 sage: Q.list()   # indirect test
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'...
- 
-             Here is another example. We artificially create a version of
-             the ring of integers that does not know whether it is finite
-diff --git a/src/sage/categories/examples/sets_cat.py b/src/sage/categories/examples/sets_cat.py
-index e0853d63f94..fbadb9ca405 100644
---- a/src/sage/categories/examples/sets_cat.py
-+++ b/src/sage/categories/examples/sets_cat.py
-@@ -619,7 +619,7 @@ class PrimeNumbers_Facade(PrimeNumbers_Abstract):
-         sage: pf.next()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'...
- 
-     unlike in the other implementations::
- 
-diff --git a/src/sage/categories/homset.py b/src/sage/categories/homset.py
-index 22ba9d047fc..2a8b8aeedeb 100644
---- a/src/sage/categories/homset.py
-+++ b/src/sage/categories/homset.py
-@@ -632,7 +632,7 @@ def __init__(self, X, Y, category=None, base=None, check=True):
-             sage: H = MyHomset(X, Y, category=1, base = ZZ, check = False)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'...
-             sage: P.<t> = ZZ[]
-             sage: f = P.hom([1/2*t])
-             sage: f.parent().domain()
-diff --git a/src/sage/categories/modules_with_basis.py b/src/sage/categories/modules_with_basis.py
-index e97bf851388..c4933d0657f 100644
---- a/src/sage/categories/modules_with_basis.py
-+++ b/src/sage/categories/modules_with_basis.py
-@@ -2456,7 +2456,7 @@ def apply_multilinear_morphism(self, f, codomain=None):
-                     sage: tensor([a, b]).apply_multilinear_morphism(f)                  # needs sage.modules
-                     Traceback (most recent call last):
-                     ...
--                    AttributeError: 'int' object has no attribute 'parent'
-+                    AttributeError: 'int' object has no attribute 'parent'...
- 
-                 Here we consider an example where the codomain is a
-                 module with basis with a different base ring::
-diff --git a/src/sage/categories/monoids.py b/src/sage/categories/monoids.py
-index 38dd7248c9d..28474bd17b6 100644
---- a/src/sage/categories/monoids.py
-+++ b/src/sage/categories/monoids.py
-@@ -556,7 +556,7 @@ def algebra_generators(self):
-                     Traceback (most recent call last):
-                     ...
-                     AttributeError: 'IntegerModMonoid_with_category' object
--                    has no attribute 'monoid_generators'
-+                    has no attribute 'monoid_generators'...
-                     sage: Z12.semigroup_generators()
-                     Family (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
-                     sage: Z12.algebra(QQ).algebra_generators()                          # needs sage.modules
-diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py
-index 494e8154c80..ec5120e41e6 100644
---- a/src/sage/combinat/finite_state_machine.py
-+++ b/src/sage/combinat/finite_state_machine.py
-@@ -1835,7 +1835,7 @@ def __getstate__(self):
-             sage: T1.transitions
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'FSMState' object has no attribute 'transitions'
-+            AttributeError: 'FSMState' object has no attribute 'transitions'...
-             sage: A1 = loads(dumps(A))
-             sage: all(A.state(j) == A1.state(j) for j in [0, 1])
-             True
-diff --git a/src/sage/combinat/growth.py b/src/sage/combinat/growth.py
-index cf8d18c1764..766eea37917 100644
---- a/src/sage/combinat/growth.py
-+++ b/src/sage/combinat/growth.py
-@@ -371,7 +371,7 @@
-     sage: GrowthDiagram(RulePascal(), [3,1,2])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'RulePascal' object has no attribute 'forward_rule'
-+    AttributeError: 'RulePascal' object has no attribute 'forward_rule'...
- 
- We now re-implement the rule where we provide the dual graded graphs::
- 
-diff --git a/src/sage/combinat/integer_lists/lists.py b/src/sage/combinat/integer_lists/lists.py
-index 5143e5cb5e8..9117a6076f7 100644
---- a/src/sage/combinat/integer_lists/lists.py
-+++ b/src/sage/combinat/integer_lists/lists.py
-@@ -261,7 +261,7 @@ def __getattr__(self, name):
-             sage: L.foo
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'foo'
-+            AttributeError: 'NoneType' object has no attribute 'foo'...
-         """
-         return getattr(self.backend, name)
- 
-diff --git a/src/sage/combinat/posets/posets.py b/src/sage/combinat/posets/posets.py
-index c31597c72e9..c74bfc67cee 100644
---- a/src/sage/combinat/posets/posets.py
-+++ b/src/sage/combinat/posets/posets.py
-@@ -8825,7 +8825,7 @@ def is_induced_subposet(self, other):
-             sage: Poset().is_induced_subposet('junk')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'subposet'
-+            AttributeError: 'str' object has no attribute 'subposet'...
-         """
-         if (not self._is_facade or (isinstance(other, FinitePoset) and
-                                     not other._is_facade)):
-diff --git a/src/sage/cpython/atexit.pyx b/src/sage/cpython/atexit.pyx
-index 961aa348d0a..e5a82735137 100644
---- a/src/sage/cpython/atexit.pyx
-+++ b/src/sage/cpython/atexit.pyx
-@@ -154,6 +154,10 @@ cdef extern from *:
-     #undef _PyGC_FINALIZED
-     #include "internal/pycore_interp.h"
-     #include "internal/pycore_pystate.h"
-+    #if PY_VERSION_HEX >= 0x030c0000
-+    // struct atexit_callback was renamed in 3.12 to atexit_py_callback
-+    #define atexit_callback atexit_py_callback
-+    #endif
-     static atexit_callback ** _atexit_callbacks(PyObject *self) {
-         PyInterpreterState *interp = _PyInterpreterState_GET();
-         struct atexit_state state = interp->atexit;
-diff --git a/src/sage/cpython/debug.pyx b/src/sage/cpython/debug.pyx
-index 986abff2a99..cdaca3a4854 100644
---- a/src/sage/cpython/debug.pyx
-+++ b/src/sage/cpython/debug.pyx
-@@ -78,7 +78,7 @@ def getattr_debug(obj, name, default=_no_default):
- 
-     EXAMPLES::
- 
--        sage: _ = getattr_debug(list, "reverse")
-+        sage: _ = getattr_debug(list, "reverse")  # not tested - broken in python 3.12
-         getattr_debug(obj=<class 'list'>, name='reverse'):
-           type(obj) = <class 'type'>
-           object has __dict__ slot (<class 'dict'>)
-@@ -123,7 +123,7 @@ def getattr_debug(obj, name, default=_no_default):
-         sage: _ = getattr_debug(1, "foo")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'...
-         sage: _ = getattr_debug(1, "foo", "xyz")
-         getattr_debug(obj=1, name='foo'):
-           type(obj) = <class 'sage.rings.integer.Integer'>
-diff --git a/src/sage/cpython/dict_internal.h b/src/sage/cpython/dict_internal.h
-index 42a57bcb468..a5ee35bc198 100644
---- a/src/sage/cpython/dict_internal.h
-+++ b/src/sage/cpython/dict_internal.h
-@@ -169,6 +169,7 @@ dictkeys_set_index(PyDictKeysObject *keys, Py_ssize_t i, Py_ssize_t ix)
- #else   /* Python >= 3.11 */
- 
- #define Py_BUILD_CORE
-+#undef _PyGC_FINALIZED
- #include <internal/pycore_dict.h>
- 
- /************************************************************/
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 52afed49d64..1f49e5230c3 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -53,12 +53,12 @@ cdef class AttributeErrorMessage:
-         sage: 1.bla  #indirect doctest
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'...
-         sage: x = polygen(ZZ, 'x')
-         sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'...
- 
-     ::
- 
-@@ -144,7 +144,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(X, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: x = X()
-         sage: raw_getattr(x, "prop")
-         <property object at ...>
-@@ -173,7 +173,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(Y, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: y = Y()
-         sage: raw_getattr(y, "prop")
-         <property object at ...>
-@@ -278,7 +278,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     The integer ring is a parent, so, lazy attributes work::
- 
-@@ -289,7 +289,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(17, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     In general, descriptors are not yet well supported, because they
-     often do not accept to be cheated with the type of their instance::
-@@ -305,7 +305,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__weakref__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-     This was caught by :trac:`8296` for which we do a couple more tests::
- 
-@@ -314,7 +314,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: 1.__weakref__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-         sage: n = 1
-         sage: ip = get_ipython()                 # not tested: only works in interactive shell
-@@ -329,7 +329,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__call__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'...
- 
-     TESTS:
- 
-@@ -339,14 +339,14 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, type, "__name__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'...
- 
-     Non-strings as "name" are handled gracefully::
- 
-         sage: getattr_from_other_class(1, type, None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute None
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute None...
-     """
-     if not isinstance(cls, type):
-         raise TypeError(f"{cls!r} is not a type")
-diff --git a/src/sage/cpython/pycore_long.h b/src/sage/cpython/pycore_long.h
-new file mode 100644
-index 00000000000..ff1a73d097a
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.h
-@@ -0,0 +1,98 @@
-+#include "Python.h"
-+#include <stdbool.h>
-+
-+#if PY_VERSION_HEX >= 0x030C00A5
-+#define ob_digit(o)  (((PyLongObject*)o)->long_value.ob_digit)
-+#else
-+#define ob_digit(o)  (((PyLongObject*)o)->ob_digit)
-+#endif
-+
-+#if PY_VERSION_HEX >= 0x030C00A7
-+// taken from cpython:Include/internal/pycore_long.h @ 3.12
-+
-+/* Long value tag bits:
-+ * 0-1: Sign bits value = (1-sign), ie. negative=2, positive=0, zero=1.
-+ * 2: Reserved for immortality bit
-+ * 3+ Unsigned digit count
-+ */
-+#define SIGN_MASK 3
-+#define SIGN_ZERO 1
-+#define SIGN_NEGATIVE 2
-+#define NON_SIZE_BITS 3
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_ZERO;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_NEGATIVE;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    assert(PyLong_Check(op));
-+    return op->long_value.lv_tag >> NON_SIZE_BITS;
-+}
-+
-+#define TAG_FROM_SIGN_AND_SIZE(sign, size) ((1 - (sign)) | ((size) << NON_SIZE_BITS))
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+    assert(size >= 0);
-+    assert(-1 <= sign && sign <= 1);
-+    assert(sign != 0 || size == 0);
-+    op->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sign, (size_t)size);
-+}
-+
-+#else
-+// fallback for < 3.12
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) == 0;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) < 0;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) > 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    Py_ssize_t size = Py_SIZE(op);
-+    return size < 0 ? -size : size;
-+}
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION < 9)
-+// The function Py_SET_SIZE is defined starting with python 3.9.
-+    Py_SIZE(o) = size;
-+#else
-+    Py_SET_SIZE(op, sign < 0 ? -size : size);
-+#endif
-+}
-+
-+#endif
-diff --git a/src/sage/cpython/pycore_long.pxd b/src/sage/cpython/pycore_long.pxd
-new file mode 100644
-index 00000000000..41de637ff18
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.pxd
-@@ -0,0 +1,9 @@
-+from cpython.longintrepr cimport py_long, digit
-+
-+cdef extern from "pycore_long.h":
-+    digit* ob_digit(py_long o)
-+    bint _PyLong_IsZero(py_long o)
-+    bint _PyLong_IsNegative(py_long o)
-+    bint _PyLong_IsPositive(py_long o)
-+    Py_ssize_t _PyLong_DigitCount(py_long o)
-+    void _PyLong_SetSignAndDigitCount(py_long o, int sign, Py_ssize_t size)
-diff --git a/src/sage/crypto/classical.py b/src/sage/crypto/classical.py
-index 616dc861652..be899c781e5 100644
---- a/src/sage/crypto/classical.py
-+++ b/src/sage/crypto/classical.py
-@@ -494,7 +494,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: A.rank_by_chi_square("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_chi_square(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -703,7 +703,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: A.rank_by_squared_differences("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_squared_differences(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -2114,7 +2114,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: S.rank_by_chi_square("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_chi_square(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-@@ -2351,7 +2351,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: S.rank_by_squared_differences("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_squared_differences(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/crypto/mq/mpolynomialsystemgenerator.py b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-index 9028dab1d98..4416d9ef7f6 100644
---- a/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-+++ b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-@@ -156,7 +156,7 @@ def sbox(self):
-             sage: msg.sbox()
-             Traceback (most recent call last):
-             ...
--            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'
-+            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'...
-         """
-         return self._sbox
- 
-diff --git a/src/sage/data_structures/bitset.pyx b/src/sage/data_structures/bitset.pyx
-index 446062554c1..d9906b5edd2 100644
---- a/src/sage/data_structures/bitset.pyx
-+++ b/src/sage/data_structures/bitset.pyx
-@@ -967,7 +967,7 @@ cdef class FrozenBitset:
-             sage: None | FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute '_union'
-+            AttributeError: 'NoneType' object has no attribute '_union'...
-         """
-         return self._union(other)
- 
-@@ -1037,7 +1037,7 @@ cdef class FrozenBitset:
-             sage: None & FrozenBitset("101011")
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'intersection'
-+            AttributeError: 'NoneType' object has no attribute 'intersection'...
-         """
-         return self.intersection(other)
- 
-@@ -1106,7 +1106,7 @@ cdef class FrozenBitset:
-             sage: None - FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'difference'
-+            AttributeError: 'NoneType' object has no attribute 'difference'...
-         """
-         return self.difference(other)
- 
-@@ -1179,7 +1179,7 @@ cdef class FrozenBitset:
-             sage: None ^^ FrozenBitset('11111' * 10)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'
-+            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'...
-         """
-         return self.symmetric_difference(other)
- 
-diff --git a/src/sage/doctest/reporting.py b/src/sage/doctest/reporting.py
-index 361fea344c2..a3947c07e01 100644
---- a/src/sage/doctest/reporting.py
-+++ b/src/sage/doctest/reporting.py
-@@ -368,7 +368,7 @@ def report(self, source, timeout, return_code, results, output, pid=None):
-             sage: DTR.report(None, None, None, None, None)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'basename'
-+            AttributeError: 'NoneType' object has no attribute 'basename'...
- 
-         The only-errors mode does not output anything on success::
- 
-diff --git a/src/sage/dynamics/finite_dynamical_system.py b/src/sage/dynamics/finite_dynamical_system.py
-index e5fbf568b7e..4295070615a 100644
---- a/src/sage/dynamics/finite_dynamical_system.py
-+++ b/src/sage/dynamics/finite_dynamical_system.py
-@@ -240,7 +240,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-@@ -252,7 +252,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-diff --git a/src/sage/geometry/cone.py b/src/sage/geometry/cone.py
-index f0a8620011a..53f78a4b7b6 100644
---- a/src/sage/geometry/cone.py
-+++ b/src/sage/geometry/cone.py
-@@ -340,7 +340,7 @@ def Cone(rays, lattice=None, check=True, normalize=True):
-         sage: Cone([(1,0), (0,1)], check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     You can construct different "not" cones: not full-dimensional, not
-     strictly convex, not containing any rays::
-diff --git a/src/sage/geometry/fan.py b/src/sage/geometry/fan.py
-index 258544012fe..3aecc84a55b 100644
---- a/src/sage/geometry/fan.py
-+++ b/src/sage/geometry/fan.py
-@@ -443,7 +443,7 @@ def Fan(cones, rays=None, lattice=None, check=True, normalize=True,
-         sage: P2c = Fan(cones, rays, check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     Yet another way is to use functions :func:`FaceFan` and :func:`NormalFan`
-     to construct fans from :class:`lattice polytopes
-diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-index f0ac1e774a7..f03f0f832ff 100644
---- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-+++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-@@ -351,7 +351,7 @@ cdef class FaceIterator_base(SageObject):
-             sage: FaceIterator_base(2)  # indirect doctest
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'...
-         """
-         cdef int i
-         sig_free(self.structure.atom_rep)
-@@ -1945,7 +1945,8 @@ cdef inline int next_face_loop(iter_t structure) nogil except -1:
-         # The function is not supposed to be called,
-         # just prevent it from crashing.
-         # Actually raising an error here results in a bad branch prediction.
--        return -1
-+        # But return -1 results in a crash with python 3.12
-+        raise StopIteration
- 
-     # Getting ``[faces, n_faces, n_visited_all]`` according to dimension.
-     cdef face_list_t* faces = &structure.new_faces[structure.current_dimension]
-diff --git a/src/sage/geometry/toric_plotter.py b/src/sage/geometry/toric_plotter.py
-index 50b4008eb0f..950e3ba7ff8 100644
---- a/src/sage/geometry/toric_plotter.py
-+++ b/src/sage/geometry/toric_plotter.py
-@@ -706,7 +706,7 @@ def set_rays(self, generators):
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ToricPlotter' object has no attribute 'rays'
-+            AttributeError: 'ToricPlotter' object has no attribute 'rays'...
-             sage: tp.set_rays([(0,1)])
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Graphics object consisting of 2 graphics primitives
-diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
-index d0ec214bb3b..c8098ad578a 100644
---- a/src/sage/groups/matrix_gps/finitely_generated.py
-+++ b/src/sage/groups/matrix_gps/finitely_generated.py
-@@ -268,7 +268,7 @@ def MatrixGroup(*gens, **kwds):
-         sage: SL2C.gens()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'
-+        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'...
-     """
-     if isinstance(gens[-1], dict):   # hack for unpickling
-         kwds.update(gens[-1])
-diff --git a/src/sage/homology/chains.py b/src/sage/homology/chains.py
-index 87c0947c0b0..b9a54940943 100644
---- a/src/sage/homology/chains.py
-+++ b/src/sage/homology/chains.py
-@@ -298,7 +298,7 @@ def is_cycle(self):
-                 sage: chain.is_cocycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -325,7 +325,7 @@ def is_boundary(self):
-                 sage: chain.is_coboundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -539,7 +539,7 @@ def is_cocycle(self):
-                 sage: cochain.is_cycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -566,7 +566,7 @@ def is_coboundary(self):
-                 sage: cochain.is_boundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -604,7 +604,7 @@ def eval(self, other):
-                 sage: z.eval(c) # z is not a cochain
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'...
-                 sage: c.eval(c) # can't evaluate a cochain on a cochain
-                 Traceback (most recent call last):
-                 ...
-diff --git a/src/sage/homology/free_resolution.py b/src/sage/homology/free_resolution.py
-index e3d38de4240..280a479b438 100644
---- a/src/sage/homology/free_resolution.py
-+++ b/src/sage/homology/free_resolution.py
-@@ -275,7 +275,7 @@ def differential(self, i):
-             sage: FreeResolution.differiental(r, 1)
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'FreeResolution' has no attribute 'differiental'
-+            AttributeError: type object 'FreeResolution' has no attribute 'differiental'...
-         """
- 
-     def target(self):
-diff --git a/src/sage/interfaces/magma.py b/src/sage/interfaces/magma.py
-index b7a0ac20d03..529bfbc349b 100644
---- a/src/sage/interfaces/magma.py
-+++ b/src/sage/interfaces/magma.py
-@@ -824,7 +824,7 @@ def _coerce_from_special_method(self, x):
-             sage: magma._coerce_from_special_method('2 + 3')  # optional - magma
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute '_magma_init_'
-+            AttributeError: 'str' object has no attribute '_magma_init_'...
-         """
-         s = x._magma_init_(self)
-         a = self(s)
-diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
-index 58499396d6c..16119d20815 100644
---- a/src/sage/lfunctions/dokchitser.py
-+++ b/src/sage/lfunctions/dokchitser.py
-@@ -418,8 +418,8 @@ def init_coeffs(self, v, cutoff=1,
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
-index bbf289aa21c..e4968866303 100644
---- a/src/sage/lfunctions/pari.py
-+++ b/src/sage/lfunctions/pari.py
-@@ -141,8 +141,8 @@ def init_coeffs(self, v, cutoff=None, w=1):
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
-index 478caf9f9d0..363024ae281 100644
---- a/src/sage/libs/gap/element.pyx
-+++ b/src/sage/libs/gap/element.pyx
-@@ -380,7 +380,7 @@ cdef GapElement make_GapElement(parent, Obj obj):
-         sage: libgap(None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute '_libgap_init_'
-+        AttributeError: 'NoneType' object has no attribute '_libgap_init_'...
-     """
-     cdef GapElement r = GapElement.__new__(GapElement)
-     r._initialize(parent, obj)
-diff --git a/src/sage/libs/gmp/pylong.pxd b/src/sage/libs/gmp/pylong.pxd
-index a73f1da6d6f..84e1bb8cd87 100644
---- a/src/sage/libs/gmp/pylong.pxd
-+++ b/src/sage/libs/gmp/pylong.pxd
-@@ -2,9 +2,10 @@
- Various functions to deal with conversion mpz <-> Python int/long
- """
- 
-+from cpython.longintrepr cimport py_long
- from sage.libs.gmp.types cimport *
- 
- cdef mpz_get_pylong(mpz_srcptr z)
- cdef mpz_get_pyintlong(mpz_srcptr z)
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1
- cdef Py_hash_t mpz_pythonhash(mpz_srcptr z)
-diff --git a/src/sage/libs/gmp/pylong.pyx b/src/sage/libs/gmp/pylong.pyx
-index d5993cca5a5..1a36c29d3fa 100644
---- a/src/sage/libs/gmp/pylong.pyx
-+++ b/src/sage/libs/gmp/pylong.pyx
-@@ -28,6 +28,8 @@ AUTHORS:
- from cpython.object cimport Py_SIZE
- from cpython.long cimport PyLong_FromLong
- from cpython.longintrepr cimport _PyLong_New, py_long, digit, PyLong_SHIFT
-+from sage.cpython.pycore_long cimport (ob_digit, _PyLong_IsNegative,
-+    _PyLong_DigitCount, _PyLong_SetSignAndDigitCount)
- from .mpz cimport *
- 
- cdef extern from *:
-@@ -60,12 +62,9 @@ cdef mpz_get_pylong_large(mpz_srcptr z):
-     """
-     cdef size_t nbits = mpz_sizeinbase(z, 2)
-     cdef size_t pylong_size = (nbits + PyLong_SHIFT - 1) // PyLong_SHIFT
--    L = _PyLong_New(pylong_size)
--    mpz_export(L.ob_digit, NULL,
--            -1, sizeof(digit), 0, PyLong_nails, z)
--    if mpz_sgn(z) < 0:
--        # Set correct size
--        Py_SET_SIZE(L, -pylong_size)
-+    cdef py_long L = _PyLong_New(pylong_size)
-+    mpz_export(ob_digit(L), NULL, -1, sizeof(digit), 0, PyLong_nails, z)
-+    _PyLong_SetSignAndDigitCount(L, mpz_sgn(z), pylong_size)
-     return L
- 
- 
-@@ -88,16 +87,13 @@ cdef mpz_get_pyintlong(mpz_srcptr z):
-     return mpz_get_pylong_large(z)
- 
- 
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1:
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1:
-     """
-     Convert a Python ``long`` `L` to an ``mpz``.
-     """
--    cdef Py_ssize_t pylong_size = Py_SIZE(L)
--    if pylong_size < 0:
--        pylong_size = -pylong_size
--    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails,
--            (<py_long>L).ob_digit)
--    if Py_SIZE(L) < 0:
-+    cdef Py_ssize_t pylong_size = _PyLong_DigitCount(L)
-+    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails, ob_digit(L))
-+    if _PyLong_IsNegative(L):
-         mpz_neg(z, z)
- 
- 
-diff --git a/src/sage/manifolds/calculus_method.py b/src/sage/manifolds/calculus_method.py
-index f5830c0bc45..303dde6cd13 100644
---- a/src/sage/manifolds/calculus_method.py
-+++ b/src/sage/manifolds/calculus_method.py
-@@ -257,7 +257,7 @@ def simplify(self, expression, method=None):
-             sage: cm.simplify(f)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'
-+            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'...
- 
-         In the present case, one should either transform ``f`` to a SymPy
-         object::
-diff --git a/src/sage/manifolds/differentiable/vectorfield_module.py b/src/sage/manifolds/differentiable/vectorfield_module.py
-index d954b5d4839..af4bfb0ceec 100644
---- a/src/sage/manifolds/differentiable/vectorfield_module.py
-+++ b/src/sage/manifolds/differentiable/vectorfield_module.py
-@@ -885,7 +885,7 @@ def tensor(self, *args, **kwds):
-             sage: XM.tensor(XM).tensor(XM.dual().tensor(XM.dual()))
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'
-+            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'...
- 
-         .. SEEALSO::
- 
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 86aca6e00d8..a5f6716e731 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15303,7 +15303,7 @@ cdef class Matrix(Matrix1):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
--            has no attribute 'conjugate'
-+            has no attribute 'conjugate'...
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/matrix/matrix_cyclo_dense.pyx b/src/sage/matrix/matrix_cyclo_dense.pyx
-index f54f3423ded..a49bb6240e6 100644
---- a/src/sage/matrix/matrix_cyclo_dense.pyx
-+++ b/src/sage/matrix/matrix_cyclo_dense.pyx
-@@ -847,7 +847,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense):
-             sage: A.set_mutable()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'
-+            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'...
-             sage: B = A.__copy__()
-             sage: B[0,0] = 20
-             sage: B[0,0]
-diff --git a/src/sage/matrix/matrix_gfpn_dense.pyx b/src/sage/matrix/matrix_gfpn_dense.pyx
-index 4cccf473de1..8e8e4d7336b 100644
---- a/src/sage/matrix/matrix_gfpn_dense.pyx
-+++ b/src/sage/matrix/matrix_gfpn_dense.pyx
-@@ -159,7 +159,7 @@ cdef class FieldConverter_class:
-             sage: C.field_to_fel('foo')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'to_integer'
-+            AttributeError: 'str' object has no attribute 'to_integer'...
-         """
-         return FfFromInt(x.to_integer())
- 
-diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py
-index 6aab58352be..b5e6f52349b 100644
---- a/src/sage/matrix/matrix_space.py
-+++ b/src/sage/matrix/matrix_space.py
-@@ -1619,7 +1619,7 @@ def __getitem__(self, x):
-             sage: MS[2]
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'
-+            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'...
-         """
-         if isinstance(x, (integer.Integer, int)):
-             return self.list()[x]
-diff --git a/src/sage/matroids/lean_matrix.pyx b/src/sage/matroids/lean_matrix.pyx
-index 54c68e637c0..a137cbf70e5 100644
---- a/src/sage/matroids/lean_matrix.pyx
-+++ b/src/sage/matroids/lean_matrix.pyx
-@@ -1,5 +1,4 @@
- # sage.doctest: optional - sage.rings.finite_rings
--# cython: profile=True
- """
- Lean matrices
- 
-diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx
-index 36f563aa433..318c82f2b64 100644
---- a/src/sage/matroids/linear_matroid.pyx
-+++ b/src/sage/matroids/linear_matroid.pyx
-@@ -1134,7 +1134,7 @@ cdef class LinearMatroid(BasisExchangeMatroid):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.matroids.basis_matroid.BasisMatroid' object
--            has no attribute 'base_ring'
-+            has no attribute 'base_ring'...
-             sage: from sage.matroids.advanced import *
-             sage: M4 = BinaryMatroid(Matrix(M1))
-             sage: M5 = LinearMatroid(reduced_matrix=Matrix(GF(2), [[-1, 0, 1],
-diff --git a/src/sage/misc/dev_tools.py b/src/sage/misc/dev_tools.py
-index e7bf176592c..3ece7db2894 100644
---- a/src/sage/misc/dev_tools.py
-+++ b/src/sage/misc/dev_tools.py
-@@ -171,6 +171,7 @@ def load_submodules(module=None, exclude_pattern=None):
-         load sage.geometry.polyhedron.ppl_lattice_polygon... succeeded
-     """
-     from .package_dir import walk_packages
-+    import importlib.util
- 
-     if module is None:
-         import sage
-@@ -194,8 +195,12 @@ def load_submodules(module=None, exclude_pattern=None):
-         try:
-             sys.stdout.write("load %s..." % module_name)
-             sys.stdout.flush()
--            loader = importer.find_module(module_name)
--            loader.load_module(module_name)
-+            # see
-+            # https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
-+            spec = importer.find_spec(module_name)
-+            module = importlib.util.module_from_spec(spec)
-+            sys.modules[module_name] = module
-+            spec.loader.exec_module(module)
-             sys.stdout.write(" succeeded\n")
-         except (ValueError, AttributeError, TypeError, ImportError):
-             # we might get error because of cython code that has been
-diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py
-index c922b8f6f12..03697f08b7c 100644
---- a/src/sage/misc/functional.py
-+++ b/src/sage/misc/functional.py
-@@ -86,7 +86,7 @@ def base_field(x):
-         sage: R.base_field()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'
-+        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'...
-     """
-     try:
-         return x.base_field()
-diff --git a/src/sage/misc/instancedoc.pyx b/src/sage/misc/instancedoc.pyx
-index d8e1e4ac536..44ee70f64ba 100644
---- a/src/sage/misc/instancedoc.pyx
-+++ b/src/sage/misc/instancedoc.pyx
-@@ -256,7 +256,7 @@ cdef class InstanceDocDescriptor:
-             sage: descr.__delete__(obj)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'X' object has no attribute '__doc__'
-+            AttributeError: 'X' object has no attribute '__doc__'...
- 
-             sage: descr.__delete__([])
-             Traceback (most recent call last):
-diff --git a/src/sage/misc/lazy_attribute.pyx b/src/sage/misc/lazy_attribute.pyx
-index bdbec3b3ba1..1f07870b8ec 100644
---- a/src/sage/misc/lazy_attribute.pyx
-+++ b/src/sage/misc/lazy_attribute.pyx
-@@ -441,37 +441,37 @@ class lazy_attribute(_lazy_attribute):
-             sage: B().unimplemented_A # todo: not implemented
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'super' object has no attribute 'unimplemented_A'
-+            AttributeError: 'super' object has no attribute 'unimplemented_A'...
- 
-     We now make some systematic checks::
- 
-         sage: B().unimplemented_A
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: B().unimplemented_B
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: B().unimplemented_AB
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: B().unimplemented_B_implemented_A
-         1
- 
-         sage: C().unimplemented_A()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: C().unimplemented_B()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: C().unimplemented_AB()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: C().unimplemented_B_implemented_A # todo: not implemented
-         1
-     """
-diff --git a/src/sage/misc/object_multiplexer.py b/src/sage/misc/object_multiplexer.py
-index d4e811ef16e..00fd89d6652 100644
---- a/src/sage/misc/object_multiplexer.py
-+++ b/src/sage/misc/object_multiplexer.py
-@@ -85,7 +85,7 @@ def __getattr__(self, name):
-             sage: m.__bork__
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Multiplex' has no attribute '__bork__'
-+            AttributeError: 'Multiplex' has no attribute '__bork__'...
-         """
-         if name.startswith("__"):
-             raise AttributeError("'Multiplex' has no attribute '%s'" % name)
-diff --git a/src/sage/misc/sage_input.py b/src/sage/misc/sage_input.py
-index 66e78ecccbc..00e8d96ee9e 100644
---- a/src/sage/misc/sage_input.py
-+++ b/src/sage/misc/sage_input.py
-@@ -3461,7 +3461,7 @@ def verify_same(a, b):
-         sage: verify_same(1, 1r)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_same(1r, 1)
-         Traceback (most recent call last):
-         ...
-@@ -3525,7 +3525,7 @@ def verify_si_answer(x, answer, preparse):
-         sage: verify_si_answer(1, '1', False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_si_answer(1, 'ZZ(1)', None)
-     """
-     from sage.misc.sage_eval import sage_eval
-diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py
-index f0545be7d81..811afc48755 100644
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -602,7 +602,7 @@ def visit_Num(self, node):
-             On Python 3 negative numbers are parsed first, for some reason, as
-             a UnaryOp node.
-         """
--        return node.n
-+        return node.value
- 
-     def visit_Str(self, node):
-         r"""
-@@ -624,7 +624,7 @@ def visit_Str(self, node):
-             sage: [vis(s) for s in ['"abstract"', "'syntax'", r'''r"tr\ee"''']]
-             ['abstract', 'syntax', 'tr\\ee']
-         """
--        return node.s
-+        return node.value
- 
-     def visit_List(self, node):
-         """
-diff --git a/src/sage/modules/fp_graded/steenrod/module.py b/src/sage/modules/fp_graded/steenrod/module.py
-index 18460b0e9a1..4acfa6b4002 100755
---- a/src/sage/modules/fp_graded/steenrod/module.py
-+++ b/src/sage/modules/fp_graded/steenrod/module.py
-@@ -70,7 +70,7 @@
-     sage: SteenrodFPModule(ZZ, [0])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'
-+    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'...
- 
- AUTHORS:
- 
-diff --git a/src/sage/monoids/trace_monoid.py b/src/sage/monoids/trace_monoid.py
-index 00baa4d14f8..f8176a1e1f2 100644
---- a/src/sage/monoids/trace_monoid.py
-+++ b/src/sage/monoids/trace_monoid.py
-@@ -40,7 +40,6 @@
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from collections import OrderedDict
- from itertools import repeat, chain, product
- 
- from sage.misc.cachefunc import cached_method
-@@ -633,14 +632,14 @@ def _compute_dependence_stack(self, x):
-             sage: x = b*a*d*a*c*b
-             sage: M._compute_dependence_stack(x)
-             ({a, b, c, d},
--             OrderedDict([(a, [False, False, True, True, False]),
--                          (b, [True, False, False, False, True]),
--                          (c, [True, False, False, False]),
--                          (d, [False, False, True, False])]))
-+             {a: [False, False, True, True, False],
-+              b: [True, False, False, False, True],
-+              c: [True, False, False, False],
-+              d: [False, False, True, False]})
-         """
-         independence = self._independence
-         generators_set = set(e for e, _ in x)
--        stacks = OrderedDict(sorted((g, []) for g in generators_set))
-+        stacks = dict(sorted((g, []) for g in generators_set))
-         for generator, times in reversed(list(x)):
-             stacks[generator].extend(repeat(True, times))
-             for other_gen in generators_set:
-diff --git a/src/sage/parallel/map_reduce.py b/src/sage/parallel/map_reduce.py
-index 11e0673ee91..5441943731d 100644
---- a/src/sage/parallel/map_reduce.py
-+++ b/src/sage/parallel/map_reduce.py
-@@ -1234,7 +1234,7 @@ def finish(self):
-             sage: S.print_communication_statistics()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'RESetMPExample' object has no attribute '_stats'
-+            AttributeError: 'RESetMPExample' object has no attribute '_stats'...
- 
-             sage: S.finish()
- 
-diff --git a/src/sage/plot/colors.py b/src/sage/plot/colors.py
-index 8c0db2b3c34..3281199400b 100644
---- a/src/sage/plot/colors.py
-+++ b/src/sage/plot/colors.py
-@@ -1099,7 +1099,7 @@ def __getattr__(self, name):
-             sage: cols.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ColorsDict' has no attribute or colormap punk
-+            AttributeError: 'ColorsDict' has no attribute or colormap punk...
-         """
-         try:
-             return self[name]
-@@ -1599,7 +1599,7 @@ def __getattr__(self, name):
-             sage: maps.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Colormaps' has no attribute or colormap punk
-+            AttributeError: 'Colormaps' has no attribute or colormap punk...
-             sage: maps['punk']
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/rings/asymptotic/asymptotic_ring.py b/src/sage/rings/asymptotic/asymptotic_ring.py
-index b07319382d3..994490e6616 100644
---- a/src/sage/rings/asymptotic/asymptotic_ring.py
-+++ b/src/sage/rings/asymptotic/asymptotic_ring.py
-@@ -1091,7 +1091,7 @@ def monomial_coefficient(self, monomial):
-             sage: O(n).monomial_coefficient(n)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'
-+            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'...
- 
-         The ``monomial`` must be exact::
- 
-diff --git a/src/sage/rings/asymptotic/growth_group.py b/src/sage/rings/asymptotic/growth_group.py
-index 27c14592bca..5be12537d62 100644
---- a/src/sage/rings/asymptotic/growth_group.py
-+++ b/src/sage/rings/asymptotic/growth_group.py
-@@ -1572,7 +1572,7 @@ def variable_names(self):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'GenericGrowthGroup_with_category.element_class' object
--            has no attribute 'is_one'
-+            has no attribute 'is_one'...
-         """
-         if self.is_one():
-             return tuple()
-diff --git a/src/sage/rings/ideal.py b/src/sage/rings/ideal.py
-index d36d9406f32..01c9fa3bf2d 100644
---- a/src/sage/rings/ideal.py
-+++ b/src/sage/rings/ideal.py
-@@ -1553,7 +1553,7 @@ def gcd(self, other):
-             sage: J.gcd(I)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Ideal_generic' object has no attribute 'gcd'
-+            AttributeError: 'Ideal_generic' object has no attribute 'gcd'...
- 
-         Note::
- 
-diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
-index 7fe89197011..8832d27e8ea 100644
---- a/src/sage/rings/number_field/number_field.py
-+++ b/src/sage/rings/number_field/number_field.py
-@@ -3823,7 +3823,7 @@ def primes_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
-         """
-         if degree is not None:
-             degree = ZZ(degree)
-@@ -3917,7 +3917,7 @@ def prime_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
- 
-         """
-         ids = self.primes_above(x, degree)
-@@ -5926,7 +5926,7 @@ def factor(self, n):
-             sage: L.factor(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'...
- 
-         AUTHORS:
- 
-@@ -12698,7 +12698,7 @@ def is_real_place(v):
-         sage: is_real_place(v_fin)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'
-+        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'...
- 
-     """
-     RR = sage.rings.real_mpfr.RealField(53)
-diff --git a/src/sage/rings/padics/generic_nodes.py b/src/sage/rings/padics/generic_nodes.py
-index 7047020edec..b6b514d4005 100644
---- a/src/sage/rings/padics/generic_nodes.py
-+++ b/src/sage/rings/padics/generic_nodes.py
-@@ -740,7 +740,7 @@ def _get_element_class(self, name=None):
-             sage: R._get_element_class("foobar")
-             Traceback (most recent call last):
-             ...
--            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'
-+            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'...
-         """
-         if name is None:
-             return self.Element
-diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx
-index c5a1129aecf..a5b7f937cfe 100644
---- a/src/sage/rings/polynomial/polynomial_element.pyx
-+++ b/src/sage/rings/polynomial/polynomial_element.pyx
-@@ -10793,7 +10793,7 @@ cdef class Polynomial(CommutativePolynomial):
-             sage: (y**2 + x).nth_root(2)
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... has no attribute 'nth_root'
-+            AttributeError: ... has no attribute 'nth_root'...
- 
-         TESTS::
- 
-@@ -11831,7 +11831,7 @@ cdef class Polynomial_generic_dense(Polynomial):
-             sage: int(1) // x  # check that this doesn't segfault
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'int' has no attribute 'base_ring'
-+            AttributeError: type object 'int' has no attribute 'base_ring'...
-         """
-         if have_same_parent(self, right):
-             return (<Polynomial_generic_dense>self)._floordiv_(<Polynomial_generic_dense>right)
-diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-index e372be888ee..aca4f08420f 100644
---- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
-+++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-@@ -2362,7 +2362,7 @@ def field_extension(self, names):
-             sage: F, g, h = S.field_extension('b')                                      # needs sage.rings.finite_rings
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'
-+            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'...
- 
-         Over a finite field, the corresponding field extension is not a
-         number field::
-diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx
-index 5273891a5b0..a6e999b8805 100644
---- a/src/sage/rings/ring.pyx
-+++ b/src/sage/rings/ring.pyx
-@@ -1734,7 +1734,7 @@ cdef class IntegralDomain(CommutativeRing):
-             sage: Z5.is_integrally_closed()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'
-+            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'...
-         """
-         raise NotImplementedError
- 
-diff --git a/src/sage/sat/solvers/satsolver.pyx b/src/sage/sat/solvers/satsolver.pyx
-index c2f41b18f55..1c4ac400cb6 100644
---- a/src/sage/sat/solvers/satsolver.pyx
-+++ b/src/sage/sat/solvers/satsolver.pyx
-@@ -375,10 +375,10 @@ def SAT(solver=None, *args, **kwds):
-         DIMACS Solver: 'kissat -q {input}'
-     """
-     if solver is None:
--        import pkgutil
--        if pkgutil.find_loader('pycryptosat') is not None:
-+        from importlib.util import find_spec
-+        if find_spec('pycryptosat') is not None:
-             solver = "cryptominisat"
--        elif pkgutil.find_loader('pycosat') is not None:
-+        elif find_spec('pycosat') is not None:
-             solver = "picosat"
-         else:
-             solver = "LP"
-diff --git a/src/sage/schemes/toric/morphism.py b/src/sage/schemes/toric/morphism.py
-index 1c8944b6dfc..5d64d632f97 100644
---- a/src/sage/schemes/toric/morphism.py
-+++ b/src/sage/schemes/toric/morphism.py
-@@ -246,7 +246,7 @@
-     Traceback (most recent call last):
-     ...
-     AttributeError: 'SchemeMorphism_fan_toric_variety' object
--    has no attribute 'fiber_generic'
-+    has no attribute 'fiber_generic'...
- 
- Let's use factorization mentioned above::
- 
-diff --git a/src/sage/sets/disjoint_union_enumerated_sets.py b/src/sage/sets/disjoint_union_enumerated_sets.py
-index 3dea567a779..5c5e08612f2 100644
---- a/src/sage/sets/disjoint_union_enumerated_sets.py
-+++ b/src/sage/sets/disjoint_union_enumerated_sets.py
-@@ -597,7 +597,7 @@ def Element(self):
-             sage: U.Element
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'
-+            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'...
-         """
-         if not self._facade:
-             return ElementWrapper
-diff --git a/src/sage/sets/set.py b/src/sage/sets/set.py
-index a1789c61300..112d3d8dc3b 100644
---- a/src/sage/sets/set.py
-+++ b/src/sage/sets/set.py
-@@ -163,7 +163,7 @@ def Set(X=None, category=None):
-         sage: sorted(B.list(), key=repr)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'Set_object_with_category' object has no attribute 'list'
-+        AttributeError: 'Set_object_with_category' object has no attribute 'list'...
-         sage: type(B)
-         <class 'sage.sets.set.Set_object_with_category'>
- 
-diff --git a/src/sage/structure/category_object.pyx b/src/sage/structure/category_object.pyx
-index b6a7eaecb5b..c06933494dc 100644
---- a/src/sage/structure/category_object.pyx
-+++ b/src/sage/structure/category_object.pyx
-@@ -836,7 +836,7 @@ cdef class CategoryObject(SageObject):
-             sage: Sets().example().sadfasdf
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'
-+            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'...
-         """
-         return self.getattr_from_category(name)
- 
-diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx
-index caae7e40ffc..543506e9a74 100644
---- a/src/sage/structure/element.pyx
-+++ b/src/sage/structure/element.pyx
-@@ -219,7 +219,7 @@ the parents::
-     sage: x._add_(x)
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-     sage: x + x
-     Traceback (most recent call last):
-     ...
-@@ -478,13 +478,13 @@ cdef class Element(SageObject):
-             sage: 1.blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'...
-             sage: Semigroups().example().an_element().is_idempotent
-             <bound method LeftZeroSemigroup.Element.is_idempotent of 42>
-             sage: Semigroups().example().an_element().blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'
-+            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'...
-         """
-         return self.getattr_from_category(name)
- 
-@@ -1269,7 +1269,7 @@ cdef class Element(SageObject):
-             sage: e._add_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-         """
-         try:
-             python_op = (<object>self)._add_
-@@ -1381,7 +1381,7 @@ cdef class Element(SageObject):
-             sage: e._sub_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'...
-         """
-         try:
-             python_op = (<object>self)._sub_
-@@ -1435,7 +1435,7 @@ cdef class Element(SageObject):
-             sage: e._neg_()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'...
-         """
-         try:
-             python_op = (<object>self)._neg_
-@@ -1549,7 +1549,7 @@ cdef class Element(SageObject):
-             sage: e._mul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'...
-         """
-         try:
-             python_op = (<object>self)._mul_
-@@ -1662,7 +1662,7 @@ cdef class Element(SageObject):
-             sage: e._matmul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'...
-         """
-         try:
-             python_op = (<object>self)._matmul_
-@@ -1765,7 +1765,7 @@ cdef class Element(SageObject):
-             sage: e._div_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'...
-         """
-         try:
-             python_op = (<object>self)._div_
-@@ -1865,7 +1865,7 @@ cdef class Element(SageObject):
-             sage: e._floordiv_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'...
-         """
-         try:
-             python_op = (<object>self)._floordiv_
-@@ -1965,7 +1965,7 @@ cdef class Element(SageObject):
-             sage: e._mod_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'...
-         """
-         try:
-             python_op = (<object>self)._mod_
-@@ -2092,7 +2092,7 @@ cdef class Element(SageObject):
-             sage: e._pow_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'...
-         """
-         try:
-             python_op = (<object>self)._pow_
-@@ -2122,7 +2122,7 @@ cdef class Element(SageObject):
-             sage: e._pow_int(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'...
-         """
-         try:
-             python_op = (<object>self)._pow_int
-@@ -2856,7 +2856,7 @@ cdef class RingElement(ModuleElement):
-             sage: m.is_nilpotent()                                                      # needs sage.modules
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... object has no attribute 'is_nilpotent'
-+            AttributeError: '...' object has no attribute 'is_nilpotent'...
-         """
-         if self.is_unit():
-             return False
-@@ -4671,7 +4671,7 @@ def coerce_binop(method):
-         sage: x.test_add(CC(2))
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'
-+        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'...
- 
-     TESTS:
- 
-diff --git a/src/sage/structure/sequence.py b/src/sage/structure/sequence.py
-index 0c700c1fb81..c3972532ac3 100644
---- a/src/sage/structure/sequence.py
-+++ b/src/sage/structure/sequence.py
-@@ -854,7 +854,7 @@ def __getattr__(self, name):
-             sage: S.universe()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'...
-             sage: S._Sequence__universe = 'foobar'
-             sage: S.universe()
-             'foobar'
-@@ -867,7 +867,7 @@ def __getattr__(self, name):
-             sage: hash(S)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'...
-             sage: S._Sequence__hash = int(34)
-             sage: hash(S)
-             34
-diff --git a/src/sage/symbolic/assumptions.py b/src/sage/symbolic/assumptions.py
-index 7dcb15f0d85..15f6fa07ce6 100644
---- a/src/sage/symbolic/assumptions.py
-+++ b/src/sage/symbolic/assumptions.py
-@@ -636,7 +636,7 @@ def assume(*args):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no
--        attribute 'assume'
-+        attribute 'assume'...
- 
-     Ensure that we can combine the two types of assumptions, as documented::
- 
-diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx
-index 0f251ac4e5c..66f624141b3 100644
---- a/src/sage/symbolic/expression.pyx
-+++ b/src/sage/symbolic/expression.pyx
-@@ -13712,7 +13712,7 @@ cdef get_dynamic_class_for_function(unsigned serial):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.symbolic.expression.Expression' object has no
--        attribute 'argp1'
-+        attribute 'argp1'...
-         sage: t = (e + 1).op[0]; t
-         tfunc(x)
-         sage: t
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index c4152e092e3..4bcf45e8793 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -67,6 +67,7 @@
- #include "archive.h"
- #include "tostring.h"
- #include "utils.h"
-+#include "../../cpython/pycore_long.h"
- 
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wdeprecated-register"
-@@ -706,18 +707,12 @@ static long _mpq_pythonhash(mpq_t the_rat)
- // Initialize an mpz_t from a Python long integer
- static void _mpz_set_pylong(mpz_t z, PyLongObject* l)
- {
--    Py_ssize_t pylong_size = Py_SIZE(l);
--    int sign = 1;
--
--    if (pylong_size < 0) {
--        pylong_size = -pylong_size;
--        sign = -1;
--    }
-+    Py_ssize_t pylong_size = _PyLong_DigitCount(l);
- 
-     mpz_import(z, pylong_size, -1, sizeof(digit), 0,
--               8*sizeof(digit) - PyLong_SHIFT, l->ob_digit);
-+               8*sizeof(digit) - PyLong_SHIFT, ob_digit(l));
- 
--    if (sign < 0)
-+    if (_PyLong_IsNegative(l))
-         mpz_neg(z, z);
- }
- 
-diff --git a/src/sage/symbolic/pynac_impl.pxi b/src/sage/symbolic/pynac_impl.pxi
-index 68c31dcfde7..7fd7c3b314b 100644
---- a/src/sage/symbolic/pynac_impl.pxi
-+++ b/src/sage/symbolic/pynac_impl.pxi
-@@ -619,7 +619,7 @@ def tolerant_is_symbol(a):
-         sage: None.is_symbol()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute 'is_symbol'
-+        AttributeError: 'NoneType' object has no attribute 'is_symbol'...
-     """
-     try:
-         return a.is_symbol()
diff --git a/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch b/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
new file mode 100644
index 0000000000000..1e695c2d9d106
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
@@ -0,0 +1,134 @@
+diff --git a/src/sage/quadratic_forms/quadratic_form__neighbors.py b/src/sage/quadratic_forms/quadratic_form__neighbors.py
+index fb781e20122..ec853cd52ef 100644
+--- a/src/sage/quadratic_forms/quadratic_form__neighbors.py
++++ b/src/sage/quadratic_forms/quadratic_form__neighbors.py
+@@ -74,6 +74,10 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+         sage: v = Q.find_primitive_p_divisible_vector__next(5, v); v
+         (1, 0)
+         sage: v = Q.find_primitive_p_divisible_vector__next(5, v); v
++        sage: v = Q.find_primitive_p_divisible_vector__next(2) ; v
++        (0, 1)
++        sage: v = Q.find_primitive_p_divisible_vector__next(2, v) ; v
++        (1, 0)
+         sage: Q = QuadraticForm(QQ, matrix.diagonal([1,1,1,1]))
+         sage: v = Q.find_primitive_p_divisible_vector__next(2)
+         sage: Q(v)
+@@ -83,6 +87,9 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+     n = self.dim()
+     if v is None:
+         w = vector(ZZ, [0] * (n - 1) + [1])
++        a = self(w)
++        if a in ZZ and (a % p == 0):
++            return w
+     else:
+         w = deepcopy(v)
+ 
+@@ -132,7 +139,7 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+             return w
+ 
+ 
+-def find_p_neighbor_from_vec(self, p, y):
++def find_p_neighbor_from_vec(self, p, y, return_matrix=False):
+     r"""
+     Return the `p`-neighbor of ``self`` defined by ``y``.
+ 
+@@ -147,25 +154,32 @@ def find_p_neighbor_from_vec(self, p, y):
+     - ``p`` -- a prime number
+     - ``y`` -- a vector with `q(y) \in p \ZZ`
+     - ``odd`` -- (default: ``False``) if `p=2`, return also odd neighbors
++    - ``return_matrix`` -- (boolean, default ``False``) return
++      the transformation matrix instead of the quadratic form
+ 
+     EXAMPLES::
+ 
++        sage: # needs sage.libs.pari
+         sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1,1])
+         sage: v = vector([0,2,1,1])
+-        sage: X = Q.find_p_neighbor_from_vec(3, v); X                                   # needs sage.libs.pari
++        sage: X = Q.find_p_neighbor_from_vec(3, v); X
+         Quadratic form in 4 variables over Integer Ring with coefficients:
+         [ 1 0 0 0 ]
+         [ * 1 4 4 ]
+         [ * * 5 12 ]
+         [ * * * 9 ]
++        sage: B = Q.find_p_neighbor_from_vec(3, v, return_matrix=True)
++        sage: Q(B) == X
++        True
+ 
+     Since the base ring and the domain are not yet separate,
+     for rational, half integral forms we just pretend
+     the base ring is `\ZZ`::
+ 
++        sage: # needs sage.libs.pari
+         sage: Q = QuadraticForm(QQ, matrix.diagonal([1,1,1,1]))
+         sage: v = vector([1,1,1,1])
+-        sage: Q.find_p_neighbor_from_vec(2, v)                                          # needs sage.libs.pari
++        sage: Q.find_p_neighbor_from_vec(2, v)
+         Quadratic form in 4 variables over Rational Field with coefficients:
+         [ 1/2 1 1 1 ]
+         [ * 1 1 2 ]
+@@ -227,9 +241,12 @@ def find_p_neighbor_from_vec(self, p, y):
+     # by definition this is the p-neighbor of L at y
+     # assert B.det().abs() == 1
+ 
+-    QF = self.parent()
+-    Gnew = (B*G*B.T).change_ring(R)
+-    return QF(Gnew)
++    if return_matrix:
++        return B.T
++    else:
++        QF = self.parent()
++        Gnew = (B*G*B.T).change_ring(R)
++        return QF(Gnew)
+ 
+ 
+ def neighbor_iteration(seeds, p, mass=None, max_classes=ZZ(10)**3,
+diff --git a/src/sage/quadratic_forms/ternary.pyx b/src/sage/quadratic_forms/ternary.pyx
+index 28dd9514c30..6e7c4389083 100644
+--- a/src/sage/quadratic_forms/ternary.pyx
++++ b/src/sage/quadratic_forms/ternary.pyx
+@@ -955,7 +955,26 @@ def extend(v):
+         [ 30   0  -7]
+         sage: M.det()
+         2
++
++    TESTS::
++
++        sage: M = matrix(3, extend( (0, 0, 1) ))
++        sage: M.det()
++        1
++        sage: M.column(0)
++        (0, 0, 1)
++        sage: M = matrix(3, extend( (0, 0, -2) ))
++        sage: M.det()
++        2
++        sage: M.column(0)
++        (0, 0, -2)
+     """
++    if v[0] == v[1] == 0:
++        if v[2] < 0:
++            return v[0], 0, 1,  v[1], 1, 0,  v[2], 0, 0
++        else:
++            return v[0], 1, 0,  v[1], 0, 1,  v[2], 0, 0
++
+     b1 = xgcd(v[0], v[1])
+     b2 = xgcd(b1[1], b1[2])
+     b3 = xgcd(b1[0], v[2])
+diff --git a/src/sage/quadratic_forms/ternary_qf.py b/src/sage/quadratic_forms/ternary_qf.py
+index fa4499566a9..2f3a57fa713 100644
+--- a/src/sage/quadratic_forms/ternary_qf.py
++++ b/src/sage/quadratic_forms/ternary_qf.py
+@@ -918,6 +918,13 @@ def find_p_neighbor_from_vec(self, p, v, mat=False):
+             [     0  -3/11  13/11]
+             sage: Q(M) == Q11
+             True
++
++        Test that it works with (0, 0, 1)::
++
++            sage: Q.find_p_neighbor_from_vec(3, (0,0,1))
++            Ternary quadratic form with integer coefficients:
++            [1 3 3]
++            [-2 0 -1]
+         """
+         if mat:
+             q, M = _find_p_neighbor_from_vec(self._a, self._b, self._c, self._r, self._s, self._t, p, v, mat)
diff --git a/srcpkgs/sagemath/patches/36696-fix_SSL_timeout.patch b/srcpkgs/sagemath/patches/36696-fix_SSL_timeout.patch
new file mode 100644
index 0000000000000..8693b0df5288b
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36696-fix_SSL_timeout.patch
@@ -0,0 +1,33 @@
+diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py
+index 8583d7a447d..633afd5c2e6 100644
+--- a/src/sage/doctest/control.py
++++ b/src/sage/doctest/control.py
+@@ -457,11 +457,15 @@ def __init__(self, options, args):
+                 options.hide.discard('all')
+                 from sage.features.all import all_features
+                 feature_names = {f.name for f in all_features() if not f.is_standard()}
++                from sage.doctest.external import external_software
++                feature_names.difference_update(external_software)
+                 options.hide = options.hide.union(feature_names)
+             if 'optional' in options.hide:
+                 options.hide.discard('optional')
+                 from sage.features.all import all_features
+                 feature_names = {f.name for f in all_features() if f.is_optional()}
++                from sage.doctest.external import external_software
++                feature_names.difference_update(external_software)
+                 options.hide = options.hide.union(feature_names)
+ 
+         options.disabled_optional = set()
+diff --git a/src/sage/features/internet.py b/src/sage/features/internet.py
+index f1eb000fe92..576b0136926 100644
+--- a/src/sage/features/internet.py
++++ b/src/sage/features/internet.py
+@@ -56,7 +56,7 @@ def _is_present(self):
+         try:
+             urlopen(req, timeout=1, context=default_context())
+             return FeatureTestResult(self, True)
+-        except urllib.error.URLError:
++        except (urllib.error.URLError, TimeoutError):
+             return FeatureTestResult(self, False)
+ 
+ 
diff --git a/srcpkgs/sagemath/patches/get_patches b/srcpkgs/sagemath/patches/get_patches
index 95a6963432948..c5ee28f6eb10c 100755
--- a/srcpkgs/sagemath/patches/get_patches
+++ b/srcpkgs/sagemath/patches/get_patches
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-version=10.1
+version=10.2.beta9
 
 URL_BASE_PR="https://github.com/sagemath/sage/pull/"
 URL_BASE_COMPARE="https://github.com/sagemath/sage/compare/${version}..."
@@ -20,24 +20,15 @@ get_pr() {
 # run from patches dir
 cd $(dirname "$0")
 
-# merged in 10.2.beta0
-#get_pr  36018   "singular 4.3.2p4" # included in #35934
-get_pr  36046   "fix memory leak"
-
-# merged in 10.2.beta1
-get_pr  35934   "singular 4.3.2p7"
-
-# merged in 10.2.beta2
-get_pr  36006   "gmp 6.3.0"
-
-# merged in 10.2.beta3
-get_pr  36235   "ecl 23.9.9"
-
-# merged in 10.2.beta4
-get_pr  36279   "matplotlib 3.8.0"
+# merged in 10.2.rc0
+#get_pr  36544   "networkx 3.2"
+#get_pr  36543   "cython warning"
+#get_pr  36573   "relative imports"
+#get_pr  36600   "giac 1.9.0-67"
 
 # positive review
-#get_pr  36403   "python 3.12" # included in #36407
 
 # needs review
-get_pr  36407   "python 3.12"
+get_pr  35848   "flintlib 3.0"
+get_pr  36551   "fix qf.nbs"
+get_pr  36696   "fix SSL timeout"
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index a80d8b7187ece..f76faa44ca588 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,14 +1,14 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=10.1
-revision=4
+version=10.2.rc1
+revision=1
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
 _bindir=/usr/lib/sagemath/$version/bin
 make_install_args="--install-scripts=$_bindir"
-hostmakedepends="m4 pkg-config python3-Cython0.29 python3-Jinja2
+hostmakedepends="m4 pkg-config python3-Cython python3-Jinja2
  python3-pkgconfig python3-setuptools"
-makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
+makedepends="boost-devel brial-devel cliquer-devel ecl eclib-devel
  ecm-devel fflas-ffpack flintlib-devel gap-devel gd-devel giac-devel glpk-devel
  gsl-devel iml-devel lcalc-devel libbraiding-devel libhomfly-devel libmpc-devel
  libpng-devel linbox-devel m4ri-devel m4rie-devel mpfi-devel
@@ -18,7 +18,7 @@ makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
 depends="eclib-devel fflas-ffpack flintlib-devel gcc-fortran gd-devel
  gfan giac gsl-devel gzip libpng-devel linbox-devel m4ri-devel maxima-ecl
  mpfr-devel nauty ntl-devel palp pari-devel pari-elldata-small pari-galdata
- pari-galpol-small pari-seadata-small pkg-config python3-Cython0.29 python3-cypari2
+ pari-galpol-small pari-seadata-small pkg-config python3-Cython python3-cypari2
  python3-cysignals python3-devel python3-fpylll python3-ipython python3-lrcalc
  python3-ipython_ipykernel python3-jupyter_ipywidgets python3-matplotlib
  python3-memory_allocator python3-networkx python3-pip python3-pkgconfig
@@ -33,7 +33,7 @@ license="GPL-2.0-or-later"
 homepage="https://www.sagemath.org/"
 changelog="https://github.com/sagemath/sage/releases"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=a658612b1b2376ddaf207cc8ed0ef458d4c2880c16e19139bedbe8baa42ad62f
+checksum=558aa9b4ec919bcc3e159b465feb643189eba2039e21f4f797dd91079024ce0a
 nocross="due to ntl (flintlib), fflas-ffpack, givaro, linbox, cysignals, sympow, maxima"
 
 post_patch() {
diff --git a/srcpkgs/sagemath/update b/srcpkgs/sagemath/update
index 68be3c5752d06..4e62503e2f8f4 100644
--- a/srcpkgs/sagemath/update
+++ b/srcpkgs/sagemath/update
@@ -1,2 +1,3 @@
 pkgname="sage"
-site="https://mirrors.mit.edu/sage/src/index.html"
+site="https://mirrors.mit.edu/sage/src/
+https://mirrors.mit.edu/sage/devel/"

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

* Re: [RC] sagemath: update to 10.2, flintlib: update to 3.0.1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (6 preceding siblings ...)
  2023-11-10 23:49 ` [PR PATCH] [Updated] [RC] sagemath: update to 10.2, flintlib: update to 3.0.1 tornaria
@ 2023-11-11 12:21 ` tornaria
  2023-11-12 19:38 ` [PR PATCH] [Updated] " tornaria
                   ` (20 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: tornaria @ 2023-11-11 12:21 UTC (permalink / raw)
  To: ml

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

New comment by tornaria on void-packages repository

https://github.com/void-linux/void-packages/pull/46832#issuecomment-1806802438

Comment:
@dkwo sagemath is on its second RC so it will be released soon. This PR will be ready to merge once the release happens. It should ideally be tested together with #46785 and #46787.

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

* Re: [PR PATCH] [Updated] [RC] sagemath: update to 10.2, flintlib: update to 3.0.1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (7 preceding siblings ...)
  2023-11-11 12:21 ` tornaria
@ 2023-11-12 19:38 ` tornaria
  2023-11-14 21:56 ` tornaria
                   ` (19 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: tornaria @ 2023-11-12 19:38 UTC (permalink / raw)
  To: ml

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

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

https://github.com/tornaria/void-packages flintlib
https://github.com/void-linux/void-packages/pull/46832

[RC] sagemath: update to 10.2, flintlib: update to 3.0.1
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **briefly**

This is a major update. A couple of packages need rebuilding (eclib, singular).

For sagemath, we need a patch (in progress: https://github.com/sagemath/sage/pull/35848).

Since backporting patches is a pain and we are not in a hurry, I'm instead targeting 10.2.beta8. Note this already moves sagemath to cython 3.

The goal is to merge flintlib 3.0 together with sagemath 10.2 when the latter is released.

<!--
#### 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/46832.patch is attached

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

From 9b96cd9e690900c428dea438cb194ba5c0e0a0ec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 11 Sep 2023 20:11:20 -0300
Subject: [PATCH 1/6] flintlib: update to 3.0.1.

---
 common/shlibs                                 |  3 +--
 srcpkgs/arb                                   |  1 +
 srcpkgs/arb-devel                             |  2 +-
 srcpkgs/arb/template                          | 24 -----------------
 .../patches/fix-test-t-sdiv_qrnnd.patch       | 23 ----------------
 srcpkgs/flintlib/template                     | 27 ++++++++++++++++---
 6 files changed, 26 insertions(+), 54 deletions(-)
 create mode 120000 srcpkgs/arb
 delete mode 100644 srcpkgs/arb/template
 delete mode 100644 srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch

diff --git a/common/shlibs b/common/shlibs
index 64643f5b3c009..3cb20c35df530 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3972,8 +3972,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.17 flintlib-2.9.0_1
-libarb.so.2 arb-2.20.0_1
+libflint.so.18 flintlib-3.0.0_1
 libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
diff --git a/srcpkgs/arb b/srcpkgs/arb
new file mode 120000
index 0000000000000..7c2633183069f
--- /dev/null
+++ b/srcpkgs/arb
@@ -0,0 +1 @@
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb-devel b/srcpkgs/arb-devel
index 456b9f00a86cd..7c2633183069f 120000
--- a/srcpkgs/arb-devel
+++ b/srcpkgs/arb-devel
@@ -1 +1 @@
-arb
\ No newline at end of file
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
deleted file mode 100644
index 84a62c7ffdba3..0000000000000
--- a/srcpkgs/arb/template
+++ /dev/null
@@ -1,24 +0,0 @@
-# Template file for 'arb'
-pkgname=arb
-version=2.23.0
-revision=1
-build_style=configure
-configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
-makedepends="flintlib-devel"
-short_desc="C library for arbitrary-precision interval arithmetic"
-maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
-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=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
-
-arb-devel_package() {
-	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"
-	short_desc+=" - development files"
-	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.a"
-		vmove "usr/lib/*.so"
-	}
-}
diff --git a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch b/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
deleted file mode 100644
index cfa109792892c..0000000000000
--- a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From fb8ddbcc06afa2a8f25637032fbb8211f6c6c122 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= <albin.ahlback@gmail.com>
-Date: Fri, 20 May 2022 14:16:38 +0200
-Subject: [PATCH] Fix bug in test code for GCC 12
-
----
- test/t-sdiv_qrnnd.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/test/t-sdiv_qrnnd.c b/test/t-sdiv_qrnnd.c
-index 2e9822e848..2676903826 100644
---- a/test/t-sdiv_qrnnd.c
-+++ b/test/t-sdiv_qrnnd.c
-@@ -33,7 +33,7 @@ int main(void)
-         {
-             d = n_randtest_not_zero(state);
-             nh = n_randtest(state);
--        } while ((FLINT_ABS(nh) >= FLINT_ABS(d)/2) || (nh == WORD_MIN));
-+        } while ((nh == WORD_MIN) || (FLINT_ABS(nh) >= FLINT_ABS(d)/2));
- 
-         nl = n_randtest(state);
- 
-
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index f7442c8052aaa..cbb73ee5f1438 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,10 +1,11 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.9.0
+version=3.0.1
 revision=1
-build_style=configure
+build_style=gnu-configure
 configure_args="--prefix=/usr $(vopt_with ntl)
- $(vopt_if openblas --with-blas=${XBPS_CROSS_BASE}/usr/include/openblas)"
+ $(vopt_if openblas --with-blas-include=${XBPS_CROSS_BASE}/usr/include/openblas)"
+hostmakedepends="automake gettext-devel libtool"
 makedepends="mpfr-devel $(vopt_if ntl ntl-devel)
  $(vopt_if openblas openblas-devel)"
 short_desc="Fast Library for Number Theory"
@@ -13,7 +14,7 @@ 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=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
+checksum=7b311a00503a863881eb8177dbeb84322f29399f3d7d72f3b1a4c9ba1d5794b4
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
@@ -28,12 +29,30 @@ esac
 
 CFLAGS="-D_GNU_SOURCE" # needed for cpu_set_t
 
+post_patch() {
+	# run autoconf because we patched configure.ac
+	autoreconf
+}
+
 flintlib-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision} mpfr-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
+		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
 		vmove "usr/lib/*.so"
 	}
 }
+
+arb_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}
+
+arb-devel_package() {
+	depends="${sourcepkg}-devel>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From 53e03795c75c6ddc0ea242d8ee7bd0694efbcb31 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:08:05 -0300
Subject: [PATCH 2/6] eclib: rebuild for flintlib-3.0.1

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

diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 1d4ad58f21b7b..12165ca788dd5 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
 version=20230424
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 makedepends="pari-devel ntl-devel flintlib-devel boost-devel"

From 16a1385d87db3d70189022b1dd6f6773f4698d34 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:13:15 -0300
Subject: [PATCH 3/6] singular: update to 4.3.2p10.

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

diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index 036e19d470354..beb0e6d30118e 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,6 +1,6 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.2p7
+version=4.3.2p10
 revision=1
 _majver=${version%p*}
 build_style=gnu-configure
@@ -20,7 +20,7 @@ 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/${_majver//./-}/singular-${version}.tar.gz"
-checksum=aad23c30066b7fbc011138a98d60532565d76a847eec6bf2938410d93b272ca3
+checksum=28c2c9fcfee954e00dfa56eb1a7d418d5b1de67c4398d25a0f2b8f73e71552a8
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From 54ff8f589200e29f42384991646c201ea64692d6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 19 Jul 2023 21:04:33 -0300
Subject: [PATCH 4/6] python3-pplpy: use cython 3.

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

diff --git a/srcpkgs/python3-pplpy/template b/srcpkgs/python3-pplpy/template
index 4a9c987b2a859..d3b9aebdf2237 100644
--- a/srcpkgs/python3-pplpy/template
+++ b/srcpkgs/python3-pplpy/template
@@ -1,9 +1,9 @@
 # Template file for 'python3-pplpy'
 pkgname=python3-pplpy
 version=0.8.9
-revision=1
+revision=2
 build_style=python3-pep517
-hostmakedepends="python3-setuptools python3-wheel python3-Cython0.29
+hostmakedepends="python3-setuptools python3-wheel python3-Cython
  python3-cysignals python3-gmpy2"
 makedepends="python3-devel gmp-devel gmpxx-devel ppl-devel mpfr-devel
  libmpc-devel pari-devel"

From d4645f8fe71976c35c339895debc6cc9f4335bde Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Thu, 19 Oct 2023 08:52:15 -0300
Subject: [PATCH 5/6] python3-networkx: update to 3.2.1.

---
 srcpkgs/python3-networkx/template | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/python3-networkx/template b/srcpkgs/python3-networkx/template
index 186bf64f7bff9..29283d9e5a032 100644
--- a/srcpkgs/python3-networkx/template
+++ b/srcpkgs/python3-networkx/template
@@ -1,11 +1,11 @@
 # Template file for 'python3-networkx'
 pkgname=python3-networkx
-version=3.1
-revision=2
-build_style=python3-module
+version=3.2.1
+revision=1
+build_style=python3-pep517
 # failing in i686
 make_check_args="--deselect networkx/algorithms/approximation/tests/test_traveling_salesman.py::test_asadpour_tsp"
-hostmakedepends="python3-setuptools"
+hostmakedepends="python3-setuptools python3-wheel"
 depends="python3"
 checkdepends="python3-numpy python3-scipy python3-matplotlib python3-pandas
  python3-lxml python3-sympy python3-pytest-xdist"
@@ -15,7 +15,7 @@ license="BSD-3-Clause"
 homepage="https://networkx.org"
 changelog="https://github.com/networkx/networkx/raw/main/doc/release/release_${version}.rst"
 distfiles="${PYPI_SITE}/n/networkx/networkx-${version}.tar.gz"
-checksum=de346335408f84de0eada6ff9fafafff9bcda11f0a0dfaa931133debb146ab61
+checksum=9f1bb5cf3409bf324e0a722c20bdb4c20ee39bf1c30ce8ae499c8502b0b5e0c6
 
 post_install() {
 	vlicense LICENSE.txt

From 3aa5b09bd1b444ef1869394ff9c7b9585eb1b988 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:50:44 -0300
Subject: [PATCH 6/6] sagemath: update to 10.2.rc2.

---
 .../sagemath/patches/35848-flintlib_3.0.patch | 1738 ++++++++++++++++
 .../patches/35934-singular_4.3.2p7.patch      |  221 ---
 .../sagemath/patches/36006-gmp_6.3.0.patch    |   38 -
 .../patches/36046-fix_memory_leak.patch       |  740 -------
 .../sagemath/patches/36235-ecl_23.9.9.patch   |   39 -
 .../patches/36279-matplotlib_3.8.0.patch      |   24 -
 srcpkgs/sagemath/patches/36403-00pre.patch    |   29 -
 .../sagemath/patches/36407-python_3.12.patch  | 1744 -----------------
 .../sagemath/patches/36551-fix_qf.nbs.patch   |  134 ++
 .../patches/36696-fix_SSL_timeout.patch       |   33 +
 srcpkgs/sagemath/patches/get_patches          |   27 +-
 srcpkgs/sagemath/template                     |   12 +-
 srcpkgs/sagemath/update                       |    3 +-
 13 files changed, 1922 insertions(+), 2860 deletions(-)
 create mode 100644 srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
 delete mode 100644 srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
 delete mode 100644 srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
 delete mode 100644 srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36403-00pre.patch
 delete mode 100644 srcpkgs/sagemath/patches/36407-python_3.12.patch
 create mode 100644 srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
 create mode 100644 srcpkgs/sagemath/patches/36696-fix_SSL_timeout.patch

diff --git a/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
new file mode 100644
index 0000000000000..c1e33e6a3c717
--- /dev/null
+++ b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
@@ -0,0 +1,1738 @@
+diff --git a/build/pkgs/antic/SPKG.rst b/build/pkgs/antic/SPKG.rst
+deleted file mode 100644
+index d6c32377957..00000000000
+--- a/build/pkgs/antic/SPKG.rst
++++ /dev/null
+@@ -1,18 +0,0 @@
+-antic: Algebraic Number Theory In C
+-===================================
+-
+-Description
+------------
+-
+-Algebraic Number Theory In C
+-
+-License
+--------
+-
+-LGPL 2.1
+-
+-Upstream Contact
+-----------------
+-
+-https://github.com/wbhart/antic
+-
+diff --git a/build/pkgs/antic/checksums.ini b/build/pkgs/antic/checksums.ini
+deleted file mode 100644
+index fc8711ecd13..00000000000
+--- a/build/pkgs/antic/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=antic-VERSION.tar.gz
+-sha1=940d8ea2c3512b9d49ee3101cf043f777764bd8f
+-md5=4e896420dd6344b53b307871efb2cbb4
+-cksum=1938565125
+-upstream_url=https://github.com/wbhart/antic/archive/refs/tags/vVERSION.tar.gz
+diff --git a/build/pkgs/antic/dependencies b/build/pkgs/antic/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/antic/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/antic/distros/arch.txt b/build/pkgs/antic/distros/arch.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/conda.txt b/build/pkgs/antic/distros/conda.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/debian.txt b/build/pkgs/antic/distros/debian.txt
+deleted file mode 100644
+index 8fdcd3e5721..00000000000
+--- a/build/pkgs/antic/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libantic-dev
+diff --git a/build/pkgs/antic/distros/fedora.txt b/build/pkgs/antic/distros/fedora.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/freebsd.txt b/build/pkgs/antic/distros/freebsd.txt
+deleted file mode 100644
+index 116ff3a26f3..00000000000
+--- a/build/pkgs/antic/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/antic
+diff --git a/build/pkgs/antic/distros/opensuse.txt b/build/pkgs/antic/distros/opensuse.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/repology.txt b/build/pkgs/antic/distros/repology.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/package-version.txt b/build/pkgs/antic/package-version.txt
+deleted file mode 100644
+index 3a4036fb450..00000000000
+--- a/build/pkgs/antic/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-0.2.5
+diff --git a/build/pkgs/antic/spkg-install.in b/build/pkgs/antic/spkg-install.in
+deleted file mode 100644
+index c57fa884a20..00000000000
+--- a/build/pkgs/antic/spkg-install.in
++++ /dev/null
+@@ -1,19 +0,0 @@
+-cd src
+-
+-# Copied from build/pkgs/flint/spkg-install.in:
+-#   Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-#   --with-ntl because otherwise FLINT's configure script uses
+-#   /usr/local, which is always wrong.
+-#   This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-#   The value $SAGE_LOCAL is always a safe choice even if the library
+-#   is coming from the system and is found using what is in
+-#   LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-flint="$SAGE_LOCAL"  || sdh_die "Error: Failed to configure antic."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/antic/type b/build/pkgs/antic/type
+deleted file mode 100644
+index 134d9bc32d5..00000000000
+--- a/build/pkgs/antic/type
++++ /dev/null
+@@ -1 +0,0 @@
+-optional
+diff --git a/build/pkgs/arb/SPKG.rst b/build/pkgs/arb/SPKG.rst
+deleted file mode 100644
+index cff49ddb95b..00000000000
+--- a/build/pkgs/arb/SPKG.rst
++++ /dev/null
+@@ -1,27 +0,0 @@
+-arb: Arbitrary-precision floating-point ball arithmetic
+-=======================================================
+-
+-Description
+------------
+-
+-Arb is a C library for arbitrary-precision floating-point ball
+-arithmetic, developed by Fredrik Johansson
+-(fredrik.johansson@gmail.com). It supports efficient high-precision
+-computation with polynomials, power series, matrices and special
+-functions over the real and complex numbers, with automatic, rigorous
+-error control.
+-
+-License
+--------
+-
+-GNU General Public License v2+
+-
+-
+-Upstream Contact
+-----------------
+-
+- - Fredrik Johansson: fredrik.johansson@gmail.com
+-
+- - https://arblib.org/
+-
+- - http://github.com/fredrik-johansson/arb/
+diff --git a/build/pkgs/arb/checksums.ini b/build/pkgs/arb/checksums.ini
+deleted file mode 100644
+index 80ef43dad5d..00000000000
+--- a/build/pkgs/arb/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=arb-VERSION.tar.gz
+-sha1=a1efe035dd3af3613dd685971a156f652b86ff63
+-md5=9b369e29f93cdf2d4f90b57a92526cce
+-cksum=64252121
+-upstream_url=https://github.com/fredrik-johansson/arb/archive/VERSION.tar.gz
+diff --git a/build/pkgs/arb/dependencies b/build/pkgs/arb/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/arb/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/arb/distros/arch.txt b/build/pkgs/arb/distros/arch.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/conda.txt b/build/pkgs/arb/distros/conda.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/debian.txt b/build/pkgs/arb/distros/debian.txt
+deleted file mode 100644
+index 9fe71110712..00000000000
+--- a/build/pkgs/arb/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libflint-arb-dev
+diff --git a/build/pkgs/arb/distros/fedora.txt b/build/pkgs/arb/distros/fedora.txt
+deleted file mode 100644
+index 76794404627..00000000000
+--- a/build/pkgs/arb/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb arb-devel
+diff --git a/build/pkgs/arb/distros/freebsd.txt b/build/pkgs/arb/distros/freebsd.txt
+deleted file mode 100644
+index 2ef8c7cec0f..00000000000
+--- a/build/pkgs/arb/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/arb
+diff --git a/build/pkgs/arb/distros/gentoo.txt b/build/pkgs/arb/distros/gentoo.txt
+deleted file mode 100644
+index 58e3d4f8008..00000000000
+--- a/build/pkgs/arb/distros/gentoo.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-sci-mathematics/arb
+diff --git a/build/pkgs/arb/distros/homebrew.txt b/build/pkgs/arb/distros/homebrew.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/homebrew.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/nix.txt b/build/pkgs/arb/distros/nix.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/nix.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/opensuse.txt b/build/pkgs/arb/distros/opensuse.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/distros/repology.txt b/build/pkgs/arb/distros/repology.txt
+deleted file mode 100644
+index 179c9d507e1..00000000000
+--- a/build/pkgs/arb/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-fp
+diff --git a/build/pkgs/arb/distros/void.txt b/build/pkgs/arb/distros/void.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/void.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/package-version.txt b/build/pkgs/arb/package-version.txt
+deleted file mode 100644
+index e9763f6bfed..00000000000
+--- a/build/pkgs/arb/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-2.23.0
+diff --git a/build/pkgs/arb/spkg-check.in b/build/pkgs/arb/spkg-check.in
+deleted file mode 100644
+index 27cd9419538..00000000000
+--- a/build/pkgs/arb/spkg-check.in
++++ /dev/null
+@@ -1,2 +0,0 @@
+-cd src
+-$MAKE check
+diff --git a/build/pkgs/arb/spkg-configure.m4 b/build/pkgs/arb/spkg-configure.m4
+deleted file mode 100644
+index ef2dd0aac4a..00000000000
+--- a/build/pkgs/arb/spkg-configure.m4
++++ /dev/null
+@@ -1,23 +0,0 @@
+-SAGE_SPKG_CONFIGURE([arb], [
+-    AC_REQUIRE([SAGE_SPKG_CONFIGURE_FLINT])
+-    SAGE_ARB_LIBRARY="arb"
+-    AC_MSG_CHECKING([installing flint? ])
+-    if test x$sage_spkg_install_flint = xyes; then
+-        AC_MSG_RESULT([yes; install arb as well])
+-        sage_spkg_install_arb=yes
+-    else
+-        AC_CHECK_HEADER(arb.h, [
+-        dnl below function added in version 2.16 of arb
+-            AC_CHECK_LIB([arb], [acb_mat_eig_simple], [],
+-              [dnl in Debian the name of dylib is different.
+-               AC_CHECK_LIB([flint-arb], [acb_mat_eig_simple],
+-                [SAGE_ARB_LIBRARY="flint-arb"], [sage_spkg_install_arb=yes])])
+-        ], [sage_spkg_install_arb=yes])
+-    fi
+-], [], [], [
+-    if test x$sage_spkg_install_arb = xyes; then
+-        AC_SUBST(SAGE_ARB_LIBRARY,["arb"])
+-    else
+-        AC_SUBST(SAGE_ARB_LIBRARY,[$SAGE_ARB_LIBRARY])
+-    fi
+-])
+diff --git a/build/pkgs/arb/spkg-install.in b/build/pkgs/arb/spkg-install.in
+deleted file mode 100644
+index 9322f04c912..00000000000
+--- a/build/pkgs/arb/spkg-install.in
++++ /dev/null
+@@ -1,17 +0,0 @@
+-cd src
+-
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-flint because otherwise ARB's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure --disable-static --prefix="$SAGE_LOCAL" \
+-        --with-gmp="$SAGE_LOCAL" \
+-        --with-mpfr="$SAGE_LOCAL" \
+-        --with-flint="$SAGE_LOCAL" || \
+-    sdh_die "Error configuring arb."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/arb/type b/build/pkgs/arb/type
+deleted file mode 100644
+index a6a7b9cd726..00000000000
+--- a/build/pkgs/arb/type
++++ /dev/null
+@@ -1 +0,0 @@
+-standard
+diff --git a/build/pkgs/e_antic/dependencies b/build/pkgs/e_antic/dependencies
+index fea1ffbda45..8e977a55c13 100644
+--- a/build/pkgs/e_antic/dependencies
++++ b/build/pkgs/e_antic/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) flint arb antic boost_cropped
++$(MP_LIBRARY) flint boost_cropped
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/SPKG.rst b/build/pkgs/flint/SPKG.rst
+index f91de70d1ff..d9dcea0903b 100644
+--- a/build/pkgs/flint/SPKG.rst
++++ b/build/pkgs/flint/SPKG.rst
+@@ -4,8 +4,8 @@ flint: Fast Library for Number Theory
+ Description
+ -----------
+ 
+-FLINT is a C library for doing number theory, maintained by William
+-Hart.
++FLINT is a C library for doing number theory, maintained by
++Fredrik Johansson.
+ 
+ Website: http://www.flintlib.org
+ 
+@@ -20,4 +20,4 @@ Upstream Contact
+ 
+ -  flint-devel Gougle Group
+    (http://groups.google.co.uk/group/flint-devel)
+--  William Hart
++-  Fredrik Johansson
+diff --git a/build/pkgs/flint/checksums.ini b/build/pkgs/flint/checksums.ini
+index 3d449d98064..2cec823bfb1 100644
+--- a/build/pkgs/flint/checksums.ini
++++ b/build/pkgs/flint/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=flint-VERSION.tar.gz
+-sha1=63d90f8242c8f8ab4011fbcfb44b86c154f43abd
+-md5=c2d3cec326438f159a530c66eb07fafe
+-cksum=4244948341
+-upstream_url=http://flintlib.org/flint-VERSION.tar.gz
++sha1=c548b1d5eb86a1805de9bef56629455b61e873f7
++md5=24551d4e475290ce6b831c78fafb5efb
++cksum=1567352998
++upstream_url=https://github.com/flintlib/flint/releases/download/vVERSION/flint-VERSION.tar.gz
+diff --git a/build/pkgs/flint/dependencies b/build/pkgs/flint/dependencies
+index 385df4faa7d..1108dc4fb21 100644
+--- a/build/pkgs/flint/dependencies
++++ b/build/pkgs/flint/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) mpfr ntl
++$(MP_LIBRARY) mpfr
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/package-version.txt b/build/pkgs/flint/package-version.txt
+index c8e38b61405..4a36342fcab 100644
+--- a/build/pkgs/flint/package-version.txt
++++ b/build/pkgs/flint/package-version.txt
+@@ -1 +1 @@
+-2.9.0
++3.0.0
+diff --git a/build/pkgs/flint/spkg-build.in b/build/pkgs/flint/spkg-build.in
+new file mode 100644
+index 00000000000..ffb822c8a97
+--- /dev/null
++++ b/build/pkgs/flint/spkg-build.in
+@@ -0,0 +1,3 @@
++cd src
++sdh_configure
++sdh_make
+diff --git a/build/pkgs/flint/spkg-configure.m4 b/build/pkgs/flint/spkg-configure.m4
+index a58108c9d6e..9576e4cc1e9 100644
+--- a/build/pkgs/flint/spkg-configure.m4
++++ b/build/pkgs/flint/spkg-configure.m4
+@@ -1,25 +1,8 @@
+ SAGE_SPKG_CONFIGURE([flint], [
+-    SAGE_SPKG_DEPCHECK([mpfr ntl], [
++    SAGE_SPKG_DEPCHECK([mpfr], [
+         AC_CHECK_HEADER(flint/flint.h, [
+-          dnl flint_parallel_binary_splitting appears in Flint 2.9.0, needed by arb 2.23
+-          AC_SEARCH_LIBS([flint_parallel_binary_splitting], [flint], [
+-            dnl check that NTL is linked in
+-            AC_SEARCH_LIBS([fmpz_poly_get_ZZX], [flint], [
+-
+-              AC_MSG_CHECKING([that GC is not enabled in Flint... ])
+-              AC_RUN_IFELSE([
+-                 AC_LANG_PROGRAM([[#include <flint/flint.h>]], [
+-                                  [#ifdef HAVE_GC]
+-                                     [return HAVE_GC;]
+-                                  [#else]
+-                                     [return 0;]
+-                                  [#endif]])],
+-                 [AC_MSG_RESULT([GC not enabled. Good.])],
+-                        [AC_MSG_RESULT([GC enabled. Incompatible with Sage.])
+-                         sage_spkg_install_flint=yes],
+-                 [AC_MSG_RESULT(["cross compiling. assuming GC is not enabled"])])
+-            ], [sage_spkg_install_flint=yes])
+-          ], [sage_spkg_install_flint=yes])
++          dnl gr_get_fexpr appears in Flint 3.0
++          AC_SEARCH_LIBS([gr_get_fexpr], [flint], [], [sage_spkg_install_flint=yes])
+         ], [sage_spkg_install_flint=yes])
+     ])
+ ], [], [], [
+diff --git a/build/pkgs/flint/spkg-install.in b/build/pkgs/flint/spkg-install.in
+index eacd7b6e491..3ea8c053669 100644
+--- a/build/pkgs/flint/spkg-install.in
++++ b/build/pkgs/flint/spkg-install.in
+@@ -1,36 +1,2 @@
+-###############################################################################
+-#
+-# FLINT Sage install script
+-#
+-###############################################################################
+-if [ "$SAGE_DEBUG" = "yes" ]; then
+-    echo "Building a debug version of FLINT."
+-    FLINT_TUNE=" $FLINT_TUNE"; export FLINT_TUNE
+-    FLINT_CONFIGURE="--enable-assert $FLINT_CONFIGURE"
+-fi
+-
+ cd src
+-
+-echo "Configuring FLINT."
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-ntl because otherwise FLINT's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-ntl="$SAGE_LOCAL" \
+-    $FLINT_CONFIGURE || sdh_die "Error: Failed to configure FLINT."
+-
+-sdh_make verbose
+-
+-echo "Deleting old FLINT files."
+-rm -f $SAGE_LOCAL/lib/libflint*
+-rm -rf $SAGE_LOCAL/include/flint
+-
+ sdh_make_install
+diff --git a/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+new file mode 100644
+index 00000000000..27a642a13b0
+--- /dev/null
++++ b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+@@ -0,0 +1,53 @@
++From fe730579476de0b2d4181a38efa7f63dff9c81d7 Mon Sep 17 00:00:00 2001
++From: Marc Mezzarobba <marc@mezzarobba.net>
++Date: Tue, 12 Sep 2023 08:23:08 +0200
++Subject: [PATCH] Make msolve build with flint3
++
++---
++ src/fglm/berlekamp_massey.c | 3 +++
++ src/fglm/data_fglm.c        | 7 +++++--
++ 2 files changed, 8 insertions(+), 2 deletions(-)
++
++diff --git a/src/fglm/berlekamp_massey.c b/src/fglm/berlekamp_massey.c
++index b0f2052..998af1c 100644
++--- a/src/fglm/berlekamp_massey.c
+++++ b/src/fglm/berlekamp_massey.c
++@@ -30,6 +30,9 @@
++ */
++ 
++ #include <stdlib.h>
+++#if __FLINT_VERSION >= 3
+++#  include <flint/nmod.h>
+++#endif
++ //#include "nmod_poly.h"
++ //#include "mpn_extras.h"
++ 
++diff --git a/src/fglm/data_fglm.c b/src/fglm/data_fglm.c
++index 0726760..0e1da6f 100644
++--- a/src/fglm/data_fglm.c
+++++ b/src/fglm/data_fglm.c
++@@ -24,6 +24,7 @@
++ #include <flint/mpn_extras.h>
++ #include <flint/nmod_poly.h>
++ #include <flint/nmod_poly_factor.h>
+++#include <flint/ulong_extras.h>
++ 
++ 
++ typedef uint32_t szmat_t;
++@@ -299,9 +300,11 @@ static inline void nmod_poly_set_prime(nmod_poly_t poly,
++   mp_limb_t ninv = n_preinvert_limb(prime);
++   poly->mod.n = prime;
++   poly->mod.ninv = ninv;
+++#if __FLINT_VERSION < 3
++   count_leading_zeros(poly->mod.norm, prime);
++-  /* poly->mod.norm = flint_clz(prime); */
++-
+++#else
+++  poly->mod.norm = flint_clz(prime);
+++#endif
++ }
++ 
++ static inline void fglm_param_set_prime(param_t *param, mp_limb_t prime){
++-- 
++2.40.1
++
+diff --git a/build/pkgs/sagelib/dependencies b/build/pkgs/sagelib/dependencies
+index 5dc2efe1d31..fa6e98df7db 100644
+--- a/build/pkgs/sagelib/dependencies
++++ b/build/pkgs/sagelib/dependencies
+@@ -1,4 +1,4 @@
+-FORCE $(SCRIPTS) arb boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
++FORCE $(SCRIPTS) boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/symengine/dependencies b/build/pkgs/symengine/dependencies
+index 1fc34963eda..7795d486018 100644
+--- a/build/pkgs/symengine/dependencies
++++ b/build/pkgs/symengine/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) arb ecm flint mpc mpfr | cmake
++$(MP_LIBRARY) ecm flint mpc mpfr | cmake
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/pkgs/sage-conf/_sage_conf/_conf.py.in b/pkgs/sage-conf/_sage_conf/_conf.py.in
+index 87b27ca05cb..895d6572d1e 100644
+--- a/pkgs/sage-conf/_sage_conf/_conf.py.in
++++ b/pkgs/sage-conf/_sage_conf/_conf.py.in
+@@ -19,8 +19,6 @@ MAXIMA_FAS = "@SAGE_MAXIMA_FAS@".replace('${prefix}', SAGE_LOCAL)
+ # Delete this line if your ECL can load Kenzo without further prodding.
+ KENZO_FAS = "@SAGE_KENZO_FAS@".replace('${prefix}', SAGE_LOCAL)
+ 
+-ARB_LIBRARY = "@SAGE_ARB_LIBRARY@"
+-
+ NTL_INCDIR = "@NTL_INCDIR@"
+ NTL_LIBDIR = "@NTL_LIBDIR@"
+ 
+diff --git a/src/sage/env.py b/src/sage/env.py
+index b1fe9a89cd1..9197fc3a703 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -223,7 +223,6 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st
+ FOURTITWO_PPI = var("FOURTITWO_PPI")
+ FOURTITWO_CIRCUITS = var("FOURTITWO_CIRCUITS")
+ FOURTITWO_GROEBNER = var("FOURTITWO_GROEBNER")
+-ARB_LIBRARY = var("ARB_LIBRARY", "arb")
+ CBLAS_PC_MODULES = var("CBLAS_PC_MODULES", "cblas:openblas:blas")
+ ECL_CONFIG = var("ECL_CONFIG", "ecl-config")
+ NTL_INCDIR = var("NTL_INCDIR")
+@@ -356,8 +355,7 @@ def cython_aliases(required_modules=None,
+         sage: cython_aliases()
+         {...}
+         sage: sorted(cython_aliases().keys())
+-        ['ARB_LIBRARY',
+-         'CBLAS_CFLAGS',
++        ['CBLAS_CFLAGS',
+          ...,
+          'ZLIB_LIBRARIES']
+         sage: cython_aliases(required_modules=('module-that-is-assumed-to-not-exist'))
+@@ -475,8 +473,6 @@ def uname_specific(name, value, alternative):
+     if "LINBOX_CFLAGS" in aliases:
+         aliases["LINBOX_CFLAGS"].append("-std=gnu++11")
+ 
+-    aliases["ARB_LIBRARY"] = ARB_LIBRARY
+-
+     # TODO: Remove Cygwin hack by installing a suitable cblas.pc
+     if os.path.exists('/usr/lib/libblas.dll.a'):
+         aliases["CBLAS_LIBS"] = ['gslcblas']
+diff --git a/src/sage/features/sagemath.py b/src/sage/features/sagemath.py
+index 7404e6d0a8e..6037d097391 100644
+--- a/src/sage/features/sagemath.py
++++ b/src/sage/features/sagemath.py
+@@ -761,7 +761,7 @@ class sage__rings__number_field(JoinFeature):
+     A :class:`~sage.features.Feature` describing the presence of :mod:`sage.rings.number_field`.
+ 
+     Number fields are implemented in Sage using a complicated mixture of various libraries,
+-    including :ref:`arb <spkg_arb>`, :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
++    including :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
+     :ref:`MPFI <spkg_mpfi>`, :ref:`NTL <spkg_ntl>`, and :ref:`PARI <spkg_pari>`.
+ 
+     EXAMPLES:
+diff --git a/src/sage/libs/arb/acb.pxd b/src/sage/libs/arb/acb.pxd
+index 5148dc43991..851488d803a 100644
+--- a/src/sage/libs/arb/acb.pxd
++++ b/src/sage/libs/arb/acb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -152,10 +152,6 @@ cdef extern from "arb_wrap.h":
+     void acb_sech(acb_t s, const acb_t z, long prec)
+     void acb_csch(acb_t c, const acb_t z, long prec)
+ 
+-    void acb_rising_ui_bs(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui_rs(acb_t z, const acb_t x, unsigned long n, unsigned long step, long prec)
+-    void acb_rising_ui_rec(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui(acb_t z, const acb_t x, unsigned long n, long prec)
+     void acb_rising(acb_t z, const acb_t x, const acb_t n, long prec)
+ 
+     void acb_gamma(acb_t y, const acb_t x, long prec)
+diff --git a/src/sage/libs/arb/acb_calc.pxd b/src/sage/libs/arb/acb_calc.pxd
+index a5dbf360b5e..67bd2ed57dc 100644
+--- a/src/sage/libs/arb/acb_calc.pxd
++++ b/src/sage/libs/arb/acb_calc.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_calc.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_elliptic.pxd b/src/sage/libs/arb/acb_elliptic.pxd
+index 176f68df00e..e3480e9f73b 100644
+--- a/src/sage/libs/arb/acb_elliptic.pxd
++++ b/src/sage/libs/arb/acb_elliptic.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_elliptic.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_hypgeom.pxd b/src/sage/libs/arb/acb_hypgeom.pxd
+index 418e766f10d..c43e5c0623b 100644
+--- a/src/sage/libs/arb/acb_hypgeom.pxd
++++ b/src/sage/libs/arb/acb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_hypgeom.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_modular.pxd b/src/sage/libs/arb/acb_modular.pxd
+index c708e9bf97d..cdc413c92da 100644
+--- a/src/sage/libs/arb/acb_modular.pxd
++++ b/src/sage/libs/arb/acb_modular.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_modular.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_poly.pxd b/src/sage/libs/arb/acb_poly.pxd
+index 69f4320055b..ae02757ffd9 100644
+--- a/src/sage/libs/arb/acb_poly.pxd
++++ b/src/sage/libs/arb/acb_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -79,24 +79,10 @@ cdef extern from "arb_wrap.h":
+     void _acb_poly_divrem(acb_ptr Q, acb_ptr R, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec)
+     bint acb_poly_divrem(acb_poly_t Q, acb_poly_t R, const acb_poly_t A, const acb_poly_t B, long prec)
+     void _acb_poly_div_root(acb_ptr Q, acb_t R, acb_srcptr A, long len, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_horner(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_horner(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_divconquer(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_divconquer(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_convolution(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_convolution(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+     void _acb_poly_taylor_shift(acb_ptr g, const acb_t c, long n, long prec)
+     void acb_poly_taylor_shift(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_compose_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_divconquer(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_divconquer(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+     void _acb_poly_compose(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+     void acb_poly_compose(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_series_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+-    void _acb_poly_compose_series_brent_kung(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_brent_kung(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_compose_series(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+     void acb_poly_compose_series(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_revert_series_lagrange(acb_ptr h, acb_srcptr f, long flen, long n, long prec)
+@@ -161,10 +147,6 @@ cdef extern from "arb_wrap.h":
+     void acb_poly_exp_series_basecase(acb_poly_t f, const acb_poly_t h, long n, long prec)
+     void _acb_poly_exp_series(acb_ptr f, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_exp_series(acb_poly_t f, const acb_poly_t h, long n, long prec)
+-    void _acb_poly_sin_cos_series_basecase(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_basecase(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+-    void _acb_poly_sin_cos_series_tangent(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_tangent(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+     void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_sin_cos_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec)
+     void _acb_poly_sin_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec)
+diff --git a/src/sage/libs/arb/arb.pxd b/src/sage/libs/arb/arb.pxd
+index c82b94de30f..acd232ab816 100644
+--- a/src/sage/libs/arb/arb.pxd
++++ b/src/sage/libs/arb/arb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -224,15 +224,8 @@ cdef extern from "arb_wrap.h":
+ 
+     void arb_lambertw(arb_t res, const arb_t x, int flags, long prec)
+ 
+-    void arb_rising_ui_bs(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui_rs(arb_t z, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising_ui_rec(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui(arb_t z, const arb_t x, unsigned long n, long prec)
+     void arb_rising(arb_t z, const arb_t x, const arb_t n, long prec)
+     void arb_rising_fmpq_ui(arb_t z, const fmpq_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_bs(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_rs(arb_t u, arb_t v, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising2_ui(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+     void arb_fac_ui(arb_t z, unsigned long n, long prec)
+     void arb_bin_ui(arb_t z, const arb_t n, unsigned long k, long prec)
+     void arb_bin_uiui(arb_t z, unsigned long n, unsigned long k, long prec)
+diff --git a/src/sage/libs/arb/arb_fmpz_poly.pxd b/src/sage/libs/arb/arb_fmpz_poly.pxd
+index 079f76e9d9e..55daa705238 100644
+--- a/src/sage/libs/arb/arb_fmpz_poly.pxd
++++ b/src/sage/libs/arb/arb_fmpz_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_fmpz_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -22,5 +22,4 @@ cdef extern from "arb_wrap.h":
+     unsigned long arb_fmpz_poly_deflation(const fmpz_poly_t poly)
+     void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long deflation)
+     void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, long prec)
+-    void arb_fmpz_poly_cos_minpoly(fmpz_poly_t res, unsigned long n)
+     void arb_fmpz_poly_gauss_period_minpoly(fmpz_poly_t res, unsigned long q, unsigned long n)
+diff --git a/src/sage/libs/arb/arb_hypgeom.pxd b/src/sage/libs/arb/arb_hypgeom.pxd
+index fb1c40ddaa8..139b987d669 100644
+--- a/src/sage/libs/arb/arb_hypgeom.pxd
++++ b/src/sage/libs/arb/arb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_hypgeom.h
+ 
+ from sage.libs.flint.types cimport fmpz_t
+diff --git a/src/sage/libs/arb/arb_wrap.h b/src/sage/libs/arb/arb_wrap.h
+index 49997075ee5..488bb376d5e 100644
+--- a/src/sage/libs/arb/arb_wrap.h
++++ b/src/sage/libs/arb/arb_wrap.h
+@@ -5,25 +5,27 @@
+  * by arb, most of which rely on flint's ulong and slong defines.
+  */
+ 
++#include <mpfr.h>
++
+ #undef ulong
+ #undef slong
+ 
+ #define ulong mp_limb_t
+ #define slong mp_limb_signed_t
+ 
+-#include <acb.h>
+-#include <acb_calc.h>
+-#include <acb_elliptic.h>
+-#include <acb_hypgeom.h>
+-#include <acb_mat.h>
+-#include <acb_modular.h>
+-#include <acb_poly.h>
+-#include <arb.h>
+-#include <arb_fmpz_poly.h>
+-#include <arb_hypgeom.h>
+-#include <arf.h>
+-#include <bernoulli.h>
+-#include <mag.h>
++#include <flint/acb.h>
++#include <flint/acb_calc.h>
++#include <flint/acb_elliptic.h>
++#include <flint/acb_hypgeom.h>
++#include <flint/acb_mat.h>
++#include <flint/acb_modular.h>
++#include <flint/acb_poly.h>
++#include <flint/arb.h>
++#include <flint/arb_fmpz_poly.h>
++#include <flint/arb_hypgeom.h>
++#include <flint/arf.h>
++#include <flint/bernoulli.h>
++#include <flint/mag.h>
+ 
+ #undef ulong
+ #undef slong
+diff --git a/src/sage/libs/arb/arf.pxd b/src/sage/libs/arb/arf.pxd
+index b8b83fefcdc..84778fe9f09 100644
+--- a/src/sage/libs/arb/arf.pxd
++++ b/src/sage/libs/arb/arf.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arf.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -30,7 +30,6 @@ cdef extern from "arb_wrap.h":
+     void arf_set_ui(arf_t y, unsigned long x)
+     void arf_set_si(arf_t y, long x)
+     void arf_set_mpfr(arf_t y, const mpfr_t x)
+-    # void arf_set_fmpr(arf_t y, const fmpr_t x)
+     void arf_set_d(arf_t y, double x)
+     void arf_swap(arf_t y, arf_t x)
+     void arf_init_set_ui(arf_t y, unsigned long x)
+@@ -46,7 +45,6 @@ cdef extern from "arb_wrap.h":
+     int arf_set_round_fmpz_2exp(arf_t y, const fmpz_t x, const fmpz_t e, long prec, arf_rnd_t rnd)
+     void arf_get_fmpz_2exp(fmpz_t m, fmpz_t e, const arf_t x)
+     double arf_get_d(const arf_t x, arf_rnd_t rnd)
+-    # void arf_get_fmpr(fmpr_t y, const arf_t x)
+     int arf_get_mpfr(mpfr_t y, const arf_t x, mpfr_rnd_t rnd)
+     void arf_get_fmpz(fmpz_t z, const arf_t x, arf_rnd_t rnd)
+     long arf_get_si(const arf_t x, arf_rnd_t rnd)
+diff --git a/src/sage/libs/arb/bernoulli.pxd b/src/sage/libs/arb/bernoulli.pxd
+index 375b2b9bbcf..ea9340f4b15 100644
+--- a/src/sage/libs/arb/bernoulli.pxd
++++ b/src/sage/libs/arb/bernoulli.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = bernoulli.h
+ 
+ from ..flint.types cimport fmpq_t, ulong
+diff --git a/src/sage/libs/arb/mag.pxd b/src/sage/libs/arb/mag.pxd
+index d5d8693ea8f..69dfb990ae0 100644
+--- a/src/sage/libs/arb/mag.pxd
++++ b/src/sage/libs/arb/mag.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = mag.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -27,13 +27,11 @@ cdef extern from "arb_wrap.h":
+     # void mag_randtest(mag_t x, flint_rand_t state, long expbits)
+     # void mag_randtest_special(mag_t x, flint_rand_t state, long expbits)
+     void mag_set_d(mag_t y, double x)
+-    # void mag_set_fmpr(mag_t y, const fmpr_t x)
+     void mag_set_ui(mag_t y, unsigned long x)
+     void mag_set_fmpz(mag_t y, const fmpz_t x)
+     void mag_set_d_2exp_fmpz(mag_t z, double x, const fmpz_t y)
+     void mag_set_fmpz_2exp_fmpz(mag_t z, const fmpz_t x, const fmpz_t y)
+     void mag_set_ui_2exp_si(mag_t z, unsigned long x, long y)
+-    # void mag_get_fmpr(fmpr_t y, const mag_t x)
+     void mag_get_fmpq(fmpq_t y, const mag_t x)
+     void mag_set_ui_lower(mag_t z, unsigned long x)
+     void mag_set_fmpz_lower(mag_t z, const fmpz_t x)
+diff --git a/src/sage/libs/flint/flint_wrap.h b/src/sage/libs/flint/flint_wrap.h
+index 266535c3835..4db72b97660 100644
+--- a/src/sage/libs/flint/flint_wrap.h
++++ b/src/sage/libs/flint/flint_wrap.h
+@@ -15,6 +15,7 @@
+  */
+ 
+ #include <gmp.h>
++#include <mpfr.h>
+ 
+ /* Save previous definition of ulong if any, as pari also uses it */
+ /* Should work on GCC, clang, MSVC */
+@@ -33,6 +34,7 @@
+ 
+ #include <flint/arith.h>
+ #include <flint/fmpq.h>
++#include <flint/fmpq_vec.h>
+ #include <flint/fmpq_mat.h>
+ #include <flint/fmpq_poly.h>
+ #include <flint/fmpz.h>
+@@ -47,6 +49,7 @@
+ #include <flint/fq.h>
+ #include <flint/fq_nmod.h>
+ #include <flint/nmod_poly.h>
++#include <flint/nmod_poly_factor.h>
+ #include <flint/nmod_vec.h>
+ #include <flint/padic.h>
+ #include <flint/padic_poly.h>
+diff --git a/src/sage/libs/flint/fmpq.pxd b/src/sage/libs/flint/fmpq.pxd
+index 5e64c82102f..0616c0a7408 100644
+--- a/src/sage/libs/flint/fmpq.pxd
++++ b/src/sage/libs/flint/fmpq.pxd
+@@ -12,6 +12,8 @@ cdef extern from "flint_wrap.h":
+     fmpz * fmpq_denref(fmpq_t)
+     void fmpq_init(fmpq_t)
+     void fmpq_clear(fmpq_t)
++    void fmpq_init_set_readonly(fmpq_t, const mpq_t)
++    void fmpq_clear_readonly(fmpq_t)
+     void fmpq_one(fmpq_t)
+     void fmpq_zero(fmpq_t)
+     bint fmpq_is_zero(fmpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pxd b/src/sage/libs/flint/fmpq_poly.pxd
+index 6050c487835..afa16e5bbdd 100644
+--- a/src/sage/libs/flint/fmpq_poly.pxd
++++ b/src/sage/libs/flint/fmpq_poly.pxd
+@@ -30,6 +30,9 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_canonicalise(fmpq_poly_t)
+     int fmpq_poly_is_canonical(const fmpq_poly_t)
+ 
++    void _fmpq_poly_set_length(fmpq_poly_t, slong)
++    void _fmpq_poly_normalise(fmpq_poly_t)
++
+     # Polynomial parameters
+     slong fmpq_poly_degree(const fmpq_poly_t)
+     ulong fmpq_poly_length(const fmpq_poly_t)
+@@ -46,10 +49,7 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_ui(fmpq_poly_t, ulong)
+     void fmpq_poly_set_fmpz(fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_set_fmpq(fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+     void fmpq_poly_set_fmpz_poly(fmpq_poly_t, const fmpz_poly_t)
+-    void fmpq_poly_set_array_mpq(fmpq_poly_t, const mpq_t *, slong)
+ 
+     void fmpq_poly_set_str(fmpq_poly_t, const char *)
+     char *fmpq_poly_get_str(const fmpq_poly_t)
+@@ -67,7 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_reverse(fmpq_poly_t, const fmpq_poly_t, slong)
+ 
+     void fmpq_poly_get_coeff_fmpq(fmpq_t, const fmpq_poly_t, slong)
+-    void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_si(slong, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_ui(ulong, const fmpq_poly_t, slong)
+ 
+@@ -75,8 +74,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_coeff_ui(fmpq_poly_t, slong, ulong)
+     void fmpq_poly_set_coeff_fmpz(fmpq_poly_t, slong, const fmpz_t)
+     void fmpq_poly_set_coeff_fmpq(fmpq_poly_t, slong, const fmpq_t)
+-    void fmpq_poly_set_coeff_mpz(fmpq_poly_t, slong, const mpz_t)
+-    void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
+ 
+     # Comparison
+     int fmpq_poly_equal(const fmpq_poly_t, const fmpq_poly_t)
+@@ -100,8 +97,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_mul_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     void fmpq_poly_scalar_div_si(fmpq_poly_t, const fmpq_poly_t, slong)
+     void fmpq_poly_scalar_div_ui(fmpq_poly_t, const fmpq_poly_t, ulong)
+@@ -109,8 +104,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_div_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_div_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_div_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Multiplication
+     void fmpq_poly_mul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -155,8 +148,6 @@ cdef extern from "flint_wrap.h":
+     # Evaluation
+     void fmpq_poly_evaluate_fmpz(fmpq_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_evaluate_fmpq(fmpq_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_evaluate_mpz(mpq_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_evaluate_mpq(mpq_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Composition
+     void fmpq_poly_compose(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -189,3 +180,11 @@ cdef extern from "flint_wrap.h":
+ # since the fmpq_poly header seems to be lacking this inline function
+ cdef inline sage_fmpq_poly_max_limbs(const fmpq_poly_t poly) noexcept:
+     return _fmpz_vec_max_limbs(fmpq_poly_numref(poly), fmpq_poly_length(poly))
++
++# functions removed from flint but still needed in sage
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
++cdef void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
++cdef void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pyx b/src/sage/libs/flint/fmpq_poly.pyx
+new file mode 100644
+index 00000000000..3b8a0cf0c51
+--- /dev/null
++++ b/src/sage/libs/flint/fmpq_poly.pyx
+@@ -0,0 +1,45 @@
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++from sage.libs.gmp.mpq cimport *
++from sage.libs.flint.fmpz cimport *
++from sage.libs.flint.fmpq cimport *
++
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t rop, const fmpq_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t rop, const fmpq_poly_t op, const mpq_t c):
++    cdef fmpq_t f
++    fmpq_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpq(rop, op, f)
++    fmpq_clear_readonly(f)
++
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t poly, slong n, const mpq_t x):
++    cdef fmpq_t t
++    fmpq_init_set_readonly(t, x)
++    fmpq_poly_set_coeff_fmpq(poly, n, t)
++    fmpq_clear_readonly(t)
++
++cdef void fmpq_poly_get_coeff_mpq(mpq_t x, const fmpq_poly_t poly, slong n):
++    cdef fmpq_t t
++    fmpq_init(t)
++    fmpq_poly_get_coeff_fmpq(t, poly, n)
++    fmpq_get_mpq(x, t)
++    fmpq_clear(t)
++
++cdef void fmpq_poly_set_mpq(fmpq_poly_t poly, const mpq_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), mpq_numref(x))
++    fmpz_set_mpz(fmpq_poly_denref(poly), mpq_denref(x))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
++
++cdef void fmpq_poly_set_mpz(fmpq_poly_t poly, const mpz_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), x)
++    fmpz_one(fmpq_poly_denref(poly))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz.pxd b/src/sage/libs/flint/fmpz.pxd
+index 01058d0f130..b97fbe1eae0 100644
+--- a/src/sage/libs/flint/fmpz.pxd
++++ b/src/sage/libs/flint/fmpz.pxd
+@@ -16,6 +16,9 @@ cdef extern from "flint_wrap.h":
+     void fmpz_init_set(fmpz_t, fmpz_t)
+     void fmpz_init_set_ui(fmpz_t, ulong)
+ 
++    void fmpz_init_set_readonly(fmpz_t, const mpz_t)
++    void fmpz_clear_readonly(fmpz_t)
++
+     # Conversion
+     void fmpz_set(fmpz_t f, fmpz_t g)
+     void fmpz_set_ui(fmpz_t, ulong)
+diff --git a/src/sage/libs/flint/fmpz_mod_poly.pxd b/src/sage/libs/flint/fmpz_mod_poly.pxd
+index 24b653eb3b7..2727246da98 100644
+--- a/src/sage/libs/flint/fmpz_mod_poly.pxd
++++ b/src/sage/libs/flint/fmpz_mod_poly.pxd
+@@ -67,13 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_get_coeff_fmpz(fmpz_t x, const fmpz_mod_poly_t poly,
+                                              slong n, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_set_coeff_mpz(fmpz_mod_poly_t poly,
+-                             slong n, const mpz_t x, const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_get_coeff_mpz(mpz_t x,
+-                 const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx)
+-
+-
+     void _fmpz_mod_poly_shift_left(fmpz * res, const fmpz * poly,
+                                                            slong len, slong n)
+ 
+@@ -194,14 +187,6 @@ cdef extern from "flint_wrap.h":
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_div_basecase(fmpz_mod_poly_t Q,
+-                            const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_div_newton_n_preinv(fmpz_mod_poly_t Q,
+-                         const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                         const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem_newton_n_preinv(fmpz_mod_poly_t Q,
+           fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                          const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+@@ -213,10 +198,6 @@ cdef extern from "flint_wrap.h":
+                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_divrem_divconquer(fmpz_mod_poly_t Q,
+-        fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem(fmpz_mod_poly_t Q, fmpz_mod_poly_t R,
+     const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+@@ -254,40 +235,13 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_make_monic_f(fmpz_t f, fmpz_mod_poly_t res,
+                          const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_euclidean(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_gcd_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_hgcd(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-
+     void fmpz_mod_poly_gcd(fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+ 
+-    void fmpz_mod_poly_xgcd_euclidean(fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_hgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S,
+-          fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_xgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                       const fmpz_mod_ctx_t ctx)
+@@ -361,14 +315,6 @@ cdef extern from "flint_wrap.h":
+                         const fmpz_mod_poly_t poly, const fmpz * xs, slong n,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_compose_horner(fmpz_mod_poly_t res,
+-                    const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_compose_divconquer(fmpz_mod_poly_t res,
+-                     const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_compose(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1,
+                          const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx)
+ 
+diff --git a/src/sage/libs/flint/fmpz_poly.pxd b/src/sage/libs/flint/fmpz_poly.pxd
+index 18b36672d30..c8bc6d3ca0a 100644
+--- a/src/sage/libs/flint/fmpz_poly.pxd
++++ b/src/sage/libs/flint/fmpz_poly.pxd
+@@ -28,7 +28,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_poly_set_ui(fmpz_poly_t, ulong)
+     void fmpz_poly_set_si(fmpz_poly_t, slong)
+     void fmpz_poly_set_fmpz(fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+     int fmpz_poly_set_str(fmpz_poly_t, const char *)
+ 
+     char *fmpz_poly_get_str(const fmpz_poly_t)
+@@ -70,7 +69,6 @@ cdef extern from "flint_wrap.h":
+     # Scalar multiplication and division
+     void fmpz_poly_scalar_mul_fmpz(
+             fmpz_poly_t, const fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+     void fmpz_poly_scalar_mul_si(fmpz_poly_t, const fmpz_poly_t, slong)
+     void fmpz_poly_scalar_mul_ui(fmpz_poly_t, const fmpz_poly_t, ulong)
+     void fmpz_poly_scalar_mul_2exp(fmpz_poly_t, const fmpz_poly_t, ulong)
+@@ -310,12 +308,14 @@ cdef extern from "flint_wrap.h":
+             fmpz_poly_t,
+                     const fmpz_poly_t, const fmpz_t, const nmod_poly_t, int)
+ 
+-    # Some functions for backwards compatibility
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
+-    void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++
++# functions removed from flint but still needed in sage
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
++cdef void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++cdef void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+ 
+ 
+ # Wrapper Cython class
+diff --git a/src/sage/libs/flint/fmpz_poly.pyx b/src/sage/libs/flint/fmpz_poly.pyx
+index 74915b37612..cfcbea9090c 100644
+--- a/src/sage/libs/flint/fmpz_poly.pyx
++++ b/src/sage/libs/flint/fmpz_poly.pyx
+@@ -25,10 +25,10 @@ from cysignals.memory cimport sig_free
+ 
+ from sage.arith.long cimport pyobject_to_long
+ from sage.cpython.string cimport char_to_str, str_to_bytes
++from sage.libs.flint.fmpz cimport *
+ from sage.structure.sage_object cimport SageObject
+ from sage.rings.integer cimport Integer
+ 
+-
+ cdef class Fmpz_poly(SageObject):
+ 
+     def __cinit__(self):
+@@ -455,3 +455,44 @@ cdef class Fmpz_poly(SageObject):
+         """
+         from sage.rings.integer_ring import ZZ
+         return ZZ[var](self.list())
++
++
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_divexact_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_fdiv_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t poly, slong n, const mpz_t x):
++    cdef fmpz_t t
++    fmpz_init_set_readonly(t, x)
++    fmpz_poly_set_coeff_fmpz(poly, n, t)
++    fmpz_clear_readonly(t)
++
++cdef void fmpz_poly_get_coeff_mpz(mpz_t x, const fmpz_poly_t poly, slong n):
++    cdef fmpz_t t
++    fmpz_init(t)
++    fmpz_poly_get_coeff_fmpz(t, poly, n)
++    fmpz_get_mpz(x, t)
++    fmpz_clear(t)
++
++cdef void fmpz_poly_set_mpz(fmpz_poly_t poly, const mpz_t x):
++    fmpz_poly_fit_length(poly, 1)
++    fmpz_set_mpz(poly.coeffs, x)
++    _fmpz_poly_set_length(poly, 1)
++    _fmpz_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz_poly_q.pxd b/src/sage/libs/flint/fmpz_poly_q.pxd
+index 846542dc0d8..63c13355bf6 100644
+--- a/src/sage/libs/flint/fmpz_poly_q.pxd
++++ b/src/sage/libs/flint/fmpz_poly_q.pxd
+@@ -49,11 +49,7 @@ cdef extern from "flint_wrap.h":
+ 
+     #* Scalar multiplication and division ****************************************/
+     void fmpz_poly_q_scalar_mul_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_mul_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_mul_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+     void fmpz_poly_q_scalar_div_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_div_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_div_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+ 
+     #* Multiplication and division ***********************************************/
+     void fmpz_poly_q_mul(fmpz_poly_q_t rop, 
+@@ -67,9 +63,6 @@ cdef extern from "flint_wrap.h":
+     #* Derivative ****************************************************************/
+     void fmpz_poly_q_derivative(fmpz_poly_q_t rop, const fmpz_poly_q_t op)
+ 
+-    #* Evaluation ****************************************************************/
+-    int fmpz_poly_q_evaluate(mpq_t rop, const fmpz_poly_q_t f, const mpq_t a)
+-
+     #* Input and output **********************************************************/
+     int fmpz_poly_q_set_str(fmpz_poly_q_t rop, const char *s)
+     char * fmpz_poly_q_get_str(const fmpz_poly_q_t op)
+diff --git a/src/sage/libs/linbox/linbox_flint_interface.pyx b/src/sage/libs/linbox/linbox_flint_interface.pyx
+index dabd375c2b8..3ca65afc514 100644
+--- a/src/sage/libs/linbox/linbox_flint_interface.pyx
++++ b/src/sage/libs/linbox/linbox_flint_interface.pyx
+@@ -33,6 +33,7 @@ and C. Pernet. The functions available are:
+ #                  https://www.gnu.org/licenses/
+ # ****************************************************************************
+ 
++from sage.libs.gmp.types cimport mpz_t
+ from sage.libs.flint.types cimport fmpz_t
+ from sage.libs.flint.fmpz cimport fmpz_get_mpz, fmpz_set_mpz
+ from sage.libs.flint.fmpz_mat cimport fmpz_mat_entry, fmpz_mat_nrows, fmpz_mat_ncols
+@@ -80,11 +81,13 @@ cdef void fmpz_poly_set_linbox(fmpz_poly_t p, PolynomialRing_integer.Element& q)
+     (the .pxd file) in order to keep the header C-compatible
+     """
+     cdef size_t i
++    cdef mpz_t tmp
+ 
+     fmpz_poly_fit_length(p, q.size())
+ 
+     for i in range(q.size()):
+-        fmpz_poly_set_coeff_mpz(p, i, q[i].get_mpz_const())
++        tmp = q[i].get_mpz_const()
++        fmpz_poly_set_coeff_mpz(p, i, tmp)
+ 
+     _fmpz_poly_set_length(p, q.size())
+ 
+diff --git a/src/sage/matrix/matrix_complex_ball_dense.pyx b/src/sage/matrix/matrix_complex_ball_dense.pyx
+index 22366b5f1f2..7fdf3f2aa36 100644
+--- a/src/sage/matrix/matrix_complex_ball_dense.pyx
++++ b/src/sage/matrix/matrix_complex_ball_dense.pyx
+@@ -1,4 +1,4 @@
+-# distutils: libraries = ARB_LIBRARY
++# distutils: libraries = flint
+ r"""
+ Arbitrary precision complex ball matrices using Arb
+ 
+diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx
+index 0712500e67d..daba89d5c43 100644
+--- a/src/sage/matrix/matrix_integer_sparse.pyx
++++ b/src/sage/matrix/matrix_integer_sparse.pyx
+@@ -847,6 +847,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+             sage: matrix(ZZ, 1, 1, sparse=True)._charpoly_linbox()
+             x
+         """
++        cdef mpz_t tmp
+         if self._nrows != self._ncols:
+             raise ArithmeticError('only valid for square matrix')
+ 
+@@ -869,7 +870,8 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         cdef size_t i
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+@@ -966,9 +968,11 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         sig_off()
+ 
+         cdef size_t i
++        cdef mpz_t tmp
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
+index f36a89bb229..20a06f7eaa3 100644
+--- a/src/sage/rings/complex_arb.pyx
++++ b/src/sage/rings/complex_arb.pyx
+@@ -1360,12 +1360,13 @@ cdef class ComplexBall(RingElement):
+             sage: CBF100(-3r)
+             -3.000000000000000000000000000000
+ 
+-            sage: ComplexBall(CBF100, 10^100)
+-            1.000000000000000000000000000000e+100
+             sage: ComplexBall(CBF100, CIF(1, 2))
+             1.000000000000000000000000000000 + 2.000000000000000000000000000000*I
+             sage: ComplexBall(CBF100, RBF(1/3), RBF(1))
+             [0.3333333333333333 +/- ...e-17] + 1.000000000000000000000000000000*I
++            sage: ComplexBall(CBF100, 10^100)
++            [1.000000000000000000000000000000e+100 +/- ...]
++
+             sage: NF.<a> = QuadraticField(-1, embedding=CC(0, -1))
+             sage: CBF(a)
+             -1.000000000000000*I
+@@ -3009,7 +3010,7 @@ cdef class ComplexBall(RingElement):
+             sage: CBF(1).rising_factorial(2**64)
+             [+/- ...e+347382171326740403407]
+             sage: ComplexBallField(128)(1).rising_factorial(2**64)
+-            [2.343691126796861348e+347382171305201285713 +/- ...e+347382171305201285694]
++            [2.34369112679686134...e+347382171305201285713 +/- ...]
+             sage: CBF(1/2).rising_factorial(CBF(2,3)) # abs tol 1e-15
+             [-0.123060451458124 +/- 3.06e-16] + [0.0406412631676552 +/- 7.57e-17]*I
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+index f651c9f3512..c68246d2142 100644
+--- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+@@ -222,7 +222,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef unsigned long n
+         cdef Rational c
+         cdef list L1
+-        cdef mpq_t * L2
++        cdef fmpq_t q
+ 
+         Polynomial.__init__(self, parent, is_gen=is_gen)
+ 
+@@ -253,14 +253,11 @@ cdef class Polynomial_rational_flint(Polynomial):
+             L1 = [e if isinstance(e, Rational) else Rational(e) for e in x]
+             n  = <unsigned long> len(x)
+             sig_on()
+-            L2 = <mpq_t *> check_allocarray(n, sizeof(mpq_t))
++            fmpq_poly_fit_length(self._poly, n)
+             for deg from 0 <= deg < n:
+-                mpq_init(L2[deg])
+-                mpq_set(L2[deg], (<Rational> L1[deg]).value)
+-            fmpq_poly_set_array_mpq(self._poly, L2, n)
+-            for deg from 0 <= deg < n:
+-                mpq_clear(L2[deg])
+-            sig_free(L2)
++                fmpq_init_set_readonly(q, (<Rational> L1[deg]).value)
++                fmpq_poly_set_coeff_fmpq(self._poly, deg, q)
++                fmpq_clear_readonly(q)
+             sig_off()
+ 
+ #           deg = 0
+@@ -435,6 +432,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         utmost care.
+         """
+         cdef bint do_sig = _do_sig(self._poly)
++        cdef fmpz_t tmpfz
+ 
+         if isinstance(value, int):
+             if do_sig: sig_str("FLINT exception")
+@@ -442,7 +440,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+             if do_sig: sig_off()
+         elif isinstance(value, Integer):
+             if do_sig: sig_str("FLINT exception")
+-            fmpq_poly_set_coeff_mpz(self._poly, n, (<Integer> value).value)
++            fmpz_init_set_readonly(tmpfz, (<Integer> value).value)
++            fmpq_poly_set_coeff_fmpz(self._poly, n, tmpfz)
++            fmpz_clear_readonly(tmpfz)
+             if do_sig: sig_off()
+         elif isinstance(value, Rational):
+             if do_sig: sig_str("FLINT exception")
+@@ -492,7 +492,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef Polynomial_rational_flint f
+         cdef Rational r
+         cdef fmpz_t tmpfz
+-        cdef fmpq_t tmpfq
++        cdef fmpq_t tmpfq, tmpfq1
+         cdef RealBall arb_a, arb_z
+         cdef ComplexBall acb_a, acb_z
+ 
+@@ -508,13 +508,23 @@ cdef class Polynomial_rational_flint(Polynomial):
+             elif isinstance(a, Rational):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpq(r.value, self._poly, (<Rational> a).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> a).value)
++                fmpq_init(tmpfq1)
++                fmpq_poly_evaluate_fmpq(tmpfq1, self._poly, tmpfq)
++                fmpq_get_mpq(r.value, tmpfq1)
++                fmpq_clear(tmpfq1)
++                fmpq_clear_readonly(tmpfq)
+                 sig_off()
+                 return r
+             elif isinstance(a, Integer):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpz(r.value, self._poly, (<Integer> a).value)
++                fmpz_init_set_readonly(tmpfz, (<Integer> a).value)
++                fmpq_init(tmpfq)
++                fmpq_poly_evaluate_fmpz(tmpfq, self._poly, tmpfz)
++                fmpq_get_mpq(r.value, tmpfq)
++                fmpq_clear(tmpfq)
++                fmpz_clear_readonly(tmpfz)
+                 sig_off()
+                 return r
+             elif isinstance(a, int):
+@@ -1321,6 +1331,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         """
+         cdef Polynomial_rational_flint res
+         cdef bint do_sig
++        cdef fmpq_t tmpfq
+ 
+         if right == 0:
+             raise ZeroDivisionError("division by zero polynomial")
+@@ -1331,8 +1342,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+                 do_sig = _do_sig(self._poly)
+ 
+                 if do_sig: sig_str("FLINT exception")
+-                fmpq_poly_scalar_div_mpq(res._poly, self._poly,
+-                                                  (<Rational> QQ(right)).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> QQ(right)).value)
++                fmpq_poly_scalar_div_fmpq(res._poly, self._poly, tmpfq)
++                fmpq_clear_readonly(tmpfq)
+                 if do_sig: sig_off()
+                 return res
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+index 6e7f7498329..3a66198d568 100644
+--- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+@@ -658,6 +658,11 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
+             ...
+             NotImplementedError: square free factorization of polynomials over rings with composite characteristic is not implemented
+ 
++        :trac:`20003`::
++
++            sage: P.<x> = GF(7)[]
++            sage: (6*x+3).squarefree_decomposition()
++            (6) * (x + 4)
+         """
+         if not self.base_ring().is_field():
+             raise NotImplementedError("square free factorization of polynomials over rings with composite characteristic is not implemented")
+diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
+index a9ce06d14ca..affe11e4376 100644
+--- a/src/sage/rings/real_arb.pyx
++++ b/src/sage/rings/real_arb.pyx
+@@ -898,7 +898,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+             sage: RBF.gamma(5)
+             24.00000000000000
+             sage: RBF.gamma(10**20)
+-            [+/- ...e+1956570552410610660600]
++            [1.932849514310098...+1956570551809674817225 +/- ...]
+             sage: RBF.gamma(1/3)
+             [2.678938534707747 +/- ...e-16]
+             sage: RBF.gamma(-5)
+@@ -1102,7 +1102,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+              15.00000000000000,
+              48.00000000000000]
+             sage: RBF.double_factorial(2**20)
+-            [1.4483729903e+2928836 +/- ...e+2928825]
++            [1.448372990...e+2928836 +/- ...]
+             sage: RBF.double_factorial(2**1000)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/schemes/plane_conics/con_rational_function_field.py b/src/sage/schemes/plane_conics/con_rational_function_field.py
+index 05d24e78a85..581102b5c5b 100644
+--- a/src/sage/schemes/plane_conics/con_rational_function_field.py
++++ b/src/sage/schemes/plane_conics/con_rational_function_field.py
+@@ -198,38 +198,6 @@ def has_rational_point(self, point=False, algorithm='default',
+             Fraction Field of Univariate Polynomial Ring in u over Rational
+             Field with modulus v^2 - u^3 - 1
+ 
+-        ``has_rational_point`` fails for some conics over function fields
+-        over finite fields, due to :trac:`20003`::
+-
+-            sage: K.<t> = PolynomialRing(GF(7))
+-            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
+-            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
+-            sage: C.has_rational_point()                                                # needs sage.libs.singular
+-            Traceback (most recent call last):
+-            ...
+-            TypeError: self (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (-t^3 + 3*t^2 - 2*t - 2)/(t + 3)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (t^2 + 3*t + 3)*x*y + (-2*t^2 - 2)*y^2 + (-t^2 + 3*t + 2)*x*z + (-3*t + 3)*y*z + (-3*t^2 + t - 2)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x + (2*t - 2)/(t + 3)*y + (3*t^4 + 2*t^3 - 2*t^2 - 2*t + 3)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z
+-                     : y + (-t^3 - t^2 + 3*t - 1)/(t^3 - 3*t^2 + 2*t + 2)*z : z))
+-            domain must equal right (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^3 - t^2 + 3*t + 3)*x^2 + (t - 3)*y^2 + (-t^7 + 2*t^5 + t^4 + 2*t^3 + 3*t^2 - t - 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    -2/(t^3 - 3*t^2 + 2*t + 2)*x^2 + 1/(t^3 + 3*t^2 - 2*t + 1)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^9 - 2*t^8 + t^7 - t^6 + 3*t^5 - 3*t^3 + t^2 - 2*t + 3)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    ((t^3 - 3*t^2 + 2*t + 2)*x : (t^2 - 2)*y : (t^5 - 3*t^4 + t^2 + 3*t + 3)*z))
+-            codomain
+-
+-
+-
+         TESTS::
+ 
+             sage: K.<t> = FractionField(PolynomialRing(QQ, 't'))
+@@ -250,6 +218,16 @@ def has_rational_point(self, point=False, algorithm='default',
+             sage: C.has_rational_point(point=True)  # long time (4 seconds)             # needs sage.libs.singular
+             (True,
+              ((-2/117*t^8 + 304/1053*t^7 + 40/117*t^6 - 1/27*t^5 - 110/351*t^4 - 2/195*t^3 + 11/351*t^2 + 1/117)/(t^4 + 2/39*t^3 + 4/117*t^2 + 2/39*t + 14/39) : -5/3*t^4 + 19*t^3 : 1))
++
++        ``has_rational_point`` used to fail for some conics over function fields
++        over finite fields, due to :trac:`20003`::
++
++            sage: K.<t> = PolynomialRing(GF(7))
++            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
++            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
++            sage: C.has_rational_point()
++            True
++
+         """
+         from .constructor import Conic
+ 
+diff --git a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+index a591cb4cd7c..a90f2050c59 100644
+--- a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
++++ b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+@@ -20,6 +20,7 @@
+ #include "utils.h"
+ 
+ #include "gmp.h"
++#include "flint/fmpz_poly.h"
+ #include "flint/fmpq_poly.h"
+ #include "flint/fmpq.h"
+ 
+@@ -63,7 +64,7 @@ static ex chebyt_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+@@ -122,7 +123,7 @@ static ex chebyu_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+diff --git a/src/sage/symbolic/ginac/useries.cpp b/src/sage/symbolic/ginac/useries.cpp
+index 40fbd7ab360..b9a8b867648 100644
+--- a/src/sage/symbolic/ginac/useries.cpp
++++ b/src/sage/symbolic/ginac/useries.cpp
+@@ -467,10 +467,17 @@ void add::useries(flint_series_t& fp, int order) const
+                 fmpq_poly_set_ui(fp.ft, 0);
+         else if (oc.is_long())
+                 fmpq_poly_set_si(fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ 
+         for (const auto & elem : seq) {
+ 		const ex& t = recombine_pair_to_ex(elem);
+@@ -505,10 +512,17 @@ void mul::useries(flint_series_t& fp, int order) const
+ 
+         if (oc.is_long())
+                 fmpq_poly_scalar_mul_si(fp.ft, fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_scalar_mul_mpz(fp.ft, fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_scalar_mul_mpq(fp.ft, fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_scalar_mul_fmpz(fp.ft, fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp.ft, fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ void power::useries(flint_series_t& fp, int order) const
+@@ -563,7 +577,10 @@ void power::useries(flint_series_t& fp, int order) const
+                 }
+                 check_poly_ccoeff_one(fp1);
+                 fmpq_poly_log_series(fp1.ft, fp1.ft, order);
+-                fmpq_poly_scalar_mul_mpq(fp1.ft, fp1.ft, nexp.as_mpq());
++                fmpq_t tmp;
++                fmpq_init_set_readonly(tmp, nexp.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp1.ft, fp1.ft, tmp);
++                fmpq_clear_readonly(tmp);
+                 fmpq_poly_exp_series(fp.ft, fp1.ft, order);
+                 return;
+         }
+@@ -608,10 +625,17 @@ void numeric::useries(flint_series_t& fp, int order) const
+ {
+         if (is_long())
+                 fmpq_poly_set_si(fp.ft, to_long());
+-        else if (is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, as_mpq());
++        else if (is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ } // namespace GiNaC
+diff --git a/src/sage_setup/library_order.py b/src/sage_setup/library_order.py
+index f40690f8d22..9ae0d2579a7 100644
+--- a/src/sage_setup/library_order.py
++++ b/src/sage_setup/library_order.py
+@@ -16,17 +16,12 @@
+ 
+ aliases = cython_aliases(required_modules=(), optional_modules=modules)
+ 
+-if "ARB_LIBRARY" in aliases:
+-    arb_dylib_names = [aliases["ARB_LIBRARY"]]
+-else:
+-    arb_dylib_names = []
+-
+ library_order_list = aliases.get("SINGULAR_LIBRARIES", []) + [
+     "giac", "intl", "curl",
+     "ec", "ecm"
+ ] + aliases.get("LINBOX_LIBRARIES", []) + aliases.get("FFLASFFPACK_LIBRARIES", []) + aliases.get("GSL_LIBRARIES", []) + [
+     "pari", "flint", "ecl", "glpk", "ppl",
+-] + arb_dylib_names + [
++] + [
+     "mpfi", "mpfr", "mpc", "ntl", "gmp", "gmpxx",
+     "brial",
+     "brial_groebner",
diff --git a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch b/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
deleted file mode 100644
index 7c55bce6e9bb4..0000000000000
--- a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
+++ /dev/null
@@ -1,221 +0,0 @@
-diff --git a/build/pkgs/singular/checksums.ini b/build/pkgs/singular/checksums.ini
-index 313463d2fea..1101fc55700 100644
---- a/build/pkgs/singular/checksums.ini
-+++ b/build/pkgs/singular/checksums.ini
-@@ -1,5 +1,5 @@
- tarball=singular-VERSION.tar.gz
--sha1=28bb3ee97ef48d04dfa96de182fd93eebe08426c
--md5=fc0a4f5720dadba45a52ee94324ce00c
--cksum=1573851737
--upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-1/singular-VERSION.tar.gz
-+sha1=df1997f412580f2073295aba569bb955ad227317
-+md5=50349213e206a18cdaa1bc410dde7ea4
-+cksum=376854707
-+upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-2/singular-VERSION.tar.gz
-diff --git a/build/pkgs/singular/package-version.txt b/build/pkgs/singular/package-version.txt
-index 66e2bede53a..9f1bf008217 100644
---- a/build/pkgs/singular/package-version.txt
-+++ b/build/pkgs/singular/package-version.txt
-@@ -1 +1 @@
--4.3.1p3
-+4.3.2p7
-diff --git a/build/pkgs/singular/spkg-configure.m4 b/build/pkgs/singular/spkg-configure.m4
-index 6a85631f624..f7621ec5fa1 100644
---- a/build/pkgs/singular/spkg-configure.m4
-+++ b/build/pkgs/singular/spkg-configure.m4
-@@ -6,14 +6,27 @@ SAGE_SPKG_CONFIGURE([singular], [
-     AS_IF([test -z "${SINGULAR_BIN}"], [sage_spkg_install_singular=yes], [
-       dnl Use pkg-config to ensure that Singular is new enough.
-       PKG_CHECK_MODULES([SINGULAR], [Singular >= 4.2.1], [
--       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)
--       ], [
--       AC_MSG_RESULT(no)
--       sage_spkg_install_singular=yes
--       ]
--      )], [
-+        AC_MSG_CHECKING([whether Singular is built with FLINT])
-+        AC_COMPILE_IFELSE([
-+          AC_LANG_PROGRAM([
-+            #include <singular/singularconfig.h>
-+            #if !defined(HAVE_FLINT)
-+            #  error "Need Singular compiled with FLINT"
-+          ], [])
-+        ], [
-+          AC_MSG_RESULT([yes])
-+          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)
-+          ], [
-+            AC_MSG_RESULT(no)
-+            sage_spkg_install_singular=yes
-+          ])
-+        ], [
-+          AC_MSG_RESULT([no])
-+          sage_spkg_install_singular=yes
-+        ])
-+      ], [
-       dnl pkg-config version check failed
-       sage_spkg_install_singular=yes
-       ])
-diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py
-index b15cc1c602c..4b5c76e2bfa 100644
---- a/src/sage/interfaces/singular.py
-+++ b/src/sage/interfaces/singular.py
-@@ -604,8 +604,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: i = singular.ideal(['x^2','y^2','z^2'])
-             sage: s = i.std()
-             sage: singular.eval('hilb(%s)'%(s.name()))
--            '// 1 t^0\n// -3 t^2\n// 3 t^4\n// -1 t^6\n\n// 1 t^0\n//
--            3 t^1\n// 3 t^2\n// 1 t^3\n// dimension (affine) = 0\n//
-+            '...// dimension (affine) = 0\n//
-             degree (affine) = 8'
- 
-         ::
-@@ -613,15 +612,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: from sage.misc.verbose import set_verbose
-             sage: set_verbose(1)
-             sage: o = singular.eval('hilb(%s)'%(s.name()))
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
- 
-         This is mainly useful if this method is called implicitly. Because
-@@ -631,15 +622,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-         ::
- 
-             sage: o = s.hilb()
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
-             // ** right side is not a datum, assignment ignored
-             ...
-diff --git a/src/sage/libs/singular/function.pyx b/src/sage/libs/singular/function.pyx
-index f40346d1fd0..c597c63aafe 100644
---- a/src/sage/libs/singular/function.pyx
-+++ b/src/sage/libs/singular/function.pyx
-@@ -1241,32 +1241,22 @@ cdef class SingularFunction(SageObject):
-             sage: I = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5])
-             sage: I = Ideal(I.groebner_basis())
-             sage: hilb = sage.libs.singular.function_factory.ff.hilb
--            sage: hilb(I) # Singular will print // ** _ is no standard basis
--            // ** _ is no standard basis
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: from sage.misc.sage_ostools import redirection
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I) # Singular will print // ** _ is no standard basis
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            True
- 
-         So we tell Singular that ``I`` is indeed a Groebner basis::
- 
--            sage: hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            False
- 
- 
-         TESTS:
-diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-index 22ada6de947..80352700872 100644
---- a/src/sage/rings/polynomial/multi_polynomial_ideal.py
-+++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-@@ -3132,13 +3132,16 @@ def hilbert_numerator(self, grading=None, algorithm='sage'):
-             sage: I.hilbert_numerator()                                                 # needs sage.rings.number_field
-             -t^5 + 1
- 
--        This example returns a wrong answer due to an integer overflow in Singular::
-+        This example returns a wrong answer in singular < 4.3.2p4 due to an integer overflow::
- 
-             sage: n=4; m=11; P = PolynomialRing(QQ, n*m, "x"); x = P.gens(); M = Matrix(n, x)
-             sage: I = P.ideal(M.minors(2))
-             sage: J = P * [m.lm() for m in I.groebner_basis()]
--            sage: J.hilbert_numerator(algorithm='singular')
--            ...120*t^33 - 3465*t^32 + 48180*t^31 - ...
-+            sage: J.hilbert_numerator(algorithm='singular') # known bug
-+            Traceback (most recent call last):
-+            ....
-+            RuntimeError: error in Singular function call 'hilb':
-+            overflow at t^22
- 
-         Our two algorithms should always agree; not tested until
-         :trac:`33178` is fixed::
-diff --git a/src/sage/sandpiles/sandpile.py b/src/sage/sandpiles/sandpile.py
-index 02d2021b2fb..c8e15e06f05 100644
---- a/src/sage/sandpiles/sandpile.py
-+++ b/src/sage/sandpiles/sandpile.py
-@@ -2493,9 +2493,15 @@ def _set_ideal(self):
-             sage: '_ideal' in S.__dict__
-             True
-         """
-+        from sage.libs.singular.function_factory import ff
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
-         R = self.ring()
--        I = self._unsaturated_ideal._singular_()
--        self._ideal = R.ideal(I.sat(prod(R.gens())._singular_())[1])
-+        I = self._unsaturated_ideal
-+        I_sat_gens = sat(I, prod(R.gens()))[0]
-+        self._ideal = R.ideal(I_sat_gens)
- 
-     def unsaturated_ideal(self):
-         r"""
-diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py
-index e6caf19ba74..afd6484d779 100644
---- a/src/sage/schemes/projective/projective_subscheme.py
-+++ b/src/sage/schemes/projective/projective_subscheme.py
-@@ -1001,7 +1001,10 @@ def dual(self):
-         for i in range(n + 1):
-             J = J + S.ideal(z[-1] * f_S.derivative(z[i]) - z[i + n + 1])
- 
--        sat = ff.elim__lib.sat
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
- 
-         max_ideal = S.ideal(z[n + 1: 2 * n + 2])
-         J_sat_gens = sat(J, max_ideal)[0]
diff --git a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch b/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
deleted file mode 100644
index 6a35ec3836550..0000000000000
--- a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-diff --git a/src/sage/ext/memory.pyx b/src/sage/ext/memory.pyx
-index 1de6dedab82..b95130b19dd 100644
---- a/src/sage/ext/memory.pyx
-+++ b/src/sage/ext/memory.pyx
-@@ -3,14 +3,14 @@ Low-level memory allocation functions
- 
- TESTS:
- 
--Check that a ``MemoryError`` is raised if we try to allocate a
-+Check that an error is raised if we try to allocate a
- ridiculously large integer, see :trac:`15363`::
- 
--    sage: 2^(2^63-3)
--    Traceback (most recent call last):
--    ...
--    OverflowError: exponent must be at most 2147483647         # 32-bit
--    RuntimeError: Aborted                                      # 64-bit
-+    sage: try:
-+    ....:     2^(2^63-3)
-+    ....: except (OverflowError, RuntimeError, FloatingPointError):
-+    ....:     print ('Overflow error')
-+    ...Overflow error
- 
- AUTHORS:
- 
-diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx
-index d5e87626d31..37ed9364845 100644
---- a/src/sage/rings/integer.pyx
-+++ b/src/sage/rings/integer.pyx
-@@ -6654,7 +6654,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
-             sage: try:
-             ....:     print('Possible error output from gmp', flush=True)
-             ....:     1 << (2^60)
--            ....: except (MemoryError, OverflowError, RuntimeError):
-+            ....: except (MemoryError, OverflowError, RuntimeError, FloatingPointError):
-             ....:     pass
-             ....: else:
-             ....:     print("Failed to raise exception")
diff --git a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch b/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
deleted file mode 100644
index 3d2a4bd9cd96f..0000000000000
--- a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
+++ /dev/null
@@ -1,740 +0,0 @@
-diff --git a/src/sage/ext_data/valgrind/valgrind-python.supp b/src/sage/ext_data/valgrind/valgrind-python.supp
-new file mode 100644
-index 00000000000..16aa2858484
---- /dev/null
-+++ b/src/sage/ext_data/valgrind/valgrind-python.supp
-@@ -0,0 +1,480 @@
-+# From the CPython repository with the suppressions for _PyObject_Free
-+# and _PyObject_Realloc enabled. See the upstream suppression file for
-+# details:
-+#
-+# https://github.com/python/cpython/blob/main/Misc/valgrind-python.supp
-+
-+# all tool names: Addrcheck,Memcheck,cachegrind,helgrind,massif
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 8 (x86_64 aka amd64)
-+   Memcheck:Value8
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:address_in_range
-+}
-+
-+#
-+# Leaks (including possible leaks)
-+#    Hmmm, I wonder if this masks some real leaks.  I think it does.
-+#    Will need to fix that.
-+#
-+
-+{
-+   Suppress leaking the GIL after a fork.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_allocate_lock
-+   fun:PyEval_ReInitThreads
-+}
-+
-+{
-+   Suppress leaking the autoTLSkey.  This looks like it shouldn't leak though.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_create_key
-+   fun:_PyGILState_Init
-+   fun:Py_InitializeEx
-+   fun:Py_Main
-+}
-+
-+{
-+   Hmmm, is this a real leak or like the GIL?
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_ReInitTLS
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:realloc
-+   fun:_PyObject_GC_Resize
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_New
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_NewVar
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+#
-+# Non-python specific leaks
-+#
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:calloc
-+   fun:allocate_dtv
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:memalign
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Realloc
-+}
-+
-+###
-+### All the suppressions below are for errors that occur within libraries
-+### that Python uses.  The problems to not appear to be related to Python's
-+### use of the libraries.
-+###
-+
-+{
-+   Generic ubuntu ld problems
-+   Memcheck:Addr8
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+}
-+
-+{
-+   Generic gentoo ld problems
-+   Memcheck:Cond
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_close
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Value8
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   GDBM problems, see test_gdbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   fun:gdbm_open
-+
-+}
-+
-+{
-+   Uninitialised byte(s) false alarm, see bpo-35561
-+   Memcheck:Param
-+   epoll_ctl(event)
-+   fun:epoll_ctl
-+   fun:pyepoll_internal_ctl
-+}
-+
-+{
-+   ZLIB problems, see test_gzip
-+   Memcheck:Cond
-+   obj:/lib/libz.so.1.2.3
-+   obj:/lib/libz.so.1.2.3
-+   fun:deflate
-+}
-+
-+{
-+   Avoid problems w/readline doing a putenv and leaking on exit
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:xmalloc
-+   fun:sh_set_lines_and_columns
-+   fun:_rl_get_screen_size
-+   fun:_rl_init_terminal_io
-+   obj:/lib/libreadline.so.4.3
-+   fun:rl_initialize
-+}
-+
-+# Valgrind emits "Conditional jump or move depends on uninitialised value(s)"
-+# false alarms on GCC builtin strcmp() function. The GCC code is correct.
-+#
-+# Valgrind bug: https://bugs.kde.org/show_bug.cgi?id=264936
-+{
-+   bpo-38118: Valgrind emits false alarm on GCC builtin strcmp()
-+   Memcheck:Cond
-+   fun:PyUnicode_Decode
-+}
-+
-+
-+###
-+### These occur from somewhere within the SSL, when running
-+###  test_socket_sll.  They are too general to leave on by default.
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:memset
-+###}
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:memset
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:MD5_Update
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:MD5_Update
-+###}
-+
-+# Fedora's package "openssl-1.0.1-0.1.beta2.fc17.x86_64" on x86_64
-+# See http://bugs.python.org/issue14171
-+{
-+   openssl 1.0.1 prng 1
-+   Memcheck:Cond
-+   fun:bcmp
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 2
-+   Memcheck:Cond
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 3
-+   Memcheck:Value8
-+   fun:_x86_64_AES_encrypt_compact
-+   fun:AES_encrypt
-+}
-+
-+#
-+# All of these problems come from using test_socket_ssl
-+#
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_bin2bn
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libcrypto.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_set_key_unchecked
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_encrypt2
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BUF_MEM_grow_clean
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:memcpy
-+   fun:ssl3_read_bytes
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:SHA1_Update
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:SHA1_Update
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-+{
-+   wcscmp_false_positive
-+   Memcheck:Addr8
-+   fun:wcscmp
-+   fun:_PyOS_GetOpt
-+   fun:Py_Main
-+   fun:main
-+}
-+
-+# Additional suppressions for the unified decimal tests:
-+{
-+   test_decimal
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_decimal2
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index b40ed64edb5..8c55861c147 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -1576,6 +1576,62 @@ const numeric numeric::div(const numeric &other) const {
-         }
- }
- 
-+
-+// Compute `a^b` as an integer, where a is an integer. Assign to ``res``` if it is integral, or return ``false``.
-+// The nonnegative real root is taken for even denominators. To be used inside numeric::integer_rational_power,
-+// to handle the special case of integral ``a``.
-+bool integer_rational_power_of_mpz(
-+        numeric& res,
-+        const numeric& a,
-+        const numeric& b
-+) {
-+        if (a.t != MPZ)
-+                throw std::runtime_error("integer_rational_power_of_mpz: bad input");
-+        mpz_t z;
-+        mpz_init(z);
-+        mpz_set_ui(z, 0);
-+        int sgn = mpz_sgn(a.v._bigint);
-+        if (mpz_cmp_ui(a.v._bigint, 1) == 0
-+            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
-+                mpz_set_ui(z, 1);
-+        else if (sgn == 0) {
-+                res = *_num0_p;
-+                mpz_clear(z);
-+                return true;
-+        }
-+        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1)) {
-+                mpz_clear(z);
-+                return false;
-+        } else {
-+                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-+                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat))) {
-+                        // too big to take roots/powers
-+                        mpz_clear(z);
-+                        return false;
-+                }
-+                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
-+                        if (mpz_perfect_square_p(a.v._bigint)) {
-+                                mpz_sqrt(z, a.v._bigint);
-+                        } else {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                else {
-+                        bool exact = mpz_root(z, a.v._bigint,
-+                                              mpz_get_ui(mpq_denref(b.v._bigrat)));
-+                        if (not exact) {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
-+        }
-+        res = numeric(z);   // transfers ownership, no mpz_clear
-+        return true;
-+}
-+
-+
- // Compute `a^b` as an integer, if it is integral, or return ``false``.
- // The nonnegative real root is taken for even denominators.
- bool numeric::integer_rational_power(numeric& res,
-@@ -1598,13 +1654,12 @@ bool numeric::integer_rational_power(numeric& res,
-                 if (a.v._long < 0
-                     and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
-                         return false;
--                long z;
-                 if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-                     or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
-                 // too big to take roots/powers
-                         return false;
-                 if (b.is_equal(*_num1_2_p)) {
--                        z = std::lround(std::sqrt(a.v._long));
-+                        long z = std::lround(std::sqrt(a.v._long));
-                         if (a.v._long == z*z) {
-                                 res = numeric(z);
-                                 return true;
-@@ -1613,44 +1668,11 @@ bool numeric::integer_rational_power(numeric& res,
-                 }
-                 return integer_rational_power(res, a.to_bigint(), b);
-         }
--        if (a.t != MPZ)
--                throw std::runtime_error("integer_rational_power: bad input");
--        int sgn = mpz_sgn(a.v._bigint);
--        mpz_t z;
--        mpz_init(z);
--        mpz_set_ui(z, 0);
--        if (mpz_cmp_ui(a.v._bigint, 1) == 0
--            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
--                mpz_set_ui(z, 1);
--        else if (sgn == 0) {
--                res = *_num0_p;
--                return true;
--        }
--        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
--                return false;
--        else {
--                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
--                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
--                // too big to take roots/powers
--                        return false;
--                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
--                        if (mpz_perfect_square_p(a.v._bigint))
--                                mpz_sqrt(z, a.v._bigint);
--                        else
--                                return false;
--                }
--                else {
--                        bool exact = mpz_root(z, a.v._bigint,
--                                        mpz_get_ui(mpq_denref(b.v._bigrat)));
--                        if (not exact)
--                                return false;
--                }
--                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
--        }
--        res = numeric(z);
--        return true;
-+        // otherwise: a is integer
-+        return integer_rational_power_of_mpz(res, a, b);
- }
- 
-+
- // for a^b return c,d such that a^b = c*d^b
- // only for MPZ/MPQ base and MPQ exponent
- void rational_power_parts(const numeric& a_orig, const numeric& b_orig,
-diff --git a/src/sage/tests/memcheck/__init__.py b/src/sage/tests/memcheck/__init__.py
-new file mode 100644
-index 00000000000..e69de29bb2d
-diff --git a/src/sage/tests/memcheck/run_tests.py b/src/sage/tests/memcheck/run_tests.py
-new file mode 100644
-index 00000000000..6ff4503a81b
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests.py
-@@ -0,0 +1,24 @@
-+import types
-+
-+
-+def run_tests() -> None:
-+    """
-+    Run all memcheck tests
-+    """
-+    from sage.tests.memcheck import symbolic_expression
-+    run_tests_in_module(symbolic_expression)
-+
-+
-+def run_tests_in_module(mod: types.ModuleType) -> None:
-+    """
-+    Run all memcheck tests in the given module
-+    """
-+    for entry in dir(mod):
-+        if not entry.startswith('test_'):
-+            continue
-+        test_func = getattr(mod, entry)
-+        test_func()
-+
-+
-+if __name__ == '__main__':
-+    run_tests()
-diff --git a/src/sage/tests/memcheck/run_tests_in_valgrind.py b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-new file mode 100644
-index 00000000000..df5ad0e92b2
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-@@ -0,0 +1,35 @@
-+"""
-+Launch valgrind and run the memory leak tests
-+
-+
-+From the commandline, run
-+
-+    sage -python -m sage.tests.memcheck.run_tests_in_valgrind
-+
-+to launch valgrind and execute the memory leak tests. Requires valgrind
-+to be installed. Alternatively, run as a unit test:
-+
-+    sage: from sage.tests.memcheck.run_tests_in_valgrind import run_tests_in_valgrind
-+    sage: run_tests_in_valgrind()    # optional - valgrind
-+"""
-+
-+import subprocess
-+
-+
-+def run_tests_in_valgrind() -> None:
-+    """
-+    Run the sage.tests.memcheck.run_tests module inside valgrind
-+    """
-+    subprocess.check_call([
-+        'valgrind',
-+        '--suppressions=src/sage/ext_data/valgrind/valgrind-python.supp',
-+        '--show-possibly-lost=no',
-+        '--show-reachable=no',
-+        './venv/bin/python',
-+        '-m',
-+        'sage.tests.memcheck.run_tests'
-+    ])
-+
-+
-+if __name__ == '__main__':
-+    run_tests_in_valgrind()
-diff --git a/src/sage/tests/memcheck/symbolic_expression.py b/src/sage/tests/memcheck/symbolic_expression.py
-new file mode 100644
-index 00000000000..52182fbe62d
---- /dev/null
-+++ b/src/sage/tests/memcheck/symbolic_expression.py
-@@ -0,0 +1,11 @@
-+from sage.tests.memcheck.verify_no_leak import verify_no_leak
-+
-+
-+def test_sqrt_sqrt_2() -> None:
-+    from sage.misc.functional import sqrt
-+    T2 = sqrt(2)
-+
-+    def sqrt_T2() -> None:
-+        sqrt(T2)
-+
-+    verify_no_leak(sqrt_T2)
-diff --git a/src/sage/tests/memcheck/verify_no_leak.py b/src/sage/tests/memcheck/verify_no_leak.py
-new file mode 100644
-index 00000000000..89ca90cf89c
---- /dev/null
-+++ b/src/sage/tests/memcheck/verify_no_leak.py
-@@ -0,0 +1,27 @@
-+from typing import Tuple, Sequence, List, Callable, Any
-+import valgrind
-+
-+
-+def verify_no_leak(callback: Callable[[], Any],
-+                   repeat: int = 10000,
-+                   fuzzy: int = 10,
-+                   ) -> None:
-+    """
-+    Verify that the callback does not generate new definitely lost blocks
-+
-+    Raises an assertion if the callback leaks memory
-+    """
-+    callback()   # warm_up
-+    initial_blocks = (0, 0, 0, 0)
-+    valgrind.memcheck_do_leak_check()
-+    initial_blocks = valgrind.memcheck_count_leak_blocks()
-+    for _ in range(repeat):
-+        callback()
-+    valgrind.memcheck_do_leak_check()
-+    leak_blocks = valgrind.memcheck_count_leak_blocks()
-+    leak = leak_blocks[0] - initial_blocks[0]
-+    if leak < repeat - fuzzy:
-+        return  # callback did not leak at least once per call
-+    blocks = round(leak / repeat, 2)
-+    message = f'{callback} leaked {blocks} block on average ({repeat} iterations)'
-+    raise AssertionError(message)
diff --git a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch b/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
deleted file mode 100644
index 684b62affaf5a..0000000000000
--- a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx
-index 8f46570313d..a8e73e57b52 100644
---- a/src/sage/libs/ecl.pyx
-+++ b/src/sage/libs/ecl.pyx
-@@ -563,15 +563,15 @@ cdef class EclObject:
-     Floats in Python are IEEE double, which LISP has as well. However,
-     the printing of floating point types in LISP depends on settings::
- 
--        sage: a = EclObject(float(10^40))
-+        sage: a = EclObject(float(1.234e40))
-         sage: ecl_eval("(setf *read-default-float-format* 'single-float)")
-         <ECL: SINGLE-FLOAT>
-         sage: a
--        <ECL: 1.d40>
-+        <ECL: 1.234d40>
-         sage: ecl_eval("(setf *read-default-float-format* 'double-float)")
-         <ECL: DOUBLE-FLOAT>
-         sage: a
--        <ECL: 1.e40>
-+        <ECL: 1.234e40>
- 
-     Tuples are translated to dotted lists::
- 
-diff --git a/src/sage/libs/eclsig.h b/src/sage/libs/eclsig.h
-index e249ccf6874..005b2d99d0b 100644
---- a/src/sage/libs/eclsig.h
-+++ b/src/sage/libs/eclsig.h
-@@ -45,7 +45,11 @@ static inline void ecl_sig_off(void)
-     sig_off();
- }
- 
-+#if ECL_VERSION_NUMBER < 230909
- #define ecl_mpz_from_bignum(obj) ((obj)->big.big_num)
-+#else
-+#define ecl_mpz_from_bignum(obj) ecl_bignum(obj)
-+#endif
- 
- cl_object ecl_bignum_from_mpz(mpz_t num)
- {
diff --git a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch b/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
deleted file mode 100644
index e858f2fd4a445..0000000000000
--- a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
-index 59f10f6b13f..adcccff059b 100644
---- a/src/sage/plot/graphics.py
-+++ b/src/sage/plot/graphics.py
-@@ -36,6 +36,7 @@
- # ****************************************************************************
- 
- import os
-+from numbers import Integral
- from collections.abc import Iterable
- from math import isnan
- import sage.misc.verbose
-@@ -2874,6 +2875,11 @@ def matplotlib(self, filename=None,
-                 weight=lopts.pop('font_weight', 'medium'),
-                 variant=lopts.pop('font_variant', 'normal'))
-             color = lopts.pop('back_color', 'white')
-+            if 'loc' in lopts:
-+                loc = lopts['loc']
-+                if isinstance(loc, Integral):
-+                    # matplotlib 3.8 doesn't support sage integers
-+                    lopts['loc'] = int(loc)
-             leg = subplot.legend(prop=prop, **lopts)
-             if leg is None:
-                 from warnings import warn
diff --git a/srcpkgs/sagemath/patches/36403-00pre.patch b/srcpkgs/sagemath/patches/36403-00pre.patch
deleted file mode 100644
index 060404d5430de..0000000000000
--- a/srcpkgs/sagemath/patches/36403-00pre.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-Minor patch so that #36403 applies cleanly over sagemath 10.1
-
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 2053bca80c3..86aca6e00d8 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15123,7 +15302,8 @@ cdef class Matrix(Matrix1):
-             sage: N.conjugate_transpose()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object has no attribute 'conjugate'
-+            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
-+            has no attribute 'conjugate'
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 525ea5aa934..52afed49d64 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -55,7 +55,7 @@ cdef class AttributeErrorMessage:
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-         sage: x = polygen(ZZ, 'x')
--        sage: QQ[x].gen().bla                                                           # optional - sage.libs.flint
-+        sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
diff --git a/srcpkgs/sagemath/patches/36407-python_3.12.patch b/srcpkgs/sagemath/patches/36407-python_3.12.patch
deleted file mode 100644
index c75c275c30764..0000000000000
--- a/srcpkgs/sagemath/patches/36407-python_3.12.patch
+++ /dev/null
@@ -1,1744 +0,0 @@
-diff --git a/build/sage_bootstrap/package.py b/build/sage_bootstrap/package.py
-index 15b342223c4..eb82f96e05f 100644
---- a/build/sage_bootstrap/package.py
-+++ b/build/sage_bootstrap/package.py
-@@ -303,7 +303,7 @@ def _init_checksum(self):
-         # Name of the directory containing the checksums.ini file
-         self.__tarball_package_name = os.path.realpath(checksums_ini).split(os.sep)[-2]
- 
--    VERSION_PATCHLEVEL = re.compile('(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
-+    VERSION_PATCHLEVEL = re.compile(r'(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
- 
-     def _init_version(self):
-         try:
-diff --git a/src/doc/en/thematic_tutorials/coercion_and_categories.rst b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-index bb23331c151..7f5712caea7 100644
---- a/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-+++ b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-@@ -1223,7 +1223,7 @@ However, only "elementary" construction functors have a rank::
-     sage: (Fract*Poly).rank
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'
-+    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'...
- 
- .. end of output
- 
-diff --git a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-index 553a946c4d8..3cd71a9bad4 100644
---- a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-+++ b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-@@ -318,7 +318,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: e.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'...
- 
-         sage: id4 = SymmetricGroup(4).one()
-         sage: type(id4)
-@@ -326,7 +326,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: id4.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'
-+        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'...
- 
- .. note::
- 
-diff --git a/src/sage/algebras/cluster_algebra.py b/src/sage/algebras/cluster_algebra.py
-index b72d2a12976..14669dfed5c 100644
---- a/src/sage/algebras/cluster_algebra.py
-+++ b/src/sage/algebras/cluster_algebra.py
-@@ -167,7 +167,7 @@
-     sage: (t*s).g_vector()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'
-+    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'...
-     sage: A = ClusterAlgebra(['A', 2], principal_coefficients=True)
-     sage: A.explore_to_depth(infinity)
-     sage: s = A.cluster_variable((0, -1)); s
-diff --git a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-index e4a91723558..343ee8a66f9 100644
---- a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-+++ b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-@@ -109,7 +109,7 @@ class WeylLieConformalAlgebra(LieConformalAlgebraWithStructureCoefficients):
-         sage: alpha0.degree()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'
-+        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'...
- 
-     TESTS::
- 
-diff --git a/src/sage/algebras/steenrod/steenrod_algebra.py b/src/sage/algebras/steenrod/steenrod_algebra.py
-index 978a3557a9d..7c4d444f81c 100644
---- a/src/sage/algebras/steenrod/steenrod_algebra.py
-+++ b/src/sage/algebras/steenrod/steenrod_algebra.py
-@@ -1080,7 +1080,7 @@ def homogeneous_component(self, n):
-             sage: a.antipode() # not defined
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'
-+            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'...
-             sage: A(a).antipode() # convert to elt of A, then compute antipode
-             Sq(2,1) + Sq(5)
- 
-diff --git a/src/sage/all__sagemath_repl.py b/src/sage/all__sagemath_repl.py
-index 8d0b43679ca..c31b206bcb8 100644
---- a/src/sage/all__sagemath_repl.py
-+++ b/src/sage/all__sagemath_repl.py
-@@ -79,6 +79,23 @@
-                         message=r"Use setlocale\(\), getencoding\(\) and getlocale\(\) instead",
-                         module='docutils.io')
- 
-+# triggered by dateutil 2.8.2 and sphinx 7.0.1 on Python 3.12
-+# see: https://github.com/dateutil/dateutil/pull/1285
-+# see: https://github.com/sphinx-doc/sphinx/pull/11468
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"datetime.datetime.utcfromtimestamp\(\) is deprecated",
-+                        module='dateutil.tz.tz|sphinx.(builders.gettext|util.i18n)')
-+
-+# triggered on Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"This process.* is multi-threaded, "
-+                                r"use of .*\(\) may lead to deadlocks in the child.")
-+
-+# pickling of itertools is deprecated in Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"Pickle, copy, and deepcopy support will be "
-+                                r"removed from itertools in Python 3.14.")
-+
- 
- from .all__sagemath_objects import *
- from .all__sagemath_environment import *
-diff --git a/src/sage/arith/long.pxd b/src/sage/arith/long.pxd
-index 0031a0ae337..3ea70cef571 100644
---- a/src/sage/arith/long.pxd
-+++ b/src/sage/arith/long.pxd
-@@ -19,6 +19,8 @@ from libc.limits cimport LONG_MIN, LONG_MAX
- from cpython.object cimport Py_SIZE
- from cpython.number cimport PyNumber_Index, PyIndex_Check
- from cpython.longintrepr cimport py_long, PyLong_SHIFT, digit
-+from sage.cpython.pycore_long cimport (
-+    ob_digit, _PyLong_IsNegative, _PyLong_DigitCount)
- 
- from sage.libs.gmp.mpz cimport mpz_fits_slong_p, mpz_get_si
- from sage.rings.integer_fake cimport is_Integer, Integer_AS_MPZ
-@@ -299,8 +301,11 @@ cdef inline bint integer_check_long_py(x, long* value, int* err):
-         return 0
- 
-     # x is a Python "int" (aka PyLongObject or py_long in cython)
--    cdef const digit* D = (<py_long>x).ob_digit
--    cdef Py_ssize_t size = Py_SIZE(x)
-+    cdef const digit* D = ob_digit(x)
-+    cdef Py_ssize_t size = _PyLong_DigitCount(x)
-+
-+    if _PyLong_IsNegative(x):
-+        size = -size
- 
-     # We assume PyLong_SHIFT <= BITS_IN_LONG <= 3 * PyLong_SHIFT.
-     # This is true in all the default configurations:
-diff --git a/src/sage/categories/category.py b/src/sage/categories/category.py
-index 57ef7f4184b..29bce8ee415 100644
---- a/src/sage/categories/category.py
-+++ b/src/sage/categories/category.py
-@@ -2129,7 +2129,7 @@ def _with_axioms(self, axioms):
-             sage: Semigroups().Inverse()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'
-+            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'...
-             sage: Semigroups()._with_axioms(["Inverse"])
-             Category of semigroups
- 
-diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py
-index 5227792e725..4775d4e5bf1 100644
---- a/src/sage/categories/category_with_axiom.py
-+++ b/src/sage/categories/category_with_axiom.py
-@@ -554,7 +554,7 @@ class from the base category class::
-     sage: Magmas.Unital.Associative
-     Traceback (most recent call last):
-     ...
--    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'
-+    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'...
- 
- The purpose of this section is to explain the design of the code
- layout and the rationale for this mismatch.
-@@ -769,7 +769,7 @@ def _(): return LazyImport('sage.categories.rngs', 'Rngs', at_startup=True)
-     sage: Semirings().NoZeroDivisors()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'
-+    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'...
- 
- Concretely, this is to be implemented by defining the new axiom in the
- (``SubcategoryMethods`` nested class of the) appropriate category with
-diff --git a/src/sage/categories/enumerated_sets.py b/src/sage/categories/enumerated_sets.py
-index a8bea53f907..b0ea05d0563 100644
---- a/src/sage/categories/enumerated_sets.py
-+++ b/src/sage/categories/enumerated_sets.py
-@@ -610,7 +610,7 @@ def _list_from_iterator(self):
-                 sage: (QQ^2).list()  # indirect test                                    # needs sage.modules
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'
-+                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'...
- 
-             Here we test that for an object that does not know whether it
-             is finite or not.  Calling ``x.list()`` simply tries to create
-@@ -622,11 +622,11 @@ def _list_from_iterator(self):
-                 sage: Q.is_finite()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'...
-                 sage: Q.list()   # indirect test
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'...
- 
-             Here is another example. We artificially create a version of
-             the ring of integers that does not know whether it is finite
-diff --git a/src/sage/categories/examples/sets_cat.py b/src/sage/categories/examples/sets_cat.py
-index e0853d63f94..fbadb9ca405 100644
---- a/src/sage/categories/examples/sets_cat.py
-+++ b/src/sage/categories/examples/sets_cat.py
-@@ -619,7 +619,7 @@ class PrimeNumbers_Facade(PrimeNumbers_Abstract):
-         sage: pf.next()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'...
- 
-     unlike in the other implementations::
- 
-diff --git a/src/sage/categories/homset.py b/src/sage/categories/homset.py
-index 22ba9d047fc..2a8b8aeedeb 100644
---- a/src/sage/categories/homset.py
-+++ b/src/sage/categories/homset.py
-@@ -632,7 +632,7 @@ def __init__(self, X, Y, category=None, base=None, check=True):
-             sage: H = MyHomset(X, Y, category=1, base = ZZ, check = False)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'...
-             sage: P.<t> = ZZ[]
-             sage: f = P.hom([1/2*t])
-             sage: f.parent().domain()
-diff --git a/src/sage/categories/modules_with_basis.py b/src/sage/categories/modules_with_basis.py
-index e97bf851388..c4933d0657f 100644
---- a/src/sage/categories/modules_with_basis.py
-+++ b/src/sage/categories/modules_with_basis.py
-@@ -2456,7 +2456,7 @@ def apply_multilinear_morphism(self, f, codomain=None):
-                     sage: tensor([a, b]).apply_multilinear_morphism(f)                  # needs sage.modules
-                     Traceback (most recent call last):
-                     ...
--                    AttributeError: 'int' object has no attribute 'parent'
-+                    AttributeError: 'int' object has no attribute 'parent'...
- 
-                 Here we consider an example where the codomain is a
-                 module with basis with a different base ring::
-diff --git a/src/sage/categories/monoids.py b/src/sage/categories/monoids.py
-index 38dd7248c9d..28474bd17b6 100644
---- a/src/sage/categories/monoids.py
-+++ b/src/sage/categories/monoids.py
-@@ -556,7 +556,7 @@ def algebra_generators(self):
-                     Traceback (most recent call last):
-                     ...
-                     AttributeError: 'IntegerModMonoid_with_category' object
--                    has no attribute 'monoid_generators'
-+                    has no attribute 'monoid_generators'...
-                     sage: Z12.semigroup_generators()
-                     Family (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
-                     sage: Z12.algebra(QQ).algebra_generators()                          # needs sage.modules
-diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py
-index 494e8154c80..ec5120e41e6 100644
---- a/src/sage/combinat/finite_state_machine.py
-+++ b/src/sage/combinat/finite_state_machine.py
-@@ -1835,7 +1835,7 @@ def __getstate__(self):
-             sage: T1.transitions
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'FSMState' object has no attribute 'transitions'
-+            AttributeError: 'FSMState' object has no attribute 'transitions'...
-             sage: A1 = loads(dumps(A))
-             sage: all(A.state(j) == A1.state(j) for j in [0, 1])
-             True
-diff --git a/src/sage/combinat/growth.py b/src/sage/combinat/growth.py
-index cf8d18c1764..766eea37917 100644
---- a/src/sage/combinat/growth.py
-+++ b/src/sage/combinat/growth.py
-@@ -371,7 +371,7 @@
-     sage: GrowthDiagram(RulePascal(), [3,1,2])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'RulePascal' object has no attribute 'forward_rule'
-+    AttributeError: 'RulePascal' object has no attribute 'forward_rule'...
- 
- We now re-implement the rule where we provide the dual graded graphs::
- 
-diff --git a/src/sage/combinat/integer_lists/lists.py b/src/sage/combinat/integer_lists/lists.py
-index 5143e5cb5e8..9117a6076f7 100644
---- a/src/sage/combinat/integer_lists/lists.py
-+++ b/src/sage/combinat/integer_lists/lists.py
-@@ -261,7 +261,7 @@ def __getattr__(self, name):
-             sage: L.foo
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'foo'
-+            AttributeError: 'NoneType' object has no attribute 'foo'...
-         """
-         return getattr(self.backend, name)
- 
-diff --git a/src/sage/combinat/posets/posets.py b/src/sage/combinat/posets/posets.py
-index c31597c72e9..c74bfc67cee 100644
---- a/src/sage/combinat/posets/posets.py
-+++ b/src/sage/combinat/posets/posets.py
-@@ -8825,7 +8825,7 @@ def is_induced_subposet(self, other):
-             sage: Poset().is_induced_subposet('junk')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'subposet'
-+            AttributeError: 'str' object has no attribute 'subposet'...
-         """
-         if (not self._is_facade or (isinstance(other, FinitePoset) and
-                                     not other._is_facade)):
-diff --git a/src/sage/cpython/atexit.pyx b/src/sage/cpython/atexit.pyx
-index 961aa348d0a..e5a82735137 100644
---- a/src/sage/cpython/atexit.pyx
-+++ b/src/sage/cpython/atexit.pyx
-@@ -154,6 +154,10 @@ cdef extern from *:
-     #undef _PyGC_FINALIZED
-     #include "internal/pycore_interp.h"
-     #include "internal/pycore_pystate.h"
-+    #if PY_VERSION_HEX >= 0x030c0000
-+    // struct atexit_callback was renamed in 3.12 to atexit_py_callback
-+    #define atexit_callback atexit_py_callback
-+    #endif
-     static atexit_callback ** _atexit_callbacks(PyObject *self) {
-         PyInterpreterState *interp = _PyInterpreterState_GET();
-         struct atexit_state state = interp->atexit;
-diff --git a/src/sage/cpython/debug.pyx b/src/sage/cpython/debug.pyx
-index 986abff2a99..cdaca3a4854 100644
---- a/src/sage/cpython/debug.pyx
-+++ b/src/sage/cpython/debug.pyx
-@@ -78,7 +78,7 @@ def getattr_debug(obj, name, default=_no_default):
- 
-     EXAMPLES::
- 
--        sage: _ = getattr_debug(list, "reverse")
-+        sage: _ = getattr_debug(list, "reverse")  # not tested - broken in python 3.12
-         getattr_debug(obj=<class 'list'>, name='reverse'):
-           type(obj) = <class 'type'>
-           object has __dict__ slot (<class 'dict'>)
-@@ -123,7 +123,7 @@ def getattr_debug(obj, name, default=_no_default):
-         sage: _ = getattr_debug(1, "foo")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'...
-         sage: _ = getattr_debug(1, "foo", "xyz")
-         getattr_debug(obj=1, name='foo'):
-           type(obj) = <class 'sage.rings.integer.Integer'>
-diff --git a/src/sage/cpython/dict_internal.h b/src/sage/cpython/dict_internal.h
-index 42a57bcb468..a5ee35bc198 100644
---- a/src/sage/cpython/dict_internal.h
-+++ b/src/sage/cpython/dict_internal.h
-@@ -169,6 +169,7 @@ dictkeys_set_index(PyDictKeysObject *keys, Py_ssize_t i, Py_ssize_t ix)
- #else   /* Python >= 3.11 */
- 
- #define Py_BUILD_CORE
-+#undef _PyGC_FINALIZED
- #include <internal/pycore_dict.h>
- 
- /************************************************************/
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 52afed49d64..1f49e5230c3 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -53,12 +53,12 @@ cdef class AttributeErrorMessage:
-         sage: 1.bla  #indirect doctest
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'...
-         sage: x = polygen(ZZ, 'x')
-         sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'...
- 
-     ::
- 
-@@ -144,7 +144,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(X, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: x = X()
-         sage: raw_getattr(x, "prop")
-         <property object at ...>
-@@ -173,7 +173,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(Y, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: y = Y()
-         sage: raw_getattr(y, "prop")
-         <property object at ...>
-@@ -278,7 +278,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     The integer ring is a parent, so, lazy attributes work::
- 
-@@ -289,7 +289,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(17, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     In general, descriptors are not yet well supported, because they
-     often do not accept to be cheated with the type of their instance::
-@@ -305,7 +305,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__weakref__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-     This was caught by :trac:`8296` for which we do a couple more tests::
- 
-@@ -314,7 +314,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: 1.__weakref__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-         sage: n = 1
-         sage: ip = get_ipython()                 # not tested: only works in interactive shell
-@@ -329,7 +329,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__call__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'...
- 
-     TESTS:
- 
-@@ -339,14 +339,14 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, type, "__name__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'...
- 
-     Non-strings as "name" are handled gracefully::
- 
-         sage: getattr_from_other_class(1, type, None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute None
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute None...
-     """
-     if not isinstance(cls, type):
-         raise TypeError(f"{cls!r} is not a type")
-diff --git a/src/sage/cpython/pycore_long.h b/src/sage/cpython/pycore_long.h
-new file mode 100644
-index 00000000000..ff1a73d097a
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.h
-@@ -0,0 +1,98 @@
-+#include "Python.h"
-+#include <stdbool.h>
-+
-+#if PY_VERSION_HEX >= 0x030C00A5
-+#define ob_digit(o)  (((PyLongObject*)o)->long_value.ob_digit)
-+#else
-+#define ob_digit(o)  (((PyLongObject*)o)->ob_digit)
-+#endif
-+
-+#if PY_VERSION_HEX >= 0x030C00A7
-+// taken from cpython:Include/internal/pycore_long.h @ 3.12
-+
-+/* Long value tag bits:
-+ * 0-1: Sign bits value = (1-sign), ie. negative=2, positive=0, zero=1.
-+ * 2: Reserved for immortality bit
-+ * 3+ Unsigned digit count
-+ */
-+#define SIGN_MASK 3
-+#define SIGN_ZERO 1
-+#define SIGN_NEGATIVE 2
-+#define NON_SIZE_BITS 3
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_ZERO;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_NEGATIVE;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    assert(PyLong_Check(op));
-+    return op->long_value.lv_tag >> NON_SIZE_BITS;
-+}
-+
-+#define TAG_FROM_SIGN_AND_SIZE(sign, size) ((1 - (sign)) | ((size) << NON_SIZE_BITS))
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+    assert(size >= 0);
-+    assert(-1 <= sign && sign <= 1);
-+    assert(sign != 0 || size == 0);
-+    op->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sign, (size_t)size);
-+}
-+
-+#else
-+// fallback for < 3.12
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) == 0;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) < 0;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) > 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    Py_ssize_t size = Py_SIZE(op);
-+    return size < 0 ? -size : size;
-+}
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION < 9)
-+// The function Py_SET_SIZE is defined starting with python 3.9.
-+    Py_SIZE(o) = size;
-+#else
-+    Py_SET_SIZE(op, sign < 0 ? -size : size);
-+#endif
-+}
-+
-+#endif
-diff --git a/src/sage/cpython/pycore_long.pxd b/src/sage/cpython/pycore_long.pxd
-new file mode 100644
-index 00000000000..41de637ff18
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.pxd
-@@ -0,0 +1,9 @@
-+from cpython.longintrepr cimport py_long, digit
-+
-+cdef extern from "pycore_long.h":
-+    digit* ob_digit(py_long o)
-+    bint _PyLong_IsZero(py_long o)
-+    bint _PyLong_IsNegative(py_long o)
-+    bint _PyLong_IsPositive(py_long o)
-+    Py_ssize_t _PyLong_DigitCount(py_long o)
-+    void _PyLong_SetSignAndDigitCount(py_long o, int sign, Py_ssize_t size)
-diff --git a/src/sage/crypto/classical.py b/src/sage/crypto/classical.py
-index 616dc861652..be899c781e5 100644
---- a/src/sage/crypto/classical.py
-+++ b/src/sage/crypto/classical.py
-@@ -494,7 +494,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: A.rank_by_chi_square("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_chi_square(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -703,7 +703,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: A.rank_by_squared_differences("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_squared_differences(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -2114,7 +2114,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: S.rank_by_chi_square("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_chi_square(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-@@ -2351,7 +2351,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: S.rank_by_squared_differences("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_squared_differences(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/crypto/mq/mpolynomialsystemgenerator.py b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-index 9028dab1d98..4416d9ef7f6 100644
---- a/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-+++ b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-@@ -156,7 +156,7 @@ def sbox(self):
-             sage: msg.sbox()
-             Traceback (most recent call last):
-             ...
--            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'
-+            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'...
-         """
-         return self._sbox
- 
-diff --git a/src/sage/data_structures/bitset.pyx b/src/sage/data_structures/bitset.pyx
-index 446062554c1..d9906b5edd2 100644
---- a/src/sage/data_structures/bitset.pyx
-+++ b/src/sage/data_structures/bitset.pyx
-@@ -967,7 +967,7 @@ cdef class FrozenBitset:
-             sage: None | FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute '_union'
-+            AttributeError: 'NoneType' object has no attribute '_union'...
-         """
-         return self._union(other)
- 
-@@ -1037,7 +1037,7 @@ cdef class FrozenBitset:
-             sage: None & FrozenBitset("101011")
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'intersection'
-+            AttributeError: 'NoneType' object has no attribute 'intersection'...
-         """
-         return self.intersection(other)
- 
-@@ -1106,7 +1106,7 @@ cdef class FrozenBitset:
-             sage: None - FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'difference'
-+            AttributeError: 'NoneType' object has no attribute 'difference'...
-         """
-         return self.difference(other)
- 
-@@ -1179,7 +1179,7 @@ cdef class FrozenBitset:
-             sage: None ^^ FrozenBitset('11111' * 10)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'
-+            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'...
-         """
-         return self.symmetric_difference(other)
- 
-diff --git a/src/sage/doctest/reporting.py b/src/sage/doctest/reporting.py
-index 361fea344c2..a3947c07e01 100644
---- a/src/sage/doctest/reporting.py
-+++ b/src/sage/doctest/reporting.py
-@@ -368,7 +368,7 @@ def report(self, source, timeout, return_code, results, output, pid=None):
-             sage: DTR.report(None, None, None, None, None)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'basename'
-+            AttributeError: 'NoneType' object has no attribute 'basename'...
- 
-         The only-errors mode does not output anything on success::
- 
-diff --git a/src/sage/dynamics/finite_dynamical_system.py b/src/sage/dynamics/finite_dynamical_system.py
-index e5fbf568b7e..4295070615a 100644
---- a/src/sage/dynamics/finite_dynamical_system.py
-+++ b/src/sage/dynamics/finite_dynamical_system.py
-@@ -240,7 +240,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-@@ -252,7 +252,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-diff --git a/src/sage/geometry/cone.py b/src/sage/geometry/cone.py
-index f0a8620011a..53f78a4b7b6 100644
---- a/src/sage/geometry/cone.py
-+++ b/src/sage/geometry/cone.py
-@@ -340,7 +340,7 @@ def Cone(rays, lattice=None, check=True, normalize=True):
-         sage: Cone([(1,0), (0,1)], check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     You can construct different "not" cones: not full-dimensional, not
-     strictly convex, not containing any rays::
-diff --git a/src/sage/geometry/fan.py b/src/sage/geometry/fan.py
-index 258544012fe..3aecc84a55b 100644
---- a/src/sage/geometry/fan.py
-+++ b/src/sage/geometry/fan.py
-@@ -443,7 +443,7 @@ def Fan(cones, rays=None, lattice=None, check=True, normalize=True,
-         sage: P2c = Fan(cones, rays, check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     Yet another way is to use functions :func:`FaceFan` and :func:`NormalFan`
-     to construct fans from :class:`lattice polytopes
-diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-index f0ac1e774a7..f03f0f832ff 100644
---- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-+++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-@@ -351,7 +351,7 @@ cdef class FaceIterator_base(SageObject):
-             sage: FaceIterator_base(2)  # indirect doctest
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'...
-         """
-         cdef int i
-         sig_free(self.structure.atom_rep)
-@@ -1945,7 +1945,8 @@ cdef inline int next_face_loop(iter_t structure) nogil except -1:
-         # The function is not supposed to be called,
-         # just prevent it from crashing.
-         # Actually raising an error here results in a bad branch prediction.
--        return -1
-+        # But return -1 results in a crash with python 3.12
-+        raise StopIteration
- 
-     # Getting ``[faces, n_faces, n_visited_all]`` according to dimension.
-     cdef face_list_t* faces = &structure.new_faces[structure.current_dimension]
-diff --git a/src/sage/geometry/toric_plotter.py b/src/sage/geometry/toric_plotter.py
-index 50b4008eb0f..950e3ba7ff8 100644
---- a/src/sage/geometry/toric_plotter.py
-+++ b/src/sage/geometry/toric_plotter.py
-@@ -706,7 +706,7 @@ def set_rays(self, generators):
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ToricPlotter' object has no attribute 'rays'
-+            AttributeError: 'ToricPlotter' object has no attribute 'rays'...
-             sage: tp.set_rays([(0,1)])
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Graphics object consisting of 2 graphics primitives
-diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
-index d0ec214bb3b..c8098ad578a 100644
---- a/src/sage/groups/matrix_gps/finitely_generated.py
-+++ b/src/sage/groups/matrix_gps/finitely_generated.py
-@@ -268,7 +268,7 @@ def MatrixGroup(*gens, **kwds):
-         sage: SL2C.gens()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'
-+        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'...
-     """
-     if isinstance(gens[-1], dict):   # hack for unpickling
-         kwds.update(gens[-1])
-diff --git a/src/sage/homology/chains.py b/src/sage/homology/chains.py
-index 87c0947c0b0..b9a54940943 100644
---- a/src/sage/homology/chains.py
-+++ b/src/sage/homology/chains.py
-@@ -298,7 +298,7 @@ def is_cycle(self):
-                 sage: chain.is_cocycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -325,7 +325,7 @@ def is_boundary(self):
-                 sage: chain.is_coboundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -539,7 +539,7 @@ def is_cocycle(self):
-                 sage: cochain.is_cycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -566,7 +566,7 @@ def is_coboundary(self):
-                 sage: cochain.is_boundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -604,7 +604,7 @@ def eval(self, other):
-                 sage: z.eval(c) # z is not a cochain
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'...
-                 sage: c.eval(c) # can't evaluate a cochain on a cochain
-                 Traceback (most recent call last):
-                 ...
-diff --git a/src/sage/homology/free_resolution.py b/src/sage/homology/free_resolution.py
-index e3d38de4240..280a479b438 100644
---- a/src/sage/homology/free_resolution.py
-+++ b/src/sage/homology/free_resolution.py
-@@ -275,7 +275,7 @@ def differential(self, i):
-             sage: FreeResolution.differiental(r, 1)
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'FreeResolution' has no attribute 'differiental'
-+            AttributeError: type object 'FreeResolution' has no attribute 'differiental'...
-         """
- 
-     def target(self):
-diff --git a/src/sage/interfaces/magma.py b/src/sage/interfaces/magma.py
-index b7a0ac20d03..529bfbc349b 100644
---- a/src/sage/interfaces/magma.py
-+++ b/src/sage/interfaces/magma.py
-@@ -824,7 +824,7 @@ def _coerce_from_special_method(self, x):
-             sage: magma._coerce_from_special_method('2 + 3')  # optional - magma
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute '_magma_init_'
-+            AttributeError: 'str' object has no attribute '_magma_init_'...
-         """
-         s = x._magma_init_(self)
-         a = self(s)
-diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
-index 58499396d6c..16119d20815 100644
---- a/src/sage/lfunctions/dokchitser.py
-+++ b/src/sage/lfunctions/dokchitser.py
-@@ -418,8 +418,8 @@ def init_coeffs(self, v, cutoff=1,
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
-index bbf289aa21c..e4968866303 100644
---- a/src/sage/lfunctions/pari.py
-+++ b/src/sage/lfunctions/pari.py
-@@ -141,8 +141,8 @@ def init_coeffs(self, v, cutoff=None, w=1):
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
-index 478caf9f9d0..363024ae281 100644
---- a/src/sage/libs/gap/element.pyx
-+++ b/src/sage/libs/gap/element.pyx
-@@ -380,7 +380,7 @@ cdef GapElement make_GapElement(parent, Obj obj):
-         sage: libgap(None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute '_libgap_init_'
-+        AttributeError: 'NoneType' object has no attribute '_libgap_init_'...
-     """
-     cdef GapElement r = GapElement.__new__(GapElement)
-     r._initialize(parent, obj)
-diff --git a/src/sage/libs/gmp/pylong.pxd b/src/sage/libs/gmp/pylong.pxd
-index a73f1da6d6f..84e1bb8cd87 100644
---- a/src/sage/libs/gmp/pylong.pxd
-+++ b/src/sage/libs/gmp/pylong.pxd
-@@ -2,9 +2,10 @@
- Various functions to deal with conversion mpz <-> Python int/long
- """
- 
-+from cpython.longintrepr cimport py_long
- from sage.libs.gmp.types cimport *
- 
- cdef mpz_get_pylong(mpz_srcptr z)
- cdef mpz_get_pyintlong(mpz_srcptr z)
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1
- cdef Py_hash_t mpz_pythonhash(mpz_srcptr z)
-diff --git a/src/sage/libs/gmp/pylong.pyx b/src/sage/libs/gmp/pylong.pyx
-index d5993cca5a5..1a36c29d3fa 100644
---- a/src/sage/libs/gmp/pylong.pyx
-+++ b/src/sage/libs/gmp/pylong.pyx
-@@ -28,6 +28,8 @@ AUTHORS:
- from cpython.object cimport Py_SIZE
- from cpython.long cimport PyLong_FromLong
- from cpython.longintrepr cimport _PyLong_New, py_long, digit, PyLong_SHIFT
-+from sage.cpython.pycore_long cimport (ob_digit, _PyLong_IsNegative,
-+    _PyLong_DigitCount, _PyLong_SetSignAndDigitCount)
- from .mpz cimport *
- 
- cdef extern from *:
-@@ -60,12 +62,9 @@ cdef mpz_get_pylong_large(mpz_srcptr z):
-     """
-     cdef size_t nbits = mpz_sizeinbase(z, 2)
-     cdef size_t pylong_size = (nbits + PyLong_SHIFT - 1) // PyLong_SHIFT
--    L = _PyLong_New(pylong_size)
--    mpz_export(L.ob_digit, NULL,
--            -1, sizeof(digit), 0, PyLong_nails, z)
--    if mpz_sgn(z) < 0:
--        # Set correct size
--        Py_SET_SIZE(L, -pylong_size)
-+    cdef py_long L = _PyLong_New(pylong_size)
-+    mpz_export(ob_digit(L), NULL, -1, sizeof(digit), 0, PyLong_nails, z)
-+    _PyLong_SetSignAndDigitCount(L, mpz_sgn(z), pylong_size)
-     return L
- 
- 
-@@ -88,16 +87,13 @@ cdef mpz_get_pyintlong(mpz_srcptr z):
-     return mpz_get_pylong_large(z)
- 
- 
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1:
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1:
-     """
-     Convert a Python ``long`` `L` to an ``mpz``.
-     """
--    cdef Py_ssize_t pylong_size = Py_SIZE(L)
--    if pylong_size < 0:
--        pylong_size = -pylong_size
--    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails,
--            (<py_long>L).ob_digit)
--    if Py_SIZE(L) < 0:
-+    cdef Py_ssize_t pylong_size = _PyLong_DigitCount(L)
-+    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails, ob_digit(L))
-+    if _PyLong_IsNegative(L):
-         mpz_neg(z, z)
- 
- 
-diff --git a/src/sage/manifolds/calculus_method.py b/src/sage/manifolds/calculus_method.py
-index f5830c0bc45..303dde6cd13 100644
---- a/src/sage/manifolds/calculus_method.py
-+++ b/src/sage/manifolds/calculus_method.py
-@@ -257,7 +257,7 @@ def simplify(self, expression, method=None):
-             sage: cm.simplify(f)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'
-+            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'...
- 
-         In the present case, one should either transform ``f`` to a SymPy
-         object::
-diff --git a/src/sage/manifolds/differentiable/vectorfield_module.py b/src/sage/manifolds/differentiable/vectorfield_module.py
-index d954b5d4839..af4bfb0ceec 100644
---- a/src/sage/manifolds/differentiable/vectorfield_module.py
-+++ b/src/sage/manifolds/differentiable/vectorfield_module.py
-@@ -885,7 +885,7 @@ def tensor(self, *args, **kwds):
-             sage: XM.tensor(XM).tensor(XM.dual().tensor(XM.dual()))
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'
-+            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'...
- 
-         .. SEEALSO::
- 
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 86aca6e00d8..a5f6716e731 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15303,7 +15303,7 @@ cdef class Matrix(Matrix1):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
--            has no attribute 'conjugate'
-+            has no attribute 'conjugate'...
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/matrix/matrix_cyclo_dense.pyx b/src/sage/matrix/matrix_cyclo_dense.pyx
-index f54f3423ded..a49bb6240e6 100644
---- a/src/sage/matrix/matrix_cyclo_dense.pyx
-+++ b/src/sage/matrix/matrix_cyclo_dense.pyx
-@@ -847,7 +847,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense):
-             sage: A.set_mutable()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'
-+            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'...
-             sage: B = A.__copy__()
-             sage: B[0,0] = 20
-             sage: B[0,0]
-diff --git a/src/sage/matrix/matrix_gfpn_dense.pyx b/src/sage/matrix/matrix_gfpn_dense.pyx
-index 4cccf473de1..8e8e4d7336b 100644
---- a/src/sage/matrix/matrix_gfpn_dense.pyx
-+++ b/src/sage/matrix/matrix_gfpn_dense.pyx
-@@ -159,7 +159,7 @@ cdef class FieldConverter_class:
-             sage: C.field_to_fel('foo')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'to_integer'
-+            AttributeError: 'str' object has no attribute 'to_integer'...
-         """
-         return FfFromInt(x.to_integer())
- 
-diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py
-index 6aab58352be..b5e6f52349b 100644
---- a/src/sage/matrix/matrix_space.py
-+++ b/src/sage/matrix/matrix_space.py
-@@ -1619,7 +1619,7 @@ def __getitem__(self, x):
-             sage: MS[2]
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'
-+            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'...
-         """
-         if isinstance(x, (integer.Integer, int)):
-             return self.list()[x]
-diff --git a/src/sage/matroids/lean_matrix.pyx b/src/sage/matroids/lean_matrix.pyx
-index 54c68e637c0..a137cbf70e5 100644
---- a/src/sage/matroids/lean_matrix.pyx
-+++ b/src/sage/matroids/lean_matrix.pyx
-@@ -1,5 +1,4 @@
- # sage.doctest: optional - sage.rings.finite_rings
--# cython: profile=True
- """
- Lean matrices
- 
-diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx
-index 36f563aa433..318c82f2b64 100644
---- a/src/sage/matroids/linear_matroid.pyx
-+++ b/src/sage/matroids/linear_matroid.pyx
-@@ -1134,7 +1134,7 @@ cdef class LinearMatroid(BasisExchangeMatroid):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.matroids.basis_matroid.BasisMatroid' object
--            has no attribute 'base_ring'
-+            has no attribute 'base_ring'...
-             sage: from sage.matroids.advanced import *
-             sage: M4 = BinaryMatroid(Matrix(M1))
-             sage: M5 = LinearMatroid(reduced_matrix=Matrix(GF(2), [[-1, 0, 1],
-diff --git a/src/sage/misc/dev_tools.py b/src/sage/misc/dev_tools.py
-index e7bf176592c..3ece7db2894 100644
---- a/src/sage/misc/dev_tools.py
-+++ b/src/sage/misc/dev_tools.py
-@@ -171,6 +171,7 @@ def load_submodules(module=None, exclude_pattern=None):
-         load sage.geometry.polyhedron.ppl_lattice_polygon... succeeded
-     """
-     from .package_dir import walk_packages
-+    import importlib.util
- 
-     if module is None:
-         import sage
-@@ -194,8 +195,12 @@ def load_submodules(module=None, exclude_pattern=None):
-         try:
-             sys.stdout.write("load %s..." % module_name)
-             sys.stdout.flush()
--            loader = importer.find_module(module_name)
--            loader.load_module(module_name)
-+            # see
-+            # https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
-+            spec = importer.find_spec(module_name)
-+            module = importlib.util.module_from_spec(spec)
-+            sys.modules[module_name] = module
-+            spec.loader.exec_module(module)
-             sys.stdout.write(" succeeded\n")
-         except (ValueError, AttributeError, TypeError, ImportError):
-             # we might get error because of cython code that has been
-diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py
-index c922b8f6f12..03697f08b7c 100644
---- a/src/sage/misc/functional.py
-+++ b/src/sage/misc/functional.py
-@@ -86,7 +86,7 @@ def base_field(x):
-         sage: R.base_field()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'
-+        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'...
-     """
-     try:
-         return x.base_field()
-diff --git a/src/sage/misc/instancedoc.pyx b/src/sage/misc/instancedoc.pyx
-index d8e1e4ac536..44ee70f64ba 100644
---- a/src/sage/misc/instancedoc.pyx
-+++ b/src/sage/misc/instancedoc.pyx
-@@ -256,7 +256,7 @@ cdef class InstanceDocDescriptor:
-             sage: descr.__delete__(obj)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'X' object has no attribute '__doc__'
-+            AttributeError: 'X' object has no attribute '__doc__'...
- 
-             sage: descr.__delete__([])
-             Traceback (most recent call last):
-diff --git a/src/sage/misc/lazy_attribute.pyx b/src/sage/misc/lazy_attribute.pyx
-index bdbec3b3ba1..1f07870b8ec 100644
---- a/src/sage/misc/lazy_attribute.pyx
-+++ b/src/sage/misc/lazy_attribute.pyx
-@@ -441,37 +441,37 @@ class lazy_attribute(_lazy_attribute):
-             sage: B().unimplemented_A # todo: not implemented
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'super' object has no attribute 'unimplemented_A'
-+            AttributeError: 'super' object has no attribute 'unimplemented_A'...
- 
-     We now make some systematic checks::
- 
-         sage: B().unimplemented_A
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: B().unimplemented_B
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: B().unimplemented_AB
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: B().unimplemented_B_implemented_A
-         1
- 
-         sage: C().unimplemented_A()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: C().unimplemented_B()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: C().unimplemented_AB()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: C().unimplemented_B_implemented_A # todo: not implemented
-         1
-     """
-diff --git a/src/sage/misc/object_multiplexer.py b/src/sage/misc/object_multiplexer.py
-index d4e811ef16e..00fd89d6652 100644
---- a/src/sage/misc/object_multiplexer.py
-+++ b/src/sage/misc/object_multiplexer.py
-@@ -85,7 +85,7 @@ def __getattr__(self, name):
-             sage: m.__bork__
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Multiplex' has no attribute '__bork__'
-+            AttributeError: 'Multiplex' has no attribute '__bork__'...
-         """
-         if name.startswith("__"):
-             raise AttributeError("'Multiplex' has no attribute '%s'" % name)
-diff --git a/src/sage/misc/sage_input.py b/src/sage/misc/sage_input.py
-index 66e78ecccbc..00e8d96ee9e 100644
---- a/src/sage/misc/sage_input.py
-+++ b/src/sage/misc/sage_input.py
-@@ -3461,7 +3461,7 @@ def verify_same(a, b):
-         sage: verify_same(1, 1r)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_same(1r, 1)
-         Traceback (most recent call last):
-         ...
-@@ -3525,7 +3525,7 @@ def verify_si_answer(x, answer, preparse):
-         sage: verify_si_answer(1, '1', False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_si_answer(1, 'ZZ(1)', None)
-     """
-     from sage.misc.sage_eval import sage_eval
-diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py
-index f0545be7d81..811afc48755 100644
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -602,7 +602,7 @@ def visit_Num(self, node):
-             On Python 3 negative numbers are parsed first, for some reason, as
-             a UnaryOp node.
-         """
--        return node.n
-+        return node.value
- 
-     def visit_Str(self, node):
-         r"""
-@@ -624,7 +624,7 @@ def visit_Str(self, node):
-             sage: [vis(s) for s in ['"abstract"', "'syntax'", r'''r"tr\ee"''']]
-             ['abstract', 'syntax', 'tr\\ee']
-         """
--        return node.s
-+        return node.value
- 
-     def visit_List(self, node):
-         """
-diff --git a/src/sage/modules/fp_graded/steenrod/module.py b/src/sage/modules/fp_graded/steenrod/module.py
-index 18460b0e9a1..4acfa6b4002 100755
---- a/src/sage/modules/fp_graded/steenrod/module.py
-+++ b/src/sage/modules/fp_graded/steenrod/module.py
-@@ -70,7 +70,7 @@
-     sage: SteenrodFPModule(ZZ, [0])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'
-+    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'...
- 
- AUTHORS:
- 
-diff --git a/src/sage/monoids/trace_monoid.py b/src/sage/monoids/trace_monoid.py
-index 00baa4d14f8..f8176a1e1f2 100644
---- a/src/sage/monoids/trace_monoid.py
-+++ b/src/sage/monoids/trace_monoid.py
-@@ -40,7 +40,6 @@
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from collections import OrderedDict
- from itertools import repeat, chain, product
- 
- from sage.misc.cachefunc import cached_method
-@@ -633,14 +632,14 @@ def _compute_dependence_stack(self, x):
-             sage: x = b*a*d*a*c*b
-             sage: M._compute_dependence_stack(x)
-             ({a, b, c, d},
--             OrderedDict([(a, [False, False, True, True, False]),
--                          (b, [True, False, False, False, True]),
--                          (c, [True, False, False, False]),
--                          (d, [False, False, True, False])]))
-+             {a: [False, False, True, True, False],
-+              b: [True, False, False, False, True],
-+              c: [True, False, False, False],
-+              d: [False, False, True, False]})
-         """
-         independence = self._independence
-         generators_set = set(e for e, _ in x)
--        stacks = OrderedDict(sorted((g, []) for g in generators_set))
-+        stacks = dict(sorted((g, []) for g in generators_set))
-         for generator, times in reversed(list(x)):
-             stacks[generator].extend(repeat(True, times))
-             for other_gen in generators_set:
-diff --git a/src/sage/parallel/map_reduce.py b/src/sage/parallel/map_reduce.py
-index 11e0673ee91..5441943731d 100644
---- a/src/sage/parallel/map_reduce.py
-+++ b/src/sage/parallel/map_reduce.py
-@@ -1234,7 +1234,7 @@ def finish(self):
-             sage: S.print_communication_statistics()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'RESetMPExample' object has no attribute '_stats'
-+            AttributeError: 'RESetMPExample' object has no attribute '_stats'...
- 
-             sage: S.finish()
- 
-diff --git a/src/sage/plot/colors.py b/src/sage/plot/colors.py
-index 8c0db2b3c34..3281199400b 100644
---- a/src/sage/plot/colors.py
-+++ b/src/sage/plot/colors.py
-@@ -1099,7 +1099,7 @@ def __getattr__(self, name):
-             sage: cols.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ColorsDict' has no attribute or colormap punk
-+            AttributeError: 'ColorsDict' has no attribute or colormap punk...
-         """
-         try:
-             return self[name]
-@@ -1599,7 +1599,7 @@ def __getattr__(self, name):
-             sage: maps.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Colormaps' has no attribute or colormap punk
-+            AttributeError: 'Colormaps' has no attribute or colormap punk...
-             sage: maps['punk']
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/rings/asymptotic/asymptotic_ring.py b/src/sage/rings/asymptotic/asymptotic_ring.py
-index b07319382d3..994490e6616 100644
---- a/src/sage/rings/asymptotic/asymptotic_ring.py
-+++ b/src/sage/rings/asymptotic/asymptotic_ring.py
-@@ -1091,7 +1091,7 @@ def monomial_coefficient(self, monomial):
-             sage: O(n).monomial_coefficient(n)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'
-+            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'...
- 
-         The ``monomial`` must be exact::
- 
-diff --git a/src/sage/rings/asymptotic/growth_group.py b/src/sage/rings/asymptotic/growth_group.py
-index 27c14592bca..5be12537d62 100644
---- a/src/sage/rings/asymptotic/growth_group.py
-+++ b/src/sage/rings/asymptotic/growth_group.py
-@@ -1572,7 +1572,7 @@ def variable_names(self):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'GenericGrowthGroup_with_category.element_class' object
--            has no attribute 'is_one'
-+            has no attribute 'is_one'...
-         """
-         if self.is_one():
-             return tuple()
-diff --git a/src/sage/rings/ideal.py b/src/sage/rings/ideal.py
-index d36d9406f32..01c9fa3bf2d 100644
---- a/src/sage/rings/ideal.py
-+++ b/src/sage/rings/ideal.py
-@@ -1553,7 +1553,7 @@ def gcd(self, other):
-             sage: J.gcd(I)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Ideal_generic' object has no attribute 'gcd'
-+            AttributeError: 'Ideal_generic' object has no attribute 'gcd'...
- 
-         Note::
- 
-diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
-index 7fe89197011..8832d27e8ea 100644
---- a/src/sage/rings/number_field/number_field.py
-+++ b/src/sage/rings/number_field/number_field.py
-@@ -3823,7 +3823,7 @@ def primes_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
-         """
-         if degree is not None:
-             degree = ZZ(degree)
-@@ -3917,7 +3917,7 @@ def prime_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
- 
-         """
-         ids = self.primes_above(x, degree)
-@@ -5926,7 +5926,7 @@ def factor(self, n):
-             sage: L.factor(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'...
- 
-         AUTHORS:
- 
-@@ -12698,7 +12698,7 @@ def is_real_place(v):
-         sage: is_real_place(v_fin)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'
-+        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'...
- 
-     """
-     RR = sage.rings.real_mpfr.RealField(53)
-diff --git a/src/sage/rings/padics/generic_nodes.py b/src/sage/rings/padics/generic_nodes.py
-index 7047020edec..b6b514d4005 100644
---- a/src/sage/rings/padics/generic_nodes.py
-+++ b/src/sage/rings/padics/generic_nodes.py
-@@ -740,7 +740,7 @@ def _get_element_class(self, name=None):
-             sage: R._get_element_class("foobar")
-             Traceback (most recent call last):
-             ...
--            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'
-+            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'...
-         """
-         if name is None:
-             return self.Element
-diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx
-index c5a1129aecf..a5b7f937cfe 100644
---- a/src/sage/rings/polynomial/polynomial_element.pyx
-+++ b/src/sage/rings/polynomial/polynomial_element.pyx
-@@ -10793,7 +10793,7 @@ cdef class Polynomial(CommutativePolynomial):
-             sage: (y**2 + x).nth_root(2)
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... has no attribute 'nth_root'
-+            AttributeError: ... has no attribute 'nth_root'...
- 
-         TESTS::
- 
-@@ -11831,7 +11831,7 @@ cdef class Polynomial_generic_dense(Polynomial):
-             sage: int(1) // x  # check that this doesn't segfault
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'int' has no attribute 'base_ring'
-+            AttributeError: type object 'int' has no attribute 'base_ring'...
-         """
-         if have_same_parent(self, right):
-             return (<Polynomial_generic_dense>self)._floordiv_(<Polynomial_generic_dense>right)
-diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-index e372be888ee..aca4f08420f 100644
---- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
-+++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-@@ -2362,7 +2362,7 @@ def field_extension(self, names):
-             sage: F, g, h = S.field_extension('b')                                      # needs sage.rings.finite_rings
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'
-+            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'...
- 
-         Over a finite field, the corresponding field extension is not a
-         number field::
-diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx
-index 5273891a5b0..a6e999b8805 100644
---- a/src/sage/rings/ring.pyx
-+++ b/src/sage/rings/ring.pyx
-@@ -1734,7 +1734,7 @@ cdef class IntegralDomain(CommutativeRing):
-             sage: Z5.is_integrally_closed()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'
-+            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'...
-         """
-         raise NotImplementedError
- 
-diff --git a/src/sage/sat/solvers/satsolver.pyx b/src/sage/sat/solvers/satsolver.pyx
-index c2f41b18f55..1c4ac400cb6 100644
---- a/src/sage/sat/solvers/satsolver.pyx
-+++ b/src/sage/sat/solvers/satsolver.pyx
-@@ -375,10 +375,10 @@ def SAT(solver=None, *args, **kwds):
-         DIMACS Solver: 'kissat -q {input}'
-     """
-     if solver is None:
--        import pkgutil
--        if pkgutil.find_loader('pycryptosat') is not None:
-+        from importlib.util import find_spec
-+        if find_spec('pycryptosat') is not None:
-             solver = "cryptominisat"
--        elif pkgutil.find_loader('pycosat') is not None:
-+        elif find_spec('pycosat') is not None:
-             solver = "picosat"
-         else:
-             solver = "LP"
-diff --git a/src/sage/schemes/toric/morphism.py b/src/sage/schemes/toric/morphism.py
-index 1c8944b6dfc..5d64d632f97 100644
---- a/src/sage/schemes/toric/morphism.py
-+++ b/src/sage/schemes/toric/morphism.py
-@@ -246,7 +246,7 @@
-     Traceback (most recent call last):
-     ...
-     AttributeError: 'SchemeMorphism_fan_toric_variety' object
--    has no attribute 'fiber_generic'
-+    has no attribute 'fiber_generic'...
- 
- Let's use factorization mentioned above::
- 
-diff --git a/src/sage/sets/disjoint_union_enumerated_sets.py b/src/sage/sets/disjoint_union_enumerated_sets.py
-index 3dea567a779..5c5e08612f2 100644
---- a/src/sage/sets/disjoint_union_enumerated_sets.py
-+++ b/src/sage/sets/disjoint_union_enumerated_sets.py
-@@ -597,7 +597,7 @@ def Element(self):
-             sage: U.Element
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'
-+            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'...
-         """
-         if not self._facade:
-             return ElementWrapper
-diff --git a/src/sage/sets/set.py b/src/sage/sets/set.py
-index a1789c61300..112d3d8dc3b 100644
---- a/src/sage/sets/set.py
-+++ b/src/sage/sets/set.py
-@@ -163,7 +163,7 @@ def Set(X=None, category=None):
-         sage: sorted(B.list(), key=repr)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'Set_object_with_category' object has no attribute 'list'
-+        AttributeError: 'Set_object_with_category' object has no attribute 'list'...
-         sage: type(B)
-         <class 'sage.sets.set.Set_object_with_category'>
- 
-diff --git a/src/sage/structure/category_object.pyx b/src/sage/structure/category_object.pyx
-index b6a7eaecb5b..c06933494dc 100644
---- a/src/sage/structure/category_object.pyx
-+++ b/src/sage/structure/category_object.pyx
-@@ -836,7 +836,7 @@ cdef class CategoryObject(SageObject):
-             sage: Sets().example().sadfasdf
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'
-+            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'...
-         """
-         return self.getattr_from_category(name)
- 
-diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx
-index caae7e40ffc..543506e9a74 100644
---- a/src/sage/structure/element.pyx
-+++ b/src/sage/structure/element.pyx
-@@ -219,7 +219,7 @@ the parents::
-     sage: x._add_(x)
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-     sage: x + x
-     Traceback (most recent call last):
-     ...
-@@ -478,13 +478,13 @@ cdef class Element(SageObject):
-             sage: 1.blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'...
-             sage: Semigroups().example().an_element().is_idempotent
-             <bound method LeftZeroSemigroup.Element.is_idempotent of 42>
-             sage: Semigroups().example().an_element().blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'
-+            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'...
-         """
-         return self.getattr_from_category(name)
- 
-@@ -1269,7 +1269,7 @@ cdef class Element(SageObject):
-             sage: e._add_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-         """
-         try:
-             python_op = (<object>self)._add_
-@@ -1381,7 +1381,7 @@ cdef class Element(SageObject):
-             sage: e._sub_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'...
-         """
-         try:
-             python_op = (<object>self)._sub_
-@@ -1435,7 +1435,7 @@ cdef class Element(SageObject):
-             sage: e._neg_()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'...
-         """
-         try:
-             python_op = (<object>self)._neg_
-@@ -1549,7 +1549,7 @@ cdef class Element(SageObject):
-             sage: e._mul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'...
-         """
-         try:
-             python_op = (<object>self)._mul_
-@@ -1662,7 +1662,7 @@ cdef class Element(SageObject):
-             sage: e._matmul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'...
-         """
-         try:
-             python_op = (<object>self)._matmul_
-@@ -1765,7 +1765,7 @@ cdef class Element(SageObject):
-             sage: e._div_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'...
-         """
-         try:
-             python_op = (<object>self)._div_
-@@ -1865,7 +1865,7 @@ cdef class Element(SageObject):
-             sage: e._floordiv_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'...
-         """
-         try:
-             python_op = (<object>self)._floordiv_
-@@ -1965,7 +1965,7 @@ cdef class Element(SageObject):
-             sage: e._mod_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'...
-         """
-         try:
-             python_op = (<object>self)._mod_
-@@ -2092,7 +2092,7 @@ cdef class Element(SageObject):
-             sage: e._pow_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'...
-         """
-         try:
-             python_op = (<object>self)._pow_
-@@ -2122,7 +2122,7 @@ cdef class Element(SageObject):
-             sage: e._pow_int(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'...
-         """
-         try:
-             python_op = (<object>self)._pow_int
-@@ -2856,7 +2856,7 @@ cdef class RingElement(ModuleElement):
-             sage: m.is_nilpotent()                                                      # needs sage.modules
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... object has no attribute 'is_nilpotent'
-+            AttributeError: '...' object has no attribute 'is_nilpotent'...
-         """
-         if self.is_unit():
-             return False
-@@ -4671,7 +4671,7 @@ def coerce_binop(method):
-         sage: x.test_add(CC(2))
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'
-+        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'...
- 
-     TESTS:
- 
-diff --git a/src/sage/structure/sequence.py b/src/sage/structure/sequence.py
-index 0c700c1fb81..c3972532ac3 100644
---- a/src/sage/structure/sequence.py
-+++ b/src/sage/structure/sequence.py
-@@ -854,7 +854,7 @@ def __getattr__(self, name):
-             sage: S.universe()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'...
-             sage: S._Sequence__universe = 'foobar'
-             sage: S.universe()
-             'foobar'
-@@ -867,7 +867,7 @@ def __getattr__(self, name):
-             sage: hash(S)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'...
-             sage: S._Sequence__hash = int(34)
-             sage: hash(S)
-             34
-diff --git a/src/sage/symbolic/assumptions.py b/src/sage/symbolic/assumptions.py
-index 7dcb15f0d85..15f6fa07ce6 100644
---- a/src/sage/symbolic/assumptions.py
-+++ b/src/sage/symbolic/assumptions.py
-@@ -636,7 +636,7 @@ def assume(*args):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no
--        attribute 'assume'
-+        attribute 'assume'...
- 
-     Ensure that we can combine the two types of assumptions, as documented::
- 
-diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx
-index 0f251ac4e5c..66f624141b3 100644
---- a/src/sage/symbolic/expression.pyx
-+++ b/src/sage/symbolic/expression.pyx
-@@ -13712,7 +13712,7 @@ cdef get_dynamic_class_for_function(unsigned serial):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.symbolic.expression.Expression' object has no
--        attribute 'argp1'
-+        attribute 'argp1'...
-         sage: t = (e + 1).op[0]; t
-         tfunc(x)
-         sage: t
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index c4152e092e3..4bcf45e8793 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -67,6 +67,7 @@
- #include "archive.h"
- #include "tostring.h"
- #include "utils.h"
-+#include "../../cpython/pycore_long.h"
- 
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wdeprecated-register"
-@@ -706,18 +707,12 @@ static long _mpq_pythonhash(mpq_t the_rat)
- // Initialize an mpz_t from a Python long integer
- static void _mpz_set_pylong(mpz_t z, PyLongObject* l)
- {
--    Py_ssize_t pylong_size = Py_SIZE(l);
--    int sign = 1;
--
--    if (pylong_size < 0) {
--        pylong_size = -pylong_size;
--        sign = -1;
--    }
-+    Py_ssize_t pylong_size = _PyLong_DigitCount(l);
- 
-     mpz_import(z, pylong_size, -1, sizeof(digit), 0,
--               8*sizeof(digit) - PyLong_SHIFT, l->ob_digit);
-+               8*sizeof(digit) - PyLong_SHIFT, ob_digit(l));
- 
--    if (sign < 0)
-+    if (_PyLong_IsNegative(l))
-         mpz_neg(z, z);
- }
- 
-diff --git a/src/sage/symbolic/pynac_impl.pxi b/src/sage/symbolic/pynac_impl.pxi
-index 68c31dcfde7..7fd7c3b314b 100644
---- a/src/sage/symbolic/pynac_impl.pxi
-+++ b/src/sage/symbolic/pynac_impl.pxi
-@@ -619,7 +619,7 @@ def tolerant_is_symbol(a):
-         sage: None.is_symbol()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute 'is_symbol'
-+        AttributeError: 'NoneType' object has no attribute 'is_symbol'...
-     """
-     try:
-         return a.is_symbol()
diff --git a/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch b/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
new file mode 100644
index 0000000000000..1e695c2d9d106
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
@@ -0,0 +1,134 @@
+diff --git a/src/sage/quadratic_forms/quadratic_form__neighbors.py b/src/sage/quadratic_forms/quadratic_form__neighbors.py
+index fb781e20122..ec853cd52ef 100644
+--- a/src/sage/quadratic_forms/quadratic_form__neighbors.py
++++ b/src/sage/quadratic_forms/quadratic_form__neighbors.py
+@@ -74,6 +74,10 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+         sage: v = Q.find_primitive_p_divisible_vector__next(5, v); v
+         (1, 0)
+         sage: v = Q.find_primitive_p_divisible_vector__next(5, v); v
++        sage: v = Q.find_primitive_p_divisible_vector__next(2) ; v
++        (0, 1)
++        sage: v = Q.find_primitive_p_divisible_vector__next(2, v) ; v
++        (1, 0)
+         sage: Q = QuadraticForm(QQ, matrix.diagonal([1,1,1,1]))
+         sage: v = Q.find_primitive_p_divisible_vector__next(2)
+         sage: Q(v)
+@@ -83,6 +87,9 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+     n = self.dim()
+     if v is None:
+         w = vector(ZZ, [0] * (n - 1) + [1])
++        a = self(w)
++        if a in ZZ and (a % p == 0):
++            return w
+     else:
+         w = deepcopy(v)
+ 
+@@ -132,7 +139,7 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+             return w
+ 
+ 
+-def find_p_neighbor_from_vec(self, p, y):
++def find_p_neighbor_from_vec(self, p, y, return_matrix=False):
+     r"""
+     Return the `p`-neighbor of ``self`` defined by ``y``.
+ 
+@@ -147,25 +154,32 @@ def find_p_neighbor_from_vec(self, p, y):
+     - ``p`` -- a prime number
+     - ``y`` -- a vector with `q(y) \in p \ZZ`
+     - ``odd`` -- (default: ``False``) if `p=2`, return also odd neighbors
++    - ``return_matrix`` -- (boolean, default ``False``) return
++      the transformation matrix instead of the quadratic form
+ 
+     EXAMPLES::
+ 
++        sage: # needs sage.libs.pari
+         sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1,1])
+         sage: v = vector([0,2,1,1])
+-        sage: X = Q.find_p_neighbor_from_vec(3, v); X                                   # needs sage.libs.pari
++        sage: X = Q.find_p_neighbor_from_vec(3, v); X
+         Quadratic form in 4 variables over Integer Ring with coefficients:
+         [ 1 0 0 0 ]
+         [ * 1 4 4 ]
+         [ * * 5 12 ]
+         [ * * * 9 ]
++        sage: B = Q.find_p_neighbor_from_vec(3, v, return_matrix=True)
++        sage: Q(B) == X
++        True
+ 
+     Since the base ring and the domain are not yet separate,
+     for rational, half integral forms we just pretend
+     the base ring is `\ZZ`::
+ 
++        sage: # needs sage.libs.pari
+         sage: Q = QuadraticForm(QQ, matrix.diagonal([1,1,1,1]))
+         sage: v = vector([1,1,1,1])
+-        sage: Q.find_p_neighbor_from_vec(2, v)                                          # needs sage.libs.pari
++        sage: Q.find_p_neighbor_from_vec(2, v)
+         Quadratic form in 4 variables over Rational Field with coefficients:
+         [ 1/2 1 1 1 ]
+         [ * 1 1 2 ]
+@@ -227,9 +241,12 @@ def find_p_neighbor_from_vec(self, p, y):
+     # by definition this is the p-neighbor of L at y
+     # assert B.det().abs() == 1
+ 
+-    QF = self.parent()
+-    Gnew = (B*G*B.T).change_ring(R)
+-    return QF(Gnew)
++    if return_matrix:
++        return B.T
++    else:
++        QF = self.parent()
++        Gnew = (B*G*B.T).change_ring(R)
++        return QF(Gnew)
+ 
+ 
+ def neighbor_iteration(seeds, p, mass=None, max_classes=ZZ(10)**3,
+diff --git a/src/sage/quadratic_forms/ternary.pyx b/src/sage/quadratic_forms/ternary.pyx
+index 28dd9514c30..6e7c4389083 100644
+--- a/src/sage/quadratic_forms/ternary.pyx
++++ b/src/sage/quadratic_forms/ternary.pyx
+@@ -955,7 +955,26 @@ def extend(v):
+         [ 30   0  -7]
+         sage: M.det()
+         2
++
++    TESTS::
++
++        sage: M = matrix(3, extend( (0, 0, 1) ))
++        sage: M.det()
++        1
++        sage: M.column(0)
++        (0, 0, 1)
++        sage: M = matrix(3, extend( (0, 0, -2) ))
++        sage: M.det()
++        2
++        sage: M.column(0)
++        (0, 0, -2)
+     """
++    if v[0] == v[1] == 0:
++        if v[2] < 0:
++            return v[0], 0, 1,  v[1], 1, 0,  v[2], 0, 0
++        else:
++            return v[0], 1, 0,  v[1], 0, 1,  v[2], 0, 0
++
+     b1 = xgcd(v[0], v[1])
+     b2 = xgcd(b1[1], b1[2])
+     b3 = xgcd(b1[0], v[2])
+diff --git a/src/sage/quadratic_forms/ternary_qf.py b/src/sage/quadratic_forms/ternary_qf.py
+index fa4499566a9..2f3a57fa713 100644
+--- a/src/sage/quadratic_forms/ternary_qf.py
++++ b/src/sage/quadratic_forms/ternary_qf.py
+@@ -918,6 +918,13 @@ def find_p_neighbor_from_vec(self, p, v, mat=False):
+             [     0  -3/11  13/11]
+             sage: Q(M) == Q11
+             True
++
++        Test that it works with (0, 0, 1)::
++
++            sage: Q.find_p_neighbor_from_vec(3, (0,0,1))
++            Ternary quadratic form with integer coefficients:
++            [1 3 3]
++            [-2 0 -1]
+         """
+         if mat:
+             q, M = _find_p_neighbor_from_vec(self._a, self._b, self._c, self._r, self._s, self._t, p, v, mat)
diff --git a/srcpkgs/sagemath/patches/36696-fix_SSL_timeout.patch b/srcpkgs/sagemath/patches/36696-fix_SSL_timeout.patch
new file mode 100644
index 0000000000000..8693b0df5288b
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36696-fix_SSL_timeout.patch
@@ -0,0 +1,33 @@
+diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py
+index 8583d7a447d..633afd5c2e6 100644
+--- a/src/sage/doctest/control.py
++++ b/src/sage/doctest/control.py
+@@ -457,11 +457,15 @@ def __init__(self, options, args):
+                 options.hide.discard('all')
+                 from sage.features.all import all_features
+                 feature_names = {f.name for f in all_features() if not f.is_standard()}
++                from sage.doctest.external import external_software
++                feature_names.difference_update(external_software)
+                 options.hide = options.hide.union(feature_names)
+             if 'optional' in options.hide:
+                 options.hide.discard('optional')
+                 from sage.features.all import all_features
+                 feature_names = {f.name for f in all_features() if f.is_optional()}
++                from sage.doctest.external import external_software
++                feature_names.difference_update(external_software)
+                 options.hide = options.hide.union(feature_names)
+ 
+         options.disabled_optional = set()
+diff --git a/src/sage/features/internet.py b/src/sage/features/internet.py
+index f1eb000fe92..576b0136926 100644
+--- a/src/sage/features/internet.py
++++ b/src/sage/features/internet.py
+@@ -56,7 +56,7 @@ def _is_present(self):
+         try:
+             urlopen(req, timeout=1, context=default_context())
+             return FeatureTestResult(self, True)
+-        except urllib.error.URLError:
++        except (urllib.error.URLError, TimeoutError):
+             return FeatureTestResult(self, False)
+ 
+ 
diff --git a/srcpkgs/sagemath/patches/get_patches b/srcpkgs/sagemath/patches/get_patches
index 95a6963432948..c5ee28f6eb10c 100755
--- a/srcpkgs/sagemath/patches/get_patches
+++ b/srcpkgs/sagemath/patches/get_patches
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-version=10.1
+version=10.2.beta9
 
 URL_BASE_PR="https://github.com/sagemath/sage/pull/"
 URL_BASE_COMPARE="https://github.com/sagemath/sage/compare/${version}..."
@@ -20,24 +20,15 @@ get_pr() {
 # run from patches dir
 cd $(dirname "$0")
 
-# merged in 10.2.beta0
-#get_pr  36018   "singular 4.3.2p4" # included in #35934
-get_pr  36046   "fix memory leak"
-
-# merged in 10.2.beta1
-get_pr  35934   "singular 4.3.2p7"
-
-# merged in 10.2.beta2
-get_pr  36006   "gmp 6.3.0"
-
-# merged in 10.2.beta3
-get_pr  36235   "ecl 23.9.9"
-
-# merged in 10.2.beta4
-get_pr  36279   "matplotlib 3.8.0"
+# merged in 10.2.rc0
+#get_pr  36544   "networkx 3.2"
+#get_pr  36543   "cython warning"
+#get_pr  36573   "relative imports"
+#get_pr  36600   "giac 1.9.0-67"
 
 # positive review
-#get_pr  36403   "python 3.12" # included in #36407
 
 # needs review
-get_pr  36407   "python 3.12"
+get_pr  35848   "flintlib 3.0"
+get_pr  36551   "fix qf.nbs"
+get_pr  36696   "fix SSL timeout"
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index a80d8b7187ece..49813f25e23e3 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,14 +1,14 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=10.1
-revision=4
+version=10.2.rc2
+revision=1
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
 _bindir=/usr/lib/sagemath/$version/bin
 make_install_args="--install-scripts=$_bindir"
-hostmakedepends="m4 pkg-config python3-Cython0.29 python3-Jinja2
+hostmakedepends="m4 pkg-config python3-Cython python3-Jinja2
  python3-pkgconfig python3-setuptools"
-makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
+makedepends="boost-devel brial-devel cliquer-devel ecl eclib-devel
  ecm-devel fflas-ffpack flintlib-devel gap-devel gd-devel giac-devel glpk-devel
  gsl-devel iml-devel lcalc-devel libbraiding-devel libhomfly-devel libmpc-devel
  libpng-devel linbox-devel m4ri-devel m4rie-devel mpfi-devel
@@ -18,7 +18,7 @@ makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
 depends="eclib-devel fflas-ffpack flintlib-devel gcc-fortran gd-devel
  gfan giac gsl-devel gzip libpng-devel linbox-devel m4ri-devel maxima-ecl
  mpfr-devel nauty ntl-devel palp pari-devel pari-elldata-small pari-galdata
- pari-galpol-small pari-seadata-small pkg-config python3-Cython0.29 python3-cypari2
+ pari-galpol-small pari-seadata-small pkg-config python3-Cython python3-cypari2
  python3-cysignals python3-devel python3-fpylll python3-ipython python3-lrcalc
  python3-ipython_ipykernel python3-jupyter_ipywidgets python3-matplotlib
  python3-memory_allocator python3-networkx python3-pip python3-pkgconfig
@@ -33,7 +33,7 @@ license="GPL-2.0-or-later"
 homepage="https://www.sagemath.org/"
 changelog="https://github.com/sagemath/sage/releases"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=a658612b1b2376ddaf207cc8ed0ef458d4c2880c16e19139bedbe8baa42ad62f
+checksum=dd17ed80553da21a9c0bba4be5f11ef476e9ef12effa61a37d077803e44fa891
 nocross="due to ntl (flintlib), fflas-ffpack, givaro, linbox, cysignals, sympow, maxima"
 
 post_patch() {
diff --git a/srcpkgs/sagemath/update b/srcpkgs/sagemath/update
index 68be3c5752d06..4e62503e2f8f4 100644
--- a/srcpkgs/sagemath/update
+++ b/srcpkgs/sagemath/update
@@ -1,2 +1,3 @@
 pkgname="sage"
-site="https://mirrors.mit.edu/sage/src/index.html"
+site="https://mirrors.mit.edu/sage/src/
+https://mirrors.mit.edu/sage/devel/"

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

* Re: [PR PATCH] [Updated] [RC] sagemath: update to 10.2, flintlib: update to 3.0.1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (8 preceding siblings ...)
  2023-11-12 19:38 ` [PR PATCH] [Updated] " tornaria
@ 2023-11-14 21:56 ` tornaria
  2023-11-15  0:51 ` tornaria
                   ` (18 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: tornaria @ 2023-11-14 21:56 UTC (permalink / raw)
  To: ml

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

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

https://github.com/tornaria/void-packages flintlib
https://github.com/void-linux/void-packages/pull/46832

[RC] sagemath: update to 10.2, flintlib: update to 3.0.1
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **briefly**

This is a major update. A couple of packages need rebuilding (eclib, singular).

For sagemath, we need a patch (in progress: https://github.com/sagemath/sage/pull/35848).

Since backporting patches is a pain and we are not in a hurry, I'm instead targeting 10.2.beta8. Note this already moves sagemath to cython 3.

The goal is to merge flintlib 3.0 together with sagemath 10.2 when the latter is released.

<!--
#### 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/46832.patch is attached

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

From 6d2f924d67bcdf7b516b3e9a4153ac9273ee7bcc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 11 Sep 2023 20:11:20 -0300
Subject: [PATCH 1/6] flintlib: update to 3.0.1.

---
 common/shlibs                                 |  3 +--
 srcpkgs/arb                                   |  1 +
 srcpkgs/arb-devel                             |  2 +-
 srcpkgs/arb/template                          | 24 -----------------
 .../patches/fix-test-t-sdiv_qrnnd.patch       | 23 ----------------
 srcpkgs/flintlib/template                     | 27 ++++++++++++++++---
 6 files changed, 26 insertions(+), 54 deletions(-)
 create mode 120000 srcpkgs/arb
 delete mode 100644 srcpkgs/arb/template
 delete mode 100644 srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch

diff --git a/common/shlibs b/common/shlibs
index 1a721780f8545..e43c51e9ea188 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3971,8 +3971,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.17 flintlib-2.9.0_1
-libarb.so.2 arb-2.20.0_1
+libflint.so.18 flintlib-3.0.0_1
 libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
diff --git a/srcpkgs/arb b/srcpkgs/arb
new file mode 120000
index 0000000000000..7c2633183069f
--- /dev/null
+++ b/srcpkgs/arb
@@ -0,0 +1 @@
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb-devel b/srcpkgs/arb-devel
index 456b9f00a86cd..7c2633183069f 120000
--- a/srcpkgs/arb-devel
+++ b/srcpkgs/arb-devel
@@ -1 +1 @@
-arb
\ No newline at end of file
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
deleted file mode 100644
index 84a62c7ffdba3..0000000000000
--- a/srcpkgs/arb/template
+++ /dev/null
@@ -1,24 +0,0 @@
-# Template file for 'arb'
-pkgname=arb
-version=2.23.0
-revision=1
-build_style=configure
-configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
-makedepends="flintlib-devel"
-short_desc="C library for arbitrary-precision interval arithmetic"
-maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
-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=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
-
-arb-devel_package() {
-	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"
-	short_desc+=" - development files"
-	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.a"
-		vmove "usr/lib/*.so"
-	}
-}
diff --git a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch b/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
deleted file mode 100644
index cfa109792892c..0000000000000
--- a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From fb8ddbcc06afa2a8f25637032fbb8211f6c6c122 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= <albin.ahlback@gmail.com>
-Date: Fri, 20 May 2022 14:16:38 +0200
-Subject: [PATCH] Fix bug in test code for GCC 12
-
----
- test/t-sdiv_qrnnd.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/test/t-sdiv_qrnnd.c b/test/t-sdiv_qrnnd.c
-index 2e9822e848..2676903826 100644
---- a/test/t-sdiv_qrnnd.c
-+++ b/test/t-sdiv_qrnnd.c
-@@ -33,7 +33,7 @@ int main(void)
-         {
-             d = n_randtest_not_zero(state);
-             nh = n_randtest(state);
--        } while ((FLINT_ABS(nh) >= FLINT_ABS(d)/2) || (nh == WORD_MIN));
-+        } while ((nh == WORD_MIN) || (FLINT_ABS(nh) >= FLINT_ABS(d)/2));
- 
-         nl = n_randtest(state);
- 
-
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index f7442c8052aaa..cbb73ee5f1438 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,10 +1,11 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.9.0
+version=3.0.1
 revision=1
-build_style=configure
+build_style=gnu-configure
 configure_args="--prefix=/usr $(vopt_with ntl)
- $(vopt_if openblas --with-blas=${XBPS_CROSS_BASE}/usr/include/openblas)"
+ $(vopt_if openblas --with-blas-include=${XBPS_CROSS_BASE}/usr/include/openblas)"
+hostmakedepends="automake gettext-devel libtool"
 makedepends="mpfr-devel $(vopt_if ntl ntl-devel)
  $(vopt_if openblas openblas-devel)"
 short_desc="Fast Library for Number Theory"
@@ -13,7 +14,7 @@ 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=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
+checksum=7b311a00503a863881eb8177dbeb84322f29399f3d7d72f3b1a4c9ba1d5794b4
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
@@ -28,12 +29,30 @@ esac
 
 CFLAGS="-D_GNU_SOURCE" # needed for cpu_set_t
 
+post_patch() {
+	# run autoconf because we patched configure.ac
+	autoreconf
+}
+
 flintlib-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision} mpfr-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
+		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
 		vmove "usr/lib/*.so"
 	}
 }
+
+arb_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}
+
+arb-devel_package() {
+	depends="${sourcepkg}-devel>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From 10c61ecaf2bafa4a93ab1e4fcb44512da5d19143 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:08:05 -0300
Subject: [PATCH 2/6] eclib: rebuild for flintlib-3.0.1

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

diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 1d4ad58f21b7b..12165ca788dd5 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
 version=20230424
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 makedepends="pari-devel ntl-devel flintlib-devel boost-devel"

From 56104369bb2129062fa2fe3dee977bfb15790c09 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:13:15 -0300
Subject: [PATCH 3/6] singular: update to 4.3.2p10.

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

diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index 036e19d470354..beb0e6d30118e 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,6 +1,6 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.2p7
+version=4.3.2p10
 revision=1
 _majver=${version%p*}
 build_style=gnu-configure
@@ -20,7 +20,7 @@ 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/${_majver//./-}/singular-${version}.tar.gz"
-checksum=aad23c30066b7fbc011138a98d60532565d76a847eec6bf2938410d93b272ca3
+checksum=28c2c9fcfee954e00dfa56eb1a7d418d5b1de67c4398d25a0f2b8f73e71552a8
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From 70b6360d40c0c080f1a4f55a0995ca08b393a324 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 19 Jul 2023 21:04:33 -0300
Subject: [PATCH 4/6] python3-pplpy: use cython 3.

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

diff --git a/srcpkgs/python3-pplpy/template b/srcpkgs/python3-pplpy/template
index 4a9c987b2a859..d3b9aebdf2237 100644
--- a/srcpkgs/python3-pplpy/template
+++ b/srcpkgs/python3-pplpy/template
@@ -1,9 +1,9 @@
 # Template file for 'python3-pplpy'
 pkgname=python3-pplpy
 version=0.8.9
-revision=1
+revision=2
 build_style=python3-pep517
-hostmakedepends="python3-setuptools python3-wheel python3-Cython0.29
+hostmakedepends="python3-setuptools python3-wheel python3-Cython
  python3-cysignals python3-gmpy2"
 makedepends="python3-devel gmp-devel gmpxx-devel ppl-devel mpfr-devel
  libmpc-devel pari-devel"

From 52695b631983e1f870c27fef71ee7dc41b9575dd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Thu, 19 Oct 2023 08:52:15 -0300
Subject: [PATCH 5/6] python3-networkx: update to 3.2.1.

---
 srcpkgs/python3-networkx/template | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/python3-networkx/template b/srcpkgs/python3-networkx/template
index 186bf64f7bff9..29283d9e5a032 100644
--- a/srcpkgs/python3-networkx/template
+++ b/srcpkgs/python3-networkx/template
@@ -1,11 +1,11 @@
 # Template file for 'python3-networkx'
 pkgname=python3-networkx
-version=3.1
-revision=2
-build_style=python3-module
+version=3.2.1
+revision=1
+build_style=python3-pep517
 # failing in i686
 make_check_args="--deselect networkx/algorithms/approximation/tests/test_traveling_salesman.py::test_asadpour_tsp"
-hostmakedepends="python3-setuptools"
+hostmakedepends="python3-setuptools python3-wheel"
 depends="python3"
 checkdepends="python3-numpy python3-scipy python3-matplotlib python3-pandas
  python3-lxml python3-sympy python3-pytest-xdist"
@@ -15,7 +15,7 @@ license="BSD-3-Clause"
 homepage="https://networkx.org"
 changelog="https://github.com/networkx/networkx/raw/main/doc/release/release_${version}.rst"
 distfiles="${PYPI_SITE}/n/networkx/networkx-${version}.tar.gz"
-checksum=de346335408f84de0eada6ff9fafafff9bcda11f0a0dfaa931133debb146ab61
+checksum=9f1bb5cf3409bf324e0a722c20bdb4c20ee39bf1c30ce8ae499c8502b0b5e0c6
 
 post_install() {
 	vlicense LICENSE.txt

From 9ae29daba338a2c0dddbd080b238af0c7aec8b22 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:50:44 -0300
Subject: [PATCH 6/6] sagemath: update to 10.2.rc2.

---
 .../sagemath/patches/35848-flintlib_3.0.patch | 1738 ++++++++++++++++
 .../patches/35934-singular_4.3.2p7.patch      |  221 ---
 .../sagemath/patches/36006-gmp_6.3.0.patch    |   38 -
 .../patches/36046-fix_memory_leak.patch       |  740 -------
 .../sagemath/patches/36235-ecl_23.9.9.patch   |   39 -
 .../patches/36279-matplotlib_3.8.0.patch      |   24 -
 srcpkgs/sagemath/patches/36403-00pre.patch    |   29 -
 .../sagemath/patches/36407-python_3.12.patch  | 1744 -----------------
 .../sagemath/patches/36551-fix_qf.nbs.patch   |  134 ++
 .../patches/36696-fix_SSL_timeout.patch       |   33 +
 srcpkgs/sagemath/patches/get_patches          |   27 +-
 srcpkgs/sagemath/template                     |   12 +-
 srcpkgs/sagemath/update                       |    3 +-
 13 files changed, 1922 insertions(+), 2860 deletions(-)
 create mode 100644 srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
 delete mode 100644 srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
 delete mode 100644 srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
 delete mode 100644 srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36403-00pre.patch
 delete mode 100644 srcpkgs/sagemath/patches/36407-python_3.12.patch
 create mode 100644 srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
 create mode 100644 srcpkgs/sagemath/patches/36696-fix_SSL_timeout.patch

diff --git a/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
new file mode 100644
index 0000000000000..c1e33e6a3c717
--- /dev/null
+++ b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
@@ -0,0 +1,1738 @@
+diff --git a/build/pkgs/antic/SPKG.rst b/build/pkgs/antic/SPKG.rst
+deleted file mode 100644
+index d6c32377957..00000000000
+--- a/build/pkgs/antic/SPKG.rst
++++ /dev/null
+@@ -1,18 +0,0 @@
+-antic: Algebraic Number Theory In C
+-===================================
+-
+-Description
+------------
+-
+-Algebraic Number Theory In C
+-
+-License
+--------
+-
+-LGPL 2.1
+-
+-Upstream Contact
+-----------------
+-
+-https://github.com/wbhart/antic
+-
+diff --git a/build/pkgs/antic/checksums.ini b/build/pkgs/antic/checksums.ini
+deleted file mode 100644
+index fc8711ecd13..00000000000
+--- a/build/pkgs/antic/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=antic-VERSION.tar.gz
+-sha1=940d8ea2c3512b9d49ee3101cf043f777764bd8f
+-md5=4e896420dd6344b53b307871efb2cbb4
+-cksum=1938565125
+-upstream_url=https://github.com/wbhart/antic/archive/refs/tags/vVERSION.tar.gz
+diff --git a/build/pkgs/antic/dependencies b/build/pkgs/antic/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/antic/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/antic/distros/arch.txt b/build/pkgs/antic/distros/arch.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/conda.txt b/build/pkgs/antic/distros/conda.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/debian.txt b/build/pkgs/antic/distros/debian.txt
+deleted file mode 100644
+index 8fdcd3e5721..00000000000
+--- a/build/pkgs/antic/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libantic-dev
+diff --git a/build/pkgs/antic/distros/fedora.txt b/build/pkgs/antic/distros/fedora.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/freebsd.txt b/build/pkgs/antic/distros/freebsd.txt
+deleted file mode 100644
+index 116ff3a26f3..00000000000
+--- a/build/pkgs/antic/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/antic
+diff --git a/build/pkgs/antic/distros/opensuse.txt b/build/pkgs/antic/distros/opensuse.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/repology.txt b/build/pkgs/antic/distros/repology.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/package-version.txt b/build/pkgs/antic/package-version.txt
+deleted file mode 100644
+index 3a4036fb450..00000000000
+--- a/build/pkgs/antic/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-0.2.5
+diff --git a/build/pkgs/antic/spkg-install.in b/build/pkgs/antic/spkg-install.in
+deleted file mode 100644
+index c57fa884a20..00000000000
+--- a/build/pkgs/antic/spkg-install.in
++++ /dev/null
+@@ -1,19 +0,0 @@
+-cd src
+-
+-# Copied from build/pkgs/flint/spkg-install.in:
+-#   Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-#   --with-ntl because otherwise FLINT's configure script uses
+-#   /usr/local, which is always wrong.
+-#   This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-#   The value $SAGE_LOCAL is always a safe choice even if the library
+-#   is coming from the system and is found using what is in
+-#   LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-flint="$SAGE_LOCAL"  || sdh_die "Error: Failed to configure antic."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/antic/type b/build/pkgs/antic/type
+deleted file mode 100644
+index 134d9bc32d5..00000000000
+--- a/build/pkgs/antic/type
++++ /dev/null
+@@ -1 +0,0 @@
+-optional
+diff --git a/build/pkgs/arb/SPKG.rst b/build/pkgs/arb/SPKG.rst
+deleted file mode 100644
+index cff49ddb95b..00000000000
+--- a/build/pkgs/arb/SPKG.rst
++++ /dev/null
+@@ -1,27 +0,0 @@
+-arb: Arbitrary-precision floating-point ball arithmetic
+-=======================================================
+-
+-Description
+------------
+-
+-Arb is a C library for arbitrary-precision floating-point ball
+-arithmetic, developed by Fredrik Johansson
+-(fredrik.johansson@gmail.com). It supports efficient high-precision
+-computation with polynomials, power series, matrices and special
+-functions over the real and complex numbers, with automatic, rigorous
+-error control.
+-
+-License
+--------
+-
+-GNU General Public License v2+
+-
+-
+-Upstream Contact
+-----------------
+-
+- - Fredrik Johansson: fredrik.johansson@gmail.com
+-
+- - https://arblib.org/
+-
+- - http://github.com/fredrik-johansson/arb/
+diff --git a/build/pkgs/arb/checksums.ini b/build/pkgs/arb/checksums.ini
+deleted file mode 100644
+index 80ef43dad5d..00000000000
+--- a/build/pkgs/arb/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=arb-VERSION.tar.gz
+-sha1=a1efe035dd3af3613dd685971a156f652b86ff63
+-md5=9b369e29f93cdf2d4f90b57a92526cce
+-cksum=64252121
+-upstream_url=https://github.com/fredrik-johansson/arb/archive/VERSION.tar.gz
+diff --git a/build/pkgs/arb/dependencies b/build/pkgs/arb/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/arb/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/arb/distros/arch.txt b/build/pkgs/arb/distros/arch.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/conda.txt b/build/pkgs/arb/distros/conda.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/debian.txt b/build/pkgs/arb/distros/debian.txt
+deleted file mode 100644
+index 9fe71110712..00000000000
+--- a/build/pkgs/arb/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libflint-arb-dev
+diff --git a/build/pkgs/arb/distros/fedora.txt b/build/pkgs/arb/distros/fedora.txt
+deleted file mode 100644
+index 76794404627..00000000000
+--- a/build/pkgs/arb/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb arb-devel
+diff --git a/build/pkgs/arb/distros/freebsd.txt b/build/pkgs/arb/distros/freebsd.txt
+deleted file mode 100644
+index 2ef8c7cec0f..00000000000
+--- a/build/pkgs/arb/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/arb
+diff --git a/build/pkgs/arb/distros/gentoo.txt b/build/pkgs/arb/distros/gentoo.txt
+deleted file mode 100644
+index 58e3d4f8008..00000000000
+--- a/build/pkgs/arb/distros/gentoo.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-sci-mathematics/arb
+diff --git a/build/pkgs/arb/distros/homebrew.txt b/build/pkgs/arb/distros/homebrew.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/homebrew.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/nix.txt b/build/pkgs/arb/distros/nix.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/nix.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/opensuse.txt b/build/pkgs/arb/distros/opensuse.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/distros/repology.txt b/build/pkgs/arb/distros/repology.txt
+deleted file mode 100644
+index 179c9d507e1..00000000000
+--- a/build/pkgs/arb/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-fp
+diff --git a/build/pkgs/arb/distros/void.txt b/build/pkgs/arb/distros/void.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/void.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/package-version.txt b/build/pkgs/arb/package-version.txt
+deleted file mode 100644
+index e9763f6bfed..00000000000
+--- a/build/pkgs/arb/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-2.23.0
+diff --git a/build/pkgs/arb/spkg-check.in b/build/pkgs/arb/spkg-check.in
+deleted file mode 100644
+index 27cd9419538..00000000000
+--- a/build/pkgs/arb/spkg-check.in
++++ /dev/null
+@@ -1,2 +0,0 @@
+-cd src
+-$MAKE check
+diff --git a/build/pkgs/arb/spkg-configure.m4 b/build/pkgs/arb/spkg-configure.m4
+deleted file mode 100644
+index ef2dd0aac4a..00000000000
+--- a/build/pkgs/arb/spkg-configure.m4
++++ /dev/null
+@@ -1,23 +0,0 @@
+-SAGE_SPKG_CONFIGURE([arb], [
+-    AC_REQUIRE([SAGE_SPKG_CONFIGURE_FLINT])
+-    SAGE_ARB_LIBRARY="arb"
+-    AC_MSG_CHECKING([installing flint? ])
+-    if test x$sage_spkg_install_flint = xyes; then
+-        AC_MSG_RESULT([yes; install arb as well])
+-        sage_spkg_install_arb=yes
+-    else
+-        AC_CHECK_HEADER(arb.h, [
+-        dnl below function added in version 2.16 of arb
+-            AC_CHECK_LIB([arb], [acb_mat_eig_simple], [],
+-              [dnl in Debian the name of dylib is different.
+-               AC_CHECK_LIB([flint-arb], [acb_mat_eig_simple],
+-                [SAGE_ARB_LIBRARY="flint-arb"], [sage_spkg_install_arb=yes])])
+-        ], [sage_spkg_install_arb=yes])
+-    fi
+-], [], [], [
+-    if test x$sage_spkg_install_arb = xyes; then
+-        AC_SUBST(SAGE_ARB_LIBRARY,["arb"])
+-    else
+-        AC_SUBST(SAGE_ARB_LIBRARY,[$SAGE_ARB_LIBRARY])
+-    fi
+-])
+diff --git a/build/pkgs/arb/spkg-install.in b/build/pkgs/arb/spkg-install.in
+deleted file mode 100644
+index 9322f04c912..00000000000
+--- a/build/pkgs/arb/spkg-install.in
++++ /dev/null
+@@ -1,17 +0,0 @@
+-cd src
+-
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-flint because otherwise ARB's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure --disable-static --prefix="$SAGE_LOCAL" \
+-        --with-gmp="$SAGE_LOCAL" \
+-        --with-mpfr="$SAGE_LOCAL" \
+-        --with-flint="$SAGE_LOCAL" || \
+-    sdh_die "Error configuring arb."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/arb/type b/build/pkgs/arb/type
+deleted file mode 100644
+index a6a7b9cd726..00000000000
+--- a/build/pkgs/arb/type
++++ /dev/null
+@@ -1 +0,0 @@
+-standard
+diff --git a/build/pkgs/e_antic/dependencies b/build/pkgs/e_antic/dependencies
+index fea1ffbda45..8e977a55c13 100644
+--- a/build/pkgs/e_antic/dependencies
++++ b/build/pkgs/e_antic/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) flint arb antic boost_cropped
++$(MP_LIBRARY) flint boost_cropped
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/SPKG.rst b/build/pkgs/flint/SPKG.rst
+index f91de70d1ff..d9dcea0903b 100644
+--- a/build/pkgs/flint/SPKG.rst
++++ b/build/pkgs/flint/SPKG.rst
+@@ -4,8 +4,8 @@ flint: Fast Library for Number Theory
+ Description
+ -----------
+ 
+-FLINT is a C library for doing number theory, maintained by William
+-Hart.
++FLINT is a C library for doing number theory, maintained by
++Fredrik Johansson.
+ 
+ Website: http://www.flintlib.org
+ 
+@@ -20,4 +20,4 @@ Upstream Contact
+ 
+ -  flint-devel Gougle Group
+    (http://groups.google.co.uk/group/flint-devel)
+--  William Hart
++-  Fredrik Johansson
+diff --git a/build/pkgs/flint/checksums.ini b/build/pkgs/flint/checksums.ini
+index 3d449d98064..2cec823bfb1 100644
+--- a/build/pkgs/flint/checksums.ini
++++ b/build/pkgs/flint/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=flint-VERSION.tar.gz
+-sha1=63d90f8242c8f8ab4011fbcfb44b86c154f43abd
+-md5=c2d3cec326438f159a530c66eb07fafe
+-cksum=4244948341
+-upstream_url=http://flintlib.org/flint-VERSION.tar.gz
++sha1=c548b1d5eb86a1805de9bef56629455b61e873f7
++md5=24551d4e475290ce6b831c78fafb5efb
++cksum=1567352998
++upstream_url=https://github.com/flintlib/flint/releases/download/vVERSION/flint-VERSION.tar.gz
+diff --git a/build/pkgs/flint/dependencies b/build/pkgs/flint/dependencies
+index 385df4faa7d..1108dc4fb21 100644
+--- a/build/pkgs/flint/dependencies
++++ b/build/pkgs/flint/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) mpfr ntl
++$(MP_LIBRARY) mpfr
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/package-version.txt b/build/pkgs/flint/package-version.txt
+index c8e38b61405..4a36342fcab 100644
+--- a/build/pkgs/flint/package-version.txt
++++ b/build/pkgs/flint/package-version.txt
+@@ -1 +1 @@
+-2.9.0
++3.0.0
+diff --git a/build/pkgs/flint/spkg-build.in b/build/pkgs/flint/spkg-build.in
+new file mode 100644
+index 00000000000..ffb822c8a97
+--- /dev/null
++++ b/build/pkgs/flint/spkg-build.in
+@@ -0,0 +1,3 @@
++cd src
++sdh_configure
++sdh_make
+diff --git a/build/pkgs/flint/spkg-configure.m4 b/build/pkgs/flint/spkg-configure.m4
+index a58108c9d6e..9576e4cc1e9 100644
+--- a/build/pkgs/flint/spkg-configure.m4
++++ b/build/pkgs/flint/spkg-configure.m4
+@@ -1,25 +1,8 @@
+ SAGE_SPKG_CONFIGURE([flint], [
+-    SAGE_SPKG_DEPCHECK([mpfr ntl], [
++    SAGE_SPKG_DEPCHECK([mpfr], [
+         AC_CHECK_HEADER(flint/flint.h, [
+-          dnl flint_parallel_binary_splitting appears in Flint 2.9.0, needed by arb 2.23
+-          AC_SEARCH_LIBS([flint_parallel_binary_splitting], [flint], [
+-            dnl check that NTL is linked in
+-            AC_SEARCH_LIBS([fmpz_poly_get_ZZX], [flint], [
+-
+-              AC_MSG_CHECKING([that GC is not enabled in Flint... ])
+-              AC_RUN_IFELSE([
+-                 AC_LANG_PROGRAM([[#include <flint/flint.h>]], [
+-                                  [#ifdef HAVE_GC]
+-                                     [return HAVE_GC;]
+-                                  [#else]
+-                                     [return 0;]
+-                                  [#endif]])],
+-                 [AC_MSG_RESULT([GC not enabled. Good.])],
+-                        [AC_MSG_RESULT([GC enabled. Incompatible with Sage.])
+-                         sage_spkg_install_flint=yes],
+-                 [AC_MSG_RESULT(["cross compiling. assuming GC is not enabled"])])
+-            ], [sage_spkg_install_flint=yes])
+-          ], [sage_spkg_install_flint=yes])
++          dnl gr_get_fexpr appears in Flint 3.0
++          AC_SEARCH_LIBS([gr_get_fexpr], [flint], [], [sage_spkg_install_flint=yes])
+         ], [sage_spkg_install_flint=yes])
+     ])
+ ], [], [], [
+diff --git a/build/pkgs/flint/spkg-install.in b/build/pkgs/flint/spkg-install.in
+index eacd7b6e491..3ea8c053669 100644
+--- a/build/pkgs/flint/spkg-install.in
++++ b/build/pkgs/flint/spkg-install.in
+@@ -1,36 +1,2 @@
+-###############################################################################
+-#
+-# FLINT Sage install script
+-#
+-###############################################################################
+-if [ "$SAGE_DEBUG" = "yes" ]; then
+-    echo "Building a debug version of FLINT."
+-    FLINT_TUNE=" $FLINT_TUNE"; export FLINT_TUNE
+-    FLINT_CONFIGURE="--enable-assert $FLINT_CONFIGURE"
+-fi
+-
+ cd src
+-
+-echo "Configuring FLINT."
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-ntl because otherwise FLINT's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-ntl="$SAGE_LOCAL" \
+-    $FLINT_CONFIGURE || sdh_die "Error: Failed to configure FLINT."
+-
+-sdh_make verbose
+-
+-echo "Deleting old FLINT files."
+-rm -f $SAGE_LOCAL/lib/libflint*
+-rm -rf $SAGE_LOCAL/include/flint
+-
+ sdh_make_install
+diff --git a/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+new file mode 100644
+index 00000000000..27a642a13b0
+--- /dev/null
++++ b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+@@ -0,0 +1,53 @@
++From fe730579476de0b2d4181a38efa7f63dff9c81d7 Mon Sep 17 00:00:00 2001
++From: Marc Mezzarobba <marc@mezzarobba.net>
++Date: Tue, 12 Sep 2023 08:23:08 +0200
++Subject: [PATCH] Make msolve build with flint3
++
++---
++ src/fglm/berlekamp_massey.c | 3 +++
++ src/fglm/data_fglm.c        | 7 +++++--
++ 2 files changed, 8 insertions(+), 2 deletions(-)
++
++diff --git a/src/fglm/berlekamp_massey.c b/src/fglm/berlekamp_massey.c
++index b0f2052..998af1c 100644
++--- a/src/fglm/berlekamp_massey.c
+++++ b/src/fglm/berlekamp_massey.c
++@@ -30,6 +30,9 @@
++ */
++ 
++ #include <stdlib.h>
+++#if __FLINT_VERSION >= 3
+++#  include <flint/nmod.h>
+++#endif
++ //#include "nmod_poly.h"
++ //#include "mpn_extras.h"
++ 
++diff --git a/src/fglm/data_fglm.c b/src/fglm/data_fglm.c
++index 0726760..0e1da6f 100644
++--- a/src/fglm/data_fglm.c
+++++ b/src/fglm/data_fglm.c
++@@ -24,6 +24,7 @@
++ #include <flint/mpn_extras.h>
++ #include <flint/nmod_poly.h>
++ #include <flint/nmod_poly_factor.h>
+++#include <flint/ulong_extras.h>
++ 
++ 
++ typedef uint32_t szmat_t;
++@@ -299,9 +300,11 @@ static inline void nmod_poly_set_prime(nmod_poly_t poly,
++   mp_limb_t ninv = n_preinvert_limb(prime);
++   poly->mod.n = prime;
++   poly->mod.ninv = ninv;
+++#if __FLINT_VERSION < 3
++   count_leading_zeros(poly->mod.norm, prime);
++-  /* poly->mod.norm = flint_clz(prime); */
++-
+++#else
+++  poly->mod.norm = flint_clz(prime);
+++#endif
++ }
++ 
++ static inline void fglm_param_set_prime(param_t *param, mp_limb_t prime){
++-- 
++2.40.1
++
+diff --git a/build/pkgs/sagelib/dependencies b/build/pkgs/sagelib/dependencies
+index 5dc2efe1d31..fa6e98df7db 100644
+--- a/build/pkgs/sagelib/dependencies
++++ b/build/pkgs/sagelib/dependencies
+@@ -1,4 +1,4 @@
+-FORCE $(SCRIPTS) arb boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
++FORCE $(SCRIPTS) boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/symengine/dependencies b/build/pkgs/symengine/dependencies
+index 1fc34963eda..7795d486018 100644
+--- a/build/pkgs/symengine/dependencies
++++ b/build/pkgs/symengine/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) arb ecm flint mpc mpfr | cmake
++$(MP_LIBRARY) ecm flint mpc mpfr | cmake
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/pkgs/sage-conf/_sage_conf/_conf.py.in b/pkgs/sage-conf/_sage_conf/_conf.py.in
+index 87b27ca05cb..895d6572d1e 100644
+--- a/pkgs/sage-conf/_sage_conf/_conf.py.in
++++ b/pkgs/sage-conf/_sage_conf/_conf.py.in
+@@ -19,8 +19,6 @@ MAXIMA_FAS = "@SAGE_MAXIMA_FAS@".replace('${prefix}', SAGE_LOCAL)
+ # Delete this line if your ECL can load Kenzo without further prodding.
+ KENZO_FAS = "@SAGE_KENZO_FAS@".replace('${prefix}', SAGE_LOCAL)
+ 
+-ARB_LIBRARY = "@SAGE_ARB_LIBRARY@"
+-
+ NTL_INCDIR = "@NTL_INCDIR@"
+ NTL_LIBDIR = "@NTL_LIBDIR@"
+ 
+diff --git a/src/sage/env.py b/src/sage/env.py
+index b1fe9a89cd1..9197fc3a703 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -223,7 +223,6 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st
+ FOURTITWO_PPI = var("FOURTITWO_PPI")
+ FOURTITWO_CIRCUITS = var("FOURTITWO_CIRCUITS")
+ FOURTITWO_GROEBNER = var("FOURTITWO_GROEBNER")
+-ARB_LIBRARY = var("ARB_LIBRARY", "arb")
+ CBLAS_PC_MODULES = var("CBLAS_PC_MODULES", "cblas:openblas:blas")
+ ECL_CONFIG = var("ECL_CONFIG", "ecl-config")
+ NTL_INCDIR = var("NTL_INCDIR")
+@@ -356,8 +355,7 @@ def cython_aliases(required_modules=None,
+         sage: cython_aliases()
+         {...}
+         sage: sorted(cython_aliases().keys())
+-        ['ARB_LIBRARY',
+-         'CBLAS_CFLAGS',
++        ['CBLAS_CFLAGS',
+          ...,
+          'ZLIB_LIBRARIES']
+         sage: cython_aliases(required_modules=('module-that-is-assumed-to-not-exist'))
+@@ -475,8 +473,6 @@ def uname_specific(name, value, alternative):
+     if "LINBOX_CFLAGS" in aliases:
+         aliases["LINBOX_CFLAGS"].append("-std=gnu++11")
+ 
+-    aliases["ARB_LIBRARY"] = ARB_LIBRARY
+-
+     # TODO: Remove Cygwin hack by installing a suitable cblas.pc
+     if os.path.exists('/usr/lib/libblas.dll.a'):
+         aliases["CBLAS_LIBS"] = ['gslcblas']
+diff --git a/src/sage/features/sagemath.py b/src/sage/features/sagemath.py
+index 7404e6d0a8e..6037d097391 100644
+--- a/src/sage/features/sagemath.py
++++ b/src/sage/features/sagemath.py
+@@ -761,7 +761,7 @@ class sage__rings__number_field(JoinFeature):
+     A :class:`~sage.features.Feature` describing the presence of :mod:`sage.rings.number_field`.
+ 
+     Number fields are implemented in Sage using a complicated mixture of various libraries,
+-    including :ref:`arb <spkg_arb>`, :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
++    including :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
+     :ref:`MPFI <spkg_mpfi>`, :ref:`NTL <spkg_ntl>`, and :ref:`PARI <spkg_pari>`.
+ 
+     EXAMPLES:
+diff --git a/src/sage/libs/arb/acb.pxd b/src/sage/libs/arb/acb.pxd
+index 5148dc43991..851488d803a 100644
+--- a/src/sage/libs/arb/acb.pxd
++++ b/src/sage/libs/arb/acb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -152,10 +152,6 @@ cdef extern from "arb_wrap.h":
+     void acb_sech(acb_t s, const acb_t z, long prec)
+     void acb_csch(acb_t c, const acb_t z, long prec)
+ 
+-    void acb_rising_ui_bs(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui_rs(acb_t z, const acb_t x, unsigned long n, unsigned long step, long prec)
+-    void acb_rising_ui_rec(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui(acb_t z, const acb_t x, unsigned long n, long prec)
+     void acb_rising(acb_t z, const acb_t x, const acb_t n, long prec)
+ 
+     void acb_gamma(acb_t y, const acb_t x, long prec)
+diff --git a/src/sage/libs/arb/acb_calc.pxd b/src/sage/libs/arb/acb_calc.pxd
+index a5dbf360b5e..67bd2ed57dc 100644
+--- a/src/sage/libs/arb/acb_calc.pxd
++++ b/src/sage/libs/arb/acb_calc.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_calc.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_elliptic.pxd b/src/sage/libs/arb/acb_elliptic.pxd
+index 176f68df00e..e3480e9f73b 100644
+--- a/src/sage/libs/arb/acb_elliptic.pxd
++++ b/src/sage/libs/arb/acb_elliptic.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_elliptic.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_hypgeom.pxd b/src/sage/libs/arb/acb_hypgeom.pxd
+index 418e766f10d..c43e5c0623b 100644
+--- a/src/sage/libs/arb/acb_hypgeom.pxd
++++ b/src/sage/libs/arb/acb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_hypgeom.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_modular.pxd b/src/sage/libs/arb/acb_modular.pxd
+index c708e9bf97d..cdc413c92da 100644
+--- a/src/sage/libs/arb/acb_modular.pxd
++++ b/src/sage/libs/arb/acb_modular.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_modular.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_poly.pxd b/src/sage/libs/arb/acb_poly.pxd
+index 69f4320055b..ae02757ffd9 100644
+--- a/src/sage/libs/arb/acb_poly.pxd
++++ b/src/sage/libs/arb/acb_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -79,24 +79,10 @@ cdef extern from "arb_wrap.h":
+     void _acb_poly_divrem(acb_ptr Q, acb_ptr R, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec)
+     bint acb_poly_divrem(acb_poly_t Q, acb_poly_t R, const acb_poly_t A, const acb_poly_t B, long prec)
+     void _acb_poly_div_root(acb_ptr Q, acb_t R, acb_srcptr A, long len, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_horner(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_horner(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_divconquer(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_divconquer(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_convolution(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_convolution(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+     void _acb_poly_taylor_shift(acb_ptr g, const acb_t c, long n, long prec)
+     void acb_poly_taylor_shift(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_compose_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_divconquer(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_divconquer(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+     void _acb_poly_compose(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+     void acb_poly_compose(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_series_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+-    void _acb_poly_compose_series_brent_kung(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_brent_kung(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_compose_series(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+     void acb_poly_compose_series(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_revert_series_lagrange(acb_ptr h, acb_srcptr f, long flen, long n, long prec)
+@@ -161,10 +147,6 @@ cdef extern from "arb_wrap.h":
+     void acb_poly_exp_series_basecase(acb_poly_t f, const acb_poly_t h, long n, long prec)
+     void _acb_poly_exp_series(acb_ptr f, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_exp_series(acb_poly_t f, const acb_poly_t h, long n, long prec)
+-    void _acb_poly_sin_cos_series_basecase(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_basecase(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+-    void _acb_poly_sin_cos_series_tangent(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_tangent(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+     void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_sin_cos_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec)
+     void _acb_poly_sin_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec)
+diff --git a/src/sage/libs/arb/arb.pxd b/src/sage/libs/arb/arb.pxd
+index c82b94de30f..acd232ab816 100644
+--- a/src/sage/libs/arb/arb.pxd
++++ b/src/sage/libs/arb/arb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -224,15 +224,8 @@ cdef extern from "arb_wrap.h":
+ 
+     void arb_lambertw(arb_t res, const arb_t x, int flags, long prec)
+ 
+-    void arb_rising_ui_bs(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui_rs(arb_t z, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising_ui_rec(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui(arb_t z, const arb_t x, unsigned long n, long prec)
+     void arb_rising(arb_t z, const arb_t x, const arb_t n, long prec)
+     void arb_rising_fmpq_ui(arb_t z, const fmpq_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_bs(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_rs(arb_t u, arb_t v, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising2_ui(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+     void arb_fac_ui(arb_t z, unsigned long n, long prec)
+     void arb_bin_ui(arb_t z, const arb_t n, unsigned long k, long prec)
+     void arb_bin_uiui(arb_t z, unsigned long n, unsigned long k, long prec)
+diff --git a/src/sage/libs/arb/arb_fmpz_poly.pxd b/src/sage/libs/arb/arb_fmpz_poly.pxd
+index 079f76e9d9e..55daa705238 100644
+--- a/src/sage/libs/arb/arb_fmpz_poly.pxd
++++ b/src/sage/libs/arb/arb_fmpz_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_fmpz_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -22,5 +22,4 @@ cdef extern from "arb_wrap.h":
+     unsigned long arb_fmpz_poly_deflation(const fmpz_poly_t poly)
+     void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long deflation)
+     void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, long prec)
+-    void arb_fmpz_poly_cos_minpoly(fmpz_poly_t res, unsigned long n)
+     void arb_fmpz_poly_gauss_period_minpoly(fmpz_poly_t res, unsigned long q, unsigned long n)
+diff --git a/src/sage/libs/arb/arb_hypgeom.pxd b/src/sage/libs/arb/arb_hypgeom.pxd
+index fb1c40ddaa8..139b987d669 100644
+--- a/src/sage/libs/arb/arb_hypgeom.pxd
++++ b/src/sage/libs/arb/arb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_hypgeom.h
+ 
+ from sage.libs.flint.types cimport fmpz_t
+diff --git a/src/sage/libs/arb/arb_wrap.h b/src/sage/libs/arb/arb_wrap.h
+index 49997075ee5..488bb376d5e 100644
+--- a/src/sage/libs/arb/arb_wrap.h
++++ b/src/sage/libs/arb/arb_wrap.h
+@@ -5,25 +5,27 @@
+  * by arb, most of which rely on flint's ulong and slong defines.
+  */
+ 
++#include <mpfr.h>
++
+ #undef ulong
+ #undef slong
+ 
+ #define ulong mp_limb_t
+ #define slong mp_limb_signed_t
+ 
+-#include <acb.h>
+-#include <acb_calc.h>
+-#include <acb_elliptic.h>
+-#include <acb_hypgeom.h>
+-#include <acb_mat.h>
+-#include <acb_modular.h>
+-#include <acb_poly.h>
+-#include <arb.h>
+-#include <arb_fmpz_poly.h>
+-#include <arb_hypgeom.h>
+-#include <arf.h>
+-#include <bernoulli.h>
+-#include <mag.h>
++#include <flint/acb.h>
++#include <flint/acb_calc.h>
++#include <flint/acb_elliptic.h>
++#include <flint/acb_hypgeom.h>
++#include <flint/acb_mat.h>
++#include <flint/acb_modular.h>
++#include <flint/acb_poly.h>
++#include <flint/arb.h>
++#include <flint/arb_fmpz_poly.h>
++#include <flint/arb_hypgeom.h>
++#include <flint/arf.h>
++#include <flint/bernoulli.h>
++#include <flint/mag.h>
+ 
+ #undef ulong
+ #undef slong
+diff --git a/src/sage/libs/arb/arf.pxd b/src/sage/libs/arb/arf.pxd
+index b8b83fefcdc..84778fe9f09 100644
+--- a/src/sage/libs/arb/arf.pxd
++++ b/src/sage/libs/arb/arf.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arf.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -30,7 +30,6 @@ cdef extern from "arb_wrap.h":
+     void arf_set_ui(arf_t y, unsigned long x)
+     void arf_set_si(arf_t y, long x)
+     void arf_set_mpfr(arf_t y, const mpfr_t x)
+-    # void arf_set_fmpr(arf_t y, const fmpr_t x)
+     void arf_set_d(arf_t y, double x)
+     void arf_swap(arf_t y, arf_t x)
+     void arf_init_set_ui(arf_t y, unsigned long x)
+@@ -46,7 +45,6 @@ cdef extern from "arb_wrap.h":
+     int arf_set_round_fmpz_2exp(arf_t y, const fmpz_t x, const fmpz_t e, long prec, arf_rnd_t rnd)
+     void arf_get_fmpz_2exp(fmpz_t m, fmpz_t e, const arf_t x)
+     double arf_get_d(const arf_t x, arf_rnd_t rnd)
+-    # void arf_get_fmpr(fmpr_t y, const arf_t x)
+     int arf_get_mpfr(mpfr_t y, const arf_t x, mpfr_rnd_t rnd)
+     void arf_get_fmpz(fmpz_t z, const arf_t x, arf_rnd_t rnd)
+     long arf_get_si(const arf_t x, arf_rnd_t rnd)
+diff --git a/src/sage/libs/arb/bernoulli.pxd b/src/sage/libs/arb/bernoulli.pxd
+index 375b2b9bbcf..ea9340f4b15 100644
+--- a/src/sage/libs/arb/bernoulli.pxd
++++ b/src/sage/libs/arb/bernoulli.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = bernoulli.h
+ 
+ from ..flint.types cimport fmpq_t, ulong
+diff --git a/src/sage/libs/arb/mag.pxd b/src/sage/libs/arb/mag.pxd
+index d5d8693ea8f..69dfb990ae0 100644
+--- a/src/sage/libs/arb/mag.pxd
++++ b/src/sage/libs/arb/mag.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = mag.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -27,13 +27,11 @@ cdef extern from "arb_wrap.h":
+     # void mag_randtest(mag_t x, flint_rand_t state, long expbits)
+     # void mag_randtest_special(mag_t x, flint_rand_t state, long expbits)
+     void mag_set_d(mag_t y, double x)
+-    # void mag_set_fmpr(mag_t y, const fmpr_t x)
+     void mag_set_ui(mag_t y, unsigned long x)
+     void mag_set_fmpz(mag_t y, const fmpz_t x)
+     void mag_set_d_2exp_fmpz(mag_t z, double x, const fmpz_t y)
+     void mag_set_fmpz_2exp_fmpz(mag_t z, const fmpz_t x, const fmpz_t y)
+     void mag_set_ui_2exp_si(mag_t z, unsigned long x, long y)
+-    # void mag_get_fmpr(fmpr_t y, const mag_t x)
+     void mag_get_fmpq(fmpq_t y, const mag_t x)
+     void mag_set_ui_lower(mag_t z, unsigned long x)
+     void mag_set_fmpz_lower(mag_t z, const fmpz_t x)
+diff --git a/src/sage/libs/flint/flint_wrap.h b/src/sage/libs/flint/flint_wrap.h
+index 266535c3835..4db72b97660 100644
+--- a/src/sage/libs/flint/flint_wrap.h
++++ b/src/sage/libs/flint/flint_wrap.h
+@@ -15,6 +15,7 @@
+  */
+ 
+ #include <gmp.h>
++#include <mpfr.h>
+ 
+ /* Save previous definition of ulong if any, as pari also uses it */
+ /* Should work on GCC, clang, MSVC */
+@@ -33,6 +34,7 @@
+ 
+ #include <flint/arith.h>
+ #include <flint/fmpq.h>
++#include <flint/fmpq_vec.h>
+ #include <flint/fmpq_mat.h>
+ #include <flint/fmpq_poly.h>
+ #include <flint/fmpz.h>
+@@ -47,6 +49,7 @@
+ #include <flint/fq.h>
+ #include <flint/fq_nmod.h>
+ #include <flint/nmod_poly.h>
++#include <flint/nmod_poly_factor.h>
+ #include <flint/nmod_vec.h>
+ #include <flint/padic.h>
+ #include <flint/padic_poly.h>
+diff --git a/src/sage/libs/flint/fmpq.pxd b/src/sage/libs/flint/fmpq.pxd
+index 5e64c82102f..0616c0a7408 100644
+--- a/src/sage/libs/flint/fmpq.pxd
++++ b/src/sage/libs/flint/fmpq.pxd
+@@ -12,6 +12,8 @@ cdef extern from "flint_wrap.h":
+     fmpz * fmpq_denref(fmpq_t)
+     void fmpq_init(fmpq_t)
+     void fmpq_clear(fmpq_t)
++    void fmpq_init_set_readonly(fmpq_t, const mpq_t)
++    void fmpq_clear_readonly(fmpq_t)
+     void fmpq_one(fmpq_t)
+     void fmpq_zero(fmpq_t)
+     bint fmpq_is_zero(fmpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pxd b/src/sage/libs/flint/fmpq_poly.pxd
+index 6050c487835..afa16e5bbdd 100644
+--- a/src/sage/libs/flint/fmpq_poly.pxd
++++ b/src/sage/libs/flint/fmpq_poly.pxd
+@@ -30,6 +30,9 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_canonicalise(fmpq_poly_t)
+     int fmpq_poly_is_canonical(const fmpq_poly_t)
+ 
++    void _fmpq_poly_set_length(fmpq_poly_t, slong)
++    void _fmpq_poly_normalise(fmpq_poly_t)
++
+     # Polynomial parameters
+     slong fmpq_poly_degree(const fmpq_poly_t)
+     ulong fmpq_poly_length(const fmpq_poly_t)
+@@ -46,10 +49,7 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_ui(fmpq_poly_t, ulong)
+     void fmpq_poly_set_fmpz(fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_set_fmpq(fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+     void fmpq_poly_set_fmpz_poly(fmpq_poly_t, const fmpz_poly_t)
+-    void fmpq_poly_set_array_mpq(fmpq_poly_t, const mpq_t *, slong)
+ 
+     void fmpq_poly_set_str(fmpq_poly_t, const char *)
+     char *fmpq_poly_get_str(const fmpq_poly_t)
+@@ -67,7 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_reverse(fmpq_poly_t, const fmpq_poly_t, slong)
+ 
+     void fmpq_poly_get_coeff_fmpq(fmpq_t, const fmpq_poly_t, slong)
+-    void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_si(slong, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_ui(ulong, const fmpq_poly_t, slong)
+ 
+@@ -75,8 +74,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_coeff_ui(fmpq_poly_t, slong, ulong)
+     void fmpq_poly_set_coeff_fmpz(fmpq_poly_t, slong, const fmpz_t)
+     void fmpq_poly_set_coeff_fmpq(fmpq_poly_t, slong, const fmpq_t)
+-    void fmpq_poly_set_coeff_mpz(fmpq_poly_t, slong, const mpz_t)
+-    void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
+ 
+     # Comparison
+     int fmpq_poly_equal(const fmpq_poly_t, const fmpq_poly_t)
+@@ -100,8 +97,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_mul_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     void fmpq_poly_scalar_div_si(fmpq_poly_t, const fmpq_poly_t, slong)
+     void fmpq_poly_scalar_div_ui(fmpq_poly_t, const fmpq_poly_t, ulong)
+@@ -109,8 +104,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_div_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_div_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_div_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Multiplication
+     void fmpq_poly_mul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -155,8 +148,6 @@ cdef extern from "flint_wrap.h":
+     # Evaluation
+     void fmpq_poly_evaluate_fmpz(fmpq_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_evaluate_fmpq(fmpq_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_evaluate_mpz(mpq_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_evaluate_mpq(mpq_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Composition
+     void fmpq_poly_compose(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -189,3 +180,11 @@ cdef extern from "flint_wrap.h":
+ # since the fmpq_poly header seems to be lacking this inline function
+ cdef inline sage_fmpq_poly_max_limbs(const fmpq_poly_t poly) noexcept:
+     return _fmpz_vec_max_limbs(fmpq_poly_numref(poly), fmpq_poly_length(poly))
++
++# functions removed from flint but still needed in sage
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
++cdef void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
++cdef void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pyx b/src/sage/libs/flint/fmpq_poly.pyx
+new file mode 100644
+index 00000000000..3b8a0cf0c51
+--- /dev/null
++++ b/src/sage/libs/flint/fmpq_poly.pyx
+@@ -0,0 +1,45 @@
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++from sage.libs.gmp.mpq cimport *
++from sage.libs.flint.fmpz cimport *
++from sage.libs.flint.fmpq cimport *
++
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t rop, const fmpq_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t rop, const fmpq_poly_t op, const mpq_t c):
++    cdef fmpq_t f
++    fmpq_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpq(rop, op, f)
++    fmpq_clear_readonly(f)
++
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t poly, slong n, const mpq_t x):
++    cdef fmpq_t t
++    fmpq_init_set_readonly(t, x)
++    fmpq_poly_set_coeff_fmpq(poly, n, t)
++    fmpq_clear_readonly(t)
++
++cdef void fmpq_poly_get_coeff_mpq(mpq_t x, const fmpq_poly_t poly, slong n):
++    cdef fmpq_t t
++    fmpq_init(t)
++    fmpq_poly_get_coeff_fmpq(t, poly, n)
++    fmpq_get_mpq(x, t)
++    fmpq_clear(t)
++
++cdef void fmpq_poly_set_mpq(fmpq_poly_t poly, const mpq_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), mpq_numref(x))
++    fmpz_set_mpz(fmpq_poly_denref(poly), mpq_denref(x))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
++
++cdef void fmpq_poly_set_mpz(fmpq_poly_t poly, const mpz_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), x)
++    fmpz_one(fmpq_poly_denref(poly))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz.pxd b/src/sage/libs/flint/fmpz.pxd
+index 01058d0f130..b97fbe1eae0 100644
+--- a/src/sage/libs/flint/fmpz.pxd
++++ b/src/sage/libs/flint/fmpz.pxd
+@@ -16,6 +16,9 @@ cdef extern from "flint_wrap.h":
+     void fmpz_init_set(fmpz_t, fmpz_t)
+     void fmpz_init_set_ui(fmpz_t, ulong)
+ 
++    void fmpz_init_set_readonly(fmpz_t, const mpz_t)
++    void fmpz_clear_readonly(fmpz_t)
++
+     # Conversion
+     void fmpz_set(fmpz_t f, fmpz_t g)
+     void fmpz_set_ui(fmpz_t, ulong)
+diff --git a/src/sage/libs/flint/fmpz_mod_poly.pxd b/src/sage/libs/flint/fmpz_mod_poly.pxd
+index 24b653eb3b7..2727246da98 100644
+--- a/src/sage/libs/flint/fmpz_mod_poly.pxd
++++ b/src/sage/libs/flint/fmpz_mod_poly.pxd
+@@ -67,13 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_get_coeff_fmpz(fmpz_t x, const fmpz_mod_poly_t poly,
+                                              slong n, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_set_coeff_mpz(fmpz_mod_poly_t poly,
+-                             slong n, const mpz_t x, const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_get_coeff_mpz(mpz_t x,
+-                 const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx)
+-
+-
+     void _fmpz_mod_poly_shift_left(fmpz * res, const fmpz * poly,
+                                                            slong len, slong n)
+ 
+@@ -194,14 +187,6 @@ cdef extern from "flint_wrap.h":
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_div_basecase(fmpz_mod_poly_t Q,
+-                            const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_div_newton_n_preinv(fmpz_mod_poly_t Q,
+-                         const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                         const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem_newton_n_preinv(fmpz_mod_poly_t Q,
+           fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                          const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+@@ -213,10 +198,6 @@ cdef extern from "flint_wrap.h":
+                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_divrem_divconquer(fmpz_mod_poly_t Q,
+-        fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem(fmpz_mod_poly_t Q, fmpz_mod_poly_t R,
+     const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+@@ -254,40 +235,13 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_make_monic_f(fmpz_t f, fmpz_mod_poly_t res,
+                          const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_euclidean(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_gcd_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_hgcd(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-
+     void fmpz_mod_poly_gcd(fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+ 
+-    void fmpz_mod_poly_xgcd_euclidean(fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_hgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S,
+-          fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_xgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                       const fmpz_mod_ctx_t ctx)
+@@ -361,14 +315,6 @@ cdef extern from "flint_wrap.h":
+                         const fmpz_mod_poly_t poly, const fmpz * xs, slong n,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_compose_horner(fmpz_mod_poly_t res,
+-                    const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_compose_divconquer(fmpz_mod_poly_t res,
+-                     const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_compose(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1,
+                          const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx)
+ 
+diff --git a/src/sage/libs/flint/fmpz_poly.pxd b/src/sage/libs/flint/fmpz_poly.pxd
+index 18b36672d30..c8bc6d3ca0a 100644
+--- a/src/sage/libs/flint/fmpz_poly.pxd
++++ b/src/sage/libs/flint/fmpz_poly.pxd
+@@ -28,7 +28,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_poly_set_ui(fmpz_poly_t, ulong)
+     void fmpz_poly_set_si(fmpz_poly_t, slong)
+     void fmpz_poly_set_fmpz(fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+     int fmpz_poly_set_str(fmpz_poly_t, const char *)
+ 
+     char *fmpz_poly_get_str(const fmpz_poly_t)
+@@ -70,7 +69,6 @@ cdef extern from "flint_wrap.h":
+     # Scalar multiplication and division
+     void fmpz_poly_scalar_mul_fmpz(
+             fmpz_poly_t, const fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+     void fmpz_poly_scalar_mul_si(fmpz_poly_t, const fmpz_poly_t, slong)
+     void fmpz_poly_scalar_mul_ui(fmpz_poly_t, const fmpz_poly_t, ulong)
+     void fmpz_poly_scalar_mul_2exp(fmpz_poly_t, const fmpz_poly_t, ulong)
+@@ -310,12 +308,14 @@ cdef extern from "flint_wrap.h":
+             fmpz_poly_t,
+                     const fmpz_poly_t, const fmpz_t, const nmod_poly_t, int)
+ 
+-    # Some functions for backwards compatibility
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
+-    void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++
++# functions removed from flint but still needed in sage
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
++cdef void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++cdef void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+ 
+ 
+ # Wrapper Cython class
+diff --git a/src/sage/libs/flint/fmpz_poly.pyx b/src/sage/libs/flint/fmpz_poly.pyx
+index 74915b37612..cfcbea9090c 100644
+--- a/src/sage/libs/flint/fmpz_poly.pyx
++++ b/src/sage/libs/flint/fmpz_poly.pyx
+@@ -25,10 +25,10 @@ from cysignals.memory cimport sig_free
+ 
+ from sage.arith.long cimport pyobject_to_long
+ from sage.cpython.string cimport char_to_str, str_to_bytes
++from sage.libs.flint.fmpz cimport *
+ from sage.structure.sage_object cimport SageObject
+ from sage.rings.integer cimport Integer
+ 
+-
+ cdef class Fmpz_poly(SageObject):
+ 
+     def __cinit__(self):
+@@ -455,3 +455,44 @@ cdef class Fmpz_poly(SageObject):
+         """
+         from sage.rings.integer_ring import ZZ
+         return ZZ[var](self.list())
++
++
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_divexact_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_fdiv_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t poly, slong n, const mpz_t x):
++    cdef fmpz_t t
++    fmpz_init_set_readonly(t, x)
++    fmpz_poly_set_coeff_fmpz(poly, n, t)
++    fmpz_clear_readonly(t)
++
++cdef void fmpz_poly_get_coeff_mpz(mpz_t x, const fmpz_poly_t poly, slong n):
++    cdef fmpz_t t
++    fmpz_init(t)
++    fmpz_poly_get_coeff_fmpz(t, poly, n)
++    fmpz_get_mpz(x, t)
++    fmpz_clear(t)
++
++cdef void fmpz_poly_set_mpz(fmpz_poly_t poly, const mpz_t x):
++    fmpz_poly_fit_length(poly, 1)
++    fmpz_set_mpz(poly.coeffs, x)
++    _fmpz_poly_set_length(poly, 1)
++    _fmpz_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz_poly_q.pxd b/src/sage/libs/flint/fmpz_poly_q.pxd
+index 846542dc0d8..63c13355bf6 100644
+--- a/src/sage/libs/flint/fmpz_poly_q.pxd
++++ b/src/sage/libs/flint/fmpz_poly_q.pxd
+@@ -49,11 +49,7 @@ cdef extern from "flint_wrap.h":
+ 
+     #* Scalar multiplication and division ****************************************/
+     void fmpz_poly_q_scalar_mul_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_mul_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_mul_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+     void fmpz_poly_q_scalar_div_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_div_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_div_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+ 
+     #* Multiplication and division ***********************************************/
+     void fmpz_poly_q_mul(fmpz_poly_q_t rop, 
+@@ -67,9 +63,6 @@ cdef extern from "flint_wrap.h":
+     #* Derivative ****************************************************************/
+     void fmpz_poly_q_derivative(fmpz_poly_q_t rop, const fmpz_poly_q_t op)
+ 
+-    #* Evaluation ****************************************************************/
+-    int fmpz_poly_q_evaluate(mpq_t rop, const fmpz_poly_q_t f, const mpq_t a)
+-
+     #* Input and output **********************************************************/
+     int fmpz_poly_q_set_str(fmpz_poly_q_t rop, const char *s)
+     char * fmpz_poly_q_get_str(const fmpz_poly_q_t op)
+diff --git a/src/sage/libs/linbox/linbox_flint_interface.pyx b/src/sage/libs/linbox/linbox_flint_interface.pyx
+index dabd375c2b8..3ca65afc514 100644
+--- a/src/sage/libs/linbox/linbox_flint_interface.pyx
++++ b/src/sage/libs/linbox/linbox_flint_interface.pyx
+@@ -33,6 +33,7 @@ and C. Pernet. The functions available are:
+ #                  https://www.gnu.org/licenses/
+ # ****************************************************************************
+ 
++from sage.libs.gmp.types cimport mpz_t
+ from sage.libs.flint.types cimport fmpz_t
+ from sage.libs.flint.fmpz cimport fmpz_get_mpz, fmpz_set_mpz
+ from sage.libs.flint.fmpz_mat cimport fmpz_mat_entry, fmpz_mat_nrows, fmpz_mat_ncols
+@@ -80,11 +81,13 @@ cdef void fmpz_poly_set_linbox(fmpz_poly_t p, PolynomialRing_integer.Element& q)
+     (the .pxd file) in order to keep the header C-compatible
+     """
+     cdef size_t i
++    cdef mpz_t tmp
+ 
+     fmpz_poly_fit_length(p, q.size())
+ 
+     for i in range(q.size()):
+-        fmpz_poly_set_coeff_mpz(p, i, q[i].get_mpz_const())
++        tmp = q[i].get_mpz_const()
++        fmpz_poly_set_coeff_mpz(p, i, tmp)
+ 
+     _fmpz_poly_set_length(p, q.size())
+ 
+diff --git a/src/sage/matrix/matrix_complex_ball_dense.pyx b/src/sage/matrix/matrix_complex_ball_dense.pyx
+index 22366b5f1f2..7fdf3f2aa36 100644
+--- a/src/sage/matrix/matrix_complex_ball_dense.pyx
++++ b/src/sage/matrix/matrix_complex_ball_dense.pyx
+@@ -1,4 +1,4 @@
+-# distutils: libraries = ARB_LIBRARY
++# distutils: libraries = flint
+ r"""
+ Arbitrary precision complex ball matrices using Arb
+ 
+diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx
+index 0712500e67d..daba89d5c43 100644
+--- a/src/sage/matrix/matrix_integer_sparse.pyx
++++ b/src/sage/matrix/matrix_integer_sparse.pyx
+@@ -847,6 +847,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+             sage: matrix(ZZ, 1, 1, sparse=True)._charpoly_linbox()
+             x
+         """
++        cdef mpz_t tmp
+         if self._nrows != self._ncols:
+             raise ArithmeticError('only valid for square matrix')
+ 
+@@ -869,7 +870,8 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         cdef size_t i
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+@@ -966,9 +968,11 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         sig_off()
+ 
+         cdef size_t i
++        cdef mpz_t tmp
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
+index f36a89bb229..20a06f7eaa3 100644
+--- a/src/sage/rings/complex_arb.pyx
++++ b/src/sage/rings/complex_arb.pyx
+@@ -1360,12 +1360,13 @@ cdef class ComplexBall(RingElement):
+             sage: CBF100(-3r)
+             -3.000000000000000000000000000000
+ 
+-            sage: ComplexBall(CBF100, 10^100)
+-            1.000000000000000000000000000000e+100
+             sage: ComplexBall(CBF100, CIF(1, 2))
+             1.000000000000000000000000000000 + 2.000000000000000000000000000000*I
+             sage: ComplexBall(CBF100, RBF(1/3), RBF(1))
+             [0.3333333333333333 +/- ...e-17] + 1.000000000000000000000000000000*I
++            sage: ComplexBall(CBF100, 10^100)
++            [1.000000000000000000000000000000e+100 +/- ...]
++
+             sage: NF.<a> = QuadraticField(-1, embedding=CC(0, -1))
+             sage: CBF(a)
+             -1.000000000000000*I
+@@ -3009,7 +3010,7 @@ cdef class ComplexBall(RingElement):
+             sage: CBF(1).rising_factorial(2**64)
+             [+/- ...e+347382171326740403407]
+             sage: ComplexBallField(128)(1).rising_factorial(2**64)
+-            [2.343691126796861348e+347382171305201285713 +/- ...e+347382171305201285694]
++            [2.34369112679686134...e+347382171305201285713 +/- ...]
+             sage: CBF(1/2).rising_factorial(CBF(2,3)) # abs tol 1e-15
+             [-0.123060451458124 +/- 3.06e-16] + [0.0406412631676552 +/- 7.57e-17]*I
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+index f651c9f3512..c68246d2142 100644
+--- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+@@ -222,7 +222,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef unsigned long n
+         cdef Rational c
+         cdef list L1
+-        cdef mpq_t * L2
++        cdef fmpq_t q
+ 
+         Polynomial.__init__(self, parent, is_gen=is_gen)
+ 
+@@ -253,14 +253,11 @@ cdef class Polynomial_rational_flint(Polynomial):
+             L1 = [e if isinstance(e, Rational) else Rational(e) for e in x]
+             n  = <unsigned long> len(x)
+             sig_on()
+-            L2 = <mpq_t *> check_allocarray(n, sizeof(mpq_t))
++            fmpq_poly_fit_length(self._poly, n)
+             for deg from 0 <= deg < n:
+-                mpq_init(L2[deg])
+-                mpq_set(L2[deg], (<Rational> L1[deg]).value)
+-            fmpq_poly_set_array_mpq(self._poly, L2, n)
+-            for deg from 0 <= deg < n:
+-                mpq_clear(L2[deg])
+-            sig_free(L2)
++                fmpq_init_set_readonly(q, (<Rational> L1[deg]).value)
++                fmpq_poly_set_coeff_fmpq(self._poly, deg, q)
++                fmpq_clear_readonly(q)
+             sig_off()
+ 
+ #           deg = 0
+@@ -435,6 +432,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         utmost care.
+         """
+         cdef bint do_sig = _do_sig(self._poly)
++        cdef fmpz_t tmpfz
+ 
+         if isinstance(value, int):
+             if do_sig: sig_str("FLINT exception")
+@@ -442,7 +440,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+             if do_sig: sig_off()
+         elif isinstance(value, Integer):
+             if do_sig: sig_str("FLINT exception")
+-            fmpq_poly_set_coeff_mpz(self._poly, n, (<Integer> value).value)
++            fmpz_init_set_readonly(tmpfz, (<Integer> value).value)
++            fmpq_poly_set_coeff_fmpz(self._poly, n, tmpfz)
++            fmpz_clear_readonly(tmpfz)
+             if do_sig: sig_off()
+         elif isinstance(value, Rational):
+             if do_sig: sig_str("FLINT exception")
+@@ -492,7 +492,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef Polynomial_rational_flint f
+         cdef Rational r
+         cdef fmpz_t tmpfz
+-        cdef fmpq_t tmpfq
++        cdef fmpq_t tmpfq, tmpfq1
+         cdef RealBall arb_a, arb_z
+         cdef ComplexBall acb_a, acb_z
+ 
+@@ -508,13 +508,23 @@ cdef class Polynomial_rational_flint(Polynomial):
+             elif isinstance(a, Rational):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpq(r.value, self._poly, (<Rational> a).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> a).value)
++                fmpq_init(tmpfq1)
++                fmpq_poly_evaluate_fmpq(tmpfq1, self._poly, tmpfq)
++                fmpq_get_mpq(r.value, tmpfq1)
++                fmpq_clear(tmpfq1)
++                fmpq_clear_readonly(tmpfq)
+                 sig_off()
+                 return r
+             elif isinstance(a, Integer):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpz(r.value, self._poly, (<Integer> a).value)
++                fmpz_init_set_readonly(tmpfz, (<Integer> a).value)
++                fmpq_init(tmpfq)
++                fmpq_poly_evaluate_fmpz(tmpfq, self._poly, tmpfz)
++                fmpq_get_mpq(r.value, tmpfq)
++                fmpq_clear(tmpfq)
++                fmpz_clear_readonly(tmpfz)
+                 sig_off()
+                 return r
+             elif isinstance(a, int):
+@@ -1321,6 +1331,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         """
+         cdef Polynomial_rational_flint res
+         cdef bint do_sig
++        cdef fmpq_t tmpfq
+ 
+         if right == 0:
+             raise ZeroDivisionError("division by zero polynomial")
+@@ -1331,8 +1342,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+                 do_sig = _do_sig(self._poly)
+ 
+                 if do_sig: sig_str("FLINT exception")
+-                fmpq_poly_scalar_div_mpq(res._poly, self._poly,
+-                                                  (<Rational> QQ(right)).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> QQ(right)).value)
++                fmpq_poly_scalar_div_fmpq(res._poly, self._poly, tmpfq)
++                fmpq_clear_readonly(tmpfq)
+                 if do_sig: sig_off()
+                 return res
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+index 6e7f7498329..3a66198d568 100644
+--- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+@@ -658,6 +658,11 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
+             ...
+             NotImplementedError: square free factorization of polynomials over rings with composite characteristic is not implemented
+ 
++        :trac:`20003`::
++
++            sage: P.<x> = GF(7)[]
++            sage: (6*x+3).squarefree_decomposition()
++            (6) * (x + 4)
+         """
+         if not self.base_ring().is_field():
+             raise NotImplementedError("square free factorization of polynomials over rings with composite characteristic is not implemented")
+diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
+index a9ce06d14ca..affe11e4376 100644
+--- a/src/sage/rings/real_arb.pyx
++++ b/src/sage/rings/real_arb.pyx
+@@ -898,7 +898,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+             sage: RBF.gamma(5)
+             24.00000000000000
+             sage: RBF.gamma(10**20)
+-            [+/- ...e+1956570552410610660600]
++            [1.932849514310098...+1956570551809674817225 +/- ...]
+             sage: RBF.gamma(1/3)
+             [2.678938534707747 +/- ...e-16]
+             sage: RBF.gamma(-5)
+@@ -1102,7 +1102,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+              15.00000000000000,
+              48.00000000000000]
+             sage: RBF.double_factorial(2**20)
+-            [1.4483729903e+2928836 +/- ...e+2928825]
++            [1.448372990...e+2928836 +/- ...]
+             sage: RBF.double_factorial(2**1000)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/schemes/plane_conics/con_rational_function_field.py b/src/sage/schemes/plane_conics/con_rational_function_field.py
+index 05d24e78a85..581102b5c5b 100644
+--- a/src/sage/schemes/plane_conics/con_rational_function_field.py
++++ b/src/sage/schemes/plane_conics/con_rational_function_field.py
+@@ -198,38 +198,6 @@ def has_rational_point(self, point=False, algorithm='default',
+             Fraction Field of Univariate Polynomial Ring in u over Rational
+             Field with modulus v^2 - u^3 - 1
+ 
+-        ``has_rational_point`` fails for some conics over function fields
+-        over finite fields, due to :trac:`20003`::
+-
+-            sage: K.<t> = PolynomialRing(GF(7))
+-            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
+-            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
+-            sage: C.has_rational_point()                                                # needs sage.libs.singular
+-            Traceback (most recent call last):
+-            ...
+-            TypeError: self (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (-t^3 + 3*t^2 - 2*t - 2)/(t + 3)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (t^2 + 3*t + 3)*x*y + (-2*t^2 - 2)*y^2 + (-t^2 + 3*t + 2)*x*z + (-3*t + 3)*y*z + (-3*t^2 + t - 2)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x + (2*t - 2)/(t + 3)*y + (3*t^4 + 2*t^3 - 2*t^2 - 2*t + 3)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z
+-                     : y + (-t^3 - t^2 + 3*t - 1)/(t^3 - 3*t^2 + 2*t + 2)*z : z))
+-            domain must equal right (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^3 - t^2 + 3*t + 3)*x^2 + (t - 3)*y^2 + (-t^7 + 2*t^5 + t^4 + 2*t^3 + 3*t^2 - t - 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    -2/(t^3 - 3*t^2 + 2*t + 2)*x^2 + 1/(t^3 + 3*t^2 - 2*t + 1)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^9 - 2*t^8 + t^7 - t^6 + 3*t^5 - 3*t^3 + t^2 - 2*t + 3)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    ((t^3 - 3*t^2 + 2*t + 2)*x : (t^2 - 2)*y : (t^5 - 3*t^4 + t^2 + 3*t + 3)*z))
+-            codomain
+-
+-
+-
+         TESTS::
+ 
+             sage: K.<t> = FractionField(PolynomialRing(QQ, 't'))
+@@ -250,6 +218,16 @@ def has_rational_point(self, point=False, algorithm='default',
+             sage: C.has_rational_point(point=True)  # long time (4 seconds)             # needs sage.libs.singular
+             (True,
+              ((-2/117*t^8 + 304/1053*t^7 + 40/117*t^6 - 1/27*t^5 - 110/351*t^4 - 2/195*t^3 + 11/351*t^2 + 1/117)/(t^4 + 2/39*t^3 + 4/117*t^2 + 2/39*t + 14/39) : -5/3*t^4 + 19*t^3 : 1))
++
++        ``has_rational_point`` used to fail for some conics over function fields
++        over finite fields, due to :trac:`20003`::
++
++            sage: K.<t> = PolynomialRing(GF(7))
++            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
++            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
++            sage: C.has_rational_point()
++            True
++
+         """
+         from .constructor import Conic
+ 
+diff --git a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+index a591cb4cd7c..a90f2050c59 100644
+--- a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
++++ b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+@@ -20,6 +20,7 @@
+ #include "utils.h"
+ 
+ #include "gmp.h"
++#include "flint/fmpz_poly.h"
+ #include "flint/fmpq_poly.h"
+ #include "flint/fmpq.h"
+ 
+@@ -63,7 +64,7 @@ static ex chebyt_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+@@ -122,7 +123,7 @@ static ex chebyu_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+diff --git a/src/sage/symbolic/ginac/useries.cpp b/src/sage/symbolic/ginac/useries.cpp
+index 40fbd7ab360..b9a8b867648 100644
+--- a/src/sage/symbolic/ginac/useries.cpp
++++ b/src/sage/symbolic/ginac/useries.cpp
+@@ -467,10 +467,17 @@ void add::useries(flint_series_t& fp, int order) const
+                 fmpq_poly_set_ui(fp.ft, 0);
+         else if (oc.is_long())
+                 fmpq_poly_set_si(fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ 
+         for (const auto & elem : seq) {
+ 		const ex& t = recombine_pair_to_ex(elem);
+@@ -505,10 +512,17 @@ void mul::useries(flint_series_t& fp, int order) const
+ 
+         if (oc.is_long())
+                 fmpq_poly_scalar_mul_si(fp.ft, fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_scalar_mul_mpz(fp.ft, fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_scalar_mul_mpq(fp.ft, fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_scalar_mul_fmpz(fp.ft, fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp.ft, fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ void power::useries(flint_series_t& fp, int order) const
+@@ -563,7 +577,10 @@ void power::useries(flint_series_t& fp, int order) const
+                 }
+                 check_poly_ccoeff_one(fp1);
+                 fmpq_poly_log_series(fp1.ft, fp1.ft, order);
+-                fmpq_poly_scalar_mul_mpq(fp1.ft, fp1.ft, nexp.as_mpq());
++                fmpq_t tmp;
++                fmpq_init_set_readonly(tmp, nexp.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp1.ft, fp1.ft, tmp);
++                fmpq_clear_readonly(tmp);
+                 fmpq_poly_exp_series(fp.ft, fp1.ft, order);
+                 return;
+         }
+@@ -608,10 +625,17 @@ void numeric::useries(flint_series_t& fp, int order) const
+ {
+         if (is_long())
+                 fmpq_poly_set_si(fp.ft, to_long());
+-        else if (is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, as_mpq());
++        else if (is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ } // namespace GiNaC
+diff --git a/src/sage_setup/library_order.py b/src/sage_setup/library_order.py
+index f40690f8d22..9ae0d2579a7 100644
+--- a/src/sage_setup/library_order.py
++++ b/src/sage_setup/library_order.py
+@@ -16,17 +16,12 @@
+ 
+ aliases = cython_aliases(required_modules=(), optional_modules=modules)
+ 
+-if "ARB_LIBRARY" in aliases:
+-    arb_dylib_names = [aliases["ARB_LIBRARY"]]
+-else:
+-    arb_dylib_names = []
+-
+ library_order_list = aliases.get("SINGULAR_LIBRARIES", []) + [
+     "giac", "intl", "curl",
+     "ec", "ecm"
+ ] + aliases.get("LINBOX_LIBRARIES", []) + aliases.get("FFLASFFPACK_LIBRARIES", []) + aliases.get("GSL_LIBRARIES", []) + [
+     "pari", "flint", "ecl", "glpk", "ppl",
+-] + arb_dylib_names + [
++] + [
+     "mpfi", "mpfr", "mpc", "ntl", "gmp", "gmpxx",
+     "brial",
+     "brial_groebner",
diff --git a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch b/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
deleted file mode 100644
index 7c55bce6e9bb4..0000000000000
--- a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
+++ /dev/null
@@ -1,221 +0,0 @@
-diff --git a/build/pkgs/singular/checksums.ini b/build/pkgs/singular/checksums.ini
-index 313463d2fea..1101fc55700 100644
---- a/build/pkgs/singular/checksums.ini
-+++ b/build/pkgs/singular/checksums.ini
-@@ -1,5 +1,5 @@
- tarball=singular-VERSION.tar.gz
--sha1=28bb3ee97ef48d04dfa96de182fd93eebe08426c
--md5=fc0a4f5720dadba45a52ee94324ce00c
--cksum=1573851737
--upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-1/singular-VERSION.tar.gz
-+sha1=df1997f412580f2073295aba569bb955ad227317
-+md5=50349213e206a18cdaa1bc410dde7ea4
-+cksum=376854707
-+upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-2/singular-VERSION.tar.gz
-diff --git a/build/pkgs/singular/package-version.txt b/build/pkgs/singular/package-version.txt
-index 66e2bede53a..9f1bf008217 100644
---- a/build/pkgs/singular/package-version.txt
-+++ b/build/pkgs/singular/package-version.txt
-@@ -1 +1 @@
--4.3.1p3
-+4.3.2p7
-diff --git a/build/pkgs/singular/spkg-configure.m4 b/build/pkgs/singular/spkg-configure.m4
-index 6a85631f624..f7621ec5fa1 100644
---- a/build/pkgs/singular/spkg-configure.m4
-+++ b/build/pkgs/singular/spkg-configure.m4
-@@ -6,14 +6,27 @@ SAGE_SPKG_CONFIGURE([singular], [
-     AS_IF([test -z "${SINGULAR_BIN}"], [sage_spkg_install_singular=yes], [
-       dnl Use pkg-config to ensure that Singular is new enough.
-       PKG_CHECK_MODULES([SINGULAR], [Singular >= 4.2.1], [
--       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)
--       ], [
--       AC_MSG_RESULT(no)
--       sage_spkg_install_singular=yes
--       ]
--      )], [
-+        AC_MSG_CHECKING([whether Singular is built with FLINT])
-+        AC_COMPILE_IFELSE([
-+          AC_LANG_PROGRAM([
-+            #include <singular/singularconfig.h>
-+            #if !defined(HAVE_FLINT)
-+            #  error "Need Singular compiled with FLINT"
-+          ], [])
-+        ], [
-+          AC_MSG_RESULT([yes])
-+          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)
-+          ], [
-+            AC_MSG_RESULT(no)
-+            sage_spkg_install_singular=yes
-+          ])
-+        ], [
-+          AC_MSG_RESULT([no])
-+          sage_spkg_install_singular=yes
-+        ])
-+      ], [
-       dnl pkg-config version check failed
-       sage_spkg_install_singular=yes
-       ])
-diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py
-index b15cc1c602c..4b5c76e2bfa 100644
---- a/src/sage/interfaces/singular.py
-+++ b/src/sage/interfaces/singular.py
-@@ -604,8 +604,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: i = singular.ideal(['x^2','y^2','z^2'])
-             sage: s = i.std()
-             sage: singular.eval('hilb(%s)'%(s.name()))
--            '// 1 t^0\n// -3 t^2\n// 3 t^4\n// -1 t^6\n\n// 1 t^0\n//
--            3 t^1\n// 3 t^2\n// 1 t^3\n// dimension (affine) = 0\n//
-+            '...// dimension (affine) = 0\n//
-             degree (affine) = 8'
- 
-         ::
-@@ -613,15 +612,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: from sage.misc.verbose import set_verbose
-             sage: set_verbose(1)
-             sage: o = singular.eval('hilb(%s)'%(s.name()))
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
- 
-         This is mainly useful if this method is called implicitly. Because
-@@ -631,15 +622,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-         ::
- 
-             sage: o = s.hilb()
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
-             // ** right side is not a datum, assignment ignored
-             ...
-diff --git a/src/sage/libs/singular/function.pyx b/src/sage/libs/singular/function.pyx
-index f40346d1fd0..c597c63aafe 100644
---- a/src/sage/libs/singular/function.pyx
-+++ b/src/sage/libs/singular/function.pyx
-@@ -1241,32 +1241,22 @@ cdef class SingularFunction(SageObject):
-             sage: I = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5])
-             sage: I = Ideal(I.groebner_basis())
-             sage: hilb = sage.libs.singular.function_factory.ff.hilb
--            sage: hilb(I) # Singular will print // ** _ is no standard basis
--            // ** _ is no standard basis
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: from sage.misc.sage_ostools import redirection
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I) # Singular will print // ** _ is no standard basis
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            True
- 
-         So we tell Singular that ``I`` is indeed a Groebner basis::
- 
--            sage: hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            False
- 
- 
-         TESTS:
-diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-index 22ada6de947..80352700872 100644
---- a/src/sage/rings/polynomial/multi_polynomial_ideal.py
-+++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-@@ -3132,13 +3132,16 @@ def hilbert_numerator(self, grading=None, algorithm='sage'):
-             sage: I.hilbert_numerator()                                                 # needs sage.rings.number_field
-             -t^5 + 1
- 
--        This example returns a wrong answer due to an integer overflow in Singular::
-+        This example returns a wrong answer in singular < 4.3.2p4 due to an integer overflow::
- 
-             sage: n=4; m=11; P = PolynomialRing(QQ, n*m, "x"); x = P.gens(); M = Matrix(n, x)
-             sage: I = P.ideal(M.minors(2))
-             sage: J = P * [m.lm() for m in I.groebner_basis()]
--            sage: J.hilbert_numerator(algorithm='singular')
--            ...120*t^33 - 3465*t^32 + 48180*t^31 - ...
-+            sage: J.hilbert_numerator(algorithm='singular') # known bug
-+            Traceback (most recent call last):
-+            ....
-+            RuntimeError: error in Singular function call 'hilb':
-+            overflow at t^22
- 
-         Our two algorithms should always agree; not tested until
-         :trac:`33178` is fixed::
-diff --git a/src/sage/sandpiles/sandpile.py b/src/sage/sandpiles/sandpile.py
-index 02d2021b2fb..c8e15e06f05 100644
---- a/src/sage/sandpiles/sandpile.py
-+++ b/src/sage/sandpiles/sandpile.py
-@@ -2493,9 +2493,15 @@ def _set_ideal(self):
-             sage: '_ideal' in S.__dict__
-             True
-         """
-+        from sage.libs.singular.function_factory import ff
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
-         R = self.ring()
--        I = self._unsaturated_ideal._singular_()
--        self._ideal = R.ideal(I.sat(prod(R.gens())._singular_())[1])
-+        I = self._unsaturated_ideal
-+        I_sat_gens = sat(I, prod(R.gens()))[0]
-+        self._ideal = R.ideal(I_sat_gens)
- 
-     def unsaturated_ideal(self):
-         r"""
-diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py
-index e6caf19ba74..afd6484d779 100644
---- a/src/sage/schemes/projective/projective_subscheme.py
-+++ b/src/sage/schemes/projective/projective_subscheme.py
-@@ -1001,7 +1001,10 @@ def dual(self):
-         for i in range(n + 1):
-             J = J + S.ideal(z[-1] * f_S.derivative(z[i]) - z[i + n + 1])
- 
--        sat = ff.elim__lib.sat
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
- 
-         max_ideal = S.ideal(z[n + 1: 2 * n + 2])
-         J_sat_gens = sat(J, max_ideal)[0]
diff --git a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch b/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
deleted file mode 100644
index 6a35ec3836550..0000000000000
--- a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-diff --git a/src/sage/ext/memory.pyx b/src/sage/ext/memory.pyx
-index 1de6dedab82..b95130b19dd 100644
---- a/src/sage/ext/memory.pyx
-+++ b/src/sage/ext/memory.pyx
-@@ -3,14 +3,14 @@ Low-level memory allocation functions
- 
- TESTS:
- 
--Check that a ``MemoryError`` is raised if we try to allocate a
-+Check that an error is raised if we try to allocate a
- ridiculously large integer, see :trac:`15363`::
- 
--    sage: 2^(2^63-3)
--    Traceback (most recent call last):
--    ...
--    OverflowError: exponent must be at most 2147483647         # 32-bit
--    RuntimeError: Aborted                                      # 64-bit
-+    sage: try:
-+    ....:     2^(2^63-3)
-+    ....: except (OverflowError, RuntimeError, FloatingPointError):
-+    ....:     print ('Overflow error')
-+    ...Overflow error
- 
- AUTHORS:
- 
-diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx
-index d5e87626d31..37ed9364845 100644
---- a/src/sage/rings/integer.pyx
-+++ b/src/sage/rings/integer.pyx
-@@ -6654,7 +6654,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
-             sage: try:
-             ....:     print('Possible error output from gmp', flush=True)
-             ....:     1 << (2^60)
--            ....: except (MemoryError, OverflowError, RuntimeError):
-+            ....: except (MemoryError, OverflowError, RuntimeError, FloatingPointError):
-             ....:     pass
-             ....: else:
-             ....:     print("Failed to raise exception")
diff --git a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch b/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
deleted file mode 100644
index 3d2a4bd9cd96f..0000000000000
--- a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
+++ /dev/null
@@ -1,740 +0,0 @@
-diff --git a/src/sage/ext_data/valgrind/valgrind-python.supp b/src/sage/ext_data/valgrind/valgrind-python.supp
-new file mode 100644
-index 00000000000..16aa2858484
---- /dev/null
-+++ b/src/sage/ext_data/valgrind/valgrind-python.supp
-@@ -0,0 +1,480 @@
-+# From the CPython repository with the suppressions for _PyObject_Free
-+# and _PyObject_Realloc enabled. See the upstream suppression file for
-+# details:
-+#
-+# https://github.com/python/cpython/blob/main/Misc/valgrind-python.supp
-+
-+# all tool names: Addrcheck,Memcheck,cachegrind,helgrind,massif
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 8 (x86_64 aka amd64)
-+   Memcheck:Value8
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:address_in_range
-+}
-+
-+#
-+# Leaks (including possible leaks)
-+#    Hmmm, I wonder if this masks some real leaks.  I think it does.
-+#    Will need to fix that.
-+#
-+
-+{
-+   Suppress leaking the GIL after a fork.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_allocate_lock
-+   fun:PyEval_ReInitThreads
-+}
-+
-+{
-+   Suppress leaking the autoTLSkey.  This looks like it shouldn't leak though.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_create_key
-+   fun:_PyGILState_Init
-+   fun:Py_InitializeEx
-+   fun:Py_Main
-+}
-+
-+{
-+   Hmmm, is this a real leak or like the GIL?
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_ReInitTLS
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:realloc
-+   fun:_PyObject_GC_Resize
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_New
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_NewVar
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+#
-+# Non-python specific leaks
-+#
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:calloc
-+   fun:allocate_dtv
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:memalign
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Realloc
-+}
-+
-+###
-+### All the suppressions below are for errors that occur within libraries
-+### that Python uses.  The problems to not appear to be related to Python's
-+### use of the libraries.
-+###
-+
-+{
-+   Generic ubuntu ld problems
-+   Memcheck:Addr8
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+}
-+
-+{
-+   Generic gentoo ld problems
-+   Memcheck:Cond
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_close
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Value8
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   GDBM problems, see test_gdbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   fun:gdbm_open
-+
-+}
-+
-+{
-+   Uninitialised byte(s) false alarm, see bpo-35561
-+   Memcheck:Param
-+   epoll_ctl(event)
-+   fun:epoll_ctl
-+   fun:pyepoll_internal_ctl
-+}
-+
-+{
-+   ZLIB problems, see test_gzip
-+   Memcheck:Cond
-+   obj:/lib/libz.so.1.2.3
-+   obj:/lib/libz.so.1.2.3
-+   fun:deflate
-+}
-+
-+{
-+   Avoid problems w/readline doing a putenv and leaking on exit
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:xmalloc
-+   fun:sh_set_lines_and_columns
-+   fun:_rl_get_screen_size
-+   fun:_rl_init_terminal_io
-+   obj:/lib/libreadline.so.4.3
-+   fun:rl_initialize
-+}
-+
-+# Valgrind emits "Conditional jump or move depends on uninitialised value(s)"
-+# false alarms on GCC builtin strcmp() function. The GCC code is correct.
-+#
-+# Valgrind bug: https://bugs.kde.org/show_bug.cgi?id=264936
-+{
-+   bpo-38118: Valgrind emits false alarm on GCC builtin strcmp()
-+   Memcheck:Cond
-+   fun:PyUnicode_Decode
-+}
-+
-+
-+###
-+### These occur from somewhere within the SSL, when running
-+###  test_socket_sll.  They are too general to leave on by default.
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:memset
-+###}
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:memset
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:MD5_Update
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:MD5_Update
-+###}
-+
-+# Fedora's package "openssl-1.0.1-0.1.beta2.fc17.x86_64" on x86_64
-+# See http://bugs.python.org/issue14171
-+{
-+   openssl 1.0.1 prng 1
-+   Memcheck:Cond
-+   fun:bcmp
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 2
-+   Memcheck:Cond
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 3
-+   Memcheck:Value8
-+   fun:_x86_64_AES_encrypt_compact
-+   fun:AES_encrypt
-+}
-+
-+#
-+# All of these problems come from using test_socket_ssl
-+#
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_bin2bn
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libcrypto.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_set_key_unchecked
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_encrypt2
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BUF_MEM_grow_clean
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:memcpy
-+   fun:ssl3_read_bytes
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:SHA1_Update
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:SHA1_Update
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-+{
-+   wcscmp_false_positive
-+   Memcheck:Addr8
-+   fun:wcscmp
-+   fun:_PyOS_GetOpt
-+   fun:Py_Main
-+   fun:main
-+}
-+
-+# Additional suppressions for the unified decimal tests:
-+{
-+   test_decimal
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_decimal2
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index b40ed64edb5..8c55861c147 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -1576,6 +1576,62 @@ const numeric numeric::div(const numeric &other) const {
-         }
- }
- 
-+
-+// Compute `a^b` as an integer, where a is an integer. Assign to ``res``` if it is integral, or return ``false``.
-+// The nonnegative real root is taken for even denominators. To be used inside numeric::integer_rational_power,
-+// to handle the special case of integral ``a``.
-+bool integer_rational_power_of_mpz(
-+        numeric& res,
-+        const numeric& a,
-+        const numeric& b
-+) {
-+        if (a.t != MPZ)
-+                throw std::runtime_error("integer_rational_power_of_mpz: bad input");
-+        mpz_t z;
-+        mpz_init(z);
-+        mpz_set_ui(z, 0);
-+        int sgn = mpz_sgn(a.v._bigint);
-+        if (mpz_cmp_ui(a.v._bigint, 1) == 0
-+            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
-+                mpz_set_ui(z, 1);
-+        else if (sgn == 0) {
-+                res = *_num0_p;
-+                mpz_clear(z);
-+                return true;
-+        }
-+        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1)) {
-+                mpz_clear(z);
-+                return false;
-+        } else {
-+                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-+                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat))) {
-+                        // too big to take roots/powers
-+                        mpz_clear(z);
-+                        return false;
-+                }
-+                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
-+                        if (mpz_perfect_square_p(a.v._bigint)) {
-+                                mpz_sqrt(z, a.v._bigint);
-+                        } else {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                else {
-+                        bool exact = mpz_root(z, a.v._bigint,
-+                                              mpz_get_ui(mpq_denref(b.v._bigrat)));
-+                        if (not exact) {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
-+        }
-+        res = numeric(z);   // transfers ownership, no mpz_clear
-+        return true;
-+}
-+
-+
- // Compute `a^b` as an integer, if it is integral, or return ``false``.
- // The nonnegative real root is taken for even denominators.
- bool numeric::integer_rational_power(numeric& res,
-@@ -1598,13 +1654,12 @@ bool numeric::integer_rational_power(numeric& res,
-                 if (a.v._long < 0
-                     and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
-                         return false;
--                long z;
-                 if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-                     or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
-                 // too big to take roots/powers
-                         return false;
-                 if (b.is_equal(*_num1_2_p)) {
--                        z = std::lround(std::sqrt(a.v._long));
-+                        long z = std::lround(std::sqrt(a.v._long));
-                         if (a.v._long == z*z) {
-                                 res = numeric(z);
-                                 return true;
-@@ -1613,44 +1668,11 @@ bool numeric::integer_rational_power(numeric& res,
-                 }
-                 return integer_rational_power(res, a.to_bigint(), b);
-         }
--        if (a.t != MPZ)
--                throw std::runtime_error("integer_rational_power: bad input");
--        int sgn = mpz_sgn(a.v._bigint);
--        mpz_t z;
--        mpz_init(z);
--        mpz_set_ui(z, 0);
--        if (mpz_cmp_ui(a.v._bigint, 1) == 0
--            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
--                mpz_set_ui(z, 1);
--        else if (sgn == 0) {
--                res = *_num0_p;
--                return true;
--        }
--        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
--                return false;
--        else {
--                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
--                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
--                // too big to take roots/powers
--                        return false;
--                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
--                        if (mpz_perfect_square_p(a.v._bigint))
--                                mpz_sqrt(z, a.v._bigint);
--                        else
--                                return false;
--                }
--                else {
--                        bool exact = mpz_root(z, a.v._bigint,
--                                        mpz_get_ui(mpq_denref(b.v._bigrat)));
--                        if (not exact)
--                                return false;
--                }
--                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
--        }
--        res = numeric(z);
--        return true;
-+        // otherwise: a is integer
-+        return integer_rational_power_of_mpz(res, a, b);
- }
- 
-+
- // for a^b return c,d such that a^b = c*d^b
- // only for MPZ/MPQ base and MPQ exponent
- void rational_power_parts(const numeric& a_orig, const numeric& b_orig,
-diff --git a/src/sage/tests/memcheck/__init__.py b/src/sage/tests/memcheck/__init__.py
-new file mode 100644
-index 00000000000..e69de29bb2d
-diff --git a/src/sage/tests/memcheck/run_tests.py b/src/sage/tests/memcheck/run_tests.py
-new file mode 100644
-index 00000000000..6ff4503a81b
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests.py
-@@ -0,0 +1,24 @@
-+import types
-+
-+
-+def run_tests() -> None:
-+    """
-+    Run all memcheck tests
-+    """
-+    from sage.tests.memcheck import symbolic_expression
-+    run_tests_in_module(symbolic_expression)
-+
-+
-+def run_tests_in_module(mod: types.ModuleType) -> None:
-+    """
-+    Run all memcheck tests in the given module
-+    """
-+    for entry in dir(mod):
-+        if not entry.startswith('test_'):
-+            continue
-+        test_func = getattr(mod, entry)
-+        test_func()
-+
-+
-+if __name__ == '__main__':
-+    run_tests()
-diff --git a/src/sage/tests/memcheck/run_tests_in_valgrind.py b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-new file mode 100644
-index 00000000000..df5ad0e92b2
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-@@ -0,0 +1,35 @@
-+"""
-+Launch valgrind and run the memory leak tests
-+
-+
-+From the commandline, run
-+
-+    sage -python -m sage.tests.memcheck.run_tests_in_valgrind
-+
-+to launch valgrind and execute the memory leak tests. Requires valgrind
-+to be installed. Alternatively, run as a unit test:
-+
-+    sage: from sage.tests.memcheck.run_tests_in_valgrind import run_tests_in_valgrind
-+    sage: run_tests_in_valgrind()    # optional - valgrind
-+"""
-+
-+import subprocess
-+
-+
-+def run_tests_in_valgrind() -> None:
-+    """
-+    Run the sage.tests.memcheck.run_tests module inside valgrind
-+    """
-+    subprocess.check_call([
-+        'valgrind',
-+        '--suppressions=src/sage/ext_data/valgrind/valgrind-python.supp',
-+        '--show-possibly-lost=no',
-+        '--show-reachable=no',
-+        './venv/bin/python',
-+        '-m',
-+        'sage.tests.memcheck.run_tests'
-+    ])
-+
-+
-+if __name__ == '__main__':
-+    run_tests_in_valgrind()
-diff --git a/src/sage/tests/memcheck/symbolic_expression.py b/src/sage/tests/memcheck/symbolic_expression.py
-new file mode 100644
-index 00000000000..52182fbe62d
---- /dev/null
-+++ b/src/sage/tests/memcheck/symbolic_expression.py
-@@ -0,0 +1,11 @@
-+from sage.tests.memcheck.verify_no_leak import verify_no_leak
-+
-+
-+def test_sqrt_sqrt_2() -> None:
-+    from sage.misc.functional import sqrt
-+    T2 = sqrt(2)
-+
-+    def sqrt_T2() -> None:
-+        sqrt(T2)
-+
-+    verify_no_leak(sqrt_T2)
-diff --git a/src/sage/tests/memcheck/verify_no_leak.py b/src/sage/tests/memcheck/verify_no_leak.py
-new file mode 100644
-index 00000000000..89ca90cf89c
---- /dev/null
-+++ b/src/sage/tests/memcheck/verify_no_leak.py
-@@ -0,0 +1,27 @@
-+from typing import Tuple, Sequence, List, Callable, Any
-+import valgrind
-+
-+
-+def verify_no_leak(callback: Callable[[], Any],
-+                   repeat: int = 10000,
-+                   fuzzy: int = 10,
-+                   ) -> None:
-+    """
-+    Verify that the callback does not generate new definitely lost blocks
-+
-+    Raises an assertion if the callback leaks memory
-+    """
-+    callback()   # warm_up
-+    initial_blocks = (0, 0, 0, 0)
-+    valgrind.memcheck_do_leak_check()
-+    initial_blocks = valgrind.memcheck_count_leak_blocks()
-+    for _ in range(repeat):
-+        callback()
-+    valgrind.memcheck_do_leak_check()
-+    leak_blocks = valgrind.memcheck_count_leak_blocks()
-+    leak = leak_blocks[0] - initial_blocks[0]
-+    if leak < repeat - fuzzy:
-+        return  # callback did not leak at least once per call
-+    blocks = round(leak / repeat, 2)
-+    message = f'{callback} leaked {blocks} block on average ({repeat} iterations)'
-+    raise AssertionError(message)
diff --git a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch b/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
deleted file mode 100644
index 684b62affaf5a..0000000000000
--- a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx
-index 8f46570313d..a8e73e57b52 100644
---- a/src/sage/libs/ecl.pyx
-+++ b/src/sage/libs/ecl.pyx
-@@ -563,15 +563,15 @@ cdef class EclObject:
-     Floats in Python are IEEE double, which LISP has as well. However,
-     the printing of floating point types in LISP depends on settings::
- 
--        sage: a = EclObject(float(10^40))
-+        sage: a = EclObject(float(1.234e40))
-         sage: ecl_eval("(setf *read-default-float-format* 'single-float)")
-         <ECL: SINGLE-FLOAT>
-         sage: a
--        <ECL: 1.d40>
-+        <ECL: 1.234d40>
-         sage: ecl_eval("(setf *read-default-float-format* 'double-float)")
-         <ECL: DOUBLE-FLOAT>
-         sage: a
--        <ECL: 1.e40>
-+        <ECL: 1.234e40>
- 
-     Tuples are translated to dotted lists::
- 
-diff --git a/src/sage/libs/eclsig.h b/src/sage/libs/eclsig.h
-index e249ccf6874..005b2d99d0b 100644
---- a/src/sage/libs/eclsig.h
-+++ b/src/sage/libs/eclsig.h
-@@ -45,7 +45,11 @@ static inline void ecl_sig_off(void)
-     sig_off();
- }
- 
-+#if ECL_VERSION_NUMBER < 230909
- #define ecl_mpz_from_bignum(obj) ((obj)->big.big_num)
-+#else
-+#define ecl_mpz_from_bignum(obj) ecl_bignum(obj)
-+#endif
- 
- cl_object ecl_bignum_from_mpz(mpz_t num)
- {
diff --git a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch b/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
deleted file mode 100644
index e858f2fd4a445..0000000000000
--- a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
-index 59f10f6b13f..adcccff059b 100644
---- a/src/sage/plot/graphics.py
-+++ b/src/sage/plot/graphics.py
-@@ -36,6 +36,7 @@
- # ****************************************************************************
- 
- import os
-+from numbers import Integral
- from collections.abc import Iterable
- from math import isnan
- import sage.misc.verbose
-@@ -2874,6 +2875,11 @@ def matplotlib(self, filename=None,
-                 weight=lopts.pop('font_weight', 'medium'),
-                 variant=lopts.pop('font_variant', 'normal'))
-             color = lopts.pop('back_color', 'white')
-+            if 'loc' in lopts:
-+                loc = lopts['loc']
-+                if isinstance(loc, Integral):
-+                    # matplotlib 3.8 doesn't support sage integers
-+                    lopts['loc'] = int(loc)
-             leg = subplot.legend(prop=prop, **lopts)
-             if leg is None:
-                 from warnings import warn
diff --git a/srcpkgs/sagemath/patches/36403-00pre.patch b/srcpkgs/sagemath/patches/36403-00pre.patch
deleted file mode 100644
index 060404d5430de..0000000000000
--- a/srcpkgs/sagemath/patches/36403-00pre.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-Minor patch so that #36403 applies cleanly over sagemath 10.1
-
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 2053bca80c3..86aca6e00d8 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15123,7 +15302,8 @@ cdef class Matrix(Matrix1):
-             sage: N.conjugate_transpose()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object has no attribute 'conjugate'
-+            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
-+            has no attribute 'conjugate'
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 525ea5aa934..52afed49d64 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -55,7 +55,7 @@ cdef class AttributeErrorMessage:
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-         sage: x = polygen(ZZ, 'x')
--        sage: QQ[x].gen().bla                                                           # optional - sage.libs.flint
-+        sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
diff --git a/srcpkgs/sagemath/patches/36407-python_3.12.patch b/srcpkgs/sagemath/patches/36407-python_3.12.patch
deleted file mode 100644
index c75c275c30764..0000000000000
--- a/srcpkgs/sagemath/patches/36407-python_3.12.patch
+++ /dev/null
@@ -1,1744 +0,0 @@
-diff --git a/build/sage_bootstrap/package.py b/build/sage_bootstrap/package.py
-index 15b342223c4..eb82f96e05f 100644
---- a/build/sage_bootstrap/package.py
-+++ b/build/sage_bootstrap/package.py
-@@ -303,7 +303,7 @@ def _init_checksum(self):
-         # Name of the directory containing the checksums.ini file
-         self.__tarball_package_name = os.path.realpath(checksums_ini).split(os.sep)[-2]
- 
--    VERSION_PATCHLEVEL = re.compile('(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
-+    VERSION_PATCHLEVEL = re.compile(r'(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
- 
-     def _init_version(self):
-         try:
-diff --git a/src/doc/en/thematic_tutorials/coercion_and_categories.rst b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-index bb23331c151..7f5712caea7 100644
---- a/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-+++ b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-@@ -1223,7 +1223,7 @@ However, only "elementary" construction functors have a rank::
-     sage: (Fract*Poly).rank
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'
-+    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'...
- 
- .. end of output
- 
-diff --git a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-index 553a946c4d8..3cd71a9bad4 100644
---- a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-+++ b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-@@ -318,7 +318,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: e.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'...
- 
-         sage: id4 = SymmetricGroup(4).one()
-         sage: type(id4)
-@@ -326,7 +326,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: id4.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'
-+        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'...
- 
- .. note::
- 
-diff --git a/src/sage/algebras/cluster_algebra.py b/src/sage/algebras/cluster_algebra.py
-index b72d2a12976..14669dfed5c 100644
---- a/src/sage/algebras/cluster_algebra.py
-+++ b/src/sage/algebras/cluster_algebra.py
-@@ -167,7 +167,7 @@
-     sage: (t*s).g_vector()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'
-+    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'...
-     sage: A = ClusterAlgebra(['A', 2], principal_coefficients=True)
-     sage: A.explore_to_depth(infinity)
-     sage: s = A.cluster_variable((0, -1)); s
-diff --git a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-index e4a91723558..343ee8a66f9 100644
---- a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-+++ b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-@@ -109,7 +109,7 @@ class WeylLieConformalAlgebra(LieConformalAlgebraWithStructureCoefficients):
-         sage: alpha0.degree()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'
-+        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'...
- 
-     TESTS::
- 
-diff --git a/src/sage/algebras/steenrod/steenrod_algebra.py b/src/sage/algebras/steenrod/steenrod_algebra.py
-index 978a3557a9d..7c4d444f81c 100644
---- a/src/sage/algebras/steenrod/steenrod_algebra.py
-+++ b/src/sage/algebras/steenrod/steenrod_algebra.py
-@@ -1080,7 +1080,7 @@ def homogeneous_component(self, n):
-             sage: a.antipode() # not defined
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'
-+            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'...
-             sage: A(a).antipode() # convert to elt of A, then compute antipode
-             Sq(2,1) + Sq(5)
- 
-diff --git a/src/sage/all__sagemath_repl.py b/src/sage/all__sagemath_repl.py
-index 8d0b43679ca..c31b206bcb8 100644
---- a/src/sage/all__sagemath_repl.py
-+++ b/src/sage/all__sagemath_repl.py
-@@ -79,6 +79,23 @@
-                         message=r"Use setlocale\(\), getencoding\(\) and getlocale\(\) instead",
-                         module='docutils.io')
- 
-+# triggered by dateutil 2.8.2 and sphinx 7.0.1 on Python 3.12
-+# see: https://github.com/dateutil/dateutil/pull/1285
-+# see: https://github.com/sphinx-doc/sphinx/pull/11468
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"datetime.datetime.utcfromtimestamp\(\) is deprecated",
-+                        module='dateutil.tz.tz|sphinx.(builders.gettext|util.i18n)')
-+
-+# triggered on Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"This process.* is multi-threaded, "
-+                                r"use of .*\(\) may lead to deadlocks in the child.")
-+
-+# pickling of itertools is deprecated in Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"Pickle, copy, and deepcopy support will be "
-+                                r"removed from itertools in Python 3.14.")
-+
- 
- from .all__sagemath_objects import *
- from .all__sagemath_environment import *
-diff --git a/src/sage/arith/long.pxd b/src/sage/arith/long.pxd
-index 0031a0ae337..3ea70cef571 100644
---- a/src/sage/arith/long.pxd
-+++ b/src/sage/arith/long.pxd
-@@ -19,6 +19,8 @@ from libc.limits cimport LONG_MIN, LONG_MAX
- from cpython.object cimport Py_SIZE
- from cpython.number cimport PyNumber_Index, PyIndex_Check
- from cpython.longintrepr cimport py_long, PyLong_SHIFT, digit
-+from sage.cpython.pycore_long cimport (
-+    ob_digit, _PyLong_IsNegative, _PyLong_DigitCount)
- 
- from sage.libs.gmp.mpz cimport mpz_fits_slong_p, mpz_get_si
- from sage.rings.integer_fake cimport is_Integer, Integer_AS_MPZ
-@@ -299,8 +301,11 @@ cdef inline bint integer_check_long_py(x, long* value, int* err):
-         return 0
- 
-     # x is a Python "int" (aka PyLongObject or py_long in cython)
--    cdef const digit* D = (<py_long>x).ob_digit
--    cdef Py_ssize_t size = Py_SIZE(x)
-+    cdef const digit* D = ob_digit(x)
-+    cdef Py_ssize_t size = _PyLong_DigitCount(x)
-+
-+    if _PyLong_IsNegative(x):
-+        size = -size
- 
-     # We assume PyLong_SHIFT <= BITS_IN_LONG <= 3 * PyLong_SHIFT.
-     # This is true in all the default configurations:
-diff --git a/src/sage/categories/category.py b/src/sage/categories/category.py
-index 57ef7f4184b..29bce8ee415 100644
---- a/src/sage/categories/category.py
-+++ b/src/sage/categories/category.py
-@@ -2129,7 +2129,7 @@ def _with_axioms(self, axioms):
-             sage: Semigroups().Inverse()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'
-+            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'...
-             sage: Semigroups()._with_axioms(["Inverse"])
-             Category of semigroups
- 
-diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py
-index 5227792e725..4775d4e5bf1 100644
---- a/src/sage/categories/category_with_axiom.py
-+++ b/src/sage/categories/category_with_axiom.py
-@@ -554,7 +554,7 @@ class from the base category class::
-     sage: Magmas.Unital.Associative
-     Traceback (most recent call last):
-     ...
--    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'
-+    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'...
- 
- The purpose of this section is to explain the design of the code
- layout and the rationale for this mismatch.
-@@ -769,7 +769,7 @@ def _(): return LazyImport('sage.categories.rngs', 'Rngs', at_startup=True)
-     sage: Semirings().NoZeroDivisors()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'
-+    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'...
- 
- Concretely, this is to be implemented by defining the new axiom in the
- (``SubcategoryMethods`` nested class of the) appropriate category with
-diff --git a/src/sage/categories/enumerated_sets.py b/src/sage/categories/enumerated_sets.py
-index a8bea53f907..b0ea05d0563 100644
---- a/src/sage/categories/enumerated_sets.py
-+++ b/src/sage/categories/enumerated_sets.py
-@@ -610,7 +610,7 @@ def _list_from_iterator(self):
-                 sage: (QQ^2).list()  # indirect test                                    # needs sage.modules
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'
-+                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'...
- 
-             Here we test that for an object that does not know whether it
-             is finite or not.  Calling ``x.list()`` simply tries to create
-@@ -622,11 +622,11 @@ def _list_from_iterator(self):
-                 sage: Q.is_finite()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'...
-                 sage: Q.list()   # indirect test
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'...
- 
-             Here is another example. We artificially create a version of
-             the ring of integers that does not know whether it is finite
-diff --git a/src/sage/categories/examples/sets_cat.py b/src/sage/categories/examples/sets_cat.py
-index e0853d63f94..fbadb9ca405 100644
---- a/src/sage/categories/examples/sets_cat.py
-+++ b/src/sage/categories/examples/sets_cat.py
-@@ -619,7 +619,7 @@ class PrimeNumbers_Facade(PrimeNumbers_Abstract):
-         sage: pf.next()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'...
- 
-     unlike in the other implementations::
- 
-diff --git a/src/sage/categories/homset.py b/src/sage/categories/homset.py
-index 22ba9d047fc..2a8b8aeedeb 100644
---- a/src/sage/categories/homset.py
-+++ b/src/sage/categories/homset.py
-@@ -632,7 +632,7 @@ def __init__(self, X, Y, category=None, base=None, check=True):
-             sage: H = MyHomset(X, Y, category=1, base = ZZ, check = False)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'...
-             sage: P.<t> = ZZ[]
-             sage: f = P.hom([1/2*t])
-             sage: f.parent().domain()
-diff --git a/src/sage/categories/modules_with_basis.py b/src/sage/categories/modules_with_basis.py
-index e97bf851388..c4933d0657f 100644
---- a/src/sage/categories/modules_with_basis.py
-+++ b/src/sage/categories/modules_with_basis.py
-@@ -2456,7 +2456,7 @@ def apply_multilinear_morphism(self, f, codomain=None):
-                     sage: tensor([a, b]).apply_multilinear_morphism(f)                  # needs sage.modules
-                     Traceback (most recent call last):
-                     ...
--                    AttributeError: 'int' object has no attribute 'parent'
-+                    AttributeError: 'int' object has no attribute 'parent'...
- 
-                 Here we consider an example where the codomain is a
-                 module with basis with a different base ring::
-diff --git a/src/sage/categories/monoids.py b/src/sage/categories/monoids.py
-index 38dd7248c9d..28474bd17b6 100644
---- a/src/sage/categories/monoids.py
-+++ b/src/sage/categories/monoids.py
-@@ -556,7 +556,7 @@ def algebra_generators(self):
-                     Traceback (most recent call last):
-                     ...
-                     AttributeError: 'IntegerModMonoid_with_category' object
--                    has no attribute 'monoid_generators'
-+                    has no attribute 'monoid_generators'...
-                     sage: Z12.semigroup_generators()
-                     Family (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
-                     sage: Z12.algebra(QQ).algebra_generators()                          # needs sage.modules
-diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py
-index 494e8154c80..ec5120e41e6 100644
---- a/src/sage/combinat/finite_state_machine.py
-+++ b/src/sage/combinat/finite_state_machine.py
-@@ -1835,7 +1835,7 @@ def __getstate__(self):
-             sage: T1.transitions
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'FSMState' object has no attribute 'transitions'
-+            AttributeError: 'FSMState' object has no attribute 'transitions'...
-             sage: A1 = loads(dumps(A))
-             sage: all(A.state(j) == A1.state(j) for j in [0, 1])
-             True
-diff --git a/src/sage/combinat/growth.py b/src/sage/combinat/growth.py
-index cf8d18c1764..766eea37917 100644
---- a/src/sage/combinat/growth.py
-+++ b/src/sage/combinat/growth.py
-@@ -371,7 +371,7 @@
-     sage: GrowthDiagram(RulePascal(), [3,1,2])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'RulePascal' object has no attribute 'forward_rule'
-+    AttributeError: 'RulePascal' object has no attribute 'forward_rule'...
- 
- We now re-implement the rule where we provide the dual graded graphs::
- 
-diff --git a/src/sage/combinat/integer_lists/lists.py b/src/sage/combinat/integer_lists/lists.py
-index 5143e5cb5e8..9117a6076f7 100644
---- a/src/sage/combinat/integer_lists/lists.py
-+++ b/src/sage/combinat/integer_lists/lists.py
-@@ -261,7 +261,7 @@ def __getattr__(self, name):
-             sage: L.foo
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'foo'
-+            AttributeError: 'NoneType' object has no attribute 'foo'...
-         """
-         return getattr(self.backend, name)
- 
-diff --git a/src/sage/combinat/posets/posets.py b/src/sage/combinat/posets/posets.py
-index c31597c72e9..c74bfc67cee 100644
---- a/src/sage/combinat/posets/posets.py
-+++ b/src/sage/combinat/posets/posets.py
-@@ -8825,7 +8825,7 @@ def is_induced_subposet(self, other):
-             sage: Poset().is_induced_subposet('junk')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'subposet'
-+            AttributeError: 'str' object has no attribute 'subposet'...
-         """
-         if (not self._is_facade or (isinstance(other, FinitePoset) and
-                                     not other._is_facade)):
-diff --git a/src/sage/cpython/atexit.pyx b/src/sage/cpython/atexit.pyx
-index 961aa348d0a..e5a82735137 100644
---- a/src/sage/cpython/atexit.pyx
-+++ b/src/sage/cpython/atexit.pyx
-@@ -154,6 +154,10 @@ cdef extern from *:
-     #undef _PyGC_FINALIZED
-     #include "internal/pycore_interp.h"
-     #include "internal/pycore_pystate.h"
-+    #if PY_VERSION_HEX >= 0x030c0000
-+    // struct atexit_callback was renamed in 3.12 to atexit_py_callback
-+    #define atexit_callback atexit_py_callback
-+    #endif
-     static atexit_callback ** _atexit_callbacks(PyObject *self) {
-         PyInterpreterState *interp = _PyInterpreterState_GET();
-         struct atexit_state state = interp->atexit;
-diff --git a/src/sage/cpython/debug.pyx b/src/sage/cpython/debug.pyx
-index 986abff2a99..cdaca3a4854 100644
---- a/src/sage/cpython/debug.pyx
-+++ b/src/sage/cpython/debug.pyx
-@@ -78,7 +78,7 @@ def getattr_debug(obj, name, default=_no_default):
- 
-     EXAMPLES::
- 
--        sage: _ = getattr_debug(list, "reverse")
-+        sage: _ = getattr_debug(list, "reverse")  # not tested - broken in python 3.12
-         getattr_debug(obj=<class 'list'>, name='reverse'):
-           type(obj) = <class 'type'>
-           object has __dict__ slot (<class 'dict'>)
-@@ -123,7 +123,7 @@ def getattr_debug(obj, name, default=_no_default):
-         sage: _ = getattr_debug(1, "foo")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'...
-         sage: _ = getattr_debug(1, "foo", "xyz")
-         getattr_debug(obj=1, name='foo'):
-           type(obj) = <class 'sage.rings.integer.Integer'>
-diff --git a/src/sage/cpython/dict_internal.h b/src/sage/cpython/dict_internal.h
-index 42a57bcb468..a5ee35bc198 100644
---- a/src/sage/cpython/dict_internal.h
-+++ b/src/sage/cpython/dict_internal.h
-@@ -169,6 +169,7 @@ dictkeys_set_index(PyDictKeysObject *keys, Py_ssize_t i, Py_ssize_t ix)
- #else   /* Python >= 3.11 */
- 
- #define Py_BUILD_CORE
-+#undef _PyGC_FINALIZED
- #include <internal/pycore_dict.h>
- 
- /************************************************************/
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 52afed49d64..1f49e5230c3 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -53,12 +53,12 @@ cdef class AttributeErrorMessage:
-         sage: 1.bla  #indirect doctest
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'...
-         sage: x = polygen(ZZ, 'x')
-         sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'...
- 
-     ::
- 
-@@ -144,7 +144,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(X, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: x = X()
-         sage: raw_getattr(x, "prop")
-         <property object at ...>
-@@ -173,7 +173,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(Y, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: y = Y()
-         sage: raw_getattr(y, "prop")
-         <property object at ...>
-@@ -278,7 +278,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     The integer ring is a parent, so, lazy attributes work::
- 
-@@ -289,7 +289,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(17, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     In general, descriptors are not yet well supported, because they
-     often do not accept to be cheated with the type of their instance::
-@@ -305,7 +305,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__weakref__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-     This was caught by :trac:`8296` for which we do a couple more tests::
- 
-@@ -314,7 +314,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: 1.__weakref__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-         sage: n = 1
-         sage: ip = get_ipython()                 # not tested: only works in interactive shell
-@@ -329,7 +329,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__call__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'...
- 
-     TESTS:
- 
-@@ -339,14 +339,14 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, type, "__name__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'...
- 
-     Non-strings as "name" are handled gracefully::
- 
-         sage: getattr_from_other_class(1, type, None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute None
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute None...
-     """
-     if not isinstance(cls, type):
-         raise TypeError(f"{cls!r} is not a type")
-diff --git a/src/sage/cpython/pycore_long.h b/src/sage/cpython/pycore_long.h
-new file mode 100644
-index 00000000000..ff1a73d097a
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.h
-@@ -0,0 +1,98 @@
-+#include "Python.h"
-+#include <stdbool.h>
-+
-+#if PY_VERSION_HEX >= 0x030C00A5
-+#define ob_digit(o)  (((PyLongObject*)o)->long_value.ob_digit)
-+#else
-+#define ob_digit(o)  (((PyLongObject*)o)->ob_digit)
-+#endif
-+
-+#if PY_VERSION_HEX >= 0x030C00A7
-+// taken from cpython:Include/internal/pycore_long.h @ 3.12
-+
-+/* Long value tag bits:
-+ * 0-1: Sign bits value = (1-sign), ie. negative=2, positive=0, zero=1.
-+ * 2: Reserved for immortality bit
-+ * 3+ Unsigned digit count
-+ */
-+#define SIGN_MASK 3
-+#define SIGN_ZERO 1
-+#define SIGN_NEGATIVE 2
-+#define NON_SIZE_BITS 3
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_ZERO;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_NEGATIVE;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    assert(PyLong_Check(op));
-+    return op->long_value.lv_tag >> NON_SIZE_BITS;
-+}
-+
-+#define TAG_FROM_SIGN_AND_SIZE(sign, size) ((1 - (sign)) | ((size) << NON_SIZE_BITS))
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+    assert(size >= 0);
-+    assert(-1 <= sign && sign <= 1);
-+    assert(sign != 0 || size == 0);
-+    op->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sign, (size_t)size);
-+}
-+
-+#else
-+// fallback for < 3.12
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) == 0;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) < 0;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) > 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    Py_ssize_t size = Py_SIZE(op);
-+    return size < 0 ? -size : size;
-+}
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION < 9)
-+// The function Py_SET_SIZE is defined starting with python 3.9.
-+    Py_SIZE(o) = size;
-+#else
-+    Py_SET_SIZE(op, sign < 0 ? -size : size);
-+#endif
-+}
-+
-+#endif
-diff --git a/src/sage/cpython/pycore_long.pxd b/src/sage/cpython/pycore_long.pxd
-new file mode 100644
-index 00000000000..41de637ff18
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.pxd
-@@ -0,0 +1,9 @@
-+from cpython.longintrepr cimport py_long, digit
-+
-+cdef extern from "pycore_long.h":
-+    digit* ob_digit(py_long o)
-+    bint _PyLong_IsZero(py_long o)
-+    bint _PyLong_IsNegative(py_long o)
-+    bint _PyLong_IsPositive(py_long o)
-+    Py_ssize_t _PyLong_DigitCount(py_long o)
-+    void _PyLong_SetSignAndDigitCount(py_long o, int sign, Py_ssize_t size)
-diff --git a/src/sage/crypto/classical.py b/src/sage/crypto/classical.py
-index 616dc861652..be899c781e5 100644
---- a/src/sage/crypto/classical.py
-+++ b/src/sage/crypto/classical.py
-@@ -494,7 +494,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: A.rank_by_chi_square("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_chi_square(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -703,7 +703,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: A.rank_by_squared_differences("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_squared_differences(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -2114,7 +2114,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: S.rank_by_chi_square("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_chi_square(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-@@ -2351,7 +2351,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: S.rank_by_squared_differences("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_squared_differences(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/crypto/mq/mpolynomialsystemgenerator.py b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-index 9028dab1d98..4416d9ef7f6 100644
---- a/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-+++ b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-@@ -156,7 +156,7 @@ def sbox(self):
-             sage: msg.sbox()
-             Traceback (most recent call last):
-             ...
--            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'
-+            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'...
-         """
-         return self._sbox
- 
-diff --git a/src/sage/data_structures/bitset.pyx b/src/sage/data_structures/bitset.pyx
-index 446062554c1..d9906b5edd2 100644
---- a/src/sage/data_structures/bitset.pyx
-+++ b/src/sage/data_structures/bitset.pyx
-@@ -967,7 +967,7 @@ cdef class FrozenBitset:
-             sage: None | FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute '_union'
-+            AttributeError: 'NoneType' object has no attribute '_union'...
-         """
-         return self._union(other)
- 
-@@ -1037,7 +1037,7 @@ cdef class FrozenBitset:
-             sage: None & FrozenBitset("101011")
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'intersection'
-+            AttributeError: 'NoneType' object has no attribute 'intersection'...
-         """
-         return self.intersection(other)
- 
-@@ -1106,7 +1106,7 @@ cdef class FrozenBitset:
-             sage: None - FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'difference'
-+            AttributeError: 'NoneType' object has no attribute 'difference'...
-         """
-         return self.difference(other)
- 
-@@ -1179,7 +1179,7 @@ cdef class FrozenBitset:
-             sage: None ^^ FrozenBitset('11111' * 10)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'
-+            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'...
-         """
-         return self.symmetric_difference(other)
- 
-diff --git a/src/sage/doctest/reporting.py b/src/sage/doctest/reporting.py
-index 361fea344c2..a3947c07e01 100644
---- a/src/sage/doctest/reporting.py
-+++ b/src/sage/doctest/reporting.py
-@@ -368,7 +368,7 @@ def report(self, source, timeout, return_code, results, output, pid=None):
-             sage: DTR.report(None, None, None, None, None)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'basename'
-+            AttributeError: 'NoneType' object has no attribute 'basename'...
- 
-         The only-errors mode does not output anything on success::
- 
-diff --git a/src/sage/dynamics/finite_dynamical_system.py b/src/sage/dynamics/finite_dynamical_system.py
-index e5fbf568b7e..4295070615a 100644
---- a/src/sage/dynamics/finite_dynamical_system.py
-+++ b/src/sage/dynamics/finite_dynamical_system.py
-@@ -240,7 +240,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-@@ -252,7 +252,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-diff --git a/src/sage/geometry/cone.py b/src/sage/geometry/cone.py
-index f0a8620011a..53f78a4b7b6 100644
---- a/src/sage/geometry/cone.py
-+++ b/src/sage/geometry/cone.py
-@@ -340,7 +340,7 @@ def Cone(rays, lattice=None, check=True, normalize=True):
-         sage: Cone([(1,0), (0,1)], check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     You can construct different "not" cones: not full-dimensional, not
-     strictly convex, not containing any rays::
-diff --git a/src/sage/geometry/fan.py b/src/sage/geometry/fan.py
-index 258544012fe..3aecc84a55b 100644
---- a/src/sage/geometry/fan.py
-+++ b/src/sage/geometry/fan.py
-@@ -443,7 +443,7 @@ def Fan(cones, rays=None, lattice=None, check=True, normalize=True,
-         sage: P2c = Fan(cones, rays, check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     Yet another way is to use functions :func:`FaceFan` and :func:`NormalFan`
-     to construct fans from :class:`lattice polytopes
-diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-index f0ac1e774a7..f03f0f832ff 100644
---- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-+++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-@@ -351,7 +351,7 @@ cdef class FaceIterator_base(SageObject):
-             sage: FaceIterator_base(2)  # indirect doctest
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'...
-         """
-         cdef int i
-         sig_free(self.structure.atom_rep)
-@@ -1945,7 +1945,8 @@ cdef inline int next_face_loop(iter_t structure) nogil except -1:
-         # The function is not supposed to be called,
-         # just prevent it from crashing.
-         # Actually raising an error here results in a bad branch prediction.
--        return -1
-+        # But return -1 results in a crash with python 3.12
-+        raise StopIteration
- 
-     # Getting ``[faces, n_faces, n_visited_all]`` according to dimension.
-     cdef face_list_t* faces = &structure.new_faces[structure.current_dimension]
-diff --git a/src/sage/geometry/toric_plotter.py b/src/sage/geometry/toric_plotter.py
-index 50b4008eb0f..950e3ba7ff8 100644
---- a/src/sage/geometry/toric_plotter.py
-+++ b/src/sage/geometry/toric_plotter.py
-@@ -706,7 +706,7 @@ def set_rays(self, generators):
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ToricPlotter' object has no attribute 'rays'
-+            AttributeError: 'ToricPlotter' object has no attribute 'rays'...
-             sage: tp.set_rays([(0,1)])
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Graphics object consisting of 2 graphics primitives
-diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
-index d0ec214bb3b..c8098ad578a 100644
---- a/src/sage/groups/matrix_gps/finitely_generated.py
-+++ b/src/sage/groups/matrix_gps/finitely_generated.py
-@@ -268,7 +268,7 @@ def MatrixGroup(*gens, **kwds):
-         sage: SL2C.gens()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'
-+        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'...
-     """
-     if isinstance(gens[-1], dict):   # hack for unpickling
-         kwds.update(gens[-1])
-diff --git a/src/sage/homology/chains.py b/src/sage/homology/chains.py
-index 87c0947c0b0..b9a54940943 100644
---- a/src/sage/homology/chains.py
-+++ b/src/sage/homology/chains.py
-@@ -298,7 +298,7 @@ def is_cycle(self):
-                 sage: chain.is_cocycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -325,7 +325,7 @@ def is_boundary(self):
-                 sage: chain.is_coboundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -539,7 +539,7 @@ def is_cocycle(self):
-                 sage: cochain.is_cycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -566,7 +566,7 @@ def is_coboundary(self):
-                 sage: cochain.is_boundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -604,7 +604,7 @@ def eval(self, other):
-                 sage: z.eval(c) # z is not a cochain
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'...
-                 sage: c.eval(c) # can't evaluate a cochain on a cochain
-                 Traceback (most recent call last):
-                 ...
-diff --git a/src/sage/homology/free_resolution.py b/src/sage/homology/free_resolution.py
-index e3d38de4240..280a479b438 100644
---- a/src/sage/homology/free_resolution.py
-+++ b/src/sage/homology/free_resolution.py
-@@ -275,7 +275,7 @@ def differential(self, i):
-             sage: FreeResolution.differiental(r, 1)
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'FreeResolution' has no attribute 'differiental'
-+            AttributeError: type object 'FreeResolution' has no attribute 'differiental'...
-         """
- 
-     def target(self):
-diff --git a/src/sage/interfaces/magma.py b/src/sage/interfaces/magma.py
-index b7a0ac20d03..529bfbc349b 100644
---- a/src/sage/interfaces/magma.py
-+++ b/src/sage/interfaces/magma.py
-@@ -824,7 +824,7 @@ def _coerce_from_special_method(self, x):
-             sage: magma._coerce_from_special_method('2 + 3')  # optional - magma
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute '_magma_init_'
-+            AttributeError: 'str' object has no attribute '_magma_init_'...
-         """
-         s = x._magma_init_(self)
-         a = self(s)
-diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
-index 58499396d6c..16119d20815 100644
---- a/src/sage/lfunctions/dokchitser.py
-+++ b/src/sage/lfunctions/dokchitser.py
-@@ -418,8 +418,8 @@ def init_coeffs(self, v, cutoff=1,
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
-index bbf289aa21c..e4968866303 100644
---- a/src/sage/lfunctions/pari.py
-+++ b/src/sage/lfunctions/pari.py
-@@ -141,8 +141,8 @@ def init_coeffs(self, v, cutoff=None, w=1):
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
-index 478caf9f9d0..363024ae281 100644
---- a/src/sage/libs/gap/element.pyx
-+++ b/src/sage/libs/gap/element.pyx
-@@ -380,7 +380,7 @@ cdef GapElement make_GapElement(parent, Obj obj):
-         sage: libgap(None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute '_libgap_init_'
-+        AttributeError: 'NoneType' object has no attribute '_libgap_init_'...
-     """
-     cdef GapElement r = GapElement.__new__(GapElement)
-     r._initialize(parent, obj)
-diff --git a/src/sage/libs/gmp/pylong.pxd b/src/sage/libs/gmp/pylong.pxd
-index a73f1da6d6f..84e1bb8cd87 100644
---- a/src/sage/libs/gmp/pylong.pxd
-+++ b/src/sage/libs/gmp/pylong.pxd
-@@ -2,9 +2,10 @@
- Various functions to deal with conversion mpz <-> Python int/long
- """
- 
-+from cpython.longintrepr cimport py_long
- from sage.libs.gmp.types cimport *
- 
- cdef mpz_get_pylong(mpz_srcptr z)
- cdef mpz_get_pyintlong(mpz_srcptr z)
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1
- cdef Py_hash_t mpz_pythonhash(mpz_srcptr z)
-diff --git a/src/sage/libs/gmp/pylong.pyx b/src/sage/libs/gmp/pylong.pyx
-index d5993cca5a5..1a36c29d3fa 100644
---- a/src/sage/libs/gmp/pylong.pyx
-+++ b/src/sage/libs/gmp/pylong.pyx
-@@ -28,6 +28,8 @@ AUTHORS:
- from cpython.object cimport Py_SIZE
- from cpython.long cimport PyLong_FromLong
- from cpython.longintrepr cimport _PyLong_New, py_long, digit, PyLong_SHIFT
-+from sage.cpython.pycore_long cimport (ob_digit, _PyLong_IsNegative,
-+    _PyLong_DigitCount, _PyLong_SetSignAndDigitCount)
- from .mpz cimport *
- 
- cdef extern from *:
-@@ -60,12 +62,9 @@ cdef mpz_get_pylong_large(mpz_srcptr z):
-     """
-     cdef size_t nbits = mpz_sizeinbase(z, 2)
-     cdef size_t pylong_size = (nbits + PyLong_SHIFT - 1) // PyLong_SHIFT
--    L = _PyLong_New(pylong_size)
--    mpz_export(L.ob_digit, NULL,
--            -1, sizeof(digit), 0, PyLong_nails, z)
--    if mpz_sgn(z) < 0:
--        # Set correct size
--        Py_SET_SIZE(L, -pylong_size)
-+    cdef py_long L = _PyLong_New(pylong_size)
-+    mpz_export(ob_digit(L), NULL, -1, sizeof(digit), 0, PyLong_nails, z)
-+    _PyLong_SetSignAndDigitCount(L, mpz_sgn(z), pylong_size)
-     return L
- 
- 
-@@ -88,16 +87,13 @@ cdef mpz_get_pyintlong(mpz_srcptr z):
-     return mpz_get_pylong_large(z)
- 
- 
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1:
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1:
-     """
-     Convert a Python ``long`` `L` to an ``mpz``.
-     """
--    cdef Py_ssize_t pylong_size = Py_SIZE(L)
--    if pylong_size < 0:
--        pylong_size = -pylong_size
--    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails,
--            (<py_long>L).ob_digit)
--    if Py_SIZE(L) < 0:
-+    cdef Py_ssize_t pylong_size = _PyLong_DigitCount(L)
-+    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails, ob_digit(L))
-+    if _PyLong_IsNegative(L):
-         mpz_neg(z, z)
- 
- 
-diff --git a/src/sage/manifolds/calculus_method.py b/src/sage/manifolds/calculus_method.py
-index f5830c0bc45..303dde6cd13 100644
---- a/src/sage/manifolds/calculus_method.py
-+++ b/src/sage/manifolds/calculus_method.py
-@@ -257,7 +257,7 @@ def simplify(self, expression, method=None):
-             sage: cm.simplify(f)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'
-+            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'...
- 
-         In the present case, one should either transform ``f`` to a SymPy
-         object::
-diff --git a/src/sage/manifolds/differentiable/vectorfield_module.py b/src/sage/manifolds/differentiable/vectorfield_module.py
-index d954b5d4839..af4bfb0ceec 100644
---- a/src/sage/manifolds/differentiable/vectorfield_module.py
-+++ b/src/sage/manifolds/differentiable/vectorfield_module.py
-@@ -885,7 +885,7 @@ def tensor(self, *args, **kwds):
-             sage: XM.tensor(XM).tensor(XM.dual().tensor(XM.dual()))
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'
-+            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'...
- 
-         .. SEEALSO::
- 
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 86aca6e00d8..a5f6716e731 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15303,7 +15303,7 @@ cdef class Matrix(Matrix1):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
--            has no attribute 'conjugate'
-+            has no attribute 'conjugate'...
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/matrix/matrix_cyclo_dense.pyx b/src/sage/matrix/matrix_cyclo_dense.pyx
-index f54f3423ded..a49bb6240e6 100644
---- a/src/sage/matrix/matrix_cyclo_dense.pyx
-+++ b/src/sage/matrix/matrix_cyclo_dense.pyx
-@@ -847,7 +847,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense):
-             sage: A.set_mutable()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'
-+            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'...
-             sage: B = A.__copy__()
-             sage: B[0,0] = 20
-             sage: B[0,0]
-diff --git a/src/sage/matrix/matrix_gfpn_dense.pyx b/src/sage/matrix/matrix_gfpn_dense.pyx
-index 4cccf473de1..8e8e4d7336b 100644
---- a/src/sage/matrix/matrix_gfpn_dense.pyx
-+++ b/src/sage/matrix/matrix_gfpn_dense.pyx
-@@ -159,7 +159,7 @@ cdef class FieldConverter_class:
-             sage: C.field_to_fel('foo')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'to_integer'
-+            AttributeError: 'str' object has no attribute 'to_integer'...
-         """
-         return FfFromInt(x.to_integer())
- 
-diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py
-index 6aab58352be..b5e6f52349b 100644
---- a/src/sage/matrix/matrix_space.py
-+++ b/src/sage/matrix/matrix_space.py
-@@ -1619,7 +1619,7 @@ def __getitem__(self, x):
-             sage: MS[2]
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'
-+            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'...
-         """
-         if isinstance(x, (integer.Integer, int)):
-             return self.list()[x]
-diff --git a/src/sage/matroids/lean_matrix.pyx b/src/sage/matroids/lean_matrix.pyx
-index 54c68e637c0..a137cbf70e5 100644
---- a/src/sage/matroids/lean_matrix.pyx
-+++ b/src/sage/matroids/lean_matrix.pyx
-@@ -1,5 +1,4 @@
- # sage.doctest: optional - sage.rings.finite_rings
--# cython: profile=True
- """
- Lean matrices
- 
-diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx
-index 36f563aa433..318c82f2b64 100644
---- a/src/sage/matroids/linear_matroid.pyx
-+++ b/src/sage/matroids/linear_matroid.pyx
-@@ -1134,7 +1134,7 @@ cdef class LinearMatroid(BasisExchangeMatroid):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.matroids.basis_matroid.BasisMatroid' object
--            has no attribute 'base_ring'
-+            has no attribute 'base_ring'...
-             sage: from sage.matroids.advanced import *
-             sage: M4 = BinaryMatroid(Matrix(M1))
-             sage: M5 = LinearMatroid(reduced_matrix=Matrix(GF(2), [[-1, 0, 1],
-diff --git a/src/sage/misc/dev_tools.py b/src/sage/misc/dev_tools.py
-index e7bf176592c..3ece7db2894 100644
---- a/src/sage/misc/dev_tools.py
-+++ b/src/sage/misc/dev_tools.py
-@@ -171,6 +171,7 @@ def load_submodules(module=None, exclude_pattern=None):
-         load sage.geometry.polyhedron.ppl_lattice_polygon... succeeded
-     """
-     from .package_dir import walk_packages
-+    import importlib.util
- 
-     if module is None:
-         import sage
-@@ -194,8 +195,12 @@ def load_submodules(module=None, exclude_pattern=None):
-         try:
-             sys.stdout.write("load %s..." % module_name)
-             sys.stdout.flush()
--            loader = importer.find_module(module_name)
--            loader.load_module(module_name)
-+            # see
-+            # https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
-+            spec = importer.find_spec(module_name)
-+            module = importlib.util.module_from_spec(spec)
-+            sys.modules[module_name] = module
-+            spec.loader.exec_module(module)
-             sys.stdout.write(" succeeded\n")
-         except (ValueError, AttributeError, TypeError, ImportError):
-             # we might get error because of cython code that has been
-diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py
-index c922b8f6f12..03697f08b7c 100644
---- a/src/sage/misc/functional.py
-+++ b/src/sage/misc/functional.py
-@@ -86,7 +86,7 @@ def base_field(x):
-         sage: R.base_field()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'
-+        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'...
-     """
-     try:
-         return x.base_field()
-diff --git a/src/sage/misc/instancedoc.pyx b/src/sage/misc/instancedoc.pyx
-index d8e1e4ac536..44ee70f64ba 100644
---- a/src/sage/misc/instancedoc.pyx
-+++ b/src/sage/misc/instancedoc.pyx
-@@ -256,7 +256,7 @@ cdef class InstanceDocDescriptor:
-             sage: descr.__delete__(obj)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'X' object has no attribute '__doc__'
-+            AttributeError: 'X' object has no attribute '__doc__'...
- 
-             sage: descr.__delete__([])
-             Traceback (most recent call last):
-diff --git a/src/sage/misc/lazy_attribute.pyx b/src/sage/misc/lazy_attribute.pyx
-index bdbec3b3ba1..1f07870b8ec 100644
---- a/src/sage/misc/lazy_attribute.pyx
-+++ b/src/sage/misc/lazy_attribute.pyx
-@@ -441,37 +441,37 @@ class lazy_attribute(_lazy_attribute):
-             sage: B().unimplemented_A # todo: not implemented
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'super' object has no attribute 'unimplemented_A'
-+            AttributeError: 'super' object has no attribute 'unimplemented_A'...
- 
-     We now make some systematic checks::
- 
-         sage: B().unimplemented_A
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: B().unimplemented_B
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: B().unimplemented_AB
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: B().unimplemented_B_implemented_A
-         1
- 
-         sage: C().unimplemented_A()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: C().unimplemented_B()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: C().unimplemented_AB()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: C().unimplemented_B_implemented_A # todo: not implemented
-         1
-     """
-diff --git a/src/sage/misc/object_multiplexer.py b/src/sage/misc/object_multiplexer.py
-index d4e811ef16e..00fd89d6652 100644
---- a/src/sage/misc/object_multiplexer.py
-+++ b/src/sage/misc/object_multiplexer.py
-@@ -85,7 +85,7 @@ def __getattr__(self, name):
-             sage: m.__bork__
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Multiplex' has no attribute '__bork__'
-+            AttributeError: 'Multiplex' has no attribute '__bork__'...
-         """
-         if name.startswith("__"):
-             raise AttributeError("'Multiplex' has no attribute '%s'" % name)
-diff --git a/src/sage/misc/sage_input.py b/src/sage/misc/sage_input.py
-index 66e78ecccbc..00e8d96ee9e 100644
---- a/src/sage/misc/sage_input.py
-+++ b/src/sage/misc/sage_input.py
-@@ -3461,7 +3461,7 @@ def verify_same(a, b):
-         sage: verify_same(1, 1r)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_same(1r, 1)
-         Traceback (most recent call last):
-         ...
-@@ -3525,7 +3525,7 @@ def verify_si_answer(x, answer, preparse):
-         sage: verify_si_answer(1, '1', False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_si_answer(1, 'ZZ(1)', None)
-     """
-     from sage.misc.sage_eval import sage_eval
-diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py
-index f0545be7d81..811afc48755 100644
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -602,7 +602,7 @@ def visit_Num(self, node):
-             On Python 3 negative numbers are parsed first, for some reason, as
-             a UnaryOp node.
-         """
--        return node.n
-+        return node.value
- 
-     def visit_Str(self, node):
-         r"""
-@@ -624,7 +624,7 @@ def visit_Str(self, node):
-             sage: [vis(s) for s in ['"abstract"', "'syntax'", r'''r"tr\ee"''']]
-             ['abstract', 'syntax', 'tr\\ee']
-         """
--        return node.s
-+        return node.value
- 
-     def visit_List(self, node):
-         """
-diff --git a/src/sage/modules/fp_graded/steenrod/module.py b/src/sage/modules/fp_graded/steenrod/module.py
-index 18460b0e9a1..4acfa6b4002 100755
---- a/src/sage/modules/fp_graded/steenrod/module.py
-+++ b/src/sage/modules/fp_graded/steenrod/module.py
-@@ -70,7 +70,7 @@
-     sage: SteenrodFPModule(ZZ, [0])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'
-+    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'...
- 
- AUTHORS:
- 
-diff --git a/src/sage/monoids/trace_monoid.py b/src/sage/monoids/trace_monoid.py
-index 00baa4d14f8..f8176a1e1f2 100644
---- a/src/sage/monoids/trace_monoid.py
-+++ b/src/sage/monoids/trace_monoid.py
-@@ -40,7 +40,6 @@
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from collections import OrderedDict
- from itertools import repeat, chain, product
- 
- from sage.misc.cachefunc import cached_method
-@@ -633,14 +632,14 @@ def _compute_dependence_stack(self, x):
-             sage: x = b*a*d*a*c*b
-             sage: M._compute_dependence_stack(x)
-             ({a, b, c, d},
--             OrderedDict([(a, [False, False, True, True, False]),
--                          (b, [True, False, False, False, True]),
--                          (c, [True, False, False, False]),
--                          (d, [False, False, True, False])]))
-+             {a: [False, False, True, True, False],
-+              b: [True, False, False, False, True],
-+              c: [True, False, False, False],
-+              d: [False, False, True, False]})
-         """
-         independence = self._independence
-         generators_set = set(e for e, _ in x)
--        stacks = OrderedDict(sorted((g, []) for g in generators_set))
-+        stacks = dict(sorted((g, []) for g in generators_set))
-         for generator, times in reversed(list(x)):
-             stacks[generator].extend(repeat(True, times))
-             for other_gen in generators_set:
-diff --git a/src/sage/parallel/map_reduce.py b/src/sage/parallel/map_reduce.py
-index 11e0673ee91..5441943731d 100644
---- a/src/sage/parallel/map_reduce.py
-+++ b/src/sage/parallel/map_reduce.py
-@@ -1234,7 +1234,7 @@ def finish(self):
-             sage: S.print_communication_statistics()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'RESetMPExample' object has no attribute '_stats'
-+            AttributeError: 'RESetMPExample' object has no attribute '_stats'...
- 
-             sage: S.finish()
- 
-diff --git a/src/sage/plot/colors.py b/src/sage/plot/colors.py
-index 8c0db2b3c34..3281199400b 100644
---- a/src/sage/plot/colors.py
-+++ b/src/sage/plot/colors.py
-@@ -1099,7 +1099,7 @@ def __getattr__(self, name):
-             sage: cols.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ColorsDict' has no attribute or colormap punk
-+            AttributeError: 'ColorsDict' has no attribute or colormap punk...
-         """
-         try:
-             return self[name]
-@@ -1599,7 +1599,7 @@ def __getattr__(self, name):
-             sage: maps.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Colormaps' has no attribute or colormap punk
-+            AttributeError: 'Colormaps' has no attribute or colormap punk...
-             sage: maps['punk']
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/rings/asymptotic/asymptotic_ring.py b/src/sage/rings/asymptotic/asymptotic_ring.py
-index b07319382d3..994490e6616 100644
---- a/src/sage/rings/asymptotic/asymptotic_ring.py
-+++ b/src/sage/rings/asymptotic/asymptotic_ring.py
-@@ -1091,7 +1091,7 @@ def monomial_coefficient(self, monomial):
-             sage: O(n).monomial_coefficient(n)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'
-+            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'...
- 
-         The ``monomial`` must be exact::
- 
-diff --git a/src/sage/rings/asymptotic/growth_group.py b/src/sage/rings/asymptotic/growth_group.py
-index 27c14592bca..5be12537d62 100644
---- a/src/sage/rings/asymptotic/growth_group.py
-+++ b/src/sage/rings/asymptotic/growth_group.py
-@@ -1572,7 +1572,7 @@ def variable_names(self):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'GenericGrowthGroup_with_category.element_class' object
--            has no attribute 'is_one'
-+            has no attribute 'is_one'...
-         """
-         if self.is_one():
-             return tuple()
-diff --git a/src/sage/rings/ideal.py b/src/sage/rings/ideal.py
-index d36d9406f32..01c9fa3bf2d 100644
---- a/src/sage/rings/ideal.py
-+++ b/src/sage/rings/ideal.py
-@@ -1553,7 +1553,7 @@ def gcd(self, other):
-             sage: J.gcd(I)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Ideal_generic' object has no attribute 'gcd'
-+            AttributeError: 'Ideal_generic' object has no attribute 'gcd'...
- 
-         Note::
- 
-diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
-index 7fe89197011..8832d27e8ea 100644
---- a/src/sage/rings/number_field/number_field.py
-+++ b/src/sage/rings/number_field/number_field.py
-@@ -3823,7 +3823,7 @@ def primes_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
-         """
-         if degree is not None:
-             degree = ZZ(degree)
-@@ -3917,7 +3917,7 @@ def prime_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
- 
-         """
-         ids = self.primes_above(x, degree)
-@@ -5926,7 +5926,7 @@ def factor(self, n):
-             sage: L.factor(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'...
- 
-         AUTHORS:
- 
-@@ -12698,7 +12698,7 @@ def is_real_place(v):
-         sage: is_real_place(v_fin)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'
-+        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'...
- 
-     """
-     RR = sage.rings.real_mpfr.RealField(53)
-diff --git a/src/sage/rings/padics/generic_nodes.py b/src/sage/rings/padics/generic_nodes.py
-index 7047020edec..b6b514d4005 100644
---- a/src/sage/rings/padics/generic_nodes.py
-+++ b/src/sage/rings/padics/generic_nodes.py
-@@ -740,7 +740,7 @@ def _get_element_class(self, name=None):
-             sage: R._get_element_class("foobar")
-             Traceback (most recent call last):
-             ...
--            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'
-+            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'...
-         """
-         if name is None:
-             return self.Element
-diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx
-index c5a1129aecf..a5b7f937cfe 100644
---- a/src/sage/rings/polynomial/polynomial_element.pyx
-+++ b/src/sage/rings/polynomial/polynomial_element.pyx
-@@ -10793,7 +10793,7 @@ cdef class Polynomial(CommutativePolynomial):
-             sage: (y**2 + x).nth_root(2)
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... has no attribute 'nth_root'
-+            AttributeError: ... has no attribute 'nth_root'...
- 
-         TESTS::
- 
-@@ -11831,7 +11831,7 @@ cdef class Polynomial_generic_dense(Polynomial):
-             sage: int(1) // x  # check that this doesn't segfault
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'int' has no attribute 'base_ring'
-+            AttributeError: type object 'int' has no attribute 'base_ring'...
-         """
-         if have_same_parent(self, right):
-             return (<Polynomial_generic_dense>self)._floordiv_(<Polynomial_generic_dense>right)
-diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-index e372be888ee..aca4f08420f 100644
---- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
-+++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-@@ -2362,7 +2362,7 @@ def field_extension(self, names):
-             sage: F, g, h = S.field_extension('b')                                      # needs sage.rings.finite_rings
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'
-+            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'...
- 
-         Over a finite field, the corresponding field extension is not a
-         number field::
-diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx
-index 5273891a5b0..a6e999b8805 100644
---- a/src/sage/rings/ring.pyx
-+++ b/src/sage/rings/ring.pyx
-@@ -1734,7 +1734,7 @@ cdef class IntegralDomain(CommutativeRing):
-             sage: Z5.is_integrally_closed()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'
-+            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'...
-         """
-         raise NotImplementedError
- 
-diff --git a/src/sage/sat/solvers/satsolver.pyx b/src/sage/sat/solvers/satsolver.pyx
-index c2f41b18f55..1c4ac400cb6 100644
---- a/src/sage/sat/solvers/satsolver.pyx
-+++ b/src/sage/sat/solvers/satsolver.pyx
-@@ -375,10 +375,10 @@ def SAT(solver=None, *args, **kwds):
-         DIMACS Solver: 'kissat -q {input}'
-     """
-     if solver is None:
--        import pkgutil
--        if pkgutil.find_loader('pycryptosat') is not None:
-+        from importlib.util import find_spec
-+        if find_spec('pycryptosat') is not None:
-             solver = "cryptominisat"
--        elif pkgutil.find_loader('pycosat') is not None:
-+        elif find_spec('pycosat') is not None:
-             solver = "picosat"
-         else:
-             solver = "LP"
-diff --git a/src/sage/schemes/toric/morphism.py b/src/sage/schemes/toric/morphism.py
-index 1c8944b6dfc..5d64d632f97 100644
---- a/src/sage/schemes/toric/morphism.py
-+++ b/src/sage/schemes/toric/morphism.py
-@@ -246,7 +246,7 @@
-     Traceback (most recent call last):
-     ...
-     AttributeError: 'SchemeMorphism_fan_toric_variety' object
--    has no attribute 'fiber_generic'
-+    has no attribute 'fiber_generic'...
- 
- Let's use factorization mentioned above::
- 
-diff --git a/src/sage/sets/disjoint_union_enumerated_sets.py b/src/sage/sets/disjoint_union_enumerated_sets.py
-index 3dea567a779..5c5e08612f2 100644
---- a/src/sage/sets/disjoint_union_enumerated_sets.py
-+++ b/src/sage/sets/disjoint_union_enumerated_sets.py
-@@ -597,7 +597,7 @@ def Element(self):
-             sage: U.Element
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'
-+            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'...
-         """
-         if not self._facade:
-             return ElementWrapper
-diff --git a/src/sage/sets/set.py b/src/sage/sets/set.py
-index a1789c61300..112d3d8dc3b 100644
---- a/src/sage/sets/set.py
-+++ b/src/sage/sets/set.py
-@@ -163,7 +163,7 @@ def Set(X=None, category=None):
-         sage: sorted(B.list(), key=repr)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'Set_object_with_category' object has no attribute 'list'
-+        AttributeError: 'Set_object_with_category' object has no attribute 'list'...
-         sage: type(B)
-         <class 'sage.sets.set.Set_object_with_category'>
- 
-diff --git a/src/sage/structure/category_object.pyx b/src/sage/structure/category_object.pyx
-index b6a7eaecb5b..c06933494dc 100644
---- a/src/sage/structure/category_object.pyx
-+++ b/src/sage/structure/category_object.pyx
-@@ -836,7 +836,7 @@ cdef class CategoryObject(SageObject):
-             sage: Sets().example().sadfasdf
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'
-+            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'...
-         """
-         return self.getattr_from_category(name)
- 
-diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx
-index caae7e40ffc..543506e9a74 100644
---- a/src/sage/structure/element.pyx
-+++ b/src/sage/structure/element.pyx
-@@ -219,7 +219,7 @@ the parents::
-     sage: x._add_(x)
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-     sage: x + x
-     Traceback (most recent call last):
-     ...
-@@ -478,13 +478,13 @@ cdef class Element(SageObject):
-             sage: 1.blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'...
-             sage: Semigroups().example().an_element().is_idempotent
-             <bound method LeftZeroSemigroup.Element.is_idempotent of 42>
-             sage: Semigroups().example().an_element().blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'
-+            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'...
-         """
-         return self.getattr_from_category(name)
- 
-@@ -1269,7 +1269,7 @@ cdef class Element(SageObject):
-             sage: e._add_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-         """
-         try:
-             python_op = (<object>self)._add_
-@@ -1381,7 +1381,7 @@ cdef class Element(SageObject):
-             sage: e._sub_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'...
-         """
-         try:
-             python_op = (<object>self)._sub_
-@@ -1435,7 +1435,7 @@ cdef class Element(SageObject):
-             sage: e._neg_()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'...
-         """
-         try:
-             python_op = (<object>self)._neg_
-@@ -1549,7 +1549,7 @@ cdef class Element(SageObject):
-             sage: e._mul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'...
-         """
-         try:
-             python_op = (<object>self)._mul_
-@@ -1662,7 +1662,7 @@ cdef class Element(SageObject):
-             sage: e._matmul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'...
-         """
-         try:
-             python_op = (<object>self)._matmul_
-@@ -1765,7 +1765,7 @@ cdef class Element(SageObject):
-             sage: e._div_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'...
-         """
-         try:
-             python_op = (<object>self)._div_
-@@ -1865,7 +1865,7 @@ cdef class Element(SageObject):
-             sage: e._floordiv_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'...
-         """
-         try:
-             python_op = (<object>self)._floordiv_
-@@ -1965,7 +1965,7 @@ cdef class Element(SageObject):
-             sage: e._mod_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'...
-         """
-         try:
-             python_op = (<object>self)._mod_
-@@ -2092,7 +2092,7 @@ cdef class Element(SageObject):
-             sage: e._pow_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'...
-         """
-         try:
-             python_op = (<object>self)._pow_
-@@ -2122,7 +2122,7 @@ cdef class Element(SageObject):
-             sage: e._pow_int(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'...
-         """
-         try:
-             python_op = (<object>self)._pow_int
-@@ -2856,7 +2856,7 @@ cdef class RingElement(ModuleElement):
-             sage: m.is_nilpotent()                                                      # needs sage.modules
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... object has no attribute 'is_nilpotent'
-+            AttributeError: '...' object has no attribute 'is_nilpotent'...
-         """
-         if self.is_unit():
-             return False
-@@ -4671,7 +4671,7 @@ def coerce_binop(method):
-         sage: x.test_add(CC(2))
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'
-+        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'...
- 
-     TESTS:
- 
-diff --git a/src/sage/structure/sequence.py b/src/sage/structure/sequence.py
-index 0c700c1fb81..c3972532ac3 100644
---- a/src/sage/structure/sequence.py
-+++ b/src/sage/structure/sequence.py
-@@ -854,7 +854,7 @@ def __getattr__(self, name):
-             sage: S.universe()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'...
-             sage: S._Sequence__universe = 'foobar'
-             sage: S.universe()
-             'foobar'
-@@ -867,7 +867,7 @@ def __getattr__(self, name):
-             sage: hash(S)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'...
-             sage: S._Sequence__hash = int(34)
-             sage: hash(S)
-             34
-diff --git a/src/sage/symbolic/assumptions.py b/src/sage/symbolic/assumptions.py
-index 7dcb15f0d85..15f6fa07ce6 100644
---- a/src/sage/symbolic/assumptions.py
-+++ b/src/sage/symbolic/assumptions.py
-@@ -636,7 +636,7 @@ def assume(*args):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no
--        attribute 'assume'
-+        attribute 'assume'...
- 
-     Ensure that we can combine the two types of assumptions, as documented::
- 
-diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx
-index 0f251ac4e5c..66f624141b3 100644
---- a/src/sage/symbolic/expression.pyx
-+++ b/src/sage/symbolic/expression.pyx
-@@ -13712,7 +13712,7 @@ cdef get_dynamic_class_for_function(unsigned serial):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.symbolic.expression.Expression' object has no
--        attribute 'argp1'
-+        attribute 'argp1'...
-         sage: t = (e + 1).op[0]; t
-         tfunc(x)
-         sage: t
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index c4152e092e3..4bcf45e8793 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -67,6 +67,7 @@
- #include "archive.h"
- #include "tostring.h"
- #include "utils.h"
-+#include "../../cpython/pycore_long.h"
- 
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wdeprecated-register"
-@@ -706,18 +707,12 @@ static long _mpq_pythonhash(mpq_t the_rat)
- // Initialize an mpz_t from a Python long integer
- static void _mpz_set_pylong(mpz_t z, PyLongObject* l)
- {
--    Py_ssize_t pylong_size = Py_SIZE(l);
--    int sign = 1;
--
--    if (pylong_size < 0) {
--        pylong_size = -pylong_size;
--        sign = -1;
--    }
-+    Py_ssize_t pylong_size = _PyLong_DigitCount(l);
- 
-     mpz_import(z, pylong_size, -1, sizeof(digit), 0,
--               8*sizeof(digit) - PyLong_SHIFT, l->ob_digit);
-+               8*sizeof(digit) - PyLong_SHIFT, ob_digit(l));
- 
--    if (sign < 0)
-+    if (_PyLong_IsNegative(l))
-         mpz_neg(z, z);
- }
- 
-diff --git a/src/sage/symbolic/pynac_impl.pxi b/src/sage/symbolic/pynac_impl.pxi
-index 68c31dcfde7..7fd7c3b314b 100644
---- a/src/sage/symbolic/pynac_impl.pxi
-+++ b/src/sage/symbolic/pynac_impl.pxi
-@@ -619,7 +619,7 @@ def tolerant_is_symbol(a):
-         sage: None.is_symbol()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute 'is_symbol'
-+        AttributeError: 'NoneType' object has no attribute 'is_symbol'...
-     """
-     try:
-         return a.is_symbol()
diff --git a/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch b/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
new file mode 100644
index 0000000000000..1e695c2d9d106
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
@@ -0,0 +1,134 @@
+diff --git a/src/sage/quadratic_forms/quadratic_form__neighbors.py b/src/sage/quadratic_forms/quadratic_form__neighbors.py
+index fb781e20122..ec853cd52ef 100644
+--- a/src/sage/quadratic_forms/quadratic_form__neighbors.py
++++ b/src/sage/quadratic_forms/quadratic_form__neighbors.py
+@@ -74,6 +74,10 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+         sage: v = Q.find_primitive_p_divisible_vector__next(5, v); v
+         (1, 0)
+         sage: v = Q.find_primitive_p_divisible_vector__next(5, v); v
++        sage: v = Q.find_primitive_p_divisible_vector__next(2) ; v
++        (0, 1)
++        sage: v = Q.find_primitive_p_divisible_vector__next(2, v) ; v
++        (1, 0)
+         sage: Q = QuadraticForm(QQ, matrix.diagonal([1,1,1,1]))
+         sage: v = Q.find_primitive_p_divisible_vector__next(2)
+         sage: Q(v)
+@@ -83,6 +87,9 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+     n = self.dim()
+     if v is None:
+         w = vector(ZZ, [0] * (n - 1) + [1])
++        a = self(w)
++        if a in ZZ and (a % p == 0):
++            return w
+     else:
+         w = deepcopy(v)
+ 
+@@ -132,7 +139,7 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+             return w
+ 
+ 
+-def find_p_neighbor_from_vec(self, p, y):
++def find_p_neighbor_from_vec(self, p, y, return_matrix=False):
+     r"""
+     Return the `p`-neighbor of ``self`` defined by ``y``.
+ 
+@@ -147,25 +154,32 @@ def find_p_neighbor_from_vec(self, p, y):
+     - ``p`` -- a prime number
+     - ``y`` -- a vector with `q(y) \in p \ZZ`
+     - ``odd`` -- (default: ``False``) if `p=2`, return also odd neighbors
++    - ``return_matrix`` -- (boolean, default ``False``) return
++      the transformation matrix instead of the quadratic form
+ 
+     EXAMPLES::
+ 
++        sage: # needs sage.libs.pari
+         sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1,1])
+         sage: v = vector([0,2,1,1])
+-        sage: X = Q.find_p_neighbor_from_vec(3, v); X                                   # needs sage.libs.pari
++        sage: X = Q.find_p_neighbor_from_vec(3, v); X
+         Quadratic form in 4 variables over Integer Ring with coefficients:
+         [ 1 0 0 0 ]
+         [ * 1 4 4 ]
+         [ * * 5 12 ]
+         [ * * * 9 ]
++        sage: B = Q.find_p_neighbor_from_vec(3, v, return_matrix=True)
++        sage: Q(B) == X
++        True
+ 
+     Since the base ring and the domain are not yet separate,
+     for rational, half integral forms we just pretend
+     the base ring is `\ZZ`::
+ 
++        sage: # needs sage.libs.pari
+         sage: Q = QuadraticForm(QQ, matrix.diagonal([1,1,1,1]))
+         sage: v = vector([1,1,1,1])
+-        sage: Q.find_p_neighbor_from_vec(2, v)                                          # needs sage.libs.pari
++        sage: Q.find_p_neighbor_from_vec(2, v)
+         Quadratic form in 4 variables over Rational Field with coefficients:
+         [ 1/2 1 1 1 ]
+         [ * 1 1 2 ]
+@@ -227,9 +241,12 @@ def find_p_neighbor_from_vec(self, p, y):
+     # by definition this is the p-neighbor of L at y
+     # assert B.det().abs() == 1
+ 
+-    QF = self.parent()
+-    Gnew = (B*G*B.T).change_ring(R)
+-    return QF(Gnew)
++    if return_matrix:
++        return B.T
++    else:
++        QF = self.parent()
++        Gnew = (B*G*B.T).change_ring(R)
++        return QF(Gnew)
+ 
+ 
+ def neighbor_iteration(seeds, p, mass=None, max_classes=ZZ(10)**3,
+diff --git a/src/sage/quadratic_forms/ternary.pyx b/src/sage/quadratic_forms/ternary.pyx
+index 28dd9514c30..6e7c4389083 100644
+--- a/src/sage/quadratic_forms/ternary.pyx
++++ b/src/sage/quadratic_forms/ternary.pyx
+@@ -955,7 +955,26 @@ def extend(v):
+         [ 30   0  -7]
+         sage: M.det()
+         2
++
++    TESTS::
++
++        sage: M = matrix(3, extend( (0, 0, 1) ))
++        sage: M.det()
++        1
++        sage: M.column(0)
++        (0, 0, 1)
++        sage: M = matrix(3, extend( (0, 0, -2) ))
++        sage: M.det()
++        2
++        sage: M.column(0)
++        (0, 0, -2)
+     """
++    if v[0] == v[1] == 0:
++        if v[2] < 0:
++            return v[0], 0, 1,  v[1], 1, 0,  v[2], 0, 0
++        else:
++            return v[0], 1, 0,  v[1], 0, 1,  v[2], 0, 0
++
+     b1 = xgcd(v[0], v[1])
+     b2 = xgcd(b1[1], b1[2])
+     b3 = xgcd(b1[0], v[2])
+diff --git a/src/sage/quadratic_forms/ternary_qf.py b/src/sage/quadratic_forms/ternary_qf.py
+index fa4499566a9..2f3a57fa713 100644
+--- a/src/sage/quadratic_forms/ternary_qf.py
++++ b/src/sage/quadratic_forms/ternary_qf.py
+@@ -918,6 +918,13 @@ def find_p_neighbor_from_vec(self, p, v, mat=False):
+             [     0  -3/11  13/11]
+             sage: Q(M) == Q11
+             True
++
++        Test that it works with (0, 0, 1)::
++
++            sage: Q.find_p_neighbor_from_vec(3, (0,0,1))
++            Ternary quadratic form with integer coefficients:
++            [1 3 3]
++            [-2 0 -1]
+         """
+         if mat:
+             q, M = _find_p_neighbor_from_vec(self._a, self._b, self._c, self._r, self._s, self._t, p, v, mat)
diff --git a/srcpkgs/sagemath/patches/36696-fix_SSL_timeout.patch b/srcpkgs/sagemath/patches/36696-fix_SSL_timeout.patch
new file mode 100644
index 0000000000000..8693b0df5288b
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36696-fix_SSL_timeout.patch
@@ -0,0 +1,33 @@
+diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py
+index 8583d7a447d..633afd5c2e6 100644
+--- a/src/sage/doctest/control.py
++++ b/src/sage/doctest/control.py
+@@ -457,11 +457,15 @@ def __init__(self, options, args):
+                 options.hide.discard('all')
+                 from sage.features.all import all_features
+                 feature_names = {f.name for f in all_features() if not f.is_standard()}
++                from sage.doctest.external import external_software
++                feature_names.difference_update(external_software)
+                 options.hide = options.hide.union(feature_names)
+             if 'optional' in options.hide:
+                 options.hide.discard('optional')
+                 from sage.features.all import all_features
+                 feature_names = {f.name for f in all_features() if f.is_optional()}
++                from sage.doctest.external import external_software
++                feature_names.difference_update(external_software)
+                 options.hide = options.hide.union(feature_names)
+ 
+         options.disabled_optional = set()
+diff --git a/src/sage/features/internet.py b/src/sage/features/internet.py
+index f1eb000fe92..576b0136926 100644
+--- a/src/sage/features/internet.py
++++ b/src/sage/features/internet.py
+@@ -56,7 +56,7 @@ def _is_present(self):
+         try:
+             urlopen(req, timeout=1, context=default_context())
+             return FeatureTestResult(self, True)
+-        except urllib.error.URLError:
++        except (urllib.error.URLError, TimeoutError):
+             return FeatureTestResult(self, False)
+ 
+ 
diff --git a/srcpkgs/sagemath/patches/get_patches b/srcpkgs/sagemath/patches/get_patches
index 95a6963432948..c5ee28f6eb10c 100755
--- a/srcpkgs/sagemath/patches/get_patches
+++ b/srcpkgs/sagemath/patches/get_patches
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-version=10.1
+version=10.2.beta9
 
 URL_BASE_PR="https://github.com/sagemath/sage/pull/"
 URL_BASE_COMPARE="https://github.com/sagemath/sage/compare/${version}..."
@@ -20,24 +20,15 @@ get_pr() {
 # run from patches dir
 cd $(dirname "$0")
 
-# merged in 10.2.beta0
-#get_pr  36018   "singular 4.3.2p4" # included in #35934
-get_pr  36046   "fix memory leak"
-
-# merged in 10.2.beta1
-get_pr  35934   "singular 4.3.2p7"
-
-# merged in 10.2.beta2
-get_pr  36006   "gmp 6.3.0"
-
-# merged in 10.2.beta3
-get_pr  36235   "ecl 23.9.9"
-
-# merged in 10.2.beta4
-get_pr  36279   "matplotlib 3.8.0"
+# merged in 10.2.rc0
+#get_pr  36544   "networkx 3.2"
+#get_pr  36543   "cython warning"
+#get_pr  36573   "relative imports"
+#get_pr  36600   "giac 1.9.0-67"
 
 # positive review
-#get_pr  36403   "python 3.12" # included in #36407
 
 # needs review
-get_pr  36407   "python 3.12"
+get_pr  35848   "flintlib 3.0"
+get_pr  36551   "fix qf.nbs"
+get_pr  36696   "fix SSL timeout"
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index a80d8b7187ece..49813f25e23e3 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,14 +1,14 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=10.1
-revision=4
+version=10.2.rc2
+revision=1
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
 _bindir=/usr/lib/sagemath/$version/bin
 make_install_args="--install-scripts=$_bindir"
-hostmakedepends="m4 pkg-config python3-Cython0.29 python3-Jinja2
+hostmakedepends="m4 pkg-config python3-Cython python3-Jinja2
  python3-pkgconfig python3-setuptools"
-makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
+makedepends="boost-devel brial-devel cliquer-devel ecl eclib-devel
  ecm-devel fflas-ffpack flintlib-devel gap-devel gd-devel giac-devel glpk-devel
  gsl-devel iml-devel lcalc-devel libbraiding-devel libhomfly-devel libmpc-devel
  libpng-devel linbox-devel m4ri-devel m4rie-devel mpfi-devel
@@ -18,7 +18,7 @@ makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
 depends="eclib-devel fflas-ffpack flintlib-devel gcc-fortran gd-devel
  gfan giac gsl-devel gzip libpng-devel linbox-devel m4ri-devel maxima-ecl
  mpfr-devel nauty ntl-devel palp pari-devel pari-elldata-small pari-galdata
- pari-galpol-small pari-seadata-small pkg-config python3-Cython0.29 python3-cypari2
+ pari-galpol-small pari-seadata-small pkg-config python3-Cython python3-cypari2
  python3-cysignals python3-devel python3-fpylll python3-ipython python3-lrcalc
  python3-ipython_ipykernel python3-jupyter_ipywidgets python3-matplotlib
  python3-memory_allocator python3-networkx python3-pip python3-pkgconfig
@@ -33,7 +33,7 @@ license="GPL-2.0-or-later"
 homepage="https://www.sagemath.org/"
 changelog="https://github.com/sagemath/sage/releases"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=a658612b1b2376ddaf207cc8ed0ef458d4c2880c16e19139bedbe8baa42ad62f
+checksum=dd17ed80553da21a9c0bba4be5f11ef476e9ef12effa61a37d077803e44fa891
 nocross="due to ntl (flintlib), fflas-ffpack, givaro, linbox, cysignals, sympow, maxima"
 
 post_patch() {
diff --git a/srcpkgs/sagemath/update b/srcpkgs/sagemath/update
index 68be3c5752d06..4e62503e2f8f4 100644
--- a/srcpkgs/sagemath/update
+++ b/srcpkgs/sagemath/update
@@ -1,2 +1,3 @@
 pkgname="sage"
-site="https://mirrors.mit.edu/sage/src/index.html"
+site="https://mirrors.mit.edu/sage/src/
+https://mirrors.mit.edu/sage/devel/"

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

* Re: [PR PATCH] [Updated] [RC] sagemath: update to 10.2, flintlib: update to 3.0.1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (9 preceding siblings ...)
  2023-11-14 21:56 ` tornaria
@ 2023-11-15  0:51 ` tornaria
  2023-11-15  8:05 ` dkwo
                   ` (17 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: tornaria @ 2023-11-15  0:51 UTC (permalink / raw)
  To: ml

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

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

https://github.com/tornaria/void-packages flintlib
https://github.com/void-linux/void-packages/pull/46832

[RC] sagemath: update to 10.2, flintlib: update to 3.0.1
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **briefly**

This is a major update. A couple of packages need rebuilding (eclib, singular).

For sagemath, we need a patch (in progress: https://github.com/sagemath/sage/pull/35848).

Since backporting patches is a pain and we are not in a hurry, I'm instead targeting 10.2.beta8. Note this already moves sagemath to cython 3.

The goal is to merge flintlib 3.0 together with sagemath 10.2 when the latter is released.

<!--
#### 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/46832.patch is attached

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

From 6d2f924d67bcdf7b516b3e9a4153ac9273ee7bcc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 11 Sep 2023 20:11:20 -0300
Subject: [PATCH 1/6] flintlib: update to 3.0.1.

---
 common/shlibs                                 |  3 +--
 srcpkgs/arb                                   |  1 +
 srcpkgs/arb-devel                             |  2 +-
 srcpkgs/arb/template                          | 24 -----------------
 .../patches/fix-test-t-sdiv_qrnnd.patch       | 23 ----------------
 srcpkgs/flintlib/template                     | 27 ++++++++++++++++---
 6 files changed, 26 insertions(+), 54 deletions(-)
 create mode 120000 srcpkgs/arb
 delete mode 100644 srcpkgs/arb/template
 delete mode 100644 srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch

diff --git a/common/shlibs b/common/shlibs
index 1a721780f8545..e43c51e9ea188 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3971,8 +3971,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.17 flintlib-2.9.0_1
-libarb.so.2 arb-2.20.0_1
+libflint.so.18 flintlib-3.0.0_1
 libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
diff --git a/srcpkgs/arb b/srcpkgs/arb
new file mode 120000
index 0000000000000..7c2633183069f
--- /dev/null
+++ b/srcpkgs/arb
@@ -0,0 +1 @@
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb-devel b/srcpkgs/arb-devel
index 456b9f00a86cd..7c2633183069f 120000
--- a/srcpkgs/arb-devel
+++ b/srcpkgs/arb-devel
@@ -1 +1 @@
-arb
\ No newline at end of file
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
deleted file mode 100644
index 84a62c7ffdba3..0000000000000
--- a/srcpkgs/arb/template
+++ /dev/null
@@ -1,24 +0,0 @@
-# Template file for 'arb'
-pkgname=arb
-version=2.23.0
-revision=1
-build_style=configure
-configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
-makedepends="flintlib-devel"
-short_desc="C library for arbitrary-precision interval arithmetic"
-maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
-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=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
-
-arb-devel_package() {
-	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"
-	short_desc+=" - development files"
-	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.a"
-		vmove "usr/lib/*.so"
-	}
-}
diff --git a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch b/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
deleted file mode 100644
index cfa109792892c..0000000000000
--- a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From fb8ddbcc06afa2a8f25637032fbb8211f6c6c122 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= <albin.ahlback@gmail.com>
-Date: Fri, 20 May 2022 14:16:38 +0200
-Subject: [PATCH] Fix bug in test code for GCC 12
-
----
- test/t-sdiv_qrnnd.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/test/t-sdiv_qrnnd.c b/test/t-sdiv_qrnnd.c
-index 2e9822e848..2676903826 100644
---- a/test/t-sdiv_qrnnd.c
-+++ b/test/t-sdiv_qrnnd.c
-@@ -33,7 +33,7 @@ int main(void)
-         {
-             d = n_randtest_not_zero(state);
-             nh = n_randtest(state);
--        } while ((FLINT_ABS(nh) >= FLINT_ABS(d)/2) || (nh == WORD_MIN));
-+        } while ((nh == WORD_MIN) || (FLINT_ABS(nh) >= FLINT_ABS(d)/2));
- 
-         nl = n_randtest(state);
- 
-
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index f7442c8052aaa..cbb73ee5f1438 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,10 +1,11 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.9.0
+version=3.0.1
 revision=1
-build_style=configure
+build_style=gnu-configure
 configure_args="--prefix=/usr $(vopt_with ntl)
- $(vopt_if openblas --with-blas=${XBPS_CROSS_BASE}/usr/include/openblas)"
+ $(vopt_if openblas --with-blas-include=${XBPS_CROSS_BASE}/usr/include/openblas)"
+hostmakedepends="automake gettext-devel libtool"
 makedepends="mpfr-devel $(vopt_if ntl ntl-devel)
  $(vopt_if openblas openblas-devel)"
 short_desc="Fast Library for Number Theory"
@@ -13,7 +14,7 @@ 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=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
+checksum=7b311a00503a863881eb8177dbeb84322f29399f3d7d72f3b1a4c9ba1d5794b4
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
@@ -28,12 +29,30 @@ esac
 
 CFLAGS="-D_GNU_SOURCE" # needed for cpu_set_t
 
+post_patch() {
+	# run autoconf because we patched configure.ac
+	autoreconf
+}
+
 flintlib-devel_package() {
 	depends="${sourcepkg}>=${version}_${revision} mpfr-devel"
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
+		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
 		vmove "usr/lib/*.so"
 	}
 }
+
+arb_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}
+
+arb-devel_package() {
+	depends="${sourcepkg}-devel>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From 10c61ecaf2bafa4a93ab1e4fcb44512da5d19143 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:08:05 -0300
Subject: [PATCH 2/6] eclib: rebuild for flintlib-3.0.1

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

diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 1d4ad58f21b7b..12165ca788dd5 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
 version=20230424
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 makedepends="pari-devel ntl-devel flintlib-devel boost-devel"

From 56104369bb2129062fa2fe3dee977bfb15790c09 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:13:15 -0300
Subject: [PATCH 3/6] singular: update to 4.3.2p10.

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

diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index 036e19d470354..beb0e6d30118e 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,6 +1,6 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.2p7
+version=4.3.2p10
 revision=1
 _majver=${version%p*}
 build_style=gnu-configure
@@ -20,7 +20,7 @@ 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/${_majver//./-}/singular-${version}.tar.gz"
-checksum=aad23c30066b7fbc011138a98d60532565d76a847eec6bf2938410d93b272ca3
+checksum=28c2c9fcfee954e00dfa56eb1a7d418d5b1de67c4398d25a0f2b8f73e71552a8
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From 70b6360d40c0c080f1a4f55a0995ca08b393a324 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 19 Jul 2023 21:04:33 -0300
Subject: [PATCH 4/6] python3-pplpy: use cython 3.

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

diff --git a/srcpkgs/python3-pplpy/template b/srcpkgs/python3-pplpy/template
index 4a9c987b2a859..d3b9aebdf2237 100644
--- a/srcpkgs/python3-pplpy/template
+++ b/srcpkgs/python3-pplpy/template
@@ -1,9 +1,9 @@
 # Template file for 'python3-pplpy'
 pkgname=python3-pplpy
 version=0.8.9
-revision=1
+revision=2
 build_style=python3-pep517
-hostmakedepends="python3-setuptools python3-wheel python3-Cython0.29
+hostmakedepends="python3-setuptools python3-wheel python3-Cython
  python3-cysignals python3-gmpy2"
 makedepends="python3-devel gmp-devel gmpxx-devel ppl-devel mpfr-devel
  libmpc-devel pari-devel"

From 52695b631983e1f870c27fef71ee7dc41b9575dd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Thu, 19 Oct 2023 08:52:15 -0300
Subject: [PATCH 5/6] python3-networkx: update to 3.2.1.

---
 srcpkgs/python3-networkx/template | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/python3-networkx/template b/srcpkgs/python3-networkx/template
index 186bf64f7bff9..29283d9e5a032 100644
--- a/srcpkgs/python3-networkx/template
+++ b/srcpkgs/python3-networkx/template
@@ -1,11 +1,11 @@
 # Template file for 'python3-networkx'
 pkgname=python3-networkx
-version=3.1
-revision=2
-build_style=python3-module
+version=3.2.1
+revision=1
+build_style=python3-pep517
 # failing in i686
 make_check_args="--deselect networkx/algorithms/approximation/tests/test_traveling_salesman.py::test_asadpour_tsp"
-hostmakedepends="python3-setuptools"
+hostmakedepends="python3-setuptools python3-wheel"
 depends="python3"
 checkdepends="python3-numpy python3-scipy python3-matplotlib python3-pandas
  python3-lxml python3-sympy python3-pytest-xdist"
@@ -15,7 +15,7 @@ license="BSD-3-Clause"
 homepage="https://networkx.org"
 changelog="https://github.com/networkx/networkx/raw/main/doc/release/release_${version}.rst"
 distfiles="${PYPI_SITE}/n/networkx/networkx-${version}.tar.gz"
-checksum=de346335408f84de0eada6ff9fafafff9bcda11f0a0dfaa931133debb146ab61
+checksum=9f1bb5cf3409bf324e0a722c20bdb4c20ee39bf1c30ce8ae499c8502b0b5e0c6
 
 post_install() {
 	vlicense LICENSE.txt

From d8aae58f7c48be31ccc4354eacbf93acf40d20ec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:50:44 -0300
Subject: [PATCH 6/6] sagemath: update to 10.2.rc3.

---
 .../sagemath/patches/35848-flintlib_3.0.patch | 1738 ++++++++++++++++
 .../patches/35934-singular_4.3.2p7.patch      |  221 ---
 .../sagemath/patches/36006-gmp_6.3.0.patch    |   38 -
 .../patches/36046-fix_memory_leak.patch       |  740 -------
 .../sagemath/patches/36235-ecl_23.9.9.patch   |   39 -
 .../patches/36279-matplotlib_3.8.0.patch      |   24 -
 srcpkgs/sagemath/patches/36403-00pre.patch    |   29 -
 .../sagemath/patches/36407-python_3.12.patch  | 1744 -----------------
 .../sagemath/patches/36551-fix_qf.nbs.patch   |  134 ++
 .../patches/36696-fix_SSL_timeout.patch       |   33 +
 srcpkgs/sagemath/patches/get_patches          |   27 +-
 srcpkgs/sagemath/template                     |   12 +-
 srcpkgs/sagemath/update                       |    3 +-
 13 files changed, 1922 insertions(+), 2860 deletions(-)
 create mode 100644 srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
 delete mode 100644 srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
 delete mode 100644 srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
 delete mode 100644 srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36403-00pre.patch
 delete mode 100644 srcpkgs/sagemath/patches/36407-python_3.12.patch
 create mode 100644 srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
 create mode 100644 srcpkgs/sagemath/patches/36696-fix_SSL_timeout.patch

diff --git a/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
new file mode 100644
index 0000000000000..c1e33e6a3c717
--- /dev/null
+++ b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
@@ -0,0 +1,1738 @@
+diff --git a/build/pkgs/antic/SPKG.rst b/build/pkgs/antic/SPKG.rst
+deleted file mode 100644
+index d6c32377957..00000000000
+--- a/build/pkgs/antic/SPKG.rst
++++ /dev/null
+@@ -1,18 +0,0 @@
+-antic: Algebraic Number Theory In C
+-===================================
+-
+-Description
+------------
+-
+-Algebraic Number Theory In C
+-
+-License
+--------
+-
+-LGPL 2.1
+-
+-Upstream Contact
+-----------------
+-
+-https://github.com/wbhart/antic
+-
+diff --git a/build/pkgs/antic/checksums.ini b/build/pkgs/antic/checksums.ini
+deleted file mode 100644
+index fc8711ecd13..00000000000
+--- a/build/pkgs/antic/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=antic-VERSION.tar.gz
+-sha1=940d8ea2c3512b9d49ee3101cf043f777764bd8f
+-md5=4e896420dd6344b53b307871efb2cbb4
+-cksum=1938565125
+-upstream_url=https://github.com/wbhart/antic/archive/refs/tags/vVERSION.tar.gz
+diff --git a/build/pkgs/antic/dependencies b/build/pkgs/antic/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/antic/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/antic/distros/arch.txt b/build/pkgs/antic/distros/arch.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/conda.txt b/build/pkgs/antic/distros/conda.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/debian.txt b/build/pkgs/antic/distros/debian.txt
+deleted file mode 100644
+index 8fdcd3e5721..00000000000
+--- a/build/pkgs/antic/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libantic-dev
+diff --git a/build/pkgs/antic/distros/fedora.txt b/build/pkgs/antic/distros/fedora.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/freebsd.txt b/build/pkgs/antic/distros/freebsd.txt
+deleted file mode 100644
+index 116ff3a26f3..00000000000
+--- a/build/pkgs/antic/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/antic
+diff --git a/build/pkgs/antic/distros/opensuse.txt b/build/pkgs/antic/distros/opensuse.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/repology.txt b/build/pkgs/antic/distros/repology.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/package-version.txt b/build/pkgs/antic/package-version.txt
+deleted file mode 100644
+index 3a4036fb450..00000000000
+--- a/build/pkgs/antic/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-0.2.5
+diff --git a/build/pkgs/antic/spkg-install.in b/build/pkgs/antic/spkg-install.in
+deleted file mode 100644
+index c57fa884a20..00000000000
+--- a/build/pkgs/antic/spkg-install.in
++++ /dev/null
+@@ -1,19 +0,0 @@
+-cd src
+-
+-# Copied from build/pkgs/flint/spkg-install.in:
+-#   Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-#   --with-ntl because otherwise FLINT's configure script uses
+-#   /usr/local, which is always wrong.
+-#   This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-#   The value $SAGE_LOCAL is always a safe choice even if the library
+-#   is coming from the system and is found using what is in
+-#   LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-flint="$SAGE_LOCAL"  || sdh_die "Error: Failed to configure antic."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/antic/type b/build/pkgs/antic/type
+deleted file mode 100644
+index 134d9bc32d5..00000000000
+--- a/build/pkgs/antic/type
++++ /dev/null
+@@ -1 +0,0 @@
+-optional
+diff --git a/build/pkgs/arb/SPKG.rst b/build/pkgs/arb/SPKG.rst
+deleted file mode 100644
+index cff49ddb95b..00000000000
+--- a/build/pkgs/arb/SPKG.rst
++++ /dev/null
+@@ -1,27 +0,0 @@
+-arb: Arbitrary-precision floating-point ball arithmetic
+-=======================================================
+-
+-Description
+------------
+-
+-Arb is a C library for arbitrary-precision floating-point ball
+-arithmetic, developed by Fredrik Johansson
+-(fredrik.johansson@gmail.com). It supports efficient high-precision
+-computation with polynomials, power series, matrices and special
+-functions over the real and complex numbers, with automatic, rigorous
+-error control.
+-
+-License
+--------
+-
+-GNU General Public License v2+
+-
+-
+-Upstream Contact
+-----------------
+-
+- - Fredrik Johansson: fredrik.johansson@gmail.com
+-
+- - https://arblib.org/
+-
+- - http://github.com/fredrik-johansson/arb/
+diff --git a/build/pkgs/arb/checksums.ini b/build/pkgs/arb/checksums.ini
+deleted file mode 100644
+index 80ef43dad5d..00000000000
+--- a/build/pkgs/arb/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=arb-VERSION.tar.gz
+-sha1=a1efe035dd3af3613dd685971a156f652b86ff63
+-md5=9b369e29f93cdf2d4f90b57a92526cce
+-cksum=64252121
+-upstream_url=https://github.com/fredrik-johansson/arb/archive/VERSION.tar.gz
+diff --git a/build/pkgs/arb/dependencies b/build/pkgs/arb/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/arb/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/arb/distros/arch.txt b/build/pkgs/arb/distros/arch.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/conda.txt b/build/pkgs/arb/distros/conda.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/debian.txt b/build/pkgs/arb/distros/debian.txt
+deleted file mode 100644
+index 9fe71110712..00000000000
+--- a/build/pkgs/arb/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libflint-arb-dev
+diff --git a/build/pkgs/arb/distros/fedora.txt b/build/pkgs/arb/distros/fedora.txt
+deleted file mode 100644
+index 76794404627..00000000000
+--- a/build/pkgs/arb/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb arb-devel
+diff --git a/build/pkgs/arb/distros/freebsd.txt b/build/pkgs/arb/distros/freebsd.txt
+deleted file mode 100644
+index 2ef8c7cec0f..00000000000
+--- a/build/pkgs/arb/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/arb
+diff --git a/build/pkgs/arb/distros/gentoo.txt b/build/pkgs/arb/distros/gentoo.txt
+deleted file mode 100644
+index 58e3d4f8008..00000000000
+--- a/build/pkgs/arb/distros/gentoo.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-sci-mathematics/arb
+diff --git a/build/pkgs/arb/distros/homebrew.txt b/build/pkgs/arb/distros/homebrew.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/homebrew.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/nix.txt b/build/pkgs/arb/distros/nix.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/nix.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/opensuse.txt b/build/pkgs/arb/distros/opensuse.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/distros/repology.txt b/build/pkgs/arb/distros/repology.txt
+deleted file mode 100644
+index 179c9d507e1..00000000000
+--- a/build/pkgs/arb/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-fp
+diff --git a/build/pkgs/arb/distros/void.txt b/build/pkgs/arb/distros/void.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/void.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/package-version.txt b/build/pkgs/arb/package-version.txt
+deleted file mode 100644
+index e9763f6bfed..00000000000
+--- a/build/pkgs/arb/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-2.23.0
+diff --git a/build/pkgs/arb/spkg-check.in b/build/pkgs/arb/spkg-check.in
+deleted file mode 100644
+index 27cd9419538..00000000000
+--- a/build/pkgs/arb/spkg-check.in
++++ /dev/null
+@@ -1,2 +0,0 @@
+-cd src
+-$MAKE check
+diff --git a/build/pkgs/arb/spkg-configure.m4 b/build/pkgs/arb/spkg-configure.m4
+deleted file mode 100644
+index ef2dd0aac4a..00000000000
+--- a/build/pkgs/arb/spkg-configure.m4
++++ /dev/null
+@@ -1,23 +0,0 @@
+-SAGE_SPKG_CONFIGURE([arb], [
+-    AC_REQUIRE([SAGE_SPKG_CONFIGURE_FLINT])
+-    SAGE_ARB_LIBRARY="arb"
+-    AC_MSG_CHECKING([installing flint? ])
+-    if test x$sage_spkg_install_flint = xyes; then
+-        AC_MSG_RESULT([yes; install arb as well])
+-        sage_spkg_install_arb=yes
+-    else
+-        AC_CHECK_HEADER(arb.h, [
+-        dnl below function added in version 2.16 of arb
+-            AC_CHECK_LIB([arb], [acb_mat_eig_simple], [],
+-              [dnl in Debian the name of dylib is different.
+-               AC_CHECK_LIB([flint-arb], [acb_mat_eig_simple],
+-                [SAGE_ARB_LIBRARY="flint-arb"], [sage_spkg_install_arb=yes])])
+-        ], [sage_spkg_install_arb=yes])
+-    fi
+-], [], [], [
+-    if test x$sage_spkg_install_arb = xyes; then
+-        AC_SUBST(SAGE_ARB_LIBRARY,["arb"])
+-    else
+-        AC_SUBST(SAGE_ARB_LIBRARY,[$SAGE_ARB_LIBRARY])
+-    fi
+-])
+diff --git a/build/pkgs/arb/spkg-install.in b/build/pkgs/arb/spkg-install.in
+deleted file mode 100644
+index 9322f04c912..00000000000
+--- a/build/pkgs/arb/spkg-install.in
++++ /dev/null
+@@ -1,17 +0,0 @@
+-cd src
+-
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-flint because otherwise ARB's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure --disable-static --prefix="$SAGE_LOCAL" \
+-        --with-gmp="$SAGE_LOCAL" \
+-        --with-mpfr="$SAGE_LOCAL" \
+-        --with-flint="$SAGE_LOCAL" || \
+-    sdh_die "Error configuring arb."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/arb/type b/build/pkgs/arb/type
+deleted file mode 100644
+index a6a7b9cd726..00000000000
+--- a/build/pkgs/arb/type
++++ /dev/null
+@@ -1 +0,0 @@
+-standard
+diff --git a/build/pkgs/e_antic/dependencies b/build/pkgs/e_antic/dependencies
+index fea1ffbda45..8e977a55c13 100644
+--- a/build/pkgs/e_antic/dependencies
++++ b/build/pkgs/e_antic/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) flint arb antic boost_cropped
++$(MP_LIBRARY) flint boost_cropped
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/SPKG.rst b/build/pkgs/flint/SPKG.rst
+index f91de70d1ff..d9dcea0903b 100644
+--- a/build/pkgs/flint/SPKG.rst
++++ b/build/pkgs/flint/SPKG.rst
+@@ -4,8 +4,8 @@ flint: Fast Library for Number Theory
+ Description
+ -----------
+ 
+-FLINT is a C library for doing number theory, maintained by William
+-Hart.
++FLINT is a C library for doing number theory, maintained by
++Fredrik Johansson.
+ 
+ Website: http://www.flintlib.org
+ 
+@@ -20,4 +20,4 @@ Upstream Contact
+ 
+ -  flint-devel Gougle Group
+    (http://groups.google.co.uk/group/flint-devel)
+--  William Hart
++-  Fredrik Johansson
+diff --git a/build/pkgs/flint/checksums.ini b/build/pkgs/flint/checksums.ini
+index 3d449d98064..2cec823bfb1 100644
+--- a/build/pkgs/flint/checksums.ini
++++ b/build/pkgs/flint/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=flint-VERSION.tar.gz
+-sha1=63d90f8242c8f8ab4011fbcfb44b86c154f43abd
+-md5=c2d3cec326438f159a530c66eb07fafe
+-cksum=4244948341
+-upstream_url=http://flintlib.org/flint-VERSION.tar.gz
++sha1=c548b1d5eb86a1805de9bef56629455b61e873f7
++md5=24551d4e475290ce6b831c78fafb5efb
++cksum=1567352998
++upstream_url=https://github.com/flintlib/flint/releases/download/vVERSION/flint-VERSION.tar.gz
+diff --git a/build/pkgs/flint/dependencies b/build/pkgs/flint/dependencies
+index 385df4faa7d..1108dc4fb21 100644
+--- a/build/pkgs/flint/dependencies
++++ b/build/pkgs/flint/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) mpfr ntl
++$(MP_LIBRARY) mpfr
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/package-version.txt b/build/pkgs/flint/package-version.txt
+index c8e38b61405..4a36342fcab 100644
+--- a/build/pkgs/flint/package-version.txt
++++ b/build/pkgs/flint/package-version.txt
+@@ -1 +1 @@
+-2.9.0
++3.0.0
+diff --git a/build/pkgs/flint/spkg-build.in b/build/pkgs/flint/spkg-build.in
+new file mode 100644
+index 00000000000..ffb822c8a97
+--- /dev/null
++++ b/build/pkgs/flint/spkg-build.in
+@@ -0,0 +1,3 @@
++cd src
++sdh_configure
++sdh_make
+diff --git a/build/pkgs/flint/spkg-configure.m4 b/build/pkgs/flint/spkg-configure.m4
+index a58108c9d6e..9576e4cc1e9 100644
+--- a/build/pkgs/flint/spkg-configure.m4
++++ b/build/pkgs/flint/spkg-configure.m4
+@@ -1,25 +1,8 @@
+ SAGE_SPKG_CONFIGURE([flint], [
+-    SAGE_SPKG_DEPCHECK([mpfr ntl], [
++    SAGE_SPKG_DEPCHECK([mpfr], [
+         AC_CHECK_HEADER(flint/flint.h, [
+-          dnl flint_parallel_binary_splitting appears in Flint 2.9.0, needed by arb 2.23
+-          AC_SEARCH_LIBS([flint_parallel_binary_splitting], [flint], [
+-            dnl check that NTL is linked in
+-            AC_SEARCH_LIBS([fmpz_poly_get_ZZX], [flint], [
+-
+-              AC_MSG_CHECKING([that GC is not enabled in Flint... ])
+-              AC_RUN_IFELSE([
+-                 AC_LANG_PROGRAM([[#include <flint/flint.h>]], [
+-                                  [#ifdef HAVE_GC]
+-                                     [return HAVE_GC;]
+-                                  [#else]
+-                                     [return 0;]
+-                                  [#endif]])],
+-                 [AC_MSG_RESULT([GC not enabled. Good.])],
+-                        [AC_MSG_RESULT([GC enabled. Incompatible with Sage.])
+-                         sage_spkg_install_flint=yes],
+-                 [AC_MSG_RESULT(["cross compiling. assuming GC is not enabled"])])
+-            ], [sage_spkg_install_flint=yes])
+-          ], [sage_spkg_install_flint=yes])
++          dnl gr_get_fexpr appears in Flint 3.0
++          AC_SEARCH_LIBS([gr_get_fexpr], [flint], [], [sage_spkg_install_flint=yes])
+         ], [sage_spkg_install_flint=yes])
+     ])
+ ], [], [], [
+diff --git a/build/pkgs/flint/spkg-install.in b/build/pkgs/flint/spkg-install.in
+index eacd7b6e491..3ea8c053669 100644
+--- a/build/pkgs/flint/spkg-install.in
++++ b/build/pkgs/flint/spkg-install.in
+@@ -1,36 +1,2 @@
+-###############################################################################
+-#
+-# FLINT Sage install script
+-#
+-###############################################################################
+-if [ "$SAGE_DEBUG" = "yes" ]; then
+-    echo "Building a debug version of FLINT."
+-    FLINT_TUNE=" $FLINT_TUNE"; export FLINT_TUNE
+-    FLINT_CONFIGURE="--enable-assert $FLINT_CONFIGURE"
+-fi
+-
+ cd src
+-
+-echo "Configuring FLINT."
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-ntl because otherwise FLINT's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-ntl="$SAGE_LOCAL" \
+-    $FLINT_CONFIGURE || sdh_die "Error: Failed to configure FLINT."
+-
+-sdh_make verbose
+-
+-echo "Deleting old FLINT files."
+-rm -f $SAGE_LOCAL/lib/libflint*
+-rm -rf $SAGE_LOCAL/include/flint
+-
+ sdh_make_install
+diff --git a/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+new file mode 100644
+index 00000000000..27a642a13b0
+--- /dev/null
++++ b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+@@ -0,0 +1,53 @@
++From fe730579476de0b2d4181a38efa7f63dff9c81d7 Mon Sep 17 00:00:00 2001
++From: Marc Mezzarobba <marc@mezzarobba.net>
++Date: Tue, 12 Sep 2023 08:23:08 +0200
++Subject: [PATCH] Make msolve build with flint3
++
++---
++ src/fglm/berlekamp_massey.c | 3 +++
++ src/fglm/data_fglm.c        | 7 +++++--
++ 2 files changed, 8 insertions(+), 2 deletions(-)
++
++diff --git a/src/fglm/berlekamp_massey.c b/src/fglm/berlekamp_massey.c
++index b0f2052..998af1c 100644
++--- a/src/fglm/berlekamp_massey.c
+++++ b/src/fglm/berlekamp_massey.c
++@@ -30,6 +30,9 @@
++ */
++ 
++ #include <stdlib.h>
+++#if __FLINT_VERSION >= 3
+++#  include <flint/nmod.h>
+++#endif
++ //#include "nmod_poly.h"
++ //#include "mpn_extras.h"
++ 
++diff --git a/src/fglm/data_fglm.c b/src/fglm/data_fglm.c
++index 0726760..0e1da6f 100644
++--- a/src/fglm/data_fglm.c
+++++ b/src/fglm/data_fglm.c
++@@ -24,6 +24,7 @@
++ #include <flint/mpn_extras.h>
++ #include <flint/nmod_poly.h>
++ #include <flint/nmod_poly_factor.h>
+++#include <flint/ulong_extras.h>
++ 
++ 
++ typedef uint32_t szmat_t;
++@@ -299,9 +300,11 @@ static inline void nmod_poly_set_prime(nmod_poly_t poly,
++   mp_limb_t ninv = n_preinvert_limb(prime);
++   poly->mod.n = prime;
++   poly->mod.ninv = ninv;
+++#if __FLINT_VERSION < 3
++   count_leading_zeros(poly->mod.norm, prime);
++-  /* poly->mod.norm = flint_clz(prime); */
++-
+++#else
+++  poly->mod.norm = flint_clz(prime);
+++#endif
++ }
++ 
++ static inline void fglm_param_set_prime(param_t *param, mp_limb_t prime){
++-- 
++2.40.1
++
+diff --git a/build/pkgs/sagelib/dependencies b/build/pkgs/sagelib/dependencies
+index 5dc2efe1d31..fa6e98df7db 100644
+--- a/build/pkgs/sagelib/dependencies
++++ b/build/pkgs/sagelib/dependencies
+@@ -1,4 +1,4 @@
+-FORCE $(SCRIPTS) arb boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
++FORCE $(SCRIPTS) boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/symengine/dependencies b/build/pkgs/symengine/dependencies
+index 1fc34963eda..7795d486018 100644
+--- a/build/pkgs/symengine/dependencies
++++ b/build/pkgs/symengine/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) arb ecm flint mpc mpfr | cmake
++$(MP_LIBRARY) ecm flint mpc mpfr | cmake
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/pkgs/sage-conf/_sage_conf/_conf.py.in b/pkgs/sage-conf/_sage_conf/_conf.py.in
+index 87b27ca05cb..895d6572d1e 100644
+--- a/pkgs/sage-conf/_sage_conf/_conf.py.in
++++ b/pkgs/sage-conf/_sage_conf/_conf.py.in
+@@ -19,8 +19,6 @@ MAXIMA_FAS = "@SAGE_MAXIMA_FAS@".replace('${prefix}', SAGE_LOCAL)
+ # Delete this line if your ECL can load Kenzo without further prodding.
+ KENZO_FAS = "@SAGE_KENZO_FAS@".replace('${prefix}', SAGE_LOCAL)
+ 
+-ARB_LIBRARY = "@SAGE_ARB_LIBRARY@"
+-
+ NTL_INCDIR = "@NTL_INCDIR@"
+ NTL_LIBDIR = "@NTL_LIBDIR@"
+ 
+diff --git a/src/sage/env.py b/src/sage/env.py
+index b1fe9a89cd1..9197fc3a703 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -223,7 +223,6 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st
+ FOURTITWO_PPI = var("FOURTITWO_PPI")
+ FOURTITWO_CIRCUITS = var("FOURTITWO_CIRCUITS")
+ FOURTITWO_GROEBNER = var("FOURTITWO_GROEBNER")
+-ARB_LIBRARY = var("ARB_LIBRARY", "arb")
+ CBLAS_PC_MODULES = var("CBLAS_PC_MODULES", "cblas:openblas:blas")
+ ECL_CONFIG = var("ECL_CONFIG", "ecl-config")
+ NTL_INCDIR = var("NTL_INCDIR")
+@@ -356,8 +355,7 @@ def cython_aliases(required_modules=None,
+         sage: cython_aliases()
+         {...}
+         sage: sorted(cython_aliases().keys())
+-        ['ARB_LIBRARY',
+-         'CBLAS_CFLAGS',
++        ['CBLAS_CFLAGS',
+          ...,
+          'ZLIB_LIBRARIES']
+         sage: cython_aliases(required_modules=('module-that-is-assumed-to-not-exist'))
+@@ -475,8 +473,6 @@ def uname_specific(name, value, alternative):
+     if "LINBOX_CFLAGS" in aliases:
+         aliases["LINBOX_CFLAGS"].append("-std=gnu++11")
+ 
+-    aliases["ARB_LIBRARY"] = ARB_LIBRARY
+-
+     # TODO: Remove Cygwin hack by installing a suitable cblas.pc
+     if os.path.exists('/usr/lib/libblas.dll.a'):
+         aliases["CBLAS_LIBS"] = ['gslcblas']
+diff --git a/src/sage/features/sagemath.py b/src/sage/features/sagemath.py
+index 7404e6d0a8e..6037d097391 100644
+--- a/src/sage/features/sagemath.py
++++ b/src/sage/features/sagemath.py
+@@ -761,7 +761,7 @@ class sage__rings__number_field(JoinFeature):
+     A :class:`~sage.features.Feature` describing the presence of :mod:`sage.rings.number_field`.
+ 
+     Number fields are implemented in Sage using a complicated mixture of various libraries,
+-    including :ref:`arb <spkg_arb>`, :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
++    including :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
+     :ref:`MPFI <spkg_mpfi>`, :ref:`NTL <spkg_ntl>`, and :ref:`PARI <spkg_pari>`.
+ 
+     EXAMPLES:
+diff --git a/src/sage/libs/arb/acb.pxd b/src/sage/libs/arb/acb.pxd
+index 5148dc43991..851488d803a 100644
+--- a/src/sage/libs/arb/acb.pxd
++++ b/src/sage/libs/arb/acb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -152,10 +152,6 @@ cdef extern from "arb_wrap.h":
+     void acb_sech(acb_t s, const acb_t z, long prec)
+     void acb_csch(acb_t c, const acb_t z, long prec)
+ 
+-    void acb_rising_ui_bs(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui_rs(acb_t z, const acb_t x, unsigned long n, unsigned long step, long prec)
+-    void acb_rising_ui_rec(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui(acb_t z, const acb_t x, unsigned long n, long prec)
+     void acb_rising(acb_t z, const acb_t x, const acb_t n, long prec)
+ 
+     void acb_gamma(acb_t y, const acb_t x, long prec)
+diff --git a/src/sage/libs/arb/acb_calc.pxd b/src/sage/libs/arb/acb_calc.pxd
+index a5dbf360b5e..67bd2ed57dc 100644
+--- a/src/sage/libs/arb/acb_calc.pxd
++++ b/src/sage/libs/arb/acb_calc.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_calc.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_elliptic.pxd b/src/sage/libs/arb/acb_elliptic.pxd
+index 176f68df00e..e3480e9f73b 100644
+--- a/src/sage/libs/arb/acb_elliptic.pxd
++++ b/src/sage/libs/arb/acb_elliptic.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_elliptic.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_hypgeom.pxd b/src/sage/libs/arb/acb_hypgeom.pxd
+index 418e766f10d..c43e5c0623b 100644
+--- a/src/sage/libs/arb/acb_hypgeom.pxd
++++ b/src/sage/libs/arb/acb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_hypgeom.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_modular.pxd b/src/sage/libs/arb/acb_modular.pxd
+index c708e9bf97d..cdc413c92da 100644
+--- a/src/sage/libs/arb/acb_modular.pxd
++++ b/src/sage/libs/arb/acb_modular.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_modular.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_poly.pxd b/src/sage/libs/arb/acb_poly.pxd
+index 69f4320055b..ae02757ffd9 100644
+--- a/src/sage/libs/arb/acb_poly.pxd
++++ b/src/sage/libs/arb/acb_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -79,24 +79,10 @@ cdef extern from "arb_wrap.h":
+     void _acb_poly_divrem(acb_ptr Q, acb_ptr R, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec)
+     bint acb_poly_divrem(acb_poly_t Q, acb_poly_t R, const acb_poly_t A, const acb_poly_t B, long prec)
+     void _acb_poly_div_root(acb_ptr Q, acb_t R, acb_srcptr A, long len, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_horner(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_horner(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_divconquer(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_divconquer(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_convolution(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_convolution(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+     void _acb_poly_taylor_shift(acb_ptr g, const acb_t c, long n, long prec)
+     void acb_poly_taylor_shift(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_compose_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_divconquer(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_divconquer(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+     void _acb_poly_compose(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+     void acb_poly_compose(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_series_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+-    void _acb_poly_compose_series_brent_kung(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_brent_kung(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_compose_series(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+     void acb_poly_compose_series(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_revert_series_lagrange(acb_ptr h, acb_srcptr f, long flen, long n, long prec)
+@@ -161,10 +147,6 @@ cdef extern from "arb_wrap.h":
+     void acb_poly_exp_series_basecase(acb_poly_t f, const acb_poly_t h, long n, long prec)
+     void _acb_poly_exp_series(acb_ptr f, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_exp_series(acb_poly_t f, const acb_poly_t h, long n, long prec)
+-    void _acb_poly_sin_cos_series_basecase(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_basecase(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+-    void _acb_poly_sin_cos_series_tangent(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_tangent(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+     void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_sin_cos_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec)
+     void _acb_poly_sin_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec)
+diff --git a/src/sage/libs/arb/arb.pxd b/src/sage/libs/arb/arb.pxd
+index c82b94de30f..acd232ab816 100644
+--- a/src/sage/libs/arb/arb.pxd
++++ b/src/sage/libs/arb/arb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -224,15 +224,8 @@ cdef extern from "arb_wrap.h":
+ 
+     void arb_lambertw(arb_t res, const arb_t x, int flags, long prec)
+ 
+-    void arb_rising_ui_bs(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui_rs(arb_t z, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising_ui_rec(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui(arb_t z, const arb_t x, unsigned long n, long prec)
+     void arb_rising(arb_t z, const arb_t x, const arb_t n, long prec)
+     void arb_rising_fmpq_ui(arb_t z, const fmpq_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_bs(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_rs(arb_t u, arb_t v, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising2_ui(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+     void arb_fac_ui(arb_t z, unsigned long n, long prec)
+     void arb_bin_ui(arb_t z, const arb_t n, unsigned long k, long prec)
+     void arb_bin_uiui(arb_t z, unsigned long n, unsigned long k, long prec)
+diff --git a/src/sage/libs/arb/arb_fmpz_poly.pxd b/src/sage/libs/arb/arb_fmpz_poly.pxd
+index 079f76e9d9e..55daa705238 100644
+--- a/src/sage/libs/arb/arb_fmpz_poly.pxd
++++ b/src/sage/libs/arb/arb_fmpz_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_fmpz_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -22,5 +22,4 @@ cdef extern from "arb_wrap.h":
+     unsigned long arb_fmpz_poly_deflation(const fmpz_poly_t poly)
+     void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long deflation)
+     void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, long prec)
+-    void arb_fmpz_poly_cos_minpoly(fmpz_poly_t res, unsigned long n)
+     void arb_fmpz_poly_gauss_period_minpoly(fmpz_poly_t res, unsigned long q, unsigned long n)
+diff --git a/src/sage/libs/arb/arb_hypgeom.pxd b/src/sage/libs/arb/arb_hypgeom.pxd
+index fb1c40ddaa8..139b987d669 100644
+--- a/src/sage/libs/arb/arb_hypgeom.pxd
++++ b/src/sage/libs/arb/arb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_hypgeom.h
+ 
+ from sage.libs.flint.types cimport fmpz_t
+diff --git a/src/sage/libs/arb/arb_wrap.h b/src/sage/libs/arb/arb_wrap.h
+index 49997075ee5..488bb376d5e 100644
+--- a/src/sage/libs/arb/arb_wrap.h
++++ b/src/sage/libs/arb/arb_wrap.h
+@@ -5,25 +5,27 @@
+  * by arb, most of which rely on flint's ulong and slong defines.
+  */
+ 
++#include <mpfr.h>
++
+ #undef ulong
+ #undef slong
+ 
+ #define ulong mp_limb_t
+ #define slong mp_limb_signed_t
+ 
+-#include <acb.h>
+-#include <acb_calc.h>
+-#include <acb_elliptic.h>
+-#include <acb_hypgeom.h>
+-#include <acb_mat.h>
+-#include <acb_modular.h>
+-#include <acb_poly.h>
+-#include <arb.h>
+-#include <arb_fmpz_poly.h>
+-#include <arb_hypgeom.h>
+-#include <arf.h>
+-#include <bernoulli.h>
+-#include <mag.h>
++#include <flint/acb.h>
++#include <flint/acb_calc.h>
++#include <flint/acb_elliptic.h>
++#include <flint/acb_hypgeom.h>
++#include <flint/acb_mat.h>
++#include <flint/acb_modular.h>
++#include <flint/acb_poly.h>
++#include <flint/arb.h>
++#include <flint/arb_fmpz_poly.h>
++#include <flint/arb_hypgeom.h>
++#include <flint/arf.h>
++#include <flint/bernoulli.h>
++#include <flint/mag.h>
+ 
+ #undef ulong
+ #undef slong
+diff --git a/src/sage/libs/arb/arf.pxd b/src/sage/libs/arb/arf.pxd
+index b8b83fefcdc..84778fe9f09 100644
+--- a/src/sage/libs/arb/arf.pxd
++++ b/src/sage/libs/arb/arf.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arf.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -30,7 +30,6 @@ cdef extern from "arb_wrap.h":
+     void arf_set_ui(arf_t y, unsigned long x)
+     void arf_set_si(arf_t y, long x)
+     void arf_set_mpfr(arf_t y, const mpfr_t x)
+-    # void arf_set_fmpr(arf_t y, const fmpr_t x)
+     void arf_set_d(arf_t y, double x)
+     void arf_swap(arf_t y, arf_t x)
+     void arf_init_set_ui(arf_t y, unsigned long x)
+@@ -46,7 +45,6 @@ cdef extern from "arb_wrap.h":
+     int arf_set_round_fmpz_2exp(arf_t y, const fmpz_t x, const fmpz_t e, long prec, arf_rnd_t rnd)
+     void arf_get_fmpz_2exp(fmpz_t m, fmpz_t e, const arf_t x)
+     double arf_get_d(const arf_t x, arf_rnd_t rnd)
+-    # void arf_get_fmpr(fmpr_t y, const arf_t x)
+     int arf_get_mpfr(mpfr_t y, const arf_t x, mpfr_rnd_t rnd)
+     void arf_get_fmpz(fmpz_t z, const arf_t x, arf_rnd_t rnd)
+     long arf_get_si(const arf_t x, arf_rnd_t rnd)
+diff --git a/src/sage/libs/arb/bernoulli.pxd b/src/sage/libs/arb/bernoulli.pxd
+index 375b2b9bbcf..ea9340f4b15 100644
+--- a/src/sage/libs/arb/bernoulli.pxd
++++ b/src/sage/libs/arb/bernoulli.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = bernoulli.h
+ 
+ from ..flint.types cimport fmpq_t, ulong
+diff --git a/src/sage/libs/arb/mag.pxd b/src/sage/libs/arb/mag.pxd
+index d5d8693ea8f..69dfb990ae0 100644
+--- a/src/sage/libs/arb/mag.pxd
++++ b/src/sage/libs/arb/mag.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = mag.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -27,13 +27,11 @@ cdef extern from "arb_wrap.h":
+     # void mag_randtest(mag_t x, flint_rand_t state, long expbits)
+     # void mag_randtest_special(mag_t x, flint_rand_t state, long expbits)
+     void mag_set_d(mag_t y, double x)
+-    # void mag_set_fmpr(mag_t y, const fmpr_t x)
+     void mag_set_ui(mag_t y, unsigned long x)
+     void mag_set_fmpz(mag_t y, const fmpz_t x)
+     void mag_set_d_2exp_fmpz(mag_t z, double x, const fmpz_t y)
+     void mag_set_fmpz_2exp_fmpz(mag_t z, const fmpz_t x, const fmpz_t y)
+     void mag_set_ui_2exp_si(mag_t z, unsigned long x, long y)
+-    # void mag_get_fmpr(fmpr_t y, const mag_t x)
+     void mag_get_fmpq(fmpq_t y, const mag_t x)
+     void mag_set_ui_lower(mag_t z, unsigned long x)
+     void mag_set_fmpz_lower(mag_t z, const fmpz_t x)
+diff --git a/src/sage/libs/flint/flint_wrap.h b/src/sage/libs/flint/flint_wrap.h
+index 266535c3835..4db72b97660 100644
+--- a/src/sage/libs/flint/flint_wrap.h
++++ b/src/sage/libs/flint/flint_wrap.h
+@@ -15,6 +15,7 @@
+  */
+ 
+ #include <gmp.h>
++#include <mpfr.h>
+ 
+ /* Save previous definition of ulong if any, as pari also uses it */
+ /* Should work on GCC, clang, MSVC */
+@@ -33,6 +34,7 @@
+ 
+ #include <flint/arith.h>
+ #include <flint/fmpq.h>
++#include <flint/fmpq_vec.h>
+ #include <flint/fmpq_mat.h>
+ #include <flint/fmpq_poly.h>
+ #include <flint/fmpz.h>
+@@ -47,6 +49,7 @@
+ #include <flint/fq.h>
+ #include <flint/fq_nmod.h>
+ #include <flint/nmod_poly.h>
++#include <flint/nmod_poly_factor.h>
+ #include <flint/nmod_vec.h>
+ #include <flint/padic.h>
+ #include <flint/padic_poly.h>
+diff --git a/src/sage/libs/flint/fmpq.pxd b/src/sage/libs/flint/fmpq.pxd
+index 5e64c82102f..0616c0a7408 100644
+--- a/src/sage/libs/flint/fmpq.pxd
++++ b/src/sage/libs/flint/fmpq.pxd
+@@ -12,6 +12,8 @@ cdef extern from "flint_wrap.h":
+     fmpz * fmpq_denref(fmpq_t)
+     void fmpq_init(fmpq_t)
+     void fmpq_clear(fmpq_t)
++    void fmpq_init_set_readonly(fmpq_t, const mpq_t)
++    void fmpq_clear_readonly(fmpq_t)
+     void fmpq_one(fmpq_t)
+     void fmpq_zero(fmpq_t)
+     bint fmpq_is_zero(fmpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pxd b/src/sage/libs/flint/fmpq_poly.pxd
+index 6050c487835..afa16e5bbdd 100644
+--- a/src/sage/libs/flint/fmpq_poly.pxd
++++ b/src/sage/libs/flint/fmpq_poly.pxd
+@@ -30,6 +30,9 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_canonicalise(fmpq_poly_t)
+     int fmpq_poly_is_canonical(const fmpq_poly_t)
+ 
++    void _fmpq_poly_set_length(fmpq_poly_t, slong)
++    void _fmpq_poly_normalise(fmpq_poly_t)
++
+     # Polynomial parameters
+     slong fmpq_poly_degree(const fmpq_poly_t)
+     ulong fmpq_poly_length(const fmpq_poly_t)
+@@ -46,10 +49,7 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_ui(fmpq_poly_t, ulong)
+     void fmpq_poly_set_fmpz(fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_set_fmpq(fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+     void fmpq_poly_set_fmpz_poly(fmpq_poly_t, const fmpz_poly_t)
+-    void fmpq_poly_set_array_mpq(fmpq_poly_t, const mpq_t *, slong)
+ 
+     void fmpq_poly_set_str(fmpq_poly_t, const char *)
+     char *fmpq_poly_get_str(const fmpq_poly_t)
+@@ -67,7 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_reverse(fmpq_poly_t, const fmpq_poly_t, slong)
+ 
+     void fmpq_poly_get_coeff_fmpq(fmpq_t, const fmpq_poly_t, slong)
+-    void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_si(slong, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_ui(ulong, const fmpq_poly_t, slong)
+ 
+@@ -75,8 +74,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_coeff_ui(fmpq_poly_t, slong, ulong)
+     void fmpq_poly_set_coeff_fmpz(fmpq_poly_t, slong, const fmpz_t)
+     void fmpq_poly_set_coeff_fmpq(fmpq_poly_t, slong, const fmpq_t)
+-    void fmpq_poly_set_coeff_mpz(fmpq_poly_t, slong, const mpz_t)
+-    void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
+ 
+     # Comparison
+     int fmpq_poly_equal(const fmpq_poly_t, const fmpq_poly_t)
+@@ -100,8 +97,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_mul_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     void fmpq_poly_scalar_div_si(fmpq_poly_t, const fmpq_poly_t, slong)
+     void fmpq_poly_scalar_div_ui(fmpq_poly_t, const fmpq_poly_t, ulong)
+@@ -109,8 +104,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_div_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_div_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_div_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Multiplication
+     void fmpq_poly_mul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -155,8 +148,6 @@ cdef extern from "flint_wrap.h":
+     # Evaluation
+     void fmpq_poly_evaluate_fmpz(fmpq_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_evaluate_fmpq(fmpq_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_evaluate_mpz(mpq_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_evaluate_mpq(mpq_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Composition
+     void fmpq_poly_compose(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -189,3 +180,11 @@ cdef extern from "flint_wrap.h":
+ # since the fmpq_poly header seems to be lacking this inline function
+ cdef inline sage_fmpq_poly_max_limbs(const fmpq_poly_t poly) noexcept:
+     return _fmpz_vec_max_limbs(fmpq_poly_numref(poly), fmpq_poly_length(poly))
++
++# functions removed from flint but still needed in sage
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
++cdef void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
++cdef void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pyx b/src/sage/libs/flint/fmpq_poly.pyx
+new file mode 100644
+index 00000000000..3b8a0cf0c51
+--- /dev/null
++++ b/src/sage/libs/flint/fmpq_poly.pyx
+@@ -0,0 +1,45 @@
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++from sage.libs.gmp.mpq cimport *
++from sage.libs.flint.fmpz cimport *
++from sage.libs.flint.fmpq cimport *
++
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t rop, const fmpq_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t rop, const fmpq_poly_t op, const mpq_t c):
++    cdef fmpq_t f
++    fmpq_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpq(rop, op, f)
++    fmpq_clear_readonly(f)
++
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t poly, slong n, const mpq_t x):
++    cdef fmpq_t t
++    fmpq_init_set_readonly(t, x)
++    fmpq_poly_set_coeff_fmpq(poly, n, t)
++    fmpq_clear_readonly(t)
++
++cdef void fmpq_poly_get_coeff_mpq(mpq_t x, const fmpq_poly_t poly, slong n):
++    cdef fmpq_t t
++    fmpq_init(t)
++    fmpq_poly_get_coeff_fmpq(t, poly, n)
++    fmpq_get_mpq(x, t)
++    fmpq_clear(t)
++
++cdef void fmpq_poly_set_mpq(fmpq_poly_t poly, const mpq_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), mpq_numref(x))
++    fmpz_set_mpz(fmpq_poly_denref(poly), mpq_denref(x))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
++
++cdef void fmpq_poly_set_mpz(fmpq_poly_t poly, const mpz_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), x)
++    fmpz_one(fmpq_poly_denref(poly))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz.pxd b/src/sage/libs/flint/fmpz.pxd
+index 01058d0f130..b97fbe1eae0 100644
+--- a/src/sage/libs/flint/fmpz.pxd
++++ b/src/sage/libs/flint/fmpz.pxd
+@@ -16,6 +16,9 @@ cdef extern from "flint_wrap.h":
+     void fmpz_init_set(fmpz_t, fmpz_t)
+     void fmpz_init_set_ui(fmpz_t, ulong)
+ 
++    void fmpz_init_set_readonly(fmpz_t, const mpz_t)
++    void fmpz_clear_readonly(fmpz_t)
++
+     # Conversion
+     void fmpz_set(fmpz_t f, fmpz_t g)
+     void fmpz_set_ui(fmpz_t, ulong)
+diff --git a/src/sage/libs/flint/fmpz_mod_poly.pxd b/src/sage/libs/flint/fmpz_mod_poly.pxd
+index 24b653eb3b7..2727246da98 100644
+--- a/src/sage/libs/flint/fmpz_mod_poly.pxd
++++ b/src/sage/libs/flint/fmpz_mod_poly.pxd
+@@ -67,13 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_get_coeff_fmpz(fmpz_t x, const fmpz_mod_poly_t poly,
+                                              slong n, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_set_coeff_mpz(fmpz_mod_poly_t poly,
+-                             slong n, const mpz_t x, const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_get_coeff_mpz(mpz_t x,
+-                 const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx)
+-
+-
+     void _fmpz_mod_poly_shift_left(fmpz * res, const fmpz * poly,
+                                                            slong len, slong n)
+ 
+@@ -194,14 +187,6 @@ cdef extern from "flint_wrap.h":
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_div_basecase(fmpz_mod_poly_t Q,
+-                            const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_div_newton_n_preinv(fmpz_mod_poly_t Q,
+-                         const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                         const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem_newton_n_preinv(fmpz_mod_poly_t Q,
+           fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                          const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+@@ -213,10 +198,6 @@ cdef extern from "flint_wrap.h":
+                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_divrem_divconquer(fmpz_mod_poly_t Q,
+-        fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem(fmpz_mod_poly_t Q, fmpz_mod_poly_t R,
+     const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+@@ -254,40 +235,13 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_make_monic_f(fmpz_t f, fmpz_mod_poly_t res,
+                          const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_euclidean(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_gcd_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_hgcd(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-
+     void fmpz_mod_poly_gcd(fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+ 
+-    void fmpz_mod_poly_xgcd_euclidean(fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_hgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S,
+-          fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_xgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                       const fmpz_mod_ctx_t ctx)
+@@ -361,14 +315,6 @@ cdef extern from "flint_wrap.h":
+                         const fmpz_mod_poly_t poly, const fmpz * xs, slong n,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_compose_horner(fmpz_mod_poly_t res,
+-                    const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_compose_divconquer(fmpz_mod_poly_t res,
+-                     const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_compose(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1,
+                          const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx)
+ 
+diff --git a/src/sage/libs/flint/fmpz_poly.pxd b/src/sage/libs/flint/fmpz_poly.pxd
+index 18b36672d30..c8bc6d3ca0a 100644
+--- a/src/sage/libs/flint/fmpz_poly.pxd
++++ b/src/sage/libs/flint/fmpz_poly.pxd
+@@ -28,7 +28,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_poly_set_ui(fmpz_poly_t, ulong)
+     void fmpz_poly_set_si(fmpz_poly_t, slong)
+     void fmpz_poly_set_fmpz(fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+     int fmpz_poly_set_str(fmpz_poly_t, const char *)
+ 
+     char *fmpz_poly_get_str(const fmpz_poly_t)
+@@ -70,7 +69,6 @@ cdef extern from "flint_wrap.h":
+     # Scalar multiplication and division
+     void fmpz_poly_scalar_mul_fmpz(
+             fmpz_poly_t, const fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+     void fmpz_poly_scalar_mul_si(fmpz_poly_t, const fmpz_poly_t, slong)
+     void fmpz_poly_scalar_mul_ui(fmpz_poly_t, const fmpz_poly_t, ulong)
+     void fmpz_poly_scalar_mul_2exp(fmpz_poly_t, const fmpz_poly_t, ulong)
+@@ -310,12 +308,14 @@ cdef extern from "flint_wrap.h":
+             fmpz_poly_t,
+                     const fmpz_poly_t, const fmpz_t, const nmod_poly_t, int)
+ 
+-    # Some functions for backwards compatibility
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
+-    void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++
++# functions removed from flint but still needed in sage
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
++cdef void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++cdef void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+ 
+ 
+ # Wrapper Cython class
+diff --git a/src/sage/libs/flint/fmpz_poly.pyx b/src/sage/libs/flint/fmpz_poly.pyx
+index 74915b37612..cfcbea9090c 100644
+--- a/src/sage/libs/flint/fmpz_poly.pyx
++++ b/src/sage/libs/flint/fmpz_poly.pyx
+@@ -25,10 +25,10 @@ from cysignals.memory cimport sig_free
+ 
+ from sage.arith.long cimport pyobject_to_long
+ from sage.cpython.string cimport char_to_str, str_to_bytes
++from sage.libs.flint.fmpz cimport *
+ from sage.structure.sage_object cimport SageObject
+ from sage.rings.integer cimport Integer
+ 
+-
+ cdef class Fmpz_poly(SageObject):
+ 
+     def __cinit__(self):
+@@ -455,3 +455,44 @@ cdef class Fmpz_poly(SageObject):
+         """
+         from sage.rings.integer_ring import ZZ
+         return ZZ[var](self.list())
++
++
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_divexact_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_fdiv_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t poly, slong n, const mpz_t x):
++    cdef fmpz_t t
++    fmpz_init_set_readonly(t, x)
++    fmpz_poly_set_coeff_fmpz(poly, n, t)
++    fmpz_clear_readonly(t)
++
++cdef void fmpz_poly_get_coeff_mpz(mpz_t x, const fmpz_poly_t poly, slong n):
++    cdef fmpz_t t
++    fmpz_init(t)
++    fmpz_poly_get_coeff_fmpz(t, poly, n)
++    fmpz_get_mpz(x, t)
++    fmpz_clear(t)
++
++cdef void fmpz_poly_set_mpz(fmpz_poly_t poly, const mpz_t x):
++    fmpz_poly_fit_length(poly, 1)
++    fmpz_set_mpz(poly.coeffs, x)
++    _fmpz_poly_set_length(poly, 1)
++    _fmpz_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz_poly_q.pxd b/src/sage/libs/flint/fmpz_poly_q.pxd
+index 846542dc0d8..63c13355bf6 100644
+--- a/src/sage/libs/flint/fmpz_poly_q.pxd
++++ b/src/sage/libs/flint/fmpz_poly_q.pxd
+@@ -49,11 +49,7 @@ cdef extern from "flint_wrap.h":
+ 
+     #* Scalar multiplication and division ****************************************/
+     void fmpz_poly_q_scalar_mul_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_mul_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_mul_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+     void fmpz_poly_q_scalar_div_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_div_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_div_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+ 
+     #* Multiplication and division ***********************************************/
+     void fmpz_poly_q_mul(fmpz_poly_q_t rop, 
+@@ -67,9 +63,6 @@ cdef extern from "flint_wrap.h":
+     #* Derivative ****************************************************************/
+     void fmpz_poly_q_derivative(fmpz_poly_q_t rop, const fmpz_poly_q_t op)
+ 
+-    #* Evaluation ****************************************************************/
+-    int fmpz_poly_q_evaluate(mpq_t rop, const fmpz_poly_q_t f, const mpq_t a)
+-
+     #* Input and output **********************************************************/
+     int fmpz_poly_q_set_str(fmpz_poly_q_t rop, const char *s)
+     char * fmpz_poly_q_get_str(const fmpz_poly_q_t op)
+diff --git a/src/sage/libs/linbox/linbox_flint_interface.pyx b/src/sage/libs/linbox/linbox_flint_interface.pyx
+index dabd375c2b8..3ca65afc514 100644
+--- a/src/sage/libs/linbox/linbox_flint_interface.pyx
++++ b/src/sage/libs/linbox/linbox_flint_interface.pyx
+@@ -33,6 +33,7 @@ and C. Pernet. The functions available are:
+ #                  https://www.gnu.org/licenses/
+ # ****************************************************************************
+ 
++from sage.libs.gmp.types cimport mpz_t
+ from sage.libs.flint.types cimport fmpz_t
+ from sage.libs.flint.fmpz cimport fmpz_get_mpz, fmpz_set_mpz
+ from sage.libs.flint.fmpz_mat cimport fmpz_mat_entry, fmpz_mat_nrows, fmpz_mat_ncols
+@@ -80,11 +81,13 @@ cdef void fmpz_poly_set_linbox(fmpz_poly_t p, PolynomialRing_integer.Element& q)
+     (the .pxd file) in order to keep the header C-compatible
+     """
+     cdef size_t i
++    cdef mpz_t tmp
+ 
+     fmpz_poly_fit_length(p, q.size())
+ 
+     for i in range(q.size()):
+-        fmpz_poly_set_coeff_mpz(p, i, q[i].get_mpz_const())
++        tmp = q[i].get_mpz_const()
++        fmpz_poly_set_coeff_mpz(p, i, tmp)
+ 
+     _fmpz_poly_set_length(p, q.size())
+ 
+diff --git a/src/sage/matrix/matrix_complex_ball_dense.pyx b/src/sage/matrix/matrix_complex_ball_dense.pyx
+index 22366b5f1f2..7fdf3f2aa36 100644
+--- a/src/sage/matrix/matrix_complex_ball_dense.pyx
++++ b/src/sage/matrix/matrix_complex_ball_dense.pyx
+@@ -1,4 +1,4 @@
+-# distutils: libraries = ARB_LIBRARY
++# distutils: libraries = flint
+ r"""
+ Arbitrary precision complex ball matrices using Arb
+ 
+diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx
+index 0712500e67d..daba89d5c43 100644
+--- a/src/sage/matrix/matrix_integer_sparse.pyx
++++ b/src/sage/matrix/matrix_integer_sparse.pyx
+@@ -847,6 +847,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+             sage: matrix(ZZ, 1, 1, sparse=True)._charpoly_linbox()
+             x
+         """
++        cdef mpz_t tmp
+         if self._nrows != self._ncols:
+             raise ArithmeticError('only valid for square matrix')
+ 
+@@ -869,7 +870,8 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         cdef size_t i
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+@@ -966,9 +968,11 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         sig_off()
+ 
+         cdef size_t i
++        cdef mpz_t tmp
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
+index f36a89bb229..20a06f7eaa3 100644
+--- a/src/sage/rings/complex_arb.pyx
++++ b/src/sage/rings/complex_arb.pyx
+@@ -1360,12 +1360,13 @@ cdef class ComplexBall(RingElement):
+             sage: CBF100(-3r)
+             -3.000000000000000000000000000000
+ 
+-            sage: ComplexBall(CBF100, 10^100)
+-            1.000000000000000000000000000000e+100
+             sage: ComplexBall(CBF100, CIF(1, 2))
+             1.000000000000000000000000000000 + 2.000000000000000000000000000000*I
+             sage: ComplexBall(CBF100, RBF(1/3), RBF(1))
+             [0.3333333333333333 +/- ...e-17] + 1.000000000000000000000000000000*I
++            sage: ComplexBall(CBF100, 10^100)
++            [1.000000000000000000000000000000e+100 +/- ...]
++
+             sage: NF.<a> = QuadraticField(-1, embedding=CC(0, -1))
+             sage: CBF(a)
+             -1.000000000000000*I
+@@ -3009,7 +3010,7 @@ cdef class ComplexBall(RingElement):
+             sage: CBF(1).rising_factorial(2**64)
+             [+/- ...e+347382171326740403407]
+             sage: ComplexBallField(128)(1).rising_factorial(2**64)
+-            [2.343691126796861348e+347382171305201285713 +/- ...e+347382171305201285694]
++            [2.34369112679686134...e+347382171305201285713 +/- ...]
+             sage: CBF(1/2).rising_factorial(CBF(2,3)) # abs tol 1e-15
+             [-0.123060451458124 +/- 3.06e-16] + [0.0406412631676552 +/- 7.57e-17]*I
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+index f651c9f3512..c68246d2142 100644
+--- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+@@ -222,7 +222,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef unsigned long n
+         cdef Rational c
+         cdef list L1
+-        cdef mpq_t * L2
++        cdef fmpq_t q
+ 
+         Polynomial.__init__(self, parent, is_gen=is_gen)
+ 
+@@ -253,14 +253,11 @@ cdef class Polynomial_rational_flint(Polynomial):
+             L1 = [e if isinstance(e, Rational) else Rational(e) for e in x]
+             n  = <unsigned long> len(x)
+             sig_on()
+-            L2 = <mpq_t *> check_allocarray(n, sizeof(mpq_t))
++            fmpq_poly_fit_length(self._poly, n)
+             for deg from 0 <= deg < n:
+-                mpq_init(L2[deg])
+-                mpq_set(L2[deg], (<Rational> L1[deg]).value)
+-            fmpq_poly_set_array_mpq(self._poly, L2, n)
+-            for deg from 0 <= deg < n:
+-                mpq_clear(L2[deg])
+-            sig_free(L2)
++                fmpq_init_set_readonly(q, (<Rational> L1[deg]).value)
++                fmpq_poly_set_coeff_fmpq(self._poly, deg, q)
++                fmpq_clear_readonly(q)
+             sig_off()
+ 
+ #           deg = 0
+@@ -435,6 +432,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         utmost care.
+         """
+         cdef bint do_sig = _do_sig(self._poly)
++        cdef fmpz_t tmpfz
+ 
+         if isinstance(value, int):
+             if do_sig: sig_str("FLINT exception")
+@@ -442,7 +440,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+             if do_sig: sig_off()
+         elif isinstance(value, Integer):
+             if do_sig: sig_str("FLINT exception")
+-            fmpq_poly_set_coeff_mpz(self._poly, n, (<Integer> value).value)
++            fmpz_init_set_readonly(tmpfz, (<Integer> value).value)
++            fmpq_poly_set_coeff_fmpz(self._poly, n, tmpfz)
++            fmpz_clear_readonly(tmpfz)
+             if do_sig: sig_off()
+         elif isinstance(value, Rational):
+             if do_sig: sig_str("FLINT exception")
+@@ -492,7 +492,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef Polynomial_rational_flint f
+         cdef Rational r
+         cdef fmpz_t tmpfz
+-        cdef fmpq_t tmpfq
++        cdef fmpq_t tmpfq, tmpfq1
+         cdef RealBall arb_a, arb_z
+         cdef ComplexBall acb_a, acb_z
+ 
+@@ -508,13 +508,23 @@ cdef class Polynomial_rational_flint(Polynomial):
+             elif isinstance(a, Rational):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpq(r.value, self._poly, (<Rational> a).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> a).value)
++                fmpq_init(tmpfq1)
++                fmpq_poly_evaluate_fmpq(tmpfq1, self._poly, tmpfq)
++                fmpq_get_mpq(r.value, tmpfq1)
++                fmpq_clear(tmpfq1)
++                fmpq_clear_readonly(tmpfq)
+                 sig_off()
+                 return r
+             elif isinstance(a, Integer):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpz(r.value, self._poly, (<Integer> a).value)
++                fmpz_init_set_readonly(tmpfz, (<Integer> a).value)
++                fmpq_init(tmpfq)
++                fmpq_poly_evaluate_fmpz(tmpfq, self._poly, tmpfz)
++                fmpq_get_mpq(r.value, tmpfq)
++                fmpq_clear(tmpfq)
++                fmpz_clear_readonly(tmpfz)
+                 sig_off()
+                 return r
+             elif isinstance(a, int):
+@@ -1321,6 +1331,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         """
+         cdef Polynomial_rational_flint res
+         cdef bint do_sig
++        cdef fmpq_t tmpfq
+ 
+         if right == 0:
+             raise ZeroDivisionError("division by zero polynomial")
+@@ -1331,8 +1342,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+                 do_sig = _do_sig(self._poly)
+ 
+                 if do_sig: sig_str("FLINT exception")
+-                fmpq_poly_scalar_div_mpq(res._poly, self._poly,
+-                                                  (<Rational> QQ(right)).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> QQ(right)).value)
++                fmpq_poly_scalar_div_fmpq(res._poly, self._poly, tmpfq)
++                fmpq_clear_readonly(tmpfq)
+                 if do_sig: sig_off()
+                 return res
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+index 6e7f7498329..3a66198d568 100644
+--- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+@@ -658,6 +658,11 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
+             ...
+             NotImplementedError: square free factorization of polynomials over rings with composite characteristic is not implemented
+ 
++        :trac:`20003`::
++
++            sage: P.<x> = GF(7)[]
++            sage: (6*x+3).squarefree_decomposition()
++            (6) * (x + 4)
+         """
+         if not self.base_ring().is_field():
+             raise NotImplementedError("square free factorization of polynomials over rings with composite characteristic is not implemented")
+diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
+index a9ce06d14ca..affe11e4376 100644
+--- a/src/sage/rings/real_arb.pyx
++++ b/src/sage/rings/real_arb.pyx
+@@ -898,7 +898,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+             sage: RBF.gamma(5)
+             24.00000000000000
+             sage: RBF.gamma(10**20)
+-            [+/- ...e+1956570552410610660600]
++            [1.932849514310098...+1956570551809674817225 +/- ...]
+             sage: RBF.gamma(1/3)
+             [2.678938534707747 +/- ...e-16]
+             sage: RBF.gamma(-5)
+@@ -1102,7 +1102,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+              15.00000000000000,
+              48.00000000000000]
+             sage: RBF.double_factorial(2**20)
+-            [1.4483729903e+2928836 +/- ...e+2928825]
++            [1.448372990...e+2928836 +/- ...]
+             sage: RBF.double_factorial(2**1000)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/schemes/plane_conics/con_rational_function_field.py b/src/sage/schemes/plane_conics/con_rational_function_field.py
+index 05d24e78a85..581102b5c5b 100644
+--- a/src/sage/schemes/plane_conics/con_rational_function_field.py
++++ b/src/sage/schemes/plane_conics/con_rational_function_field.py
+@@ -198,38 +198,6 @@ def has_rational_point(self, point=False, algorithm='default',
+             Fraction Field of Univariate Polynomial Ring in u over Rational
+             Field with modulus v^2 - u^3 - 1
+ 
+-        ``has_rational_point`` fails for some conics over function fields
+-        over finite fields, due to :trac:`20003`::
+-
+-            sage: K.<t> = PolynomialRing(GF(7))
+-            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
+-            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
+-            sage: C.has_rational_point()                                                # needs sage.libs.singular
+-            Traceback (most recent call last):
+-            ...
+-            TypeError: self (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (-t^3 + 3*t^2 - 2*t - 2)/(t + 3)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (t^2 + 3*t + 3)*x*y + (-2*t^2 - 2)*y^2 + (-t^2 + 3*t + 2)*x*z + (-3*t + 3)*y*z + (-3*t^2 + t - 2)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x + (2*t - 2)/(t + 3)*y + (3*t^4 + 2*t^3 - 2*t^2 - 2*t + 3)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z
+-                     : y + (-t^3 - t^2 + 3*t - 1)/(t^3 - 3*t^2 + 2*t + 2)*z : z))
+-            domain must equal right (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^3 - t^2 + 3*t + 3)*x^2 + (t - 3)*y^2 + (-t^7 + 2*t^5 + t^4 + 2*t^3 + 3*t^2 - t - 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    -2/(t^3 - 3*t^2 + 2*t + 2)*x^2 + 1/(t^3 + 3*t^2 - 2*t + 1)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^9 - 2*t^8 + t^7 - t^6 + 3*t^5 - 3*t^3 + t^2 - 2*t + 3)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    ((t^3 - 3*t^2 + 2*t + 2)*x : (t^2 - 2)*y : (t^5 - 3*t^4 + t^2 + 3*t + 3)*z))
+-            codomain
+-
+-
+-
+         TESTS::
+ 
+             sage: K.<t> = FractionField(PolynomialRing(QQ, 't'))
+@@ -250,6 +218,16 @@ def has_rational_point(self, point=False, algorithm='default',
+             sage: C.has_rational_point(point=True)  # long time (4 seconds)             # needs sage.libs.singular
+             (True,
+              ((-2/117*t^8 + 304/1053*t^7 + 40/117*t^6 - 1/27*t^5 - 110/351*t^4 - 2/195*t^3 + 11/351*t^2 + 1/117)/(t^4 + 2/39*t^3 + 4/117*t^2 + 2/39*t + 14/39) : -5/3*t^4 + 19*t^3 : 1))
++
++        ``has_rational_point`` used to fail for some conics over function fields
++        over finite fields, due to :trac:`20003`::
++
++            sage: K.<t> = PolynomialRing(GF(7))
++            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
++            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
++            sage: C.has_rational_point()
++            True
++
+         """
+         from .constructor import Conic
+ 
+diff --git a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+index a591cb4cd7c..a90f2050c59 100644
+--- a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
++++ b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+@@ -20,6 +20,7 @@
+ #include "utils.h"
+ 
+ #include "gmp.h"
++#include "flint/fmpz_poly.h"
+ #include "flint/fmpq_poly.h"
+ #include "flint/fmpq.h"
+ 
+@@ -63,7 +64,7 @@ static ex chebyt_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+@@ -122,7 +123,7 @@ static ex chebyu_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+diff --git a/src/sage/symbolic/ginac/useries.cpp b/src/sage/symbolic/ginac/useries.cpp
+index 40fbd7ab360..b9a8b867648 100644
+--- a/src/sage/symbolic/ginac/useries.cpp
++++ b/src/sage/symbolic/ginac/useries.cpp
+@@ -467,10 +467,17 @@ void add::useries(flint_series_t& fp, int order) const
+                 fmpq_poly_set_ui(fp.ft, 0);
+         else if (oc.is_long())
+                 fmpq_poly_set_si(fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ 
+         for (const auto & elem : seq) {
+ 		const ex& t = recombine_pair_to_ex(elem);
+@@ -505,10 +512,17 @@ void mul::useries(flint_series_t& fp, int order) const
+ 
+         if (oc.is_long())
+                 fmpq_poly_scalar_mul_si(fp.ft, fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_scalar_mul_mpz(fp.ft, fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_scalar_mul_mpq(fp.ft, fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_scalar_mul_fmpz(fp.ft, fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp.ft, fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ void power::useries(flint_series_t& fp, int order) const
+@@ -563,7 +577,10 @@ void power::useries(flint_series_t& fp, int order) const
+                 }
+                 check_poly_ccoeff_one(fp1);
+                 fmpq_poly_log_series(fp1.ft, fp1.ft, order);
+-                fmpq_poly_scalar_mul_mpq(fp1.ft, fp1.ft, nexp.as_mpq());
++                fmpq_t tmp;
++                fmpq_init_set_readonly(tmp, nexp.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp1.ft, fp1.ft, tmp);
++                fmpq_clear_readonly(tmp);
+                 fmpq_poly_exp_series(fp.ft, fp1.ft, order);
+                 return;
+         }
+@@ -608,10 +625,17 @@ void numeric::useries(flint_series_t& fp, int order) const
+ {
+         if (is_long())
+                 fmpq_poly_set_si(fp.ft, to_long());
+-        else if (is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, as_mpq());
++        else if (is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ } // namespace GiNaC
+diff --git a/src/sage_setup/library_order.py b/src/sage_setup/library_order.py
+index f40690f8d22..9ae0d2579a7 100644
+--- a/src/sage_setup/library_order.py
++++ b/src/sage_setup/library_order.py
+@@ -16,17 +16,12 @@
+ 
+ aliases = cython_aliases(required_modules=(), optional_modules=modules)
+ 
+-if "ARB_LIBRARY" in aliases:
+-    arb_dylib_names = [aliases["ARB_LIBRARY"]]
+-else:
+-    arb_dylib_names = []
+-
+ library_order_list = aliases.get("SINGULAR_LIBRARIES", []) + [
+     "giac", "intl", "curl",
+     "ec", "ecm"
+ ] + aliases.get("LINBOX_LIBRARIES", []) + aliases.get("FFLASFFPACK_LIBRARIES", []) + aliases.get("GSL_LIBRARIES", []) + [
+     "pari", "flint", "ecl", "glpk", "ppl",
+-] + arb_dylib_names + [
++] + [
+     "mpfi", "mpfr", "mpc", "ntl", "gmp", "gmpxx",
+     "brial",
+     "brial_groebner",
diff --git a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch b/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
deleted file mode 100644
index 7c55bce6e9bb4..0000000000000
--- a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
+++ /dev/null
@@ -1,221 +0,0 @@
-diff --git a/build/pkgs/singular/checksums.ini b/build/pkgs/singular/checksums.ini
-index 313463d2fea..1101fc55700 100644
---- a/build/pkgs/singular/checksums.ini
-+++ b/build/pkgs/singular/checksums.ini
-@@ -1,5 +1,5 @@
- tarball=singular-VERSION.tar.gz
--sha1=28bb3ee97ef48d04dfa96de182fd93eebe08426c
--md5=fc0a4f5720dadba45a52ee94324ce00c
--cksum=1573851737
--upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-1/singular-VERSION.tar.gz
-+sha1=df1997f412580f2073295aba569bb955ad227317
-+md5=50349213e206a18cdaa1bc410dde7ea4
-+cksum=376854707
-+upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-2/singular-VERSION.tar.gz
-diff --git a/build/pkgs/singular/package-version.txt b/build/pkgs/singular/package-version.txt
-index 66e2bede53a..9f1bf008217 100644
---- a/build/pkgs/singular/package-version.txt
-+++ b/build/pkgs/singular/package-version.txt
-@@ -1 +1 @@
--4.3.1p3
-+4.3.2p7
-diff --git a/build/pkgs/singular/spkg-configure.m4 b/build/pkgs/singular/spkg-configure.m4
-index 6a85631f624..f7621ec5fa1 100644
---- a/build/pkgs/singular/spkg-configure.m4
-+++ b/build/pkgs/singular/spkg-configure.m4
-@@ -6,14 +6,27 @@ SAGE_SPKG_CONFIGURE([singular], [
-     AS_IF([test -z "${SINGULAR_BIN}"], [sage_spkg_install_singular=yes], [
-       dnl Use pkg-config to ensure that Singular is new enough.
-       PKG_CHECK_MODULES([SINGULAR], [Singular >= 4.2.1], [
--       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)
--       ], [
--       AC_MSG_RESULT(no)
--       sage_spkg_install_singular=yes
--       ]
--      )], [
-+        AC_MSG_CHECKING([whether Singular is built with FLINT])
-+        AC_COMPILE_IFELSE([
-+          AC_LANG_PROGRAM([
-+            #include <singular/singularconfig.h>
-+            #if !defined(HAVE_FLINT)
-+            #  error "Need Singular compiled with FLINT"
-+          ], [])
-+        ], [
-+          AC_MSG_RESULT([yes])
-+          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)
-+          ], [
-+            AC_MSG_RESULT(no)
-+            sage_spkg_install_singular=yes
-+          ])
-+        ], [
-+          AC_MSG_RESULT([no])
-+          sage_spkg_install_singular=yes
-+        ])
-+      ], [
-       dnl pkg-config version check failed
-       sage_spkg_install_singular=yes
-       ])
-diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py
-index b15cc1c602c..4b5c76e2bfa 100644
---- a/src/sage/interfaces/singular.py
-+++ b/src/sage/interfaces/singular.py
-@@ -604,8 +604,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: i = singular.ideal(['x^2','y^2','z^2'])
-             sage: s = i.std()
-             sage: singular.eval('hilb(%s)'%(s.name()))
--            '// 1 t^0\n// -3 t^2\n// 3 t^4\n// -1 t^6\n\n// 1 t^0\n//
--            3 t^1\n// 3 t^2\n// 1 t^3\n// dimension (affine) = 0\n//
-+            '...// dimension (affine) = 0\n//
-             degree (affine) = 8'
- 
-         ::
-@@ -613,15 +612,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: from sage.misc.verbose import set_verbose
-             sage: set_verbose(1)
-             sage: o = singular.eval('hilb(%s)'%(s.name()))
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
- 
-         This is mainly useful if this method is called implicitly. Because
-@@ -631,15 +622,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-         ::
- 
-             sage: o = s.hilb()
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
-             // ** right side is not a datum, assignment ignored
-             ...
-diff --git a/src/sage/libs/singular/function.pyx b/src/sage/libs/singular/function.pyx
-index f40346d1fd0..c597c63aafe 100644
---- a/src/sage/libs/singular/function.pyx
-+++ b/src/sage/libs/singular/function.pyx
-@@ -1241,32 +1241,22 @@ cdef class SingularFunction(SageObject):
-             sage: I = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5])
-             sage: I = Ideal(I.groebner_basis())
-             sage: hilb = sage.libs.singular.function_factory.ff.hilb
--            sage: hilb(I) # Singular will print // ** _ is no standard basis
--            // ** _ is no standard basis
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: from sage.misc.sage_ostools import redirection
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I) # Singular will print // ** _ is no standard basis
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            True
- 
-         So we tell Singular that ``I`` is indeed a Groebner basis::
- 
--            sage: hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            False
- 
- 
-         TESTS:
-diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-index 22ada6de947..80352700872 100644
---- a/src/sage/rings/polynomial/multi_polynomial_ideal.py
-+++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-@@ -3132,13 +3132,16 @@ def hilbert_numerator(self, grading=None, algorithm='sage'):
-             sage: I.hilbert_numerator()                                                 # needs sage.rings.number_field
-             -t^5 + 1
- 
--        This example returns a wrong answer due to an integer overflow in Singular::
-+        This example returns a wrong answer in singular < 4.3.2p4 due to an integer overflow::
- 
-             sage: n=4; m=11; P = PolynomialRing(QQ, n*m, "x"); x = P.gens(); M = Matrix(n, x)
-             sage: I = P.ideal(M.minors(2))
-             sage: J = P * [m.lm() for m in I.groebner_basis()]
--            sage: J.hilbert_numerator(algorithm='singular')
--            ...120*t^33 - 3465*t^32 + 48180*t^31 - ...
-+            sage: J.hilbert_numerator(algorithm='singular') # known bug
-+            Traceback (most recent call last):
-+            ....
-+            RuntimeError: error in Singular function call 'hilb':
-+            overflow at t^22
- 
-         Our two algorithms should always agree; not tested until
-         :trac:`33178` is fixed::
-diff --git a/src/sage/sandpiles/sandpile.py b/src/sage/sandpiles/sandpile.py
-index 02d2021b2fb..c8e15e06f05 100644
---- a/src/sage/sandpiles/sandpile.py
-+++ b/src/sage/sandpiles/sandpile.py
-@@ -2493,9 +2493,15 @@ def _set_ideal(self):
-             sage: '_ideal' in S.__dict__
-             True
-         """
-+        from sage.libs.singular.function_factory import ff
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
-         R = self.ring()
--        I = self._unsaturated_ideal._singular_()
--        self._ideal = R.ideal(I.sat(prod(R.gens())._singular_())[1])
-+        I = self._unsaturated_ideal
-+        I_sat_gens = sat(I, prod(R.gens()))[0]
-+        self._ideal = R.ideal(I_sat_gens)
- 
-     def unsaturated_ideal(self):
-         r"""
-diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py
-index e6caf19ba74..afd6484d779 100644
---- a/src/sage/schemes/projective/projective_subscheme.py
-+++ b/src/sage/schemes/projective/projective_subscheme.py
-@@ -1001,7 +1001,10 @@ def dual(self):
-         for i in range(n + 1):
-             J = J + S.ideal(z[-1] * f_S.derivative(z[i]) - z[i + n + 1])
- 
--        sat = ff.elim__lib.sat
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
- 
-         max_ideal = S.ideal(z[n + 1: 2 * n + 2])
-         J_sat_gens = sat(J, max_ideal)[0]
diff --git a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch b/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
deleted file mode 100644
index 6a35ec3836550..0000000000000
--- a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-diff --git a/src/sage/ext/memory.pyx b/src/sage/ext/memory.pyx
-index 1de6dedab82..b95130b19dd 100644
---- a/src/sage/ext/memory.pyx
-+++ b/src/sage/ext/memory.pyx
-@@ -3,14 +3,14 @@ Low-level memory allocation functions
- 
- TESTS:
- 
--Check that a ``MemoryError`` is raised if we try to allocate a
-+Check that an error is raised if we try to allocate a
- ridiculously large integer, see :trac:`15363`::
- 
--    sage: 2^(2^63-3)
--    Traceback (most recent call last):
--    ...
--    OverflowError: exponent must be at most 2147483647         # 32-bit
--    RuntimeError: Aborted                                      # 64-bit
-+    sage: try:
-+    ....:     2^(2^63-3)
-+    ....: except (OverflowError, RuntimeError, FloatingPointError):
-+    ....:     print ('Overflow error')
-+    ...Overflow error
- 
- AUTHORS:
- 
-diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx
-index d5e87626d31..37ed9364845 100644
---- a/src/sage/rings/integer.pyx
-+++ b/src/sage/rings/integer.pyx
-@@ -6654,7 +6654,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
-             sage: try:
-             ....:     print('Possible error output from gmp', flush=True)
-             ....:     1 << (2^60)
--            ....: except (MemoryError, OverflowError, RuntimeError):
-+            ....: except (MemoryError, OverflowError, RuntimeError, FloatingPointError):
-             ....:     pass
-             ....: else:
-             ....:     print("Failed to raise exception")
diff --git a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch b/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
deleted file mode 100644
index 3d2a4bd9cd96f..0000000000000
--- a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
+++ /dev/null
@@ -1,740 +0,0 @@
-diff --git a/src/sage/ext_data/valgrind/valgrind-python.supp b/src/sage/ext_data/valgrind/valgrind-python.supp
-new file mode 100644
-index 00000000000..16aa2858484
---- /dev/null
-+++ b/src/sage/ext_data/valgrind/valgrind-python.supp
-@@ -0,0 +1,480 @@
-+# From the CPython repository with the suppressions for _PyObject_Free
-+# and _PyObject_Realloc enabled. See the upstream suppression file for
-+# details:
-+#
-+# https://github.com/python/cpython/blob/main/Misc/valgrind-python.supp
-+
-+# all tool names: Addrcheck,Memcheck,cachegrind,helgrind,massif
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 8 (x86_64 aka amd64)
-+   Memcheck:Value8
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:address_in_range
-+}
-+
-+#
-+# Leaks (including possible leaks)
-+#    Hmmm, I wonder if this masks some real leaks.  I think it does.
-+#    Will need to fix that.
-+#
-+
-+{
-+   Suppress leaking the GIL after a fork.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_allocate_lock
-+   fun:PyEval_ReInitThreads
-+}
-+
-+{
-+   Suppress leaking the autoTLSkey.  This looks like it shouldn't leak though.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_create_key
-+   fun:_PyGILState_Init
-+   fun:Py_InitializeEx
-+   fun:Py_Main
-+}
-+
-+{
-+   Hmmm, is this a real leak or like the GIL?
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_ReInitTLS
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:realloc
-+   fun:_PyObject_GC_Resize
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_New
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_NewVar
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+#
-+# Non-python specific leaks
-+#
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:calloc
-+   fun:allocate_dtv
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:memalign
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Realloc
-+}
-+
-+###
-+### All the suppressions below are for errors that occur within libraries
-+### that Python uses.  The problems to not appear to be related to Python's
-+### use of the libraries.
-+###
-+
-+{
-+   Generic ubuntu ld problems
-+   Memcheck:Addr8
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+}
-+
-+{
-+   Generic gentoo ld problems
-+   Memcheck:Cond
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_close
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Value8
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   GDBM problems, see test_gdbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   fun:gdbm_open
-+
-+}
-+
-+{
-+   Uninitialised byte(s) false alarm, see bpo-35561
-+   Memcheck:Param
-+   epoll_ctl(event)
-+   fun:epoll_ctl
-+   fun:pyepoll_internal_ctl
-+}
-+
-+{
-+   ZLIB problems, see test_gzip
-+   Memcheck:Cond
-+   obj:/lib/libz.so.1.2.3
-+   obj:/lib/libz.so.1.2.3
-+   fun:deflate
-+}
-+
-+{
-+   Avoid problems w/readline doing a putenv and leaking on exit
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:xmalloc
-+   fun:sh_set_lines_and_columns
-+   fun:_rl_get_screen_size
-+   fun:_rl_init_terminal_io
-+   obj:/lib/libreadline.so.4.3
-+   fun:rl_initialize
-+}
-+
-+# Valgrind emits "Conditional jump or move depends on uninitialised value(s)"
-+# false alarms on GCC builtin strcmp() function. The GCC code is correct.
-+#
-+# Valgrind bug: https://bugs.kde.org/show_bug.cgi?id=264936
-+{
-+   bpo-38118: Valgrind emits false alarm on GCC builtin strcmp()
-+   Memcheck:Cond
-+   fun:PyUnicode_Decode
-+}
-+
-+
-+###
-+### These occur from somewhere within the SSL, when running
-+###  test_socket_sll.  They are too general to leave on by default.
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:memset
-+###}
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:memset
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:MD5_Update
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:MD5_Update
-+###}
-+
-+# Fedora's package "openssl-1.0.1-0.1.beta2.fc17.x86_64" on x86_64
-+# See http://bugs.python.org/issue14171
-+{
-+   openssl 1.0.1 prng 1
-+   Memcheck:Cond
-+   fun:bcmp
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 2
-+   Memcheck:Cond
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 3
-+   Memcheck:Value8
-+   fun:_x86_64_AES_encrypt_compact
-+   fun:AES_encrypt
-+}
-+
-+#
-+# All of these problems come from using test_socket_ssl
-+#
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_bin2bn
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libcrypto.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_set_key_unchecked
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_encrypt2
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BUF_MEM_grow_clean
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:memcpy
-+   fun:ssl3_read_bytes
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:SHA1_Update
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:SHA1_Update
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-+{
-+   wcscmp_false_positive
-+   Memcheck:Addr8
-+   fun:wcscmp
-+   fun:_PyOS_GetOpt
-+   fun:Py_Main
-+   fun:main
-+}
-+
-+# Additional suppressions for the unified decimal tests:
-+{
-+   test_decimal
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_decimal2
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index b40ed64edb5..8c55861c147 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -1576,6 +1576,62 @@ const numeric numeric::div(const numeric &other) const {
-         }
- }
- 
-+
-+// Compute `a^b` as an integer, where a is an integer. Assign to ``res``` if it is integral, or return ``false``.
-+// The nonnegative real root is taken for even denominators. To be used inside numeric::integer_rational_power,
-+// to handle the special case of integral ``a``.
-+bool integer_rational_power_of_mpz(
-+        numeric& res,
-+        const numeric& a,
-+        const numeric& b
-+) {
-+        if (a.t != MPZ)
-+                throw std::runtime_error("integer_rational_power_of_mpz: bad input");
-+        mpz_t z;
-+        mpz_init(z);
-+        mpz_set_ui(z, 0);
-+        int sgn = mpz_sgn(a.v._bigint);
-+        if (mpz_cmp_ui(a.v._bigint, 1) == 0
-+            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
-+                mpz_set_ui(z, 1);
-+        else if (sgn == 0) {
-+                res = *_num0_p;
-+                mpz_clear(z);
-+                return true;
-+        }
-+        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1)) {
-+                mpz_clear(z);
-+                return false;
-+        } else {
-+                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-+                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat))) {
-+                        // too big to take roots/powers
-+                        mpz_clear(z);
-+                        return false;
-+                }
-+                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
-+                        if (mpz_perfect_square_p(a.v._bigint)) {
-+                                mpz_sqrt(z, a.v._bigint);
-+                        } else {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                else {
-+                        bool exact = mpz_root(z, a.v._bigint,
-+                                              mpz_get_ui(mpq_denref(b.v._bigrat)));
-+                        if (not exact) {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
-+        }
-+        res = numeric(z);   // transfers ownership, no mpz_clear
-+        return true;
-+}
-+
-+
- // Compute `a^b` as an integer, if it is integral, or return ``false``.
- // The nonnegative real root is taken for even denominators.
- bool numeric::integer_rational_power(numeric& res,
-@@ -1598,13 +1654,12 @@ bool numeric::integer_rational_power(numeric& res,
-                 if (a.v._long < 0
-                     and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
-                         return false;
--                long z;
-                 if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-                     or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
-                 // too big to take roots/powers
-                         return false;
-                 if (b.is_equal(*_num1_2_p)) {
--                        z = std::lround(std::sqrt(a.v._long));
-+                        long z = std::lround(std::sqrt(a.v._long));
-                         if (a.v._long == z*z) {
-                                 res = numeric(z);
-                                 return true;
-@@ -1613,44 +1668,11 @@ bool numeric::integer_rational_power(numeric& res,
-                 }
-                 return integer_rational_power(res, a.to_bigint(), b);
-         }
--        if (a.t != MPZ)
--                throw std::runtime_error("integer_rational_power: bad input");
--        int sgn = mpz_sgn(a.v._bigint);
--        mpz_t z;
--        mpz_init(z);
--        mpz_set_ui(z, 0);
--        if (mpz_cmp_ui(a.v._bigint, 1) == 0
--            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
--                mpz_set_ui(z, 1);
--        else if (sgn == 0) {
--                res = *_num0_p;
--                return true;
--        }
--        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
--                return false;
--        else {
--                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
--                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
--                // too big to take roots/powers
--                        return false;
--                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
--                        if (mpz_perfect_square_p(a.v._bigint))
--                                mpz_sqrt(z, a.v._bigint);
--                        else
--                                return false;
--                }
--                else {
--                        bool exact = mpz_root(z, a.v._bigint,
--                                        mpz_get_ui(mpq_denref(b.v._bigrat)));
--                        if (not exact)
--                                return false;
--                }
--                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
--        }
--        res = numeric(z);
--        return true;
-+        // otherwise: a is integer
-+        return integer_rational_power_of_mpz(res, a, b);
- }
- 
-+
- // for a^b return c,d such that a^b = c*d^b
- // only for MPZ/MPQ base and MPQ exponent
- void rational_power_parts(const numeric& a_orig, const numeric& b_orig,
-diff --git a/src/sage/tests/memcheck/__init__.py b/src/sage/tests/memcheck/__init__.py
-new file mode 100644
-index 00000000000..e69de29bb2d
-diff --git a/src/sage/tests/memcheck/run_tests.py b/src/sage/tests/memcheck/run_tests.py
-new file mode 100644
-index 00000000000..6ff4503a81b
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests.py
-@@ -0,0 +1,24 @@
-+import types
-+
-+
-+def run_tests() -> None:
-+    """
-+    Run all memcheck tests
-+    """
-+    from sage.tests.memcheck import symbolic_expression
-+    run_tests_in_module(symbolic_expression)
-+
-+
-+def run_tests_in_module(mod: types.ModuleType) -> None:
-+    """
-+    Run all memcheck tests in the given module
-+    """
-+    for entry in dir(mod):
-+        if not entry.startswith('test_'):
-+            continue
-+        test_func = getattr(mod, entry)
-+        test_func()
-+
-+
-+if __name__ == '__main__':
-+    run_tests()
-diff --git a/src/sage/tests/memcheck/run_tests_in_valgrind.py b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-new file mode 100644
-index 00000000000..df5ad0e92b2
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-@@ -0,0 +1,35 @@
-+"""
-+Launch valgrind and run the memory leak tests
-+
-+
-+From the commandline, run
-+
-+    sage -python -m sage.tests.memcheck.run_tests_in_valgrind
-+
-+to launch valgrind and execute the memory leak tests. Requires valgrind
-+to be installed. Alternatively, run as a unit test:
-+
-+    sage: from sage.tests.memcheck.run_tests_in_valgrind import run_tests_in_valgrind
-+    sage: run_tests_in_valgrind()    # optional - valgrind
-+"""
-+
-+import subprocess
-+
-+
-+def run_tests_in_valgrind() -> None:
-+    """
-+    Run the sage.tests.memcheck.run_tests module inside valgrind
-+    """
-+    subprocess.check_call([
-+        'valgrind',
-+        '--suppressions=src/sage/ext_data/valgrind/valgrind-python.supp',
-+        '--show-possibly-lost=no',
-+        '--show-reachable=no',
-+        './venv/bin/python',
-+        '-m',
-+        'sage.tests.memcheck.run_tests'
-+    ])
-+
-+
-+if __name__ == '__main__':
-+    run_tests_in_valgrind()
-diff --git a/src/sage/tests/memcheck/symbolic_expression.py b/src/sage/tests/memcheck/symbolic_expression.py
-new file mode 100644
-index 00000000000..52182fbe62d
---- /dev/null
-+++ b/src/sage/tests/memcheck/symbolic_expression.py
-@@ -0,0 +1,11 @@
-+from sage.tests.memcheck.verify_no_leak import verify_no_leak
-+
-+
-+def test_sqrt_sqrt_2() -> None:
-+    from sage.misc.functional import sqrt
-+    T2 = sqrt(2)
-+
-+    def sqrt_T2() -> None:
-+        sqrt(T2)
-+
-+    verify_no_leak(sqrt_T2)
-diff --git a/src/sage/tests/memcheck/verify_no_leak.py b/src/sage/tests/memcheck/verify_no_leak.py
-new file mode 100644
-index 00000000000..89ca90cf89c
---- /dev/null
-+++ b/src/sage/tests/memcheck/verify_no_leak.py
-@@ -0,0 +1,27 @@
-+from typing import Tuple, Sequence, List, Callable, Any
-+import valgrind
-+
-+
-+def verify_no_leak(callback: Callable[[], Any],
-+                   repeat: int = 10000,
-+                   fuzzy: int = 10,
-+                   ) -> None:
-+    """
-+    Verify that the callback does not generate new definitely lost blocks
-+
-+    Raises an assertion if the callback leaks memory
-+    """
-+    callback()   # warm_up
-+    initial_blocks = (0, 0, 0, 0)
-+    valgrind.memcheck_do_leak_check()
-+    initial_blocks = valgrind.memcheck_count_leak_blocks()
-+    for _ in range(repeat):
-+        callback()
-+    valgrind.memcheck_do_leak_check()
-+    leak_blocks = valgrind.memcheck_count_leak_blocks()
-+    leak = leak_blocks[0] - initial_blocks[0]
-+    if leak < repeat - fuzzy:
-+        return  # callback did not leak at least once per call
-+    blocks = round(leak / repeat, 2)
-+    message = f'{callback} leaked {blocks} block on average ({repeat} iterations)'
-+    raise AssertionError(message)
diff --git a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch b/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
deleted file mode 100644
index 684b62affaf5a..0000000000000
--- a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx
-index 8f46570313d..a8e73e57b52 100644
---- a/src/sage/libs/ecl.pyx
-+++ b/src/sage/libs/ecl.pyx
-@@ -563,15 +563,15 @@ cdef class EclObject:
-     Floats in Python are IEEE double, which LISP has as well. However,
-     the printing of floating point types in LISP depends on settings::
- 
--        sage: a = EclObject(float(10^40))
-+        sage: a = EclObject(float(1.234e40))
-         sage: ecl_eval("(setf *read-default-float-format* 'single-float)")
-         <ECL: SINGLE-FLOAT>
-         sage: a
--        <ECL: 1.d40>
-+        <ECL: 1.234d40>
-         sage: ecl_eval("(setf *read-default-float-format* 'double-float)")
-         <ECL: DOUBLE-FLOAT>
-         sage: a
--        <ECL: 1.e40>
-+        <ECL: 1.234e40>
- 
-     Tuples are translated to dotted lists::
- 
-diff --git a/src/sage/libs/eclsig.h b/src/sage/libs/eclsig.h
-index e249ccf6874..005b2d99d0b 100644
---- a/src/sage/libs/eclsig.h
-+++ b/src/sage/libs/eclsig.h
-@@ -45,7 +45,11 @@ static inline void ecl_sig_off(void)
-     sig_off();
- }
- 
-+#if ECL_VERSION_NUMBER < 230909
- #define ecl_mpz_from_bignum(obj) ((obj)->big.big_num)
-+#else
-+#define ecl_mpz_from_bignum(obj) ecl_bignum(obj)
-+#endif
- 
- cl_object ecl_bignum_from_mpz(mpz_t num)
- {
diff --git a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch b/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
deleted file mode 100644
index e858f2fd4a445..0000000000000
--- a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
-index 59f10f6b13f..adcccff059b 100644
---- a/src/sage/plot/graphics.py
-+++ b/src/sage/plot/graphics.py
-@@ -36,6 +36,7 @@
- # ****************************************************************************
- 
- import os
-+from numbers import Integral
- from collections.abc import Iterable
- from math import isnan
- import sage.misc.verbose
-@@ -2874,6 +2875,11 @@ def matplotlib(self, filename=None,
-                 weight=lopts.pop('font_weight', 'medium'),
-                 variant=lopts.pop('font_variant', 'normal'))
-             color = lopts.pop('back_color', 'white')
-+            if 'loc' in lopts:
-+                loc = lopts['loc']
-+                if isinstance(loc, Integral):
-+                    # matplotlib 3.8 doesn't support sage integers
-+                    lopts['loc'] = int(loc)
-             leg = subplot.legend(prop=prop, **lopts)
-             if leg is None:
-                 from warnings import warn
diff --git a/srcpkgs/sagemath/patches/36403-00pre.patch b/srcpkgs/sagemath/patches/36403-00pre.patch
deleted file mode 100644
index 060404d5430de..0000000000000
--- a/srcpkgs/sagemath/patches/36403-00pre.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-Minor patch so that #36403 applies cleanly over sagemath 10.1
-
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 2053bca80c3..86aca6e00d8 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15123,7 +15302,8 @@ cdef class Matrix(Matrix1):
-             sage: N.conjugate_transpose()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object has no attribute 'conjugate'
-+            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
-+            has no attribute 'conjugate'
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 525ea5aa934..52afed49d64 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -55,7 +55,7 @@ cdef class AttributeErrorMessage:
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-         sage: x = polygen(ZZ, 'x')
--        sage: QQ[x].gen().bla                                                           # optional - sage.libs.flint
-+        sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
diff --git a/srcpkgs/sagemath/patches/36407-python_3.12.patch b/srcpkgs/sagemath/patches/36407-python_3.12.patch
deleted file mode 100644
index c75c275c30764..0000000000000
--- a/srcpkgs/sagemath/patches/36407-python_3.12.patch
+++ /dev/null
@@ -1,1744 +0,0 @@
-diff --git a/build/sage_bootstrap/package.py b/build/sage_bootstrap/package.py
-index 15b342223c4..eb82f96e05f 100644
---- a/build/sage_bootstrap/package.py
-+++ b/build/sage_bootstrap/package.py
-@@ -303,7 +303,7 @@ def _init_checksum(self):
-         # Name of the directory containing the checksums.ini file
-         self.__tarball_package_name = os.path.realpath(checksums_ini).split(os.sep)[-2]
- 
--    VERSION_PATCHLEVEL = re.compile('(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
-+    VERSION_PATCHLEVEL = re.compile(r'(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
- 
-     def _init_version(self):
-         try:
-diff --git a/src/doc/en/thematic_tutorials/coercion_and_categories.rst b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-index bb23331c151..7f5712caea7 100644
---- a/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-+++ b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-@@ -1223,7 +1223,7 @@ However, only "elementary" construction functors have a rank::
-     sage: (Fract*Poly).rank
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'
-+    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'...
- 
- .. end of output
- 
-diff --git a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-index 553a946c4d8..3cd71a9bad4 100644
---- a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-+++ b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-@@ -318,7 +318,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: e.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'...
- 
-         sage: id4 = SymmetricGroup(4).one()
-         sage: type(id4)
-@@ -326,7 +326,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: id4.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'
-+        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'...
- 
- .. note::
- 
-diff --git a/src/sage/algebras/cluster_algebra.py b/src/sage/algebras/cluster_algebra.py
-index b72d2a12976..14669dfed5c 100644
---- a/src/sage/algebras/cluster_algebra.py
-+++ b/src/sage/algebras/cluster_algebra.py
-@@ -167,7 +167,7 @@
-     sage: (t*s).g_vector()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'
-+    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'...
-     sage: A = ClusterAlgebra(['A', 2], principal_coefficients=True)
-     sage: A.explore_to_depth(infinity)
-     sage: s = A.cluster_variable((0, -1)); s
-diff --git a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-index e4a91723558..343ee8a66f9 100644
---- a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-+++ b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-@@ -109,7 +109,7 @@ class WeylLieConformalAlgebra(LieConformalAlgebraWithStructureCoefficients):
-         sage: alpha0.degree()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'
-+        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'...
- 
-     TESTS::
- 
-diff --git a/src/sage/algebras/steenrod/steenrod_algebra.py b/src/sage/algebras/steenrod/steenrod_algebra.py
-index 978a3557a9d..7c4d444f81c 100644
---- a/src/sage/algebras/steenrod/steenrod_algebra.py
-+++ b/src/sage/algebras/steenrod/steenrod_algebra.py
-@@ -1080,7 +1080,7 @@ def homogeneous_component(self, n):
-             sage: a.antipode() # not defined
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'
-+            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'...
-             sage: A(a).antipode() # convert to elt of A, then compute antipode
-             Sq(2,1) + Sq(5)
- 
-diff --git a/src/sage/all__sagemath_repl.py b/src/sage/all__sagemath_repl.py
-index 8d0b43679ca..c31b206bcb8 100644
---- a/src/sage/all__sagemath_repl.py
-+++ b/src/sage/all__sagemath_repl.py
-@@ -79,6 +79,23 @@
-                         message=r"Use setlocale\(\), getencoding\(\) and getlocale\(\) instead",
-                         module='docutils.io')
- 
-+# triggered by dateutil 2.8.2 and sphinx 7.0.1 on Python 3.12
-+# see: https://github.com/dateutil/dateutil/pull/1285
-+# see: https://github.com/sphinx-doc/sphinx/pull/11468
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"datetime.datetime.utcfromtimestamp\(\) is deprecated",
-+                        module='dateutil.tz.tz|sphinx.(builders.gettext|util.i18n)')
-+
-+# triggered on Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"This process.* is multi-threaded, "
-+                                r"use of .*\(\) may lead to deadlocks in the child.")
-+
-+# pickling of itertools is deprecated in Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"Pickle, copy, and deepcopy support will be "
-+                                r"removed from itertools in Python 3.14.")
-+
- 
- from .all__sagemath_objects import *
- from .all__sagemath_environment import *
-diff --git a/src/sage/arith/long.pxd b/src/sage/arith/long.pxd
-index 0031a0ae337..3ea70cef571 100644
---- a/src/sage/arith/long.pxd
-+++ b/src/sage/arith/long.pxd
-@@ -19,6 +19,8 @@ from libc.limits cimport LONG_MIN, LONG_MAX
- from cpython.object cimport Py_SIZE
- from cpython.number cimport PyNumber_Index, PyIndex_Check
- from cpython.longintrepr cimport py_long, PyLong_SHIFT, digit
-+from sage.cpython.pycore_long cimport (
-+    ob_digit, _PyLong_IsNegative, _PyLong_DigitCount)
- 
- from sage.libs.gmp.mpz cimport mpz_fits_slong_p, mpz_get_si
- from sage.rings.integer_fake cimport is_Integer, Integer_AS_MPZ
-@@ -299,8 +301,11 @@ cdef inline bint integer_check_long_py(x, long* value, int* err):
-         return 0
- 
-     # x is a Python "int" (aka PyLongObject or py_long in cython)
--    cdef const digit* D = (<py_long>x).ob_digit
--    cdef Py_ssize_t size = Py_SIZE(x)
-+    cdef const digit* D = ob_digit(x)
-+    cdef Py_ssize_t size = _PyLong_DigitCount(x)
-+
-+    if _PyLong_IsNegative(x):
-+        size = -size
- 
-     # We assume PyLong_SHIFT <= BITS_IN_LONG <= 3 * PyLong_SHIFT.
-     # This is true in all the default configurations:
-diff --git a/src/sage/categories/category.py b/src/sage/categories/category.py
-index 57ef7f4184b..29bce8ee415 100644
---- a/src/sage/categories/category.py
-+++ b/src/sage/categories/category.py
-@@ -2129,7 +2129,7 @@ def _with_axioms(self, axioms):
-             sage: Semigroups().Inverse()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'
-+            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'...
-             sage: Semigroups()._with_axioms(["Inverse"])
-             Category of semigroups
- 
-diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py
-index 5227792e725..4775d4e5bf1 100644
---- a/src/sage/categories/category_with_axiom.py
-+++ b/src/sage/categories/category_with_axiom.py
-@@ -554,7 +554,7 @@ class from the base category class::
-     sage: Magmas.Unital.Associative
-     Traceback (most recent call last):
-     ...
--    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'
-+    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'...
- 
- The purpose of this section is to explain the design of the code
- layout and the rationale for this mismatch.
-@@ -769,7 +769,7 @@ def _(): return LazyImport('sage.categories.rngs', 'Rngs', at_startup=True)
-     sage: Semirings().NoZeroDivisors()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'
-+    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'...
- 
- Concretely, this is to be implemented by defining the new axiom in the
- (``SubcategoryMethods`` nested class of the) appropriate category with
-diff --git a/src/sage/categories/enumerated_sets.py b/src/sage/categories/enumerated_sets.py
-index a8bea53f907..b0ea05d0563 100644
---- a/src/sage/categories/enumerated_sets.py
-+++ b/src/sage/categories/enumerated_sets.py
-@@ -610,7 +610,7 @@ def _list_from_iterator(self):
-                 sage: (QQ^2).list()  # indirect test                                    # needs sage.modules
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'
-+                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'...
- 
-             Here we test that for an object that does not know whether it
-             is finite or not.  Calling ``x.list()`` simply tries to create
-@@ -622,11 +622,11 @@ def _list_from_iterator(self):
-                 sage: Q.is_finite()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'...
-                 sage: Q.list()   # indirect test
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'...
- 
-             Here is another example. We artificially create a version of
-             the ring of integers that does not know whether it is finite
-diff --git a/src/sage/categories/examples/sets_cat.py b/src/sage/categories/examples/sets_cat.py
-index e0853d63f94..fbadb9ca405 100644
---- a/src/sage/categories/examples/sets_cat.py
-+++ b/src/sage/categories/examples/sets_cat.py
-@@ -619,7 +619,7 @@ class PrimeNumbers_Facade(PrimeNumbers_Abstract):
-         sage: pf.next()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'...
- 
-     unlike in the other implementations::
- 
-diff --git a/src/sage/categories/homset.py b/src/sage/categories/homset.py
-index 22ba9d047fc..2a8b8aeedeb 100644
---- a/src/sage/categories/homset.py
-+++ b/src/sage/categories/homset.py
-@@ -632,7 +632,7 @@ def __init__(self, X, Y, category=None, base=None, check=True):
-             sage: H = MyHomset(X, Y, category=1, base = ZZ, check = False)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'...
-             sage: P.<t> = ZZ[]
-             sage: f = P.hom([1/2*t])
-             sage: f.parent().domain()
-diff --git a/src/sage/categories/modules_with_basis.py b/src/sage/categories/modules_with_basis.py
-index e97bf851388..c4933d0657f 100644
---- a/src/sage/categories/modules_with_basis.py
-+++ b/src/sage/categories/modules_with_basis.py
-@@ -2456,7 +2456,7 @@ def apply_multilinear_morphism(self, f, codomain=None):
-                     sage: tensor([a, b]).apply_multilinear_morphism(f)                  # needs sage.modules
-                     Traceback (most recent call last):
-                     ...
--                    AttributeError: 'int' object has no attribute 'parent'
-+                    AttributeError: 'int' object has no attribute 'parent'...
- 
-                 Here we consider an example where the codomain is a
-                 module with basis with a different base ring::
-diff --git a/src/sage/categories/monoids.py b/src/sage/categories/monoids.py
-index 38dd7248c9d..28474bd17b6 100644
---- a/src/sage/categories/monoids.py
-+++ b/src/sage/categories/monoids.py
-@@ -556,7 +556,7 @@ def algebra_generators(self):
-                     Traceback (most recent call last):
-                     ...
-                     AttributeError: 'IntegerModMonoid_with_category' object
--                    has no attribute 'monoid_generators'
-+                    has no attribute 'monoid_generators'...
-                     sage: Z12.semigroup_generators()
-                     Family (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
-                     sage: Z12.algebra(QQ).algebra_generators()                          # needs sage.modules
-diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py
-index 494e8154c80..ec5120e41e6 100644
---- a/src/sage/combinat/finite_state_machine.py
-+++ b/src/sage/combinat/finite_state_machine.py
-@@ -1835,7 +1835,7 @@ def __getstate__(self):
-             sage: T1.transitions
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'FSMState' object has no attribute 'transitions'
-+            AttributeError: 'FSMState' object has no attribute 'transitions'...
-             sage: A1 = loads(dumps(A))
-             sage: all(A.state(j) == A1.state(j) for j in [0, 1])
-             True
-diff --git a/src/sage/combinat/growth.py b/src/sage/combinat/growth.py
-index cf8d18c1764..766eea37917 100644
---- a/src/sage/combinat/growth.py
-+++ b/src/sage/combinat/growth.py
-@@ -371,7 +371,7 @@
-     sage: GrowthDiagram(RulePascal(), [3,1,2])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'RulePascal' object has no attribute 'forward_rule'
-+    AttributeError: 'RulePascal' object has no attribute 'forward_rule'...
- 
- We now re-implement the rule where we provide the dual graded graphs::
- 
-diff --git a/src/sage/combinat/integer_lists/lists.py b/src/sage/combinat/integer_lists/lists.py
-index 5143e5cb5e8..9117a6076f7 100644
---- a/src/sage/combinat/integer_lists/lists.py
-+++ b/src/sage/combinat/integer_lists/lists.py
-@@ -261,7 +261,7 @@ def __getattr__(self, name):
-             sage: L.foo
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'foo'
-+            AttributeError: 'NoneType' object has no attribute 'foo'...
-         """
-         return getattr(self.backend, name)
- 
-diff --git a/src/sage/combinat/posets/posets.py b/src/sage/combinat/posets/posets.py
-index c31597c72e9..c74bfc67cee 100644
---- a/src/sage/combinat/posets/posets.py
-+++ b/src/sage/combinat/posets/posets.py
-@@ -8825,7 +8825,7 @@ def is_induced_subposet(self, other):
-             sage: Poset().is_induced_subposet('junk')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'subposet'
-+            AttributeError: 'str' object has no attribute 'subposet'...
-         """
-         if (not self._is_facade or (isinstance(other, FinitePoset) and
-                                     not other._is_facade)):
-diff --git a/src/sage/cpython/atexit.pyx b/src/sage/cpython/atexit.pyx
-index 961aa348d0a..e5a82735137 100644
---- a/src/sage/cpython/atexit.pyx
-+++ b/src/sage/cpython/atexit.pyx
-@@ -154,6 +154,10 @@ cdef extern from *:
-     #undef _PyGC_FINALIZED
-     #include "internal/pycore_interp.h"
-     #include "internal/pycore_pystate.h"
-+    #if PY_VERSION_HEX >= 0x030c0000
-+    // struct atexit_callback was renamed in 3.12 to atexit_py_callback
-+    #define atexit_callback atexit_py_callback
-+    #endif
-     static atexit_callback ** _atexit_callbacks(PyObject *self) {
-         PyInterpreterState *interp = _PyInterpreterState_GET();
-         struct atexit_state state = interp->atexit;
-diff --git a/src/sage/cpython/debug.pyx b/src/sage/cpython/debug.pyx
-index 986abff2a99..cdaca3a4854 100644
---- a/src/sage/cpython/debug.pyx
-+++ b/src/sage/cpython/debug.pyx
-@@ -78,7 +78,7 @@ def getattr_debug(obj, name, default=_no_default):
- 
-     EXAMPLES::
- 
--        sage: _ = getattr_debug(list, "reverse")
-+        sage: _ = getattr_debug(list, "reverse")  # not tested - broken in python 3.12
-         getattr_debug(obj=<class 'list'>, name='reverse'):
-           type(obj) = <class 'type'>
-           object has __dict__ slot (<class 'dict'>)
-@@ -123,7 +123,7 @@ def getattr_debug(obj, name, default=_no_default):
-         sage: _ = getattr_debug(1, "foo")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'...
-         sage: _ = getattr_debug(1, "foo", "xyz")
-         getattr_debug(obj=1, name='foo'):
-           type(obj) = <class 'sage.rings.integer.Integer'>
-diff --git a/src/sage/cpython/dict_internal.h b/src/sage/cpython/dict_internal.h
-index 42a57bcb468..a5ee35bc198 100644
---- a/src/sage/cpython/dict_internal.h
-+++ b/src/sage/cpython/dict_internal.h
-@@ -169,6 +169,7 @@ dictkeys_set_index(PyDictKeysObject *keys, Py_ssize_t i, Py_ssize_t ix)
- #else   /* Python >= 3.11 */
- 
- #define Py_BUILD_CORE
-+#undef _PyGC_FINALIZED
- #include <internal/pycore_dict.h>
- 
- /************************************************************/
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 52afed49d64..1f49e5230c3 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -53,12 +53,12 @@ cdef class AttributeErrorMessage:
-         sage: 1.bla  #indirect doctest
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'...
-         sage: x = polygen(ZZ, 'x')
-         sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'...
- 
-     ::
- 
-@@ -144,7 +144,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(X, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: x = X()
-         sage: raw_getattr(x, "prop")
-         <property object at ...>
-@@ -173,7 +173,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(Y, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: y = Y()
-         sage: raw_getattr(y, "prop")
-         <property object at ...>
-@@ -278,7 +278,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     The integer ring is a parent, so, lazy attributes work::
- 
-@@ -289,7 +289,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(17, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     In general, descriptors are not yet well supported, because they
-     often do not accept to be cheated with the type of their instance::
-@@ -305,7 +305,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__weakref__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-     This was caught by :trac:`8296` for which we do a couple more tests::
- 
-@@ -314,7 +314,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: 1.__weakref__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-         sage: n = 1
-         sage: ip = get_ipython()                 # not tested: only works in interactive shell
-@@ -329,7 +329,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__call__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'...
- 
-     TESTS:
- 
-@@ -339,14 +339,14 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, type, "__name__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'...
- 
-     Non-strings as "name" are handled gracefully::
- 
-         sage: getattr_from_other_class(1, type, None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute None
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute None...
-     """
-     if not isinstance(cls, type):
-         raise TypeError(f"{cls!r} is not a type")
-diff --git a/src/sage/cpython/pycore_long.h b/src/sage/cpython/pycore_long.h
-new file mode 100644
-index 00000000000..ff1a73d097a
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.h
-@@ -0,0 +1,98 @@
-+#include "Python.h"
-+#include <stdbool.h>
-+
-+#if PY_VERSION_HEX >= 0x030C00A5
-+#define ob_digit(o)  (((PyLongObject*)o)->long_value.ob_digit)
-+#else
-+#define ob_digit(o)  (((PyLongObject*)o)->ob_digit)
-+#endif
-+
-+#if PY_VERSION_HEX >= 0x030C00A7
-+// taken from cpython:Include/internal/pycore_long.h @ 3.12
-+
-+/* Long value tag bits:
-+ * 0-1: Sign bits value = (1-sign), ie. negative=2, positive=0, zero=1.
-+ * 2: Reserved for immortality bit
-+ * 3+ Unsigned digit count
-+ */
-+#define SIGN_MASK 3
-+#define SIGN_ZERO 1
-+#define SIGN_NEGATIVE 2
-+#define NON_SIZE_BITS 3
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_ZERO;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_NEGATIVE;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    assert(PyLong_Check(op));
-+    return op->long_value.lv_tag >> NON_SIZE_BITS;
-+}
-+
-+#define TAG_FROM_SIGN_AND_SIZE(sign, size) ((1 - (sign)) | ((size) << NON_SIZE_BITS))
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+    assert(size >= 0);
-+    assert(-1 <= sign && sign <= 1);
-+    assert(sign != 0 || size == 0);
-+    op->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sign, (size_t)size);
-+}
-+
-+#else
-+// fallback for < 3.12
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) == 0;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) < 0;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) > 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    Py_ssize_t size = Py_SIZE(op);
-+    return size < 0 ? -size : size;
-+}
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION < 9)
-+// The function Py_SET_SIZE is defined starting with python 3.9.
-+    Py_SIZE(o) = size;
-+#else
-+    Py_SET_SIZE(op, sign < 0 ? -size : size);
-+#endif
-+}
-+
-+#endif
-diff --git a/src/sage/cpython/pycore_long.pxd b/src/sage/cpython/pycore_long.pxd
-new file mode 100644
-index 00000000000..41de637ff18
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.pxd
-@@ -0,0 +1,9 @@
-+from cpython.longintrepr cimport py_long, digit
-+
-+cdef extern from "pycore_long.h":
-+    digit* ob_digit(py_long o)
-+    bint _PyLong_IsZero(py_long o)
-+    bint _PyLong_IsNegative(py_long o)
-+    bint _PyLong_IsPositive(py_long o)
-+    Py_ssize_t _PyLong_DigitCount(py_long o)
-+    void _PyLong_SetSignAndDigitCount(py_long o, int sign, Py_ssize_t size)
-diff --git a/src/sage/crypto/classical.py b/src/sage/crypto/classical.py
-index 616dc861652..be899c781e5 100644
---- a/src/sage/crypto/classical.py
-+++ b/src/sage/crypto/classical.py
-@@ -494,7 +494,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: A.rank_by_chi_square("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_chi_square(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -703,7 +703,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: A.rank_by_squared_differences("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_squared_differences(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -2114,7 +2114,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: S.rank_by_chi_square("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_chi_square(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-@@ -2351,7 +2351,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: S.rank_by_squared_differences("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_squared_differences(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/crypto/mq/mpolynomialsystemgenerator.py b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-index 9028dab1d98..4416d9ef7f6 100644
---- a/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-+++ b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-@@ -156,7 +156,7 @@ def sbox(self):
-             sage: msg.sbox()
-             Traceback (most recent call last):
-             ...
--            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'
-+            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'...
-         """
-         return self._sbox
- 
-diff --git a/src/sage/data_structures/bitset.pyx b/src/sage/data_structures/bitset.pyx
-index 446062554c1..d9906b5edd2 100644
---- a/src/sage/data_structures/bitset.pyx
-+++ b/src/sage/data_structures/bitset.pyx
-@@ -967,7 +967,7 @@ cdef class FrozenBitset:
-             sage: None | FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute '_union'
-+            AttributeError: 'NoneType' object has no attribute '_union'...
-         """
-         return self._union(other)
- 
-@@ -1037,7 +1037,7 @@ cdef class FrozenBitset:
-             sage: None & FrozenBitset("101011")
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'intersection'
-+            AttributeError: 'NoneType' object has no attribute 'intersection'...
-         """
-         return self.intersection(other)
- 
-@@ -1106,7 +1106,7 @@ cdef class FrozenBitset:
-             sage: None - FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'difference'
-+            AttributeError: 'NoneType' object has no attribute 'difference'...
-         """
-         return self.difference(other)
- 
-@@ -1179,7 +1179,7 @@ cdef class FrozenBitset:
-             sage: None ^^ FrozenBitset('11111' * 10)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'
-+            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'...
-         """
-         return self.symmetric_difference(other)
- 
-diff --git a/src/sage/doctest/reporting.py b/src/sage/doctest/reporting.py
-index 361fea344c2..a3947c07e01 100644
---- a/src/sage/doctest/reporting.py
-+++ b/src/sage/doctest/reporting.py
-@@ -368,7 +368,7 @@ def report(self, source, timeout, return_code, results, output, pid=None):
-             sage: DTR.report(None, None, None, None, None)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'basename'
-+            AttributeError: 'NoneType' object has no attribute 'basename'...
- 
-         The only-errors mode does not output anything on success::
- 
-diff --git a/src/sage/dynamics/finite_dynamical_system.py b/src/sage/dynamics/finite_dynamical_system.py
-index e5fbf568b7e..4295070615a 100644
---- a/src/sage/dynamics/finite_dynamical_system.py
-+++ b/src/sage/dynamics/finite_dynamical_system.py
-@@ -240,7 +240,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-@@ -252,7 +252,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-diff --git a/src/sage/geometry/cone.py b/src/sage/geometry/cone.py
-index f0a8620011a..53f78a4b7b6 100644
---- a/src/sage/geometry/cone.py
-+++ b/src/sage/geometry/cone.py
-@@ -340,7 +340,7 @@ def Cone(rays, lattice=None, check=True, normalize=True):
-         sage: Cone([(1,0), (0,1)], check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     You can construct different "not" cones: not full-dimensional, not
-     strictly convex, not containing any rays::
-diff --git a/src/sage/geometry/fan.py b/src/sage/geometry/fan.py
-index 258544012fe..3aecc84a55b 100644
---- a/src/sage/geometry/fan.py
-+++ b/src/sage/geometry/fan.py
-@@ -443,7 +443,7 @@ def Fan(cones, rays=None, lattice=None, check=True, normalize=True,
-         sage: P2c = Fan(cones, rays, check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     Yet another way is to use functions :func:`FaceFan` and :func:`NormalFan`
-     to construct fans from :class:`lattice polytopes
-diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-index f0ac1e774a7..f03f0f832ff 100644
---- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-+++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-@@ -351,7 +351,7 @@ cdef class FaceIterator_base(SageObject):
-             sage: FaceIterator_base(2)  # indirect doctest
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'...
-         """
-         cdef int i
-         sig_free(self.structure.atom_rep)
-@@ -1945,7 +1945,8 @@ cdef inline int next_face_loop(iter_t structure) nogil except -1:
-         # The function is not supposed to be called,
-         # just prevent it from crashing.
-         # Actually raising an error here results in a bad branch prediction.
--        return -1
-+        # But return -1 results in a crash with python 3.12
-+        raise StopIteration
- 
-     # Getting ``[faces, n_faces, n_visited_all]`` according to dimension.
-     cdef face_list_t* faces = &structure.new_faces[structure.current_dimension]
-diff --git a/src/sage/geometry/toric_plotter.py b/src/sage/geometry/toric_plotter.py
-index 50b4008eb0f..950e3ba7ff8 100644
---- a/src/sage/geometry/toric_plotter.py
-+++ b/src/sage/geometry/toric_plotter.py
-@@ -706,7 +706,7 @@ def set_rays(self, generators):
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ToricPlotter' object has no attribute 'rays'
-+            AttributeError: 'ToricPlotter' object has no attribute 'rays'...
-             sage: tp.set_rays([(0,1)])
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Graphics object consisting of 2 graphics primitives
-diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
-index d0ec214bb3b..c8098ad578a 100644
---- a/src/sage/groups/matrix_gps/finitely_generated.py
-+++ b/src/sage/groups/matrix_gps/finitely_generated.py
-@@ -268,7 +268,7 @@ def MatrixGroup(*gens, **kwds):
-         sage: SL2C.gens()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'
-+        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'...
-     """
-     if isinstance(gens[-1], dict):   # hack for unpickling
-         kwds.update(gens[-1])
-diff --git a/src/sage/homology/chains.py b/src/sage/homology/chains.py
-index 87c0947c0b0..b9a54940943 100644
---- a/src/sage/homology/chains.py
-+++ b/src/sage/homology/chains.py
-@@ -298,7 +298,7 @@ def is_cycle(self):
-                 sage: chain.is_cocycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -325,7 +325,7 @@ def is_boundary(self):
-                 sage: chain.is_coboundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -539,7 +539,7 @@ def is_cocycle(self):
-                 sage: cochain.is_cycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -566,7 +566,7 @@ def is_coboundary(self):
-                 sage: cochain.is_boundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -604,7 +604,7 @@ def eval(self, other):
-                 sage: z.eval(c) # z is not a cochain
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'...
-                 sage: c.eval(c) # can't evaluate a cochain on a cochain
-                 Traceback (most recent call last):
-                 ...
-diff --git a/src/sage/homology/free_resolution.py b/src/sage/homology/free_resolution.py
-index e3d38de4240..280a479b438 100644
---- a/src/sage/homology/free_resolution.py
-+++ b/src/sage/homology/free_resolution.py
-@@ -275,7 +275,7 @@ def differential(self, i):
-             sage: FreeResolution.differiental(r, 1)
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'FreeResolution' has no attribute 'differiental'
-+            AttributeError: type object 'FreeResolution' has no attribute 'differiental'...
-         """
- 
-     def target(self):
-diff --git a/src/sage/interfaces/magma.py b/src/sage/interfaces/magma.py
-index b7a0ac20d03..529bfbc349b 100644
---- a/src/sage/interfaces/magma.py
-+++ b/src/sage/interfaces/magma.py
-@@ -824,7 +824,7 @@ def _coerce_from_special_method(self, x):
-             sage: magma._coerce_from_special_method('2 + 3')  # optional - magma
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute '_magma_init_'
-+            AttributeError: 'str' object has no attribute '_magma_init_'...
-         """
-         s = x._magma_init_(self)
-         a = self(s)
-diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
-index 58499396d6c..16119d20815 100644
---- a/src/sage/lfunctions/dokchitser.py
-+++ b/src/sage/lfunctions/dokchitser.py
-@@ -418,8 +418,8 @@ def init_coeffs(self, v, cutoff=1,
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
-index bbf289aa21c..e4968866303 100644
---- a/src/sage/lfunctions/pari.py
-+++ b/src/sage/lfunctions/pari.py
-@@ -141,8 +141,8 @@ def init_coeffs(self, v, cutoff=None, w=1):
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
-index 478caf9f9d0..363024ae281 100644
---- a/src/sage/libs/gap/element.pyx
-+++ b/src/sage/libs/gap/element.pyx
-@@ -380,7 +380,7 @@ cdef GapElement make_GapElement(parent, Obj obj):
-         sage: libgap(None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute '_libgap_init_'
-+        AttributeError: 'NoneType' object has no attribute '_libgap_init_'...
-     """
-     cdef GapElement r = GapElement.__new__(GapElement)
-     r._initialize(parent, obj)
-diff --git a/src/sage/libs/gmp/pylong.pxd b/src/sage/libs/gmp/pylong.pxd
-index a73f1da6d6f..84e1bb8cd87 100644
---- a/src/sage/libs/gmp/pylong.pxd
-+++ b/src/sage/libs/gmp/pylong.pxd
-@@ -2,9 +2,10 @@
- Various functions to deal with conversion mpz <-> Python int/long
- """
- 
-+from cpython.longintrepr cimport py_long
- from sage.libs.gmp.types cimport *
- 
- cdef mpz_get_pylong(mpz_srcptr z)
- cdef mpz_get_pyintlong(mpz_srcptr z)
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1
- cdef Py_hash_t mpz_pythonhash(mpz_srcptr z)
-diff --git a/src/sage/libs/gmp/pylong.pyx b/src/sage/libs/gmp/pylong.pyx
-index d5993cca5a5..1a36c29d3fa 100644
---- a/src/sage/libs/gmp/pylong.pyx
-+++ b/src/sage/libs/gmp/pylong.pyx
-@@ -28,6 +28,8 @@ AUTHORS:
- from cpython.object cimport Py_SIZE
- from cpython.long cimport PyLong_FromLong
- from cpython.longintrepr cimport _PyLong_New, py_long, digit, PyLong_SHIFT
-+from sage.cpython.pycore_long cimport (ob_digit, _PyLong_IsNegative,
-+    _PyLong_DigitCount, _PyLong_SetSignAndDigitCount)
- from .mpz cimport *
- 
- cdef extern from *:
-@@ -60,12 +62,9 @@ cdef mpz_get_pylong_large(mpz_srcptr z):
-     """
-     cdef size_t nbits = mpz_sizeinbase(z, 2)
-     cdef size_t pylong_size = (nbits + PyLong_SHIFT - 1) // PyLong_SHIFT
--    L = _PyLong_New(pylong_size)
--    mpz_export(L.ob_digit, NULL,
--            -1, sizeof(digit), 0, PyLong_nails, z)
--    if mpz_sgn(z) < 0:
--        # Set correct size
--        Py_SET_SIZE(L, -pylong_size)
-+    cdef py_long L = _PyLong_New(pylong_size)
-+    mpz_export(ob_digit(L), NULL, -1, sizeof(digit), 0, PyLong_nails, z)
-+    _PyLong_SetSignAndDigitCount(L, mpz_sgn(z), pylong_size)
-     return L
- 
- 
-@@ -88,16 +87,13 @@ cdef mpz_get_pyintlong(mpz_srcptr z):
-     return mpz_get_pylong_large(z)
- 
- 
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1:
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1:
-     """
-     Convert a Python ``long`` `L` to an ``mpz``.
-     """
--    cdef Py_ssize_t pylong_size = Py_SIZE(L)
--    if pylong_size < 0:
--        pylong_size = -pylong_size
--    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails,
--            (<py_long>L).ob_digit)
--    if Py_SIZE(L) < 0:
-+    cdef Py_ssize_t pylong_size = _PyLong_DigitCount(L)
-+    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails, ob_digit(L))
-+    if _PyLong_IsNegative(L):
-         mpz_neg(z, z)
- 
- 
-diff --git a/src/sage/manifolds/calculus_method.py b/src/sage/manifolds/calculus_method.py
-index f5830c0bc45..303dde6cd13 100644
---- a/src/sage/manifolds/calculus_method.py
-+++ b/src/sage/manifolds/calculus_method.py
-@@ -257,7 +257,7 @@ def simplify(self, expression, method=None):
-             sage: cm.simplify(f)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'
-+            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'...
- 
-         In the present case, one should either transform ``f`` to a SymPy
-         object::
-diff --git a/src/sage/manifolds/differentiable/vectorfield_module.py b/src/sage/manifolds/differentiable/vectorfield_module.py
-index d954b5d4839..af4bfb0ceec 100644
---- a/src/sage/manifolds/differentiable/vectorfield_module.py
-+++ b/src/sage/manifolds/differentiable/vectorfield_module.py
-@@ -885,7 +885,7 @@ def tensor(self, *args, **kwds):
-             sage: XM.tensor(XM).tensor(XM.dual().tensor(XM.dual()))
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'
-+            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'...
- 
-         .. SEEALSO::
- 
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 86aca6e00d8..a5f6716e731 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15303,7 +15303,7 @@ cdef class Matrix(Matrix1):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
--            has no attribute 'conjugate'
-+            has no attribute 'conjugate'...
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/matrix/matrix_cyclo_dense.pyx b/src/sage/matrix/matrix_cyclo_dense.pyx
-index f54f3423ded..a49bb6240e6 100644
---- a/src/sage/matrix/matrix_cyclo_dense.pyx
-+++ b/src/sage/matrix/matrix_cyclo_dense.pyx
-@@ -847,7 +847,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense):
-             sage: A.set_mutable()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'
-+            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'...
-             sage: B = A.__copy__()
-             sage: B[0,0] = 20
-             sage: B[0,0]
-diff --git a/src/sage/matrix/matrix_gfpn_dense.pyx b/src/sage/matrix/matrix_gfpn_dense.pyx
-index 4cccf473de1..8e8e4d7336b 100644
---- a/src/sage/matrix/matrix_gfpn_dense.pyx
-+++ b/src/sage/matrix/matrix_gfpn_dense.pyx
-@@ -159,7 +159,7 @@ cdef class FieldConverter_class:
-             sage: C.field_to_fel('foo')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'to_integer'
-+            AttributeError: 'str' object has no attribute 'to_integer'...
-         """
-         return FfFromInt(x.to_integer())
- 
-diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py
-index 6aab58352be..b5e6f52349b 100644
---- a/src/sage/matrix/matrix_space.py
-+++ b/src/sage/matrix/matrix_space.py
-@@ -1619,7 +1619,7 @@ def __getitem__(self, x):
-             sage: MS[2]
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'
-+            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'...
-         """
-         if isinstance(x, (integer.Integer, int)):
-             return self.list()[x]
-diff --git a/src/sage/matroids/lean_matrix.pyx b/src/sage/matroids/lean_matrix.pyx
-index 54c68e637c0..a137cbf70e5 100644
---- a/src/sage/matroids/lean_matrix.pyx
-+++ b/src/sage/matroids/lean_matrix.pyx
-@@ -1,5 +1,4 @@
- # sage.doctest: optional - sage.rings.finite_rings
--# cython: profile=True
- """
- Lean matrices
- 
-diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx
-index 36f563aa433..318c82f2b64 100644
---- a/src/sage/matroids/linear_matroid.pyx
-+++ b/src/sage/matroids/linear_matroid.pyx
-@@ -1134,7 +1134,7 @@ cdef class LinearMatroid(BasisExchangeMatroid):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.matroids.basis_matroid.BasisMatroid' object
--            has no attribute 'base_ring'
-+            has no attribute 'base_ring'...
-             sage: from sage.matroids.advanced import *
-             sage: M4 = BinaryMatroid(Matrix(M1))
-             sage: M5 = LinearMatroid(reduced_matrix=Matrix(GF(2), [[-1, 0, 1],
-diff --git a/src/sage/misc/dev_tools.py b/src/sage/misc/dev_tools.py
-index e7bf176592c..3ece7db2894 100644
---- a/src/sage/misc/dev_tools.py
-+++ b/src/sage/misc/dev_tools.py
-@@ -171,6 +171,7 @@ def load_submodules(module=None, exclude_pattern=None):
-         load sage.geometry.polyhedron.ppl_lattice_polygon... succeeded
-     """
-     from .package_dir import walk_packages
-+    import importlib.util
- 
-     if module is None:
-         import sage
-@@ -194,8 +195,12 @@ def load_submodules(module=None, exclude_pattern=None):
-         try:
-             sys.stdout.write("load %s..." % module_name)
-             sys.stdout.flush()
--            loader = importer.find_module(module_name)
--            loader.load_module(module_name)
-+            # see
-+            # https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
-+            spec = importer.find_spec(module_name)
-+            module = importlib.util.module_from_spec(spec)
-+            sys.modules[module_name] = module
-+            spec.loader.exec_module(module)
-             sys.stdout.write(" succeeded\n")
-         except (ValueError, AttributeError, TypeError, ImportError):
-             # we might get error because of cython code that has been
-diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py
-index c922b8f6f12..03697f08b7c 100644
---- a/src/sage/misc/functional.py
-+++ b/src/sage/misc/functional.py
-@@ -86,7 +86,7 @@ def base_field(x):
-         sage: R.base_field()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'
-+        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'...
-     """
-     try:
-         return x.base_field()
-diff --git a/src/sage/misc/instancedoc.pyx b/src/sage/misc/instancedoc.pyx
-index d8e1e4ac536..44ee70f64ba 100644
---- a/src/sage/misc/instancedoc.pyx
-+++ b/src/sage/misc/instancedoc.pyx
-@@ -256,7 +256,7 @@ cdef class InstanceDocDescriptor:
-             sage: descr.__delete__(obj)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'X' object has no attribute '__doc__'
-+            AttributeError: 'X' object has no attribute '__doc__'...
- 
-             sage: descr.__delete__([])
-             Traceback (most recent call last):
-diff --git a/src/sage/misc/lazy_attribute.pyx b/src/sage/misc/lazy_attribute.pyx
-index bdbec3b3ba1..1f07870b8ec 100644
---- a/src/sage/misc/lazy_attribute.pyx
-+++ b/src/sage/misc/lazy_attribute.pyx
-@@ -441,37 +441,37 @@ class lazy_attribute(_lazy_attribute):
-             sage: B().unimplemented_A # todo: not implemented
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'super' object has no attribute 'unimplemented_A'
-+            AttributeError: 'super' object has no attribute 'unimplemented_A'...
- 
-     We now make some systematic checks::
- 
-         sage: B().unimplemented_A
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: B().unimplemented_B
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: B().unimplemented_AB
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: B().unimplemented_B_implemented_A
-         1
- 
-         sage: C().unimplemented_A()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: C().unimplemented_B()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: C().unimplemented_AB()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: C().unimplemented_B_implemented_A # todo: not implemented
-         1
-     """
-diff --git a/src/sage/misc/object_multiplexer.py b/src/sage/misc/object_multiplexer.py
-index d4e811ef16e..00fd89d6652 100644
---- a/src/sage/misc/object_multiplexer.py
-+++ b/src/sage/misc/object_multiplexer.py
-@@ -85,7 +85,7 @@ def __getattr__(self, name):
-             sage: m.__bork__
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Multiplex' has no attribute '__bork__'
-+            AttributeError: 'Multiplex' has no attribute '__bork__'...
-         """
-         if name.startswith("__"):
-             raise AttributeError("'Multiplex' has no attribute '%s'" % name)
-diff --git a/src/sage/misc/sage_input.py b/src/sage/misc/sage_input.py
-index 66e78ecccbc..00e8d96ee9e 100644
---- a/src/sage/misc/sage_input.py
-+++ b/src/sage/misc/sage_input.py
-@@ -3461,7 +3461,7 @@ def verify_same(a, b):
-         sage: verify_same(1, 1r)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_same(1r, 1)
-         Traceback (most recent call last):
-         ...
-@@ -3525,7 +3525,7 @@ def verify_si_answer(x, answer, preparse):
-         sage: verify_si_answer(1, '1', False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_si_answer(1, 'ZZ(1)', None)
-     """
-     from sage.misc.sage_eval import sage_eval
-diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py
-index f0545be7d81..811afc48755 100644
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -602,7 +602,7 @@ def visit_Num(self, node):
-             On Python 3 negative numbers are parsed first, for some reason, as
-             a UnaryOp node.
-         """
--        return node.n
-+        return node.value
- 
-     def visit_Str(self, node):
-         r"""
-@@ -624,7 +624,7 @@ def visit_Str(self, node):
-             sage: [vis(s) for s in ['"abstract"', "'syntax'", r'''r"tr\ee"''']]
-             ['abstract', 'syntax', 'tr\\ee']
-         """
--        return node.s
-+        return node.value
- 
-     def visit_List(self, node):
-         """
-diff --git a/src/sage/modules/fp_graded/steenrod/module.py b/src/sage/modules/fp_graded/steenrod/module.py
-index 18460b0e9a1..4acfa6b4002 100755
---- a/src/sage/modules/fp_graded/steenrod/module.py
-+++ b/src/sage/modules/fp_graded/steenrod/module.py
-@@ -70,7 +70,7 @@
-     sage: SteenrodFPModule(ZZ, [0])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'
-+    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'...
- 
- AUTHORS:
- 
-diff --git a/src/sage/monoids/trace_monoid.py b/src/sage/monoids/trace_monoid.py
-index 00baa4d14f8..f8176a1e1f2 100644
---- a/src/sage/monoids/trace_monoid.py
-+++ b/src/sage/monoids/trace_monoid.py
-@@ -40,7 +40,6 @@
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from collections import OrderedDict
- from itertools import repeat, chain, product
- 
- from sage.misc.cachefunc import cached_method
-@@ -633,14 +632,14 @@ def _compute_dependence_stack(self, x):
-             sage: x = b*a*d*a*c*b
-             sage: M._compute_dependence_stack(x)
-             ({a, b, c, d},
--             OrderedDict([(a, [False, False, True, True, False]),
--                          (b, [True, False, False, False, True]),
--                          (c, [True, False, False, False]),
--                          (d, [False, False, True, False])]))
-+             {a: [False, False, True, True, False],
-+              b: [True, False, False, False, True],
-+              c: [True, False, False, False],
-+              d: [False, False, True, False]})
-         """
-         independence = self._independence
-         generators_set = set(e for e, _ in x)
--        stacks = OrderedDict(sorted((g, []) for g in generators_set))
-+        stacks = dict(sorted((g, []) for g in generators_set))
-         for generator, times in reversed(list(x)):
-             stacks[generator].extend(repeat(True, times))
-             for other_gen in generators_set:
-diff --git a/src/sage/parallel/map_reduce.py b/src/sage/parallel/map_reduce.py
-index 11e0673ee91..5441943731d 100644
---- a/src/sage/parallel/map_reduce.py
-+++ b/src/sage/parallel/map_reduce.py
-@@ -1234,7 +1234,7 @@ def finish(self):
-             sage: S.print_communication_statistics()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'RESetMPExample' object has no attribute '_stats'
-+            AttributeError: 'RESetMPExample' object has no attribute '_stats'...
- 
-             sage: S.finish()
- 
-diff --git a/src/sage/plot/colors.py b/src/sage/plot/colors.py
-index 8c0db2b3c34..3281199400b 100644
---- a/src/sage/plot/colors.py
-+++ b/src/sage/plot/colors.py
-@@ -1099,7 +1099,7 @@ def __getattr__(self, name):
-             sage: cols.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ColorsDict' has no attribute or colormap punk
-+            AttributeError: 'ColorsDict' has no attribute or colormap punk...
-         """
-         try:
-             return self[name]
-@@ -1599,7 +1599,7 @@ def __getattr__(self, name):
-             sage: maps.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Colormaps' has no attribute or colormap punk
-+            AttributeError: 'Colormaps' has no attribute or colormap punk...
-             sage: maps['punk']
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/rings/asymptotic/asymptotic_ring.py b/src/sage/rings/asymptotic/asymptotic_ring.py
-index b07319382d3..994490e6616 100644
---- a/src/sage/rings/asymptotic/asymptotic_ring.py
-+++ b/src/sage/rings/asymptotic/asymptotic_ring.py
-@@ -1091,7 +1091,7 @@ def monomial_coefficient(self, monomial):
-             sage: O(n).monomial_coefficient(n)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'
-+            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'...
- 
-         The ``monomial`` must be exact::
- 
-diff --git a/src/sage/rings/asymptotic/growth_group.py b/src/sage/rings/asymptotic/growth_group.py
-index 27c14592bca..5be12537d62 100644
---- a/src/sage/rings/asymptotic/growth_group.py
-+++ b/src/sage/rings/asymptotic/growth_group.py
-@@ -1572,7 +1572,7 @@ def variable_names(self):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'GenericGrowthGroup_with_category.element_class' object
--            has no attribute 'is_one'
-+            has no attribute 'is_one'...
-         """
-         if self.is_one():
-             return tuple()
-diff --git a/src/sage/rings/ideal.py b/src/sage/rings/ideal.py
-index d36d9406f32..01c9fa3bf2d 100644
---- a/src/sage/rings/ideal.py
-+++ b/src/sage/rings/ideal.py
-@@ -1553,7 +1553,7 @@ def gcd(self, other):
-             sage: J.gcd(I)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Ideal_generic' object has no attribute 'gcd'
-+            AttributeError: 'Ideal_generic' object has no attribute 'gcd'...
- 
-         Note::
- 
-diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
-index 7fe89197011..8832d27e8ea 100644
---- a/src/sage/rings/number_field/number_field.py
-+++ b/src/sage/rings/number_field/number_field.py
-@@ -3823,7 +3823,7 @@ def primes_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
-         """
-         if degree is not None:
-             degree = ZZ(degree)
-@@ -3917,7 +3917,7 @@ def prime_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
- 
-         """
-         ids = self.primes_above(x, degree)
-@@ -5926,7 +5926,7 @@ def factor(self, n):
-             sage: L.factor(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'...
- 
-         AUTHORS:
- 
-@@ -12698,7 +12698,7 @@ def is_real_place(v):
-         sage: is_real_place(v_fin)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'
-+        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'...
- 
-     """
-     RR = sage.rings.real_mpfr.RealField(53)
-diff --git a/src/sage/rings/padics/generic_nodes.py b/src/sage/rings/padics/generic_nodes.py
-index 7047020edec..b6b514d4005 100644
---- a/src/sage/rings/padics/generic_nodes.py
-+++ b/src/sage/rings/padics/generic_nodes.py
-@@ -740,7 +740,7 @@ def _get_element_class(self, name=None):
-             sage: R._get_element_class("foobar")
-             Traceback (most recent call last):
-             ...
--            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'
-+            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'...
-         """
-         if name is None:
-             return self.Element
-diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx
-index c5a1129aecf..a5b7f937cfe 100644
---- a/src/sage/rings/polynomial/polynomial_element.pyx
-+++ b/src/sage/rings/polynomial/polynomial_element.pyx
-@@ -10793,7 +10793,7 @@ cdef class Polynomial(CommutativePolynomial):
-             sage: (y**2 + x).nth_root(2)
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... has no attribute 'nth_root'
-+            AttributeError: ... has no attribute 'nth_root'...
- 
-         TESTS::
- 
-@@ -11831,7 +11831,7 @@ cdef class Polynomial_generic_dense(Polynomial):
-             sage: int(1) // x  # check that this doesn't segfault
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'int' has no attribute 'base_ring'
-+            AttributeError: type object 'int' has no attribute 'base_ring'...
-         """
-         if have_same_parent(self, right):
-             return (<Polynomial_generic_dense>self)._floordiv_(<Polynomial_generic_dense>right)
-diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-index e372be888ee..aca4f08420f 100644
---- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
-+++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-@@ -2362,7 +2362,7 @@ def field_extension(self, names):
-             sage: F, g, h = S.field_extension('b')                                      # needs sage.rings.finite_rings
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'
-+            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'...
- 
-         Over a finite field, the corresponding field extension is not a
-         number field::
-diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx
-index 5273891a5b0..a6e999b8805 100644
---- a/src/sage/rings/ring.pyx
-+++ b/src/sage/rings/ring.pyx
-@@ -1734,7 +1734,7 @@ cdef class IntegralDomain(CommutativeRing):
-             sage: Z5.is_integrally_closed()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'
-+            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'...
-         """
-         raise NotImplementedError
- 
-diff --git a/src/sage/sat/solvers/satsolver.pyx b/src/sage/sat/solvers/satsolver.pyx
-index c2f41b18f55..1c4ac400cb6 100644
---- a/src/sage/sat/solvers/satsolver.pyx
-+++ b/src/sage/sat/solvers/satsolver.pyx
-@@ -375,10 +375,10 @@ def SAT(solver=None, *args, **kwds):
-         DIMACS Solver: 'kissat -q {input}'
-     """
-     if solver is None:
--        import pkgutil
--        if pkgutil.find_loader('pycryptosat') is not None:
-+        from importlib.util import find_spec
-+        if find_spec('pycryptosat') is not None:
-             solver = "cryptominisat"
--        elif pkgutil.find_loader('pycosat') is not None:
-+        elif find_spec('pycosat') is not None:
-             solver = "picosat"
-         else:
-             solver = "LP"
-diff --git a/src/sage/schemes/toric/morphism.py b/src/sage/schemes/toric/morphism.py
-index 1c8944b6dfc..5d64d632f97 100644
---- a/src/sage/schemes/toric/morphism.py
-+++ b/src/sage/schemes/toric/morphism.py
-@@ -246,7 +246,7 @@
-     Traceback (most recent call last):
-     ...
-     AttributeError: 'SchemeMorphism_fan_toric_variety' object
--    has no attribute 'fiber_generic'
-+    has no attribute 'fiber_generic'...
- 
- Let's use factorization mentioned above::
- 
-diff --git a/src/sage/sets/disjoint_union_enumerated_sets.py b/src/sage/sets/disjoint_union_enumerated_sets.py
-index 3dea567a779..5c5e08612f2 100644
---- a/src/sage/sets/disjoint_union_enumerated_sets.py
-+++ b/src/sage/sets/disjoint_union_enumerated_sets.py
-@@ -597,7 +597,7 @@ def Element(self):
-             sage: U.Element
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'
-+            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'...
-         """
-         if not self._facade:
-             return ElementWrapper
-diff --git a/src/sage/sets/set.py b/src/sage/sets/set.py
-index a1789c61300..112d3d8dc3b 100644
---- a/src/sage/sets/set.py
-+++ b/src/sage/sets/set.py
-@@ -163,7 +163,7 @@ def Set(X=None, category=None):
-         sage: sorted(B.list(), key=repr)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'Set_object_with_category' object has no attribute 'list'
-+        AttributeError: 'Set_object_with_category' object has no attribute 'list'...
-         sage: type(B)
-         <class 'sage.sets.set.Set_object_with_category'>
- 
-diff --git a/src/sage/structure/category_object.pyx b/src/sage/structure/category_object.pyx
-index b6a7eaecb5b..c06933494dc 100644
---- a/src/sage/structure/category_object.pyx
-+++ b/src/sage/structure/category_object.pyx
-@@ -836,7 +836,7 @@ cdef class CategoryObject(SageObject):
-             sage: Sets().example().sadfasdf
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'
-+            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'...
-         """
-         return self.getattr_from_category(name)
- 
-diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx
-index caae7e40ffc..543506e9a74 100644
---- a/src/sage/structure/element.pyx
-+++ b/src/sage/structure/element.pyx
-@@ -219,7 +219,7 @@ the parents::
-     sage: x._add_(x)
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-     sage: x + x
-     Traceback (most recent call last):
-     ...
-@@ -478,13 +478,13 @@ cdef class Element(SageObject):
-             sage: 1.blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'...
-             sage: Semigroups().example().an_element().is_idempotent
-             <bound method LeftZeroSemigroup.Element.is_idempotent of 42>
-             sage: Semigroups().example().an_element().blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'
-+            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'...
-         """
-         return self.getattr_from_category(name)
- 
-@@ -1269,7 +1269,7 @@ cdef class Element(SageObject):
-             sage: e._add_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-         """
-         try:
-             python_op = (<object>self)._add_
-@@ -1381,7 +1381,7 @@ cdef class Element(SageObject):
-             sage: e._sub_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'...
-         """
-         try:
-             python_op = (<object>self)._sub_
-@@ -1435,7 +1435,7 @@ cdef class Element(SageObject):
-             sage: e._neg_()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'...
-         """
-         try:
-             python_op = (<object>self)._neg_
-@@ -1549,7 +1549,7 @@ cdef class Element(SageObject):
-             sage: e._mul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'...
-         """
-         try:
-             python_op = (<object>self)._mul_
-@@ -1662,7 +1662,7 @@ cdef class Element(SageObject):
-             sage: e._matmul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'...
-         """
-         try:
-             python_op = (<object>self)._matmul_
-@@ -1765,7 +1765,7 @@ cdef class Element(SageObject):
-             sage: e._div_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'...
-         """
-         try:
-             python_op = (<object>self)._div_
-@@ -1865,7 +1865,7 @@ cdef class Element(SageObject):
-             sage: e._floordiv_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'...
-         """
-         try:
-             python_op = (<object>self)._floordiv_
-@@ -1965,7 +1965,7 @@ cdef class Element(SageObject):
-             sage: e._mod_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'...
-         """
-         try:
-             python_op = (<object>self)._mod_
-@@ -2092,7 +2092,7 @@ cdef class Element(SageObject):
-             sage: e._pow_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'...
-         """
-         try:
-             python_op = (<object>self)._pow_
-@@ -2122,7 +2122,7 @@ cdef class Element(SageObject):
-             sage: e._pow_int(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'...
-         """
-         try:
-             python_op = (<object>self)._pow_int
-@@ -2856,7 +2856,7 @@ cdef class RingElement(ModuleElement):
-             sage: m.is_nilpotent()                                                      # needs sage.modules
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... object has no attribute 'is_nilpotent'
-+            AttributeError: '...' object has no attribute 'is_nilpotent'...
-         """
-         if self.is_unit():
-             return False
-@@ -4671,7 +4671,7 @@ def coerce_binop(method):
-         sage: x.test_add(CC(2))
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'
-+        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'...
- 
-     TESTS:
- 
-diff --git a/src/sage/structure/sequence.py b/src/sage/structure/sequence.py
-index 0c700c1fb81..c3972532ac3 100644
---- a/src/sage/structure/sequence.py
-+++ b/src/sage/structure/sequence.py
-@@ -854,7 +854,7 @@ def __getattr__(self, name):
-             sage: S.universe()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'...
-             sage: S._Sequence__universe = 'foobar'
-             sage: S.universe()
-             'foobar'
-@@ -867,7 +867,7 @@ def __getattr__(self, name):
-             sage: hash(S)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'...
-             sage: S._Sequence__hash = int(34)
-             sage: hash(S)
-             34
-diff --git a/src/sage/symbolic/assumptions.py b/src/sage/symbolic/assumptions.py
-index 7dcb15f0d85..15f6fa07ce6 100644
---- a/src/sage/symbolic/assumptions.py
-+++ b/src/sage/symbolic/assumptions.py
-@@ -636,7 +636,7 @@ def assume(*args):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no
--        attribute 'assume'
-+        attribute 'assume'...
- 
-     Ensure that we can combine the two types of assumptions, as documented::
- 
-diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx
-index 0f251ac4e5c..66f624141b3 100644
---- a/src/sage/symbolic/expression.pyx
-+++ b/src/sage/symbolic/expression.pyx
-@@ -13712,7 +13712,7 @@ cdef get_dynamic_class_for_function(unsigned serial):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.symbolic.expression.Expression' object has no
--        attribute 'argp1'
-+        attribute 'argp1'...
-         sage: t = (e + 1).op[0]; t
-         tfunc(x)
-         sage: t
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index c4152e092e3..4bcf45e8793 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -67,6 +67,7 @@
- #include "archive.h"
- #include "tostring.h"
- #include "utils.h"
-+#include "../../cpython/pycore_long.h"
- 
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wdeprecated-register"
-@@ -706,18 +707,12 @@ static long _mpq_pythonhash(mpq_t the_rat)
- // Initialize an mpz_t from a Python long integer
- static void _mpz_set_pylong(mpz_t z, PyLongObject* l)
- {
--    Py_ssize_t pylong_size = Py_SIZE(l);
--    int sign = 1;
--
--    if (pylong_size < 0) {
--        pylong_size = -pylong_size;
--        sign = -1;
--    }
-+    Py_ssize_t pylong_size = _PyLong_DigitCount(l);
- 
-     mpz_import(z, pylong_size, -1, sizeof(digit), 0,
--               8*sizeof(digit) - PyLong_SHIFT, l->ob_digit);
-+               8*sizeof(digit) - PyLong_SHIFT, ob_digit(l));
- 
--    if (sign < 0)
-+    if (_PyLong_IsNegative(l))
-         mpz_neg(z, z);
- }
- 
-diff --git a/src/sage/symbolic/pynac_impl.pxi b/src/sage/symbolic/pynac_impl.pxi
-index 68c31dcfde7..7fd7c3b314b 100644
---- a/src/sage/symbolic/pynac_impl.pxi
-+++ b/src/sage/symbolic/pynac_impl.pxi
-@@ -619,7 +619,7 @@ def tolerant_is_symbol(a):
-         sage: None.is_symbol()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute 'is_symbol'
-+        AttributeError: 'NoneType' object has no attribute 'is_symbol'...
-     """
-     try:
-         return a.is_symbol()
diff --git a/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch b/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
new file mode 100644
index 0000000000000..1e695c2d9d106
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
@@ -0,0 +1,134 @@
+diff --git a/src/sage/quadratic_forms/quadratic_form__neighbors.py b/src/sage/quadratic_forms/quadratic_form__neighbors.py
+index fb781e20122..ec853cd52ef 100644
+--- a/src/sage/quadratic_forms/quadratic_form__neighbors.py
++++ b/src/sage/quadratic_forms/quadratic_form__neighbors.py
+@@ -74,6 +74,10 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+         sage: v = Q.find_primitive_p_divisible_vector__next(5, v); v
+         (1, 0)
+         sage: v = Q.find_primitive_p_divisible_vector__next(5, v); v
++        sage: v = Q.find_primitive_p_divisible_vector__next(2) ; v
++        (0, 1)
++        sage: v = Q.find_primitive_p_divisible_vector__next(2, v) ; v
++        (1, 0)
+         sage: Q = QuadraticForm(QQ, matrix.diagonal([1,1,1,1]))
+         sage: v = Q.find_primitive_p_divisible_vector__next(2)
+         sage: Q(v)
+@@ -83,6 +87,9 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+     n = self.dim()
+     if v is None:
+         w = vector(ZZ, [0] * (n - 1) + [1])
++        a = self(w)
++        if a in ZZ and (a % p == 0):
++            return w
+     else:
+         w = deepcopy(v)
+ 
+@@ -132,7 +139,7 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+             return w
+ 
+ 
+-def find_p_neighbor_from_vec(self, p, y):
++def find_p_neighbor_from_vec(self, p, y, return_matrix=False):
+     r"""
+     Return the `p`-neighbor of ``self`` defined by ``y``.
+ 
+@@ -147,25 +154,32 @@ def find_p_neighbor_from_vec(self, p, y):
+     - ``p`` -- a prime number
+     - ``y`` -- a vector with `q(y) \in p \ZZ`
+     - ``odd`` -- (default: ``False``) if `p=2`, return also odd neighbors
++    - ``return_matrix`` -- (boolean, default ``False``) return
++      the transformation matrix instead of the quadratic form
+ 
+     EXAMPLES::
+ 
++        sage: # needs sage.libs.pari
+         sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1,1])
+         sage: v = vector([0,2,1,1])
+-        sage: X = Q.find_p_neighbor_from_vec(3, v); X                                   # needs sage.libs.pari
++        sage: X = Q.find_p_neighbor_from_vec(3, v); X
+         Quadratic form in 4 variables over Integer Ring with coefficients:
+         [ 1 0 0 0 ]
+         [ * 1 4 4 ]
+         [ * * 5 12 ]
+         [ * * * 9 ]
++        sage: B = Q.find_p_neighbor_from_vec(3, v, return_matrix=True)
++        sage: Q(B) == X
++        True
+ 
+     Since the base ring and the domain are not yet separate,
+     for rational, half integral forms we just pretend
+     the base ring is `\ZZ`::
+ 
++        sage: # needs sage.libs.pari
+         sage: Q = QuadraticForm(QQ, matrix.diagonal([1,1,1,1]))
+         sage: v = vector([1,1,1,1])
+-        sage: Q.find_p_neighbor_from_vec(2, v)                                          # needs sage.libs.pari
++        sage: Q.find_p_neighbor_from_vec(2, v)
+         Quadratic form in 4 variables over Rational Field with coefficients:
+         [ 1/2 1 1 1 ]
+         [ * 1 1 2 ]
+@@ -227,9 +241,12 @@ def find_p_neighbor_from_vec(self, p, y):
+     # by definition this is the p-neighbor of L at y
+     # assert B.det().abs() == 1
+ 
+-    QF = self.parent()
+-    Gnew = (B*G*B.T).change_ring(R)
+-    return QF(Gnew)
++    if return_matrix:
++        return B.T
++    else:
++        QF = self.parent()
++        Gnew = (B*G*B.T).change_ring(R)
++        return QF(Gnew)
+ 
+ 
+ def neighbor_iteration(seeds, p, mass=None, max_classes=ZZ(10)**3,
+diff --git a/src/sage/quadratic_forms/ternary.pyx b/src/sage/quadratic_forms/ternary.pyx
+index 28dd9514c30..6e7c4389083 100644
+--- a/src/sage/quadratic_forms/ternary.pyx
++++ b/src/sage/quadratic_forms/ternary.pyx
+@@ -955,7 +955,26 @@ def extend(v):
+         [ 30   0  -7]
+         sage: M.det()
+         2
++
++    TESTS::
++
++        sage: M = matrix(3, extend( (0, 0, 1) ))
++        sage: M.det()
++        1
++        sage: M.column(0)
++        (0, 0, 1)
++        sage: M = matrix(3, extend( (0, 0, -2) ))
++        sage: M.det()
++        2
++        sage: M.column(0)
++        (0, 0, -2)
+     """
++    if v[0] == v[1] == 0:
++        if v[2] < 0:
++            return v[0], 0, 1,  v[1], 1, 0,  v[2], 0, 0
++        else:
++            return v[0], 1, 0,  v[1], 0, 1,  v[2], 0, 0
++
+     b1 = xgcd(v[0], v[1])
+     b2 = xgcd(b1[1], b1[2])
+     b3 = xgcd(b1[0], v[2])
+diff --git a/src/sage/quadratic_forms/ternary_qf.py b/src/sage/quadratic_forms/ternary_qf.py
+index fa4499566a9..2f3a57fa713 100644
+--- a/src/sage/quadratic_forms/ternary_qf.py
++++ b/src/sage/quadratic_forms/ternary_qf.py
+@@ -918,6 +918,13 @@ def find_p_neighbor_from_vec(self, p, v, mat=False):
+             [     0  -3/11  13/11]
+             sage: Q(M) == Q11
+             True
++
++        Test that it works with (0, 0, 1)::
++
++            sage: Q.find_p_neighbor_from_vec(3, (0,0,1))
++            Ternary quadratic form with integer coefficients:
++            [1 3 3]
++            [-2 0 -1]
+         """
+         if mat:
+             q, M = _find_p_neighbor_from_vec(self._a, self._b, self._c, self._r, self._s, self._t, p, v, mat)
diff --git a/srcpkgs/sagemath/patches/36696-fix_SSL_timeout.patch b/srcpkgs/sagemath/patches/36696-fix_SSL_timeout.patch
new file mode 100644
index 0000000000000..8693b0df5288b
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36696-fix_SSL_timeout.patch
@@ -0,0 +1,33 @@
+diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py
+index 8583d7a447d..633afd5c2e6 100644
+--- a/src/sage/doctest/control.py
++++ b/src/sage/doctest/control.py
+@@ -457,11 +457,15 @@ def __init__(self, options, args):
+                 options.hide.discard('all')
+                 from sage.features.all import all_features
+                 feature_names = {f.name for f in all_features() if not f.is_standard()}
++                from sage.doctest.external import external_software
++                feature_names.difference_update(external_software)
+                 options.hide = options.hide.union(feature_names)
+             if 'optional' in options.hide:
+                 options.hide.discard('optional')
+                 from sage.features.all import all_features
+                 feature_names = {f.name for f in all_features() if f.is_optional()}
++                from sage.doctest.external import external_software
++                feature_names.difference_update(external_software)
+                 options.hide = options.hide.union(feature_names)
+ 
+         options.disabled_optional = set()
+diff --git a/src/sage/features/internet.py b/src/sage/features/internet.py
+index f1eb000fe92..576b0136926 100644
+--- a/src/sage/features/internet.py
++++ b/src/sage/features/internet.py
+@@ -56,7 +56,7 @@ def _is_present(self):
+         try:
+             urlopen(req, timeout=1, context=default_context())
+             return FeatureTestResult(self, True)
+-        except urllib.error.URLError:
++        except (urllib.error.URLError, TimeoutError):
+             return FeatureTestResult(self, False)
+ 
+ 
diff --git a/srcpkgs/sagemath/patches/get_patches b/srcpkgs/sagemath/patches/get_patches
index 95a6963432948..c5ee28f6eb10c 100755
--- a/srcpkgs/sagemath/patches/get_patches
+++ b/srcpkgs/sagemath/patches/get_patches
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-version=10.1
+version=10.2.beta9
 
 URL_BASE_PR="https://github.com/sagemath/sage/pull/"
 URL_BASE_COMPARE="https://github.com/sagemath/sage/compare/${version}..."
@@ -20,24 +20,15 @@ get_pr() {
 # run from patches dir
 cd $(dirname "$0")
 
-# merged in 10.2.beta0
-#get_pr  36018   "singular 4.3.2p4" # included in #35934
-get_pr  36046   "fix memory leak"
-
-# merged in 10.2.beta1
-get_pr  35934   "singular 4.3.2p7"
-
-# merged in 10.2.beta2
-get_pr  36006   "gmp 6.3.0"
-
-# merged in 10.2.beta3
-get_pr  36235   "ecl 23.9.9"
-
-# merged in 10.2.beta4
-get_pr  36279   "matplotlib 3.8.0"
+# merged in 10.2.rc0
+#get_pr  36544   "networkx 3.2"
+#get_pr  36543   "cython warning"
+#get_pr  36573   "relative imports"
+#get_pr  36600   "giac 1.9.0-67"
 
 # positive review
-#get_pr  36403   "python 3.12" # included in #36407
 
 # needs review
-get_pr  36407   "python 3.12"
+get_pr  35848   "flintlib 3.0"
+get_pr  36551   "fix qf.nbs"
+get_pr  36696   "fix SSL timeout"
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index a80d8b7187ece..7bc286b1b07a3 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,14 +1,14 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=10.1
-revision=4
+version=10.2.rc3
+revision=1
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
 _bindir=/usr/lib/sagemath/$version/bin
 make_install_args="--install-scripts=$_bindir"
-hostmakedepends="m4 pkg-config python3-Cython0.29 python3-Jinja2
+hostmakedepends="m4 pkg-config python3-Cython python3-Jinja2
  python3-pkgconfig python3-setuptools"
-makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
+makedepends="boost-devel brial-devel cliquer-devel ecl eclib-devel
  ecm-devel fflas-ffpack flintlib-devel gap-devel gd-devel giac-devel glpk-devel
  gsl-devel iml-devel lcalc-devel libbraiding-devel libhomfly-devel libmpc-devel
  libpng-devel linbox-devel m4ri-devel m4rie-devel mpfi-devel
@@ -18,7 +18,7 @@ makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
 depends="eclib-devel fflas-ffpack flintlib-devel gcc-fortran gd-devel
  gfan giac gsl-devel gzip libpng-devel linbox-devel m4ri-devel maxima-ecl
  mpfr-devel nauty ntl-devel palp pari-devel pari-elldata-small pari-galdata
- pari-galpol-small pari-seadata-small pkg-config python3-Cython0.29 python3-cypari2
+ pari-galpol-small pari-seadata-small pkg-config python3-Cython python3-cypari2
  python3-cysignals python3-devel python3-fpylll python3-ipython python3-lrcalc
  python3-ipython_ipykernel python3-jupyter_ipywidgets python3-matplotlib
  python3-memory_allocator python3-networkx python3-pip python3-pkgconfig
@@ -33,7 +33,7 @@ license="GPL-2.0-or-later"
 homepage="https://www.sagemath.org/"
 changelog="https://github.com/sagemath/sage/releases"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=a658612b1b2376ddaf207cc8ed0ef458d4c2880c16e19139bedbe8baa42ad62f
+checksum=7735119d7d9c7e191ea0c308d11714ffd5d4dc98d71ecc487b2606ac43376c2d
 nocross="due to ntl (flintlib), fflas-ffpack, givaro, linbox, cysignals, sympow, maxima"
 
 post_patch() {
diff --git a/srcpkgs/sagemath/update b/srcpkgs/sagemath/update
index 68be3c5752d06..4e62503e2f8f4 100644
--- a/srcpkgs/sagemath/update
+++ b/srcpkgs/sagemath/update
@@ -1,2 +1,3 @@
 pkgname="sage"
-site="https://mirrors.mit.edu/sage/src/index.html"
+site="https://mirrors.mit.edu/sage/src/
+https://mirrors.mit.edu/sage/devel/"

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

* Re: [RC] sagemath: update to 10.2, flintlib: update to 3.0.1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (10 preceding siblings ...)
  2023-11-15  0:51 ` tornaria
@ 2023-11-15  8:05 ` dkwo
  2023-11-15  8:08 ` dkwo
                   ` (16 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: dkwo @ 2023-11-15  8:05 UTC (permalink / raw)
  To: ml

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

New comment by dkwo on void-packages repository

https://github.com/void-linux/void-packages/pull/46832#issuecomment-1811978368

Comment:
Can flint (and possibly sage) be built without ntl after this update?
i read somewhere that ntl might not be necessary anymore, and this would ease the burden of cross compiling.

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

* Re: [RC] sagemath: update to 10.2, flintlib: update to 3.0.1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (11 preceding siblings ...)
  2023-11-15  8:05 ` dkwo
@ 2023-11-15  8:08 ` dkwo
  2023-11-16  1:16 ` tornaria
                   ` (15 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: dkwo @ 2023-11-15  8:08 UTC (permalink / raw)
  To: ml

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

New comment by dkwo on void-packages repository

https://github.com/void-linux/void-packages/pull/46832#issuecomment-1811981293

Comment:
possibly eclib as well?

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

* Re: [RC] sagemath: update to 10.2, flintlib: update to 3.0.1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (12 preceding siblings ...)
  2023-11-15  8:08 ` dkwo
@ 2023-11-16  1:16 ` tornaria
  2023-11-16  1:19 ` [PR PATCH] [Updated] " tornaria
                   ` (14 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: tornaria @ 2023-11-16  1:16 UTC (permalink / raw)
  To: ml

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

New comment by tornaria on void-packages repository

https://github.com/void-linux/void-packages/pull/46832#issuecomment-1813570151

Comment:
> Can flint (and possibly sage) be built without ntl after this update? i read somewhere that ntl might not be necessary anymore, and this would ease the burden of cross compiling.

I think flintlib is already cross-compiled.

As for eclib, it lists `ntl-devel` in makedepends. Have you tried building it cross without `ntl-devel`? If it works, we can just add a build option ntl that is disabled by default in cross builds. However, I think that `eclib` actually uses `ntl` for some things.

As for sagemath, I think it has a few more nocross makedepends. The comment in the template list some; including flintlib, but I'm not sure this is a mistake. It's possible that sagemath needs a flintlib that was built with ntl.

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

* Re: [PR PATCH] [Updated] [RC] sagemath: update to 10.2, flintlib: update to 3.0.1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (13 preceding siblings ...)
  2023-11-16  1:16 ` tornaria
@ 2023-11-16  1:19 ` tornaria
  2023-11-18  4:51 ` tornaria
                   ` (13 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: tornaria @ 2023-11-16  1:19 UTC (permalink / raw)
  To: ml

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

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

https://github.com/tornaria/void-packages flintlib
https://github.com/void-linux/void-packages/pull/46832

[RC] sagemath: update to 10.2, flintlib: update to 3.0.1
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **briefly**

This is a major update. A couple of packages need rebuilding (eclib, singular).

For sagemath, we need a patch (in progress: https://github.com/sagemath/sage/pull/35848).

Since backporting patches is a pain and we are not in a hurry, I'm instead targeting 10.2.beta8. Note this already moves sagemath to cython 3.

The goal is to merge flintlib 3.0 together with sagemath 10.2 when the latter is released.

<!--
#### 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/46832.patch is attached

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

From fb73d519857e56ac2b73bf9aa23164d5eb5a7fe0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 11 Sep 2023 20:11:20 -0300
Subject: [PATCH 1/6] flintlib: update to 3.0.1.

---
 common/shlibs                                 |  3 +--
 srcpkgs/arb                                   |  1 +
 srcpkgs/arb-devel                             |  2 +-
 srcpkgs/arb/template                          | 24 -------------------
 .../patches/fix-test-t-sdiv_qrnnd.patch       | 23 ------------------
 srcpkgs/flintlib/template                     | 21 ++++++++++++----
 6 files changed, 20 insertions(+), 54 deletions(-)
 create mode 120000 srcpkgs/arb
 delete mode 100644 srcpkgs/arb/template
 delete mode 100644 srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch

diff --git a/common/shlibs b/common/shlibs
index 1a721780f8545..e43c51e9ea188 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3971,8 +3971,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.17 flintlib-2.9.0_1
-libarb.so.2 arb-2.20.0_1
+libflint.so.18 flintlib-3.0.0_1
 libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
diff --git a/srcpkgs/arb b/srcpkgs/arb
new file mode 120000
index 0000000000000..7c2633183069f
--- /dev/null
+++ b/srcpkgs/arb
@@ -0,0 +1 @@
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb-devel b/srcpkgs/arb-devel
index 456b9f00a86cd..7c2633183069f 120000
--- a/srcpkgs/arb-devel
+++ b/srcpkgs/arb-devel
@@ -1 +1 @@
-arb
\ No newline at end of file
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
deleted file mode 100644
index 84a62c7ffdba3..0000000000000
--- a/srcpkgs/arb/template
+++ /dev/null
@@ -1,24 +0,0 @@
-# Template file for 'arb'
-pkgname=arb
-version=2.23.0
-revision=1
-build_style=configure
-configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
-makedepends="flintlib-devel"
-short_desc="C library for arbitrary-precision interval arithmetic"
-maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
-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=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
-
-arb-devel_package() {
-	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"
-	short_desc+=" - development files"
-	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.a"
-		vmove "usr/lib/*.so"
-	}
-}
diff --git a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch b/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
deleted file mode 100644
index cfa109792892c..0000000000000
--- a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From fb8ddbcc06afa2a8f25637032fbb8211f6c6c122 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= <albin.ahlback@gmail.com>
-Date: Fri, 20 May 2022 14:16:38 +0200
-Subject: [PATCH] Fix bug in test code for GCC 12
-
----
- test/t-sdiv_qrnnd.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/test/t-sdiv_qrnnd.c b/test/t-sdiv_qrnnd.c
-index 2e9822e848..2676903826 100644
---- a/test/t-sdiv_qrnnd.c
-+++ b/test/t-sdiv_qrnnd.c
-@@ -33,7 +33,7 @@ int main(void)
-         {
-             d = n_randtest_not_zero(state);
-             nh = n_randtest(state);
--        } while ((FLINT_ABS(nh) >= FLINT_ABS(d)/2) || (nh == WORD_MIN));
-+        } while ((nh == WORD_MIN) || (FLINT_ABS(nh) >= FLINT_ABS(d)/2));
- 
-         nl = n_randtest(state);
- 
-
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index f7442c8052aaa..254d18c42f5b3 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,10 +1,10 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.9.0
+version=3.0.1
 revision=1
-build_style=configure
+build_style=gnu-configure
 configure_args="--prefix=/usr $(vopt_with ntl)
- $(vopt_if openblas --with-blas=${XBPS_CROSS_BASE}/usr/include/openblas)"
+ $(vopt_if openblas --with-blas-include=${XBPS_CROSS_BASE}/usr/include/openblas)"
 makedepends="mpfr-devel $(vopt_if ntl ntl-devel)
  $(vopt_if openblas openblas-devel)"
 short_desc="Fast Library for Number Theory"
@@ -13,7 +13,7 @@ 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=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
+checksum=7b311a00503a863881eb8177dbeb84322f29399f3d7d72f3b1a4c9ba1d5794b4
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
@@ -33,7 +33,20 @@ flintlib-devel_package() {
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
+		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
 		vmove "usr/lib/*.so"
 	}
 }
+
+arb_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}
+
+arb-devel_package() {
+	depends="${sourcepkg}-devel>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From d9bb1508dbb5b94fccbf05680f940c20c0af6f8d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:08:05 -0300
Subject: [PATCH 2/6] eclib: rebuild for flintlib-3.0.1

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

diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 1d4ad58f21b7b..12165ca788dd5 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
 version=20230424
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 makedepends="pari-devel ntl-devel flintlib-devel boost-devel"

From 3191ed7254d95d1925f899efcd152ca4f71187cf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:13:15 -0300
Subject: [PATCH 3/6] singular: update to 4.3.2p10.

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

diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index 036e19d470354..beb0e6d30118e 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,6 +1,6 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.2p7
+version=4.3.2p10
 revision=1
 _majver=${version%p*}
 build_style=gnu-configure
@@ -20,7 +20,7 @@ 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/${_majver//./-}/singular-${version}.tar.gz"
-checksum=aad23c30066b7fbc011138a98d60532565d76a847eec6bf2938410d93b272ca3
+checksum=28c2c9fcfee954e00dfa56eb1a7d418d5b1de67c4398d25a0f2b8f73e71552a8
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From 5de5990cb3568bee73e66348a081f7551e9416cd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 19 Jul 2023 21:04:33 -0300
Subject: [PATCH 4/6] python3-pplpy: use cython 3.

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

diff --git a/srcpkgs/python3-pplpy/template b/srcpkgs/python3-pplpy/template
index 4a9c987b2a859..d3b9aebdf2237 100644
--- a/srcpkgs/python3-pplpy/template
+++ b/srcpkgs/python3-pplpy/template
@@ -1,9 +1,9 @@
 # Template file for 'python3-pplpy'
 pkgname=python3-pplpy
 version=0.8.9
-revision=1
+revision=2
 build_style=python3-pep517
-hostmakedepends="python3-setuptools python3-wheel python3-Cython0.29
+hostmakedepends="python3-setuptools python3-wheel python3-Cython
  python3-cysignals python3-gmpy2"
 makedepends="python3-devel gmp-devel gmpxx-devel ppl-devel mpfr-devel
  libmpc-devel pari-devel"

From 27775ddc2051d83964267c2c3183d782f42705cd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Thu, 19 Oct 2023 08:52:15 -0300
Subject: [PATCH 5/6] python3-networkx: update to 3.2.1.

---
 srcpkgs/python3-networkx/template | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/python3-networkx/template b/srcpkgs/python3-networkx/template
index 186bf64f7bff9..29283d9e5a032 100644
--- a/srcpkgs/python3-networkx/template
+++ b/srcpkgs/python3-networkx/template
@@ -1,11 +1,11 @@
 # Template file for 'python3-networkx'
 pkgname=python3-networkx
-version=3.1
-revision=2
-build_style=python3-module
+version=3.2.1
+revision=1
+build_style=python3-pep517
 # failing in i686
 make_check_args="--deselect networkx/algorithms/approximation/tests/test_traveling_salesman.py::test_asadpour_tsp"
-hostmakedepends="python3-setuptools"
+hostmakedepends="python3-setuptools python3-wheel"
 depends="python3"
 checkdepends="python3-numpy python3-scipy python3-matplotlib python3-pandas
  python3-lxml python3-sympy python3-pytest-xdist"
@@ -15,7 +15,7 @@ license="BSD-3-Clause"
 homepage="https://networkx.org"
 changelog="https://github.com/networkx/networkx/raw/main/doc/release/release_${version}.rst"
 distfiles="${PYPI_SITE}/n/networkx/networkx-${version}.tar.gz"
-checksum=de346335408f84de0eada6ff9fafafff9bcda11f0a0dfaa931133debb146ab61
+checksum=9f1bb5cf3409bf324e0a722c20bdb4c20ee39bf1c30ce8ae499c8502b0b5e0c6
 
 post_install() {
 	vlicense LICENSE.txt

From f570c14a0ec7f2d6713a301ccfa9def6d60a4bbd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:50:44 -0300
Subject: [PATCH 6/6] sagemath: update to 10.2.rc3.

---
 .../sagemath/patches/35848-flintlib_3.0.patch | 1738 ++++++++++++++++
 .../patches/35934-singular_4.3.2p7.patch      |  221 ---
 .../sagemath/patches/36006-gmp_6.3.0.patch    |   38 -
 .../patches/36046-fix_memory_leak.patch       |  740 -------
 .../sagemath/patches/36235-ecl_23.9.9.patch   |   39 -
 .../patches/36279-matplotlib_3.8.0.patch      |   24 -
 srcpkgs/sagemath/patches/36403-00pre.patch    |   29 -
 .../sagemath/patches/36407-python_3.12.patch  | 1744 -----------------
 .../sagemath/patches/36551-fix_qf.nbs.patch   |  134 ++
 srcpkgs/sagemath/patches/get_patches          |   27 +-
 srcpkgs/sagemath/template                     |   12 +-
 srcpkgs/sagemath/update                       |    3 +-
 12 files changed, 1889 insertions(+), 2860 deletions(-)
 create mode 100644 srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
 delete mode 100644 srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
 delete mode 100644 srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
 delete mode 100644 srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36403-00pre.patch
 delete mode 100644 srcpkgs/sagemath/patches/36407-python_3.12.patch
 create mode 100644 srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch

diff --git a/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
new file mode 100644
index 0000000000000..c1e33e6a3c717
--- /dev/null
+++ b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
@@ -0,0 +1,1738 @@
+diff --git a/build/pkgs/antic/SPKG.rst b/build/pkgs/antic/SPKG.rst
+deleted file mode 100644
+index d6c32377957..00000000000
+--- a/build/pkgs/antic/SPKG.rst
++++ /dev/null
+@@ -1,18 +0,0 @@
+-antic: Algebraic Number Theory In C
+-===================================
+-
+-Description
+------------
+-
+-Algebraic Number Theory In C
+-
+-License
+--------
+-
+-LGPL 2.1
+-
+-Upstream Contact
+-----------------
+-
+-https://github.com/wbhart/antic
+-
+diff --git a/build/pkgs/antic/checksums.ini b/build/pkgs/antic/checksums.ini
+deleted file mode 100644
+index fc8711ecd13..00000000000
+--- a/build/pkgs/antic/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=antic-VERSION.tar.gz
+-sha1=940d8ea2c3512b9d49ee3101cf043f777764bd8f
+-md5=4e896420dd6344b53b307871efb2cbb4
+-cksum=1938565125
+-upstream_url=https://github.com/wbhart/antic/archive/refs/tags/vVERSION.tar.gz
+diff --git a/build/pkgs/antic/dependencies b/build/pkgs/antic/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/antic/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/antic/distros/arch.txt b/build/pkgs/antic/distros/arch.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/conda.txt b/build/pkgs/antic/distros/conda.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/debian.txt b/build/pkgs/antic/distros/debian.txt
+deleted file mode 100644
+index 8fdcd3e5721..00000000000
+--- a/build/pkgs/antic/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libantic-dev
+diff --git a/build/pkgs/antic/distros/fedora.txt b/build/pkgs/antic/distros/fedora.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/freebsd.txt b/build/pkgs/antic/distros/freebsd.txt
+deleted file mode 100644
+index 116ff3a26f3..00000000000
+--- a/build/pkgs/antic/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/antic
+diff --git a/build/pkgs/antic/distros/opensuse.txt b/build/pkgs/antic/distros/opensuse.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/repology.txt b/build/pkgs/antic/distros/repology.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/package-version.txt b/build/pkgs/antic/package-version.txt
+deleted file mode 100644
+index 3a4036fb450..00000000000
+--- a/build/pkgs/antic/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-0.2.5
+diff --git a/build/pkgs/antic/spkg-install.in b/build/pkgs/antic/spkg-install.in
+deleted file mode 100644
+index c57fa884a20..00000000000
+--- a/build/pkgs/antic/spkg-install.in
++++ /dev/null
+@@ -1,19 +0,0 @@
+-cd src
+-
+-# Copied from build/pkgs/flint/spkg-install.in:
+-#   Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-#   --with-ntl because otherwise FLINT's configure script uses
+-#   /usr/local, which is always wrong.
+-#   This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-#   The value $SAGE_LOCAL is always a safe choice even if the library
+-#   is coming from the system and is found using what is in
+-#   LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-flint="$SAGE_LOCAL"  || sdh_die "Error: Failed to configure antic."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/antic/type b/build/pkgs/antic/type
+deleted file mode 100644
+index 134d9bc32d5..00000000000
+--- a/build/pkgs/antic/type
++++ /dev/null
+@@ -1 +0,0 @@
+-optional
+diff --git a/build/pkgs/arb/SPKG.rst b/build/pkgs/arb/SPKG.rst
+deleted file mode 100644
+index cff49ddb95b..00000000000
+--- a/build/pkgs/arb/SPKG.rst
++++ /dev/null
+@@ -1,27 +0,0 @@
+-arb: Arbitrary-precision floating-point ball arithmetic
+-=======================================================
+-
+-Description
+------------
+-
+-Arb is a C library for arbitrary-precision floating-point ball
+-arithmetic, developed by Fredrik Johansson
+-(fredrik.johansson@gmail.com). It supports efficient high-precision
+-computation with polynomials, power series, matrices and special
+-functions over the real and complex numbers, with automatic, rigorous
+-error control.
+-
+-License
+--------
+-
+-GNU General Public License v2+
+-
+-
+-Upstream Contact
+-----------------
+-
+- - Fredrik Johansson: fredrik.johansson@gmail.com
+-
+- - https://arblib.org/
+-
+- - http://github.com/fredrik-johansson/arb/
+diff --git a/build/pkgs/arb/checksums.ini b/build/pkgs/arb/checksums.ini
+deleted file mode 100644
+index 80ef43dad5d..00000000000
+--- a/build/pkgs/arb/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=arb-VERSION.tar.gz
+-sha1=a1efe035dd3af3613dd685971a156f652b86ff63
+-md5=9b369e29f93cdf2d4f90b57a92526cce
+-cksum=64252121
+-upstream_url=https://github.com/fredrik-johansson/arb/archive/VERSION.tar.gz
+diff --git a/build/pkgs/arb/dependencies b/build/pkgs/arb/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/arb/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/arb/distros/arch.txt b/build/pkgs/arb/distros/arch.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/conda.txt b/build/pkgs/arb/distros/conda.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/debian.txt b/build/pkgs/arb/distros/debian.txt
+deleted file mode 100644
+index 9fe71110712..00000000000
+--- a/build/pkgs/arb/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libflint-arb-dev
+diff --git a/build/pkgs/arb/distros/fedora.txt b/build/pkgs/arb/distros/fedora.txt
+deleted file mode 100644
+index 76794404627..00000000000
+--- a/build/pkgs/arb/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb arb-devel
+diff --git a/build/pkgs/arb/distros/freebsd.txt b/build/pkgs/arb/distros/freebsd.txt
+deleted file mode 100644
+index 2ef8c7cec0f..00000000000
+--- a/build/pkgs/arb/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/arb
+diff --git a/build/pkgs/arb/distros/gentoo.txt b/build/pkgs/arb/distros/gentoo.txt
+deleted file mode 100644
+index 58e3d4f8008..00000000000
+--- a/build/pkgs/arb/distros/gentoo.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-sci-mathematics/arb
+diff --git a/build/pkgs/arb/distros/homebrew.txt b/build/pkgs/arb/distros/homebrew.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/homebrew.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/nix.txt b/build/pkgs/arb/distros/nix.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/nix.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/opensuse.txt b/build/pkgs/arb/distros/opensuse.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/distros/repology.txt b/build/pkgs/arb/distros/repology.txt
+deleted file mode 100644
+index 179c9d507e1..00000000000
+--- a/build/pkgs/arb/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-fp
+diff --git a/build/pkgs/arb/distros/void.txt b/build/pkgs/arb/distros/void.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/void.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/package-version.txt b/build/pkgs/arb/package-version.txt
+deleted file mode 100644
+index e9763f6bfed..00000000000
+--- a/build/pkgs/arb/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-2.23.0
+diff --git a/build/pkgs/arb/spkg-check.in b/build/pkgs/arb/spkg-check.in
+deleted file mode 100644
+index 27cd9419538..00000000000
+--- a/build/pkgs/arb/spkg-check.in
++++ /dev/null
+@@ -1,2 +0,0 @@
+-cd src
+-$MAKE check
+diff --git a/build/pkgs/arb/spkg-configure.m4 b/build/pkgs/arb/spkg-configure.m4
+deleted file mode 100644
+index ef2dd0aac4a..00000000000
+--- a/build/pkgs/arb/spkg-configure.m4
++++ /dev/null
+@@ -1,23 +0,0 @@
+-SAGE_SPKG_CONFIGURE([arb], [
+-    AC_REQUIRE([SAGE_SPKG_CONFIGURE_FLINT])
+-    SAGE_ARB_LIBRARY="arb"
+-    AC_MSG_CHECKING([installing flint? ])
+-    if test x$sage_spkg_install_flint = xyes; then
+-        AC_MSG_RESULT([yes; install arb as well])
+-        sage_spkg_install_arb=yes
+-    else
+-        AC_CHECK_HEADER(arb.h, [
+-        dnl below function added in version 2.16 of arb
+-            AC_CHECK_LIB([arb], [acb_mat_eig_simple], [],
+-              [dnl in Debian the name of dylib is different.
+-               AC_CHECK_LIB([flint-arb], [acb_mat_eig_simple],
+-                [SAGE_ARB_LIBRARY="flint-arb"], [sage_spkg_install_arb=yes])])
+-        ], [sage_spkg_install_arb=yes])
+-    fi
+-], [], [], [
+-    if test x$sage_spkg_install_arb = xyes; then
+-        AC_SUBST(SAGE_ARB_LIBRARY,["arb"])
+-    else
+-        AC_SUBST(SAGE_ARB_LIBRARY,[$SAGE_ARB_LIBRARY])
+-    fi
+-])
+diff --git a/build/pkgs/arb/spkg-install.in b/build/pkgs/arb/spkg-install.in
+deleted file mode 100644
+index 9322f04c912..00000000000
+--- a/build/pkgs/arb/spkg-install.in
++++ /dev/null
+@@ -1,17 +0,0 @@
+-cd src
+-
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-flint because otherwise ARB's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure --disable-static --prefix="$SAGE_LOCAL" \
+-        --with-gmp="$SAGE_LOCAL" \
+-        --with-mpfr="$SAGE_LOCAL" \
+-        --with-flint="$SAGE_LOCAL" || \
+-    sdh_die "Error configuring arb."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/arb/type b/build/pkgs/arb/type
+deleted file mode 100644
+index a6a7b9cd726..00000000000
+--- a/build/pkgs/arb/type
++++ /dev/null
+@@ -1 +0,0 @@
+-standard
+diff --git a/build/pkgs/e_antic/dependencies b/build/pkgs/e_antic/dependencies
+index fea1ffbda45..8e977a55c13 100644
+--- a/build/pkgs/e_antic/dependencies
++++ b/build/pkgs/e_antic/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) flint arb antic boost_cropped
++$(MP_LIBRARY) flint boost_cropped
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/SPKG.rst b/build/pkgs/flint/SPKG.rst
+index f91de70d1ff..d9dcea0903b 100644
+--- a/build/pkgs/flint/SPKG.rst
++++ b/build/pkgs/flint/SPKG.rst
+@@ -4,8 +4,8 @@ flint: Fast Library for Number Theory
+ Description
+ -----------
+ 
+-FLINT is a C library for doing number theory, maintained by William
+-Hart.
++FLINT is a C library for doing number theory, maintained by
++Fredrik Johansson.
+ 
+ Website: http://www.flintlib.org
+ 
+@@ -20,4 +20,4 @@ Upstream Contact
+ 
+ -  flint-devel Gougle Group
+    (http://groups.google.co.uk/group/flint-devel)
+--  William Hart
++-  Fredrik Johansson
+diff --git a/build/pkgs/flint/checksums.ini b/build/pkgs/flint/checksums.ini
+index 3d449d98064..2cec823bfb1 100644
+--- a/build/pkgs/flint/checksums.ini
++++ b/build/pkgs/flint/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=flint-VERSION.tar.gz
+-sha1=63d90f8242c8f8ab4011fbcfb44b86c154f43abd
+-md5=c2d3cec326438f159a530c66eb07fafe
+-cksum=4244948341
+-upstream_url=http://flintlib.org/flint-VERSION.tar.gz
++sha1=c548b1d5eb86a1805de9bef56629455b61e873f7
++md5=24551d4e475290ce6b831c78fafb5efb
++cksum=1567352998
++upstream_url=https://github.com/flintlib/flint/releases/download/vVERSION/flint-VERSION.tar.gz
+diff --git a/build/pkgs/flint/dependencies b/build/pkgs/flint/dependencies
+index 385df4faa7d..1108dc4fb21 100644
+--- a/build/pkgs/flint/dependencies
++++ b/build/pkgs/flint/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) mpfr ntl
++$(MP_LIBRARY) mpfr
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/package-version.txt b/build/pkgs/flint/package-version.txt
+index c8e38b61405..4a36342fcab 100644
+--- a/build/pkgs/flint/package-version.txt
++++ b/build/pkgs/flint/package-version.txt
+@@ -1 +1 @@
+-2.9.0
++3.0.0
+diff --git a/build/pkgs/flint/spkg-build.in b/build/pkgs/flint/spkg-build.in
+new file mode 100644
+index 00000000000..ffb822c8a97
+--- /dev/null
++++ b/build/pkgs/flint/spkg-build.in
+@@ -0,0 +1,3 @@
++cd src
++sdh_configure
++sdh_make
+diff --git a/build/pkgs/flint/spkg-configure.m4 b/build/pkgs/flint/spkg-configure.m4
+index a58108c9d6e..9576e4cc1e9 100644
+--- a/build/pkgs/flint/spkg-configure.m4
++++ b/build/pkgs/flint/spkg-configure.m4
+@@ -1,25 +1,8 @@
+ SAGE_SPKG_CONFIGURE([flint], [
+-    SAGE_SPKG_DEPCHECK([mpfr ntl], [
++    SAGE_SPKG_DEPCHECK([mpfr], [
+         AC_CHECK_HEADER(flint/flint.h, [
+-          dnl flint_parallel_binary_splitting appears in Flint 2.9.0, needed by arb 2.23
+-          AC_SEARCH_LIBS([flint_parallel_binary_splitting], [flint], [
+-            dnl check that NTL is linked in
+-            AC_SEARCH_LIBS([fmpz_poly_get_ZZX], [flint], [
+-
+-              AC_MSG_CHECKING([that GC is not enabled in Flint... ])
+-              AC_RUN_IFELSE([
+-                 AC_LANG_PROGRAM([[#include <flint/flint.h>]], [
+-                                  [#ifdef HAVE_GC]
+-                                     [return HAVE_GC;]
+-                                  [#else]
+-                                     [return 0;]
+-                                  [#endif]])],
+-                 [AC_MSG_RESULT([GC not enabled. Good.])],
+-                        [AC_MSG_RESULT([GC enabled. Incompatible with Sage.])
+-                         sage_spkg_install_flint=yes],
+-                 [AC_MSG_RESULT(["cross compiling. assuming GC is not enabled"])])
+-            ], [sage_spkg_install_flint=yes])
+-          ], [sage_spkg_install_flint=yes])
++          dnl gr_get_fexpr appears in Flint 3.0
++          AC_SEARCH_LIBS([gr_get_fexpr], [flint], [], [sage_spkg_install_flint=yes])
+         ], [sage_spkg_install_flint=yes])
+     ])
+ ], [], [], [
+diff --git a/build/pkgs/flint/spkg-install.in b/build/pkgs/flint/spkg-install.in
+index eacd7b6e491..3ea8c053669 100644
+--- a/build/pkgs/flint/spkg-install.in
++++ b/build/pkgs/flint/spkg-install.in
+@@ -1,36 +1,2 @@
+-###############################################################################
+-#
+-# FLINT Sage install script
+-#
+-###############################################################################
+-if [ "$SAGE_DEBUG" = "yes" ]; then
+-    echo "Building a debug version of FLINT."
+-    FLINT_TUNE=" $FLINT_TUNE"; export FLINT_TUNE
+-    FLINT_CONFIGURE="--enable-assert $FLINT_CONFIGURE"
+-fi
+-
+ cd src
+-
+-echo "Configuring FLINT."
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-ntl because otherwise FLINT's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-ntl="$SAGE_LOCAL" \
+-    $FLINT_CONFIGURE || sdh_die "Error: Failed to configure FLINT."
+-
+-sdh_make verbose
+-
+-echo "Deleting old FLINT files."
+-rm -f $SAGE_LOCAL/lib/libflint*
+-rm -rf $SAGE_LOCAL/include/flint
+-
+ sdh_make_install
+diff --git a/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+new file mode 100644
+index 00000000000..27a642a13b0
+--- /dev/null
++++ b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+@@ -0,0 +1,53 @@
++From fe730579476de0b2d4181a38efa7f63dff9c81d7 Mon Sep 17 00:00:00 2001
++From: Marc Mezzarobba <marc@mezzarobba.net>
++Date: Tue, 12 Sep 2023 08:23:08 +0200
++Subject: [PATCH] Make msolve build with flint3
++
++---
++ src/fglm/berlekamp_massey.c | 3 +++
++ src/fglm/data_fglm.c        | 7 +++++--
++ 2 files changed, 8 insertions(+), 2 deletions(-)
++
++diff --git a/src/fglm/berlekamp_massey.c b/src/fglm/berlekamp_massey.c
++index b0f2052..998af1c 100644
++--- a/src/fglm/berlekamp_massey.c
+++++ b/src/fglm/berlekamp_massey.c
++@@ -30,6 +30,9 @@
++ */
++ 
++ #include <stdlib.h>
+++#if __FLINT_VERSION >= 3
+++#  include <flint/nmod.h>
+++#endif
++ //#include "nmod_poly.h"
++ //#include "mpn_extras.h"
++ 
++diff --git a/src/fglm/data_fglm.c b/src/fglm/data_fglm.c
++index 0726760..0e1da6f 100644
++--- a/src/fglm/data_fglm.c
+++++ b/src/fglm/data_fglm.c
++@@ -24,6 +24,7 @@
++ #include <flint/mpn_extras.h>
++ #include <flint/nmod_poly.h>
++ #include <flint/nmod_poly_factor.h>
+++#include <flint/ulong_extras.h>
++ 
++ 
++ typedef uint32_t szmat_t;
++@@ -299,9 +300,11 @@ static inline void nmod_poly_set_prime(nmod_poly_t poly,
++   mp_limb_t ninv = n_preinvert_limb(prime);
++   poly->mod.n = prime;
++   poly->mod.ninv = ninv;
+++#if __FLINT_VERSION < 3
++   count_leading_zeros(poly->mod.norm, prime);
++-  /* poly->mod.norm = flint_clz(prime); */
++-
+++#else
+++  poly->mod.norm = flint_clz(prime);
+++#endif
++ }
++ 
++ static inline void fglm_param_set_prime(param_t *param, mp_limb_t prime){
++-- 
++2.40.1
++
+diff --git a/build/pkgs/sagelib/dependencies b/build/pkgs/sagelib/dependencies
+index 5dc2efe1d31..fa6e98df7db 100644
+--- a/build/pkgs/sagelib/dependencies
++++ b/build/pkgs/sagelib/dependencies
+@@ -1,4 +1,4 @@
+-FORCE $(SCRIPTS) arb boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
++FORCE $(SCRIPTS) boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/symengine/dependencies b/build/pkgs/symengine/dependencies
+index 1fc34963eda..7795d486018 100644
+--- a/build/pkgs/symengine/dependencies
++++ b/build/pkgs/symengine/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) arb ecm flint mpc mpfr | cmake
++$(MP_LIBRARY) ecm flint mpc mpfr | cmake
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/pkgs/sage-conf/_sage_conf/_conf.py.in b/pkgs/sage-conf/_sage_conf/_conf.py.in
+index 87b27ca05cb..895d6572d1e 100644
+--- a/pkgs/sage-conf/_sage_conf/_conf.py.in
++++ b/pkgs/sage-conf/_sage_conf/_conf.py.in
+@@ -19,8 +19,6 @@ MAXIMA_FAS = "@SAGE_MAXIMA_FAS@".replace('${prefix}', SAGE_LOCAL)
+ # Delete this line if your ECL can load Kenzo without further prodding.
+ KENZO_FAS = "@SAGE_KENZO_FAS@".replace('${prefix}', SAGE_LOCAL)
+ 
+-ARB_LIBRARY = "@SAGE_ARB_LIBRARY@"
+-
+ NTL_INCDIR = "@NTL_INCDIR@"
+ NTL_LIBDIR = "@NTL_LIBDIR@"
+ 
+diff --git a/src/sage/env.py b/src/sage/env.py
+index b1fe9a89cd1..9197fc3a703 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -223,7 +223,6 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st
+ FOURTITWO_PPI = var("FOURTITWO_PPI")
+ FOURTITWO_CIRCUITS = var("FOURTITWO_CIRCUITS")
+ FOURTITWO_GROEBNER = var("FOURTITWO_GROEBNER")
+-ARB_LIBRARY = var("ARB_LIBRARY", "arb")
+ CBLAS_PC_MODULES = var("CBLAS_PC_MODULES", "cblas:openblas:blas")
+ ECL_CONFIG = var("ECL_CONFIG", "ecl-config")
+ NTL_INCDIR = var("NTL_INCDIR")
+@@ -356,8 +355,7 @@ def cython_aliases(required_modules=None,
+         sage: cython_aliases()
+         {...}
+         sage: sorted(cython_aliases().keys())
+-        ['ARB_LIBRARY',
+-         'CBLAS_CFLAGS',
++        ['CBLAS_CFLAGS',
+          ...,
+          'ZLIB_LIBRARIES']
+         sage: cython_aliases(required_modules=('module-that-is-assumed-to-not-exist'))
+@@ -475,8 +473,6 @@ def uname_specific(name, value, alternative):
+     if "LINBOX_CFLAGS" in aliases:
+         aliases["LINBOX_CFLAGS"].append("-std=gnu++11")
+ 
+-    aliases["ARB_LIBRARY"] = ARB_LIBRARY
+-
+     # TODO: Remove Cygwin hack by installing a suitable cblas.pc
+     if os.path.exists('/usr/lib/libblas.dll.a'):
+         aliases["CBLAS_LIBS"] = ['gslcblas']
+diff --git a/src/sage/features/sagemath.py b/src/sage/features/sagemath.py
+index 7404e6d0a8e..6037d097391 100644
+--- a/src/sage/features/sagemath.py
++++ b/src/sage/features/sagemath.py
+@@ -761,7 +761,7 @@ class sage__rings__number_field(JoinFeature):
+     A :class:`~sage.features.Feature` describing the presence of :mod:`sage.rings.number_field`.
+ 
+     Number fields are implemented in Sage using a complicated mixture of various libraries,
+-    including :ref:`arb <spkg_arb>`, :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
++    including :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
+     :ref:`MPFI <spkg_mpfi>`, :ref:`NTL <spkg_ntl>`, and :ref:`PARI <spkg_pari>`.
+ 
+     EXAMPLES:
+diff --git a/src/sage/libs/arb/acb.pxd b/src/sage/libs/arb/acb.pxd
+index 5148dc43991..851488d803a 100644
+--- a/src/sage/libs/arb/acb.pxd
++++ b/src/sage/libs/arb/acb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -152,10 +152,6 @@ cdef extern from "arb_wrap.h":
+     void acb_sech(acb_t s, const acb_t z, long prec)
+     void acb_csch(acb_t c, const acb_t z, long prec)
+ 
+-    void acb_rising_ui_bs(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui_rs(acb_t z, const acb_t x, unsigned long n, unsigned long step, long prec)
+-    void acb_rising_ui_rec(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui(acb_t z, const acb_t x, unsigned long n, long prec)
+     void acb_rising(acb_t z, const acb_t x, const acb_t n, long prec)
+ 
+     void acb_gamma(acb_t y, const acb_t x, long prec)
+diff --git a/src/sage/libs/arb/acb_calc.pxd b/src/sage/libs/arb/acb_calc.pxd
+index a5dbf360b5e..67bd2ed57dc 100644
+--- a/src/sage/libs/arb/acb_calc.pxd
++++ b/src/sage/libs/arb/acb_calc.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_calc.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_elliptic.pxd b/src/sage/libs/arb/acb_elliptic.pxd
+index 176f68df00e..e3480e9f73b 100644
+--- a/src/sage/libs/arb/acb_elliptic.pxd
++++ b/src/sage/libs/arb/acb_elliptic.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_elliptic.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_hypgeom.pxd b/src/sage/libs/arb/acb_hypgeom.pxd
+index 418e766f10d..c43e5c0623b 100644
+--- a/src/sage/libs/arb/acb_hypgeom.pxd
++++ b/src/sage/libs/arb/acb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_hypgeom.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_modular.pxd b/src/sage/libs/arb/acb_modular.pxd
+index c708e9bf97d..cdc413c92da 100644
+--- a/src/sage/libs/arb/acb_modular.pxd
++++ b/src/sage/libs/arb/acb_modular.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_modular.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_poly.pxd b/src/sage/libs/arb/acb_poly.pxd
+index 69f4320055b..ae02757ffd9 100644
+--- a/src/sage/libs/arb/acb_poly.pxd
++++ b/src/sage/libs/arb/acb_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -79,24 +79,10 @@ cdef extern from "arb_wrap.h":
+     void _acb_poly_divrem(acb_ptr Q, acb_ptr R, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec)
+     bint acb_poly_divrem(acb_poly_t Q, acb_poly_t R, const acb_poly_t A, const acb_poly_t B, long prec)
+     void _acb_poly_div_root(acb_ptr Q, acb_t R, acb_srcptr A, long len, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_horner(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_horner(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_divconquer(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_divconquer(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_convolution(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_convolution(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+     void _acb_poly_taylor_shift(acb_ptr g, const acb_t c, long n, long prec)
+     void acb_poly_taylor_shift(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_compose_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_divconquer(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_divconquer(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+     void _acb_poly_compose(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+     void acb_poly_compose(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_series_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+-    void _acb_poly_compose_series_brent_kung(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_brent_kung(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_compose_series(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+     void acb_poly_compose_series(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_revert_series_lagrange(acb_ptr h, acb_srcptr f, long flen, long n, long prec)
+@@ -161,10 +147,6 @@ cdef extern from "arb_wrap.h":
+     void acb_poly_exp_series_basecase(acb_poly_t f, const acb_poly_t h, long n, long prec)
+     void _acb_poly_exp_series(acb_ptr f, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_exp_series(acb_poly_t f, const acb_poly_t h, long n, long prec)
+-    void _acb_poly_sin_cos_series_basecase(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_basecase(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+-    void _acb_poly_sin_cos_series_tangent(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_tangent(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+     void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_sin_cos_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec)
+     void _acb_poly_sin_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec)
+diff --git a/src/sage/libs/arb/arb.pxd b/src/sage/libs/arb/arb.pxd
+index c82b94de30f..acd232ab816 100644
+--- a/src/sage/libs/arb/arb.pxd
++++ b/src/sage/libs/arb/arb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -224,15 +224,8 @@ cdef extern from "arb_wrap.h":
+ 
+     void arb_lambertw(arb_t res, const arb_t x, int flags, long prec)
+ 
+-    void arb_rising_ui_bs(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui_rs(arb_t z, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising_ui_rec(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui(arb_t z, const arb_t x, unsigned long n, long prec)
+     void arb_rising(arb_t z, const arb_t x, const arb_t n, long prec)
+     void arb_rising_fmpq_ui(arb_t z, const fmpq_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_bs(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_rs(arb_t u, arb_t v, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising2_ui(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+     void arb_fac_ui(arb_t z, unsigned long n, long prec)
+     void arb_bin_ui(arb_t z, const arb_t n, unsigned long k, long prec)
+     void arb_bin_uiui(arb_t z, unsigned long n, unsigned long k, long prec)
+diff --git a/src/sage/libs/arb/arb_fmpz_poly.pxd b/src/sage/libs/arb/arb_fmpz_poly.pxd
+index 079f76e9d9e..55daa705238 100644
+--- a/src/sage/libs/arb/arb_fmpz_poly.pxd
++++ b/src/sage/libs/arb/arb_fmpz_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_fmpz_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -22,5 +22,4 @@ cdef extern from "arb_wrap.h":
+     unsigned long arb_fmpz_poly_deflation(const fmpz_poly_t poly)
+     void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long deflation)
+     void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, long prec)
+-    void arb_fmpz_poly_cos_minpoly(fmpz_poly_t res, unsigned long n)
+     void arb_fmpz_poly_gauss_period_minpoly(fmpz_poly_t res, unsigned long q, unsigned long n)
+diff --git a/src/sage/libs/arb/arb_hypgeom.pxd b/src/sage/libs/arb/arb_hypgeom.pxd
+index fb1c40ddaa8..139b987d669 100644
+--- a/src/sage/libs/arb/arb_hypgeom.pxd
++++ b/src/sage/libs/arb/arb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_hypgeom.h
+ 
+ from sage.libs.flint.types cimport fmpz_t
+diff --git a/src/sage/libs/arb/arb_wrap.h b/src/sage/libs/arb/arb_wrap.h
+index 49997075ee5..488bb376d5e 100644
+--- a/src/sage/libs/arb/arb_wrap.h
++++ b/src/sage/libs/arb/arb_wrap.h
+@@ -5,25 +5,27 @@
+  * by arb, most of which rely on flint's ulong and slong defines.
+  */
+ 
++#include <mpfr.h>
++
+ #undef ulong
+ #undef slong
+ 
+ #define ulong mp_limb_t
+ #define slong mp_limb_signed_t
+ 
+-#include <acb.h>
+-#include <acb_calc.h>
+-#include <acb_elliptic.h>
+-#include <acb_hypgeom.h>
+-#include <acb_mat.h>
+-#include <acb_modular.h>
+-#include <acb_poly.h>
+-#include <arb.h>
+-#include <arb_fmpz_poly.h>
+-#include <arb_hypgeom.h>
+-#include <arf.h>
+-#include <bernoulli.h>
+-#include <mag.h>
++#include <flint/acb.h>
++#include <flint/acb_calc.h>
++#include <flint/acb_elliptic.h>
++#include <flint/acb_hypgeom.h>
++#include <flint/acb_mat.h>
++#include <flint/acb_modular.h>
++#include <flint/acb_poly.h>
++#include <flint/arb.h>
++#include <flint/arb_fmpz_poly.h>
++#include <flint/arb_hypgeom.h>
++#include <flint/arf.h>
++#include <flint/bernoulli.h>
++#include <flint/mag.h>
+ 
+ #undef ulong
+ #undef slong
+diff --git a/src/sage/libs/arb/arf.pxd b/src/sage/libs/arb/arf.pxd
+index b8b83fefcdc..84778fe9f09 100644
+--- a/src/sage/libs/arb/arf.pxd
++++ b/src/sage/libs/arb/arf.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arf.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -30,7 +30,6 @@ cdef extern from "arb_wrap.h":
+     void arf_set_ui(arf_t y, unsigned long x)
+     void arf_set_si(arf_t y, long x)
+     void arf_set_mpfr(arf_t y, const mpfr_t x)
+-    # void arf_set_fmpr(arf_t y, const fmpr_t x)
+     void arf_set_d(arf_t y, double x)
+     void arf_swap(arf_t y, arf_t x)
+     void arf_init_set_ui(arf_t y, unsigned long x)
+@@ -46,7 +45,6 @@ cdef extern from "arb_wrap.h":
+     int arf_set_round_fmpz_2exp(arf_t y, const fmpz_t x, const fmpz_t e, long prec, arf_rnd_t rnd)
+     void arf_get_fmpz_2exp(fmpz_t m, fmpz_t e, const arf_t x)
+     double arf_get_d(const arf_t x, arf_rnd_t rnd)
+-    # void arf_get_fmpr(fmpr_t y, const arf_t x)
+     int arf_get_mpfr(mpfr_t y, const arf_t x, mpfr_rnd_t rnd)
+     void arf_get_fmpz(fmpz_t z, const arf_t x, arf_rnd_t rnd)
+     long arf_get_si(const arf_t x, arf_rnd_t rnd)
+diff --git a/src/sage/libs/arb/bernoulli.pxd b/src/sage/libs/arb/bernoulli.pxd
+index 375b2b9bbcf..ea9340f4b15 100644
+--- a/src/sage/libs/arb/bernoulli.pxd
++++ b/src/sage/libs/arb/bernoulli.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = bernoulli.h
+ 
+ from ..flint.types cimport fmpq_t, ulong
+diff --git a/src/sage/libs/arb/mag.pxd b/src/sage/libs/arb/mag.pxd
+index d5d8693ea8f..69dfb990ae0 100644
+--- a/src/sage/libs/arb/mag.pxd
++++ b/src/sage/libs/arb/mag.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = mag.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -27,13 +27,11 @@ cdef extern from "arb_wrap.h":
+     # void mag_randtest(mag_t x, flint_rand_t state, long expbits)
+     # void mag_randtest_special(mag_t x, flint_rand_t state, long expbits)
+     void mag_set_d(mag_t y, double x)
+-    # void mag_set_fmpr(mag_t y, const fmpr_t x)
+     void mag_set_ui(mag_t y, unsigned long x)
+     void mag_set_fmpz(mag_t y, const fmpz_t x)
+     void mag_set_d_2exp_fmpz(mag_t z, double x, const fmpz_t y)
+     void mag_set_fmpz_2exp_fmpz(mag_t z, const fmpz_t x, const fmpz_t y)
+     void mag_set_ui_2exp_si(mag_t z, unsigned long x, long y)
+-    # void mag_get_fmpr(fmpr_t y, const mag_t x)
+     void mag_get_fmpq(fmpq_t y, const mag_t x)
+     void mag_set_ui_lower(mag_t z, unsigned long x)
+     void mag_set_fmpz_lower(mag_t z, const fmpz_t x)
+diff --git a/src/sage/libs/flint/flint_wrap.h b/src/sage/libs/flint/flint_wrap.h
+index 266535c3835..4db72b97660 100644
+--- a/src/sage/libs/flint/flint_wrap.h
++++ b/src/sage/libs/flint/flint_wrap.h
+@@ -15,6 +15,7 @@
+  */
+ 
+ #include <gmp.h>
++#include <mpfr.h>
+ 
+ /* Save previous definition of ulong if any, as pari also uses it */
+ /* Should work on GCC, clang, MSVC */
+@@ -33,6 +34,7 @@
+ 
+ #include <flint/arith.h>
+ #include <flint/fmpq.h>
++#include <flint/fmpq_vec.h>
+ #include <flint/fmpq_mat.h>
+ #include <flint/fmpq_poly.h>
+ #include <flint/fmpz.h>
+@@ -47,6 +49,7 @@
+ #include <flint/fq.h>
+ #include <flint/fq_nmod.h>
+ #include <flint/nmod_poly.h>
++#include <flint/nmod_poly_factor.h>
+ #include <flint/nmod_vec.h>
+ #include <flint/padic.h>
+ #include <flint/padic_poly.h>
+diff --git a/src/sage/libs/flint/fmpq.pxd b/src/sage/libs/flint/fmpq.pxd
+index 5e64c82102f..0616c0a7408 100644
+--- a/src/sage/libs/flint/fmpq.pxd
++++ b/src/sage/libs/flint/fmpq.pxd
+@@ -12,6 +12,8 @@ cdef extern from "flint_wrap.h":
+     fmpz * fmpq_denref(fmpq_t)
+     void fmpq_init(fmpq_t)
+     void fmpq_clear(fmpq_t)
++    void fmpq_init_set_readonly(fmpq_t, const mpq_t)
++    void fmpq_clear_readonly(fmpq_t)
+     void fmpq_one(fmpq_t)
+     void fmpq_zero(fmpq_t)
+     bint fmpq_is_zero(fmpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pxd b/src/sage/libs/flint/fmpq_poly.pxd
+index 6050c487835..afa16e5bbdd 100644
+--- a/src/sage/libs/flint/fmpq_poly.pxd
++++ b/src/sage/libs/flint/fmpq_poly.pxd
+@@ -30,6 +30,9 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_canonicalise(fmpq_poly_t)
+     int fmpq_poly_is_canonical(const fmpq_poly_t)
+ 
++    void _fmpq_poly_set_length(fmpq_poly_t, slong)
++    void _fmpq_poly_normalise(fmpq_poly_t)
++
+     # Polynomial parameters
+     slong fmpq_poly_degree(const fmpq_poly_t)
+     ulong fmpq_poly_length(const fmpq_poly_t)
+@@ -46,10 +49,7 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_ui(fmpq_poly_t, ulong)
+     void fmpq_poly_set_fmpz(fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_set_fmpq(fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+     void fmpq_poly_set_fmpz_poly(fmpq_poly_t, const fmpz_poly_t)
+-    void fmpq_poly_set_array_mpq(fmpq_poly_t, const mpq_t *, slong)
+ 
+     void fmpq_poly_set_str(fmpq_poly_t, const char *)
+     char *fmpq_poly_get_str(const fmpq_poly_t)
+@@ -67,7 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_reverse(fmpq_poly_t, const fmpq_poly_t, slong)
+ 
+     void fmpq_poly_get_coeff_fmpq(fmpq_t, const fmpq_poly_t, slong)
+-    void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_si(slong, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_ui(ulong, const fmpq_poly_t, slong)
+ 
+@@ -75,8 +74,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_coeff_ui(fmpq_poly_t, slong, ulong)
+     void fmpq_poly_set_coeff_fmpz(fmpq_poly_t, slong, const fmpz_t)
+     void fmpq_poly_set_coeff_fmpq(fmpq_poly_t, slong, const fmpq_t)
+-    void fmpq_poly_set_coeff_mpz(fmpq_poly_t, slong, const mpz_t)
+-    void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
+ 
+     # Comparison
+     int fmpq_poly_equal(const fmpq_poly_t, const fmpq_poly_t)
+@@ -100,8 +97,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_mul_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     void fmpq_poly_scalar_div_si(fmpq_poly_t, const fmpq_poly_t, slong)
+     void fmpq_poly_scalar_div_ui(fmpq_poly_t, const fmpq_poly_t, ulong)
+@@ -109,8 +104,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_div_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_div_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_div_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Multiplication
+     void fmpq_poly_mul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -155,8 +148,6 @@ cdef extern from "flint_wrap.h":
+     # Evaluation
+     void fmpq_poly_evaluate_fmpz(fmpq_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_evaluate_fmpq(fmpq_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_evaluate_mpz(mpq_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_evaluate_mpq(mpq_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Composition
+     void fmpq_poly_compose(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -189,3 +180,11 @@ cdef extern from "flint_wrap.h":
+ # since the fmpq_poly header seems to be lacking this inline function
+ cdef inline sage_fmpq_poly_max_limbs(const fmpq_poly_t poly) noexcept:
+     return _fmpz_vec_max_limbs(fmpq_poly_numref(poly), fmpq_poly_length(poly))
++
++# functions removed from flint but still needed in sage
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
++cdef void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
++cdef void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pyx b/src/sage/libs/flint/fmpq_poly.pyx
+new file mode 100644
+index 00000000000..3b8a0cf0c51
+--- /dev/null
++++ b/src/sage/libs/flint/fmpq_poly.pyx
+@@ -0,0 +1,45 @@
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++from sage.libs.gmp.mpq cimport *
++from sage.libs.flint.fmpz cimport *
++from sage.libs.flint.fmpq cimport *
++
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t rop, const fmpq_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t rop, const fmpq_poly_t op, const mpq_t c):
++    cdef fmpq_t f
++    fmpq_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpq(rop, op, f)
++    fmpq_clear_readonly(f)
++
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t poly, slong n, const mpq_t x):
++    cdef fmpq_t t
++    fmpq_init_set_readonly(t, x)
++    fmpq_poly_set_coeff_fmpq(poly, n, t)
++    fmpq_clear_readonly(t)
++
++cdef void fmpq_poly_get_coeff_mpq(mpq_t x, const fmpq_poly_t poly, slong n):
++    cdef fmpq_t t
++    fmpq_init(t)
++    fmpq_poly_get_coeff_fmpq(t, poly, n)
++    fmpq_get_mpq(x, t)
++    fmpq_clear(t)
++
++cdef void fmpq_poly_set_mpq(fmpq_poly_t poly, const mpq_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), mpq_numref(x))
++    fmpz_set_mpz(fmpq_poly_denref(poly), mpq_denref(x))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
++
++cdef void fmpq_poly_set_mpz(fmpq_poly_t poly, const mpz_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), x)
++    fmpz_one(fmpq_poly_denref(poly))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz.pxd b/src/sage/libs/flint/fmpz.pxd
+index 01058d0f130..b97fbe1eae0 100644
+--- a/src/sage/libs/flint/fmpz.pxd
++++ b/src/sage/libs/flint/fmpz.pxd
+@@ -16,6 +16,9 @@ cdef extern from "flint_wrap.h":
+     void fmpz_init_set(fmpz_t, fmpz_t)
+     void fmpz_init_set_ui(fmpz_t, ulong)
+ 
++    void fmpz_init_set_readonly(fmpz_t, const mpz_t)
++    void fmpz_clear_readonly(fmpz_t)
++
+     # Conversion
+     void fmpz_set(fmpz_t f, fmpz_t g)
+     void fmpz_set_ui(fmpz_t, ulong)
+diff --git a/src/sage/libs/flint/fmpz_mod_poly.pxd b/src/sage/libs/flint/fmpz_mod_poly.pxd
+index 24b653eb3b7..2727246da98 100644
+--- a/src/sage/libs/flint/fmpz_mod_poly.pxd
++++ b/src/sage/libs/flint/fmpz_mod_poly.pxd
+@@ -67,13 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_get_coeff_fmpz(fmpz_t x, const fmpz_mod_poly_t poly,
+                                              slong n, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_set_coeff_mpz(fmpz_mod_poly_t poly,
+-                             slong n, const mpz_t x, const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_get_coeff_mpz(mpz_t x,
+-                 const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx)
+-
+-
+     void _fmpz_mod_poly_shift_left(fmpz * res, const fmpz * poly,
+                                                            slong len, slong n)
+ 
+@@ -194,14 +187,6 @@ cdef extern from "flint_wrap.h":
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_div_basecase(fmpz_mod_poly_t Q,
+-                            const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_div_newton_n_preinv(fmpz_mod_poly_t Q,
+-                         const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                         const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem_newton_n_preinv(fmpz_mod_poly_t Q,
+           fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                          const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+@@ -213,10 +198,6 @@ cdef extern from "flint_wrap.h":
+                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_divrem_divconquer(fmpz_mod_poly_t Q,
+-        fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem(fmpz_mod_poly_t Q, fmpz_mod_poly_t R,
+     const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+@@ -254,40 +235,13 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_make_monic_f(fmpz_t f, fmpz_mod_poly_t res,
+                          const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_euclidean(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_gcd_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_hgcd(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-
+     void fmpz_mod_poly_gcd(fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+ 
+-    void fmpz_mod_poly_xgcd_euclidean(fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_hgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S,
+-          fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_xgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                       const fmpz_mod_ctx_t ctx)
+@@ -361,14 +315,6 @@ cdef extern from "flint_wrap.h":
+                         const fmpz_mod_poly_t poly, const fmpz * xs, slong n,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_compose_horner(fmpz_mod_poly_t res,
+-                    const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_compose_divconquer(fmpz_mod_poly_t res,
+-                     const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_compose(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1,
+                          const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx)
+ 
+diff --git a/src/sage/libs/flint/fmpz_poly.pxd b/src/sage/libs/flint/fmpz_poly.pxd
+index 18b36672d30..c8bc6d3ca0a 100644
+--- a/src/sage/libs/flint/fmpz_poly.pxd
++++ b/src/sage/libs/flint/fmpz_poly.pxd
+@@ -28,7 +28,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_poly_set_ui(fmpz_poly_t, ulong)
+     void fmpz_poly_set_si(fmpz_poly_t, slong)
+     void fmpz_poly_set_fmpz(fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+     int fmpz_poly_set_str(fmpz_poly_t, const char *)
+ 
+     char *fmpz_poly_get_str(const fmpz_poly_t)
+@@ -70,7 +69,6 @@ cdef extern from "flint_wrap.h":
+     # Scalar multiplication and division
+     void fmpz_poly_scalar_mul_fmpz(
+             fmpz_poly_t, const fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+     void fmpz_poly_scalar_mul_si(fmpz_poly_t, const fmpz_poly_t, slong)
+     void fmpz_poly_scalar_mul_ui(fmpz_poly_t, const fmpz_poly_t, ulong)
+     void fmpz_poly_scalar_mul_2exp(fmpz_poly_t, const fmpz_poly_t, ulong)
+@@ -310,12 +308,14 @@ cdef extern from "flint_wrap.h":
+             fmpz_poly_t,
+                     const fmpz_poly_t, const fmpz_t, const nmod_poly_t, int)
+ 
+-    # Some functions for backwards compatibility
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
+-    void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++
++# functions removed from flint but still needed in sage
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
++cdef void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++cdef void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+ 
+ 
+ # Wrapper Cython class
+diff --git a/src/sage/libs/flint/fmpz_poly.pyx b/src/sage/libs/flint/fmpz_poly.pyx
+index 74915b37612..cfcbea9090c 100644
+--- a/src/sage/libs/flint/fmpz_poly.pyx
++++ b/src/sage/libs/flint/fmpz_poly.pyx
+@@ -25,10 +25,10 @@ from cysignals.memory cimport sig_free
+ 
+ from sage.arith.long cimport pyobject_to_long
+ from sage.cpython.string cimport char_to_str, str_to_bytes
++from sage.libs.flint.fmpz cimport *
+ from sage.structure.sage_object cimport SageObject
+ from sage.rings.integer cimport Integer
+ 
+-
+ cdef class Fmpz_poly(SageObject):
+ 
+     def __cinit__(self):
+@@ -455,3 +455,44 @@ cdef class Fmpz_poly(SageObject):
+         """
+         from sage.rings.integer_ring import ZZ
+         return ZZ[var](self.list())
++
++
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_divexact_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_fdiv_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t poly, slong n, const mpz_t x):
++    cdef fmpz_t t
++    fmpz_init_set_readonly(t, x)
++    fmpz_poly_set_coeff_fmpz(poly, n, t)
++    fmpz_clear_readonly(t)
++
++cdef void fmpz_poly_get_coeff_mpz(mpz_t x, const fmpz_poly_t poly, slong n):
++    cdef fmpz_t t
++    fmpz_init(t)
++    fmpz_poly_get_coeff_fmpz(t, poly, n)
++    fmpz_get_mpz(x, t)
++    fmpz_clear(t)
++
++cdef void fmpz_poly_set_mpz(fmpz_poly_t poly, const mpz_t x):
++    fmpz_poly_fit_length(poly, 1)
++    fmpz_set_mpz(poly.coeffs, x)
++    _fmpz_poly_set_length(poly, 1)
++    _fmpz_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz_poly_q.pxd b/src/sage/libs/flint/fmpz_poly_q.pxd
+index 846542dc0d8..63c13355bf6 100644
+--- a/src/sage/libs/flint/fmpz_poly_q.pxd
++++ b/src/sage/libs/flint/fmpz_poly_q.pxd
+@@ -49,11 +49,7 @@ cdef extern from "flint_wrap.h":
+ 
+     #* Scalar multiplication and division ****************************************/
+     void fmpz_poly_q_scalar_mul_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_mul_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_mul_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+     void fmpz_poly_q_scalar_div_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_div_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_div_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+ 
+     #* Multiplication and division ***********************************************/
+     void fmpz_poly_q_mul(fmpz_poly_q_t rop, 
+@@ -67,9 +63,6 @@ cdef extern from "flint_wrap.h":
+     #* Derivative ****************************************************************/
+     void fmpz_poly_q_derivative(fmpz_poly_q_t rop, const fmpz_poly_q_t op)
+ 
+-    #* Evaluation ****************************************************************/
+-    int fmpz_poly_q_evaluate(mpq_t rop, const fmpz_poly_q_t f, const mpq_t a)
+-
+     #* Input and output **********************************************************/
+     int fmpz_poly_q_set_str(fmpz_poly_q_t rop, const char *s)
+     char * fmpz_poly_q_get_str(const fmpz_poly_q_t op)
+diff --git a/src/sage/libs/linbox/linbox_flint_interface.pyx b/src/sage/libs/linbox/linbox_flint_interface.pyx
+index dabd375c2b8..3ca65afc514 100644
+--- a/src/sage/libs/linbox/linbox_flint_interface.pyx
++++ b/src/sage/libs/linbox/linbox_flint_interface.pyx
+@@ -33,6 +33,7 @@ and C. Pernet. The functions available are:
+ #                  https://www.gnu.org/licenses/
+ # ****************************************************************************
+ 
++from sage.libs.gmp.types cimport mpz_t
+ from sage.libs.flint.types cimport fmpz_t
+ from sage.libs.flint.fmpz cimport fmpz_get_mpz, fmpz_set_mpz
+ from sage.libs.flint.fmpz_mat cimport fmpz_mat_entry, fmpz_mat_nrows, fmpz_mat_ncols
+@@ -80,11 +81,13 @@ cdef void fmpz_poly_set_linbox(fmpz_poly_t p, PolynomialRing_integer.Element& q)
+     (the .pxd file) in order to keep the header C-compatible
+     """
+     cdef size_t i
++    cdef mpz_t tmp
+ 
+     fmpz_poly_fit_length(p, q.size())
+ 
+     for i in range(q.size()):
+-        fmpz_poly_set_coeff_mpz(p, i, q[i].get_mpz_const())
++        tmp = q[i].get_mpz_const()
++        fmpz_poly_set_coeff_mpz(p, i, tmp)
+ 
+     _fmpz_poly_set_length(p, q.size())
+ 
+diff --git a/src/sage/matrix/matrix_complex_ball_dense.pyx b/src/sage/matrix/matrix_complex_ball_dense.pyx
+index 22366b5f1f2..7fdf3f2aa36 100644
+--- a/src/sage/matrix/matrix_complex_ball_dense.pyx
++++ b/src/sage/matrix/matrix_complex_ball_dense.pyx
+@@ -1,4 +1,4 @@
+-# distutils: libraries = ARB_LIBRARY
++# distutils: libraries = flint
+ r"""
+ Arbitrary precision complex ball matrices using Arb
+ 
+diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx
+index 0712500e67d..daba89d5c43 100644
+--- a/src/sage/matrix/matrix_integer_sparse.pyx
++++ b/src/sage/matrix/matrix_integer_sparse.pyx
+@@ -847,6 +847,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+             sage: matrix(ZZ, 1, 1, sparse=True)._charpoly_linbox()
+             x
+         """
++        cdef mpz_t tmp
+         if self._nrows != self._ncols:
+             raise ArithmeticError('only valid for square matrix')
+ 
+@@ -869,7 +870,8 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         cdef size_t i
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+@@ -966,9 +968,11 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         sig_off()
+ 
+         cdef size_t i
++        cdef mpz_t tmp
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
+index f36a89bb229..20a06f7eaa3 100644
+--- a/src/sage/rings/complex_arb.pyx
++++ b/src/sage/rings/complex_arb.pyx
+@@ -1360,12 +1360,13 @@ cdef class ComplexBall(RingElement):
+             sage: CBF100(-3r)
+             -3.000000000000000000000000000000
+ 
+-            sage: ComplexBall(CBF100, 10^100)
+-            1.000000000000000000000000000000e+100
+             sage: ComplexBall(CBF100, CIF(1, 2))
+             1.000000000000000000000000000000 + 2.000000000000000000000000000000*I
+             sage: ComplexBall(CBF100, RBF(1/3), RBF(1))
+             [0.3333333333333333 +/- ...e-17] + 1.000000000000000000000000000000*I
++            sage: ComplexBall(CBF100, 10^100)
++            [1.000000000000000000000000000000e+100 +/- ...]
++
+             sage: NF.<a> = QuadraticField(-1, embedding=CC(0, -1))
+             sage: CBF(a)
+             -1.000000000000000*I
+@@ -3009,7 +3010,7 @@ cdef class ComplexBall(RingElement):
+             sage: CBF(1).rising_factorial(2**64)
+             [+/- ...e+347382171326740403407]
+             sage: ComplexBallField(128)(1).rising_factorial(2**64)
+-            [2.343691126796861348e+347382171305201285713 +/- ...e+347382171305201285694]
++            [2.34369112679686134...e+347382171305201285713 +/- ...]
+             sage: CBF(1/2).rising_factorial(CBF(2,3)) # abs tol 1e-15
+             [-0.123060451458124 +/- 3.06e-16] + [0.0406412631676552 +/- 7.57e-17]*I
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+index f651c9f3512..c68246d2142 100644
+--- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+@@ -222,7 +222,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef unsigned long n
+         cdef Rational c
+         cdef list L1
+-        cdef mpq_t * L2
++        cdef fmpq_t q
+ 
+         Polynomial.__init__(self, parent, is_gen=is_gen)
+ 
+@@ -253,14 +253,11 @@ cdef class Polynomial_rational_flint(Polynomial):
+             L1 = [e if isinstance(e, Rational) else Rational(e) for e in x]
+             n  = <unsigned long> len(x)
+             sig_on()
+-            L2 = <mpq_t *> check_allocarray(n, sizeof(mpq_t))
++            fmpq_poly_fit_length(self._poly, n)
+             for deg from 0 <= deg < n:
+-                mpq_init(L2[deg])
+-                mpq_set(L2[deg], (<Rational> L1[deg]).value)
+-            fmpq_poly_set_array_mpq(self._poly, L2, n)
+-            for deg from 0 <= deg < n:
+-                mpq_clear(L2[deg])
+-            sig_free(L2)
++                fmpq_init_set_readonly(q, (<Rational> L1[deg]).value)
++                fmpq_poly_set_coeff_fmpq(self._poly, deg, q)
++                fmpq_clear_readonly(q)
+             sig_off()
+ 
+ #           deg = 0
+@@ -435,6 +432,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         utmost care.
+         """
+         cdef bint do_sig = _do_sig(self._poly)
++        cdef fmpz_t tmpfz
+ 
+         if isinstance(value, int):
+             if do_sig: sig_str("FLINT exception")
+@@ -442,7 +440,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+             if do_sig: sig_off()
+         elif isinstance(value, Integer):
+             if do_sig: sig_str("FLINT exception")
+-            fmpq_poly_set_coeff_mpz(self._poly, n, (<Integer> value).value)
++            fmpz_init_set_readonly(tmpfz, (<Integer> value).value)
++            fmpq_poly_set_coeff_fmpz(self._poly, n, tmpfz)
++            fmpz_clear_readonly(tmpfz)
+             if do_sig: sig_off()
+         elif isinstance(value, Rational):
+             if do_sig: sig_str("FLINT exception")
+@@ -492,7 +492,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef Polynomial_rational_flint f
+         cdef Rational r
+         cdef fmpz_t tmpfz
+-        cdef fmpq_t tmpfq
++        cdef fmpq_t tmpfq, tmpfq1
+         cdef RealBall arb_a, arb_z
+         cdef ComplexBall acb_a, acb_z
+ 
+@@ -508,13 +508,23 @@ cdef class Polynomial_rational_flint(Polynomial):
+             elif isinstance(a, Rational):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpq(r.value, self._poly, (<Rational> a).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> a).value)
++                fmpq_init(tmpfq1)
++                fmpq_poly_evaluate_fmpq(tmpfq1, self._poly, tmpfq)
++                fmpq_get_mpq(r.value, tmpfq1)
++                fmpq_clear(tmpfq1)
++                fmpq_clear_readonly(tmpfq)
+                 sig_off()
+                 return r
+             elif isinstance(a, Integer):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpz(r.value, self._poly, (<Integer> a).value)
++                fmpz_init_set_readonly(tmpfz, (<Integer> a).value)
++                fmpq_init(tmpfq)
++                fmpq_poly_evaluate_fmpz(tmpfq, self._poly, tmpfz)
++                fmpq_get_mpq(r.value, tmpfq)
++                fmpq_clear(tmpfq)
++                fmpz_clear_readonly(tmpfz)
+                 sig_off()
+                 return r
+             elif isinstance(a, int):
+@@ -1321,6 +1331,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         """
+         cdef Polynomial_rational_flint res
+         cdef bint do_sig
++        cdef fmpq_t tmpfq
+ 
+         if right == 0:
+             raise ZeroDivisionError("division by zero polynomial")
+@@ -1331,8 +1342,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+                 do_sig = _do_sig(self._poly)
+ 
+                 if do_sig: sig_str("FLINT exception")
+-                fmpq_poly_scalar_div_mpq(res._poly, self._poly,
+-                                                  (<Rational> QQ(right)).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> QQ(right)).value)
++                fmpq_poly_scalar_div_fmpq(res._poly, self._poly, tmpfq)
++                fmpq_clear_readonly(tmpfq)
+                 if do_sig: sig_off()
+                 return res
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+index 6e7f7498329..3a66198d568 100644
+--- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+@@ -658,6 +658,11 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
+             ...
+             NotImplementedError: square free factorization of polynomials over rings with composite characteristic is not implemented
+ 
++        :trac:`20003`::
++
++            sage: P.<x> = GF(7)[]
++            sage: (6*x+3).squarefree_decomposition()
++            (6) * (x + 4)
+         """
+         if not self.base_ring().is_field():
+             raise NotImplementedError("square free factorization of polynomials over rings with composite characteristic is not implemented")
+diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
+index a9ce06d14ca..affe11e4376 100644
+--- a/src/sage/rings/real_arb.pyx
++++ b/src/sage/rings/real_arb.pyx
+@@ -898,7 +898,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+             sage: RBF.gamma(5)
+             24.00000000000000
+             sage: RBF.gamma(10**20)
+-            [+/- ...e+1956570552410610660600]
++            [1.932849514310098...+1956570551809674817225 +/- ...]
+             sage: RBF.gamma(1/3)
+             [2.678938534707747 +/- ...e-16]
+             sage: RBF.gamma(-5)
+@@ -1102,7 +1102,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+              15.00000000000000,
+              48.00000000000000]
+             sage: RBF.double_factorial(2**20)
+-            [1.4483729903e+2928836 +/- ...e+2928825]
++            [1.448372990...e+2928836 +/- ...]
+             sage: RBF.double_factorial(2**1000)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/schemes/plane_conics/con_rational_function_field.py b/src/sage/schemes/plane_conics/con_rational_function_field.py
+index 05d24e78a85..581102b5c5b 100644
+--- a/src/sage/schemes/plane_conics/con_rational_function_field.py
++++ b/src/sage/schemes/plane_conics/con_rational_function_field.py
+@@ -198,38 +198,6 @@ def has_rational_point(self, point=False, algorithm='default',
+             Fraction Field of Univariate Polynomial Ring in u over Rational
+             Field with modulus v^2 - u^3 - 1
+ 
+-        ``has_rational_point`` fails for some conics over function fields
+-        over finite fields, due to :trac:`20003`::
+-
+-            sage: K.<t> = PolynomialRing(GF(7))
+-            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
+-            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
+-            sage: C.has_rational_point()                                                # needs sage.libs.singular
+-            Traceback (most recent call last):
+-            ...
+-            TypeError: self (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (-t^3 + 3*t^2 - 2*t - 2)/(t + 3)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (t^2 + 3*t + 3)*x*y + (-2*t^2 - 2)*y^2 + (-t^2 + 3*t + 2)*x*z + (-3*t + 3)*y*z + (-3*t^2 + t - 2)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x + (2*t - 2)/(t + 3)*y + (3*t^4 + 2*t^3 - 2*t^2 - 2*t + 3)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z
+-                     : y + (-t^3 - t^2 + 3*t - 1)/(t^3 - 3*t^2 + 2*t + 2)*z : z))
+-            domain must equal right (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^3 - t^2 + 3*t + 3)*x^2 + (t - 3)*y^2 + (-t^7 + 2*t^5 + t^4 + 2*t^3 + 3*t^2 - t - 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    -2/(t^3 - 3*t^2 + 2*t + 2)*x^2 + 1/(t^3 + 3*t^2 - 2*t + 1)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^9 - 2*t^8 + t^7 - t^6 + 3*t^5 - 3*t^3 + t^2 - 2*t + 3)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    ((t^3 - 3*t^2 + 2*t + 2)*x : (t^2 - 2)*y : (t^5 - 3*t^4 + t^2 + 3*t + 3)*z))
+-            codomain
+-
+-
+-
+         TESTS::
+ 
+             sage: K.<t> = FractionField(PolynomialRing(QQ, 't'))
+@@ -250,6 +218,16 @@ def has_rational_point(self, point=False, algorithm='default',
+             sage: C.has_rational_point(point=True)  # long time (4 seconds)             # needs sage.libs.singular
+             (True,
+              ((-2/117*t^8 + 304/1053*t^7 + 40/117*t^6 - 1/27*t^5 - 110/351*t^4 - 2/195*t^3 + 11/351*t^2 + 1/117)/(t^4 + 2/39*t^3 + 4/117*t^2 + 2/39*t + 14/39) : -5/3*t^4 + 19*t^3 : 1))
++
++        ``has_rational_point`` used to fail for some conics over function fields
++        over finite fields, due to :trac:`20003`::
++
++            sage: K.<t> = PolynomialRing(GF(7))
++            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
++            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
++            sage: C.has_rational_point()
++            True
++
+         """
+         from .constructor import Conic
+ 
+diff --git a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+index a591cb4cd7c..a90f2050c59 100644
+--- a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
++++ b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+@@ -20,6 +20,7 @@
+ #include "utils.h"
+ 
+ #include "gmp.h"
++#include "flint/fmpz_poly.h"
+ #include "flint/fmpq_poly.h"
+ #include "flint/fmpq.h"
+ 
+@@ -63,7 +64,7 @@ static ex chebyt_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+@@ -122,7 +123,7 @@ static ex chebyu_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+diff --git a/src/sage/symbolic/ginac/useries.cpp b/src/sage/symbolic/ginac/useries.cpp
+index 40fbd7ab360..b9a8b867648 100644
+--- a/src/sage/symbolic/ginac/useries.cpp
++++ b/src/sage/symbolic/ginac/useries.cpp
+@@ -467,10 +467,17 @@ void add::useries(flint_series_t& fp, int order) const
+                 fmpq_poly_set_ui(fp.ft, 0);
+         else if (oc.is_long())
+                 fmpq_poly_set_si(fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ 
+         for (const auto & elem : seq) {
+ 		const ex& t = recombine_pair_to_ex(elem);
+@@ -505,10 +512,17 @@ void mul::useries(flint_series_t& fp, int order) const
+ 
+         if (oc.is_long())
+                 fmpq_poly_scalar_mul_si(fp.ft, fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_scalar_mul_mpz(fp.ft, fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_scalar_mul_mpq(fp.ft, fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_scalar_mul_fmpz(fp.ft, fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp.ft, fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ void power::useries(flint_series_t& fp, int order) const
+@@ -563,7 +577,10 @@ void power::useries(flint_series_t& fp, int order) const
+                 }
+                 check_poly_ccoeff_one(fp1);
+                 fmpq_poly_log_series(fp1.ft, fp1.ft, order);
+-                fmpq_poly_scalar_mul_mpq(fp1.ft, fp1.ft, nexp.as_mpq());
++                fmpq_t tmp;
++                fmpq_init_set_readonly(tmp, nexp.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp1.ft, fp1.ft, tmp);
++                fmpq_clear_readonly(tmp);
+                 fmpq_poly_exp_series(fp.ft, fp1.ft, order);
+                 return;
+         }
+@@ -608,10 +625,17 @@ void numeric::useries(flint_series_t& fp, int order) const
+ {
+         if (is_long())
+                 fmpq_poly_set_si(fp.ft, to_long());
+-        else if (is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, as_mpq());
++        else if (is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ } // namespace GiNaC
+diff --git a/src/sage_setup/library_order.py b/src/sage_setup/library_order.py
+index f40690f8d22..9ae0d2579a7 100644
+--- a/src/sage_setup/library_order.py
++++ b/src/sage_setup/library_order.py
+@@ -16,17 +16,12 @@
+ 
+ aliases = cython_aliases(required_modules=(), optional_modules=modules)
+ 
+-if "ARB_LIBRARY" in aliases:
+-    arb_dylib_names = [aliases["ARB_LIBRARY"]]
+-else:
+-    arb_dylib_names = []
+-
+ library_order_list = aliases.get("SINGULAR_LIBRARIES", []) + [
+     "giac", "intl", "curl",
+     "ec", "ecm"
+ ] + aliases.get("LINBOX_LIBRARIES", []) + aliases.get("FFLASFFPACK_LIBRARIES", []) + aliases.get("GSL_LIBRARIES", []) + [
+     "pari", "flint", "ecl", "glpk", "ppl",
+-] + arb_dylib_names + [
++] + [
+     "mpfi", "mpfr", "mpc", "ntl", "gmp", "gmpxx",
+     "brial",
+     "brial_groebner",
diff --git a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch b/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
deleted file mode 100644
index 7c55bce6e9bb4..0000000000000
--- a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
+++ /dev/null
@@ -1,221 +0,0 @@
-diff --git a/build/pkgs/singular/checksums.ini b/build/pkgs/singular/checksums.ini
-index 313463d2fea..1101fc55700 100644
---- a/build/pkgs/singular/checksums.ini
-+++ b/build/pkgs/singular/checksums.ini
-@@ -1,5 +1,5 @@
- tarball=singular-VERSION.tar.gz
--sha1=28bb3ee97ef48d04dfa96de182fd93eebe08426c
--md5=fc0a4f5720dadba45a52ee94324ce00c
--cksum=1573851737
--upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-1/singular-VERSION.tar.gz
-+sha1=df1997f412580f2073295aba569bb955ad227317
-+md5=50349213e206a18cdaa1bc410dde7ea4
-+cksum=376854707
-+upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-2/singular-VERSION.tar.gz
-diff --git a/build/pkgs/singular/package-version.txt b/build/pkgs/singular/package-version.txt
-index 66e2bede53a..9f1bf008217 100644
---- a/build/pkgs/singular/package-version.txt
-+++ b/build/pkgs/singular/package-version.txt
-@@ -1 +1 @@
--4.3.1p3
-+4.3.2p7
-diff --git a/build/pkgs/singular/spkg-configure.m4 b/build/pkgs/singular/spkg-configure.m4
-index 6a85631f624..f7621ec5fa1 100644
---- a/build/pkgs/singular/spkg-configure.m4
-+++ b/build/pkgs/singular/spkg-configure.m4
-@@ -6,14 +6,27 @@ SAGE_SPKG_CONFIGURE([singular], [
-     AS_IF([test -z "${SINGULAR_BIN}"], [sage_spkg_install_singular=yes], [
-       dnl Use pkg-config to ensure that Singular is new enough.
-       PKG_CHECK_MODULES([SINGULAR], [Singular >= 4.2.1], [
--       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)
--       ], [
--       AC_MSG_RESULT(no)
--       sage_spkg_install_singular=yes
--       ]
--      )], [
-+        AC_MSG_CHECKING([whether Singular is built with FLINT])
-+        AC_COMPILE_IFELSE([
-+          AC_LANG_PROGRAM([
-+            #include <singular/singularconfig.h>
-+            #if !defined(HAVE_FLINT)
-+            #  error "Need Singular compiled with FLINT"
-+          ], [])
-+        ], [
-+          AC_MSG_RESULT([yes])
-+          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)
-+          ], [
-+            AC_MSG_RESULT(no)
-+            sage_spkg_install_singular=yes
-+          ])
-+        ], [
-+          AC_MSG_RESULT([no])
-+          sage_spkg_install_singular=yes
-+        ])
-+      ], [
-       dnl pkg-config version check failed
-       sage_spkg_install_singular=yes
-       ])
-diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py
-index b15cc1c602c..4b5c76e2bfa 100644
---- a/src/sage/interfaces/singular.py
-+++ b/src/sage/interfaces/singular.py
-@@ -604,8 +604,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: i = singular.ideal(['x^2','y^2','z^2'])
-             sage: s = i.std()
-             sage: singular.eval('hilb(%s)'%(s.name()))
--            '// 1 t^0\n// -3 t^2\n// 3 t^4\n// -1 t^6\n\n// 1 t^0\n//
--            3 t^1\n// 3 t^2\n// 1 t^3\n// dimension (affine) = 0\n//
-+            '...// dimension (affine) = 0\n//
-             degree (affine) = 8'
- 
-         ::
-@@ -613,15 +612,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: from sage.misc.verbose import set_verbose
-             sage: set_verbose(1)
-             sage: o = singular.eval('hilb(%s)'%(s.name()))
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
- 
-         This is mainly useful if this method is called implicitly. Because
-@@ -631,15 +622,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-         ::
- 
-             sage: o = s.hilb()
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
-             // ** right side is not a datum, assignment ignored
-             ...
-diff --git a/src/sage/libs/singular/function.pyx b/src/sage/libs/singular/function.pyx
-index f40346d1fd0..c597c63aafe 100644
---- a/src/sage/libs/singular/function.pyx
-+++ b/src/sage/libs/singular/function.pyx
-@@ -1241,32 +1241,22 @@ cdef class SingularFunction(SageObject):
-             sage: I = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5])
-             sage: I = Ideal(I.groebner_basis())
-             sage: hilb = sage.libs.singular.function_factory.ff.hilb
--            sage: hilb(I) # Singular will print // ** _ is no standard basis
--            // ** _ is no standard basis
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: from sage.misc.sage_ostools import redirection
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I) # Singular will print // ** _ is no standard basis
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            True
- 
-         So we tell Singular that ``I`` is indeed a Groebner basis::
- 
--            sage: hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            False
- 
- 
-         TESTS:
-diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-index 22ada6de947..80352700872 100644
---- a/src/sage/rings/polynomial/multi_polynomial_ideal.py
-+++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-@@ -3132,13 +3132,16 @@ def hilbert_numerator(self, grading=None, algorithm='sage'):
-             sage: I.hilbert_numerator()                                                 # needs sage.rings.number_field
-             -t^5 + 1
- 
--        This example returns a wrong answer due to an integer overflow in Singular::
-+        This example returns a wrong answer in singular < 4.3.2p4 due to an integer overflow::
- 
-             sage: n=4; m=11; P = PolynomialRing(QQ, n*m, "x"); x = P.gens(); M = Matrix(n, x)
-             sage: I = P.ideal(M.minors(2))
-             sage: J = P * [m.lm() for m in I.groebner_basis()]
--            sage: J.hilbert_numerator(algorithm='singular')
--            ...120*t^33 - 3465*t^32 + 48180*t^31 - ...
-+            sage: J.hilbert_numerator(algorithm='singular') # known bug
-+            Traceback (most recent call last):
-+            ....
-+            RuntimeError: error in Singular function call 'hilb':
-+            overflow at t^22
- 
-         Our two algorithms should always agree; not tested until
-         :trac:`33178` is fixed::
-diff --git a/src/sage/sandpiles/sandpile.py b/src/sage/sandpiles/sandpile.py
-index 02d2021b2fb..c8e15e06f05 100644
---- a/src/sage/sandpiles/sandpile.py
-+++ b/src/sage/sandpiles/sandpile.py
-@@ -2493,9 +2493,15 @@ def _set_ideal(self):
-             sage: '_ideal' in S.__dict__
-             True
-         """
-+        from sage.libs.singular.function_factory import ff
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
-         R = self.ring()
--        I = self._unsaturated_ideal._singular_()
--        self._ideal = R.ideal(I.sat(prod(R.gens())._singular_())[1])
-+        I = self._unsaturated_ideal
-+        I_sat_gens = sat(I, prod(R.gens()))[0]
-+        self._ideal = R.ideal(I_sat_gens)
- 
-     def unsaturated_ideal(self):
-         r"""
-diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py
-index e6caf19ba74..afd6484d779 100644
---- a/src/sage/schemes/projective/projective_subscheme.py
-+++ b/src/sage/schemes/projective/projective_subscheme.py
-@@ -1001,7 +1001,10 @@ def dual(self):
-         for i in range(n + 1):
-             J = J + S.ideal(z[-1] * f_S.derivative(z[i]) - z[i + n + 1])
- 
--        sat = ff.elim__lib.sat
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
- 
-         max_ideal = S.ideal(z[n + 1: 2 * n + 2])
-         J_sat_gens = sat(J, max_ideal)[0]
diff --git a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch b/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
deleted file mode 100644
index 6a35ec3836550..0000000000000
--- a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-diff --git a/src/sage/ext/memory.pyx b/src/sage/ext/memory.pyx
-index 1de6dedab82..b95130b19dd 100644
---- a/src/sage/ext/memory.pyx
-+++ b/src/sage/ext/memory.pyx
-@@ -3,14 +3,14 @@ Low-level memory allocation functions
- 
- TESTS:
- 
--Check that a ``MemoryError`` is raised if we try to allocate a
-+Check that an error is raised if we try to allocate a
- ridiculously large integer, see :trac:`15363`::
- 
--    sage: 2^(2^63-3)
--    Traceback (most recent call last):
--    ...
--    OverflowError: exponent must be at most 2147483647         # 32-bit
--    RuntimeError: Aborted                                      # 64-bit
-+    sage: try:
-+    ....:     2^(2^63-3)
-+    ....: except (OverflowError, RuntimeError, FloatingPointError):
-+    ....:     print ('Overflow error')
-+    ...Overflow error
- 
- AUTHORS:
- 
-diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx
-index d5e87626d31..37ed9364845 100644
---- a/src/sage/rings/integer.pyx
-+++ b/src/sage/rings/integer.pyx
-@@ -6654,7 +6654,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
-             sage: try:
-             ....:     print('Possible error output from gmp', flush=True)
-             ....:     1 << (2^60)
--            ....: except (MemoryError, OverflowError, RuntimeError):
-+            ....: except (MemoryError, OverflowError, RuntimeError, FloatingPointError):
-             ....:     pass
-             ....: else:
-             ....:     print("Failed to raise exception")
diff --git a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch b/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
deleted file mode 100644
index 3d2a4bd9cd96f..0000000000000
--- a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
+++ /dev/null
@@ -1,740 +0,0 @@
-diff --git a/src/sage/ext_data/valgrind/valgrind-python.supp b/src/sage/ext_data/valgrind/valgrind-python.supp
-new file mode 100644
-index 00000000000..16aa2858484
---- /dev/null
-+++ b/src/sage/ext_data/valgrind/valgrind-python.supp
-@@ -0,0 +1,480 @@
-+# From the CPython repository with the suppressions for _PyObject_Free
-+# and _PyObject_Realloc enabled. See the upstream suppression file for
-+# details:
-+#
-+# https://github.com/python/cpython/blob/main/Misc/valgrind-python.supp
-+
-+# all tool names: Addrcheck,Memcheck,cachegrind,helgrind,massif
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 8 (x86_64 aka amd64)
-+   Memcheck:Value8
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:address_in_range
-+}
-+
-+#
-+# Leaks (including possible leaks)
-+#    Hmmm, I wonder if this masks some real leaks.  I think it does.
-+#    Will need to fix that.
-+#
-+
-+{
-+   Suppress leaking the GIL after a fork.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_allocate_lock
-+   fun:PyEval_ReInitThreads
-+}
-+
-+{
-+   Suppress leaking the autoTLSkey.  This looks like it shouldn't leak though.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_create_key
-+   fun:_PyGILState_Init
-+   fun:Py_InitializeEx
-+   fun:Py_Main
-+}
-+
-+{
-+   Hmmm, is this a real leak or like the GIL?
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_ReInitTLS
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:realloc
-+   fun:_PyObject_GC_Resize
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_New
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_NewVar
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+#
-+# Non-python specific leaks
-+#
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:calloc
-+   fun:allocate_dtv
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:memalign
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Realloc
-+}
-+
-+###
-+### All the suppressions below are for errors that occur within libraries
-+### that Python uses.  The problems to not appear to be related to Python's
-+### use of the libraries.
-+###
-+
-+{
-+   Generic ubuntu ld problems
-+   Memcheck:Addr8
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+}
-+
-+{
-+   Generic gentoo ld problems
-+   Memcheck:Cond
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_close
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Value8
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   GDBM problems, see test_gdbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   fun:gdbm_open
-+
-+}
-+
-+{
-+   Uninitialised byte(s) false alarm, see bpo-35561
-+   Memcheck:Param
-+   epoll_ctl(event)
-+   fun:epoll_ctl
-+   fun:pyepoll_internal_ctl
-+}
-+
-+{
-+   ZLIB problems, see test_gzip
-+   Memcheck:Cond
-+   obj:/lib/libz.so.1.2.3
-+   obj:/lib/libz.so.1.2.3
-+   fun:deflate
-+}
-+
-+{
-+   Avoid problems w/readline doing a putenv and leaking on exit
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:xmalloc
-+   fun:sh_set_lines_and_columns
-+   fun:_rl_get_screen_size
-+   fun:_rl_init_terminal_io
-+   obj:/lib/libreadline.so.4.3
-+   fun:rl_initialize
-+}
-+
-+# Valgrind emits "Conditional jump or move depends on uninitialised value(s)"
-+# false alarms on GCC builtin strcmp() function. The GCC code is correct.
-+#
-+# Valgrind bug: https://bugs.kde.org/show_bug.cgi?id=264936
-+{
-+   bpo-38118: Valgrind emits false alarm on GCC builtin strcmp()
-+   Memcheck:Cond
-+   fun:PyUnicode_Decode
-+}
-+
-+
-+###
-+### These occur from somewhere within the SSL, when running
-+###  test_socket_sll.  They are too general to leave on by default.
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:memset
-+###}
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:memset
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:MD5_Update
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:MD5_Update
-+###}
-+
-+# Fedora's package "openssl-1.0.1-0.1.beta2.fc17.x86_64" on x86_64
-+# See http://bugs.python.org/issue14171
-+{
-+   openssl 1.0.1 prng 1
-+   Memcheck:Cond
-+   fun:bcmp
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 2
-+   Memcheck:Cond
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 3
-+   Memcheck:Value8
-+   fun:_x86_64_AES_encrypt_compact
-+   fun:AES_encrypt
-+}
-+
-+#
-+# All of these problems come from using test_socket_ssl
-+#
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_bin2bn
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libcrypto.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_set_key_unchecked
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_encrypt2
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BUF_MEM_grow_clean
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:memcpy
-+   fun:ssl3_read_bytes
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:SHA1_Update
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:SHA1_Update
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-+{
-+   wcscmp_false_positive
-+   Memcheck:Addr8
-+   fun:wcscmp
-+   fun:_PyOS_GetOpt
-+   fun:Py_Main
-+   fun:main
-+}
-+
-+# Additional suppressions for the unified decimal tests:
-+{
-+   test_decimal
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_decimal2
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index b40ed64edb5..8c55861c147 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -1576,6 +1576,62 @@ const numeric numeric::div(const numeric &other) const {
-         }
- }
- 
-+
-+// Compute `a^b` as an integer, where a is an integer. Assign to ``res``` if it is integral, or return ``false``.
-+// The nonnegative real root is taken for even denominators. To be used inside numeric::integer_rational_power,
-+// to handle the special case of integral ``a``.
-+bool integer_rational_power_of_mpz(
-+        numeric& res,
-+        const numeric& a,
-+        const numeric& b
-+) {
-+        if (a.t != MPZ)
-+                throw std::runtime_error("integer_rational_power_of_mpz: bad input");
-+        mpz_t z;
-+        mpz_init(z);
-+        mpz_set_ui(z, 0);
-+        int sgn = mpz_sgn(a.v._bigint);
-+        if (mpz_cmp_ui(a.v._bigint, 1) == 0
-+            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
-+                mpz_set_ui(z, 1);
-+        else if (sgn == 0) {
-+                res = *_num0_p;
-+                mpz_clear(z);
-+                return true;
-+        }
-+        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1)) {
-+                mpz_clear(z);
-+                return false;
-+        } else {
-+                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-+                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat))) {
-+                        // too big to take roots/powers
-+                        mpz_clear(z);
-+                        return false;
-+                }
-+                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
-+                        if (mpz_perfect_square_p(a.v._bigint)) {
-+                                mpz_sqrt(z, a.v._bigint);
-+                        } else {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                else {
-+                        bool exact = mpz_root(z, a.v._bigint,
-+                                              mpz_get_ui(mpq_denref(b.v._bigrat)));
-+                        if (not exact) {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
-+        }
-+        res = numeric(z);   // transfers ownership, no mpz_clear
-+        return true;
-+}
-+
-+
- // Compute `a^b` as an integer, if it is integral, or return ``false``.
- // The nonnegative real root is taken for even denominators.
- bool numeric::integer_rational_power(numeric& res,
-@@ -1598,13 +1654,12 @@ bool numeric::integer_rational_power(numeric& res,
-                 if (a.v._long < 0
-                     and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
-                         return false;
--                long z;
-                 if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-                     or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
-                 // too big to take roots/powers
-                         return false;
-                 if (b.is_equal(*_num1_2_p)) {
--                        z = std::lround(std::sqrt(a.v._long));
-+                        long z = std::lround(std::sqrt(a.v._long));
-                         if (a.v._long == z*z) {
-                                 res = numeric(z);
-                                 return true;
-@@ -1613,44 +1668,11 @@ bool numeric::integer_rational_power(numeric& res,
-                 }
-                 return integer_rational_power(res, a.to_bigint(), b);
-         }
--        if (a.t != MPZ)
--                throw std::runtime_error("integer_rational_power: bad input");
--        int sgn = mpz_sgn(a.v._bigint);
--        mpz_t z;
--        mpz_init(z);
--        mpz_set_ui(z, 0);
--        if (mpz_cmp_ui(a.v._bigint, 1) == 0
--            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
--                mpz_set_ui(z, 1);
--        else if (sgn == 0) {
--                res = *_num0_p;
--                return true;
--        }
--        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
--                return false;
--        else {
--                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
--                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
--                // too big to take roots/powers
--                        return false;
--                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
--                        if (mpz_perfect_square_p(a.v._bigint))
--                                mpz_sqrt(z, a.v._bigint);
--                        else
--                                return false;
--                }
--                else {
--                        bool exact = mpz_root(z, a.v._bigint,
--                                        mpz_get_ui(mpq_denref(b.v._bigrat)));
--                        if (not exact)
--                                return false;
--                }
--                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
--        }
--        res = numeric(z);
--        return true;
-+        // otherwise: a is integer
-+        return integer_rational_power_of_mpz(res, a, b);
- }
- 
-+
- // for a^b return c,d such that a^b = c*d^b
- // only for MPZ/MPQ base and MPQ exponent
- void rational_power_parts(const numeric& a_orig, const numeric& b_orig,
-diff --git a/src/sage/tests/memcheck/__init__.py b/src/sage/tests/memcheck/__init__.py
-new file mode 100644
-index 00000000000..e69de29bb2d
-diff --git a/src/sage/tests/memcheck/run_tests.py b/src/sage/tests/memcheck/run_tests.py
-new file mode 100644
-index 00000000000..6ff4503a81b
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests.py
-@@ -0,0 +1,24 @@
-+import types
-+
-+
-+def run_tests() -> None:
-+    """
-+    Run all memcheck tests
-+    """
-+    from sage.tests.memcheck import symbolic_expression
-+    run_tests_in_module(symbolic_expression)
-+
-+
-+def run_tests_in_module(mod: types.ModuleType) -> None:
-+    """
-+    Run all memcheck tests in the given module
-+    """
-+    for entry in dir(mod):
-+        if not entry.startswith('test_'):
-+            continue
-+        test_func = getattr(mod, entry)
-+        test_func()
-+
-+
-+if __name__ == '__main__':
-+    run_tests()
-diff --git a/src/sage/tests/memcheck/run_tests_in_valgrind.py b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-new file mode 100644
-index 00000000000..df5ad0e92b2
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-@@ -0,0 +1,35 @@
-+"""
-+Launch valgrind and run the memory leak tests
-+
-+
-+From the commandline, run
-+
-+    sage -python -m sage.tests.memcheck.run_tests_in_valgrind
-+
-+to launch valgrind and execute the memory leak tests. Requires valgrind
-+to be installed. Alternatively, run as a unit test:
-+
-+    sage: from sage.tests.memcheck.run_tests_in_valgrind import run_tests_in_valgrind
-+    sage: run_tests_in_valgrind()    # optional - valgrind
-+"""
-+
-+import subprocess
-+
-+
-+def run_tests_in_valgrind() -> None:
-+    """
-+    Run the sage.tests.memcheck.run_tests module inside valgrind
-+    """
-+    subprocess.check_call([
-+        'valgrind',
-+        '--suppressions=src/sage/ext_data/valgrind/valgrind-python.supp',
-+        '--show-possibly-lost=no',
-+        '--show-reachable=no',
-+        './venv/bin/python',
-+        '-m',
-+        'sage.tests.memcheck.run_tests'
-+    ])
-+
-+
-+if __name__ == '__main__':
-+    run_tests_in_valgrind()
-diff --git a/src/sage/tests/memcheck/symbolic_expression.py b/src/sage/tests/memcheck/symbolic_expression.py
-new file mode 100644
-index 00000000000..52182fbe62d
---- /dev/null
-+++ b/src/sage/tests/memcheck/symbolic_expression.py
-@@ -0,0 +1,11 @@
-+from sage.tests.memcheck.verify_no_leak import verify_no_leak
-+
-+
-+def test_sqrt_sqrt_2() -> None:
-+    from sage.misc.functional import sqrt
-+    T2 = sqrt(2)
-+
-+    def sqrt_T2() -> None:
-+        sqrt(T2)
-+
-+    verify_no_leak(sqrt_T2)
-diff --git a/src/sage/tests/memcheck/verify_no_leak.py b/src/sage/tests/memcheck/verify_no_leak.py
-new file mode 100644
-index 00000000000..89ca90cf89c
---- /dev/null
-+++ b/src/sage/tests/memcheck/verify_no_leak.py
-@@ -0,0 +1,27 @@
-+from typing import Tuple, Sequence, List, Callable, Any
-+import valgrind
-+
-+
-+def verify_no_leak(callback: Callable[[], Any],
-+                   repeat: int = 10000,
-+                   fuzzy: int = 10,
-+                   ) -> None:
-+    """
-+    Verify that the callback does not generate new definitely lost blocks
-+
-+    Raises an assertion if the callback leaks memory
-+    """
-+    callback()   # warm_up
-+    initial_blocks = (0, 0, 0, 0)
-+    valgrind.memcheck_do_leak_check()
-+    initial_blocks = valgrind.memcheck_count_leak_blocks()
-+    for _ in range(repeat):
-+        callback()
-+    valgrind.memcheck_do_leak_check()
-+    leak_blocks = valgrind.memcheck_count_leak_blocks()
-+    leak = leak_blocks[0] - initial_blocks[0]
-+    if leak < repeat - fuzzy:
-+        return  # callback did not leak at least once per call
-+    blocks = round(leak / repeat, 2)
-+    message = f'{callback} leaked {blocks} block on average ({repeat} iterations)'
-+    raise AssertionError(message)
diff --git a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch b/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
deleted file mode 100644
index 684b62affaf5a..0000000000000
--- a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx
-index 8f46570313d..a8e73e57b52 100644
---- a/src/sage/libs/ecl.pyx
-+++ b/src/sage/libs/ecl.pyx
-@@ -563,15 +563,15 @@ cdef class EclObject:
-     Floats in Python are IEEE double, which LISP has as well. However,
-     the printing of floating point types in LISP depends on settings::
- 
--        sage: a = EclObject(float(10^40))
-+        sage: a = EclObject(float(1.234e40))
-         sage: ecl_eval("(setf *read-default-float-format* 'single-float)")
-         <ECL: SINGLE-FLOAT>
-         sage: a
--        <ECL: 1.d40>
-+        <ECL: 1.234d40>
-         sage: ecl_eval("(setf *read-default-float-format* 'double-float)")
-         <ECL: DOUBLE-FLOAT>
-         sage: a
--        <ECL: 1.e40>
-+        <ECL: 1.234e40>
- 
-     Tuples are translated to dotted lists::
- 
-diff --git a/src/sage/libs/eclsig.h b/src/sage/libs/eclsig.h
-index e249ccf6874..005b2d99d0b 100644
---- a/src/sage/libs/eclsig.h
-+++ b/src/sage/libs/eclsig.h
-@@ -45,7 +45,11 @@ static inline void ecl_sig_off(void)
-     sig_off();
- }
- 
-+#if ECL_VERSION_NUMBER < 230909
- #define ecl_mpz_from_bignum(obj) ((obj)->big.big_num)
-+#else
-+#define ecl_mpz_from_bignum(obj) ecl_bignum(obj)
-+#endif
- 
- cl_object ecl_bignum_from_mpz(mpz_t num)
- {
diff --git a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch b/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
deleted file mode 100644
index e858f2fd4a445..0000000000000
--- a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
-index 59f10f6b13f..adcccff059b 100644
---- a/src/sage/plot/graphics.py
-+++ b/src/sage/plot/graphics.py
-@@ -36,6 +36,7 @@
- # ****************************************************************************
- 
- import os
-+from numbers import Integral
- from collections.abc import Iterable
- from math import isnan
- import sage.misc.verbose
-@@ -2874,6 +2875,11 @@ def matplotlib(self, filename=None,
-                 weight=lopts.pop('font_weight', 'medium'),
-                 variant=lopts.pop('font_variant', 'normal'))
-             color = lopts.pop('back_color', 'white')
-+            if 'loc' in lopts:
-+                loc = lopts['loc']
-+                if isinstance(loc, Integral):
-+                    # matplotlib 3.8 doesn't support sage integers
-+                    lopts['loc'] = int(loc)
-             leg = subplot.legend(prop=prop, **lopts)
-             if leg is None:
-                 from warnings import warn
diff --git a/srcpkgs/sagemath/patches/36403-00pre.patch b/srcpkgs/sagemath/patches/36403-00pre.patch
deleted file mode 100644
index 060404d5430de..0000000000000
--- a/srcpkgs/sagemath/patches/36403-00pre.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-Minor patch so that #36403 applies cleanly over sagemath 10.1
-
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 2053bca80c3..86aca6e00d8 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15123,7 +15302,8 @@ cdef class Matrix(Matrix1):
-             sage: N.conjugate_transpose()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object has no attribute 'conjugate'
-+            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
-+            has no attribute 'conjugate'
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 525ea5aa934..52afed49d64 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -55,7 +55,7 @@ cdef class AttributeErrorMessage:
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-         sage: x = polygen(ZZ, 'x')
--        sage: QQ[x].gen().bla                                                           # optional - sage.libs.flint
-+        sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
diff --git a/srcpkgs/sagemath/patches/36407-python_3.12.patch b/srcpkgs/sagemath/patches/36407-python_3.12.patch
deleted file mode 100644
index c75c275c30764..0000000000000
--- a/srcpkgs/sagemath/patches/36407-python_3.12.patch
+++ /dev/null
@@ -1,1744 +0,0 @@
-diff --git a/build/sage_bootstrap/package.py b/build/sage_bootstrap/package.py
-index 15b342223c4..eb82f96e05f 100644
---- a/build/sage_bootstrap/package.py
-+++ b/build/sage_bootstrap/package.py
-@@ -303,7 +303,7 @@ def _init_checksum(self):
-         # Name of the directory containing the checksums.ini file
-         self.__tarball_package_name = os.path.realpath(checksums_ini).split(os.sep)[-2]
- 
--    VERSION_PATCHLEVEL = re.compile('(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
-+    VERSION_PATCHLEVEL = re.compile(r'(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
- 
-     def _init_version(self):
-         try:
-diff --git a/src/doc/en/thematic_tutorials/coercion_and_categories.rst b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-index bb23331c151..7f5712caea7 100644
---- a/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-+++ b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-@@ -1223,7 +1223,7 @@ However, only "elementary" construction functors have a rank::
-     sage: (Fract*Poly).rank
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'
-+    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'...
- 
- .. end of output
- 
-diff --git a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-index 553a946c4d8..3cd71a9bad4 100644
---- a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-+++ b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-@@ -318,7 +318,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: e.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'...
- 
-         sage: id4 = SymmetricGroup(4).one()
-         sage: type(id4)
-@@ -326,7 +326,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: id4.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'
-+        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'...
- 
- .. note::
- 
-diff --git a/src/sage/algebras/cluster_algebra.py b/src/sage/algebras/cluster_algebra.py
-index b72d2a12976..14669dfed5c 100644
---- a/src/sage/algebras/cluster_algebra.py
-+++ b/src/sage/algebras/cluster_algebra.py
-@@ -167,7 +167,7 @@
-     sage: (t*s).g_vector()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'
-+    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'...
-     sage: A = ClusterAlgebra(['A', 2], principal_coefficients=True)
-     sage: A.explore_to_depth(infinity)
-     sage: s = A.cluster_variable((0, -1)); s
-diff --git a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-index e4a91723558..343ee8a66f9 100644
---- a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-+++ b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-@@ -109,7 +109,7 @@ class WeylLieConformalAlgebra(LieConformalAlgebraWithStructureCoefficients):
-         sage: alpha0.degree()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'
-+        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'...
- 
-     TESTS::
- 
-diff --git a/src/sage/algebras/steenrod/steenrod_algebra.py b/src/sage/algebras/steenrod/steenrod_algebra.py
-index 978a3557a9d..7c4d444f81c 100644
---- a/src/sage/algebras/steenrod/steenrod_algebra.py
-+++ b/src/sage/algebras/steenrod/steenrod_algebra.py
-@@ -1080,7 +1080,7 @@ def homogeneous_component(self, n):
-             sage: a.antipode() # not defined
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'
-+            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'...
-             sage: A(a).antipode() # convert to elt of A, then compute antipode
-             Sq(2,1) + Sq(5)
- 
-diff --git a/src/sage/all__sagemath_repl.py b/src/sage/all__sagemath_repl.py
-index 8d0b43679ca..c31b206bcb8 100644
---- a/src/sage/all__sagemath_repl.py
-+++ b/src/sage/all__sagemath_repl.py
-@@ -79,6 +79,23 @@
-                         message=r"Use setlocale\(\), getencoding\(\) and getlocale\(\) instead",
-                         module='docutils.io')
- 
-+# triggered by dateutil 2.8.2 and sphinx 7.0.1 on Python 3.12
-+# see: https://github.com/dateutil/dateutil/pull/1285
-+# see: https://github.com/sphinx-doc/sphinx/pull/11468
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"datetime.datetime.utcfromtimestamp\(\) is deprecated",
-+                        module='dateutil.tz.tz|sphinx.(builders.gettext|util.i18n)')
-+
-+# triggered on Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"This process.* is multi-threaded, "
-+                                r"use of .*\(\) may lead to deadlocks in the child.")
-+
-+# pickling of itertools is deprecated in Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"Pickle, copy, and deepcopy support will be "
-+                                r"removed from itertools in Python 3.14.")
-+
- 
- from .all__sagemath_objects import *
- from .all__sagemath_environment import *
-diff --git a/src/sage/arith/long.pxd b/src/sage/arith/long.pxd
-index 0031a0ae337..3ea70cef571 100644
---- a/src/sage/arith/long.pxd
-+++ b/src/sage/arith/long.pxd
-@@ -19,6 +19,8 @@ from libc.limits cimport LONG_MIN, LONG_MAX
- from cpython.object cimport Py_SIZE
- from cpython.number cimport PyNumber_Index, PyIndex_Check
- from cpython.longintrepr cimport py_long, PyLong_SHIFT, digit
-+from sage.cpython.pycore_long cimport (
-+    ob_digit, _PyLong_IsNegative, _PyLong_DigitCount)
- 
- from sage.libs.gmp.mpz cimport mpz_fits_slong_p, mpz_get_si
- from sage.rings.integer_fake cimport is_Integer, Integer_AS_MPZ
-@@ -299,8 +301,11 @@ cdef inline bint integer_check_long_py(x, long* value, int* err):
-         return 0
- 
-     # x is a Python "int" (aka PyLongObject or py_long in cython)
--    cdef const digit* D = (<py_long>x).ob_digit
--    cdef Py_ssize_t size = Py_SIZE(x)
-+    cdef const digit* D = ob_digit(x)
-+    cdef Py_ssize_t size = _PyLong_DigitCount(x)
-+
-+    if _PyLong_IsNegative(x):
-+        size = -size
- 
-     # We assume PyLong_SHIFT <= BITS_IN_LONG <= 3 * PyLong_SHIFT.
-     # This is true in all the default configurations:
-diff --git a/src/sage/categories/category.py b/src/sage/categories/category.py
-index 57ef7f4184b..29bce8ee415 100644
---- a/src/sage/categories/category.py
-+++ b/src/sage/categories/category.py
-@@ -2129,7 +2129,7 @@ def _with_axioms(self, axioms):
-             sage: Semigroups().Inverse()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'
-+            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'...
-             sage: Semigroups()._with_axioms(["Inverse"])
-             Category of semigroups
- 
-diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py
-index 5227792e725..4775d4e5bf1 100644
---- a/src/sage/categories/category_with_axiom.py
-+++ b/src/sage/categories/category_with_axiom.py
-@@ -554,7 +554,7 @@ class from the base category class::
-     sage: Magmas.Unital.Associative
-     Traceback (most recent call last):
-     ...
--    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'
-+    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'...
- 
- The purpose of this section is to explain the design of the code
- layout and the rationale for this mismatch.
-@@ -769,7 +769,7 @@ def _(): return LazyImport('sage.categories.rngs', 'Rngs', at_startup=True)
-     sage: Semirings().NoZeroDivisors()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'
-+    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'...
- 
- Concretely, this is to be implemented by defining the new axiom in the
- (``SubcategoryMethods`` nested class of the) appropriate category with
-diff --git a/src/sage/categories/enumerated_sets.py b/src/sage/categories/enumerated_sets.py
-index a8bea53f907..b0ea05d0563 100644
---- a/src/sage/categories/enumerated_sets.py
-+++ b/src/sage/categories/enumerated_sets.py
-@@ -610,7 +610,7 @@ def _list_from_iterator(self):
-                 sage: (QQ^2).list()  # indirect test                                    # needs sage.modules
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'
-+                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'...
- 
-             Here we test that for an object that does not know whether it
-             is finite or not.  Calling ``x.list()`` simply tries to create
-@@ -622,11 +622,11 @@ def _list_from_iterator(self):
-                 sage: Q.is_finite()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'...
-                 sage: Q.list()   # indirect test
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'...
- 
-             Here is another example. We artificially create a version of
-             the ring of integers that does not know whether it is finite
-diff --git a/src/sage/categories/examples/sets_cat.py b/src/sage/categories/examples/sets_cat.py
-index e0853d63f94..fbadb9ca405 100644
---- a/src/sage/categories/examples/sets_cat.py
-+++ b/src/sage/categories/examples/sets_cat.py
-@@ -619,7 +619,7 @@ class PrimeNumbers_Facade(PrimeNumbers_Abstract):
-         sage: pf.next()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'...
- 
-     unlike in the other implementations::
- 
-diff --git a/src/sage/categories/homset.py b/src/sage/categories/homset.py
-index 22ba9d047fc..2a8b8aeedeb 100644
---- a/src/sage/categories/homset.py
-+++ b/src/sage/categories/homset.py
-@@ -632,7 +632,7 @@ def __init__(self, X, Y, category=None, base=None, check=True):
-             sage: H = MyHomset(X, Y, category=1, base = ZZ, check = False)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'...
-             sage: P.<t> = ZZ[]
-             sage: f = P.hom([1/2*t])
-             sage: f.parent().domain()
-diff --git a/src/sage/categories/modules_with_basis.py b/src/sage/categories/modules_with_basis.py
-index e97bf851388..c4933d0657f 100644
---- a/src/sage/categories/modules_with_basis.py
-+++ b/src/sage/categories/modules_with_basis.py
-@@ -2456,7 +2456,7 @@ def apply_multilinear_morphism(self, f, codomain=None):
-                     sage: tensor([a, b]).apply_multilinear_morphism(f)                  # needs sage.modules
-                     Traceback (most recent call last):
-                     ...
--                    AttributeError: 'int' object has no attribute 'parent'
-+                    AttributeError: 'int' object has no attribute 'parent'...
- 
-                 Here we consider an example where the codomain is a
-                 module with basis with a different base ring::
-diff --git a/src/sage/categories/monoids.py b/src/sage/categories/monoids.py
-index 38dd7248c9d..28474bd17b6 100644
---- a/src/sage/categories/monoids.py
-+++ b/src/sage/categories/monoids.py
-@@ -556,7 +556,7 @@ def algebra_generators(self):
-                     Traceback (most recent call last):
-                     ...
-                     AttributeError: 'IntegerModMonoid_with_category' object
--                    has no attribute 'monoid_generators'
-+                    has no attribute 'monoid_generators'...
-                     sage: Z12.semigroup_generators()
-                     Family (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
-                     sage: Z12.algebra(QQ).algebra_generators()                          # needs sage.modules
-diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py
-index 494e8154c80..ec5120e41e6 100644
---- a/src/sage/combinat/finite_state_machine.py
-+++ b/src/sage/combinat/finite_state_machine.py
-@@ -1835,7 +1835,7 @@ def __getstate__(self):
-             sage: T1.transitions
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'FSMState' object has no attribute 'transitions'
-+            AttributeError: 'FSMState' object has no attribute 'transitions'...
-             sage: A1 = loads(dumps(A))
-             sage: all(A.state(j) == A1.state(j) for j in [0, 1])
-             True
-diff --git a/src/sage/combinat/growth.py b/src/sage/combinat/growth.py
-index cf8d18c1764..766eea37917 100644
---- a/src/sage/combinat/growth.py
-+++ b/src/sage/combinat/growth.py
-@@ -371,7 +371,7 @@
-     sage: GrowthDiagram(RulePascal(), [3,1,2])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'RulePascal' object has no attribute 'forward_rule'
-+    AttributeError: 'RulePascal' object has no attribute 'forward_rule'...
- 
- We now re-implement the rule where we provide the dual graded graphs::
- 
-diff --git a/src/sage/combinat/integer_lists/lists.py b/src/sage/combinat/integer_lists/lists.py
-index 5143e5cb5e8..9117a6076f7 100644
---- a/src/sage/combinat/integer_lists/lists.py
-+++ b/src/sage/combinat/integer_lists/lists.py
-@@ -261,7 +261,7 @@ def __getattr__(self, name):
-             sage: L.foo
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'foo'
-+            AttributeError: 'NoneType' object has no attribute 'foo'...
-         """
-         return getattr(self.backend, name)
- 
-diff --git a/src/sage/combinat/posets/posets.py b/src/sage/combinat/posets/posets.py
-index c31597c72e9..c74bfc67cee 100644
---- a/src/sage/combinat/posets/posets.py
-+++ b/src/sage/combinat/posets/posets.py
-@@ -8825,7 +8825,7 @@ def is_induced_subposet(self, other):
-             sage: Poset().is_induced_subposet('junk')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'subposet'
-+            AttributeError: 'str' object has no attribute 'subposet'...
-         """
-         if (not self._is_facade or (isinstance(other, FinitePoset) and
-                                     not other._is_facade)):
-diff --git a/src/sage/cpython/atexit.pyx b/src/sage/cpython/atexit.pyx
-index 961aa348d0a..e5a82735137 100644
---- a/src/sage/cpython/atexit.pyx
-+++ b/src/sage/cpython/atexit.pyx
-@@ -154,6 +154,10 @@ cdef extern from *:
-     #undef _PyGC_FINALIZED
-     #include "internal/pycore_interp.h"
-     #include "internal/pycore_pystate.h"
-+    #if PY_VERSION_HEX >= 0x030c0000
-+    // struct atexit_callback was renamed in 3.12 to atexit_py_callback
-+    #define atexit_callback atexit_py_callback
-+    #endif
-     static atexit_callback ** _atexit_callbacks(PyObject *self) {
-         PyInterpreterState *interp = _PyInterpreterState_GET();
-         struct atexit_state state = interp->atexit;
-diff --git a/src/sage/cpython/debug.pyx b/src/sage/cpython/debug.pyx
-index 986abff2a99..cdaca3a4854 100644
---- a/src/sage/cpython/debug.pyx
-+++ b/src/sage/cpython/debug.pyx
-@@ -78,7 +78,7 @@ def getattr_debug(obj, name, default=_no_default):
- 
-     EXAMPLES::
- 
--        sage: _ = getattr_debug(list, "reverse")
-+        sage: _ = getattr_debug(list, "reverse")  # not tested - broken in python 3.12
-         getattr_debug(obj=<class 'list'>, name='reverse'):
-           type(obj) = <class 'type'>
-           object has __dict__ slot (<class 'dict'>)
-@@ -123,7 +123,7 @@ def getattr_debug(obj, name, default=_no_default):
-         sage: _ = getattr_debug(1, "foo")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'...
-         sage: _ = getattr_debug(1, "foo", "xyz")
-         getattr_debug(obj=1, name='foo'):
-           type(obj) = <class 'sage.rings.integer.Integer'>
-diff --git a/src/sage/cpython/dict_internal.h b/src/sage/cpython/dict_internal.h
-index 42a57bcb468..a5ee35bc198 100644
---- a/src/sage/cpython/dict_internal.h
-+++ b/src/sage/cpython/dict_internal.h
-@@ -169,6 +169,7 @@ dictkeys_set_index(PyDictKeysObject *keys, Py_ssize_t i, Py_ssize_t ix)
- #else   /* Python >= 3.11 */
- 
- #define Py_BUILD_CORE
-+#undef _PyGC_FINALIZED
- #include <internal/pycore_dict.h>
- 
- /************************************************************/
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 52afed49d64..1f49e5230c3 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -53,12 +53,12 @@ cdef class AttributeErrorMessage:
-         sage: 1.bla  #indirect doctest
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'...
-         sage: x = polygen(ZZ, 'x')
-         sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'...
- 
-     ::
- 
-@@ -144,7 +144,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(X, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: x = X()
-         sage: raw_getattr(x, "prop")
-         <property object at ...>
-@@ -173,7 +173,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(Y, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: y = Y()
-         sage: raw_getattr(y, "prop")
-         <property object at ...>
-@@ -278,7 +278,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     The integer ring is a parent, so, lazy attributes work::
- 
-@@ -289,7 +289,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(17, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     In general, descriptors are not yet well supported, because they
-     often do not accept to be cheated with the type of their instance::
-@@ -305,7 +305,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__weakref__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-     This was caught by :trac:`8296` for which we do a couple more tests::
- 
-@@ -314,7 +314,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: 1.__weakref__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-         sage: n = 1
-         sage: ip = get_ipython()                 # not tested: only works in interactive shell
-@@ -329,7 +329,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__call__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'...
- 
-     TESTS:
- 
-@@ -339,14 +339,14 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, type, "__name__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'...
- 
-     Non-strings as "name" are handled gracefully::
- 
-         sage: getattr_from_other_class(1, type, None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute None
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute None...
-     """
-     if not isinstance(cls, type):
-         raise TypeError(f"{cls!r} is not a type")
-diff --git a/src/sage/cpython/pycore_long.h b/src/sage/cpython/pycore_long.h
-new file mode 100644
-index 00000000000..ff1a73d097a
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.h
-@@ -0,0 +1,98 @@
-+#include "Python.h"
-+#include <stdbool.h>
-+
-+#if PY_VERSION_HEX >= 0x030C00A5
-+#define ob_digit(o)  (((PyLongObject*)o)->long_value.ob_digit)
-+#else
-+#define ob_digit(o)  (((PyLongObject*)o)->ob_digit)
-+#endif
-+
-+#if PY_VERSION_HEX >= 0x030C00A7
-+// taken from cpython:Include/internal/pycore_long.h @ 3.12
-+
-+/* Long value tag bits:
-+ * 0-1: Sign bits value = (1-sign), ie. negative=2, positive=0, zero=1.
-+ * 2: Reserved for immortality bit
-+ * 3+ Unsigned digit count
-+ */
-+#define SIGN_MASK 3
-+#define SIGN_ZERO 1
-+#define SIGN_NEGATIVE 2
-+#define NON_SIZE_BITS 3
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_ZERO;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_NEGATIVE;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    assert(PyLong_Check(op));
-+    return op->long_value.lv_tag >> NON_SIZE_BITS;
-+}
-+
-+#define TAG_FROM_SIGN_AND_SIZE(sign, size) ((1 - (sign)) | ((size) << NON_SIZE_BITS))
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+    assert(size >= 0);
-+    assert(-1 <= sign && sign <= 1);
-+    assert(sign != 0 || size == 0);
-+    op->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sign, (size_t)size);
-+}
-+
-+#else
-+// fallback for < 3.12
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) == 0;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) < 0;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) > 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    Py_ssize_t size = Py_SIZE(op);
-+    return size < 0 ? -size : size;
-+}
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION < 9)
-+// The function Py_SET_SIZE is defined starting with python 3.9.
-+    Py_SIZE(o) = size;
-+#else
-+    Py_SET_SIZE(op, sign < 0 ? -size : size);
-+#endif
-+}
-+
-+#endif
-diff --git a/src/sage/cpython/pycore_long.pxd b/src/sage/cpython/pycore_long.pxd
-new file mode 100644
-index 00000000000..41de637ff18
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.pxd
-@@ -0,0 +1,9 @@
-+from cpython.longintrepr cimport py_long, digit
-+
-+cdef extern from "pycore_long.h":
-+    digit* ob_digit(py_long o)
-+    bint _PyLong_IsZero(py_long o)
-+    bint _PyLong_IsNegative(py_long o)
-+    bint _PyLong_IsPositive(py_long o)
-+    Py_ssize_t _PyLong_DigitCount(py_long o)
-+    void _PyLong_SetSignAndDigitCount(py_long o, int sign, Py_ssize_t size)
-diff --git a/src/sage/crypto/classical.py b/src/sage/crypto/classical.py
-index 616dc861652..be899c781e5 100644
---- a/src/sage/crypto/classical.py
-+++ b/src/sage/crypto/classical.py
-@@ -494,7 +494,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: A.rank_by_chi_square("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_chi_square(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -703,7 +703,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: A.rank_by_squared_differences("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_squared_differences(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -2114,7 +2114,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: S.rank_by_chi_square("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_chi_square(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-@@ -2351,7 +2351,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: S.rank_by_squared_differences("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_squared_differences(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/crypto/mq/mpolynomialsystemgenerator.py b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-index 9028dab1d98..4416d9ef7f6 100644
---- a/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-+++ b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-@@ -156,7 +156,7 @@ def sbox(self):
-             sage: msg.sbox()
-             Traceback (most recent call last):
-             ...
--            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'
-+            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'...
-         """
-         return self._sbox
- 
-diff --git a/src/sage/data_structures/bitset.pyx b/src/sage/data_structures/bitset.pyx
-index 446062554c1..d9906b5edd2 100644
---- a/src/sage/data_structures/bitset.pyx
-+++ b/src/sage/data_structures/bitset.pyx
-@@ -967,7 +967,7 @@ cdef class FrozenBitset:
-             sage: None | FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute '_union'
-+            AttributeError: 'NoneType' object has no attribute '_union'...
-         """
-         return self._union(other)
- 
-@@ -1037,7 +1037,7 @@ cdef class FrozenBitset:
-             sage: None & FrozenBitset("101011")
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'intersection'
-+            AttributeError: 'NoneType' object has no attribute 'intersection'...
-         """
-         return self.intersection(other)
- 
-@@ -1106,7 +1106,7 @@ cdef class FrozenBitset:
-             sage: None - FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'difference'
-+            AttributeError: 'NoneType' object has no attribute 'difference'...
-         """
-         return self.difference(other)
- 
-@@ -1179,7 +1179,7 @@ cdef class FrozenBitset:
-             sage: None ^^ FrozenBitset('11111' * 10)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'
-+            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'...
-         """
-         return self.symmetric_difference(other)
- 
-diff --git a/src/sage/doctest/reporting.py b/src/sage/doctest/reporting.py
-index 361fea344c2..a3947c07e01 100644
---- a/src/sage/doctest/reporting.py
-+++ b/src/sage/doctest/reporting.py
-@@ -368,7 +368,7 @@ def report(self, source, timeout, return_code, results, output, pid=None):
-             sage: DTR.report(None, None, None, None, None)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'basename'
-+            AttributeError: 'NoneType' object has no attribute 'basename'...
- 
-         The only-errors mode does not output anything on success::
- 
-diff --git a/src/sage/dynamics/finite_dynamical_system.py b/src/sage/dynamics/finite_dynamical_system.py
-index e5fbf568b7e..4295070615a 100644
---- a/src/sage/dynamics/finite_dynamical_system.py
-+++ b/src/sage/dynamics/finite_dynamical_system.py
-@@ -240,7 +240,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-@@ -252,7 +252,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-diff --git a/src/sage/geometry/cone.py b/src/sage/geometry/cone.py
-index f0a8620011a..53f78a4b7b6 100644
---- a/src/sage/geometry/cone.py
-+++ b/src/sage/geometry/cone.py
-@@ -340,7 +340,7 @@ def Cone(rays, lattice=None, check=True, normalize=True):
-         sage: Cone([(1,0), (0,1)], check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     You can construct different "not" cones: not full-dimensional, not
-     strictly convex, not containing any rays::
-diff --git a/src/sage/geometry/fan.py b/src/sage/geometry/fan.py
-index 258544012fe..3aecc84a55b 100644
---- a/src/sage/geometry/fan.py
-+++ b/src/sage/geometry/fan.py
-@@ -443,7 +443,7 @@ def Fan(cones, rays=None, lattice=None, check=True, normalize=True,
-         sage: P2c = Fan(cones, rays, check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     Yet another way is to use functions :func:`FaceFan` and :func:`NormalFan`
-     to construct fans from :class:`lattice polytopes
-diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-index f0ac1e774a7..f03f0f832ff 100644
---- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-+++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-@@ -351,7 +351,7 @@ cdef class FaceIterator_base(SageObject):
-             sage: FaceIterator_base(2)  # indirect doctest
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'...
-         """
-         cdef int i
-         sig_free(self.structure.atom_rep)
-@@ -1945,7 +1945,8 @@ cdef inline int next_face_loop(iter_t structure) nogil except -1:
-         # The function is not supposed to be called,
-         # just prevent it from crashing.
-         # Actually raising an error here results in a bad branch prediction.
--        return -1
-+        # But return -1 results in a crash with python 3.12
-+        raise StopIteration
- 
-     # Getting ``[faces, n_faces, n_visited_all]`` according to dimension.
-     cdef face_list_t* faces = &structure.new_faces[structure.current_dimension]
-diff --git a/src/sage/geometry/toric_plotter.py b/src/sage/geometry/toric_plotter.py
-index 50b4008eb0f..950e3ba7ff8 100644
---- a/src/sage/geometry/toric_plotter.py
-+++ b/src/sage/geometry/toric_plotter.py
-@@ -706,7 +706,7 @@ def set_rays(self, generators):
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ToricPlotter' object has no attribute 'rays'
-+            AttributeError: 'ToricPlotter' object has no attribute 'rays'...
-             sage: tp.set_rays([(0,1)])
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Graphics object consisting of 2 graphics primitives
-diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
-index d0ec214bb3b..c8098ad578a 100644
---- a/src/sage/groups/matrix_gps/finitely_generated.py
-+++ b/src/sage/groups/matrix_gps/finitely_generated.py
-@@ -268,7 +268,7 @@ def MatrixGroup(*gens, **kwds):
-         sage: SL2C.gens()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'
-+        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'...
-     """
-     if isinstance(gens[-1], dict):   # hack for unpickling
-         kwds.update(gens[-1])
-diff --git a/src/sage/homology/chains.py b/src/sage/homology/chains.py
-index 87c0947c0b0..b9a54940943 100644
---- a/src/sage/homology/chains.py
-+++ b/src/sage/homology/chains.py
-@@ -298,7 +298,7 @@ def is_cycle(self):
-                 sage: chain.is_cocycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -325,7 +325,7 @@ def is_boundary(self):
-                 sage: chain.is_coboundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -539,7 +539,7 @@ def is_cocycle(self):
-                 sage: cochain.is_cycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -566,7 +566,7 @@ def is_coboundary(self):
-                 sage: cochain.is_boundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -604,7 +604,7 @@ def eval(self, other):
-                 sage: z.eval(c) # z is not a cochain
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'...
-                 sage: c.eval(c) # can't evaluate a cochain on a cochain
-                 Traceback (most recent call last):
-                 ...
-diff --git a/src/sage/homology/free_resolution.py b/src/sage/homology/free_resolution.py
-index e3d38de4240..280a479b438 100644
---- a/src/sage/homology/free_resolution.py
-+++ b/src/sage/homology/free_resolution.py
-@@ -275,7 +275,7 @@ def differential(self, i):
-             sage: FreeResolution.differiental(r, 1)
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'FreeResolution' has no attribute 'differiental'
-+            AttributeError: type object 'FreeResolution' has no attribute 'differiental'...
-         """
- 
-     def target(self):
-diff --git a/src/sage/interfaces/magma.py b/src/sage/interfaces/magma.py
-index b7a0ac20d03..529bfbc349b 100644
---- a/src/sage/interfaces/magma.py
-+++ b/src/sage/interfaces/magma.py
-@@ -824,7 +824,7 @@ def _coerce_from_special_method(self, x):
-             sage: magma._coerce_from_special_method('2 + 3')  # optional - magma
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute '_magma_init_'
-+            AttributeError: 'str' object has no attribute '_magma_init_'...
-         """
-         s = x._magma_init_(self)
-         a = self(s)
-diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
-index 58499396d6c..16119d20815 100644
---- a/src/sage/lfunctions/dokchitser.py
-+++ b/src/sage/lfunctions/dokchitser.py
-@@ -418,8 +418,8 @@ def init_coeffs(self, v, cutoff=1,
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
-index bbf289aa21c..e4968866303 100644
---- a/src/sage/lfunctions/pari.py
-+++ b/src/sage/lfunctions/pari.py
-@@ -141,8 +141,8 @@ def init_coeffs(self, v, cutoff=None, w=1):
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
-index 478caf9f9d0..363024ae281 100644
---- a/src/sage/libs/gap/element.pyx
-+++ b/src/sage/libs/gap/element.pyx
-@@ -380,7 +380,7 @@ cdef GapElement make_GapElement(parent, Obj obj):
-         sage: libgap(None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute '_libgap_init_'
-+        AttributeError: 'NoneType' object has no attribute '_libgap_init_'...
-     """
-     cdef GapElement r = GapElement.__new__(GapElement)
-     r._initialize(parent, obj)
-diff --git a/src/sage/libs/gmp/pylong.pxd b/src/sage/libs/gmp/pylong.pxd
-index a73f1da6d6f..84e1bb8cd87 100644
---- a/src/sage/libs/gmp/pylong.pxd
-+++ b/src/sage/libs/gmp/pylong.pxd
-@@ -2,9 +2,10 @@
- Various functions to deal with conversion mpz <-> Python int/long
- """
- 
-+from cpython.longintrepr cimport py_long
- from sage.libs.gmp.types cimport *
- 
- cdef mpz_get_pylong(mpz_srcptr z)
- cdef mpz_get_pyintlong(mpz_srcptr z)
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1
- cdef Py_hash_t mpz_pythonhash(mpz_srcptr z)
-diff --git a/src/sage/libs/gmp/pylong.pyx b/src/sage/libs/gmp/pylong.pyx
-index d5993cca5a5..1a36c29d3fa 100644
---- a/src/sage/libs/gmp/pylong.pyx
-+++ b/src/sage/libs/gmp/pylong.pyx
-@@ -28,6 +28,8 @@ AUTHORS:
- from cpython.object cimport Py_SIZE
- from cpython.long cimport PyLong_FromLong
- from cpython.longintrepr cimport _PyLong_New, py_long, digit, PyLong_SHIFT
-+from sage.cpython.pycore_long cimport (ob_digit, _PyLong_IsNegative,
-+    _PyLong_DigitCount, _PyLong_SetSignAndDigitCount)
- from .mpz cimport *
- 
- cdef extern from *:
-@@ -60,12 +62,9 @@ cdef mpz_get_pylong_large(mpz_srcptr z):
-     """
-     cdef size_t nbits = mpz_sizeinbase(z, 2)
-     cdef size_t pylong_size = (nbits + PyLong_SHIFT - 1) // PyLong_SHIFT
--    L = _PyLong_New(pylong_size)
--    mpz_export(L.ob_digit, NULL,
--            -1, sizeof(digit), 0, PyLong_nails, z)
--    if mpz_sgn(z) < 0:
--        # Set correct size
--        Py_SET_SIZE(L, -pylong_size)
-+    cdef py_long L = _PyLong_New(pylong_size)
-+    mpz_export(ob_digit(L), NULL, -1, sizeof(digit), 0, PyLong_nails, z)
-+    _PyLong_SetSignAndDigitCount(L, mpz_sgn(z), pylong_size)
-     return L
- 
- 
-@@ -88,16 +87,13 @@ cdef mpz_get_pyintlong(mpz_srcptr z):
-     return mpz_get_pylong_large(z)
- 
- 
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1:
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1:
-     """
-     Convert a Python ``long`` `L` to an ``mpz``.
-     """
--    cdef Py_ssize_t pylong_size = Py_SIZE(L)
--    if pylong_size < 0:
--        pylong_size = -pylong_size
--    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails,
--            (<py_long>L).ob_digit)
--    if Py_SIZE(L) < 0:
-+    cdef Py_ssize_t pylong_size = _PyLong_DigitCount(L)
-+    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails, ob_digit(L))
-+    if _PyLong_IsNegative(L):
-         mpz_neg(z, z)
- 
- 
-diff --git a/src/sage/manifolds/calculus_method.py b/src/sage/manifolds/calculus_method.py
-index f5830c0bc45..303dde6cd13 100644
---- a/src/sage/manifolds/calculus_method.py
-+++ b/src/sage/manifolds/calculus_method.py
-@@ -257,7 +257,7 @@ def simplify(self, expression, method=None):
-             sage: cm.simplify(f)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'
-+            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'...
- 
-         In the present case, one should either transform ``f`` to a SymPy
-         object::
-diff --git a/src/sage/manifolds/differentiable/vectorfield_module.py b/src/sage/manifolds/differentiable/vectorfield_module.py
-index d954b5d4839..af4bfb0ceec 100644
---- a/src/sage/manifolds/differentiable/vectorfield_module.py
-+++ b/src/sage/manifolds/differentiable/vectorfield_module.py
-@@ -885,7 +885,7 @@ def tensor(self, *args, **kwds):
-             sage: XM.tensor(XM).tensor(XM.dual().tensor(XM.dual()))
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'
-+            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'...
- 
-         .. SEEALSO::
- 
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 86aca6e00d8..a5f6716e731 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15303,7 +15303,7 @@ cdef class Matrix(Matrix1):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
--            has no attribute 'conjugate'
-+            has no attribute 'conjugate'...
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/matrix/matrix_cyclo_dense.pyx b/src/sage/matrix/matrix_cyclo_dense.pyx
-index f54f3423ded..a49bb6240e6 100644
---- a/src/sage/matrix/matrix_cyclo_dense.pyx
-+++ b/src/sage/matrix/matrix_cyclo_dense.pyx
-@@ -847,7 +847,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense):
-             sage: A.set_mutable()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'
-+            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'...
-             sage: B = A.__copy__()
-             sage: B[0,0] = 20
-             sage: B[0,0]
-diff --git a/src/sage/matrix/matrix_gfpn_dense.pyx b/src/sage/matrix/matrix_gfpn_dense.pyx
-index 4cccf473de1..8e8e4d7336b 100644
---- a/src/sage/matrix/matrix_gfpn_dense.pyx
-+++ b/src/sage/matrix/matrix_gfpn_dense.pyx
-@@ -159,7 +159,7 @@ cdef class FieldConverter_class:
-             sage: C.field_to_fel('foo')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'to_integer'
-+            AttributeError: 'str' object has no attribute 'to_integer'...
-         """
-         return FfFromInt(x.to_integer())
- 
-diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py
-index 6aab58352be..b5e6f52349b 100644
---- a/src/sage/matrix/matrix_space.py
-+++ b/src/sage/matrix/matrix_space.py
-@@ -1619,7 +1619,7 @@ def __getitem__(self, x):
-             sage: MS[2]
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'
-+            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'...
-         """
-         if isinstance(x, (integer.Integer, int)):
-             return self.list()[x]
-diff --git a/src/sage/matroids/lean_matrix.pyx b/src/sage/matroids/lean_matrix.pyx
-index 54c68e637c0..a137cbf70e5 100644
---- a/src/sage/matroids/lean_matrix.pyx
-+++ b/src/sage/matroids/lean_matrix.pyx
-@@ -1,5 +1,4 @@
- # sage.doctest: optional - sage.rings.finite_rings
--# cython: profile=True
- """
- Lean matrices
- 
-diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx
-index 36f563aa433..318c82f2b64 100644
---- a/src/sage/matroids/linear_matroid.pyx
-+++ b/src/sage/matroids/linear_matroid.pyx
-@@ -1134,7 +1134,7 @@ cdef class LinearMatroid(BasisExchangeMatroid):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.matroids.basis_matroid.BasisMatroid' object
--            has no attribute 'base_ring'
-+            has no attribute 'base_ring'...
-             sage: from sage.matroids.advanced import *
-             sage: M4 = BinaryMatroid(Matrix(M1))
-             sage: M5 = LinearMatroid(reduced_matrix=Matrix(GF(2), [[-1, 0, 1],
-diff --git a/src/sage/misc/dev_tools.py b/src/sage/misc/dev_tools.py
-index e7bf176592c..3ece7db2894 100644
---- a/src/sage/misc/dev_tools.py
-+++ b/src/sage/misc/dev_tools.py
-@@ -171,6 +171,7 @@ def load_submodules(module=None, exclude_pattern=None):
-         load sage.geometry.polyhedron.ppl_lattice_polygon... succeeded
-     """
-     from .package_dir import walk_packages
-+    import importlib.util
- 
-     if module is None:
-         import sage
-@@ -194,8 +195,12 @@ def load_submodules(module=None, exclude_pattern=None):
-         try:
-             sys.stdout.write("load %s..." % module_name)
-             sys.stdout.flush()
--            loader = importer.find_module(module_name)
--            loader.load_module(module_name)
-+            # see
-+            # https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
-+            spec = importer.find_spec(module_name)
-+            module = importlib.util.module_from_spec(spec)
-+            sys.modules[module_name] = module
-+            spec.loader.exec_module(module)
-             sys.stdout.write(" succeeded\n")
-         except (ValueError, AttributeError, TypeError, ImportError):
-             # we might get error because of cython code that has been
-diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py
-index c922b8f6f12..03697f08b7c 100644
---- a/src/sage/misc/functional.py
-+++ b/src/sage/misc/functional.py
-@@ -86,7 +86,7 @@ def base_field(x):
-         sage: R.base_field()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'
-+        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'...
-     """
-     try:
-         return x.base_field()
-diff --git a/src/sage/misc/instancedoc.pyx b/src/sage/misc/instancedoc.pyx
-index d8e1e4ac536..44ee70f64ba 100644
---- a/src/sage/misc/instancedoc.pyx
-+++ b/src/sage/misc/instancedoc.pyx
-@@ -256,7 +256,7 @@ cdef class InstanceDocDescriptor:
-             sage: descr.__delete__(obj)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'X' object has no attribute '__doc__'
-+            AttributeError: 'X' object has no attribute '__doc__'...
- 
-             sage: descr.__delete__([])
-             Traceback (most recent call last):
-diff --git a/src/sage/misc/lazy_attribute.pyx b/src/sage/misc/lazy_attribute.pyx
-index bdbec3b3ba1..1f07870b8ec 100644
---- a/src/sage/misc/lazy_attribute.pyx
-+++ b/src/sage/misc/lazy_attribute.pyx
-@@ -441,37 +441,37 @@ class lazy_attribute(_lazy_attribute):
-             sage: B().unimplemented_A # todo: not implemented
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'super' object has no attribute 'unimplemented_A'
-+            AttributeError: 'super' object has no attribute 'unimplemented_A'...
- 
-     We now make some systematic checks::
- 
-         sage: B().unimplemented_A
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: B().unimplemented_B
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: B().unimplemented_AB
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: B().unimplemented_B_implemented_A
-         1
- 
-         sage: C().unimplemented_A()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: C().unimplemented_B()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: C().unimplemented_AB()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: C().unimplemented_B_implemented_A # todo: not implemented
-         1
-     """
-diff --git a/src/sage/misc/object_multiplexer.py b/src/sage/misc/object_multiplexer.py
-index d4e811ef16e..00fd89d6652 100644
---- a/src/sage/misc/object_multiplexer.py
-+++ b/src/sage/misc/object_multiplexer.py
-@@ -85,7 +85,7 @@ def __getattr__(self, name):
-             sage: m.__bork__
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Multiplex' has no attribute '__bork__'
-+            AttributeError: 'Multiplex' has no attribute '__bork__'...
-         """
-         if name.startswith("__"):
-             raise AttributeError("'Multiplex' has no attribute '%s'" % name)
-diff --git a/src/sage/misc/sage_input.py b/src/sage/misc/sage_input.py
-index 66e78ecccbc..00e8d96ee9e 100644
---- a/src/sage/misc/sage_input.py
-+++ b/src/sage/misc/sage_input.py
-@@ -3461,7 +3461,7 @@ def verify_same(a, b):
-         sage: verify_same(1, 1r)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_same(1r, 1)
-         Traceback (most recent call last):
-         ...
-@@ -3525,7 +3525,7 @@ def verify_si_answer(x, answer, preparse):
-         sage: verify_si_answer(1, '1', False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_si_answer(1, 'ZZ(1)', None)
-     """
-     from sage.misc.sage_eval import sage_eval
-diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py
-index f0545be7d81..811afc48755 100644
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -602,7 +602,7 @@ def visit_Num(self, node):
-             On Python 3 negative numbers are parsed first, for some reason, as
-             a UnaryOp node.
-         """
--        return node.n
-+        return node.value
- 
-     def visit_Str(self, node):
-         r"""
-@@ -624,7 +624,7 @@ def visit_Str(self, node):
-             sage: [vis(s) for s in ['"abstract"', "'syntax'", r'''r"tr\ee"''']]
-             ['abstract', 'syntax', 'tr\\ee']
-         """
--        return node.s
-+        return node.value
- 
-     def visit_List(self, node):
-         """
-diff --git a/src/sage/modules/fp_graded/steenrod/module.py b/src/sage/modules/fp_graded/steenrod/module.py
-index 18460b0e9a1..4acfa6b4002 100755
---- a/src/sage/modules/fp_graded/steenrod/module.py
-+++ b/src/sage/modules/fp_graded/steenrod/module.py
-@@ -70,7 +70,7 @@
-     sage: SteenrodFPModule(ZZ, [0])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'
-+    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'...
- 
- AUTHORS:
- 
-diff --git a/src/sage/monoids/trace_monoid.py b/src/sage/monoids/trace_monoid.py
-index 00baa4d14f8..f8176a1e1f2 100644
---- a/src/sage/monoids/trace_monoid.py
-+++ b/src/sage/monoids/trace_monoid.py
-@@ -40,7 +40,6 @@
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from collections import OrderedDict
- from itertools import repeat, chain, product
- 
- from sage.misc.cachefunc import cached_method
-@@ -633,14 +632,14 @@ def _compute_dependence_stack(self, x):
-             sage: x = b*a*d*a*c*b
-             sage: M._compute_dependence_stack(x)
-             ({a, b, c, d},
--             OrderedDict([(a, [False, False, True, True, False]),
--                          (b, [True, False, False, False, True]),
--                          (c, [True, False, False, False]),
--                          (d, [False, False, True, False])]))
-+             {a: [False, False, True, True, False],
-+              b: [True, False, False, False, True],
-+              c: [True, False, False, False],
-+              d: [False, False, True, False]})
-         """
-         independence = self._independence
-         generators_set = set(e for e, _ in x)
--        stacks = OrderedDict(sorted((g, []) for g in generators_set))
-+        stacks = dict(sorted((g, []) for g in generators_set))
-         for generator, times in reversed(list(x)):
-             stacks[generator].extend(repeat(True, times))
-             for other_gen in generators_set:
-diff --git a/src/sage/parallel/map_reduce.py b/src/sage/parallel/map_reduce.py
-index 11e0673ee91..5441943731d 100644
---- a/src/sage/parallel/map_reduce.py
-+++ b/src/sage/parallel/map_reduce.py
-@@ -1234,7 +1234,7 @@ def finish(self):
-             sage: S.print_communication_statistics()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'RESetMPExample' object has no attribute '_stats'
-+            AttributeError: 'RESetMPExample' object has no attribute '_stats'...
- 
-             sage: S.finish()
- 
-diff --git a/src/sage/plot/colors.py b/src/sage/plot/colors.py
-index 8c0db2b3c34..3281199400b 100644
---- a/src/sage/plot/colors.py
-+++ b/src/sage/plot/colors.py
-@@ -1099,7 +1099,7 @@ def __getattr__(self, name):
-             sage: cols.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ColorsDict' has no attribute or colormap punk
-+            AttributeError: 'ColorsDict' has no attribute or colormap punk...
-         """
-         try:
-             return self[name]
-@@ -1599,7 +1599,7 @@ def __getattr__(self, name):
-             sage: maps.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Colormaps' has no attribute or colormap punk
-+            AttributeError: 'Colormaps' has no attribute or colormap punk...
-             sage: maps['punk']
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/rings/asymptotic/asymptotic_ring.py b/src/sage/rings/asymptotic/asymptotic_ring.py
-index b07319382d3..994490e6616 100644
---- a/src/sage/rings/asymptotic/asymptotic_ring.py
-+++ b/src/sage/rings/asymptotic/asymptotic_ring.py
-@@ -1091,7 +1091,7 @@ def monomial_coefficient(self, monomial):
-             sage: O(n).monomial_coefficient(n)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'
-+            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'...
- 
-         The ``monomial`` must be exact::
- 
-diff --git a/src/sage/rings/asymptotic/growth_group.py b/src/sage/rings/asymptotic/growth_group.py
-index 27c14592bca..5be12537d62 100644
---- a/src/sage/rings/asymptotic/growth_group.py
-+++ b/src/sage/rings/asymptotic/growth_group.py
-@@ -1572,7 +1572,7 @@ def variable_names(self):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'GenericGrowthGroup_with_category.element_class' object
--            has no attribute 'is_one'
-+            has no attribute 'is_one'...
-         """
-         if self.is_one():
-             return tuple()
-diff --git a/src/sage/rings/ideal.py b/src/sage/rings/ideal.py
-index d36d9406f32..01c9fa3bf2d 100644
---- a/src/sage/rings/ideal.py
-+++ b/src/sage/rings/ideal.py
-@@ -1553,7 +1553,7 @@ def gcd(self, other):
-             sage: J.gcd(I)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Ideal_generic' object has no attribute 'gcd'
-+            AttributeError: 'Ideal_generic' object has no attribute 'gcd'...
- 
-         Note::
- 
-diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
-index 7fe89197011..8832d27e8ea 100644
---- a/src/sage/rings/number_field/number_field.py
-+++ b/src/sage/rings/number_field/number_field.py
-@@ -3823,7 +3823,7 @@ def primes_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
-         """
-         if degree is not None:
-             degree = ZZ(degree)
-@@ -3917,7 +3917,7 @@ def prime_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
- 
-         """
-         ids = self.primes_above(x, degree)
-@@ -5926,7 +5926,7 @@ def factor(self, n):
-             sage: L.factor(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'...
- 
-         AUTHORS:
- 
-@@ -12698,7 +12698,7 @@ def is_real_place(v):
-         sage: is_real_place(v_fin)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'
-+        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'...
- 
-     """
-     RR = sage.rings.real_mpfr.RealField(53)
-diff --git a/src/sage/rings/padics/generic_nodes.py b/src/sage/rings/padics/generic_nodes.py
-index 7047020edec..b6b514d4005 100644
---- a/src/sage/rings/padics/generic_nodes.py
-+++ b/src/sage/rings/padics/generic_nodes.py
-@@ -740,7 +740,7 @@ def _get_element_class(self, name=None):
-             sage: R._get_element_class("foobar")
-             Traceback (most recent call last):
-             ...
--            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'
-+            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'...
-         """
-         if name is None:
-             return self.Element
-diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx
-index c5a1129aecf..a5b7f937cfe 100644
---- a/src/sage/rings/polynomial/polynomial_element.pyx
-+++ b/src/sage/rings/polynomial/polynomial_element.pyx
-@@ -10793,7 +10793,7 @@ cdef class Polynomial(CommutativePolynomial):
-             sage: (y**2 + x).nth_root(2)
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... has no attribute 'nth_root'
-+            AttributeError: ... has no attribute 'nth_root'...
- 
-         TESTS::
- 
-@@ -11831,7 +11831,7 @@ cdef class Polynomial_generic_dense(Polynomial):
-             sage: int(1) // x  # check that this doesn't segfault
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'int' has no attribute 'base_ring'
-+            AttributeError: type object 'int' has no attribute 'base_ring'...
-         """
-         if have_same_parent(self, right):
-             return (<Polynomial_generic_dense>self)._floordiv_(<Polynomial_generic_dense>right)
-diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-index e372be888ee..aca4f08420f 100644
---- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
-+++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-@@ -2362,7 +2362,7 @@ def field_extension(self, names):
-             sage: F, g, h = S.field_extension('b')                                      # needs sage.rings.finite_rings
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'
-+            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'...
- 
-         Over a finite field, the corresponding field extension is not a
-         number field::
-diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx
-index 5273891a5b0..a6e999b8805 100644
---- a/src/sage/rings/ring.pyx
-+++ b/src/sage/rings/ring.pyx
-@@ -1734,7 +1734,7 @@ cdef class IntegralDomain(CommutativeRing):
-             sage: Z5.is_integrally_closed()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'
-+            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'...
-         """
-         raise NotImplementedError
- 
-diff --git a/src/sage/sat/solvers/satsolver.pyx b/src/sage/sat/solvers/satsolver.pyx
-index c2f41b18f55..1c4ac400cb6 100644
---- a/src/sage/sat/solvers/satsolver.pyx
-+++ b/src/sage/sat/solvers/satsolver.pyx
-@@ -375,10 +375,10 @@ def SAT(solver=None, *args, **kwds):
-         DIMACS Solver: 'kissat -q {input}'
-     """
-     if solver is None:
--        import pkgutil
--        if pkgutil.find_loader('pycryptosat') is not None:
-+        from importlib.util import find_spec
-+        if find_spec('pycryptosat') is not None:
-             solver = "cryptominisat"
--        elif pkgutil.find_loader('pycosat') is not None:
-+        elif find_spec('pycosat') is not None:
-             solver = "picosat"
-         else:
-             solver = "LP"
-diff --git a/src/sage/schemes/toric/morphism.py b/src/sage/schemes/toric/morphism.py
-index 1c8944b6dfc..5d64d632f97 100644
---- a/src/sage/schemes/toric/morphism.py
-+++ b/src/sage/schemes/toric/morphism.py
-@@ -246,7 +246,7 @@
-     Traceback (most recent call last):
-     ...
-     AttributeError: 'SchemeMorphism_fan_toric_variety' object
--    has no attribute 'fiber_generic'
-+    has no attribute 'fiber_generic'...
- 
- Let's use factorization mentioned above::
- 
-diff --git a/src/sage/sets/disjoint_union_enumerated_sets.py b/src/sage/sets/disjoint_union_enumerated_sets.py
-index 3dea567a779..5c5e08612f2 100644
---- a/src/sage/sets/disjoint_union_enumerated_sets.py
-+++ b/src/sage/sets/disjoint_union_enumerated_sets.py
-@@ -597,7 +597,7 @@ def Element(self):
-             sage: U.Element
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'
-+            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'...
-         """
-         if not self._facade:
-             return ElementWrapper
-diff --git a/src/sage/sets/set.py b/src/sage/sets/set.py
-index a1789c61300..112d3d8dc3b 100644
---- a/src/sage/sets/set.py
-+++ b/src/sage/sets/set.py
-@@ -163,7 +163,7 @@ def Set(X=None, category=None):
-         sage: sorted(B.list(), key=repr)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'Set_object_with_category' object has no attribute 'list'
-+        AttributeError: 'Set_object_with_category' object has no attribute 'list'...
-         sage: type(B)
-         <class 'sage.sets.set.Set_object_with_category'>
- 
-diff --git a/src/sage/structure/category_object.pyx b/src/sage/structure/category_object.pyx
-index b6a7eaecb5b..c06933494dc 100644
---- a/src/sage/structure/category_object.pyx
-+++ b/src/sage/structure/category_object.pyx
-@@ -836,7 +836,7 @@ cdef class CategoryObject(SageObject):
-             sage: Sets().example().sadfasdf
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'
-+            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'...
-         """
-         return self.getattr_from_category(name)
- 
-diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx
-index caae7e40ffc..543506e9a74 100644
---- a/src/sage/structure/element.pyx
-+++ b/src/sage/structure/element.pyx
-@@ -219,7 +219,7 @@ the parents::
-     sage: x._add_(x)
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-     sage: x + x
-     Traceback (most recent call last):
-     ...
-@@ -478,13 +478,13 @@ cdef class Element(SageObject):
-             sage: 1.blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'...
-             sage: Semigroups().example().an_element().is_idempotent
-             <bound method LeftZeroSemigroup.Element.is_idempotent of 42>
-             sage: Semigroups().example().an_element().blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'
-+            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'...
-         """
-         return self.getattr_from_category(name)
- 
-@@ -1269,7 +1269,7 @@ cdef class Element(SageObject):
-             sage: e._add_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-         """
-         try:
-             python_op = (<object>self)._add_
-@@ -1381,7 +1381,7 @@ cdef class Element(SageObject):
-             sage: e._sub_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'...
-         """
-         try:
-             python_op = (<object>self)._sub_
-@@ -1435,7 +1435,7 @@ cdef class Element(SageObject):
-             sage: e._neg_()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'...
-         """
-         try:
-             python_op = (<object>self)._neg_
-@@ -1549,7 +1549,7 @@ cdef class Element(SageObject):
-             sage: e._mul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'...
-         """
-         try:
-             python_op = (<object>self)._mul_
-@@ -1662,7 +1662,7 @@ cdef class Element(SageObject):
-             sage: e._matmul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'...
-         """
-         try:
-             python_op = (<object>self)._matmul_
-@@ -1765,7 +1765,7 @@ cdef class Element(SageObject):
-             sage: e._div_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'...
-         """
-         try:
-             python_op = (<object>self)._div_
-@@ -1865,7 +1865,7 @@ cdef class Element(SageObject):
-             sage: e._floordiv_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'...
-         """
-         try:
-             python_op = (<object>self)._floordiv_
-@@ -1965,7 +1965,7 @@ cdef class Element(SageObject):
-             sage: e._mod_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'...
-         """
-         try:
-             python_op = (<object>self)._mod_
-@@ -2092,7 +2092,7 @@ cdef class Element(SageObject):
-             sage: e._pow_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'...
-         """
-         try:
-             python_op = (<object>self)._pow_
-@@ -2122,7 +2122,7 @@ cdef class Element(SageObject):
-             sage: e._pow_int(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'...
-         """
-         try:
-             python_op = (<object>self)._pow_int
-@@ -2856,7 +2856,7 @@ cdef class RingElement(ModuleElement):
-             sage: m.is_nilpotent()                                                      # needs sage.modules
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... object has no attribute 'is_nilpotent'
-+            AttributeError: '...' object has no attribute 'is_nilpotent'...
-         """
-         if self.is_unit():
-             return False
-@@ -4671,7 +4671,7 @@ def coerce_binop(method):
-         sage: x.test_add(CC(2))
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'
-+        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'...
- 
-     TESTS:
- 
-diff --git a/src/sage/structure/sequence.py b/src/sage/structure/sequence.py
-index 0c700c1fb81..c3972532ac3 100644
---- a/src/sage/structure/sequence.py
-+++ b/src/sage/structure/sequence.py
-@@ -854,7 +854,7 @@ def __getattr__(self, name):
-             sage: S.universe()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'...
-             sage: S._Sequence__universe = 'foobar'
-             sage: S.universe()
-             'foobar'
-@@ -867,7 +867,7 @@ def __getattr__(self, name):
-             sage: hash(S)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'...
-             sage: S._Sequence__hash = int(34)
-             sage: hash(S)
-             34
-diff --git a/src/sage/symbolic/assumptions.py b/src/sage/symbolic/assumptions.py
-index 7dcb15f0d85..15f6fa07ce6 100644
---- a/src/sage/symbolic/assumptions.py
-+++ b/src/sage/symbolic/assumptions.py
-@@ -636,7 +636,7 @@ def assume(*args):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no
--        attribute 'assume'
-+        attribute 'assume'...
- 
-     Ensure that we can combine the two types of assumptions, as documented::
- 
-diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx
-index 0f251ac4e5c..66f624141b3 100644
---- a/src/sage/symbolic/expression.pyx
-+++ b/src/sage/symbolic/expression.pyx
-@@ -13712,7 +13712,7 @@ cdef get_dynamic_class_for_function(unsigned serial):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.symbolic.expression.Expression' object has no
--        attribute 'argp1'
-+        attribute 'argp1'...
-         sage: t = (e + 1).op[0]; t
-         tfunc(x)
-         sage: t
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index c4152e092e3..4bcf45e8793 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -67,6 +67,7 @@
- #include "archive.h"
- #include "tostring.h"
- #include "utils.h"
-+#include "../../cpython/pycore_long.h"
- 
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wdeprecated-register"
-@@ -706,18 +707,12 @@ static long _mpq_pythonhash(mpq_t the_rat)
- // Initialize an mpz_t from a Python long integer
- static void _mpz_set_pylong(mpz_t z, PyLongObject* l)
- {
--    Py_ssize_t pylong_size = Py_SIZE(l);
--    int sign = 1;
--
--    if (pylong_size < 0) {
--        pylong_size = -pylong_size;
--        sign = -1;
--    }
-+    Py_ssize_t pylong_size = _PyLong_DigitCount(l);
- 
-     mpz_import(z, pylong_size, -1, sizeof(digit), 0,
--               8*sizeof(digit) - PyLong_SHIFT, l->ob_digit);
-+               8*sizeof(digit) - PyLong_SHIFT, ob_digit(l));
- 
--    if (sign < 0)
-+    if (_PyLong_IsNegative(l))
-         mpz_neg(z, z);
- }
- 
-diff --git a/src/sage/symbolic/pynac_impl.pxi b/src/sage/symbolic/pynac_impl.pxi
-index 68c31dcfde7..7fd7c3b314b 100644
---- a/src/sage/symbolic/pynac_impl.pxi
-+++ b/src/sage/symbolic/pynac_impl.pxi
-@@ -619,7 +619,7 @@ def tolerant_is_symbol(a):
-         sage: None.is_symbol()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute 'is_symbol'
-+        AttributeError: 'NoneType' object has no attribute 'is_symbol'...
-     """
-     try:
-         return a.is_symbol()
diff --git a/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch b/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
new file mode 100644
index 0000000000000..1e695c2d9d106
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
@@ -0,0 +1,134 @@
+diff --git a/src/sage/quadratic_forms/quadratic_form__neighbors.py b/src/sage/quadratic_forms/quadratic_form__neighbors.py
+index fb781e20122..ec853cd52ef 100644
+--- a/src/sage/quadratic_forms/quadratic_form__neighbors.py
++++ b/src/sage/quadratic_forms/quadratic_form__neighbors.py
+@@ -74,6 +74,10 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+         sage: v = Q.find_primitive_p_divisible_vector__next(5, v); v
+         (1, 0)
+         sage: v = Q.find_primitive_p_divisible_vector__next(5, v); v
++        sage: v = Q.find_primitive_p_divisible_vector__next(2) ; v
++        (0, 1)
++        sage: v = Q.find_primitive_p_divisible_vector__next(2, v) ; v
++        (1, 0)
+         sage: Q = QuadraticForm(QQ, matrix.diagonal([1,1,1,1]))
+         sage: v = Q.find_primitive_p_divisible_vector__next(2)
+         sage: Q(v)
+@@ -83,6 +87,9 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+     n = self.dim()
+     if v is None:
+         w = vector(ZZ, [0] * (n - 1) + [1])
++        a = self(w)
++        if a in ZZ and (a % p == 0):
++            return w
+     else:
+         w = deepcopy(v)
+ 
+@@ -132,7 +139,7 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+             return w
+ 
+ 
+-def find_p_neighbor_from_vec(self, p, y):
++def find_p_neighbor_from_vec(self, p, y, return_matrix=False):
+     r"""
+     Return the `p`-neighbor of ``self`` defined by ``y``.
+ 
+@@ -147,25 +154,32 @@ def find_p_neighbor_from_vec(self, p, y):
+     - ``p`` -- a prime number
+     - ``y`` -- a vector with `q(y) \in p \ZZ`
+     - ``odd`` -- (default: ``False``) if `p=2`, return also odd neighbors
++    - ``return_matrix`` -- (boolean, default ``False``) return
++      the transformation matrix instead of the quadratic form
+ 
+     EXAMPLES::
+ 
++        sage: # needs sage.libs.pari
+         sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1,1])
+         sage: v = vector([0,2,1,1])
+-        sage: X = Q.find_p_neighbor_from_vec(3, v); X                                   # needs sage.libs.pari
++        sage: X = Q.find_p_neighbor_from_vec(3, v); X
+         Quadratic form in 4 variables over Integer Ring with coefficients:
+         [ 1 0 0 0 ]
+         [ * 1 4 4 ]
+         [ * * 5 12 ]
+         [ * * * 9 ]
++        sage: B = Q.find_p_neighbor_from_vec(3, v, return_matrix=True)
++        sage: Q(B) == X
++        True
+ 
+     Since the base ring and the domain are not yet separate,
+     for rational, half integral forms we just pretend
+     the base ring is `\ZZ`::
+ 
++        sage: # needs sage.libs.pari
+         sage: Q = QuadraticForm(QQ, matrix.diagonal([1,1,1,1]))
+         sage: v = vector([1,1,1,1])
+-        sage: Q.find_p_neighbor_from_vec(2, v)                                          # needs sage.libs.pari
++        sage: Q.find_p_neighbor_from_vec(2, v)
+         Quadratic form in 4 variables over Rational Field with coefficients:
+         [ 1/2 1 1 1 ]
+         [ * 1 1 2 ]
+@@ -227,9 +241,12 @@ def find_p_neighbor_from_vec(self, p, y):
+     # by definition this is the p-neighbor of L at y
+     # assert B.det().abs() == 1
+ 
+-    QF = self.parent()
+-    Gnew = (B*G*B.T).change_ring(R)
+-    return QF(Gnew)
++    if return_matrix:
++        return B.T
++    else:
++        QF = self.parent()
++        Gnew = (B*G*B.T).change_ring(R)
++        return QF(Gnew)
+ 
+ 
+ def neighbor_iteration(seeds, p, mass=None, max_classes=ZZ(10)**3,
+diff --git a/src/sage/quadratic_forms/ternary.pyx b/src/sage/quadratic_forms/ternary.pyx
+index 28dd9514c30..6e7c4389083 100644
+--- a/src/sage/quadratic_forms/ternary.pyx
++++ b/src/sage/quadratic_forms/ternary.pyx
+@@ -955,7 +955,26 @@ def extend(v):
+         [ 30   0  -7]
+         sage: M.det()
+         2
++
++    TESTS::
++
++        sage: M = matrix(3, extend( (0, 0, 1) ))
++        sage: M.det()
++        1
++        sage: M.column(0)
++        (0, 0, 1)
++        sage: M = matrix(3, extend( (0, 0, -2) ))
++        sage: M.det()
++        2
++        sage: M.column(0)
++        (0, 0, -2)
+     """
++    if v[0] == v[1] == 0:
++        if v[2] < 0:
++            return v[0], 0, 1,  v[1], 1, 0,  v[2], 0, 0
++        else:
++            return v[0], 1, 0,  v[1], 0, 1,  v[2], 0, 0
++
+     b1 = xgcd(v[0], v[1])
+     b2 = xgcd(b1[1], b1[2])
+     b3 = xgcd(b1[0], v[2])
+diff --git a/src/sage/quadratic_forms/ternary_qf.py b/src/sage/quadratic_forms/ternary_qf.py
+index fa4499566a9..2f3a57fa713 100644
+--- a/src/sage/quadratic_forms/ternary_qf.py
++++ b/src/sage/quadratic_forms/ternary_qf.py
+@@ -918,6 +918,13 @@ def find_p_neighbor_from_vec(self, p, v, mat=False):
+             [     0  -3/11  13/11]
+             sage: Q(M) == Q11
+             True
++
++        Test that it works with (0, 0, 1)::
++
++            sage: Q.find_p_neighbor_from_vec(3, (0,0,1))
++            Ternary quadratic form with integer coefficients:
++            [1 3 3]
++            [-2 0 -1]
+         """
+         if mat:
+             q, M = _find_p_neighbor_from_vec(self._a, self._b, self._c, self._r, self._s, self._t, p, v, mat)
diff --git a/srcpkgs/sagemath/patches/get_patches b/srcpkgs/sagemath/patches/get_patches
index 95a6963432948..c5ee28f6eb10c 100755
--- a/srcpkgs/sagemath/patches/get_patches
+++ b/srcpkgs/sagemath/patches/get_patches
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-version=10.1
+version=10.2.beta9
 
 URL_BASE_PR="https://github.com/sagemath/sage/pull/"
 URL_BASE_COMPARE="https://github.com/sagemath/sage/compare/${version}..."
@@ -20,24 +20,15 @@ get_pr() {
 # run from patches dir
 cd $(dirname "$0")
 
-# merged in 10.2.beta0
-#get_pr  36018   "singular 4.3.2p4" # included in #35934
-get_pr  36046   "fix memory leak"
-
-# merged in 10.2.beta1
-get_pr  35934   "singular 4.3.2p7"
-
-# merged in 10.2.beta2
-get_pr  36006   "gmp 6.3.0"
-
-# merged in 10.2.beta3
-get_pr  36235   "ecl 23.9.9"
-
-# merged in 10.2.beta4
-get_pr  36279   "matplotlib 3.8.0"
+# merged in 10.2.rc0
+#get_pr  36544   "networkx 3.2"
+#get_pr  36543   "cython warning"
+#get_pr  36573   "relative imports"
+#get_pr  36600   "giac 1.9.0-67"
 
 # positive review
-#get_pr  36403   "python 3.12" # included in #36407
 
 # needs review
-get_pr  36407   "python 3.12"
+get_pr  35848   "flintlib 3.0"
+get_pr  36551   "fix qf.nbs"
+get_pr  36696   "fix SSL timeout"
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index a80d8b7187ece..7bc286b1b07a3 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,14 +1,14 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=10.1
-revision=4
+version=10.2.rc3
+revision=1
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
 _bindir=/usr/lib/sagemath/$version/bin
 make_install_args="--install-scripts=$_bindir"
-hostmakedepends="m4 pkg-config python3-Cython0.29 python3-Jinja2
+hostmakedepends="m4 pkg-config python3-Cython python3-Jinja2
  python3-pkgconfig python3-setuptools"
-makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
+makedepends="boost-devel brial-devel cliquer-devel ecl eclib-devel
  ecm-devel fflas-ffpack flintlib-devel gap-devel gd-devel giac-devel glpk-devel
  gsl-devel iml-devel lcalc-devel libbraiding-devel libhomfly-devel libmpc-devel
  libpng-devel linbox-devel m4ri-devel m4rie-devel mpfi-devel
@@ -18,7 +18,7 @@ makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
 depends="eclib-devel fflas-ffpack flintlib-devel gcc-fortran gd-devel
  gfan giac gsl-devel gzip libpng-devel linbox-devel m4ri-devel maxima-ecl
  mpfr-devel nauty ntl-devel palp pari-devel pari-elldata-small pari-galdata
- pari-galpol-small pari-seadata-small pkg-config python3-Cython0.29 python3-cypari2
+ pari-galpol-small pari-seadata-small pkg-config python3-Cython python3-cypari2
  python3-cysignals python3-devel python3-fpylll python3-ipython python3-lrcalc
  python3-ipython_ipykernel python3-jupyter_ipywidgets python3-matplotlib
  python3-memory_allocator python3-networkx python3-pip python3-pkgconfig
@@ -33,7 +33,7 @@ license="GPL-2.0-or-later"
 homepage="https://www.sagemath.org/"
 changelog="https://github.com/sagemath/sage/releases"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=a658612b1b2376ddaf207cc8ed0ef458d4c2880c16e19139bedbe8baa42ad62f
+checksum=7735119d7d9c7e191ea0c308d11714ffd5d4dc98d71ecc487b2606ac43376c2d
 nocross="due to ntl (flintlib), fflas-ffpack, givaro, linbox, cysignals, sympow, maxima"
 
 post_patch() {
diff --git a/srcpkgs/sagemath/update b/srcpkgs/sagemath/update
index 68be3c5752d06..4e62503e2f8f4 100644
--- a/srcpkgs/sagemath/update
+++ b/srcpkgs/sagemath/update
@@ -1,2 +1,3 @@
 pkgname="sage"
-site="https://mirrors.mit.edu/sage/src/index.html"
+site="https://mirrors.mit.edu/sage/src/
+https://mirrors.mit.edu/sage/devel/"

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

* Re: [PR PATCH] [Updated] [RC] sagemath: update to 10.2, flintlib: update to 3.0.1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (14 preceding siblings ...)
  2023-11-16  1:19 ` [PR PATCH] [Updated] " tornaria
@ 2023-11-18  4:51 ` tornaria
  2023-11-19 18:06 ` [PR REVIEW] " dkwo
                   ` (12 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: tornaria @ 2023-11-18  4:51 UTC (permalink / raw)
  To: ml

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

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

https://github.com/tornaria/void-packages flintlib
https://github.com/void-linux/void-packages/pull/46832

[RC] sagemath: update to 10.2, flintlib: update to 3.0.1
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **briefly**

This is a major update. A couple of packages need rebuilding (eclib, singular).

For sagemath, we need a patch (in progress: https://github.com/sagemath/sage/pull/35848).

Since backporting patches is a pain and we are not in a hurry, I'm instead targeting 10.2.beta8. Note this already moves sagemath to cython 3.

The goal is to merge flintlib 3.0 together with sagemath 10.2 when the latter is released.

<!--
#### 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/46832.patch is attached

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

From d29176cf93f5f4adb5cfa63207bb03c36cb56617 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 11 Sep 2023 20:11:20 -0300
Subject: [PATCH 1/6] flintlib: update to 3.0.1.

---
 common/shlibs                                 |  3 +--
 srcpkgs/arb                                   |  1 +
 srcpkgs/arb-devel                             |  2 +-
 srcpkgs/arb/template                          | 24 -------------------
 .../patches/fix-test-t-sdiv_qrnnd.patch       | 23 ------------------
 srcpkgs/flintlib/template                     | 21 ++++++++++++----
 6 files changed, 20 insertions(+), 54 deletions(-)
 create mode 120000 srcpkgs/arb
 delete mode 100644 srcpkgs/arb/template
 delete mode 100644 srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch

diff --git a/common/shlibs b/common/shlibs
index c4a090b04798f..e09c070b7068d 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3971,8 +3971,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.17 flintlib-2.9.0_1
-libarb.so.2 arb-2.20.0_1
+libflint.so.18 flintlib-3.0.0_1
 libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
diff --git a/srcpkgs/arb b/srcpkgs/arb
new file mode 120000
index 0000000000000..7c2633183069f
--- /dev/null
+++ b/srcpkgs/arb
@@ -0,0 +1 @@
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb-devel b/srcpkgs/arb-devel
index 456b9f00a86cd..7c2633183069f 120000
--- a/srcpkgs/arb-devel
+++ b/srcpkgs/arb-devel
@@ -1 +1 @@
-arb
\ No newline at end of file
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
deleted file mode 100644
index 84a62c7ffdba3..0000000000000
--- a/srcpkgs/arb/template
+++ /dev/null
@@ -1,24 +0,0 @@
-# Template file for 'arb'
-pkgname=arb
-version=2.23.0
-revision=1
-build_style=configure
-configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
-makedepends="flintlib-devel"
-short_desc="C library for arbitrary-precision interval arithmetic"
-maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
-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=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
-
-arb-devel_package() {
-	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"
-	short_desc+=" - development files"
-	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.a"
-		vmove "usr/lib/*.so"
-	}
-}
diff --git a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch b/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
deleted file mode 100644
index cfa109792892c..0000000000000
--- a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From fb8ddbcc06afa2a8f25637032fbb8211f6c6c122 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= <albin.ahlback@gmail.com>
-Date: Fri, 20 May 2022 14:16:38 +0200
-Subject: [PATCH] Fix bug in test code for GCC 12
-
----
- test/t-sdiv_qrnnd.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/test/t-sdiv_qrnnd.c b/test/t-sdiv_qrnnd.c
-index 2e9822e848..2676903826 100644
---- a/test/t-sdiv_qrnnd.c
-+++ b/test/t-sdiv_qrnnd.c
-@@ -33,7 +33,7 @@ int main(void)
-         {
-             d = n_randtest_not_zero(state);
-             nh = n_randtest(state);
--        } while ((FLINT_ABS(nh) >= FLINT_ABS(d)/2) || (nh == WORD_MIN));
-+        } while ((nh == WORD_MIN) || (FLINT_ABS(nh) >= FLINT_ABS(d)/2));
- 
-         nl = n_randtest(state);
- 
-
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index f7442c8052aaa..254d18c42f5b3 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,10 +1,10 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.9.0
+version=3.0.1
 revision=1
-build_style=configure
+build_style=gnu-configure
 configure_args="--prefix=/usr $(vopt_with ntl)
- $(vopt_if openblas --with-blas=${XBPS_CROSS_BASE}/usr/include/openblas)"
+ $(vopt_if openblas --with-blas-include=${XBPS_CROSS_BASE}/usr/include/openblas)"
 makedepends="mpfr-devel $(vopt_if ntl ntl-devel)
  $(vopt_if openblas openblas-devel)"
 short_desc="Fast Library for Number Theory"
@@ -13,7 +13,7 @@ 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=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
+checksum=7b311a00503a863881eb8177dbeb84322f29399f3d7d72f3b1a4c9ba1d5794b4
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
@@ -33,7 +33,20 @@ flintlib-devel_package() {
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
+		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
 		vmove "usr/lib/*.so"
 	}
 }
+
+arb_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}
+
+arb-devel_package() {
+	depends="${sourcepkg}-devel>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From e98158998898d1cd07fa428eb795d9d605215551 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:08:05 -0300
Subject: [PATCH 2/6] eclib: rebuild for flintlib-3.0.1

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

diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 1d4ad58f21b7b..12165ca788dd5 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
 version=20230424
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 makedepends="pari-devel ntl-devel flintlib-devel boost-devel"

From 3a1223aa50ec1a81fd93ec46e42259820b30720f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:13:15 -0300
Subject: [PATCH 3/6] singular: update to 4.3.2p10.

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

diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index 036e19d470354..beb0e6d30118e 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,6 +1,6 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.2p7
+version=4.3.2p10
 revision=1
 _majver=${version%p*}
 build_style=gnu-configure
@@ -20,7 +20,7 @@ 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/${_majver//./-}/singular-${version}.tar.gz"
-checksum=aad23c30066b7fbc011138a98d60532565d76a847eec6bf2938410d93b272ca3
+checksum=28c2c9fcfee954e00dfa56eb1a7d418d5b1de67c4398d25a0f2b8f73e71552a8
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From b9f45df3d18f9dc85f83bc618607d2a78023692e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 19 Jul 2023 21:04:33 -0300
Subject: [PATCH 4/6] python3-pplpy: use cython 3.

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

diff --git a/srcpkgs/python3-pplpy/template b/srcpkgs/python3-pplpy/template
index 4a9c987b2a859..d3b9aebdf2237 100644
--- a/srcpkgs/python3-pplpy/template
+++ b/srcpkgs/python3-pplpy/template
@@ -1,9 +1,9 @@
 # Template file for 'python3-pplpy'
 pkgname=python3-pplpy
 version=0.8.9
-revision=1
+revision=2
 build_style=python3-pep517
-hostmakedepends="python3-setuptools python3-wheel python3-Cython0.29
+hostmakedepends="python3-setuptools python3-wheel python3-Cython
  python3-cysignals python3-gmpy2"
 makedepends="python3-devel gmp-devel gmpxx-devel ppl-devel mpfr-devel
  libmpc-devel pari-devel"

From 0433006ac056fcd1d7ae28037d37b72f62dc4d2e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Thu, 19 Oct 2023 08:52:15 -0300
Subject: [PATCH 5/6] python3-networkx: update to 3.2.1.

---
 srcpkgs/python3-networkx/template | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/python3-networkx/template b/srcpkgs/python3-networkx/template
index 186bf64f7bff9..29283d9e5a032 100644
--- a/srcpkgs/python3-networkx/template
+++ b/srcpkgs/python3-networkx/template
@@ -1,11 +1,11 @@
 # Template file for 'python3-networkx'
 pkgname=python3-networkx
-version=3.1
-revision=2
-build_style=python3-module
+version=3.2.1
+revision=1
+build_style=python3-pep517
 # failing in i686
 make_check_args="--deselect networkx/algorithms/approximation/tests/test_traveling_salesman.py::test_asadpour_tsp"
-hostmakedepends="python3-setuptools"
+hostmakedepends="python3-setuptools python3-wheel"
 depends="python3"
 checkdepends="python3-numpy python3-scipy python3-matplotlib python3-pandas
  python3-lxml python3-sympy python3-pytest-xdist"
@@ -15,7 +15,7 @@ license="BSD-3-Clause"
 homepage="https://networkx.org"
 changelog="https://github.com/networkx/networkx/raw/main/doc/release/release_${version}.rst"
 distfiles="${PYPI_SITE}/n/networkx/networkx-${version}.tar.gz"
-checksum=de346335408f84de0eada6ff9fafafff9bcda11f0a0dfaa931133debb146ab61
+checksum=9f1bb5cf3409bf324e0a722c20bdb4c20ee39bf1c30ce8ae499c8502b0b5e0c6
 
 post_install() {
 	vlicense LICENSE.txt

From 7c598079a6d43ee581d1a694d9724dd088bb02f7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:50:44 -0300
Subject: [PATCH 6/6] sagemath: update to 10.2.rc4.

---
 .../sagemath/patches/35848-flintlib_3.0.patch | 1867 +++++++++++++++++
 .../patches/35934-singular_4.3.2p7.patch      |  221 --
 .../sagemath/patches/36006-gmp_6.3.0.patch    |   38 -
 .../patches/36046-fix_memory_leak.patch       |  740 -------
 .../sagemath/patches/36235-ecl_23.9.9.patch   |   39 -
 .../patches/36279-matplotlib_3.8.0.patch      |   24 -
 srcpkgs/sagemath/patches/36403-00pre.patch    |   29 -
 .../sagemath/patches/36407-python_3.12.patch  | 1744 ---------------
 .../sagemath/patches/36551-fix_qf.nbs.patch   |  134 ++
 srcpkgs/sagemath/patches/get_patches          |   22 +-
 srcpkgs/sagemath/template                     |   12 +-
 srcpkgs/sagemath/update                       |    3 +-
 12 files changed, 2012 insertions(+), 2861 deletions(-)
 create mode 100644 srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
 delete mode 100644 srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
 delete mode 100644 srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
 delete mode 100644 srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36403-00pre.patch
 delete mode 100644 srcpkgs/sagemath/patches/36407-python_3.12.patch
 create mode 100644 srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch

diff --git a/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
new file mode 100644
index 0000000000000..2cad28134f6e6
--- /dev/null
+++ b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
@@ -0,0 +1,1867 @@
+diff --git a/build/pkgs/antic/SPKG.rst b/build/pkgs/antic/SPKG.rst
+deleted file mode 100644
+index d6c32377957..00000000000
+--- a/build/pkgs/antic/SPKG.rst
++++ /dev/null
+@@ -1,18 +0,0 @@
+-antic: Algebraic Number Theory In C
+-===================================
+-
+-Description
+------------
+-
+-Algebraic Number Theory In C
+-
+-License
+--------
+-
+-LGPL 2.1
+-
+-Upstream Contact
+-----------------
+-
+-https://github.com/wbhart/antic
+-
+diff --git a/build/pkgs/antic/checksums.ini b/build/pkgs/antic/checksums.ini
+deleted file mode 100644
+index fc8711ecd13..00000000000
+--- a/build/pkgs/antic/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=antic-VERSION.tar.gz
+-sha1=940d8ea2c3512b9d49ee3101cf043f777764bd8f
+-md5=4e896420dd6344b53b307871efb2cbb4
+-cksum=1938565125
+-upstream_url=https://github.com/wbhart/antic/archive/refs/tags/vVERSION.tar.gz
+diff --git a/build/pkgs/antic/dependencies b/build/pkgs/antic/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/antic/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/antic/distros/arch.txt b/build/pkgs/antic/distros/arch.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/conda.txt b/build/pkgs/antic/distros/conda.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/debian.txt b/build/pkgs/antic/distros/debian.txt
+deleted file mode 100644
+index 8fdcd3e5721..00000000000
+--- a/build/pkgs/antic/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libantic-dev
+diff --git a/build/pkgs/antic/distros/fedora.txt b/build/pkgs/antic/distros/fedora.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/freebsd.txt b/build/pkgs/antic/distros/freebsd.txt
+deleted file mode 100644
+index 116ff3a26f3..00000000000
+--- a/build/pkgs/antic/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/antic
+diff --git a/build/pkgs/antic/distros/opensuse.txt b/build/pkgs/antic/distros/opensuse.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/repology.txt b/build/pkgs/antic/distros/repology.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/package-version.txt b/build/pkgs/antic/package-version.txt
+deleted file mode 100644
+index 3a4036fb450..00000000000
+--- a/build/pkgs/antic/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-0.2.5
+diff --git a/build/pkgs/antic/spkg-install.in b/build/pkgs/antic/spkg-install.in
+deleted file mode 100644
+index c57fa884a20..00000000000
+--- a/build/pkgs/antic/spkg-install.in
++++ /dev/null
+@@ -1,19 +0,0 @@
+-cd src
+-
+-# Copied from build/pkgs/flint/spkg-install.in:
+-#   Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-#   --with-ntl because otherwise FLINT's configure script uses
+-#   /usr/local, which is always wrong.
+-#   This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-#   The value $SAGE_LOCAL is always a safe choice even if the library
+-#   is coming from the system and is found using what is in
+-#   LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-flint="$SAGE_LOCAL"  || sdh_die "Error: Failed to configure antic."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/antic/type b/build/pkgs/antic/type
+deleted file mode 100644
+index 134d9bc32d5..00000000000
+--- a/build/pkgs/antic/type
++++ /dev/null
+@@ -1 +0,0 @@
+-optional
+diff --git a/build/pkgs/arb/SPKG.rst b/build/pkgs/arb/SPKG.rst
+deleted file mode 100644
+index cff49ddb95b..00000000000
+--- a/build/pkgs/arb/SPKG.rst
++++ /dev/null
+@@ -1,27 +0,0 @@
+-arb: Arbitrary-precision floating-point ball arithmetic
+-=======================================================
+-
+-Description
+------------
+-
+-Arb is a C library for arbitrary-precision floating-point ball
+-arithmetic, developed by Fredrik Johansson
+-(fredrik.johansson@gmail.com). It supports efficient high-precision
+-computation with polynomials, power series, matrices and special
+-functions over the real and complex numbers, with automatic, rigorous
+-error control.
+-
+-License
+--------
+-
+-GNU General Public License v2+
+-
+-
+-Upstream Contact
+-----------------
+-
+- - Fredrik Johansson: fredrik.johansson@gmail.com
+-
+- - https://arblib.org/
+-
+- - http://github.com/fredrik-johansson/arb/
+diff --git a/build/pkgs/arb/checksums.ini b/build/pkgs/arb/checksums.ini
+deleted file mode 100644
+index 80ef43dad5d..00000000000
+--- a/build/pkgs/arb/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=arb-VERSION.tar.gz
+-sha1=a1efe035dd3af3613dd685971a156f652b86ff63
+-md5=9b369e29f93cdf2d4f90b57a92526cce
+-cksum=64252121
+-upstream_url=https://github.com/fredrik-johansson/arb/archive/VERSION.tar.gz
+diff --git a/build/pkgs/arb/dependencies b/build/pkgs/arb/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/arb/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/arb/distros/arch.txt b/build/pkgs/arb/distros/arch.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/conda.txt b/build/pkgs/arb/distros/conda.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/debian.txt b/build/pkgs/arb/distros/debian.txt
+deleted file mode 100644
+index 9fe71110712..00000000000
+--- a/build/pkgs/arb/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libflint-arb-dev
+diff --git a/build/pkgs/arb/distros/fedora.txt b/build/pkgs/arb/distros/fedora.txt
+deleted file mode 100644
+index 76794404627..00000000000
+--- a/build/pkgs/arb/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb arb-devel
+diff --git a/build/pkgs/arb/distros/freebsd.txt b/build/pkgs/arb/distros/freebsd.txt
+deleted file mode 100644
+index 2ef8c7cec0f..00000000000
+--- a/build/pkgs/arb/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/arb
+diff --git a/build/pkgs/arb/distros/gentoo.txt b/build/pkgs/arb/distros/gentoo.txt
+deleted file mode 100644
+index 58e3d4f8008..00000000000
+--- a/build/pkgs/arb/distros/gentoo.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-sci-mathematics/arb
+diff --git a/build/pkgs/arb/distros/homebrew.txt b/build/pkgs/arb/distros/homebrew.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/homebrew.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/nix.txt b/build/pkgs/arb/distros/nix.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/nix.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/opensuse.txt b/build/pkgs/arb/distros/opensuse.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/distros/repology.txt b/build/pkgs/arb/distros/repology.txt
+deleted file mode 100644
+index 179c9d507e1..00000000000
+--- a/build/pkgs/arb/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-fp
+diff --git a/build/pkgs/arb/distros/void.txt b/build/pkgs/arb/distros/void.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/void.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/package-version.txt b/build/pkgs/arb/package-version.txt
+deleted file mode 100644
+index e9763f6bfed..00000000000
+--- a/build/pkgs/arb/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-2.23.0
+diff --git a/build/pkgs/arb/spkg-check.in b/build/pkgs/arb/spkg-check.in
+deleted file mode 100644
+index 27cd9419538..00000000000
+--- a/build/pkgs/arb/spkg-check.in
++++ /dev/null
+@@ -1,2 +0,0 @@
+-cd src
+-$MAKE check
+diff --git a/build/pkgs/arb/spkg-configure.m4 b/build/pkgs/arb/spkg-configure.m4
+deleted file mode 100644
+index ef2dd0aac4a..00000000000
+--- a/build/pkgs/arb/spkg-configure.m4
++++ /dev/null
+@@ -1,23 +0,0 @@
+-SAGE_SPKG_CONFIGURE([arb], [
+-    AC_REQUIRE([SAGE_SPKG_CONFIGURE_FLINT])
+-    SAGE_ARB_LIBRARY="arb"
+-    AC_MSG_CHECKING([installing flint? ])
+-    if test x$sage_spkg_install_flint = xyes; then
+-        AC_MSG_RESULT([yes; install arb as well])
+-        sage_spkg_install_arb=yes
+-    else
+-        AC_CHECK_HEADER(arb.h, [
+-        dnl below function added in version 2.16 of arb
+-            AC_CHECK_LIB([arb], [acb_mat_eig_simple], [],
+-              [dnl in Debian the name of dylib is different.
+-               AC_CHECK_LIB([flint-arb], [acb_mat_eig_simple],
+-                [SAGE_ARB_LIBRARY="flint-arb"], [sage_spkg_install_arb=yes])])
+-        ], [sage_spkg_install_arb=yes])
+-    fi
+-], [], [], [
+-    if test x$sage_spkg_install_arb = xyes; then
+-        AC_SUBST(SAGE_ARB_LIBRARY,["arb"])
+-    else
+-        AC_SUBST(SAGE_ARB_LIBRARY,[$SAGE_ARB_LIBRARY])
+-    fi
+-])
+diff --git a/build/pkgs/arb/spkg-install.in b/build/pkgs/arb/spkg-install.in
+deleted file mode 100644
+index 9322f04c912..00000000000
+--- a/build/pkgs/arb/spkg-install.in
++++ /dev/null
+@@ -1,17 +0,0 @@
+-cd src
+-
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-flint because otherwise ARB's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure --disable-static --prefix="$SAGE_LOCAL" \
+-        --with-gmp="$SAGE_LOCAL" \
+-        --with-mpfr="$SAGE_LOCAL" \
+-        --with-flint="$SAGE_LOCAL" || \
+-    sdh_die "Error configuring arb."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/arb/type b/build/pkgs/arb/type
+deleted file mode 100644
+index a6a7b9cd726..00000000000
+--- a/build/pkgs/arb/type
++++ /dev/null
+@@ -1 +0,0 @@
+-standard
+diff --git a/build/pkgs/e_antic/dependencies b/build/pkgs/e_antic/dependencies
+index fea1ffbda45..8e977a55c13 100644
+--- a/build/pkgs/e_antic/dependencies
++++ b/build/pkgs/e_antic/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) flint arb antic boost_cropped
++$(MP_LIBRARY) flint boost_cropped
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/SPKG.rst b/build/pkgs/flint/SPKG.rst
+index f91de70d1ff..d9dcea0903b 100644
+--- a/build/pkgs/flint/SPKG.rst
++++ b/build/pkgs/flint/SPKG.rst
+@@ -4,8 +4,8 @@ flint: Fast Library for Number Theory
+ Description
+ -----------
+ 
+-FLINT is a C library for doing number theory, maintained by William
+-Hart.
++FLINT is a C library for doing number theory, maintained by
++Fredrik Johansson.
+ 
+ Website: http://www.flintlib.org
+ 
+@@ -20,4 +20,4 @@ Upstream Contact
+ 
+ -  flint-devel Gougle Group
+    (http://groups.google.co.uk/group/flint-devel)
+--  William Hart
++-  Fredrik Johansson
+diff --git a/build/pkgs/flint/checksums.ini b/build/pkgs/flint/checksums.ini
+index 3d449d98064..ab836606657 100644
+--- a/build/pkgs/flint/checksums.ini
++++ b/build/pkgs/flint/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=flint-VERSION.tar.gz
+-sha1=63d90f8242c8f8ab4011fbcfb44b86c154f43abd
+-md5=c2d3cec326438f159a530c66eb07fafe
+-cksum=4244948341
+-upstream_url=http://flintlib.org/flint-VERSION.tar.gz
++sha1=65be9297c06edd7e24f20874b7bd6130cee56723
++md5=5189f67b0ec12e4a54d6782851642b81
++cksum=172350473
++upstream_url=https://github.com/flintlib/flint/releases/download/vVERSION/flint-VERSION.tar.gz
+diff --git a/build/pkgs/flint/dependencies b/build/pkgs/flint/dependencies
+index 385df4faa7d..1108dc4fb21 100644
+--- a/build/pkgs/flint/dependencies
++++ b/build/pkgs/flint/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) mpfr ntl
++$(MP_LIBRARY) mpfr
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/package-version.txt b/build/pkgs/flint/package-version.txt
+index c8e38b61405..cb2b00e4f7a 100644
+--- a/build/pkgs/flint/package-version.txt
++++ b/build/pkgs/flint/package-version.txt
+@@ -1 +1 @@
+-2.9.0
++3.0.1
+diff --git a/build/pkgs/flint/patches/0001-Makefile.in-fix-handling-of-DESTDIR.patch b/build/pkgs/flint/patches/0001-Makefile.in-fix-handling-of-DESTDIR.patch
+new file mode 100644
+index 00000000000..48a32f5d894
+--- /dev/null
++++ b/build/pkgs/flint/patches/0001-Makefile.in-fix-handling-of-DESTDIR.patch
+@@ -0,0 +1,106 @@
++From 54277f054f13254898c9a57c2c7eb869877e1252 Mon Sep 17 00:00:00 2001
++From: Marc Mezzarobba <marc@mezzarobba.net>
++Date: Mon, 13 Nov 2023 10:23:54 +0100
++Subject: [PATCH] Makefile.in: fix handling of $DESTDIR
++
++---
++ Makefile.in | 54 ++++++++++++++++++++++++++---------------------------
++ 1 file changed, 27 insertions(+), 27 deletions(-)
++
++diff --git a/Makefile.in b/Makefile.in
++index 08db6837c..2827b9da1 100644
++--- a/Makefile.in
+++++ b/Makefile.in
++@@ -34,9 +34,9 @@ FLINT_SOLIB:=@FLINT_SOLIB@
++ prefix:=@prefix@
++ exec_prefix:=@exec_prefix@
++ 
++-INCLUDEDIR:=$(DESTDIR)@includedir@
++-LIBDIR:=$(DESTDIR)@libdir@
++-BINDIR:=$(DESTDIR)@bindir@
+++INCLUDEDIR:=@includedir@
+++LIBDIR:=@libdir@
+++BINDIR:=@bindir@
++ PKGCONFIGDIR:=$(LIBDIR)/pkgconfig
++ 
++ HOST_OS:=@host_os@
++@@ -202,10 +202,10 @@ BUILD_DIRS +=                                                               \
++ endif
++ 
++ INSTALL_DIRS :=                                                             \
++-        $(LIBDIR)                       $(INCLUDEDIR)/flint                 \
++-        $(PKGCONFIGDIR)
+++        $(DESTDIR)$(LIBDIR)             $(DESTDIR)$(INCLUDEDIR)/flint       \
+++        $(DESTDIR)$(PKGCONFIGDIR)
++ ifneq ($(FLINT_DLLLIB),0)
++-INSTALL_DIRS += $(BINDIR)
+++INSTALL_DIRS += $(DESTDIR)$(BINDIR)
++ endif
++ 
++ ################################################################################
++@@ -722,41 +722,41 @@ distclean: clean
++ ################################################################################
++ 
++ install: library | $(INSTALL_DIRS)
++-	$(CP) flint.pc $(PKGCONFIGDIR)/flint.pc
+++	$(CP) flint.pc $(DESTDIR)$(PKGCONFIGDIR)/flint.pc
++ ifneq ($(SHARED), 0)
++ ifneq ($(FLINT_DLLLIB),0)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(BINDIR)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(BINDIR)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(BINDIR)
++-	$(CP) $(FLINT_DIR)/$(FLINT_IMPLIB) $(LIBDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(DESTDIR)$(BINDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(DESTDIR)$(BINDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(DESTDIR)$(BINDIR)
+++	$(CP) $(FLINT_DIR)/$(FLINT_IMPLIB) $(DESTDIR)$(LIBDIR)
++ else
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(LIBDIR)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(LIBDIR)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(LIBDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(DESTDIR)$(LIBDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(DESTDIR)$(LIBDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(DESTDIR)$(LIBDIR)
++ endif
++ ifneq ($(FLINT_DYLIB),0)
++-	install_name_tool -id $(LIBDIR)/$(FLINT_LIB_FULL) $(LIBDIR)/$(FLINT_LIB)
+++	install_name_tool -id $(LIBDIR)/$(FLINT_LIB_FULL) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB)
++ endif
++ endif
++ ifneq ($(STATIC), 0)
++-	$(CP) $(FLINT_DIR)/$(FLINT_LIB_STATIC) $(LIBDIR)
+++	$(CP) $(FLINT_DIR)/$(FLINT_LIB_STATIC) $(DESTDIR)$(LIBDIR)
++ endif
++-	$(CP) $(HEADERS) $(INCLUDEDIR)/flint
+++	$(CP) $(HEADERS) $(DESTDIR)$(INCLUDEDIR)/flint
++ 
++ uninstall:
++-	$(RM_F) $(PKGCONFIGDIR)/flint.pc
+++	$(RM_F) $(DESTDIR)$(PKGCONFIGDIR)/flint.pc
++ ifneq ($(FLINT_DLLLIB),0)
++-	$(RM_F) $(BINDIR)/$(FLINT_LIB)
++-	$(RM_F) $(BINDIR)/$(FLINT_LIB_MAJOR)
++-	$(RM_F) $(BINDIR)/$(FLINT_LIB_FULL)
++-	$(RM_F) $(LIBDIR)/$(FLINT_IMPLIB)
+++	$(RM_F) $(DESTDIR)$(BINDIR)/$(FLINT_LIB)
+++	$(RM_F) $(DESTDIR)$(BINDIR)/$(FLINT_LIB_MAJOR)
+++	$(RM_F) $(DESTDIR)$(BINDIR)/$(FLINT_LIB_FULL)
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_IMPLIB)
++ else
++-	$(RM_F) $(LIBDIR)/$(FLINT_LIB)
++-	$(RM_F) $(LIBDIR)/$(FLINT_LIB_MAJOR)
++-	$(RM_F) $(LIBDIR)/$(FLINT_LIB_FULL)
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB)
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB_MAJOR)
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB_FULL)
++ endif
++-	$(RM_F) $(LIBDIR)/$(FLINT_LIB_STATIC)
++-	$(RM_RF) $(INCLUDEDIR)/flint
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB_STATIC)
+++	$(RM_RF) $(DESTDIR)$(INCLUDEDIR)/flint
++ 
++ ################################################################################
++ # maintainer stuff
++-- 
++2.42.0
++
+diff --git a/build/pkgs/flint/spkg-build.in b/build/pkgs/flint/spkg-build.in
+new file mode 100644
+index 00000000000..ffb822c8a97
+--- /dev/null
++++ b/build/pkgs/flint/spkg-build.in
+@@ -0,0 +1,3 @@
++cd src
++sdh_configure
++sdh_make
+diff --git a/build/pkgs/flint/spkg-configure.m4 b/build/pkgs/flint/spkg-configure.m4
+index a58108c9d6e..9576e4cc1e9 100644
+--- a/build/pkgs/flint/spkg-configure.m4
++++ b/build/pkgs/flint/spkg-configure.m4
+@@ -1,25 +1,8 @@
+ SAGE_SPKG_CONFIGURE([flint], [
+-    SAGE_SPKG_DEPCHECK([mpfr ntl], [
++    SAGE_SPKG_DEPCHECK([mpfr], [
+         AC_CHECK_HEADER(flint/flint.h, [
+-          dnl flint_parallel_binary_splitting appears in Flint 2.9.0, needed by arb 2.23
+-          AC_SEARCH_LIBS([flint_parallel_binary_splitting], [flint], [
+-            dnl check that NTL is linked in
+-            AC_SEARCH_LIBS([fmpz_poly_get_ZZX], [flint], [
+-
+-              AC_MSG_CHECKING([that GC is not enabled in Flint... ])
+-              AC_RUN_IFELSE([
+-                 AC_LANG_PROGRAM([[#include <flint/flint.h>]], [
+-                                  [#ifdef HAVE_GC]
+-                                     [return HAVE_GC;]
+-                                  [#else]
+-                                     [return 0;]
+-                                  [#endif]])],
+-                 [AC_MSG_RESULT([GC not enabled. Good.])],
+-                        [AC_MSG_RESULT([GC enabled. Incompatible with Sage.])
+-                         sage_spkg_install_flint=yes],
+-                 [AC_MSG_RESULT(["cross compiling. assuming GC is not enabled"])])
+-            ], [sage_spkg_install_flint=yes])
+-          ], [sage_spkg_install_flint=yes])
++          dnl gr_get_fexpr appears in Flint 3.0
++          AC_SEARCH_LIBS([gr_get_fexpr], [flint], [], [sage_spkg_install_flint=yes])
+         ], [sage_spkg_install_flint=yes])
+     ])
+ ], [], [], [
+diff --git a/build/pkgs/flint/spkg-install.in b/build/pkgs/flint/spkg-install.in
+index eacd7b6e491..3ea8c053669 100644
+--- a/build/pkgs/flint/spkg-install.in
++++ b/build/pkgs/flint/spkg-install.in
+@@ -1,36 +1,2 @@
+-###############################################################################
+-#
+-# FLINT Sage install script
+-#
+-###############################################################################
+-if [ "$SAGE_DEBUG" = "yes" ]; then
+-    echo "Building a debug version of FLINT."
+-    FLINT_TUNE=" $FLINT_TUNE"; export FLINT_TUNE
+-    FLINT_CONFIGURE="--enable-assert $FLINT_CONFIGURE"
+-fi
+-
+ cd src
+-
+-echo "Configuring FLINT."
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-ntl because otherwise FLINT's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-ntl="$SAGE_LOCAL" \
+-    $FLINT_CONFIGURE || sdh_die "Error: Failed to configure FLINT."
+-
+-sdh_make verbose
+-
+-echo "Deleting old FLINT files."
+-rm -f $SAGE_LOCAL/lib/libflint*
+-rm -rf $SAGE_LOCAL/include/flint
+-
+ sdh_make_install
+diff --git a/build/pkgs/gmp/spkg-configure.m4 b/build/pkgs/gmp/spkg-configure.m4
+index 61d7c5f3b2f..4000200db2c 100644
+--- a/build/pkgs/gmp/spkg-configure.m4
++++ b/build/pkgs/gmp/spkg-configure.m4
+@@ -2,8 +2,10 @@ SAGE_SPKG_CONFIGURE([gmp], [
+            sage_spkg_install_gmp=no
+             AC_CHECK_HEADER(gmp.h, [], [sage_spkg_install_gmp=yes])
+             AC_CHECK_HEADER(gmpxx.h, [], [sage_spkg_install_gmp=yes])
+-            dnl mpq_cmp_z appeared in GMP 6.1.0 and is used by pynac
+-            AC_SEARCH_LIBS([__gmpq_cmp_z], [gmp], [],
++            dnl mpn_gcd_11 appeared in GMP 6.2.1
++            dnl It is undocumented but is used by Flint when built with default
++            dnl flags.
++            AC_SEARCH_LIBS([__gmpn_gcd_11], [gmp], [],
+                 [sage_spkg_install_gmp=yes])
+ ], [], [], [
+     if test x$sage_spkg_install_gmp = xyes; then
+diff --git a/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+new file mode 100644
+index 00000000000..27a642a13b0
+--- /dev/null
++++ b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+@@ -0,0 +1,53 @@
++From fe730579476de0b2d4181a38efa7f63dff9c81d7 Mon Sep 17 00:00:00 2001
++From: Marc Mezzarobba <marc@mezzarobba.net>
++Date: Tue, 12 Sep 2023 08:23:08 +0200
++Subject: [PATCH] Make msolve build with flint3
++
++---
++ src/fglm/berlekamp_massey.c | 3 +++
++ src/fglm/data_fglm.c        | 7 +++++--
++ 2 files changed, 8 insertions(+), 2 deletions(-)
++
++diff --git a/src/fglm/berlekamp_massey.c b/src/fglm/berlekamp_massey.c
++index b0f2052..998af1c 100644
++--- a/src/fglm/berlekamp_massey.c
+++++ b/src/fglm/berlekamp_massey.c
++@@ -30,6 +30,9 @@
++ */
++ 
++ #include <stdlib.h>
+++#if __FLINT_VERSION >= 3
+++#  include <flint/nmod.h>
+++#endif
++ //#include "nmod_poly.h"
++ //#include "mpn_extras.h"
++ 
++diff --git a/src/fglm/data_fglm.c b/src/fglm/data_fglm.c
++index 0726760..0e1da6f 100644
++--- a/src/fglm/data_fglm.c
+++++ b/src/fglm/data_fglm.c
++@@ -24,6 +24,7 @@
++ #include <flint/mpn_extras.h>
++ #include <flint/nmod_poly.h>
++ #include <flint/nmod_poly_factor.h>
+++#include <flint/ulong_extras.h>
++ 
++ 
++ typedef uint32_t szmat_t;
++@@ -299,9 +300,11 @@ static inline void nmod_poly_set_prime(nmod_poly_t poly,
++   mp_limb_t ninv = n_preinvert_limb(prime);
++   poly->mod.n = prime;
++   poly->mod.ninv = ninv;
+++#if __FLINT_VERSION < 3
++   count_leading_zeros(poly->mod.norm, prime);
++-  /* poly->mod.norm = flint_clz(prime); */
++-
+++#else
+++  poly->mod.norm = flint_clz(prime);
+++#endif
++ }
++ 
++ static inline void fglm_param_set_prime(param_t *param, mp_limb_t prime){
++-- 
++2.40.1
++
+diff --git a/build/pkgs/sagelib/dependencies b/build/pkgs/sagelib/dependencies
+index 5dc2efe1d31..fa6e98df7db 100644
+--- a/build/pkgs/sagelib/dependencies
++++ b/build/pkgs/sagelib/dependencies
+@@ -1,4 +1,4 @@
+-FORCE $(SCRIPTS) arb boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
++FORCE $(SCRIPTS) boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/symengine/dependencies b/build/pkgs/symengine/dependencies
+index 1fc34963eda..7795d486018 100644
+--- a/build/pkgs/symengine/dependencies
++++ b/build/pkgs/symengine/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) arb ecm flint mpc mpfr | cmake
++$(MP_LIBRARY) ecm flint mpc mpfr | cmake
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/pkgs/sage-conf/_sage_conf/_conf.py.in b/pkgs/sage-conf/_sage_conf/_conf.py.in
+index 87b27ca05cb..895d6572d1e 100644
+--- a/pkgs/sage-conf/_sage_conf/_conf.py.in
++++ b/pkgs/sage-conf/_sage_conf/_conf.py.in
+@@ -19,8 +19,6 @@ MAXIMA_FAS = "@SAGE_MAXIMA_FAS@".replace('${prefix}', SAGE_LOCAL)
+ # Delete this line if your ECL can load Kenzo without further prodding.
+ KENZO_FAS = "@SAGE_KENZO_FAS@".replace('${prefix}', SAGE_LOCAL)
+ 
+-ARB_LIBRARY = "@SAGE_ARB_LIBRARY@"
+-
+ NTL_INCDIR = "@NTL_INCDIR@"
+ NTL_LIBDIR = "@NTL_LIBDIR@"
+ 
+diff --git a/src/sage/env.py b/src/sage/env.py
+index 4515e90e912..9ab6b1e1864 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -223,7 +223,6 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st
+ FOURTITWO_PPI = var("FOURTITWO_PPI")
+ FOURTITWO_CIRCUITS = var("FOURTITWO_CIRCUITS")
+ FOURTITWO_GROEBNER = var("FOURTITWO_GROEBNER")
+-ARB_LIBRARY = var("ARB_LIBRARY", "arb")
+ CBLAS_PC_MODULES = var("CBLAS_PC_MODULES", "cblas:openblas:blas")
+ ECL_CONFIG = var("ECL_CONFIG", "ecl-config")
+ NTL_INCDIR = var("NTL_INCDIR")
+@@ -356,8 +355,7 @@ def cython_aliases(required_modules=None,
+         sage: cython_aliases()
+         {...}
+         sage: sorted(cython_aliases().keys())
+-        ['ARB_LIBRARY',
+-         'CBLAS_CFLAGS',
++        ['CBLAS_CFLAGS',
+          ...,
+          'ZLIB_LIBRARIES']
+         sage: cython_aliases(required_modules=('module-that-is-assumed-to-not-exist'))
+@@ -475,8 +473,6 @@ def uname_specific(name, value, alternative):
+     if "LINBOX_CFLAGS" in aliases:
+         aliases["LINBOX_CFLAGS"].append("-std=gnu++11")
+ 
+-    aliases["ARB_LIBRARY"] = ARB_LIBRARY
+-
+     # TODO: Remove Cygwin hack by installing a suitable cblas.pc
+     if os.path.exists('/usr/lib/libblas.dll.a'):
+         aliases["CBLAS_LIBS"] = ['gslcblas']
+diff --git a/src/sage/features/sagemath.py b/src/sage/features/sagemath.py
+index bc34d35dd1c..4097d3512b9 100644
+--- a/src/sage/features/sagemath.py
++++ b/src/sage/features/sagemath.py
+@@ -777,7 +777,7 @@ class sage__rings__number_field(JoinFeature):
+     A :class:`~sage.features.Feature` describing the presence of :mod:`sage.rings.number_field`.
+ 
+     Number fields are implemented in Sage using a complicated mixture of various libraries,
+-    including :ref:`arb <spkg_arb>`, :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
++    including :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
+     :ref:`MPFI <spkg_mpfi>`, :ref:`NTL <spkg_ntl>`, and :ref:`PARI <spkg_pari>`.
+ 
+     EXAMPLES:
+diff --git a/src/sage/libs/arb/acb.pxd b/src/sage/libs/arb/acb.pxd
+index 5148dc43991..851488d803a 100644
+--- a/src/sage/libs/arb/acb.pxd
++++ b/src/sage/libs/arb/acb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -152,10 +152,6 @@ cdef extern from "arb_wrap.h":
+     void acb_sech(acb_t s, const acb_t z, long prec)
+     void acb_csch(acb_t c, const acb_t z, long prec)
+ 
+-    void acb_rising_ui_bs(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui_rs(acb_t z, const acb_t x, unsigned long n, unsigned long step, long prec)
+-    void acb_rising_ui_rec(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui(acb_t z, const acb_t x, unsigned long n, long prec)
+     void acb_rising(acb_t z, const acb_t x, const acb_t n, long prec)
+ 
+     void acb_gamma(acb_t y, const acb_t x, long prec)
+diff --git a/src/sage/libs/arb/acb_calc.pxd b/src/sage/libs/arb/acb_calc.pxd
+index a5dbf360b5e..67bd2ed57dc 100644
+--- a/src/sage/libs/arb/acb_calc.pxd
++++ b/src/sage/libs/arb/acb_calc.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_calc.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_elliptic.pxd b/src/sage/libs/arb/acb_elliptic.pxd
+index 176f68df00e..e3480e9f73b 100644
+--- a/src/sage/libs/arb/acb_elliptic.pxd
++++ b/src/sage/libs/arb/acb_elliptic.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_elliptic.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_hypgeom.pxd b/src/sage/libs/arb/acb_hypgeom.pxd
+index 418e766f10d..c43e5c0623b 100644
+--- a/src/sage/libs/arb/acb_hypgeom.pxd
++++ b/src/sage/libs/arb/acb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_hypgeom.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_modular.pxd b/src/sage/libs/arb/acb_modular.pxd
+index c708e9bf97d..cdc413c92da 100644
+--- a/src/sage/libs/arb/acb_modular.pxd
++++ b/src/sage/libs/arb/acb_modular.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_modular.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_poly.pxd b/src/sage/libs/arb/acb_poly.pxd
+index 69f4320055b..ae02757ffd9 100644
+--- a/src/sage/libs/arb/acb_poly.pxd
++++ b/src/sage/libs/arb/acb_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -79,24 +79,10 @@ cdef extern from "arb_wrap.h":
+     void _acb_poly_divrem(acb_ptr Q, acb_ptr R, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec)
+     bint acb_poly_divrem(acb_poly_t Q, acb_poly_t R, const acb_poly_t A, const acb_poly_t B, long prec)
+     void _acb_poly_div_root(acb_ptr Q, acb_t R, acb_srcptr A, long len, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_horner(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_horner(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_divconquer(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_divconquer(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_convolution(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_convolution(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+     void _acb_poly_taylor_shift(acb_ptr g, const acb_t c, long n, long prec)
+     void acb_poly_taylor_shift(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_compose_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_divconquer(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_divconquer(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+     void _acb_poly_compose(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+     void acb_poly_compose(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_series_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+-    void _acb_poly_compose_series_brent_kung(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_brent_kung(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_compose_series(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+     void acb_poly_compose_series(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_revert_series_lagrange(acb_ptr h, acb_srcptr f, long flen, long n, long prec)
+@@ -161,10 +147,6 @@ cdef extern from "arb_wrap.h":
+     void acb_poly_exp_series_basecase(acb_poly_t f, const acb_poly_t h, long n, long prec)
+     void _acb_poly_exp_series(acb_ptr f, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_exp_series(acb_poly_t f, const acb_poly_t h, long n, long prec)
+-    void _acb_poly_sin_cos_series_basecase(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_basecase(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+-    void _acb_poly_sin_cos_series_tangent(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_tangent(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+     void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_sin_cos_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec)
+     void _acb_poly_sin_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec)
+diff --git a/src/sage/libs/arb/arb.pxd b/src/sage/libs/arb/arb.pxd
+index c82b94de30f..acd232ab816 100644
+--- a/src/sage/libs/arb/arb.pxd
++++ b/src/sage/libs/arb/arb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -224,15 +224,8 @@ cdef extern from "arb_wrap.h":
+ 
+     void arb_lambertw(arb_t res, const arb_t x, int flags, long prec)
+ 
+-    void arb_rising_ui_bs(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui_rs(arb_t z, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising_ui_rec(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui(arb_t z, const arb_t x, unsigned long n, long prec)
+     void arb_rising(arb_t z, const arb_t x, const arb_t n, long prec)
+     void arb_rising_fmpq_ui(arb_t z, const fmpq_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_bs(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_rs(arb_t u, arb_t v, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising2_ui(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+     void arb_fac_ui(arb_t z, unsigned long n, long prec)
+     void arb_bin_ui(arb_t z, const arb_t n, unsigned long k, long prec)
+     void arb_bin_uiui(arb_t z, unsigned long n, unsigned long k, long prec)
+diff --git a/src/sage/libs/arb/arb_fmpz_poly.pxd b/src/sage/libs/arb/arb_fmpz_poly.pxd
+index 079f76e9d9e..55daa705238 100644
+--- a/src/sage/libs/arb/arb_fmpz_poly.pxd
++++ b/src/sage/libs/arb/arb_fmpz_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_fmpz_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -22,5 +22,4 @@ cdef extern from "arb_wrap.h":
+     unsigned long arb_fmpz_poly_deflation(const fmpz_poly_t poly)
+     void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long deflation)
+     void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, long prec)
+-    void arb_fmpz_poly_cos_minpoly(fmpz_poly_t res, unsigned long n)
+     void arb_fmpz_poly_gauss_period_minpoly(fmpz_poly_t res, unsigned long q, unsigned long n)
+diff --git a/src/sage/libs/arb/arb_hypgeom.pxd b/src/sage/libs/arb/arb_hypgeom.pxd
+index fb1c40ddaa8..139b987d669 100644
+--- a/src/sage/libs/arb/arb_hypgeom.pxd
++++ b/src/sage/libs/arb/arb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_hypgeom.h
+ 
+ from sage.libs.flint.types cimport fmpz_t
+diff --git a/src/sage/libs/arb/arb_wrap.h b/src/sage/libs/arb/arb_wrap.h
+index 49997075ee5..488bb376d5e 100644
+--- a/src/sage/libs/arb/arb_wrap.h
++++ b/src/sage/libs/arb/arb_wrap.h
+@@ -5,25 +5,27 @@
+  * by arb, most of which rely on flint's ulong and slong defines.
+  */
+ 
++#include <mpfr.h>
++
+ #undef ulong
+ #undef slong
+ 
+ #define ulong mp_limb_t
+ #define slong mp_limb_signed_t
+ 
+-#include <acb.h>
+-#include <acb_calc.h>
+-#include <acb_elliptic.h>
+-#include <acb_hypgeom.h>
+-#include <acb_mat.h>
+-#include <acb_modular.h>
+-#include <acb_poly.h>
+-#include <arb.h>
+-#include <arb_fmpz_poly.h>
+-#include <arb_hypgeom.h>
+-#include <arf.h>
+-#include <bernoulli.h>
+-#include <mag.h>
++#include <flint/acb.h>
++#include <flint/acb_calc.h>
++#include <flint/acb_elliptic.h>
++#include <flint/acb_hypgeom.h>
++#include <flint/acb_mat.h>
++#include <flint/acb_modular.h>
++#include <flint/acb_poly.h>
++#include <flint/arb.h>
++#include <flint/arb_fmpz_poly.h>
++#include <flint/arb_hypgeom.h>
++#include <flint/arf.h>
++#include <flint/bernoulli.h>
++#include <flint/mag.h>
+ 
+ #undef ulong
+ #undef slong
+diff --git a/src/sage/libs/arb/arf.pxd b/src/sage/libs/arb/arf.pxd
+index b8b83fefcdc..84778fe9f09 100644
+--- a/src/sage/libs/arb/arf.pxd
++++ b/src/sage/libs/arb/arf.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arf.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -30,7 +30,6 @@ cdef extern from "arb_wrap.h":
+     void arf_set_ui(arf_t y, unsigned long x)
+     void arf_set_si(arf_t y, long x)
+     void arf_set_mpfr(arf_t y, const mpfr_t x)
+-    # void arf_set_fmpr(arf_t y, const fmpr_t x)
+     void arf_set_d(arf_t y, double x)
+     void arf_swap(arf_t y, arf_t x)
+     void arf_init_set_ui(arf_t y, unsigned long x)
+@@ -46,7 +45,6 @@ cdef extern from "arb_wrap.h":
+     int arf_set_round_fmpz_2exp(arf_t y, const fmpz_t x, const fmpz_t e, long prec, arf_rnd_t rnd)
+     void arf_get_fmpz_2exp(fmpz_t m, fmpz_t e, const arf_t x)
+     double arf_get_d(const arf_t x, arf_rnd_t rnd)
+-    # void arf_get_fmpr(fmpr_t y, const arf_t x)
+     int arf_get_mpfr(mpfr_t y, const arf_t x, mpfr_rnd_t rnd)
+     void arf_get_fmpz(fmpz_t z, const arf_t x, arf_rnd_t rnd)
+     long arf_get_si(const arf_t x, arf_rnd_t rnd)
+diff --git a/src/sage/libs/arb/bernoulli.pxd b/src/sage/libs/arb/bernoulli.pxd
+index f859ebfb8d7..95a84dd5179 100644
+--- a/src/sage/libs/arb/bernoulli.pxd
++++ b/src/sage/libs/arb/bernoulli.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = bernoulli.h
+ 
+ from sage.libs.flint.types cimport fmpq_t, ulong
+diff --git a/src/sage/libs/arb/mag.pxd b/src/sage/libs/arb/mag.pxd
+index d5d8693ea8f..69dfb990ae0 100644
+--- a/src/sage/libs/arb/mag.pxd
++++ b/src/sage/libs/arb/mag.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = mag.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -27,13 +27,11 @@ cdef extern from "arb_wrap.h":
+     # void mag_randtest(mag_t x, flint_rand_t state, long expbits)
+     # void mag_randtest_special(mag_t x, flint_rand_t state, long expbits)
+     void mag_set_d(mag_t y, double x)
+-    # void mag_set_fmpr(mag_t y, const fmpr_t x)
+     void mag_set_ui(mag_t y, unsigned long x)
+     void mag_set_fmpz(mag_t y, const fmpz_t x)
+     void mag_set_d_2exp_fmpz(mag_t z, double x, const fmpz_t y)
+     void mag_set_fmpz_2exp_fmpz(mag_t z, const fmpz_t x, const fmpz_t y)
+     void mag_set_ui_2exp_si(mag_t z, unsigned long x, long y)
+-    # void mag_get_fmpr(fmpr_t y, const mag_t x)
+     void mag_get_fmpq(fmpq_t y, const mag_t x)
+     void mag_set_ui_lower(mag_t z, unsigned long x)
+     void mag_set_fmpz_lower(mag_t z, const fmpz_t x)
+diff --git a/src/sage/libs/flint/flint_wrap.h b/src/sage/libs/flint/flint_wrap.h
+index 266535c3835..4db72b97660 100644
+--- a/src/sage/libs/flint/flint_wrap.h
++++ b/src/sage/libs/flint/flint_wrap.h
+@@ -15,6 +15,7 @@
+  */
+ 
+ #include <gmp.h>
++#include <mpfr.h>
+ 
+ /* Save previous definition of ulong if any, as pari also uses it */
+ /* Should work on GCC, clang, MSVC */
+@@ -33,6 +34,7 @@
+ 
+ #include <flint/arith.h>
+ #include <flint/fmpq.h>
++#include <flint/fmpq_vec.h>
+ #include <flint/fmpq_mat.h>
+ #include <flint/fmpq_poly.h>
+ #include <flint/fmpz.h>
+@@ -47,6 +49,7 @@
+ #include <flint/fq.h>
+ #include <flint/fq_nmod.h>
+ #include <flint/nmod_poly.h>
++#include <flint/nmod_poly_factor.h>
+ #include <flint/nmod_vec.h>
+ #include <flint/padic.h>
+ #include <flint/padic_poly.h>
+diff --git a/src/sage/libs/flint/fmpq.pxd b/src/sage/libs/flint/fmpq.pxd
+index 5e64c82102f..0616c0a7408 100644
+--- a/src/sage/libs/flint/fmpq.pxd
++++ b/src/sage/libs/flint/fmpq.pxd
+@@ -12,6 +12,8 @@ cdef extern from "flint_wrap.h":
+     fmpz * fmpq_denref(fmpq_t)
+     void fmpq_init(fmpq_t)
+     void fmpq_clear(fmpq_t)
++    void fmpq_init_set_readonly(fmpq_t, const mpq_t)
++    void fmpq_clear_readonly(fmpq_t)
+     void fmpq_one(fmpq_t)
+     void fmpq_zero(fmpq_t)
+     bint fmpq_is_zero(fmpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pxd b/src/sage/libs/flint/fmpq_poly.pxd
+index 6050c487835..afa16e5bbdd 100644
+--- a/src/sage/libs/flint/fmpq_poly.pxd
++++ b/src/sage/libs/flint/fmpq_poly.pxd
+@@ -30,6 +30,9 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_canonicalise(fmpq_poly_t)
+     int fmpq_poly_is_canonical(const fmpq_poly_t)
+ 
++    void _fmpq_poly_set_length(fmpq_poly_t, slong)
++    void _fmpq_poly_normalise(fmpq_poly_t)
++
+     # Polynomial parameters
+     slong fmpq_poly_degree(const fmpq_poly_t)
+     ulong fmpq_poly_length(const fmpq_poly_t)
+@@ -46,10 +49,7 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_ui(fmpq_poly_t, ulong)
+     void fmpq_poly_set_fmpz(fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_set_fmpq(fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+     void fmpq_poly_set_fmpz_poly(fmpq_poly_t, const fmpz_poly_t)
+-    void fmpq_poly_set_array_mpq(fmpq_poly_t, const mpq_t *, slong)
+ 
+     void fmpq_poly_set_str(fmpq_poly_t, const char *)
+     char *fmpq_poly_get_str(const fmpq_poly_t)
+@@ -67,7 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_reverse(fmpq_poly_t, const fmpq_poly_t, slong)
+ 
+     void fmpq_poly_get_coeff_fmpq(fmpq_t, const fmpq_poly_t, slong)
+-    void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_si(slong, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_ui(ulong, const fmpq_poly_t, slong)
+ 
+@@ -75,8 +74,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_coeff_ui(fmpq_poly_t, slong, ulong)
+     void fmpq_poly_set_coeff_fmpz(fmpq_poly_t, slong, const fmpz_t)
+     void fmpq_poly_set_coeff_fmpq(fmpq_poly_t, slong, const fmpq_t)
+-    void fmpq_poly_set_coeff_mpz(fmpq_poly_t, slong, const mpz_t)
+-    void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
+ 
+     # Comparison
+     int fmpq_poly_equal(const fmpq_poly_t, const fmpq_poly_t)
+@@ -100,8 +97,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_mul_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     void fmpq_poly_scalar_div_si(fmpq_poly_t, const fmpq_poly_t, slong)
+     void fmpq_poly_scalar_div_ui(fmpq_poly_t, const fmpq_poly_t, ulong)
+@@ -109,8 +104,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_div_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_div_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_div_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Multiplication
+     void fmpq_poly_mul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -155,8 +148,6 @@ cdef extern from "flint_wrap.h":
+     # Evaluation
+     void fmpq_poly_evaluate_fmpz(fmpq_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_evaluate_fmpq(fmpq_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_evaluate_mpz(mpq_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_evaluate_mpq(mpq_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Composition
+     void fmpq_poly_compose(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -189,3 +180,11 @@ cdef extern from "flint_wrap.h":
+ # since the fmpq_poly header seems to be lacking this inline function
+ cdef inline sage_fmpq_poly_max_limbs(const fmpq_poly_t poly) noexcept:
+     return _fmpz_vec_max_limbs(fmpq_poly_numref(poly), fmpq_poly_length(poly))
++
++# functions removed from flint but still needed in sage
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
++cdef void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
++cdef void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pyx b/src/sage/libs/flint/fmpq_poly.pyx
+new file mode 100644
+index 00000000000..3b8a0cf0c51
+--- /dev/null
++++ b/src/sage/libs/flint/fmpq_poly.pyx
+@@ -0,0 +1,45 @@
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++from sage.libs.gmp.mpq cimport *
++from sage.libs.flint.fmpz cimport *
++from sage.libs.flint.fmpq cimport *
++
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t rop, const fmpq_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t rop, const fmpq_poly_t op, const mpq_t c):
++    cdef fmpq_t f
++    fmpq_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpq(rop, op, f)
++    fmpq_clear_readonly(f)
++
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t poly, slong n, const mpq_t x):
++    cdef fmpq_t t
++    fmpq_init_set_readonly(t, x)
++    fmpq_poly_set_coeff_fmpq(poly, n, t)
++    fmpq_clear_readonly(t)
++
++cdef void fmpq_poly_get_coeff_mpq(mpq_t x, const fmpq_poly_t poly, slong n):
++    cdef fmpq_t t
++    fmpq_init(t)
++    fmpq_poly_get_coeff_fmpq(t, poly, n)
++    fmpq_get_mpq(x, t)
++    fmpq_clear(t)
++
++cdef void fmpq_poly_set_mpq(fmpq_poly_t poly, const mpq_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), mpq_numref(x))
++    fmpz_set_mpz(fmpq_poly_denref(poly), mpq_denref(x))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
++
++cdef void fmpq_poly_set_mpz(fmpq_poly_t poly, const mpz_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), x)
++    fmpz_one(fmpq_poly_denref(poly))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz.pxd b/src/sage/libs/flint/fmpz.pxd
+index 01058d0f130..b97fbe1eae0 100644
+--- a/src/sage/libs/flint/fmpz.pxd
++++ b/src/sage/libs/flint/fmpz.pxd
+@@ -16,6 +16,9 @@ cdef extern from "flint_wrap.h":
+     void fmpz_init_set(fmpz_t, fmpz_t)
+     void fmpz_init_set_ui(fmpz_t, ulong)
+ 
++    void fmpz_init_set_readonly(fmpz_t, const mpz_t)
++    void fmpz_clear_readonly(fmpz_t)
++
+     # Conversion
+     void fmpz_set(fmpz_t f, fmpz_t g)
+     void fmpz_set_ui(fmpz_t, ulong)
+diff --git a/src/sage/libs/flint/fmpz_mod_poly.pxd b/src/sage/libs/flint/fmpz_mod_poly.pxd
+index 24b653eb3b7..2727246da98 100644
+--- a/src/sage/libs/flint/fmpz_mod_poly.pxd
++++ b/src/sage/libs/flint/fmpz_mod_poly.pxd
+@@ -67,13 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_get_coeff_fmpz(fmpz_t x, const fmpz_mod_poly_t poly,
+                                              slong n, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_set_coeff_mpz(fmpz_mod_poly_t poly,
+-                             slong n, const mpz_t x, const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_get_coeff_mpz(mpz_t x,
+-                 const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx)
+-
+-
+     void _fmpz_mod_poly_shift_left(fmpz * res, const fmpz * poly,
+                                                            slong len, slong n)
+ 
+@@ -194,14 +187,6 @@ cdef extern from "flint_wrap.h":
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_div_basecase(fmpz_mod_poly_t Q,
+-                            const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_div_newton_n_preinv(fmpz_mod_poly_t Q,
+-                         const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                         const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem_newton_n_preinv(fmpz_mod_poly_t Q,
+           fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                          const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+@@ -213,10 +198,6 @@ cdef extern from "flint_wrap.h":
+                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_divrem_divconquer(fmpz_mod_poly_t Q,
+-        fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem(fmpz_mod_poly_t Q, fmpz_mod_poly_t R,
+     const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+@@ -254,40 +235,13 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_make_monic_f(fmpz_t f, fmpz_mod_poly_t res,
+                          const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_euclidean(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_gcd_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_hgcd(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-
+     void fmpz_mod_poly_gcd(fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+ 
+-    void fmpz_mod_poly_xgcd_euclidean(fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_hgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S,
+-          fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_xgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                       const fmpz_mod_ctx_t ctx)
+@@ -361,14 +315,6 @@ cdef extern from "flint_wrap.h":
+                         const fmpz_mod_poly_t poly, const fmpz * xs, slong n,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_compose_horner(fmpz_mod_poly_t res,
+-                    const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_compose_divconquer(fmpz_mod_poly_t res,
+-                     const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_compose(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1,
+                          const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx)
+ 
+diff --git a/src/sage/libs/flint/fmpz_poly.pxd b/src/sage/libs/flint/fmpz_poly.pxd
+index 18b36672d30..c8bc6d3ca0a 100644
+--- a/src/sage/libs/flint/fmpz_poly.pxd
++++ b/src/sage/libs/flint/fmpz_poly.pxd
+@@ -28,7 +28,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_poly_set_ui(fmpz_poly_t, ulong)
+     void fmpz_poly_set_si(fmpz_poly_t, slong)
+     void fmpz_poly_set_fmpz(fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+     int fmpz_poly_set_str(fmpz_poly_t, const char *)
+ 
+     char *fmpz_poly_get_str(const fmpz_poly_t)
+@@ -70,7 +69,6 @@ cdef extern from "flint_wrap.h":
+     # Scalar multiplication and division
+     void fmpz_poly_scalar_mul_fmpz(
+             fmpz_poly_t, const fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+     void fmpz_poly_scalar_mul_si(fmpz_poly_t, const fmpz_poly_t, slong)
+     void fmpz_poly_scalar_mul_ui(fmpz_poly_t, const fmpz_poly_t, ulong)
+     void fmpz_poly_scalar_mul_2exp(fmpz_poly_t, const fmpz_poly_t, ulong)
+@@ -310,12 +308,14 @@ cdef extern from "flint_wrap.h":
+             fmpz_poly_t,
+                     const fmpz_poly_t, const fmpz_t, const nmod_poly_t, int)
+ 
+-    # Some functions for backwards compatibility
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
+-    void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++
++# functions removed from flint but still needed in sage
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
++cdef void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++cdef void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+ 
+ 
+ # Wrapper Cython class
+diff --git a/src/sage/libs/flint/fmpz_poly.pyx b/src/sage/libs/flint/fmpz_poly.pyx
+index 74915b37612..cfcbea9090c 100644
+--- a/src/sage/libs/flint/fmpz_poly.pyx
++++ b/src/sage/libs/flint/fmpz_poly.pyx
+@@ -25,10 +25,10 @@ from cysignals.memory cimport sig_free
+ 
+ from sage.arith.long cimport pyobject_to_long
+ from sage.cpython.string cimport char_to_str, str_to_bytes
++from sage.libs.flint.fmpz cimport *
+ from sage.structure.sage_object cimport SageObject
+ from sage.rings.integer cimport Integer
+ 
+-
+ cdef class Fmpz_poly(SageObject):
+ 
+     def __cinit__(self):
+@@ -455,3 +455,44 @@ cdef class Fmpz_poly(SageObject):
+         """
+         from sage.rings.integer_ring import ZZ
+         return ZZ[var](self.list())
++
++
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_divexact_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_fdiv_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t poly, slong n, const mpz_t x):
++    cdef fmpz_t t
++    fmpz_init_set_readonly(t, x)
++    fmpz_poly_set_coeff_fmpz(poly, n, t)
++    fmpz_clear_readonly(t)
++
++cdef void fmpz_poly_get_coeff_mpz(mpz_t x, const fmpz_poly_t poly, slong n):
++    cdef fmpz_t t
++    fmpz_init(t)
++    fmpz_poly_get_coeff_fmpz(t, poly, n)
++    fmpz_get_mpz(x, t)
++    fmpz_clear(t)
++
++cdef void fmpz_poly_set_mpz(fmpz_poly_t poly, const mpz_t x):
++    fmpz_poly_fit_length(poly, 1)
++    fmpz_set_mpz(poly.coeffs, x)
++    _fmpz_poly_set_length(poly, 1)
++    _fmpz_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz_poly_q.pxd b/src/sage/libs/flint/fmpz_poly_q.pxd
+index 846542dc0d8..63c13355bf6 100644
+--- a/src/sage/libs/flint/fmpz_poly_q.pxd
++++ b/src/sage/libs/flint/fmpz_poly_q.pxd
+@@ -49,11 +49,7 @@ cdef extern from "flint_wrap.h":
+ 
+     #* Scalar multiplication and division ****************************************/
+     void fmpz_poly_q_scalar_mul_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_mul_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_mul_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+     void fmpz_poly_q_scalar_div_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_div_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_div_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+ 
+     #* Multiplication and division ***********************************************/
+     void fmpz_poly_q_mul(fmpz_poly_q_t rop, 
+@@ -67,9 +63,6 @@ cdef extern from "flint_wrap.h":
+     #* Derivative ****************************************************************/
+     void fmpz_poly_q_derivative(fmpz_poly_q_t rop, const fmpz_poly_q_t op)
+ 
+-    #* Evaluation ****************************************************************/
+-    int fmpz_poly_q_evaluate(mpq_t rop, const fmpz_poly_q_t f, const mpq_t a)
+-
+     #* Input and output **********************************************************/
+     int fmpz_poly_q_set_str(fmpz_poly_q_t rop, const char *s)
+     char * fmpz_poly_q_get_str(const fmpz_poly_q_t op)
+diff --git a/src/sage/libs/linbox/linbox_flint_interface.pyx b/src/sage/libs/linbox/linbox_flint_interface.pyx
+index 1979ac0f0a4..37a340c457f 100644
+--- a/src/sage/libs/linbox/linbox_flint_interface.pyx
++++ b/src/sage/libs/linbox/linbox_flint_interface.pyx
+@@ -33,6 +33,7 @@ and C. Pernet. The functions available are:
+ #                  https://www.gnu.org/licenses/
+ # ****************************************************************************
+ 
++from sage.libs.gmp.types cimport mpz_t
+ from sage.libs.flint.types cimport fmpz_t
+ from sage.libs.flint.fmpz cimport fmpz_get_mpz, fmpz_set_mpz
+ from sage.libs.flint.fmpz_mat cimport fmpz_mat_entry, fmpz_mat_nrows, fmpz_mat_ncols
+@@ -80,11 +81,13 @@ cdef void fmpz_poly_set_linbox(fmpz_poly_t p, PolynomialRing_integer.Element& q)
+     (the .pxd file) in order to keep the header C-compatible
+     """
+     cdef size_t i
++    cdef mpz_t tmp
+ 
+     fmpz_poly_fit_length(p, q.size())
+ 
+     for i in range(q.size()):
+-        fmpz_poly_set_coeff_mpz(p, i, q[i].get_mpz_const())
++        tmp = q[i].get_mpz_const()
++        fmpz_poly_set_coeff_mpz(p, i, tmp)
+ 
+     _fmpz_poly_set_length(p, q.size())
+ 
+diff --git a/src/sage/matrix/matrix_complex_ball_dense.pyx b/src/sage/matrix/matrix_complex_ball_dense.pyx
+index e5414abdd9e..2f0131f4064 100644
+--- a/src/sage/matrix/matrix_complex_ball_dense.pyx
++++ b/src/sage/matrix/matrix_complex_ball_dense.pyx
+@@ -1,4 +1,4 @@
+-# distutils: libraries = ARB_LIBRARY
++# distutils: libraries = flint
+ r"""
+ Arbitrary precision complex ball matrices using Arb
+ 
+diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx
+index 27f5cdfac0f..6c5c20dbc6b 100644
+--- a/src/sage/matrix/matrix_integer_sparse.pyx
++++ b/src/sage/matrix/matrix_integer_sparse.pyx
+@@ -847,6 +847,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+             sage: matrix(ZZ, 1, 1, sparse=True)._charpoly_linbox()
+             x
+         """
++        cdef mpz_t tmp
+         if self._nrows != self._ncols:
+             raise ArithmeticError('only valid for square matrix')
+ 
+@@ -869,7 +870,8 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         cdef size_t i
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+@@ -966,9 +968,11 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         sig_off()
+ 
+         cdef size_t i
++        cdef mpz_t tmp
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
+index 1e3085c9215..0786de7fc81 100644
+--- a/src/sage/rings/complex_arb.pyx
++++ b/src/sage/rings/complex_arb.pyx
+@@ -1360,12 +1360,13 @@ cdef class ComplexBall(RingElement):
+             sage: CBF100(-3r)
+             -3.000000000000000000000000000000
+ 
+-            sage: ComplexBall(CBF100, 10^100)
+-            1.000000000000000000000000000000e+100
+             sage: ComplexBall(CBF100, CIF(1, 2))
+             1.000000000000000000000000000000 + 2.000000000000000000000000000000*I
+             sage: ComplexBall(CBF100, RBF(1/3), RBF(1))
+             [0.3333333333333333 +/- ...e-17] + 1.000000000000000000000000000000*I
++            sage: ComplexBall(CBF100, 10^100)
++            [1.000000000000000000000000000000e+100 +/- ...]
++
+             sage: NF.<a> = QuadraticField(-1, embedding=CC(0, -1))
+             sage: CBF(a)
+             -1.000000000000000*I
+@@ -3009,7 +3010,7 @@ cdef class ComplexBall(RingElement):
+             sage: CBF(1).rising_factorial(2**64)
+             [+/- ...e+347382171326740403407]
+             sage: ComplexBallField(128)(1).rising_factorial(2**64)
+-            [2.343691126796861348e+347382171305201285713 +/- ...e+347382171305201285694]
++            [2.34369112679686134...e+347382171305201285713 +/- ...]
+             sage: CBF(1/2).rising_factorial(CBF(2,3)) # abs tol 1e-15
+             [-0.123060451458124 +/- 3.06e-16] + [0.0406412631676552 +/- 7.57e-17]*I
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+index 04eaefc9fed..d99f0d3b98c 100644
+--- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+@@ -222,7 +222,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef unsigned long n
+         cdef Rational c
+         cdef list L1
+-        cdef mpq_t * L2
++        cdef fmpq_t q
+ 
+         Polynomial.__init__(self, parent, is_gen=is_gen)
+ 
+@@ -253,14 +253,11 @@ cdef class Polynomial_rational_flint(Polynomial):
+             L1 = [e if isinstance(e, Rational) else Rational(e) for e in x]
+             n  = <unsigned long> len(x)
+             sig_on()
+-            L2 = <mpq_t *> check_allocarray(n, sizeof(mpq_t))
++            fmpq_poly_fit_length(self._poly, n)
+             for deg from 0 <= deg < n:
+-                mpq_init(L2[deg])
+-                mpq_set(L2[deg], (<Rational> L1[deg]).value)
+-            fmpq_poly_set_array_mpq(self._poly, L2, n)
+-            for deg from 0 <= deg < n:
+-                mpq_clear(L2[deg])
+-            sig_free(L2)
++                fmpq_init_set_readonly(q, (<Rational> L1[deg]).value)
++                fmpq_poly_set_coeff_fmpq(self._poly, deg, q)
++                fmpq_clear_readonly(q)
+             sig_off()
+ 
+ #           deg = 0
+@@ -435,6 +432,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         utmost care.
+         """
+         cdef bint do_sig = _do_sig(self._poly)
++        cdef fmpz_t tmpfz
+ 
+         if isinstance(value, int):
+             if do_sig: sig_str("FLINT exception")
+@@ -442,7 +440,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+             if do_sig: sig_off()
+         elif isinstance(value, Integer):
+             if do_sig: sig_str("FLINT exception")
+-            fmpq_poly_set_coeff_mpz(self._poly, n, (<Integer> value).value)
++            fmpz_init_set_readonly(tmpfz, (<Integer> value).value)
++            fmpq_poly_set_coeff_fmpz(self._poly, n, tmpfz)
++            fmpz_clear_readonly(tmpfz)
+             if do_sig: sig_off()
+         elif isinstance(value, Rational):
+             if do_sig: sig_str("FLINT exception")
+@@ -492,7 +492,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef Polynomial_rational_flint f
+         cdef Rational r
+         cdef fmpz_t tmpfz
+-        cdef fmpq_t tmpfq
++        cdef fmpq_t tmpfq, tmpfq1
+         cdef RealBall arb_a, arb_z
+         cdef ComplexBall acb_a, acb_z
+ 
+@@ -508,13 +508,23 @@ cdef class Polynomial_rational_flint(Polynomial):
+             elif isinstance(a, Rational):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpq(r.value, self._poly, (<Rational> a).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> a).value)
++                fmpq_init(tmpfq1)
++                fmpq_poly_evaluate_fmpq(tmpfq1, self._poly, tmpfq)
++                fmpq_get_mpq(r.value, tmpfq1)
++                fmpq_clear(tmpfq1)
++                fmpq_clear_readonly(tmpfq)
+                 sig_off()
+                 return r
+             elif isinstance(a, Integer):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpz(r.value, self._poly, (<Integer> a).value)
++                fmpz_init_set_readonly(tmpfz, (<Integer> a).value)
++                fmpq_init(tmpfq)
++                fmpq_poly_evaluate_fmpz(tmpfq, self._poly, tmpfz)
++                fmpq_get_mpq(r.value, tmpfq)
++                fmpq_clear(tmpfq)
++                fmpz_clear_readonly(tmpfz)
+                 sig_off()
+                 return r
+             elif isinstance(a, int):
+@@ -1321,6 +1331,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         """
+         cdef Polynomial_rational_flint res
+         cdef bint do_sig
++        cdef fmpq_t tmpfq
+ 
+         if right == 0:
+             raise ZeroDivisionError("division by zero polynomial")
+@@ -1331,8 +1342,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+                 do_sig = _do_sig(self._poly)
+ 
+                 if do_sig: sig_str("FLINT exception")
+-                fmpq_poly_scalar_div_mpq(res._poly, self._poly,
+-                                                  (<Rational> QQ(right)).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> QQ(right)).value)
++                fmpq_poly_scalar_div_fmpq(res._poly, self._poly, tmpfq)
++                fmpq_clear_readonly(tmpfq)
+                 if do_sig: sig_off()
+                 return res
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+index 6e7f7498329..3a66198d568 100644
+--- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+@@ -658,6 +658,11 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
+             ...
+             NotImplementedError: square free factorization of polynomials over rings with composite characteristic is not implemented
+ 
++        :trac:`20003`::
++
++            sage: P.<x> = GF(7)[]
++            sage: (6*x+3).squarefree_decomposition()
++            (6) * (x + 4)
+         """
+         if not self.base_ring().is_field():
+             raise NotImplementedError("square free factorization of polynomials over rings with composite characteristic is not implemented")
+diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
+index 17961ac36b2..8509b19cc66 100644
+--- a/src/sage/rings/real_arb.pyx
++++ b/src/sage/rings/real_arb.pyx
+@@ -898,7 +898,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+             sage: RBF.gamma(5)
+             24.00000000000000
+             sage: RBF.gamma(10**20)
+-            [+/- ...e+1956570552410610660600]
++            [1.932849514310098...+1956570551809674817225 +/- ...]
+             sage: RBF.gamma(1/3)
+             [2.678938534707747 +/- ...e-16]
+             sage: RBF.gamma(-5)
+@@ -1102,7 +1102,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+              15.00000000000000,
+              48.00000000000000]
+             sage: RBF.double_factorial(2**20)
+-            [1.4483729903e+2928836 +/- ...e+2928825]
++            [1.448372990...e+2928836 +/- ...]
+             sage: RBF.double_factorial(2**1000)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/schemes/plane_conics/con_rational_function_field.py b/src/sage/schemes/plane_conics/con_rational_function_field.py
+index 05d24e78a85..581102b5c5b 100644
+--- a/src/sage/schemes/plane_conics/con_rational_function_field.py
++++ b/src/sage/schemes/plane_conics/con_rational_function_field.py
+@@ -198,38 +198,6 @@ def has_rational_point(self, point=False, algorithm='default',
+             Fraction Field of Univariate Polynomial Ring in u over Rational
+             Field with modulus v^2 - u^3 - 1
+ 
+-        ``has_rational_point`` fails for some conics over function fields
+-        over finite fields, due to :trac:`20003`::
+-
+-            sage: K.<t> = PolynomialRing(GF(7))
+-            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
+-            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
+-            sage: C.has_rational_point()                                                # needs sage.libs.singular
+-            Traceback (most recent call last):
+-            ...
+-            TypeError: self (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (-t^3 + 3*t^2 - 2*t - 2)/(t + 3)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (t^2 + 3*t + 3)*x*y + (-2*t^2 - 2)*y^2 + (-t^2 + 3*t + 2)*x*z + (-3*t + 3)*y*z + (-3*t^2 + t - 2)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x + (2*t - 2)/(t + 3)*y + (3*t^4 + 2*t^3 - 2*t^2 - 2*t + 3)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z
+-                     : y + (-t^3 - t^2 + 3*t - 1)/(t^3 - 3*t^2 + 2*t + 2)*z : z))
+-            domain must equal right (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^3 - t^2 + 3*t + 3)*x^2 + (t - 3)*y^2 + (-t^7 + 2*t^5 + t^4 + 2*t^3 + 3*t^2 - t - 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    -2/(t^3 - 3*t^2 + 2*t + 2)*x^2 + 1/(t^3 + 3*t^2 - 2*t + 1)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^9 - 2*t^8 + t^7 - t^6 + 3*t^5 - 3*t^3 + t^2 - 2*t + 3)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    ((t^3 - 3*t^2 + 2*t + 2)*x : (t^2 - 2)*y : (t^5 - 3*t^4 + t^2 + 3*t + 3)*z))
+-            codomain
+-
+-
+-
+         TESTS::
+ 
+             sage: K.<t> = FractionField(PolynomialRing(QQ, 't'))
+@@ -250,6 +218,16 @@ def has_rational_point(self, point=False, algorithm='default',
+             sage: C.has_rational_point(point=True)  # long time (4 seconds)             # needs sage.libs.singular
+             (True,
+              ((-2/117*t^8 + 304/1053*t^7 + 40/117*t^6 - 1/27*t^5 - 110/351*t^4 - 2/195*t^3 + 11/351*t^2 + 1/117)/(t^4 + 2/39*t^3 + 4/117*t^2 + 2/39*t + 14/39) : -5/3*t^4 + 19*t^3 : 1))
++
++        ``has_rational_point`` used to fail for some conics over function fields
++        over finite fields, due to :trac:`20003`::
++
++            sage: K.<t> = PolynomialRing(GF(7))
++            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
++            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
++            sage: C.has_rational_point()
++            True
++
+         """
+         from .constructor import Conic
+ 
+diff --git a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+index a591cb4cd7c..a90f2050c59 100644
+--- a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
++++ b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+@@ -20,6 +20,7 @@
+ #include "utils.h"
+ 
+ #include "gmp.h"
++#include "flint/fmpz_poly.h"
+ #include "flint/fmpq_poly.h"
+ #include "flint/fmpq.h"
+ 
+@@ -63,7 +64,7 @@ static ex chebyt_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+@@ -122,7 +123,7 @@ static ex chebyu_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+diff --git a/src/sage/symbolic/ginac/useries.cpp b/src/sage/symbolic/ginac/useries.cpp
+index 40fbd7ab360..b9a8b867648 100644
+--- a/src/sage/symbolic/ginac/useries.cpp
++++ b/src/sage/symbolic/ginac/useries.cpp
+@@ -467,10 +467,17 @@ void add::useries(flint_series_t& fp, int order) const
+                 fmpq_poly_set_ui(fp.ft, 0);
+         else if (oc.is_long())
+                 fmpq_poly_set_si(fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ 
+         for (const auto & elem : seq) {
+ 		const ex& t = recombine_pair_to_ex(elem);
+@@ -505,10 +512,17 @@ void mul::useries(flint_series_t& fp, int order) const
+ 
+         if (oc.is_long())
+                 fmpq_poly_scalar_mul_si(fp.ft, fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_scalar_mul_mpz(fp.ft, fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_scalar_mul_mpq(fp.ft, fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_scalar_mul_fmpz(fp.ft, fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp.ft, fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ void power::useries(flint_series_t& fp, int order) const
+@@ -563,7 +577,10 @@ void power::useries(flint_series_t& fp, int order) const
+                 }
+                 check_poly_ccoeff_one(fp1);
+                 fmpq_poly_log_series(fp1.ft, fp1.ft, order);
+-                fmpq_poly_scalar_mul_mpq(fp1.ft, fp1.ft, nexp.as_mpq());
++                fmpq_t tmp;
++                fmpq_init_set_readonly(tmp, nexp.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp1.ft, fp1.ft, tmp);
++                fmpq_clear_readonly(tmp);
+                 fmpq_poly_exp_series(fp.ft, fp1.ft, order);
+                 return;
+         }
+@@ -608,10 +625,17 @@ void numeric::useries(flint_series_t& fp, int order) const
+ {
+         if (is_long())
+                 fmpq_poly_set_si(fp.ft, to_long());
+-        else if (is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, as_mpq());
++        else if (is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ } // namespace GiNaC
+diff --git a/src/sage_setup/library_order.py b/src/sage_setup/library_order.py
+index f40690f8d22..9ae0d2579a7 100644
+--- a/src/sage_setup/library_order.py
++++ b/src/sage_setup/library_order.py
+@@ -16,17 +16,12 @@
+ 
+ aliases = cython_aliases(required_modules=(), optional_modules=modules)
+ 
+-if "ARB_LIBRARY" in aliases:
+-    arb_dylib_names = [aliases["ARB_LIBRARY"]]
+-else:
+-    arb_dylib_names = []
+-
+ library_order_list = aliases.get("SINGULAR_LIBRARIES", []) + [
+     "giac", "intl", "curl",
+     "ec", "ecm"
+ ] + aliases.get("LINBOX_LIBRARIES", []) + aliases.get("FFLASFFPACK_LIBRARIES", []) + aliases.get("GSL_LIBRARIES", []) + [
+     "pari", "flint", "ecl", "glpk", "ppl",
+-] + arb_dylib_names + [
++] + [
+     "mpfi", "mpfr", "mpc", "ntl", "gmp", "gmpxx",
+     "brial",
+     "brial_groebner",
diff --git a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch b/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
deleted file mode 100644
index 7c55bce6e9bb4..0000000000000
--- a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
+++ /dev/null
@@ -1,221 +0,0 @@
-diff --git a/build/pkgs/singular/checksums.ini b/build/pkgs/singular/checksums.ini
-index 313463d2fea..1101fc55700 100644
---- a/build/pkgs/singular/checksums.ini
-+++ b/build/pkgs/singular/checksums.ini
-@@ -1,5 +1,5 @@
- tarball=singular-VERSION.tar.gz
--sha1=28bb3ee97ef48d04dfa96de182fd93eebe08426c
--md5=fc0a4f5720dadba45a52ee94324ce00c
--cksum=1573851737
--upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-1/singular-VERSION.tar.gz
-+sha1=df1997f412580f2073295aba569bb955ad227317
-+md5=50349213e206a18cdaa1bc410dde7ea4
-+cksum=376854707
-+upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-2/singular-VERSION.tar.gz
-diff --git a/build/pkgs/singular/package-version.txt b/build/pkgs/singular/package-version.txt
-index 66e2bede53a..9f1bf008217 100644
---- a/build/pkgs/singular/package-version.txt
-+++ b/build/pkgs/singular/package-version.txt
-@@ -1 +1 @@
--4.3.1p3
-+4.3.2p7
-diff --git a/build/pkgs/singular/spkg-configure.m4 b/build/pkgs/singular/spkg-configure.m4
-index 6a85631f624..f7621ec5fa1 100644
---- a/build/pkgs/singular/spkg-configure.m4
-+++ b/build/pkgs/singular/spkg-configure.m4
-@@ -6,14 +6,27 @@ SAGE_SPKG_CONFIGURE([singular], [
-     AS_IF([test -z "${SINGULAR_BIN}"], [sage_spkg_install_singular=yes], [
-       dnl Use pkg-config to ensure that Singular is new enough.
-       PKG_CHECK_MODULES([SINGULAR], [Singular >= 4.2.1], [
--       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)
--       ], [
--       AC_MSG_RESULT(no)
--       sage_spkg_install_singular=yes
--       ]
--      )], [
-+        AC_MSG_CHECKING([whether Singular is built with FLINT])
-+        AC_COMPILE_IFELSE([
-+          AC_LANG_PROGRAM([
-+            #include <singular/singularconfig.h>
-+            #if !defined(HAVE_FLINT)
-+            #  error "Need Singular compiled with FLINT"
-+          ], [])
-+        ], [
-+          AC_MSG_RESULT([yes])
-+          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)
-+          ], [
-+            AC_MSG_RESULT(no)
-+            sage_spkg_install_singular=yes
-+          ])
-+        ], [
-+          AC_MSG_RESULT([no])
-+          sage_spkg_install_singular=yes
-+        ])
-+      ], [
-       dnl pkg-config version check failed
-       sage_spkg_install_singular=yes
-       ])
-diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py
-index b15cc1c602c..4b5c76e2bfa 100644
---- a/src/sage/interfaces/singular.py
-+++ b/src/sage/interfaces/singular.py
-@@ -604,8 +604,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: i = singular.ideal(['x^2','y^2','z^2'])
-             sage: s = i.std()
-             sage: singular.eval('hilb(%s)'%(s.name()))
--            '// 1 t^0\n// -3 t^2\n// 3 t^4\n// -1 t^6\n\n// 1 t^0\n//
--            3 t^1\n// 3 t^2\n// 1 t^3\n// dimension (affine) = 0\n//
-+            '...// dimension (affine) = 0\n//
-             degree (affine) = 8'
- 
-         ::
-@@ -613,15 +612,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: from sage.misc.verbose import set_verbose
-             sage: set_verbose(1)
-             sage: o = singular.eval('hilb(%s)'%(s.name()))
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
- 
-         This is mainly useful if this method is called implicitly. Because
-@@ -631,15 +622,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-         ::
- 
-             sage: o = s.hilb()
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
-             // ** right side is not a datum, assignment ignored
-             ...
-diff --git a/src/sage/libs/singular/function.pyx b/src/sage/libs/singular/function.pyx
-index f40346d1fd0..c597c63aafe 100644
---- a/src/sage/libs/singular/function.pyx
-+++ b/src/sage/libs/singular/function.pyx
-@@ -1241,32 +1241,22 @@ cdef class SingularFunction(SageObject):
-             sage: I = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5])
-             sage: I = Ideal(I.groebner_basis())
-             sage: hilb = sage.libs.singular.function_factory.ff.hilb
--            sage: hilb(I) # Singular will print // ** _ is no standard basis
--            // ** _ is no standard basis
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: from sage.misc.sage_ostools import redirection
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I) # Singular will print // ** _ is no standard basis
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            True
- 
-         So we tell Singular that ``I`` is indeed a Groebner basis::
- 
--            sage: hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            False
- 
- 
-         TESTS:
-diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-index 22ada6de947..80352700872 100644
---- a/src/sage/rings/polynomial/multi_polynomial_ideal.py
-+++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-@@ -3132,13 +3132,16 @@ def hilbert_numerator(self, grading=None, algorithm='sage'):
-             sage: I.hilbert_numerator()                                                 # needs sage.rings.number_field
-             -t^5 + 1
- 
--        This example returns a wrong answer due to an integer overflow in Singular::
-+        This example returns a wrong answer in singular < 4.3.2p4 due to an integer overflow::
- 
-             sage: n=4; m=11; P = PolynomialRing(QQ, n*m, "x"); x = P.gens(); M = Matrix(n, x)
-             sage: I = P.ideal(M.minors(2))
-             sage: J = P * [m.lm() for m in I.groebner_basis()]
--            sage: J.hilbert_numerator(algorithm='singular')
--            ...120*t^33 - 3465*t^32 + 48180*t^31 - ...
-+            sage: J.hilbert_numerator(algorithm='singular') # known bug
-+            Traceback (most recent call last):
-+            ....
-+            RuntimeError: error in Singular function call 'hilb':
-+            overflow at t^22
- 
-         Our two algorithms should always agree; not tested until
-         :trac:`33178` is fixed::
-diff --git a/src/sage/sandpiles/sandpile.py b/src/sage/sandpiles/sandpile.py
-index 02d2021b2fb..c8e15e06f05 100644
---- a/src/sage/sandpiles/sandpile.py
-+++ b/src/sage/sandpiles/sandpile.py
-@@ -2493,9 +2493,15 @@ def _set_ideal(self):
-             sage: '_ideal' in S.__dict__
-             True
-         """
-+        from sage.libs.singular.function_factory import ff
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
-         R = self.ring()
--        I = self._unsaturated_ideal._singular_()
--        self._ideal = R.ideal(I.sat(prod(R.gens())._singular_())[1])
-+        I = self._unsaturated_ideal
-+        I_sat_gens = sat(I, prod(R.gens()))[0]
-+        self._ideal = R.ideal(I_sat_gens)
- 
-     def unsaturated_ideal(self):
-         r"""
-diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py
-index e6caf19ba74..afd6484d779 100644
---- a/src/sage/schemes/projective/projective_subscheme.py
-+++ b/src/sage/schemes/projective/projective_subscheme.py
-@@ -1001,7 +1001,10 @@ def dual(self):
-         for i in range(n + 1):
-             J = J + S.ideal(z[-1] * f_S.derivative(z[i]) - z[i + n + 1])
- 
--        sat = ff.elim__lib.sat
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
- 
-         max_ideal = S.ideal(z[n + 1: 2 * n + 2])
-         J_sat_gens = sat(J, max_ideal)[0]
diff --git a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch b/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
deleted file mode 100644
index 6a35ec3836550..0000000000000
--- a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-diff --git a/src/sage/ext/memory.pyx b/src/sage/ext/memory.pyx
-index 1de6dedab82..b95130b19dd 100644
---- a/src/sage/ext/memory.pyx
-+++ b/src/sage/ext/memory.pyx
-@@ -3,14 +3,14 @@ Low-level memory allocation functions
- 
- TESTS:
- 
--Check that a ``MemoryError`` is raised if we try to allocate a
-+Check that an error is raised if we try to allocate a
- ridiculously large integer, see :trac:`15363`::
- 
--    sage: 2^(2^63-3)
--    Traceback (most recent call last):
--    ...
--    OverflowError: exponent must be at most 2147483647         # 32-bit
--    RuntimeError: Aborted                                      # 64-bit
-+    sage: try:
-+    ....:     2^(2^63-3)
-+    ....: except (OverflowError, RuntimeError, FloatingPointError):
-+    ....:     print ('Overflow error')
-+    ...Overflow error
- 
- AUTHORS:
- 
-diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx
-index d5e87626d31..37ed9364845 100644
---- a/src/sage/rings/integer.pyx
-+++ b/src/sage/rings/integer.pyx
-@@ -6654,7 +6654,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
-             sage: try:
-             ....:     print('Possible error output from gmp', flush=True)
-             ....:     1 << (2^60)
--            ....: except (MemoryError, OverflowError, RuntimeError):
-+            ....: except (MemoryError, OverflowError, RuntimeError, FloatingPointError):
-             ....:     pass
-             ....: else:
-             ....:     print("Failed to raise exception")
diff --git a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch b/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
deleted file mode 100644
index 3d2a4bd9cd96f..0000000000000
--- a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
+++ /dev/null
@@ -1,740 +0,0 @@
-diff --git a/src/sage/ext_data/valgrind/valgrind-python.supp b/src/sage/ext_data/valgrind/valgrind-python.supp
-new file mode 100644
-index 00000000000..16aa2858484
---- /dev/null
-+++ b/src/sage/ext_data/valgrind/valgrind-python.supp
-@@ -0,0 +1,480 @@
-+# From the CPython repository with the suppressions for _PyObject_Free
-+# and _PyObject_Realloc enabled. See the upstream suppression file for
-+# details:
-+#
-+# https://github.com/python/cpython/blob/main/Misc/valgrind-python.supp
-+
-+# all tool names: Addrcheck,Memcheck,cachegrind,helgrind,massif
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 8 (x86_64 aka amd64)
-+   Memcheck:Value8
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:address_in_range
-+}
-+
-+#
-+# Leaks (including possible leaks)
-+#    Hmmm, I wonder if this masks some real leaks.  I think it does.
-+#    Will need to fix that.
-+#
-+
-+{
-+   Suppress leaking the GIL after a fork.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_allocate_lock
-+   fun:PyEval_ReInitThreads
-+}
-+
-+{
-+   Suppress leaking the autoTLSkey.  This looks like it shouldn't leak though.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_create_key
-+   fun:_PyGILState_Init
-+   fun:Py_InitializeEx
-+   fun:Py_Main
-+}
-+
-+{
-+   Hmmm, is this a real leak or like the GIL?
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_ReInitTLS
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:realloc
-+   fun:_PyObject_GC_Resize
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_New
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_NewVar
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+#
-+# Non-python specific leaks
-+#
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:calloc
-+   fun:allocate_dtv
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:memalign
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Realloc
-+}
-+
-+###
-+### All the suppressions below are for errors that occur within libraries
-+### that Python uses.  The problems to not appear to be related to Python's
-+### use of the libraries.
-+###
-+
-+{
-+   Generic ubuntu ld problems
-+   Memcheck:Addr8
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+}
-+
-+{
-+   Generic gentoo ld problems
-+   Memcheck:Cond
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_close
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Value8
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   GDBM problems, see test_gdbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   fun:gdbm_open
-+
-+}
-+
-+{
-+   Uninitialised byte(s) false alarm, see bpo-35561
-+   Memcheck:Param
-+   epoll_ctl(event)
-+   fun:epoll_ctl
-+   fun:pyepoll_internal_ctl
-+}
-+
-+{
-+   ZLIB problems, see test_gzip
-+   Memcheck:Cond
-+   obj:/lib/libz.so.1.2.3
-+   obj:/lib/libz.so.1.2.3
-+   fun:deflate
-+}
-+
-+{
-+   Avoid problems w/readline doing a putenv and leaking on exit
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:xmalloc
-+   fun:sh_set_lines_and_columns
-+   fun:_rl_get_screen_size
-+   fun:_rl_init_terminal_io
-+   obj:/lib/libreadline.so.4.3
-+   fun:rl_initialize
-+}
-+
-+# Valgrind emits "Conditional jump or move depends on uninitialised value(s)"
-+# false alarms on GCC builtin strcmp() function. The GCC code is correct.
-+#
-+# Valgrind bug: https://bugs.kde.org/show_bug.cgi?id=264936
-+{
-+   bpo-38118: Valgrind emits false alarm on GCC builtin strcmp()
-+   Memcheck:Cond
-+   fun:PyUnicode_Decode
-+}
-+
-+
-+###
-+### These occur from somewhere within the SSL, when running
-+###  test_socket_sll.  They are too general to leave on by default.
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:memset
-+###}
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:memset
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:MD5_Update
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:MD5_Update
-+###}
-+
-+# Fedora's package "openssl-1.0.1-0.1.beta2.fc17.x86_64" on x86_64
-+# See http://bugs.python.org/issue14171
-+{
-+   openssl 1.0.1 prng 1
-+   Memcheck:Cond
-+   fun:bcmp
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 2
-+   Memcheck:Cond
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 3
-+   Memcheck:Value8
-+   fun:_x86_64_AES_encrypt_compact
-+   fun:AES_encrypt
-+}
-+
-+#
-+# All of these problems come from using test_socket_ssl
-+#
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_bin2bn
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libcrypto.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_set_key_unchecked
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_encrypt2
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BUF_MEM_grow_clean
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:memcpy
-+   fun:ssl3_read_bytes
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:SHA1_Update
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:SHA1_Update
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-+{
-+   wcscmp_false_positive
-+   Memcheck:Addr8
-+   fun:wcscmp
-+   fun:_PyOS_GetOpt
-+   fun:Py_Main
-+   fun:main
-+}
-+
-+# Additional suppressions for the unified decimal tests:
-+{
-+   test_decimal
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_decimal2
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index b40ed64edb5..8c55861c147 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -1576,6 +1576,62 @@ const numeric numeric::div(const numeric &other) const {
-         }
- }
- 
-+
-+// Compute `a^b` as an integer, where a is an integer. Assign to ``res``` if it is integral, or return ``false``.
-+// The nonnegative real root is taken for even denominators. To be used inside numeric::integer_rational_power,
-+// to handle the special case of integral ``a``.
-+bool integer_rational_power_of_mpz(
-+        numeric& res,
-+        const numeric& a,
-+        const numeric& b
-+) {
-+        if (a.t != MPZ)
-+                throw std::runtime_error("integer_rational_power_of_mpz: bad input");
-+        mpz_t z;
-+        mpz_init(z);
-+        mpz_set_ui(z, 0);
-+        int sgn = mpz_sgn(a.v._bigint);
-+        if (mpz_cmp_ui(a.v._bigint, 1) == 0
-+            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
-+                mpz_set_ui(z, 1);
-+        else if (sgn == 0) {
-+                res = *_num0_p;
-+                mpz_clear(z);
-+                return true;
-+        }
-+        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1)) {
-+                mpz_clear(z);
-+                return false;
-+        } else {
-+                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-+                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat))) {
-+                        // too big to take roots/powers
-+                        mpz_clear(z);
-+                        return false;
-+                }
-+                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
-+                        if (mpz_perfect_square_p(a.v._bigint)) {
-+                                mpz_sqrt(z, a.v._bigint);
-+                        } else {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                else {
-+                        bool exact = mpz_root(z, a.v._bigint,
-+                                              mpz_get_ui(mpq_denref(b.v._bigrat)));
-+                        if (not exact) {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
-+        }
-+        res = numeric(z);   // transfers ownership, no mpz_clear
-+        return true;
-+}
-+
-+
- // Compute `a^b` as an integer, if it is integral, or return ``false``.
- // The nonnegative real root is taken for even denominators.
- bool numeric::integer_rational_power(numeric& res,
-@@ -1598,13 +1654,12 @@ bool numeric::integer_rational_power(numeric& res,
-                 if (a.v._long < 0
-                     and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
-                         return false;
--                long z;
-                 if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-                     or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
-                 // too big to take roots/powers
-                         return false;
-                 if (b.is_equal(*_num1_2_p)) {
--                        z = std::lround(std::sqrt(a.v._long));
-+                        long z = std::lround(std::sqrt(a.v._long));
-                         if (a.v._long == z*z) {
-                                 res = numeric(z);
-                                 return true;
-@@ -1613,44 +1668,11 @@ bool numeric::integer_rational_power(numeric& res,
-                 }
-                 return integer_rational_power(res, a.to_bigint(), b);
-         }
--        if (a.t != MPZ)
--                throw std::runtime_error("integer_rational_power: bad input");
--        int sgn = mpz_sgn(a.v._bigint);
--        mpz_t z;
--        mpz_init(z);
--        mpz_set_ui(z, 0);
--        if (mpz_cmp_ui(a.v._bigint, 1) == 0
--            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
--                mpz_set_ui(z, 1);
--        else if (sgn == 0) {
--                res = *_num0_p;
--                return true;
--        }
--        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
--                return false;
--        else {
--                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
--                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
--                // too big to take roots/powers
--                        return false;
--                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
--                        if (mpz_perfect_square_p(a.v._bigint))
--                                mpz_sqrt(z, a.v._bigint);
--                        else
--                                return false;
--                }
--                else {
--                        bool exact = mpz_root(z, a.v._bigint,
--                                        mpz_get_ui(mpq_denref(b.v._bigrat)));
--                        if (not exact)
--                                return false;
--                }
--                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
--        }
--        res = numeric(z);
--        return true;
-+        // otherwise: a is integer
-+        return integer_rational_power_of_mpz(res, a, b);
- }
- 
-+
- // for a^b return c,d such that a^b = c*d^b
- // only for MPZ/MPQ base and MPQ exponent
- void rational_power_parts(const numeric& a_orig, const numeric& b_orig,
-diff --git a/src/sage/tests/memcheck/__init__.py b/src/sage/tests/memcheck/__init__.py
-new file mode 100644
-index 00000000000..e69de29bb2d
-diff --git a/src/sage/tests/memcheck/run_tests.py b/src/sage/tests/memcheck/run_tests.py
-new file mode 100644
-index 00000000000..6ff4503a81b
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests.py
-@@ -0,0 +1,24 @@
-+import types
-+
-+
-+def run_tests() -> None:
-+    """
-+    Run all memcheck tests
-+    """
-+    from sage.tests.memcheck import symbolic_expression
-+    run_tests_in_module(symbolic_expression)
-+
-+
-+def run_tests_in_module(mod: types.ModuleType) -> None:
-+    """
-+    Run all memcheck tests in the given module
-+    """
-+    for entry in dir(mod):
-+        if not entry.startswith('test_'):
-+            continue
-+        test_func = getattr(mod, entry)
-+        test_func()
-+
-+
-+if __name__ == '__main__':
-+    run_tests()
-diff --git a/src/sage/tests/memcheck/run_tests_in_valgrind.py b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-new file mode 100644
-index 00000000000..df5ad0e92b2
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-@@ -0,0 +1,35 @@
-+"""
-+Launch valgrind and run the memory leak tests
-+
-+
-+From the commandline, run
-+
-+    sage -python -m sage.tests.memcheck.run_tests_in_valgrind
-+
-+to launch valgrind and execute the memory leak tests. Requires valgrind
-+to be installed. Alternatively, run as a unit test:
-+
-+    sage: from sage.tests.memcheck.run_tests_in_valgrind import run_tests_in_valgrind
-+    sage: run_tests_in_valgrind()    # optional - valgrind
-+"""
-+
-+import subprocess
-+
-+
-+def run_tests_in_valgrind() -> None:
-+    """
-+    Run the sage.tests.memcheck.run_tests module inside valgrind
-+    """
-+    subprocess.check_call([
-+        'valgrind',
-+        '--suppressions=src/sage/ext_data/valgrind/valgrind-python.supp',
-+        '--show-possibly-lost=no',
-+        '--show-reachable=no',
-+        './venv/bin/python',
-+        '-m',
-+        'sage.tests.memcheck.run_tests'
-+    ])
-+
-+
-+if __name__ == '__main__':
-+    run_tests_in_valgrind()
-diff --git a/src/sage/tests/memcheck/symbolic_expression.py b/src/sage/tests/memcheck/symbolic_expression.py
-new file mode 100644
-index 00000000000..52182fbe62d
---- /dev/null
-+++ b/src/sage/tests/memcheck/symbolic_expression.py
-@@ -0,0 +1,11 @@
-+from sage.tests.memcheck.verify_no_leak import verify_no_leak
-+
-+
-+def test_sqrt_sqrt_2() -> None:
-+    from sage.misc.functional import sqrt
-+    T2 = sqrt(2)
-+
-+    def sqrt_T2() -> None:
-+        sqrt(T2)
-+
-+    verify_no_leak(sqrt_T2)
-diff --git a/src/sage/tests/memcheck/verify_no_leak.py b/src/sage/tests/memcheck/verify_no_leak.py
-new file mode 100644
-index 00000000000..89ca90cf89c
---- /dev/null
-+++ b/src/sage/tests/memcheck/verify_no_leak.py
-@@ -0,0 +1,27 @@
-+from typing import Tuple, Sequence, List, Callable, Any
-+import valgrind
-+
-+
-+def verify_no_leak(callback: Callable[[], Any],
-+                   repeat: int = 10000,
-+                   fuzzy: int = 10,
-+                   ) -> None:
-+    """
-+    Verify that the callback does not generate new definitely lost blocks
-+
-+    Raises an assertion if the callback leaks memory
-+    """
-+    callback()   # warm_up
-+    initial_blocks = (0, 0, 0, 0)
-+    valgrind.memcheck_do_leak_check()
-+    initial_blocks = valgrind.memcheck_count_leak_blocks()
-+    for _ in range(repeat):
-+        callback()
-+    valgrind.memcheck_do_leak_check()
-+    leak_blocks = valgrind.memcheck_count_leak_blocks()
-+    leak = leak_blocks[0] - initial_blocks[0]
-+    if leak < repeat - fuzzy:
-+        return  # callback did not leak at least once per call
-+    blocks = round(leak / repeat, 2)
-+    message = f'{callback} leaked {blocks} block on average ({repeat} iterations)'
-+    raise AssertionError(message)
diff --git a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch b/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
deleted file mode 100644
index 684b62affaf5a..0000000000000
--- a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx
-index 8f46570313d..a8e73e57b52 100644
---- a/src/sage/libs/ecl.pyx
-+++ b/src/sage/libs/ecl.pyx
-@@ -563,15 +563,15 @@ cdef class EclObject:
-     Floats in Python are IEEE double, which LISP has as well. However,
-     the printing of floating point types in LISP depends on settings::
- 
--        sage: a = EclObject(float(10^40))
-+        sage: a = EclObject(float(1.234e40))
-         sage: ecl_eval("(setf *read-default-float-format* 'single-float)")
-         <ECL: SINGLE-FLOAT>
-         sage: a
--        <ECL: 1.d40>
-+        <ECL: 1.234d40>
-         sage: ecl_eval("(setf *read-default-float-format* 'double-float)")
-         <ECL: DOUBLE-FLOAT>
-         sage: a
--        <ECL: 1.e40>
-+        <ECL: 1.234e40>
- 
-     Tuples are translated to dotted lists::
- 
-diff --git a/src/sage/libs/eclsig.h b/src/sage/libs/eclsig.h
-index e249ccf6874..005b2d99d0b 100644
---- a/src/sage/libs/eclsig.h
-+++ b/src/sage/libs/eclsig.h
-@@ -45,7 +45,11 @@ static inline void ecl_sig_off(void)
-     sig_off();
- }
- 
-+#if ECL_VERSION_NUMBER < 230909
- #define ecl_mpz_from_bignum(obj) ((obj)->big.big_num)
-+#else
-+#define ecl_mpz_from_bignum(obj) ecl_bignum(obj)
-+#endif
- 
- cl_object ecl_bignum_from_mpz(mpz_t num)
- {
diff --git a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch b/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
deleted file mode 100644
index e858f2fd4a445..0000000000000
--- a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
-index 59f10f6b13f..adcccff059b 100644
---- a/src/sage/plot/graphics.py
-+++ b/src/sage/plot/graphics.py
-@@ -36,6 +36,7 @@
- # ****************************************************************************
- 
- import os
-+from numbers import Integral
- from collections.abc import Iterable
- from math import isnan
- import sage.misc.verbose
-@@ -2874,6 +2875,11 @@ def matplotlib(self, filename=None,
-                 weight=lopts.pop('font_weight', 'medium'),
-                 variant=lopts.pop('font_variant', 'normal'))
-             color = lopts.pop('back_color', 'white')
-+            if 'loc' in lopts:
-+                loc = lopts['loc']
-+                if isinstance(loc, Integral):
-+                    # matplotlib 3.8 doesn't support sage integers
-+                    lopts['loc'] = int(loc)
-             leg = subplot.legend(prop=prop, **lopts)
-             if leg is None:
-                 from warnings import warn
diff --git a/srcpkgs/sagemath/patches/36403-00pre.patch b/srcpkgs/sagemath/patches/36403-00pre.patch
deleted file mode 100644
index 060404d5430de..0000000000000
--- a/srcpkgs/sagemath/patches/36403-00pre.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-Minor patch so that #36403 applies cleanly over sagemath 10.1
-
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 2053bca80c3..86aca6e00d8 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15123,7 +15302,8 @@ cdef class Matrix(Matrix1):
-             sage: N.conjugate_transpose()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object has no attribute 'conjugate'
-+            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
-+            has no attribute 'conjugate'
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 525ea5aa934..52afed49d64 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -55,7 +55,7 @@ cdef class AttributeErrorMessage:
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-         sage: x = polygen(ZZ, 'x')
--        sage: QQ[x].gen().bla                                                           # optional - sage.libs.flint
-+        sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
diff --git a/srcpkgs/sagemath/patches/36407-python_3.12.patch b/srcpkgs/sagemath/patches/36407-python_3.12.patch
deleted file mode 100644
index c75c275c30764..0000000000000
--- a/srcpkgs/sagemath/patches/36407-python_3.12.patch
+++ /dev/null
@@ -1,1744 +0,0 @@
-diff --git a/build/sage_bootstrap/package.py b/build/sage_bootstrap/package.py
-index 15b342223c4..eb82f96e05f 100644
---- a/build/sage_bootstrap/package.py
-+++ b/build/sage_bootstrap/package.py
-@@ -303,7 +303,7 @@ def _init_checksum(self):
-         # Name of the directory containing the checksums.ini file
-         self.__tarball_package_name = os.path.realpath(checksums_ini).split(os.sep)[-2]
- 
--    VERSION_PATCHLEVEL = re.compile('(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
-+    VERSION_PATCHLEVEL = re.compile(r'(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
- 
-     def _init_version(self):
-         try:
-diff --git a/src/doc/en/thematic_tutorials/coercion_and_categories.rst b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-index bb23331c151..7f5712caea7 100644
---- a/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-+++ b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-@@ -1223,7 +1223,7 @@ However, only "elementary" construction functors have a rank::
-     sage: (Fract*Poly).rank
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'
-+    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'...
- 
- .. end of output
- 
-diff --git a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-index 553a946c4d8..3cd71a9bad4 100644
---- a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-+++ b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-@@ -318,7 +318,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: e.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'...
- 
-         sage: id4 = SymmetricGroup(4).one()
-         sage: type(id4)
-@@ -326,7 +326,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: id4.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'
-+        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'...
- 
- .. note::
- 
-diff --git a/src/sage/algebras/cluster_algebra.py b/src/sage/algebras/cluster_algebra.py
-index b72d2a12976..14669dfed5c 100644
---- a/src/sage/algebras/cluster_algebra.py
-+++ b/src/sage/algebras/cluster_algebra.py
-@@ -167,7 +167,7 @@
-     sage: (t*s).g_vector()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'
-+    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'...
-     sage: A = ClusterAlgebra(['A', 2], principal_coefficients=True)
-     sage: A.explore_to_depth(infinity)
-     sage: s = A.cluster_variable((0, -1)); s
-diff --git a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-index e4a91723558..343ee8a66f9 100644
---- a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-+++ b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-@@ -109,7 +109,7 @@ class WeylLieConformalAlgebra(LieConformalAlgebraWithStructureCoefficients):
-         sage: alpha0.degree()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'
-+        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'...
- 
-     TESTS::
- 
-diff --git a/src/sage/algebras/steenrod/steenrod_algebra.py b/src/sage/algebras/steenrod/steenrod_algebra.py
-index 978a3557a9d..7c4d444f81c 100644
---- a/src/sage/algebras/steenrod/steenrod_algebra.py
-+++ b/src/sage/algebras/steenrod/steenrod_algebra.py
-@@ -1080,7 +1080,7 @@ def homogeneous_component(self, n):
-             sage: a.antipode() # not defined
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'
-+            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'...
-             sage: A(a).antipode() # convert to elt of A, then compute antipode
-             Sq(2,1) + Sq(5)
- 
-diff --git a/src/sage/all__sagemath_repl.py b/src/sage/all__sagemath_repl.py
-index 8d0b43679ca..c31b206bcb8 100644
---- a/src/sage/all__sagemath_repl.py
-+++ b/src/sage/all__sagemath_repl.py
-@@ -79,6 +79,23 @@
-                         message=r"Use setlocale\(\), getencoding\(\) and getlocale\(\) instead",
-                         module='docutils.io')
- 
-+# triggered by dateutil 2.8.2 and sphinx 7.0.1 on Python 3.12
-+# see: https://github.com/dateutil/dateutil/pull/1285
-+# see: https://github.com/sphinx-doc/sphinx/pull/11468
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"datetime.datetime.utcfromtimestamp\(\) is deprecated",
-+                        module='dateutil.tz.tz|sphinx.(builders.gettext|util.i18n)')
-+
-+# triggered on Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"This process.* is multi-threaded, "
-+                                r"use of .*\(\) may lead to deadlocks in the child.")
-+
-+# pickling of itertools is deprecated in Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"Pickle, copy, and deepcopy support will be "
-+                                r"removed from itertools in Python 3.14.")
-+
- 
- from .all__sagemath_objects import *
- from .all__sagemath_environment import *
-diff --git a/src/sage/arith/long.pxd b/src/sage/arith/long.pxd
-index 0031a0ae337..3ea70cef571 100644
---- a/src/sage/arith/long.pxd
-+++ b/src/sage/arith/long.pxd
-@@ -19,6 +19,8 @@ from libc.limits cimport LONG_MIN, LONG_MAX
- from cpython.object cimport Py_SIZE
- from cpython.number cimport PyNumber_Index, PyIndex_Check
- from cpython.longintrepr cimport py_long, PyLong_SHIFT, digit
-+from sage.cpython.pycore_long cimport (
-+    ob_digit, _PyLong_IsNegative, _PyLong_DigitCount)
- 
- from sage.libs.gmp.mpz cimport mpz_fits_slong_p, mpz_get_si
- from sage.rings.integer_fake cimport is_Integer, Integer_AS_MPZ
-@@ -299,8 +301,11 @@ cdef inline bint integer_check_long_py(x, long* value, int* err):
-         return 0
- 
-     # x is a Python "int" (aka PyLongObject or py_long in cython)
--    cdef const digit* D = (<py_long>x).ob_digit
--    cdef Py_ssize_t size = Py_SIZE(x)
-+    cdef const digit* D = ob_digit(x)
-+    cdef Py_ssize_t size = _PyLong_DigitCount(x)
-+
-+    if _PyLong_IsNegative(x):
-+        size = -size
- 
-     # We assume PyLong_SHIFT <= BITS_IN_LONG <= 3 * PyLong_SHIFT.
-     # This is true in all the default configurations:
-diff --git a/src/sage/categories/category.py b/src/sage/categories/category.py
-index 57ef7f4184b..29bce8ee415 100644
---- a/src/sage/categories/category.py
-+++ b/src/sage/categories/category.py
-@@ -2129,7 +2129,7 @@ def _with_axioms(self, axioms):
-             sage: Semigroups().Inverse()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'
-+            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'...
-             sage: Semigroups()._with_axioms(["Inverse"])
-             Category of semigroups
- 
-diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py
-index 5227792e725..4775d4e5bf1 100644
---- a/src/sage/categories/category_with_axiom.py
-+++ b/src/sage/categories/category_with_axiom.py
-@@ -554,7 +554,7 @@ class from the base category class::
-     sage: Magmas.Unital.Associative
-     Traceback (most recent call last):
-     ...
--    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'
-+    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'...
- 
- The purpose of this section is to explain the design of the code
- layout and the rationale for this mismatch.
-@@ -769,7 +769,7 @@ def _(): return LazyImport('sage.categories.rngs', 'Rngs', at_startup=True)
-     sage: Semirings().NoZeroDivisors()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'
-+    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'...
- 
- Concretely, this is to be implemented by defining the new axiom in the
- (``SubcategoryMethods`` nested class of the) appropriate category with
-diff --git a/src/sage/categories/enumerated_sets.py b/src/sage/categories/enumerated_sets.py
-index a8bea53f907..b0ea05d0563 100644
---- a/src/sage/categories/enumerated_sets.py
-+++ b/src/sage/categories/enumerated_sets.py
-@@ -610,7 +610,7 @@ def _list_from_iterator(self):
-                 sage: (QQ^2).list()  # indirect test                                    # needs sage.modules
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'
-+                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'...
- 
-             Here we test that for an object that does not know whether it
-             is finite or not.  Calling ``x.list()`` simply tries to create
-@@ -622,11 +622,11 @@ def _list_from_iterator(self):
-                 sage: Q.is_finite()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'...
-                 sage: Q.list()   # indirect test
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'...
- 
-             Here is another example. We artificially create a version of
-             the ring of integers that does not know whether it is finite
-diff --git a/src/sage/categories/examples/sets_cat.py b/src/sage/categories/examples/sets_cat.py
-index e0853d63f94..fbadb9ca405 100644
---- a/src/sage/categories/examples/sets_cat.py
-+++ b/src/sage/categories/examples/sets_cat.py
-@@ -619,7 +619,7 @@ class PrimeNumbers_Facade(PrimeNumbers_Abstract):
-         sage: pf.next()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'...
- 
-     unlike in the other implementations::
- 
-diff --git a/src/sage/categories/homset.py b/src/sage/categories/homset.py
-index 22ba9d047fc..2a8b8aeedeb 100644
---- a/src/sage/categories/homset.py
-+++ b/src/sage/categories/homset.py
-@@ -632,7 +632,7 @@ def __init__(self, X, Y, category=None, base=None, check=True):
-             sage: H = MyHomset(X, Y, category=1, base = ZZ, check = False)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'...
-             sage: P.<t> = ZZ[]
-             sage: f = P.hom([1/2*t])
-             sage: f.parent().domain()
-diff --git a/src/sage/categories/modules_with_basis.py b/src/sage/categories/modules_with_basis.py
-index e97bf851388..c4933d0657f 100644
---- a/src/sage/categories/modules_with_basis.py
-+++ b/src/sage/categories/modules_with_basis.py
-@@ -2456,7 +2456,7 @@ def apply_multilinear_morphism(self, f, codomain=None):
-                     sage: tensor([a, b]).apply_multilinear_morphism(f)                  # needs sage.modules
-                     Traceback (most recent call last):
-                     ...
--                    AttributeError: 'int' object has no attribute 'parent'
-+                    AttributeError: 'int' object has no attribute 'parent'...
- 
-                 Here we consider an example where the codomain is a
-                 module with basis with a different base ring::
-diff --git a/src/sage/categories/monoids.py b/src/sage/categories/monoids.py
-index 38dd7248c9d..28474bd17b6 100644
---- a/src/sage/categories/monoids.py
-+++ b/src/sage/categories/monoids.py
-@@ -556,7 +556,7 @@ def algebra_generators(self):
-                     Traceback (most recent call last):
-                     ...
-                     AttributeError: 'IntegerModMonoid_with_category' object
--                    has no attribute 'monoid_generators'
-+                    has no attribute 'monoid_generators'...
-                     sage: Z12.semigroup_generators()
-                     Family (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
-                     sage: Z12.algebra(QQ).algebra_generators()                          # needs sage.modules
-diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py
-index 494e8154c80..ec5120e41e6 100644
---- a/src/sage/combinat/finite_state_machine.py
-+++ b/src/sage/combinat/finite_state_machine.py
-@@ -1835,7 +1835,7 @@ def __getstate__(self):
-             sage: T1.transitions
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'FSMState' object has no attribute 'transitions'
-+            AttributeError: 'FSMState' object has no attribute 'transitions'...
-             sage: A1 = loads(dumps(A))
-             sage: all(A.state(j) == A1.state(j) for j in [0, 1])
-             True
-diff --git a/src/sage/combinat/growth.py b/src/sage/combinat/growth.py
-index cf8d18c1764..766eea37917 100644
---- a/src/sage/combinat/growth.py
-+++ b/src/sage/combinat/growth.py
-@@ -371,7 +371,7 @@
-     sage: GrowthDiagram(RulePascal(), [3,1,2])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'RulePascal' object has no attribute 'forward_rule'
-+    AttributeError: 'RulePascal' object has no attribute 'forward_rule'...
- 
- We now re-implement the rule where we provide the dual graded graphs::
- 
-diff --git a/src/sage/combinat/integer_lists/lists.py b/src/sage/combinat/integer_lists/lists.py
-index 5143e5cb5e8..9117a6076f7 100644
---- a/src/sage/combinat/integer_lists/lists.py
-+++ b/src/sage/combinat/integer_lists/lists.py
-@@ -261,7 +261,7 @@ def __getattr__(self, name):
-             sage: L.foo
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'foo'
-+            AttributeError: 'NoneType' object has no attribute 'foo'...
-         """
-         return getattr(self.backend, name)
- 
-diff --git a/src/sage/combinat/posets/posets.py b/src/sage/combinat/posets/posets.py
-index c31597c72e9..c74bfc67cee 100644
---- a/src/sage/combinat/posets/posets.py
-+++ b/src/sage/combinat/posets/posets.py
-@@ -8825,7 +8825,7 @@ def is_induced_subposet(self, other):
-             sage: Poset().is_induced_subposet('junk')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'subposet'
-+            AttributeError: 'str' object has no attribute 'subposet'...
-         """
-         if (not self._is_facade or (isinstance(other, FinitePoset) and
-                                     not other._is_facade)):
-diff --git a/src/sage/cpython/atexit.pyx b/src/sage/cpython/atexit.pyx
-index 961aa348d0a..e5a82735137 100644
---- a/src/sage/cpython/atexit.pyx
-+++ b/src/sage/cpython/atexit.pyx
-@@ -154,6 +154,10 @@ cdef extern from *:
-     #undef _PyGC_FINALIZED
-     #include "internal/pycore_interp.h"
-     #include "internal/pycore_pystate.h"
-+    #if PY_VERSION_HEX >= 0x030c0000
-+    // struct atexit_callback was renamed in 3.12 to atexit_py_callback
-+    #define atexit_callback atexit_py_callback
-+    #endif
-     static atexit_callback ** _atexit_callbacks(PyObject *self) {
-         PyInterpreterState *interp = _PyInterpreterState_GET();
-         struct atexit_state state = interp->atexit;
-diff --git a/src/sage/cpython/debug.pyx b/src/sage/cpython/debug.pyx
-index 986abff2a99..cdaca3a4854 100644
---- a/src/sage/cpython/debug.pyx
-+++ b/src/sage/cpython/debug.pyx
-@@ -78,7 +78,7 @@ def getattr_debug(obj, name, default=_no_default):
- 
-     EXAMPLES::
- 
--        sage: _ = getattr_debug(list, "reverse")
-+        sage: _ = getattr_debug(list, "reverse")  # not tested - broken in python 3.12
-         getattr_debug(obj=<class 'list'>, name='reverse'):
-           type(obj) = <class 'type'>
-           object has __dict__ slot (<class 'dict'>)
-@@ -123,7 +123,7 @@ def getattr_debug(obj, name, default=_no_default):
-         sage: _ = getattr_debug(1, "foo")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'...
-         sage: _ = getattr_debug(1, "foo", "xyz")
-         getattr_debug(obj=1, name='foo'):
-           type(obj) = <class 'sage.rings.integer.Integer'>
-diff --git a/src/sage/cpython/dict_internal.h b/src/sage/cpython/dict_internal.h
-index 42a57bcb468..a5ee35bc198 100644
---- a/src/sage/cpython/dict_internal.h
-+++ b/src/sage/cpython/dict_internal.h
-@@ -169,6 +169,7 @@ dictkeys_set_index(PyDictKeysObject *keys, Py_ssize_t i, Py_ssize_t ix)
- #else   /* Python >= 3.11 */
- 
- #define Py_BUILD_CORE
-+#undef _PyGC_FINALIZED
- #include <internal/pycore_dict.h>
- 
- /************************************************************/
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 52afed49d64..1f49e5230c3 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -53,12 +53,12 @@ cdef class AttributeErrorMessage:
-         sage: 1.bla  #indirect doctest
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'...
-         sage: x = polygen(ZZ, 'x')
-         sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'...
- 
-     ::
- 
-@@ -144,7 +144,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(X, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: x = X()
-         sage: raw_getattr(x, "prop")
-         <property object at ...>
-@@ -173,7 +173,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(Y, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: y = Y()
-         sage: raw_getattr(y, "prop")
-         <property object at ...>
-@@ -278,7 +278,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     The integer ring is a parent, so, lazy attributes work::
- 
-@@ -289,7 +289,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(17, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     In general, descriptors are not yet well supported, because they
-     often do not accept to be cheated with the type of their instance::
-@@ -305,7 +305,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__weakref__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-     This was caught by :trac:`8296` for which we do a couple more tests::
- 
-@@ -314,7 +314,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: 1.__weakref__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-         sage: n = 1
-         sage: ip = get_ipython()                 # not tested: only works in interactive shell
-@@ -329,7 +329,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__call__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'...
- 
-     TESTS:
- 
-@@ -339,14 +339,14 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, type, "__name__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'...
- 
-     Non-strings as "name" are handled gracefully::
- 
-         sage: getattr_from_other_class(1, type, None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute None
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute None...
-     """
-     if not isinstance(cls, type):
-         raise TypeError(f"{cls!r} is not a type")
-diff --git a/src/sage/cpython/pycore_long.h b/src/sage/cpython/pycore_long.h
-new file mode 100644
-index 00000000000..ff1a73d097a
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.h
-@@ -0,0 +1,98 @@
-+#include "Python.h"
-+#include <stdbool.h>
-+
-+#if PY_VERSION_HEX >= 0x030C00A5
-+#define ob_digit(o)  (((PyLongObject*)o)->long_value.ob_digit)
-+#else
-+#define ob_digit(o)  (((PyLongObject*)o)->ob_digit)
-+#endif
-+
-+#if PY_VERSION_HEX >= 0x030C00A7
-+// taken from cpython:Include/internal/pycore_long.h @ 3.12
-+
-+/* Long value tag bits:
-+ * 0-1: Sign bits value = (1-sign), ie. negative=2, positive=0, zero=1.
-+ * 2: Reserved for immortality bit
-+ * 3+ Unsigned digit count
-+ */
-+#define SIGN_MASK 3
-+#define SIGN_ZERO 1
-+#define SIGN_NEGATIVE 2
-+#define NON_SIZE_BITS 3
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_ZERO;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_NEGATIVE;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    assert(PyLong_Check(op));
-+    return op->long_value.lv_tag >> NON_SIZE_BITS;
-+}
-+
-+#define TAG_FROM_SIGN_AND_SIZE(sign, size) ((1 - (sign)) | ((size) << NON_SIZE_BITS))
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+    assert(size >= 0);
-+    assert(-1 <= sign && sign <= 1);
-+    assert(sign != 0 || size == 0);
-+    op->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sign, (size_t)size);
-+}
-+
-+#else
-+// fallback for < 3.12
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) == 0;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) < 0;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) > 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    Py_ssize_t size = Py_SIZE(op);
-+    return size < 0 ? -size : size;
-+}
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION < 9)
-+// The function Py_SET_SIZE is defined starting with python 3.9.
-+    Py_SIZE(o) = size;
-+#else
-+    Py_SET_SIZE(op, sign < 0 ? -size : size);
-+#endif
-+}
-+
-+#endif
-diff --git a/src/sage/cpython/pycore_long.pxd b/src/sage/cpython/pycore_long.pxd
-new file mode 100644
-index 00000000000..41de637ff18
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.pxd
-@@ -0,0 +1,9 @@
-+from cpython.longintrepr cimport py_long, digit
-+
-+cdef extern from "pycore_long.h":
-+    digit* ob_digit(py_long o)
-+    bint _PyLong_IsZero(py_long o)
-+    bint _PyLong_IsNegative(py_long o)
-+    bint _PyLong_IsPositive(py_long o)
-+    Py_ssize_t _PyLong_DigitCount(py_long o)
-+    void _PyLong_SetSignAndDigitCount(py_long o, int sign, Py_ssize_t size)
-diff --git a/src/sage/crypto/classical.py b/src/sage/crypto/classical.py
-index 616dc861652..be899c781e5 100644
---- a/src/sage/crypto/classical.py
-+++ b/src/sage/crypto/classical.py
-@@ -494,7 +494,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: A.rank_by_chi_square("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_chi_square(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -703,7 +703,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: A.rank_by_squared_differences("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_squared_differences(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -2114,7 +2114,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: S.rank_by_chi_square("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_chi_square(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-@@ -2351,7 +2351,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: S.rank_by_squared_differences("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_squared_differences(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/crypto/mq/mpolynomialsystemgenerator.py b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-index 9028dab1d98..4416d9ef7f6 100644
---- a/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-+++ b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-@@ -156,7 +156,7 @@ def sbox(self):
-             sage: msg.sbox()
-             Traceback (most recent call last):
-             ...
--            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'
-+            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'...
-         """
-         return self._sbox
- 
-diff --git a/src/sage/data_structures/bitset.pyx b/src/sage/data_structures/bitset.pyx
-index 446062554c1..d9906b5edd2 100644
---- a/src/sage/data_structures/bitset.pyx
-+++ b/src/sage/data_structures/bitset.pyx
-@@ -967,7 +967,7 @@ cdef class FrozenBitset:
-             sage: None | FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute '_union'
-+            AttributeError: 'NoneType' object has no attribute '_union'...
-         """
-         return self._union(other)
- 
-@@ -1037,7 +1037,7 @@ cdef class FrozenBitset:
-             sage: None & FrozenBitset("101011")
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'intersection'
-+            AttributeError: 'NoneType' object has no attribute 'intersection'...
-         """
-         return self.intersection(other)
- 
-@@ -1106,7 +1106,7 @@ cdef class FrozenBitset:
-             sage: None - FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'difference'
-+            AttributeError: 'NoneType' object has no attribute 'difference'...
-         """
-         return self.difference(other)
- 
-@@ -1179,7 +1179,7 @@ cdef class FrozenBitset:
-             sage: None ^^ FrozenBitset('11111' * 10)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'
-+            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'...
-         """
-         return self.symmetric_difference(other)
- 
-diff --git a/src/sage/doctest/reporting.py b/src/sage/doctest/reporting.py
-index 361fea344c2..a3947c07e01 100644
---- a/src/sage/doctest/reporting.py
-+++ b/src/sage/doctest/reporting.py
-@@ -368,7 +368,7 @@ def report(self, source, timeout, return_code, results, output, pid=None):
-             sage: DTR.report(None, None, None, None, None)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'basename'
-+            AttributeError: 'NoneType' object has no attribute 'basename'...
- 
-         The only-errors mode does not output anything on success::
- 
-diff --git a/src/sage/dynamics/finite_dynamical_system.py b/src/sage/dynamics/finite_dynamical_system.py
-index e5fbf568b7e..4295070615a 100644
---- a/src/sage/dynamics/finite_dynamical_system.py
-+++ b/src/sage/dynamics/finite_dynamical_system.py
-@@ -240,7 +240,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-@@ -252,7 +252,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-diff --git a/src/sage/geometry/cone.py b/src/sage/geometry/cone.py
-index f0a8620011a..53f78a4b7b6 100644
---- a/src/sage/geometry/cone.py
-+++ b/src/sage/geometry/cone.py
-@@ -340,7 +340,7 @@ def Cone(rays, lattice=None, check=True, normalize=True):
-         sage: Cone([(1,0), (0,1)], check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     You can construct different "not" cones: not full-dimensional, not
-     strictly convex, not containing any rays::
-diff --git a/src/sage/geometry/fan.py b/src/sage/geometry/fan.py
-index 258544012fe..3aecc84a55b 100644
---- a/src/sage/geometry/fan.py
-+++ b/src/sage/geometry/fan.py
-@@ -443,7 +443,7 @@ def Fan(cones, rays=None, lattice=None, check=True, normalize=True,
-         sage: P2c = Fan(cones, rays, check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     Yet another way is to use functions :func:`FaceFan` and :func:`NormalFan`
-     to construct fans from :class:`lattice polytopes
-diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-index f0ac1e774a7..f03f0f832ff 100644
---- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-+++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-@@ -351,7 +351,7 @@ cdef class FaceIterator_base(SageObject):
-             sage: FaceIterator_base(2)  # indirect doctest
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'...
-         """
-         cdef int i
-         sig_free(self.structure.atom_rep)
-@@ -1945,7 +1945,8 @@ cdef inline int next_face_loop(iter_t structure) nogil except -1:
-         # The function is not supposed to be called,
-         # just prevent it from crashing.
-         # Actually raising an error here results in a bad branch prediction.
--        return -1
-+        # But return -1 results in a crash with python 3.12
-+        raise StopIteration
- 
-     # Getting ``[faces, n_faces, n_visited_all]`` according to dimension.
-     cdef face_list_t* faces = &structure.new_faces[structure.current_dimension]
-diff --git a/src/sage/geometry/toric_plotter.py b/src/sage/geometry/toric_plotter.py
-index 50b4008eb0f..950e3ba7ff8 100644
---- a/src/sage/geometry/toric_plotter.py
-+++ b/src/sage/geometry/toric_plotter.py
-@@ -706,7 +706,7 @@ def set_rays(self, generators):
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ToricPlotter' object has no attribute 'rays'
-+            AttributeError: 'ToricPlotter' object has no attribute 'rays'...
-             sage: tp.set_rays([(0,1)])
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Graphics object consisting of 2 graphics primitives
-diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
-index d0ec214bb3b..c8098ad578a 100644
---- a/src/sage/groups/matrix_gps/finitely_generated.py
-+++ b/src/sage/groups/matrix_gps/finitely_generated.py
-@@ -268,7 +268,7 @@ def MatrixGroup(*gens, **kwds):
-         sage: SL2C.gens()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'
-+        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'...
-     """
-     if isinstance(gens[-1], dict):   # hack for unpickling
-         kwds.update(gens[-1])
-diff --git a/src/sage/homology/chains.py b/src/sage/homology/chains.py
-index 87c0947c0b0..b9a54940943 100644
---- a/src/sage/homology/chains.py
-+++ b/src/sage/homology/chains.py
-@@ -298,7 +298,7 @@ def is_cycle(self):
-                 sage: chain.is_cocycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -325,7 +325,7 @@ def is_boundary(self):
-                 sage: chain.is_coboundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -539,7 +539,7 @@ def is_cocycle(self):
-                 sage: cochain.is_cycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -566,7 +566,7 @@ def is_coboundary(self):
-                 sage: cochain.is_boundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -604,7 +604,7 @@ def eval(self, other):
-                 sage: z.eval(c) # z is not a cochain
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'...
-                 sage: c.eval(c) # can't evaluate a cochain on a cochain
-                 Traceback (most recent call last):
-                 ...
-diff --git a/src/sage/homology/free_resolution.py b/src/sage/homology/free_resolution.py
-index e3d38de4240..280a479b438 100644
---- a/src/sage/homology/free_resolution.py
-+++ b/src/sage/homology/free_resolution.py
-@@ -275,7 +275,7 @@ def differential(self, i):
-             sage: FreeResolution.differiental(r, 1)
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'FreeResolution' has no attribute 'differiental'
-+            AttributeError: type object 'FreeResolution' has no attribute 'differiental'...
-         """
- 
-     def target(self):
-diff --git a/src/sage/interfaces/magma.py b/src/sage/interfaces/magma.py
-index b7a0ac20d03..529bfbc349b 100644
---- a/src/sage/interfaces/magma.py
-+++ b/src/sage/interfaces/magma.py
-@@ -824,7 +824,7 @@ def _coerce_from_special_method(self, x):
-             sage: magma._coerce_from_special_method('2 + 3')  # optional - magma
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute '_magma_init_'
-+            AttributeError: 'str' object has no attribute '_magma_init_'...
-         """
-         s = x._magma_init_(self)
-         a = self(s)
-diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
-index 58499396d6c..16119d20815 100644
---- a/src/sage/lfunctions/dokchitser.py
-+++ b/src/sage/lfunctions/dokchitser.py
-@@ -418,8 +418,8 @@ def init_coeffs(self, v, cutoff=1,
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
-index bbf289aa21c..e4968866303 100644
---- a/src/sage/lfunctions/pari.py
-+++ b/src/sage/lfunctions/pari.py
-@@ -141,8 +141,8 @@ def init_coeffs(self, v, cutoff=None, w=1):
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
-index 478caf9f9d0..363024ae281 100644
---- a/src/sage/libs/gap/element.pyx
-+++ b/src/sage/libs/gap/element.pyx
-@@ -380,7 +380,7 @@ cdef GapElement make_GapElement(parent, Obj obj):
-         sage: libgap(None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute '_libgap_init_'
-+        AttributeError: 'NoneType' object has no attribute '_libgap_init_'...
-     """
-     cdef GapElement r = GapElement.__new__(GapElement)
-     r._initialize(parent, obj)
-diff --git a/src/sage/libs/gmp/pylong.pxd b/src/sage/libs/gmp/pylong.pxd
-index a73f1da6d6f..84e1bb8cd87 100644
---- a/src/sage/libs/gmp/pylong.pxd
-+++ b/src/sage/libs/gmp/pylong.pxd
-@@ -2,9 +2,10 @@
- Various functions to deal with conversion mpz <-> Python int/long
- """
- 
-+from cpython.longintrepr cimport py_long
- from sage.libs.gmp.types cimport *
- 
- cdef mpz_get_pylong(mpz_srcptr z)
- cdef mpz_get_pyintlong(mpz_srcptr z)
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1
- cdef Py_hash_t mpz_pythonhash(mpz_srcptr z)
-diff --git a/src/sage/libs/gmp/pylong.pyx b/src/sage/libs/gmp/pylong.pyx
-index d5993cca5a5..1a36c29d3fa 100644
---- a/src/sage/libs/gmp/pylong.pyx
-+++ b/src/sage/libs/gmp/pylong.pyx
-@@ -28,6 +28,8 @@ AUTHORS:
- from cpython.object cimport Py_SIZE
- from cpython.long cimport PyLong_FromLong
- from cpython.longintrepr cimport _PyLong_New, py_long, digit, PyLong_SHIFT
-+from sage.cpython.pycore_long cimport (ob_digit, _PyLong_IsNegative,
-+    _PyLong_DigitCount, _PyLong_SetSignAndDigitCount)
- from .mpz cimport *
- 
- cdef extern from *:
-@@ -60,12 +62,9 @@ cdef mpz_get_pylong_large(mpz_srcptr z):
-     """
-     cdef size_t nbits = mpz_sizeinbase(z, 2)
-     cdef size_t pylong_size = (nbits + PyLong_SHIFT - 1) // PyLong_SHIFT
--    L = _PyLong_New(pylong_size)
--    mpz_export(L.ob_digit, NULL,
--            -1, sizeof(digit), 0, PyLong_nails, z)
--    if mpz_sgn(z) < 0:
--        # Set correct size
--        Py_SET_SIZE(L, -pylong_size)
-+    cdef py_long L = _PyLong_New(pylong_size)
-+    mpz_export(ob_digit(L), NULL, -1, sizeof(digit), 0, PyLong_nails, z)
-+    _PyLong_SetSignAndDigitCount(L, mpz_sgn(z), pylong_size)
-     return L
- 
- 
-@@ -88,16 +87,13 @@ cdef mpz_get_pyintlong(mpz_srcptr z):
-     return mpz_get_pylong_large(z)
- 
- 
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1:
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1:
-     """
-     Convert a Python ``long`` `L` to an ``mpz``.
-     """
--    cdef Py_ssize_t pylong_size = Py_SIZE(L)
--    if pylong_size < 0:
--        pylong_size = -pylong_size
--    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails,
--            (<py_long>L).ob_digit)
--    if Py_SIZE(L) < 0:
-+    cdef Py_ssize_t pylong_size = _PyLong_DigitCount(L)
-+    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails, ob_digit(L))
-+    if _PyLong_IsNegative(L):
-         mpz_neg(z, z)
- 
- 
-diff --git a/src/sage/manifolds/calculus_method.py b/src/sage/manifolds/calculus_method.py
-index f5830c0bc45..303dde6cd13 100644
---- a/src/sage/manifolds/calculus_method.py
-+++ b/src/sage/manifolds/calculus_method.py
-@@ -257,7 +257,7 @@ def simplify(self, expression, method=None):
-             sage: cm.simplify(f)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'
-+            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'...
- 
-         In the present case, one should either transform ``f`` to a SymPy
-         object::
-diff --git a/src/sage/manifolds/differentiable/vectorfield_module.py b/src/sage/manifolds/differentiable/vectorfield_module.py
-index d954b5d4839..af4bfb0ceec 100644
---- a/src/sage/manifolds/differentiable/vectorfield_module.py
-+++ b/src/sage/manifolds/differentiable/vectorfield_module.py
-@@ -885,7 +885,7 @@ def tensor(self, *args, **kwds):
-             sage: XM.tensor(XM).tensor(XM.dual().tensor(XM.dual()))
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'
-+            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'...
- 
-         .. SEEALSO::
- 
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 86aca6e00d8..a5f6716e731 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15303,7 +15303,7 @@ cdef class Matrix(Matrix1):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
--            has no attribute 'conjugate'
-+            has no attribute 'conjugate'...
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/matrix/matrix_cyclo_dense.pyx b/src/sage/matrix/matrix_cyclo_dense.pyx
-index f54f3423ded..a49bb6240e6 100644
---- a/src/sage/matrix/matrix_cyclo_dense.pyx
-+++ b/src/sage/matrix/matrix_cyclo_dense.pyx
-@@ -847,7 +847,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense):
-             sage: A.set_mutable()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'
-+            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'...
-             sage: B = A.__copy__()
-             sage: B[0,0] = 20
-             sage: B[0,0]
-diff --git a/src/sage/matrix/matrix_gfpn_dense.pyx b/src/sage/matrix/matrix_gfpn_dense.pyx
-index 4cccf473de1..8e8e4d7336b 100644
---- a/src/sage/matrix/matrix_gfpn_dense.pyx
-+++ b/src/sage/matrix/matrix_gfpn_dense.pyx
-@@ -159,7 +159,7 @@ cdef class FieldConverter_class:
-             sage: C.field_to_fel('foo')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'to_integer'
-+            AttributeError: 'str' object has no attribute 'to_integer'...
-         """
-         return FfFromInt(x.to_integer())
- 
-diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py
-index 6aab58352be..b5e6f52349b 100644
---- a/src/sage/matrix/matrix_space.py
-+++ b/src/sage/matrix/matrix_space.py
-@@ -1619,7 +1619,7 @@ def __getitem__(self, x):
-             sage: MS[2]
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'
-+            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'...
-         """
-         if isinstance(x, (integer.Integer, int)):
-             return self.list()[x]
-diff --git a/src/sage/matroids/lean_matrix.pyx b/src/sage/matroids/lean_matrix.pyx
-index 54c68e637c0..a137cbf70e5 100644
---- a/src/sage/matroids/lean_matrix.pyx
-+++ b/src/sage/matroids/lean_matrix.pyx
-@@ -1,5 +1,4 @@
- # sage.doctest: optional - sage.rings.finite_rings
--# cython: profile=True
- """
- Lean matrices
- 
-diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx
-index 36f563aa433..318c82f2b64 100644
---- a/src/sage/matroids/linear_matroid.pyx
-+++ b/src/sage/matroids/linear_matroid.pyx
-@@ -1134,7 +1134,7 @@ cdef class LinearMatroid(BasisExchangeMatroid):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.matroids.basis_matroid.BasisMatroid' object
--            has no attribute 'base_ring'
-+            has no attribute 'base_ring'...
-             sage: from sage.matroids.advanced import *
-             sage: M4 = BinaryMatroid(Matrix(M1))
-             sage: M5 = LinearMatroid(reduced_matrix=Matrix(GF(2), [[-1, 0, 1],
-diff --git a/src/sage/misc/dev_tools.py b/src/sage/misc/dev_tools.py
-index e7bf176592c..3ece7db2894 100644
---- a/src/sage/misc/dev_tools.py
-+++ b/src/sage/misc/dev_tools.py
-@@ -171,6 +171,7 @@ def load_submodules(module=None, exclude_pattern=None):
-         load sage.geometry.polyhedron.ppl_lattice_polygon... succeeded
-     """
-     from .package_dir import walk_packages
-+    import importlib.util
- 
-     if module is None:
-         import sage
-@@ -194,8 +195,12 @@ def load_submodules(module=None, exclude_pattern=None):
-         try:
-             sys.stdout.write("load %s..." % module_name)
-             sys.stdout.flush()
--            loader = importer.find_module(module_name)
--            loader.load_module(module_name)
-+            # see
-+            # https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
-+            spec = importer.find_spec(module_name)
-+            module = importlib.util.module_from_spec(spec)
-+            sys.modules[module_name] = module
-+            spec.loader.exec_module(module)
-             sys.stdout.write(" succeeded\n")
-         except (ValueError, AttributeError, TypeError, ImportError):
-             # we might get error because of cython code that has been
-diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py
-index c922b8f6f12..03697f08b7c 100644
---- a/src/sage/misc/functional.py
-+++ b/src/sage/misc/functional.py
-@@ -86,7 +86,7 @@ def base_field(x):
-         sage: R.base_field()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'
-+        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'...
-     """
-     try:
-         return x.base_field()
-diff --git a/src/sage/misc/instancedoc.pyx b/src/sage/misc/instancedoc.pyx
-index d8e1e4ac536..44ee70f64ba 100644
---- a/src/sage/misc/instancedoc.pyx
-+++ b/src/sage/misc/instancedoc.pyx
-@@ -256,7 +256,7 @@ cdef class InstanceDocDescriptor:
-             sage: descr.__delete__(obj)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'X' object has no attribute '__doc__'
-+            AttributeError: 'X' object has no attribute '__doc__'...
- 
-             sage: descr.__delete__([])
-             Traceback (most recent call last):
-diff --git a/src/sage/misc/lazy_attribute.pyx b/src/sage/misc/lazy_attribute.pyx
-index bdbec3b3ba1..1f07870b8ec 100644
---- a/src/sage/misc/lazy_attribute.pyx
-+++ b/src/sage/misc/lazy_attribute.pyx
-@@ -441,37 +441,37 @@ class lazy_attribute(_lazy_attribute):
-             sage: B().unimplemented_A # todo: not implemented
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'super' object has no attribute 'unimplemented_A'
-+            AttributeError: 'super' object has no attribute 'unimplemented_A'...
- 
-     We now make some systematic checks::
- 
-         sage: B().unimplemented_A
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: B().unimplemented_B
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: B().unimplemented_AB
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: B().unimplemented_B_implemented_A
-         1
- 
-         sage: C().unimplemented_A()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: C().unimplemented_B()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: C().unimplemented_AB()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: C().unimplemented_B_implemented_A # todo: not implemented
-         1
-     """
-diff --git a/src/sage/misc/object_multiplexer.py b/src/sage/misc/object_multiplexer.py
-index d4e811ef16e..00fd89d6652 100644
---- a/src/sage/misc/object_multiplexer.py
-+++ b/src/sage/misc/object_multiplexer.py
-@@ -85,7 +85,7 @@ def __getattr__(self, name):
-             sage: m.__bork__
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Multiplex' has no attribute '__bork__'
-+            AttributeError: 'Multiplex' has no attribute '__bork__'...
-         """
-         if name.startswith("__"):
-             raise AttributeError("'Multiplex' has no attribute '%s'" % name)
-diff --git a/src/sage/misc/sage_input.py b/src/sage/misc/sage_input.py
-index 66e78ecccbc..00e8d96ee9e 100644
---- a/src/sage/misc/sage_input.py
-+++ b/src/sage/misc/sage_input.py
-@@ -3461,7 +3461,7 @@ def verify_same(a, b):
-         sage: verify_same(1, 1r)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_same(1r, 1)
-         Traceback (most recent call last):
-         ...
-@@ -3525,7 +3525,7 @@ def verify_si_answer(x, answer, preparse):
-         sage: verify_si_answer(1, '1', False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_si_answer(1, 'ZZ(1)', None)
-     """
-     from sage.misc.sage_eval import sage_eval
-diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py
-index f0545be7d81..811afc48755 100644
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -602,7 +602,7 @@ def visit_Num(self, node):
-             On Python 3 negative numbers are parsed first, for some reason, as
-             a UnaryOp node.
-         """
--        return node.n
-+        return node.value
- 
-     def visit_Str(self, node):
-         r"""
-@@ -624,7 +624,7 @@ def visit_Str(self, node):
-             sage: [vis(s) for s in ['"abstract"', "'syntax'", r'''r"tr\ee"''']]
-             ['abstract', 'syntax', 'tr\\ee']
-         """
--        return node.s
-+        return node.value
- 
-     def visit_List(self, node):
-         """
-diff --git a/src/sage/modules/fp_graded/steenrod/module.py b/src/sage/modules/fp_graded/steenrod/module.py
-index 18460b0e9a1..4acfa6b4002 100755
---- a/src/sage/modules/fp_graded/steenrod/module.py
-+++ b/src/sage/modules/fp_graded/steenrod/module.py
-@@ -70,7 +70,7 @@
-     sage: SteenrodFPModule(ZZ, [0])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'
-+    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'...
- 
- AUTHORS:
- 
-diff --git a/src/sage/monoids/trace_monoid.py b/src/sage/monoids/trace_monoid.py
-index 00baa4d14f8..f8176a1e1f2 100644
---- a/src/sage/monoids/trace_monoid.py
-+++ b/src/sage/monoids/trace_monoid.py
-@@ -40,7 +40,6 @@
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from collections import OrderedDict
- from itertools import repeat, chain, product
- 
- from sage.misc.cachefunc import cached_method
-@@ -633,14 +632,14 @@ def _compute_dependence_stack(self, x):
-             sage: x = b*a*d*a*c*b
-             sage: M._compute_dependence_stack(x)
-             ({a, b, c, d},
--             OrderedDict([(a, [False, False, True, True, False]),
--                          (b, [True, False, False, False, True]),
--                          (c, [True, False, False, False]),
--                          (d, [False, False, True, False])]))
-+             {a: [False, False, True, True, False],
-+              b: [True, False, False, False, True],
-+              c: [True, False, False, False],
-+              d: [False, False, True, False]})
-         """
-         independence = self._independence
-         generators_set = set(e for e, _ in x)
--        stacks = OrderedDict(sorted((g, []) for g in generators_set))
-+        stacks = dict(sorted((g, []) for g in generators_set))
-         for generator, times in reversed(list(x)):
-             stacks[generator].extend(repeat(True, times))
-             for other_gen in generators_set:
-diff --git a/src/sage/parallel/map_reduce.py b/src/sage/parallel/map_reduce.py
-index 11e0673ee91..5441943731d 100644
---- a/src/sage/parallel/map_reduce.py
-+++ b/src/sage/parallel/map_reduce.py
-@@ -1234,7 +1234,7 @@ def finish(self):
-             sage: S.print_communication_statistics()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'RESetMPExample' object has no attribute '_stats'
-+            AttributeError: 'RESetMPExample' object has no attribute '_stats'...
- 
-             sage: S.finish()
- 
-diff --git a/src/sage/plot/colors.py b/src/sage/plot/colors.py
-index 8c0db2b3c34..3281199400b 100644
---- a/src/sage/plot/colors.py
-+++ b/src/sage/plot/colors.py
-@@ -1099,7 +1099,7 @@ def __getattr__(self, name):
-             sage: cols.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ColorsDict' has no attribute or colormap punk
-+            AttributeError: 'ColorsDict' has no attribute or colormap punk...
-         """
-         try:
-             return self[name]
-@@ -1599,7 +1599,7 @@ def __getattr__(self, name):
-             sage: maps.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Colormaps' has no attribute or colormap punk
-+            AttributeError: 'Colormaps' has no attribute or colormap punk...
-             sage: maps['punk']
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/rings/asymptotic/asymptotic_ring.py b/src/sage/rings/asymptotic/asymptotic_ring.py
-index b07319382d3..994490e6616 100644
---- a/src/sage/rings/asymptotic/asymptotic_ring.py
-+++ b/src/sage/rings/asymptotic/asymptotic_ring.py
-@@ -1091,7 +1091,7 @@ def monomial_coefficient(self, monomial):
-             sage: O(n).monomial_coefficient(n)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'
-+            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'...
- 
-         The ``monomial`` must be exact::
- 
-diff --git a/src/sage/rings/asymptotic/growth_group.py b/src/sage/rings/asymptotic/growth_group.py
-index 27c14592bca..5be12537d62 100644
---- a/src/sage/rings/asymptotic/growth_group.py
-+++ b/src/sage/rings/asymptotic/growth_group.py
-@@ -1572,7 +1572,7 @@ def variable_names(self):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'GenericGrowthGroup_with_category.element_class' object
--            has no attribute 'is_one'
-+            has no attribute 'is_one'...
-         """
-         if self.is_one():
-             return tuple()
-diff --git a/src/sage/rings/ideal.py b/src/sage/rings/ideal.py
-index d36d9406f32..01c9fa3bf2d 100644
---- a/src/sage/rings/ideal.py
-+++ b/src/sage/rings/ideal.py
-@@ -1553,7 +1553,7 @@ def gcd(self, other):
-             sage: J.gcd(I)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Ideal_generic' object has no attribute 'gcd'
-+            AttributeError: 'Ideal_generic' object has no attribute 'gcd'...
- 
-         Note::
- 
-diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
-index 7fe89197011..8832d27e8ea 100644
---- a/src/sage/rings/number_field/number_field.py
-+++ b/src/sage/rings/number_field/number_field.py
-@@ -3823,7 +3823,7 @@ def primes_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
-         """
-         if degree is not None:
-             degree = ZZ(degree)
-@@ -3917,7 +3917,7 @@ def prime_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
- 
-         """
-         ids = self.primes_above(x, degree)
-@@ -5926,7 +5926,7 @@ def factor(self, n):
-             sage: L.factor(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'...
- 
-         AUTHORS:
- 
-@@ -12698,7 +12698,7 @@ def is_real_place(v):
-         sage: is_real_place(v_fin)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'
-+        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'...
- 
-     """
-     RR = sage.rings.real_mpfr.RealField(53)
-diff --git a/src/sage/rings/padics/generic_nodes.py b/src/sage/rings/padics/generic_nodes.py
-index 7047020edec..b6b514d4005 100644
---- a/src/sage/rings/padics/generic_nodes.py
-+++ b/src/sage/rings/padics/generic_nodes.py
-@@ -740,7 +740,7 @@ def _get_element_class(self, name=None):
-             sage: R._get_element_class("foobar")
-             Traceback (most recent call last):
-             ...
--            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'
-+            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'...
-         """
-         if name is None:
-             return self.Element
-diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx
-index c5a1129aecf..a5b7f937cfe 100644
---- a/src/sage/rings/polynomial/polynomial_element.pyx
-+++ b/src/sage/rings/polynomial/polynomial_element.pyx
-@@ -10793,7 +10793,7 @@ cdef class Polynomial(CommutativePolynomial):
-             sage: (y**2 + x).nth_root(2)
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... has no attribute 'nth_root'
-+            AttributeError: ... has no attribute 'nth_root'...
- 
-         TESTS::
- 
-@@ -11831,7 +11831,7 @@ cdef class Polynomial_generic_dense(Polynomial):
-             sage: int(1) // x  # check that this doesn't segfault
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'int' has no attribute 'base_ring'
-+            AttributeError: type object 'int' has no attribute 'base_ring'...
-         """
-         if have_same_parent(self, right):
-             return (<Polynomial_generic_dense>self)._floordiv_(<Polynomial_generic_dense>right)
-diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-index e372be888ee..aca4f08420f 100644
---- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
-+++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-@@ -2362,7 +2362,7 @@ def field_extension(self, names):
-             sage: F, g, h = S.field_extension('b')                                      # needs sage.rings.finite_rings
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'
-+            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'...
- 
-         Over a finite field, the corresponding field extension is not a
-         number field::
-diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx
-index 5273891a5b0..a6e999b8805 100644
---- a/src/sage/rings/ring.pyx
-+++ b/src/sage/rings/ring.pyx
-@@ -1734,7 +1734,7 @@ cdef class IntegralDomain(CommutativeRing):
-             sage: Z5.is_integrally_closed()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'
-+            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'...
-         """
-         raise NotImplementedError
- 
-diff --git a/src/sage/sat/solvers/satsolver.pyx b/src/sage/sat/solvers/satsolver.pyx
-index c2f41b18f55..1c4ac400cb6 100644
---- a/src/sage/sat/solvers/satsolver.pyx
-+++ b/src/sage/sat/solvers/satsolver.pyx
-@@ -375,10 +375,10 @@ def SAT(solver=None, *args, **kwds):
-         DIMACS Solver: 'kissat -q {input}'
-     """
-     if solver is None:
--        import pkgutil
--        if pkgutil.find_loader('pycryptosat') is not None:
-+        from importlib.util import find_spec
-+        if find_spec('pycryptosat') is not None:
-             solver = "cryptominisat"
--        elif pkgutil.find_loader('pycosat') is not None:
-+        elif find_spec('pycosat') is not None:
-             solver = "picosat"
-         else:
-             solver = "LP"
-diff --git a/src/sage/schemes/toric/morphism.py b/src/sage/schemes/toric/morphism.py
-index 1c8944b6dfc..5d64d632f97 100644
---- a/src/sage/schemes/toric/morphism.py
-+++ b/src/sage/schemes/toric/morphism.py
-@@ -246,7 +246,7 @@
-     Traceback (most recent call last):
-     ...
-     AttributeError: 'SchemeMorphism_fan_toric_variety' object
--    has no attribute 'fiber_generic'
-+    has no attribute 'fiber_generic'...
- 
- Let's use factorization mentioned above::
- 
-diff --git a/src/sage/sets/disjoint_union_enumerated_sets.py b/src/sage/sets/disjoint_union_enumerated_sets.py
-index 3dea567a779..5c5e08612f2 100644
---- a/src/sage/sets/disjoint_union_enumerated_sets.py
-+++ b/src/sage/sets/disjoint_union_enumerated_sets.py
-@@ -597,7 +597,7 @@ def Element(self):
-             sage: U.Element
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'
-+            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'...
-         """
-         if not self._facade:
-             return ElementWrapper
-diff --git a/src/sage/sets/set.py b/src/sage/sets/set.py
-index a1789c61300..112d3d8dc3b 100644
---- a/src/sage/sets/set.py
-+++ b/src/sage/sets/set.py
-@@ -163,7 +163,7 @@ def Set(X=None, category=None):
-         sage: sorted(B.list(), key=repr)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'Set_object_with_category' object has no attribute 'list'
-+        AttributeError: 'Set_object_with_category' object has no attribute 'list'...
-         sage: type(B)
-         <class 'sage.sets.set.Set_object_with_category'>
- 
-diff --git a/src/sage/structure/category_object.pyx b/src/sage/structure/category_object.pyx
-index b6a7eaecb5b..c06933494dc 100644
---- a/src/sage/structure/category_object.pyx
-+++ b/src/sage/structure/category_object.pyx
-@@ -836,7 +836,7 @@ cdef class CategoryObject(SageObject):
-             sage: Sets().example().sadfasdf
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'
-+            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'...
-         """
-         return self.getattr_from_category(name)
- 
-diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx
-index caae7e40ffc..543506e9a74 100644
---- a/src/sage/structure/element.pyx
-+++ b/src/sage/structure/element.pyx
-@@ -219,7 +219,7 @@ the parents::
-     sage: x._add_(x)
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-     sage: x + x
-     Traceback (most recent call last):
-     ...
-@@ -478,13 +478,13 @@ cdef class Element(SageObject):
-             sage: 1.blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'...
-             sage: Semigroups().example().an_element().is_idempotent
-             <bound method LeftZeroSemigroup.Element.is_idempotent of 42>
-             sage: Semigroups().example().an_element().blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'
-+            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'...
-         """
-         return self.getattr_from_category(name)
- 
-@@ -1269,7 +1269,7 @@ cdef class Element(SageObject):
-             sage: e._add_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-         """
-         try:
-             python_op = (<object>self)._add_
-@@ -1381,7 +1381,7 @@ cdef class Element(SageObject):
-             sage: e._sub_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'...
-         """
-         try:
-             python_op = (<object>self)._sub_
-@@ -1435,7 +1435,7 @@ cdef class Element(SageObject):
-             sage: e._neg_()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'...
-         """
-         try:
-             python_op = (<object>self)._neg_
-@@ -1549,7 +1549,7 @@ cdef class Element(SageObject):
-             sage: e._mul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'...
-         """
-         try:
-             python_op = (<object>self)._mul_
-@@ -1662,7 +1662,7 @@ cdef class Element(SageObject):
-             sage: e._matmul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'...
-         """
-         try:
-             python_op = (<object>self)._matmul_
-@@ -1765,7 +1765,7 @@ cdef class Element(SageObject):
-             sage: e._div_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'...
-         """
-         try:
-             python_op = (<object>self)._div_
-@@ -1865,7 +1865,7 @@ cdef class Element(SageObject):
-             sage: e._floordiv_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'...
-         """
-         try:
-             python_op = (<object>self)._floordiv_
-@@ -1965,7 +1965,7 @@ cdef class Element(SageObject):
-             sage: e._mod_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'...
-         """
-         try:
-             python_op = (<object>self)._mod_
-@@ -2092,7 +2092,7 @@ cdef class Element(SageObject):
-             sage: e._pow_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'...
-         """
-         try:
-             python_op = (<object>self)._pow_
-@@ -2122,7 +2122,7 @@ cdef class Element(SageObject):
-             sage: e._pow_int(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'...
-         """
-         try:
-             python_op = (<object>self)._pow_int
-@@ -2856,7 +2856,7 @@ cdef class RingElement(ModuleElement):
-             sage: m.is_nilpotent()                                                      # needs sage.modules
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... object has no attribute 'is_nilpotent'
-+            AttributeError: '...' object has no attribute 'is_nilpotent'...
-         """
-         if self.is_unit():
-             return False
-@@ -4671,7 +4671,7 @@ def coerce_binop(method):
-         sage: x.test_add(CC(2))
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'
-+        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'...
- 
-     TESTS:
- 
-diff --git a/src/sage/structure/sequence.py b/src/sage/structure/sequence.py
-index 0c700c1fb81..c3972532ac3 100644
---- a/src/sage/structure/sequence.py
-+++ b/src/sage/structure/sequence.py
-@@ -854,7 +854,7 @@ def __getattr__(self, name):
-             sage: S.universe()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'...
-             sage: S._Sequence__universe = 'foobar'
-             sage: S.universe()
-             'foobar'
-@@ -867,7 +867,7 @@ def __getattr__(self, name):
-             sage: hash(S)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'...
-             sage: S._Sequence__hash = int(34)
-             sage: hash(S)
-             34
-diff --git a/src/sage/symbolic/assumptions.py b/src/sage/symbolic/assumptions.py
-index 7dcb15f0d85..15f6fa07ce6 100644
---- a/src/sage/symbolic/assumptions.py
-+++ b/src/sage/symbolic/assumptions.py
-@@ -636,7 +636,7 @@ def assume(*args):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no
--        attribute 'assume'
-+        attribute 'assume'...
- 
-     Ensure that we can combine the two types of assumptions, as documented::
- 
-diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx
-index 0f251ac4e5c..66f624141b3 100644
---- a/src/sage/symbolic/expression.pyx
-+++ b/src/sage/symbolic/expression.pyx
-@@ -13712,7 +13712,7 @@ cdef get_dynamic_class_for_function(unsigned serial):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.symbolic.expression.Expression' object has no
--        attribute 'argp1'
-+        attribute 'argp1'...
-         sage: t = (e + 1).op[0]; t
-         tfunc(x)
-         sage: t
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index c4152e092e3..4bcf45e8793 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -67,6 +67,7 @@
- #include "archive.h"
- #include "tostring.h"
- #include "utils.h"
-+#include "../../cpython/pycore_long.h"
- 
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wdeprecated-register"
-@@ -706,18 +707,12 @@ static long _mpq_pythonhash(mpq_t the_rat)
- // Initialize an mpz_t from a Python long integer
- static void _mpz_set_pylong(mpz_t z, PyLongObject* l)
- {
--    Py_ssize_t pylong_size = Py_SIZE(l);
--    int sign = 1;
--
--    if (pylong_size < 0) {
--        pylong_size = -pylong_size;
--        sign = -1;
--    }
-+    Py_ssize_t pylong_size = _PyLong_DigitCount(l);
- 
-     mpz_import(z, pylong_size, -1, sizeof(digit), 0,
--               8*sizeof(digit) - PyLong_SHIFT, l->ob_digit);
-+               8*sizeof(digit) - PyLong_SHIFT, ob_digit(l));
- 
--    if (sign < 0)
-+    if (_PyLong_IsNegative(l))
-         mpz_neg(z, z);
- }
- 
-diff --git a/src/sage/symbolic/pynac_impl.pxi b/src/sage/symbolic/pynac_impl.pxi
-index 68c31dcfde7..7fd7c3b314b 100644
---- a/src/sage/symbolic/pynac_impl.pxi
-+++ b/src/sage/symbolic/pynac_impl.pxi
-@@ -619,7 +619,7 @@ def tolerant_is_symbol(a):
-         sage: None.is_symbol()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute 'is_symbol'
-+        AttributeError: 'NoneType' object has no attribute 'is_symbol'...
-     """
-     try:
-         return a.is_symbol()
diff --git a/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch b/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
new file mode 100644
index 0000000000000..1e695c2d9d106
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36551-fix_qf.nbs.patch
@@ -0,0 +1,134 @@
+diff --git a/src/sage/quadratic_forms/quadratic_form__neighbors.py b/src/sage/quadratic_forms/quadratic_form__neighbors.py
+index fb781e20122..ec853cd52ef 100644
+--- a/src/sage/quadratic_forms/quadratic_form__neighbors.py
++++ b/src/sage/quadratic_forms/quadratic_form__neighbors.py
+@@ -74,6 +74,10 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+         sage: v = Q.find_primitive_p_divisible_vector__next(5, v); v
+         (1, 0)
+         sage: v = Q.find_primitive_p_divisible_vector__next(5, v); v
++        sage: v = Q.find_primitive_p_divisible_vector__next(2) ; v
++        (0, 1)
++        sage: v = Q.find_primitive_p_divisible_vector__next(2, v) ; v
++        (1, 0)
+         sage: Q = QuadraticForm(QQ, matrix.diagonal([1,1,1,1]))
+         sage: v = Q.find_primitive_p_divisible_vector__next(2)
+         sage: Q(v)
+@@ -83,6 +87,9 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+     n = self.dim()
+     if v is None:
+         w = vector(ZZ, [0] * (n - 1) + [1])
++        a = self(w)
++        if a in ZZ and (a % p == 0):
++            return w
+     else:
+         w = deepcopy(v)
+ 
+@@ -132,7 +139,7 @@ def find_primitive_p_divisible_vector__next(self, p, v=None):
+             return w
+ 
+ 
+-def find_p_neighbor_from_vec(self, p, y):
++def find_p_neighbor_from_vec(self, p, y, return_matrix=False):
+     r"""
+     Return the `p`-neighbor of ``self`` defined by ``y``.
+ 
+@@ -147,25 +154,32 @@ def find_p_neighbor_from_vec(self, p, y):
+     - ``p`` -- a prime number
+     - ``y`` -- a vector with `q(y) \in p \ZZ`
+     - ``odd`` -- (default: ``False``) if `p=2`, return also odd neighbors
++    - ``return_matrix`` -- (boolean, default ``False``) return
++      the transformation matrix instead of the quadratic form
+ 
+     EXAMPLES::
+ 
++        sage: # needs sage.libs.pari
+         sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1,1])
+         sage: v = vector([0,2,1,1])
+-        sage: X = Q.find_p_neighbor_from_vec(3, v); X                                   # needs sage.libs.pari
++        sage: X = Q.find_p_neighbor_from_vec(3, v); X
+         Quadratic form in 4 variables over Integer Ring with coefficients:
+         [ 1 0 0 0 ]
+         [ * 1 4 4 ]
+         [ * * 5 12 ]
+         [ * * * 9 ]
++        sage: B = Q.find_p_neighbor_from_vec(3, v, return_matrix=True)
++        sage: Q(B) == X
++        True
+ 
+     Since the base ring and the domain are not yet separate,
+     for rational, half integral forms we just pretend
+     the base ring is `\ZZ`::
+ 
++        sage: # needs sage.libs.pari
+         sage: Q = QuadraticForm(QQ, matrix.diagonal([1,1,1,1]))
+         sage: v = vector([1,1,1,1])
+-        sage: Q.find_p_neighbor_from_vec(2, v)                                          # needs sage.libs.pari
++        sage: Q.find_p_neighbor_from_vec(2, v)
+         Quadratic form in 4 variables over Rational Field with coefficients:
+         [ 1/2 1 1 1 ]
+         [ * 1 1 2 ]
+@@ -227,9 +241,12 @@ def find_p_neighbor_from_vec(self, p, y):
+     # by definition this is the p-neighbor of L at y
+     # assert B.det().abs() == 1
+ 
+-    QF = self.parent()
+-    Gnew = (B*G*B.T).change_ring(R)
+-    return QF(Gnew)
++    if return_matrix:
++        return B.T
++    else:
++        QF = self.parent()
++        Gnew = (B*G*B.T).change_ring(R)
++        return QF(Gnew)
+ 
+ 
+ def neighbor_iteration(seeds, p, mass=None, max_classes=ZZ(10)**3,
+diff --git a/src/sage/quadratic_forms/ternary.pyx b/src/sage/quadratic_forms/ternary.pyx
+index 28dd9514c30..6e7c4389083 100644
+--- a/src/sage/quadratic_forms/ternary.pyx
++++ b/src/sage/quadratic_forms/ternary.pyx
+@@ -955,7 +955,26 @@ def extend(v):
+         [ 30   0  -7]
+         sage: M.det()
+         2
++
++    TESTS::
++
++        sage: M = matrix(3, extend( (0, 0, 1) ))
++        sage: M.det()
++        1
++        sage: M.column(0)
++        (0, 0, 1)
++        sage: M = matrix(3, extend( (0, 0, -2) ))
++        sage: M.det()
++        2
++        sage: M.column(0)
++        (0, 0, -2)
+     """
++    if v[0] == v[1] == 0:
++        if v[2] < 0:
++            return v[0], 0, 1,  v[1], 1, 0,  v[2], 0, 0
++        else:
++            return v[0], 1, 0,  v[1], 0, 1,  v[2], 0, 0
++
+     b1 = xgcd(v[0], v[1])
+     b2 = xgcd(b1[1], b1[2])
+     b3 = xgcd(b1[0], v[2])
+diff --git a/src/sage/quadratic_forms/ternary_qf.py b/src/sage/quadratic_forms/ternary_qf.py
+index fa4499566a9..2f3a57fa713 100644
+--- a/src/sage/quadratic_forms/ternary_qf.py
++++ b/src/sage/quadratic_forms/ternary_qf.py
+@@ -918,6 +918,13 @@ def find_p_neighbor_from_vec(self, p, v, mat=False):
+             [     0  -3/11  13/11]
+             sage: Q(M) == Q11
+             True
++
++        Test that it works with (0, 0, 1)::
++
++            sage: Q.find_p_neighbor_from_vec(3, (0,0,1))
++            Ternary quadratic form with integer coefficients:
++            [1 3 3]
++            [-2 0 -1]
+         """
+         if mat:
+             q, M = _find_p_neighbor_from_vec(self._a, self._b, self._c, self._r, self._s, self._t, p, v, mat)
diff --git a/srcpkgs/sagemath/patches/get_patches b/srcpkgs/sagemath/patches/get_patches
index 95a6963432948..6306ee90e4b1a 100755
--- a/srcpkgs/sagemath/patches/get_patches
+++ b/srcpkgs/sagemath/patches/get_patches
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-version=10.1
+version=10.2.rc4
 
 URL_BASE_PR="https://github.com/sagemath/sage/pull/"
 URL_BASE_COMPARE="https://github.com/sagemath/sage/compare/${version}..."
@@ -20,24 +20,8 @@ get_pr() {
 # run from patches dir
 cd $(dirname "$0")
 
-# merged in 10.2.beta0
-#get_pr  36018   "singular 4.3.2p4" # included in #35934
-get_pr  36046   "fix memory leak"
-
-# merged in 10.2.beta1
-get_pr  35934   "singular 4.3.2p7"
-
-# merged in 10.2.beta2
-get_pr  36006   "gmp 6.3.0"
-
-# merged in 10.2.beta3
-get_pr  36235   "ecl 23.9.9"
-
-# merged in 10.2.beta4
-get_pr  36279   "matplotlib 3.8.0"
-
 # positive review
-#get_pr  36403   "python 3.12" # included in #36407
+get_pr  36551   "fix qf.nbs"
 
 # needs review
-get_pr  36407   "python 3.12"
+get_pr  35848   "flintlib 3.0"
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index a80d8b7187ece..f03d2530246ed 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,14 +1,14 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=10.1
-revision=4
+version=10.2.rc4
+revision=1
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
 _bindir=/usr/lib/sagemath/$version/bin
 make_install_args="--install-scripts=$_bindir"
-hostmakedepends="m4 pkg-config python3-Cython0.29 python3-Jinja2
+hostmakedepends="m4 pkg-config python3-Cython python3-Jinja2
  python3-pkgconfig python3-setuptools"
-makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
+makedepends="boost-devel brial-devel cliquer-devel ecl eclib-devel
  ecm-devel fflas-ffpack flintlib-devel gap-devel gd-devel giac-devel glpk-devel
  gsl-devel iml-devel lcalc-devel libbraiding-devel libhomfly-devel libmpc-devel
  libpng-devel linbox-devel m4ri-devel m4rie-devel mpfi-devel
@@ -18,7 +18,7 @@ makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
 depends="eclib-devel fflas-ffpack flintlib-devel gcc-fortran gd-devel
  gfan giac gsl-devel gzip libpng-devel linbox-devel m4ri-devel maxima-ecl
  mpfr-devel nauty ntl-devel palp pari-devel pari-elldata-small pari-galdata
- pari-galpol-small pari-seadata-small pkg-config python3-Cython0.29 python3-cypari2
+ pari-galpol-small pari-seadata-small pkg-config python3-Cython python3-cypari2
  python3-cysignals python3-devel python3-fpylll python3-ipython python3-lrcalc
  python3-ipython_ipykernel python3-jupyter_ipywidgets python3-matplotlib
  python3-memory_allocator python3-networkx python3-pip python3-pkgconfig
@@ -33,7 +33,7 @@ license="GPL-2.0-or-later"
 homepage="https://www.sagemath.org/"
 changelog="https://github.com/sagemath/sage/releases"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=a658612b1b2376ddaf207cc8ed0ef458d4c2880c16e19139bedbe8baa42ad62f
+checksum=d13f4bdc5db4f8602be0453c51765a563f6ff5c4cf2d80c696fbb2194d0932ce
 nocross="due to ntl (flintlib), fflas-ffpack, givaro, linbox, cysignals, sympow, maxima"
 
 post_patch() {
diff --git a/srcpkgs/sagemath/update b/srcpkgs/sagemath/update
index 68be3c5752d06..4e62503e2f8f4 100644
--- a/srcpkgs/sagemath/update
+++ b/srcpkgs/sagemath/update
@@ -1,2 +1,3 @@
 pkgname="sage"
-site="https://mirrors.mit.edu/sage/src/index.html"
+site="https://mirrors.mit.edu/sage/src/
+https://mirrors.mit.edu/sage/devel/"

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

* Re: [PR REVIEW] [RC] sagemath: update to 10.2, flintlib: update to 3.0.1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (15 preceding siblings ...)
  2023-11-18  4:51 ` tornaria
@ 2023-11-19 18:06 ` dkwo
  2023-11-19 18:08 ` dkwo
                   ` (11 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: dkwo @ 2023-11-19 18:06 UTC (permalink / raw)
  To: ml

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

New review comment by dkwo on void-packages repository

https://github.com/void-linux/void-packages/pull/46832#discussion_r1398468545

Comment:
could you remove cysignals and add eclib (again due to ntl)?

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

* Re: [RC] sagemath: update to 10.2, flintlib: update to 3.0.1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (16 preceding siblings ...)
  2023-11-19 18:06 ` [PR REVIEW] " dkwo
@ 2023-11-19 18:08 ` dkwo
  2023-11-20 14:24 ` dkwo
                   ` (10 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: dkwo @ 2023-11-19 18:08 UTC (permalink / raw)
  To: ml

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

New comment by dkwo on void-packages repository

https://github.com/void-linux/void-packages/pull/46832#issuecomment-1817934173

Comment:
The current iteration (rc4) has a couple of test failures on aarch64:
```
sage/libs/gap/element.pyx (killed due to segfault)
sage/matrix/matrix_integer_dense.pyx (killed due to segfault)
sage/graphs/generic_graph.py (timed out)
```
With regard to the crossbuild, I will investigate eclib and flint (in the past, our crossbuilt flintlib was giving a doctest error in sage).

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

* Re: [RC] sagemath: update to 10.2, flintlib: update to 3.0.1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (17 preceding siblings ...)
  2023-11-19 18:08 ` dkwo
@ 2023-11-20 14:24 ` dkwo
  2023-11-21 20:39 ` [PR REVIEW] " dkwo
                   ` (9 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: dkwo @ 2023-11-20 14:24 UTC (permalink / raw)
  To: ml

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

New comment by dkwo on void-packages repository

https://github.com/void-linux/void-packages/pull/46832#issuecomment-1819162451

Comment:
(previously, I was testing with `XBPS_CHECK_PKGS=yes`, yesterday I switched to `full`.)

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

* Re: [PR REVIEW] [RC] sagemath: update to 10.2, flintlib: update to 3.0.1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (18 preceding siblings ...)
  2023-11-20 14:24 ` dkwo
@ 2023-11-21 20:39 ` dkwo
  2023-11-22 17:23 ` tornaria
                   ` (8 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: dkwo @ 2023-11-21 20:39 UTC (permalink / raw)
  To: ml

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

New review comment by dkwo on void-packages repository

https://github.com/void-linux/void-packages/pull/46832#discussion_r1401146512

Comment:
as well as remove flintlib, per discussion in the sage thread?

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

* Re: [RC] sagemath: update to 10.2, flintlib: update to 3.0.1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (19 preceding siblings ...)
  2023-11-21 20:39 ` [PR REVIEW] " dkwo
@ 2023-11-22 17:23 ` tornaria
  2023-12-01 11:01 ` [PR PATCH] [Updated] " tornaria
                   ` (7 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: tornaria @ 2023-11-22 17:23 UTC (permalink / raw)
  To: ml

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

New comment by tornaria on void-packages repository

https://github.com/void-linux/void-packages/pull/46832#issuecomment-1823190085

Comment:
> The current iteration (rc4) has a couple of test failures on aarch64:
> 
> ```
> sage/libs/gap/element.pyx (killed due to segfault)
> sage/matrix/matrix_integer_dense.pyx (killed due to segfault)
> sage/graphs/generic_graph.py (timed out)
> ```
> 
> With regard to the crossbuild, I will investigate eclib and flint (in the past, our crossbuilt flintlib was giving a doctest error in sage).

Can you try running those tests again? At least the `matrix_integer_dense.pyx` I think I've seen from time to time as a random segfault. The others I don't know, if you can reproduce consistently, then try to see what triggers it, get a minimal example that reproduces the issue, and submit a bug report upstream.

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

* Re: [PR PATCH] [Updated] [RC] sagemath: update to 10.2, flintlib: update to 3.0.1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (20 preceding siblings ...)
  2023-11-22 17:23 ` tornaria
@ 2023-12-01 11:01 ` tornaria
  2023-12-01 21:08 ` tornaria
                   ` (6 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: tornaria @ 2023-12-01 11:01 UTC (permalink / raw)
  To: ml

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

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

https://github.com/tornaria/void-packages flintlib
https://github.com/void-linux/void-packages/pull/46832

[RC] sagemath: update to 10.2, flintlib: update to 3.0.1
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **briefly**

This is a major update. A couple of packages need rebuilding (eclib, singular).

For sagemath, we need a patch (in progress: https://github.com/sagemath/sage/pull/35848).

Since backporting patches is a pain and we are not in a hurry, I'm instead targeting 10.2.beta8. Note this already moves sagemath to cython 3.

The goal is to merge flintlib 3.0 together with sagemath 10.2 when the latter is released.

<!--
#### 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/46832.patch is attached

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

From 8d25437a84325678cc63f951421931db57b180b0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 11 Sep 2023 20:11:20 -0300
Subject: [PATCH 1/8] flintlib: update to 3.0.1.

---
 common/shlibs                                 |  3 +--
 srcpkgs/arb                                   |  1 +
 srcpkgs/arb-devel                             |  2 +-
 srcpkgs/arb/template                          | 24 -------------------
 .../patches/fix-test-t-sdiv_qrnnd.patch       | 23 ------------------
 srcpkgs/flintlib/template                     | 21 ++++++++++++----
 6 files changed, 20 insertions(+), 54 deletions(-)
 create mode 120000 srcpkgs/arb
 delete mode 100644 srcpkgs/arb/template
 delete mode 100644 srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch

diff --git a/common/shlibs b/common/shlibs
index 90018a5616f86..b61f1d1abe1a5 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3972,8 +3972,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.17 flintlib-2.9.0_1
-libarb.so.2 arb-2.20.0_1
+libflint.so.18 flintlib-3.0.0_1
 libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
diff --git a/srcpkgs/arb b/srcpkgs/arb
new file mode 120000
index 0000000000000..7c2633183069f
--- /dev/null
+++ b/srcpkgs/arb
@@ -0,0 +1 @@
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb-devel b/srcpkgs/arb-devel
index 456b9f00a86cd..7c2633183069f 120000
--- a/srcpkgs/arb-devel
+++ b/srcpkgs/arb-devel
@@ -1 +1 @@
-arb
\ No newline at end of file
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
deleted file mode 100644
index 84a62c7ffdba3..0000000000000
--- a/srcpkgs/arb/template
+++ /dev/null
@@ -1,24 +0,0 @@
-# Template file for 'arb'
-pkgname=arb
-version=2.23.0
-revision=1
-build_style=configure
-configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
-makedepends="flintlib-devel"
-short_desc="C library for arbitrary-precision interval arithmetic"
-maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
-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=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
-
-arb-devel_package() {
-	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"
-	short_desc+=" - development files"
-	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.a"
-		vmove "usr/lib/*.so"
-	}
-}
diff --git a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch b/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
deleted file mode 100644
index cfa109792892c..0000000000000
--- a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From fb8ddbcc06afa2a8f25637032fbb8211f6c6c122 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= <albin.ahlback@gmail.com>
-Date: Fri, 20 May 2022 14:16:38 +0200
-Subject: [PATCH] Fix bug in test code for GCC 12
-
----
- test/t-sdiv_qrnnd.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/test/t-sdiv_qrnnd.c b/test/t-sdiv_qrnnd.c
-index 2e9822e848..2676903826 100644
---- a/test/t-sdiv_qrnnd.c
-+++ b/test/t-sdiv_qrnnd.c
-@@ -33,7 +33,7 @@ int main(void)
-         {
-             d = n_randtest_not_zero(state);
-             nh = n_randtest(state);
--        } while ((FLINT_ABS(nh) >= FLINT_ABS(d)/2) || (nh == WORD_MIN));
-+        } while ((nh == WORD_MIN) || (FLINT_ABS(nh) >= FLINT_ABS(d)/2));
- 
-         nl = n_randtest(state);
- 
-
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index f7442c8052aaa..254d18c42f5b3 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,10 +1,10 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.9.0
+version=3.0.1
 revision=1
-build_style=configure
+build_style=gnu-configure
 configure_args="--prefix=/usr $(vopt_with ntl)
- $(vopt_if openblas --with-blas=${XBPS_CROSS_BASE}/usr/include/openblas)"
+ $(vopt_if openblas --with-blas-include=${XBPS_CROSS_BASE}/usr/include/openblas)"
 makedepends="mpfr-devel $(vopt_if ntl ntl-devel)
  $(vopt_if openblas openblas-devel)"
 short_desc="Fast Library for Number Theory"
@@ -13,7 +13,7 @@ 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=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
+checksum=7b311a00503a863881eb8177dbeb84322f29399f3d7d72f3b1a4c9ba1d5794b4
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
@@ -33,7 +33,20 @@ flintlib-devel_package() {
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
+		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
 		vmove "usr/lib/*.so"
 	}
 }
+
+arb_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}
+
+arb-devel_package() {
+	depends="${sourcepkg}-devel>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From dd19338e303fa8f77e168fa14ad7714693b4e311 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:08:05 -0300
Subject: [PATCH 2/8] eclib: rebuild for flintlib-3.0.1

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

diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 1d4ad58f21b7b..12165ca788dd5 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
 version=20230424
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 makedepends="pari-devel ntl-devel flintlib-devel boost-devel"

From 9edbd0e2b96d2a57310a00da095ae771ee702426 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:13:15 -0300
Subject: [PATCH 3/8] singular: update to 4.3.2p10.

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

diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index 036e19d470354..beb0e6d30118e 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,6 +1,6 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.2p7
+version=4.3.2p10
 revision=1
 _majver=${version%p*}
 build_style=gnu-configure
@@ -20,7 +20,7 @@ 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/${_majver//./-}/singular-${version}.tar.gz"
-checksum=aad23c30066b7fbc011138a98d60532565d76a847eec6bf2938410d93b272ca3
+checksum=28c2c9fcfee954e00dfa56eb1a7d418d5b1de67c4398d25a0f2b8f73e71552a8
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From 28a366290c2b680802aebc0962a202e9f182317a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Tue, 28 Nov 2023 08:29:48 -0300
Subject: [PATCH 4/8] python3-Cython: update to 3.0.6.

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

diff --git a/srcpkgs/python3-Cython/template b/srcpkgs/python3-Cython/template
index 076f95fd93cdc..e1bdc64f5ba20 100644
--- a/srcpkgs/python3-Cython/template
+++ b/srcpkgs/python3-Cython/template
@@ -1,6 +1,6 @@
 # Template file for 'python3-Cython'
 pkgname=python3-Cython
-version=3.0.5
+version=3.0.6
 revision=1
 build_style=python3-module
 hostmakedepends="python3-setuptools"
@@ -12,7 +12,7 @@ license="Apache-2.0"
 homepage="https://cython.org/"
 changelog="https://raw.githubusercontent.com/cython/cython/master/CHANGES.rst"
 distfiles="${PYPI_SITE}/C/Cython/Cython-${version}.tar.gz"
-checksum=39318348db488a2f24e7c84e08bdc82f2624853c0fea8b475ea0b70b27176492
+checksum=399d185672c667b26eabbdca420c98564583798af3bc47670a8a09e9f19dd660
 # Tests are flaky
 make_check=no
 conflicts="python3-Cython0.29>=0"

From 2fe535adc84e6cbdce8fa780306fd568c55c20ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 19 Jul 2023 21:04:33 -0300
Subject: [PATCH 5/8] python3-pplpy: use cython 3.

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

diff --git a/srcpkgs/python3-pplpy/template b/srcpkgs/python3-pplpy/template
index 4a9c987b2a859..d3b9aebdf2237 100644
--- a/srcpkgs/python3-pplpy/template
+++ b/srcpkgs/python3-pplpy/template
@@ -1,9 +1,9 @@
 # Template file for 'python3-pplpy'
 pkgname=python3-pplpy
 version=0.8.9
-revision=1
+revision=2
 build_style=python3-pep517
-hostmakedepends="python3-setuptools python3-wheel python3-Cython0.29
+hostmakedepends="python3-setuptools python3-wheel python3-Cython
  python3-cysignals python3-gmpy2"
 makedepends="python3-devel gmp-devel gmpxx-devel ppl-devel mpfr-devel
  libmpc-devel pari-devel"

From c85c5080f1935518abde4245377540d1997067c9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Thu, 19 Oct 2023 08:52:15 -0300
Subject: [PATCH 6/8] python3-networkx: update to 3.2.1.

---
 srcpkgs/python3-networkx/template | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/python3-networkx/template b/srcpkgs/python3-networkx/template
index 186bf64f7bff9..29283d9e5a032 100644
--- a/srcpkgs/python3-networkx/template
+++ b/srcpkgs/python3-networkx/template
@@ -1,11 +1,11 @@
 # Template file for 'python3-networkx'
 pkgname=python3-networkx
-version=3.1
-revision=2
-build_style=python3-module
+version=3.2.1
+revision=1
+build_style=python3-pep517
 # failing in i686
 make_check_args="--deselect networkx/algorithms/approximation/tests/test_traveling_salesman.py::test_asadpour_tsp"
-hostmakedepends="python3-setuptools"
+hostmakedepends="python3-setuptools python3-wheel"
 depends="python3"
 checkdepends="python3-numpy python3-scipy python3-matplotlib python3-pandas
  python3-lxml python3-sympy python3-pytest-xdist"
@@ -15,7 +15,7 @@ license="BSD-3-Clause"
 homepage="https://networkx.org"
 changelog="https://github.com/networkx/networkx/raw/main/doc/release/release_${version}.rst"
 distfiles="${PYPI_SITE}/n/networkx/networkx-${version}.tar.gz"
-checksum=de346335408f84de0eada6ff9fafafff9bcda11f0a0dfaa931133debb146ab61
+checksum=9f1bb5cf3409bf324e0a722c20bdb4c20ee39bf1c30ce8ae499c8502b0b5e0c6
 
 post_install() {
 	vlicense LICENSE.txt

From ca31c9f68a829b4e84d40755d0b8b23740097a07 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 27 Nov 2023 00:24:06 -0300
Subject: [PATCH 7/8] python3-prompt_toolkit: disable workaround for ipython
 8.18

See:
https://github.com/prompt-toolkit/python-prompt-toolkit/pull/1811#issuecomment-1827043359
https://github.com/prompt-toolkit/python-prompt-toolkit/pull/1821
---
 ...-disable_workaround_for_ipython_8.18.patch | 23 +++++++++++++++++++
 srcpkgs/python3-prompt_toolkit/template       |  2 +-
 2 files changed, 24 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/python3-prompt_toolkit/patches/1821-disable_workaround_for_ipython_8.18.patch

diff --git a/srcpkgs/python3-prompt_toolkit/patches/1821-disable_workaround_for_ipython_8.18.patch b/srcpkgs/python3-prompt_toolkit/patches/1821-disable_workaround_for_ipython_8.18.patch
new file mode 100644
index 0000000000000..ac752dc75b83c
--- /dev/null
+++ b/srcpkgs/python3-prompt_toolkit/patches/1821-disable_workaround_for_ipython_8.18.patch
@@ -0,0 +1,23 @@
+From 55a45b1d19330a939d5df5a33671c10d52e11477 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Mon, 27 Nov 2023 11:10:21 -0300
+Subject: [PATCH] Disable workaround for ipython >= 8.18
+
+---
+ src/prompt_toolkit/application/application.py | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/src/prompt_toolkit/application/application.py b/src/prompt_toolkit/application/application.py
+index 726fc0a06..c07ea4e94 100644
+--- a/src/prompt_toolkit/application/application.py
++++ b/src/prompt_toolkit/application/application.py
+@@ -960,7 +960,8 @@ def run_in_thread() -> None:
+         def _called_from_ipython() -> bool:
+             try:
+                 return (
+-                    "IPython/terminal/interactiveshell.py"
++                    sys.modules["IPython"].version_info < (8, 18, 0, "")
++                    and "IPython/terminal/interactiveshell.py"
+                     in sys._getframe(3).f_code.co_filename
+                 )
+             except BaseException:
diff --git a/srcpkgs/python3-prompt_toolkit/template b/srcpkgs/python3-prompt_toolkit/template
index b0ecc731388e5..6e60d8daa6c6f 100644
--- a/srcpkgs/python3-prompt_toolkit/template
+++ b/srcpkgs/python3-prompt_toolkit/template
@@ -1,7 +1,7 @@
 # Template file for 'python3-prompt_toolkit'
 pkgname=python3-prompt_toolkit
 version=3.0.41
-revision=1
+revision=2
 build_style=python3-module
 hostmakedepends="python3-setuptools"
 depends="python3-wcwidth"

From 17eaf9d04eaafb50e343b3139b924b7c36452dc5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:50:44 -0300
Subject: [PATCH 8/8] sagemath: update to 10.2.rc5.

---
 .../sagemath/patches/35848-flintlib_3.0.patch | 1867 +++++++++++++++++
 .../patches/35934-singular_4.3.2p7.patch      |  221 --
 .../sagemath/patches/36006-gmp_6.3.0.patch    |   38 -
 .../patches/36046-fix_memory_leak.patch       |  740 -------
 .../sagemath/patches/36235-ecl_23.9.9.patch   |   39 -
 .../patches/36279-matplotlib_3.8.0.patch      |   24 -
 srcpkgs/sagemath/patches/36403-00pre.patch    |   29 -
 .../sagemath/patches/36407-python_3.12.patch  | 1744 ---------------
 .../patches/36769-fix_jmol_detect.patch       |   97 +
 srcpkgs/sagemath/patches/get_patches          |   24 +-
 srcpkgs/sagemath/template                     |   12 +-
 srcpkgs/sagemath/update                       |    3 +-
 12 files changed, 1975 insertions(+), 2863 deletions(-)
 create mode 100644 srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
 delete mode 100644 srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
 delete mode 100644 srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
 delete mode 100644 srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36403-00pre.patch
 delete mode 100644 srcpkgs/sagemath/patches/36407-python_3.12.patch
 create mode 100644 srcpkgs/sagemath/patches/36769-fix_jmol_detect.patch

diff --git a/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
new file mode 100644
index 0000000000000..2cad28134f6e6
--- /dev/null
+++ b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
@@ -0,0 +1,1867 @@
+diff --git a/build/pkgs/antic/SPKG.rst b/build/pkgs/antic/SPKG.rst
+deleted file mode 100644
+index d6c32377957..00000000000
+--- a/build/pkgs/antic/SPKG.rst
++++ /dev/null
+@@ -1,18 +0,0 @@
+-antic: Algebraic Number Theory In C
+-===================================
+-
+-Description
+------------
+-
+-Algebraic Number Theory In C
+-
+-License
+--------
+-
+-LGPL 2.1
+-
+-Upstream Contact
+-----------------
+-
+-https://github.com/wbhart/antic
+-
+diff --git a/build/pkgs/antic/checksums.ini b/build/pkgs/antic/checksums.ini
+deleted file mode 100644
+index fc8711ecd13..00000000000
+--- a/build/pkgs/antic/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=antic-VERSION.tar.gz
+-sha1=940d8ea2c3512b9d49ee3101cf043f777764bd8f
+-md5=4e896420dd6344b53b307871efb2cbb4
+-cksum=1938565125
+-upstream_url=https://github.com/wbhart/antic/archive/refs/tags/vVERSION.tar.gz
+diff --git a/build/pkgs/antic/dependencies b/build/pkgs/antic/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/antic/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/antic/distros/arch.txt b/build/pkgs/antic/distros/arch.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/conda.txt b/build/pkgs/antic/distros/conda.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/debian.txt b/build/pkgs/antic/distros/debian.txt
+deleted file mode 100644
+index 8fdcd3e5721..00000000000
+--- a/build/pkgs/antic/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libantic-dev
+diff --git a/build/pkgs/antic/distros/fedora.txt b/build/pkgs/antic/distros/fedora.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/freebsd.txt b/build/pkgs/antic/distros/freebsd.txt
+deleted file mode 100644
+index 116ff3a26f3..00000000000
+--- a/build/pkgs/antic/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/antic
+diff --git a/build/pkgs/antic/distros/opensuse.txt b/build/pkgs/antic/distros/opensuse.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/repology.txt b/build/pkgs/antic/distros/repology.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/package-version.txt b/build/pkgs/antic/package-version.txt
+deleted file mode 100644
+index 3a4036fb450..00000000000
+--- a/build/pkgs/antic/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-0.2.5
+diff --git a/build/pkgs/antic/spkg-install.in b/build/pkgs/antic/spkg-install.in
+deleted file mode 100644
+index c57fa884a20..00000000000
+--- a/build/pkgs/antic/spkg-install.in
++++ /dev/null
+@@ -1,19 +0,0 @@
+-cd src
+-
+-# Copied from build/pkgs/flint/spkg-install.in:
+-#   Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-#   --with-ntl because otherwise FLINT's configure script uses
+-#   /usr/local, which is always wrong.
+-#   This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-#   The value $SAGE_LOCAL is always a safe choice even if the library
+-#   is coming from the system and is found using what is in
+-#   LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-flint="$SAGE_LOCAL"  || sdh_die "Error: Failed to configure antic."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/antic/type b/build/pkgs/antic/type
+deleted file mode 100644
+index 134d9bc32d5..00000000000
+--- a/build/pkgs/antic/type
++++ /dev/null
+@@ -1 +0,0 @@
+-optional
+diff --git a/build/pkgs/arb/SPKG.rst b/build/pkgs/arb/SPKG.rst
+deleted file mode 100644
+index cff49ddb95b..00000000000
+--- a/build/pkgs/arb/SPKG.rst
++++ /dev/null
+@@ -1,27 +0,0 @@
+-arb: Arbitrary-precision floating-point ball arithmetic
+-=======================================================
+-
+-Description
+------------
+-
+-Arb is a C library for arbitrary-precision floating-point ball
+-arithmetic, developed by Fredrik Johansson
+-(fredrik.johansson@gmail.com). It supports efficient high-precision
+-computation with polynomials, power series, matrices and special
+-functions over the real and complex numbers, with automatic, rigorous
+-error control.
+-
+-License
+--------
+-
+-GNU General Public License v2+
+-
+-
+-Upstream Contact
+-----------------
+-
+- - Fredrik Johansson: fredrik.johansson@gmail.com
+-
+- - https://arblib.org/
+-
+- - http://github.com/fredrik-johansson/arb/
+diff --git a/build/pkgs/arb/checksums.ini b/build/pkgs/arb/checksums.ini
+deleted file mode 100644
+index 80ef43dad5d..00000000000
+--- a/build/pkgs/arb/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=arb-VERSION.tar.gz
+-sha1=a1efe035dd3af3613dd685971a156f652b86ff63
+-md5=9b369e29f93cdf2d4f90b57a92526cce
+-cksum=64252121
+-upstream_url=https://github.com/fredrik-johansson/arb/archive/VERSION.tar.gz
+diff --git a/build/pkgs/arb/dependencies b/build/pkgs/arb/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/arb/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/arb/distros/arch.txt b/build/pkgs/arb/distros/arch.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/conda.txt b/build/pkgs/arb/distros/conda.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/debian.txt b/build/pkgs/arb/distros/debian.txt
+deleted file mode 100644
+index 9fe71110712..00000000000
+--- a/build/pkgs/arb/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libflint-arb-dev
+diff --git a/build/pkgs/arb/distros/fedora.txt b/build/pkgs/arb/distros/fedora.txt
+deleted file mode 100644
+index 76794404627..00000000000
+--- a/build/pkgs/arb/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb arb-devel
+diff --git a/build/pkgs/arb/distros/freebsd.txt b/build/pkgs/arb/distros/freebsd.txt
+deleted file mode 100644
+index 2ef8c7cec0f..00000000000
+--- a/build/pkgs/arb/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/arb
+diff --git a/build/pkgs/arb/distros/gentoo.txt b/build/pkgs/arb/distros/gentoo.txt
+deleted file mode 100644
+index 58e3d4f8008..00000000000
+--- a/build/pkgs/arb/distros/gentoo.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-sci-mathematics/arb
+diff --git a/build/pkgs/arb/distros/homebrew.txt b/build/pkgs/arb/distros/homebrew.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/homebrew.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/nix.txt b/build/pkgs/arb/distros/nix.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/nix.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/opensuse.txt b/build/pkgs/arb/distros/opensuse.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/distros/repology.txt b/build/pkgs/arb/distros/repology.txt
+deleted file mode 100644
+index 179c9d507e1..00000000000
+--- a/build/pkgs/arb/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-fp
+diff --git a/build/pkgs/arb/distros/void.txt b/build/pkgs/arb/distros/void.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/void.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/package-version.txt b/build/pkgs/arb/package-version.txt
+deleted file mode 100644
+index e9763f6bfed..00000000000
+--- a/build/pkgs/arb/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-2.23.0
+diff --git a/build/pkgs/arb/spkg-check.in b/build/pkgs/arb/spkg-check.in
+deleted file mode 100644
+index 27cd9419538..00000000000
+--- a/build/pkgs/arb/spkg-check.in
++++ /dev/null
+@@ -1,2 +0,0 @@
+-cd src
+-$MAKE check
+diff --git a/build/pkgs/arb/spkg-configure.m4 b/build/pkgs/arb/spkg-configure.m4
+deleted file mode 100644
+index ef2dd0aac4a..00000000000
+--- a/build/pkgs/arb/spkg-configure.m4
++++ /dev/null
+@@ -1,23 +0,0 @@
+-SAGE_SPKG_CONFIGURE([arb], [
+-    AC_REQUIRE([SAGE_SPKG_CONFIGURE_FLINT])
+-    SAGE_ARB_LIBRARY="arb"
+-    AC_MSG_CHECKING([installing flint? ])
+-    if test x$sage_spkg_install_flint = xyes; then
+-        AC_MSG_RESULT([yes; install arb as well])
+-        sage_spkg_install_arb=yes
+-    else
+-        AC_CHECK_HEADER(arb.h, [
+-        dnl below function added in version 2.16 of arb
+-            AC_CHECK_LIB([arb], [acb_mat_eig_simple], [],
+-              [dnl in Debian the name of dylib is different.
+-               AC_CHECK_LIB([flint-arb], [acb_mat_eig_simple],
+-                [SAGE_ARB_LIBRARY="flint-arb"], [sage_spkg_install_arb=yes])])
+-        ], [sage_spkg_install_arb=yes])
+-    fi
+-], [], [], [
+-    if test x$sage_spkg_install_arb = xyes; then
+-        AC_SUBST(SAGE_ARB_LIBRARY,["arb"])
+-    else
+-        AC_SUBST(SAGE_ARB_LIBRARY,[$SAGE_ARB_LIBRARY])
+-    fi
+-])
+diff --git a/build/pkgs/arb/spkg-install.in b/build/pkgs/arb/spkg-install.in
+deleted file mode 100644
+index 9322f04c912..00000000000
+--- a/build/pkgs/arb/spkg-install.in
++++ /dev/null
+@@ -1,17 +0,0 @@
+-cd src
+-
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-flint because otherwise ARB's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure --disable-static --prefix="$SAGE_LOCAL" \
+-        --with-gmp="$SAGE_LOCAL" \
+-        --with-mpfr="$SAGE_LOCAL" \
+-        --with-flint="$SAGE_LOCAL" || \
+-    sdh_die "Error configuring arb."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/arb/type b/build/pkgs/arb/type
+deleted file mode 100644
+index a6a7b9cd726..00000000000
+--- a/build/pkgs/arb/type
++++ /dev/null
+@@ -1 +0,0 @@
+-standard
+diff --git a/build/pkgs/e_antic/dependencies b/build/pkgs/e_antic/dependencies
+index fea1ffbda45..8e977a55c13 100644
+--- a/build/pkgs/e_antic/dependencies
++++ b/build/pkgs/e_antic/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) flint arb antic boost_cropped
++$(MP_LIBRARY) flint boost_cropped
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/SPKG.rst b/build/pkgs/flint/SPKG.rst
+index f91de70d1ff..d9dcea0903b 100644
+--- a/build/pkgs/flint/SPKG.rst
++++ b/build/pkgs/flint/SPKG.rst
+@@ -4,8 +4,8 @@ flint: Fast Library for Number Theory
+ Description
+ -----------
+ 
+-FLINT is a C library for doing number theory, maintained by William
+-Hart.
++FLINT is a C library for doing number theory, maintained by
++Fredrik Johansson.
+ 
+ Website: http://www.flintlib.org
+ 
+@@ -20,4 +20,4 @@ Upstream Contact
+ 
+ -  flint-devel Gougle Group
+    (http://groups.google.co.uk/group/flint-devel)
+--  William Hart
++-  Fredrik Johansson
+diff --git a/build/pkgs/flint/checksums.ini b/build/pkgs/flint/checksums.ini
+index 3d449d98064..ab836606657 100644
+--- a/build/pkgs/flint/checksums.ini
++++ b/build/pkgs/flint/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=flint-VERSION.tar.gz
+-sha1=63d90f8242c8f8ab4011fbcfb44b86c154f43abd
+-md5=c2d3cec326438f159a530c66eb07fafe
+-cksum=4244948341
+-upstream_url=http://flintlib.org/flint-VERSION.tar.gz
++sha1=65be9297c06edd7e24f20874b7bd6130cee56723
++md5=5189f67b0ec12e4a54d6782851642b81
++cksum=172350473
++upstream_url=https://github.com/flintlib/flint/releases/download/vVERSION/flint-VERSION.tar.gz
+diff --git a/build/pkgs/flint/dependencies b/build/pkgs/flint/dependencies
+index 385df4faa7d..1108dc4fb21 100644
+--- a/build/pkgs/flint/dependencies
++++ b/build/pkgs/flint/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) mpfr ntl
++$(MP_LIBRARY) mpfr
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/package-version.txt b/build/pkgs/flint/package-version.txt
+index c8e38b61405..cb2b00e4f7a 100644
+--- a/build/pkgs/flint/package-version.txt
++++ b/build/pkgs/flint/package-version.txt
+@@ -1 +1 @@
+-2.9.0
++3.0.1
+diff --git a/build/pkgs/flint/patches/0001-Makefile.in-fix-handling-of-DESTDIR.patch b/build/pkgs/flint/patches/0001-Makefile.in-fix-handling-of-DESTDIR.patch
+new file mode 100644
+index 00000000000..48a32f5d894
+--- /dev/null
++++ b/build/pkgs/flint/patches/0001-Makefile.in-fix-handling-of-DESTDIR.patch
+@@ -0,0 +1,106 @@
++From 54277f054f13254898c9a57c2c7eb869877e1252 Mon Sep 17 00:00:00 2001
++From: Marc Mezzarobba <marc@mezzarobba.net>
++Date: Mon, 13 Nov 2023 10:23:54 +0100
++Subject: [PATCH] Makefile.in: fix handling of $DESTDIR
++
++---
++ Makefile.in | 54 ++++++++++++++++++++++++++---------------------------
++ 1 file changed, 27 insertions(+), 27 deletions(-)
++
++diff --git a/Makefile.in b/Makefile.in
++index 08db6837c..2827b9da1 100644
++--- a/Makefile.in
+++++ b/Makefile.in
++@@ -34,9 +34,9 @@ FLINT_SOLIB:=@FLINT_SOLIB@
++ prefix:=@prefix@
++ exec_prefix:=@exec_prefix@
++ 
++-INCLUDEDIR:=$(DESTDIR)@includedir@
++-LIBDIR:=$(DESTDIR)@libdir@
++-BINDIR:=$(DESTDIR)@bindir@
+++INCLUDEDIR:=@includedir@
+++LIBDIR:=@libdir@
+++BINDIR:=@bindir@
++ PKGCONFIGDIR:=$(LIBDIR)/pkgconfig
++ 
++ HOST_OS:=@host_os@
++@@ -202,10 +202,10 @@ BUILD_DIRS +=                                                               \
++ endif
++ 
++ INSTALL_DIRS :=                                                             \
++-        $(LIBDIR)                       $(INCLUDEDIR)/flint                 \
++-        $(PKGCONFIGDIR)
+++        $(DESTDIR)$(LIBDIR)             $(DESTDIR)$(INCLUDEDIR)/flint       \
+++        $(DESTDIR)$(PKGCONFIGDIR)
++ ifneq ($(FLINT_DLLLIB),0)
++-INSTALL_DIRS += $(BINDIR)
+++INSTALL_DIRS += $(DESTDIR)$(BINDIR)
++ endif
++ 
++ ################################################################################
++@@ -722,41 +722,41 @@ distclean: clean
++ ################################################################################
++ 
++ install: library | $(INSTALL_DIRS)
++-	$(CP) flint.pc $(PKGCONFIGDIR)/flint.pc
+++	$(CP) flint.pc $(DESTDIR)$(PKGCONFIGDIR)/flint.pc
++ ifneq ($(SHARED), 0)
++ ifneq ($(FLINT_DLLLIB),0)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(BINDIR)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(BINDIR)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(BINDIR)
++-	$(CP) $(FLINT_DIR)/$(FLINT_IMPLIB) $(LIBDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(DESTDIR)$(BINDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(DESTDIR)$(BINDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(DESTDIR)$(BINDIR)
+++	$(CP) $(FLINT_DIR)/$(FLINT_IMPLIB) $(DESTDIR)$(LIBDIR)
++ else
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(LIBDIR)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(LIBDIR)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(LIBDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(DESTDIR)$(LIBDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(DESTDIR)$(LIBDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(DESTDIR)$(LIBDIR)
++ endif
++ ifneq ($(FLINT_DYLIB),0)
++-	install_name_tool -id $(LIBDIR)/$(FLINT_LIB_FULL) $(LIBDIR)/$(FLINT_LIB)
+++	install_name_tool -id $(LIBDIR)/$(FLINT_LIB_FULL) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB)
++ endif
++ endif
++ ifneq ($(STATIC), 0)
++-	$(CP) $(FLINT_DIR)/$(FLINT_LIB_STATIC) $(LIBDIR)
+++	$(CP) $(FLINT_DIR)/$(FLINT_LIB_STATIC) $(DESTDIR)$(LIBDIR)
++ endif
++-	$(CP) $(HEADERS) $(INCLUDEDIR)/flint
+++	$(CP) $(HEADERS) $(DESTDIR)$(INCLUDEDIR)/flint
++ 
++ uninstall:
++-	$(RM_F) $(PKGCONFIGDIR)/flint.pc
+++	$(RM_F) $(DESTDIR)$(PKGCONFIGDIR)/flint.pc
++ ifneq ($(FLINT_DLLLIB),0)
++-	$(RM_F) $(BINDIR)/$(FLINT_LIB)
++-	$(RM_F) $(BINDIR)/$(FLINT_LIB_MAJOR)
++-	$(RM_F) $(BINDIR)/$(FLINT_LIB_FULL)
++-	$(RM_F) $(LIBDIR)/$(FLINT_IMPLIB)
+++	$(RM_F) $(DESTDIR)$(BINDIR)/$(FLINT_LIB)
+++	$(RM_F) $(DESTDIR)$(BINDIR)/$(FLINT_LIB_MAJOR)
+++	$(RM_F) $(DESTDIR)$(BINDIR)/$(FLINT_LIB_FULL)
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_IMPLIB)
++ else
++-	$(RM_F) $(LIBDIR)/$(FLINT_LIB)
++-	$(RM_F) $(LIBDIR)/$(FLINT_LIB_MAJOR)
++-	$(RM_F) $(LIBDIR)/$(FLINT_LIB_FULL)
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB)
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB_MAJOR)
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB_FULL)
++ endif
++-	$(RM_F) $(LIBDIR)/$(FLINT_LIB_STATIC)
++-	$(RM_RF) $(INCLUDEDIR)/flint
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB_STATIC)
+++	$(RM_RF) $(DESTDIR)$(INCLUDEDIR)/flint
++ 
++ ################################################################################
++ # maintainer stuff
++-- 
++2.42.0
++
+diff --git a/build/pkgs/flint/spkg-build.in b/build/pkgs/flint/spkg-build.in
+new file mode 100644
+index 00000000000..ffb822c8a97
+--- /dev/null
++++ b/build/pkgs/flint/spkg-build.in
+@@ -0,0 +1,3 @@
++cd src
++sdh_configure
++sdh_make
+diff --git a/build/pkgs/flint/spkg-configure.m4 b/build/pkgs/flint/spkg-configure.m4
+index a58108c9d6e..9576e4cc1e9 100644
+--- a/build/pkgs/flint/spkg-configure.m4
++++ b/build/pkgs/flint/spkg-configure.m4
+@@ -1,25 +1,8 @@
+ SAGE_SPKG_CONFIGURE([flint], [
+-    SAGE_SPKG_DEPCHECK([mpfr ntl], [
++    SAGE_SPKG_DEPCHECK([mpfr], [
+         AC_CHECK_HEADER(flint/flint.h, [
+-          dnl flint_parallel_binary_splitting appears in Flint 2.9.0, needed by arb 2.23
+-          AC_SEARCH_LIBS([flint_parallel_binary_splitting], [flint], [
+-            dnl check that NTL is linked in
+-            AC_SEARCH_LIBS([fmpz_poly_get_ZZX], [flint], [
+-
+-              AC_MSG_CHECKING([that GC is not enabled in Flint... ])
+-              AC_RUN_IFELSE([
+-                 AC_LANG_PROGRAM([[#include <flint/flint.h>]], [
+-                                  [#ifdef HAVE_GC]
+-                                     [return HAVE_GC;]
+-                                  [#else]
+-                                     [return 0;]
+-                                  [#endif]])],
+-                 [AC_MSG_RESULT([GC not enabled. Good.])],
+-                        [AC_MSG_RESULT([GC enabled. Incompatible with Sage.])
+-                         sage_spkg_install_flint=yes],
+-                 [AC_MSG_RESULT(["cross compiling. assuming GC is not enabled"])])
+-            ], [sage_spkg_install_flint=yes])
+-          ], [sage_spkg_install_flint=yes])
++          dnl gr_get_fexpr appears in Flint 3.0
++          AC_SEARCH_LIBS([gr_get_fexpr], [flint], [], [sage_spkg_install_flint=yes])
+         ], [sage_spkg_install_flint=yes])
+     ])
+ ], [], [], [
+diff --git a/build/pkgs/flint/spkg-install.in b/build/pkgs/flint/spkg-install.in
+index eacd7b6e491..3ea8c053669 100644
+--- a/build/pkgs/flint/spkg-install.in
++++ b/build/pkgs/flint/spkg-install.in
+@@ -1,36 +1,2 @@
+-###############################################################################
+-#
+-# FLINT Sage install script
+-#
+-###############################################################################
+-if [ "$SAGE_DEBUG" = "yes" ]; then
+-    echo "Building a debug version of FLINT."
+-    FLINT_TUNE=" $FLINT_TUNE"; export FLINT_TUNE
+-    FLINT_CONFIGURE="--enable-assert $FLINT_CONFIGURE"
+-fi
+-
+ cd src
+-
+-echo "Configuring FLINT."
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-ntl because otherwise FLINT's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-ntl="$SAGE_LOCAL" \
+-    $FLINT_CONFIGURE || sdh_die "Error: Failed to configure FLINT."
+-
+-sdh_make verbose
+-
+-echo "Deleting old FLINT files."
+-rm -f $SAGE_LOCAL/lib/libflint*
+-rm -rf $SAGE_LOCAL/include/flint
+-
+ sdh_make_install
+diff --git a/build/pkgs/gmp/spkg-configure.m4 b/build/pkgs/gmp/spkg-configure.m4
+index 61d7c5f3b2f..4000200db2c 100644
+--- a/build/pkgs/gmp/spkg-configure.m4
++++ b/build/pkgs/gmp/spkg-configure.m4
+@@ -2,8 +2,10 @@ SAGE_SPKG_CONFIGURE([gmp], [
+            sage_spkg_install_gmp=no
+             AC_CHECK_HEADER(gmp.h, [], [sage_spkg_install_gmp=yes])
+             AC_CHECK_HEADER(gmpxx.h, [], [sage_spkg_install_gmp=yes])
+-            dnl mpq_cmp_z appeared in GMP 6.1.0 and is used by pynac
+-            AC_SEARCH_LIBS([__gmpq_cmp_z], [gmp], [],
++            dnl mpn_gcd_11 appeared in GMP 6.2.1
++            dnl It is undocumented but is used by Flint when built with default
++            dnl flags.
++            AC_SEARCH_LIBS([__gmpn_gcd_11], [gmp], [],
+                 [sage_spkg_install_gmp=yes])
+ ], [], [], [
+     if test x$sage_spkg_install_gmp = xyes; then
+diff --git a/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+new file mode 100644
+index 00000000000..27a642a13b0
+--- /dev/null
++++ b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+@@ -0,0 +1,53 @@
++From fe730579476de0b2d4181a38efa7f63dff9c81d7 Mon Sep 17 00:00:00 2001
++From: Marc Mezzarobba <marc@mezzarobba.net>
++Date: Tue, 12 Sep 2023 08:23:08 +0200
++Subject: [PATCH] Make msolve build with flint3
++
++---
++ src/fglm/berlekamp_massey.c | 3 +++
++ src/fglm/data_fglm.c        | 7 +++++--
++ 2 files changed, 8 insertions(+), 2 deletions(-)
++
++diff --git a/src/fglm/berlekamp_massey.c b/src/fglm/berlekamp_massey.c
++index b0f2052..998af1c 100644
++--- a/src/fglm/berlekamp_massey.c
+++++ b/src/fglm/berlekamp_massey.c
++@@ -30,6 +30,9 @@
++ */
++ 
++ #include <stdlib.h>
+++#if __FLINT_VERSION >= 3
+++#  include <flint/nmod.h>
+++#endif
++ //#include "nmod_poly.h"
++ //#include "mpn_extras.h"
++ 
++diff --git a/src/fglm/data_fglm.c b/src/fglm/data_fglm.c
++index 0726760..0e1da6f 100644
++--- a/src/fglm/data_fglm.c
+++++ b/src/fglm/data_fglm.c
++@@ -24,6 +24,7 @@
++ #include <flint/mpn_extras.h>
++ #include <flint/nmod_poly.h>
++ #include <flint/nmod_poly_factor.h>
+++#include <flint/ulong_extras.h>
++ 
++ 
++ typedef uint32_t szmat_t;
++@@ -299,9 +300,11 @@ static inline void nmod_poly_set_prime(nmod_poly_t poly,
++   mp_limb_t ninv = n_preinvert_limb(prime);
++   poly->mod.n = prime;
++   poly->mod.ninv = ninv;
+++#if __FLINT_VERSION < 3
++   count_leading_zeros(poly->mod.norm, prime);
++-  /* poly->mod.norm = flint_clz(prime); */
++-
+++#else
+++  poly->mod.norm = flint_clz(prime);
+++#endif
++ }
++ 
++ static inline void fglm_param_set_prime(param_t *param, mp_limb_t prime){
++-- 
++2.40.1
++
+diff --git a/build/pkgs/sagelib/dependencies b/build/pkgs/sagelib/dependencies
+index 5dc2efe1d31..fa6e98df7db 100644
+--- a/build/pkgs/sagelib/dependencies
++++ b/build/pkgs/sagelib/dependencies
+@@ -1,4 +1,4 @@
+-FORCE $(SCRIPTS) arb boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
++FORCE $(SCRIPTS) boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/symengine/dependencies b/build/pkgs/symengine/dependencies
+index 1fc34963eda..7795d486018 100644
+--- a/build/pkgs/symengine/dependencies
++++ b/build/pkgs/symengine/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) arb ecm flint mpc mpfr | cmake
++$(MP_LIBRARY) ecm flint mpc mpfr | cmake
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/pkgs/sage-conf/_sage_conf/_conf.py.in b/pkgs/sage-conf/_sage_conf/_conf.py.in
+index 87b27ca05cb..895d6572d1e 100644
+--- a/pkgs/sage-conf/_sage_conf/_conf.py.in
++++ b/pkgs/sage-conf/_sage_conf/_conf.py.in
+@@ -19,8 +19,6 @@ MAXIMA_FAS = "@SAGE_MAXIMA_FAS@".replace('${prefix}', SAGE_LOCAL)
+ # Delete this line if your ECL can load Kenzo without further prodding.
+ KENZO_FAS = "@SAGE_KENZO_FAS@".replace('${prefix}', SAGE_LOCAL)
+ 
+-ARB_LIBRARY = "@SAGE_ARB_LIBRARY@"
+-
+ NTL_INCDIR = "@NTL_INCDIR@"
+ NTL_LIBDIR = "@NTL_LIBDIR@"
+ 
+diff --git a/src/sage/env.py b/src/sage/env.py
+index 4515e90e912..9ab6b1e1864 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -223,7 +223,6 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st
+ FOURTITWO_PPI = var("FOURTITWO_PPI")
+ FOURTITWO_CIRCUITS = var("FOURTITWO_CIRCUITS")
+ FOURTITWO_GROEBNER = var("FOURTITWO_GROEBNER")
+-ARB_LIBRARY = var("ARB_LIBRARY", "arb")
+ CBLAS_PC_MODULES = var("CBLAS_PC_MODULES", "cblas:openblas:blas")
+ ECL_CONFIG = var("ECL_CONFIG", "ecl-config")
+ NTL_INCDIR = var("NTL_INCDIR")
+@@ -356,8 +355,7 @@ def cython_aliases(required_modules=None,
+         sage: cython_aliases()
+         {...}
+         sage: sorted(cython_aliases().keys())
+-        ['ARB_LIBRARY',
+-         'CBLAS_CFLAGS',
++        ['CBLAS_CFLAGS',
+          ...,
+          'ZLIB_LIBRARIES']
+         sage: cython_aliases(required_modules=('module-that-is-assumed-to-not-exist'))
+@@ -475,8 +473,6 @@ def uname_specific(name, value, alternative):
+     if "LINBOX_CFLAGS" in aliases:
+         aliases["LINBOX_CFLAGS"].append("-std=gnu++11")
+ 
+-    aliases["ARB_LIBRARY"] = ARB_LIBRARY
+-
+     # TODO: Remove Cygwin hack by installing a suitable cblas.pc
+     if os.path.exists('/usr/lib/libblas.dll.a'):
+         aliases["CBLAS_LIBS"] = ['gslcblas']
+diff --git a/src/sage/features/sagemath.py b/src/sage/features/sagemath.py
+index bc34d35dd1c..4097d3512b9 100644
+--- a/src/sage/features/sagemath.py
++++ b/src/sage/features/sagemath.py
+@@ -777,7 +777,7 @@ class sage__rings__number_field(JoinFeature):
+     A :class:`~sage.features.Feature` describing the presence of :mod:`sage.rings.number_field`.
+ 
+     Number fields are implemented in Sage using a complicated mixture of various libraries,
+-    including :ref:`arb <spkg_arb>`, :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
++    including :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
+     :ref:`MPFI <spkg_mpfi>`, :ref:`NTL <spkg_ntl>`, and :ref:`PARI <spkg_pari>`.
+ 
+     EXAMPLES:
+diff --git a/src/sage/libs/arb/acb.pxd b/src/sage/libs/arb/acb.pxd
+index 5148dc43991..851488d803a 100644
+--- a/src/sage/libs/arb/acb.pxd
++++ b/src/sage/libs/arb/acb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -152,10 +152,6 @@ cdef extern from "arb_wrap.h":
+     void acb_sech(acb_t s, const acb_t z, long prec)
+     void acb_csch(acb_t c, const acb_t z, long prec)
+ 
+-    void acb_rising_ui_bs(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui_rs(acb_t z, const acb_t x, unsigned long n, unsigned long step, long prec)
+-    void acb_rising_ui_rec(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui(acb_t z, const acb_t x, unsigned long n, long prec)
+     void acb_rising(acb_t z, const acb_t x, const acb_t n, long prec)
+ 
+     void acb_gamma(acb_t y, const acb_t x, long prec)
+diff --git a/src/sage/libs/arb/acb_calc.pxd b/src/sage/libs/arb/acb_calc.pxd
+index a5dbf360b5e..67bd2ed57dc 100644
+--- a/src/sage/libs/arb/acb_calc.pxd
++++ b/src/sage/libs/arb/acb_calc.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_calc.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_elliptic.pxd b/src/sage/libs/arb/acb_elliptic.pxd
+index 176f68df00e..e3480e9f73b 100644
+--- a/src/sage/libs/arb/acb_elliptic.pxd
++++ b/src/sage/libs/arb/acb_elliptic.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_elliptic.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_hypgeom.pxd b/src/sage/libs/arb/acb_hypgeom.pxd
+index 418e766f10d..c43e5c0623b 100644
+--- a/src/sage/libs/arb/acb_hypgeom.pxd
++++ b/src/sage/libs/arb/acb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_hypgeom.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_modular.pxd b/src/sage/libs/arb/acb_modular.pxd
+index c708e9bf97d..cdc413c92da 100644
+--- a/src/sage/libs/arb/acb_modular.pxd
++++ b/src/sage/libs/arb/acb_modular.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_modular.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_poly.pxd b/src/sage/libs/arb/acb_poly.pxd
+index 69f4320055b..ae02757ffd9 100644
+--- a/src/sage/libs/arb/acb_poly.pxd
++++ b/src/sage/libs/arb/acb_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -79,24 +79,10 @@ cdef extern from "arb_wrap.h":
+     void _acb_poly_divrem(acb_ptr Q, acb_ptr R, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec)
+     bint acb_poly_divrem(acb_poly_t Q, acb_poly_t R, const acb_poly_t A, const acb_poly_t B, long prec)
+     void _acb_poly_div_root(acb_ptr Q, acb_t R, acb_srcptr A, long len, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_horner(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_horner(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_divconquer(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_divconquer(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_convolution(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_convolution(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+     void _acb_poly_taylor_shift(acb_ptr g, const acb_t c, long n, long prec)
+     void acb_poly_taylor_shift(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_compose_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_divconquer(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_divconquer(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+     void _acb_poly_compose(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+     void acb_poly_compose(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_series_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+-    void _acb_poly_compose_series_brent_kung(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_brent_kung(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_compose_series(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+     void acb_poly_compose_series(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_revert_series_lagrange(acb_ptr h, acb_srcptr f, long flen, long n, long prec)
+@@ -161,10 +147,6 @@ cdef extern from "arb_wrap.h":
+     void acb_poly_exp_series_basecase(acb_poly_t f, const acb_poly_t h, long n, long prec)
+     void _acb_poly_exp_series(acb_ptr f, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_exp_series(acb_poly_t f, const acb_poly_t h, long n, long prec)
+-    void _acb_poly_sin_cos_series_basecase(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_basecase(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+-    void _acb_poly_sin_cos_series_tangent(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_tangent(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+     void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_sin_cos_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec)
+     void _acb_poly_sin_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec)
+diff --git a/src/sage/libs/arb/arb.pxd b/src/sage/libs/arb/arb.pxd
+index c82b94de30f..acd232ab816 100644
+--- a/src/sage/libs/arb/arb.pxd
++++ b/src/sage/libs/arb/arb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -224,15 +224,8 @@ cdef extern from "arb_wrap.h":
+ 
+     void arb_lambertw(arb_t res, const arb_t x, int flags, long prec)
+ 
+-    void arb_rising_ui_bs(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui_rs(arb_t z, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising_ui_rec(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui(arb_t z, const arb_t x, unsigned long n, long prec)
+     void arb_rising(arb_t z, const arb_t x, const arb_t n, long prec)
+     void arb_rising_fmpq_ui(arb_t z, const fmpq_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_bs(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_rs(arb_t u, arb_t v, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising2_ui(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+     void arb_fac_ui(arb_t z, unsigned long n, long prec)
+     void arb_bin_ui(arb_t z, const arb_t n, unsigned long k, long prec)
+     void arb_bin_uiui(arb_t z, unsigned long n, unsigned long k, long prec)
+diff --git a/src/sage/libs/arb/arb_fmpz_poly.pxd b/src/sage/libs/arb/arb_fmpz_poly.pxd
+index 079f76e9d9e..55daa705238 100644
+--- a/src/sage/libs/arb/arb_fmpz_poly.pxd
++++ b/src/sage/libs/arb/arb_fmpz_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_fmpz_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -22,5 +22,4 @@ cdef extern from "arb_wrap.h":
+     unsigned long arb_fmpz_poly_deflation(const fmpz_poly_t poly)
+     void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long deflation)
+     void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, long prec)
+-    void arb_fmpz_poly_cos_minpoly(fmpz_poly_t res, unsigned long n)
+     void arb_fmpz_poly_gauss_period_minpoly(fmpz_poly_t res, unsigned long q, unsigned long n)
+diff --git a/src/sage/libs/arb/arb_hypgeom.pxd b/src/sage/libs/arb/arb_hypgeom.pxd
+index fb1c40ddaa8..139b987d669 100644
+--- a/src/sage/libs/arb/arb_hypgeom.pxd
++++ b/src/sage/libs/arb/arb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_hypgeom.h
+ 
+ from sage.libs.flint.types cimport fmpz_t
+diff --git a/src/sage/libs/arb/arb_wrap.h b/src/sage/libs/arb/arb_wrap.h
+index 49997075ee5..488bb376d5e 100644
+--- a/src/sage/libs/arb/arb_wrap.h
++++ b/src/sage/libs/arb/arb_wrap.h
+@@ -5,25 +5,27 @@
+  * by arb, most of which rely on flint's ulong and slong defines.
+  */
+ 
++#include <mpfr.h>
++
+ #undef ulong
+ #undef slong
+ 
+ #define ulong mp_limb_t
+ #define slong mp_limb_signed_t
+ 
+-#include <acb.h>
+-#include <acb_calc.h>
+-#include <acb_elliptic.h>
+-#include <acb_hypgeom.h>
+-#include <acb_mat.h>
+-#include <acb_modular.h>
+-#include <acb_poly.h>
+-#include <arb.h>
+-#include <arb_fmpz_poly.h>
+-#include <arb_hypgeom.h>
+-#include <arf.h>
+-#include <bernoulli.h>
+-#include <mag.h>
++#include <flint/acb.h>
++#include <flint/acb_calc.h>
++#include <flint/acb_elliptic.h>
++#include <flint/acb_hypgeom.h>
++#include <flint/acb_mat.h>
++#include <flint/acb_modular.h>
++#include <flint/acb_poly.h>
++#include <flint/arb.h>
++#include <flint/arb_fmpz_poly.h>
++#include <flint/arb_hypgeom.h>
++#include <flint/arf.h>
++#include <flint/bernoulli.h>
++#include <flint/mag.h>
+ 
+ #undef ulong
+ #undef slong
+diff --git a/src/sage/libs/arb/arf.pxd b/src/sage/libs/arb/arf.pxd
+index b8b83fefcdc..84778fe9f09 100644
+--- a/src/sage/libs/arb/arf.pxd
++++ b/src/sage/libs/arb/arf.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arf.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -30,7 +30,6 @@ cdef extern from "arb_wrap.h":
+     void arf_set_ui(arf_t y, unsigned long x)
+     void arf_set_si(arf_t y, long x)
+     void arf_set_mpfr(arf_t y, const mpfr_t x)
+-    # void arf_set_fmpr(arf_t y, const fmpr_t x)
+     void arf_set_d(arf_t y, double x)
+     void arf_swap(arf_t y, arf_t x)
+     void arf_init_set_ui(arf_t y, unsigned long x)
+@@ -46,7 +45,6 @@ cdef extern from "arb_wrap.h":
+     int arf_set_round_fmpz_2exp(arf_t y, const fmpz_t x, const fmpz_t e, long prec, arf_rnd_t rnd)
+     void arf_get_fmpz_2exp(fmpz_t m, fmpz_t e, const arf_t x)
+     double arf_get_d(const arf_t x, arf_rnd_t rnd)
+-    # void arf_get_fmpr(fmpr_t y, const arf_t x)
+     int arf_get_mpfr(mpfr_t y, const arf_t x, mpfr_rnd_t rnd)
+     void arf_get_fmpz(fmpz_t z, const arf_t x, arf_rnd_t rnd)
+     long arf_get_si(const arf_t x, arf_rnd_t rnd)
+diff --git a/src/sage/libs/arb/bernoulli.pxd b/src/sage/libs/arb/bernoulli.pxd
+index f859ebfb8d7..95a84dd5179 100644
+--- a/src/sage/libs/arb/bernoulli.pxd
++++ b/src/sage/libs/arb/bernoulli.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = bernoulli.h
+ 
+ from sage.libs.flint.types cimport fmpq_t, ulong
+diff --git a/src/sage/libs/arb/mag.pxd b/src/sage/libs/arb/mag.pxd
+index d5d8693ea8f..69dfb990ae0 100644
+--- a/src/sage/libs/arb/mag.pxd
++++ b/src/sage/libs/arb/mag.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = mag.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -27,13 +27,11 @@ cdef extern from "arb_wrap.h":
+     # void mag_randtest(mag_t x, flint_rand_t state, long expbits)
+     # void mag_randtest_special(mag_t x, flint_rand_t state, long expbits)
+     void mag_set_d(mag_t y, double x)
+-    # void mag_set_fmpr(mag_t y, const fmpr_t x)
+     void mag_set_ui(mag_t y, unsigned long x)
+     void mag_set_fmpz(mag_t y, const fmpz_t x)
+     void mag_set_d_2exp_fmpz(mag_t z, double x, const fmpz_t y)
+     void mag_set_fmpz_2exp_fmpz(mag_t z, const fmpz_t x, const fmpz_t y)
+     void mag_set_ui_2exp_si(mag_t z, unsigned long x, long y)
+-    # void mag_get_fmpr(fmpr_t y, const mag_t x)
+     void mag_get_fmpq(fmpq_t y, const mag_t x)
+     void mag_set_ui_lower(mag_t z, unsigned long x)
+     void mag_set_fmpz_lower(mag_t z, const fmpz_t x)
+diff --git a/src/sage/libs/flint/flint_wrap.h b/src/sage/libs/flint/flint_wrap.h
+index 266535c3835..4db72b97660 100644
+--- a/src/sage/libs/flint/flint_wrap.h
++++ b/src/sage/libs/flint/flint_wrap.h
+@@ -15,6 +15,7 @@
+  */
+ 
+ #include <gmp.h>
++#include <mpfr.h>
+ 
+ /* Save previous definition of ulong if any, as pari also uses it */
+ /* Should work on GCC, clang, MSVC */
+@@ -33,6 +34,7 @@
+ 
+ #include <flint/arith.h>
+ #include <flint/fmpq.h>
++#include <flint/fmpq_vec.h>
+ #include <flint/fmpq_mat.h>
+ #include <flint/fmpq_poly.h>
+ #include <flint/fmpz.h>
+@@ -47,6 +49,7 @@
+ #include <flint/fq.h>
+ #include <flint/fq_nmod.h>
+ #include <flint/nmod_poly.h>
++#include <flint/nmod_poly_factor.h>
+ #include <flint/nmod_vec.h>
+ #include <flint/padic.h>
+ #include <flint/padic_poly.h>
+diff --git a/src/sage/libs/flint/fmpq.pxd b/src/sage/libs/flint/fmpq.pxd
+index 5e64c82102f..0616c0a7408 100644
+--- a/src/sage/libs/flint/fmpq.pxd
++++ b/src/sage/libs/flint/fmpq.pxd
+@@ -12,6 +12,8 @@ cdef extern from "flint_wrap.h":
+     fmpz * fmpq_denref(fmpq_t)
+     void fmpq_init(fmpq_t)
+     void fmpq_clear(fmpq_t)
++    void fmpq_init_set_readonly(fmpq_t, const mpq_t)
++    void fmpq_clear_readonly(fmpq_t)
+     void fmpq_one(fmpq_t)
+     void fmpq_zero(fmpq_t)
+     bint fmpq_is_zero(fmpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pxd b/src/sage/libs/flint/fmpq_poly.pxd
+index 6050c487835..afa16e5bbdd 100644
+--- a/src/sage/libs/flint/fmpq_poly.pxd
++++ b/src/sage/libs/flint/fmpq_poly.pxd
+@@ -30,6 +30,9 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_canonicalise(fmpq_poly_t)
+     int fmpq_poly_is_canonical(const fmpq_poly_t)
+ 
++    void _fmpq_poly_set_length(fmpq_poly_t, slong)
++    void _fmpq_poly_normalise(fmpq_poly_t)
++
+     # Polynomial parameters
+     slong fmpq_poly_degree(const fmpq_poly_t)
+     ulong fmpq_poly_length(const fmpq_poly_t)
+@@ -46,10 +49,7 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_ui(fmpq_poly_t, ulong)
+     void fmpq_poly_set_fmpz(fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_set_fmpq(fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+     void fmpq_poly_set_fmpz_poly(fmpq_poly_t, const fmpz_poly_t)
+-    void fmpq_poly_set_array_mpq(fmpq_poly_t, const mpq_t *, slong)
+ 
+     void fmpq_poly_set_str(fmpq_poly_t, const char *)
+     char *fmpq_poly_get_str(const fmpq_poly_t)
+@@ -67,7 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_reverse(fmpq_poly_t, const fmpq_poly_t, slong)
+ 
+     void fmpq_poly_get_coeff_fmpq(fmpq_t, const fmpq_poly_t, slong)
+-    void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_si(slong, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_ui(ulong, const fmpq_poly_t, slong)
+ 
+@@ -75,8 +74,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_coeff_ui(fmpq_poly_t, slong, ulong)
+     void fmpq_poly_set_coeff_fmpz(fmpq_poly_t, slong, const fmpz_t)
+     void fmpq_poly_set_coeff_fmpq(fmpq_poly_t, slong, const fmpq_t)
+-    void fmpq_poly_set_coeff_mpz(fmpq_poly_t, slong, const mpz_t)
+-    void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
+ 
+     # Comparison
+     int fmpq_poly_equal(const fmpq_poly_t, const fmpq_poly_t)
+@@ -100,8 +97,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_mul_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     void fmpq_poly_scalar_div_si(fmpq_poly_t, const fmpq_poly_t, slong)
+     void fmpq_poly_scalar_div_ui(fmpq_poly_t, const fmpq_poly_t, ulong)
+@@ -109,8 +104,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_div_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_div_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_div_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Multiplication
+     void fmpq_poly_mul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -155,8 +148,6 @@ cdef extern from "flint_wrap.h":
+     # Evaluation
+     void fmpq_poly_evaluate_fmpz(fmpq_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_evaluate_fmpq(fmpq_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_evaluate_mpz(mpq_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_evaluate_mpq(mpq_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Composition
+     void fmpq_poly_compose(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -189,3 +180,11 @@ cdef extern from "flint_wrap.h":
+ # since the fmpq_poly header seems to be lacking this inline function
+ cdef inline sage_fmpq_poly_max_limbs(const fmpq_poly_t poly) noexcept:
+     return _fmpz_vec_max_limbs(fmpq_poly_numref(poly), fmpq_poly_length(poly))
++
++# functions removed from flint but still needed in sage
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
++cdef void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
++cdef void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pyx b/src/sage/libs/flint/fmpq_poly.pyx
+new file mode 100644
+index 00000000000..3b8a0cf0c51
+--- /dev/null
++++ b/src/sage/libs/flint/fmpq_poly.pyx
+@@ -0,0 +1,45 @@
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++from sage.libs.gmp.mpq cimport *
++from sage.libs.flint.fmpz cimport *
++from sage.libs.flint.fmpq cimport *
++
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t rop, const fmpq_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t rop, const fmpq_poly_t op, const mpq_t c):
++    cdef fmpq_t f
++    fmpq_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpq(rop, op, f)
++    fmpq_clear_readonly(f)
++
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t poly, slong n, const mpq_t x):
++    cdef fmpq_t t
++    fmpq_init_set_readonly(t, x)
++    fmpq_poly_set_coeff_fmpq(poly, n, t)
++    fmpq_clear_readonly(t)
++
++cdef void fmpq_poly_get_coeff_mpq(mpq_t x, const fmpq_poly_t poly, slong n):
++    cdef fmpq_t t
++    fmpq_init(t)
++    fmpq_poly_get_coeff_fmpq(t, poly, n)
++    fmpq_get_mpq(x, t)
++    fmpq_clear(t)
++
++cdef void fmpq_poly_set_mpq(fmpq_poly_t poly, const mpq_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), mpq_numref(x))
++    fmpz_set_mpz(fmpq_poly_denref(poly), mpq_denref(x))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
++
++cdef void fmpq_poly_set_mpz(fmpq_poly_t poly, const mpz_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), x)
++    fmpz_one(fmpq_poly_denref(poly))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz.pxd b/src/sage/libs/flint/fmpz.pxd
+index 01058d0f130..b97fbe1eae0 100644
+--- a/src/sage/libs/flint/fmpz.pxd
++++ b/src/sage/libs/flint/fmpz.pxd
+@@ -16,6 +16,9 @@ cdef extern from "flint_wrap.h":
+     void fmpz_init_set(fmpz_t, fmpz_t)
+     void fmpz_init_set_ui(fmpz_t, ulong)
+ 
++    void fmpz_init_set_readonly(fmpz_t, const mpz_t)
++    void fmpz_clear_readonly(fmpz_t)
++
+     # Conversion
+     void fmpz_set(fmpz_t f, fmpz_t g)
+     void fmpz_set_ui(fmpz_t, ulong)
+diff --git a/src/sage/libs/flint/fmpz_mod_poly.pxd b/src/sage/libs/flint/fmpz_mod_poly.pxd
+index 24b653eb3b7..2727246da98 100644
+--- a/src/sage/libs/flint/fmpz_mod_poly.pxd
++++ b/src/sage/libs/flint/fmpz_mod_poly.pxd
+@@ -67,13 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_get_coeff_fmpz(fmpz_t x, const fmpz_mod_poly_t poly,
+                                              slong n, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_set_coeff_mpz(fmpz_mod_poly_t poly,
+-                             slong n, const mpz_t x, const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_get_coeff_mpz(mpz_t x,
+-                 const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx)
+-
+-
+     void _fmpz_mod_poly_shift_left(fmpz * res, const fmpz * poly,
+                                                            slong len, slong n)
+ 
+@@ -194,14 +187,6 @@ cdef extern from "flint_wrap.h":
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_div_basecase(fmpz_mod_poly_t Q,
+-                            const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_div_newton_n_preinv(fmpz_mod_poly_t Q,
+-                         const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                         const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem_newton_n_preinv(fmpz_mod_poly_t Q,
+           fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                          const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+@@ -213,10 +198,6 @@ cdef extern from "flint_wrap.h":
+                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_divrem_divconquer(fmpz_mod_poly_t Q,
+-        fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem(fmpz_mod_poly_t Q, fmpz_mod_poly_t R,
+     const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+@@ -254,40 +235,13 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_make_monic_f(fmpz_t f, fmpz_mod_poly_t res,
+                          const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_euclidean(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_gcd_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_hgcd(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-
+     void fmpz_mod_poly_gcd(fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+ 
+-    void fmpz_mod_poly_xgcd_euclidean(fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_hgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S,
+-          fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_xgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                       const fmpz_mod_ctx_t ctx)
+@@ -361,14 +315,6 @@ cdef extern from "flint_wrap.h":
+                         const fmpz_mod_poly_t poly, const fmpz * xs, slong n,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_compose_horner(fmpz_mod_poly_t res,
+-                    const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_compose_divconquer(fmpz_mod_poly_t res,
+-                     const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_compose(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1,
+                          const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx)
+ 
+diff --git a/src/sage/libs/flint/fmpz_poly.pxd b/src/sage/libs/flint/fmpz_poly.pxd
+index 18b36672d30..c8bc6d3ca0a 100644
+--- a/src/sage/libs/flint/fmpz_poly.pxd
++++ b/src/sage/libs/flint/fmpz_poly.pxd
+@@ -28,7 +28,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_poly_set_ui(fmpz_poly_t, ulong)
+     void fmpz_poly_set_si(fmpz_poly_t, slong)
+     void fmpz_poly_set_fmpz(fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+     int fmpz_poly_set_str(fmpz_poly_t, const char *)
+ 
+     char *fmpz_poly_get_str(const fmpz_poly_t)
+@@ -70,7 +69,6 @@ cdef extern from "flint_wrap.h":
+     # Scalar multiplication and division
+     void fmpz_poly_scalar_mul_fmpz(
+             fmpz_poly_t, const fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+     void fmpz_poly_scalar_mul_si(fmpz_poly_t, const fmpz_poly_t, slong)
+     void fmpz_poly_scalar_mul_ui(fmpz_poly_t, const fmpz_poly_t, ulong)
+     void fmpz_poly_scalar_mul_2exp(fmpz_poly_t, const fmpz_poly_t, ulong)
+@@ -310,12 +308,14 @@ cdef extern from "flint_wrap.h":
+             fmpz_poly_t,
+                     const fmpz_poly_t, const fmpz_t, const nmod_poly_t, int)
+ 
+-    # Some functions for backwards compatibility
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
+-    void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++
++# functions removed from flint but still needed in sage
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
++cdef void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++cdef void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+ 
+ 
+ # Wrapper Cython class
+diff --git a/src/sage/libs/flint/fmpz_poly.pyx b/src/sage/libs/flint/fmpz_poly.pyx
+index 74915b37612..cfcbea9090c 100644
+--- a/src/sage/libs/flint/fmpz_poly.pyx
++++ b/src/sage/libs/flint/fmpz_poly.pyx
+@@ -25,10 +25,10 @@ from cysignals.memory cimport sig_free
+ 
+ from sage.arith.long cimport pyobject_to_long
+ from sage.cpython.string cimport char_to_str, str_to_bytes
++from sage.libs.flint.fmpz cimport *
+ from sage.structure.sage_object cimport SageObject
+ from sage.rings.integer cimport Integer
+ 
+-
+ cdef class Fmpz_poly(SageObject):
+ 
+     def __cinit__(self):
+@@ -455,3 +455,44 @@ cdef class Fmpz_poly(SageObject):
+         """
+         from sage.rings.integer_ring import ZZ
+         return ZZ[var](self.list())
++
++
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_divexact_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_fdiv_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t poly, slong n, const mpz_t x):
++    cdef fmpz_t t
++    fmpz_init_set_readonly(t, x)
++    fmpz_poly_set_coeff_fmpz(poly, n, t)
++    fmpz_clear_readonly(t)
++
++cdef void fmpz_poly_get_coeff_mpz(mpz_t x, const fmpz_poly_t poly, slong n):
++    cdef fmpz_t t
++    fmpz_init(t)
++    fmpz_poly_get_coeff_fmpz(t, poly, n)
++    fmpz_get_mpz(x, t)
++    fmpz_clear(t)
++
++cdef void fmpz_poly_set_mpz(fmpz_poly_t poly, const mpz_t x):
++    fmpz_poly_fit_length(poly, 1)
++    fmpz_set_mpz(poly.coeffs, x)
++    _fmpz_poly_set_length(poly, 1)
++    _fmpz_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz_poly_q.pxd b/src/sage/libs/flint/fmpz_poly_q.pxd
+index 846542dc0d8..63c13355bf6 100644
+--- a/src/sage/libs/flint/fmpz_poly_q.pxd
++++ b/src/sage/libs/flint/fmpz_poly_q.pxd
+@@ -49,11 +49,7 @@ cdef extern from "flint_wrap.h":
+ 
+     #* Scalar multiplication and division ****************************************/
+     void fmpz_poly_q_scalar_mul_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_mul_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_mul_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+     void fmpz_poly_q_scalar_div_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_div_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_div_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+ 
+     #* Multiplication and division ***********************************************/
+     void fmpz_poly_q_mul(fmpz_poly_q_t rop, 
+@@ -67,9 +63,6 @@ cdef extern from "flint_wrap.h":
+     #* Derivative ****************************************************************/
+     void fmpz_poly_q_derivative(fmpz_poly_q_t rop, const fmpz_poly_q_t op)
+ 
+-    #* Evaluation ****************************************************************/
+-    int fmpz_poly_q_evaluate(mpq_t rop, const fmpz_poly_q_t f, const mpq_t a)
+-
+     #* Input and output **********************************************************/
+     int fmpz_poly_q_set_str(fmpz_poly_q_t rop, const char *s)
+     char * fmpz_poly_q_get_str(const fmpz_poly_q_t op)
+diff --git a/src/sage/libs/linbox/linbox_flint_interface.pyx b/src/sage/libs/linbox/linbox_flint_interface.pyx
+index 1979ac0f0a4..37a340c457f 100644
+--- a/src/sage/libs/linbox/linbox_flint_interface.pyx
++++ b/src/sage/libs/linbox/linbox_flint_interface.pyx
+@@ -33,6 +33,7 @@ and C. Pernet. The functions available are:
+ #                  https://www.gnu.org/licenses/
+ # ****************************************************************************
+ 
++from sage.libs.gmp.types cimport mpz_t
+ from sage.libs.flint.types cimport fmpz_t
+ from sage.libs.flint.fmpz cimport fmpz_get_mpz, fmpz_set_mpz
+ from sage.libs.flint.fmpz_mat cimport fmpz_mat_entry, fmpz_mat_nrows, fmpz_mat_ncols
+@@ -80,11 +81,13 @@ cdef void fmpz_poly_set_linbox(fmpz_poly_t p, PolynomialRing_integer.Element& q)
+     (the .pxd file) in order to keep the header C-compatible
+     """
+     cdef size_t i
++    cdef mpz_t tmp
+ 
+     fmpz_poly_fit_length(p, q.size())
+ 
+     for i in range(q.size()):
+-        fmpz_poly_set_coeff_mpz(p, i, q[i].get_mpz_const())
++        tmp = q[i].get_mpz_const()
++        fmpz_poly_set_coeff_mpz(p, i, tmp)
+ 
+     _fmpz_poly_set_length(p, q.size())
+ 
+diff --git a/src/sage/matrix/matrix_complex_ball_dense.pyx b/src/sage/matrix/matrix_complex_ball_dense.pyx
+index e5414abdd9e..2f0131f4064 100644
+--- a/src/sage/matrix/matrix_complex_ball_dense.pyx
++++ b/src/sage/matrix/matrix_complex_ball_dense.pyx
+@@ -1,4 +1,4 @@
+-# distutils: libraries = ARB_LIBRARY
++# distutils: libraries = flint
+ r"""
+ Arbitrary precision complex ball matrices using Arb
+ 
+diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx
+index 27f5cdfac0f..6c5c20dbc6b 100644
+--- a/src/sage/matrix/matrix_integer_sparse.pyx
++++ b/src/sage/matrix/matrix_integer_sparse.pyx
+@@ -847,6 +847,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+             sage: matrix(ZZ, 1, 1, sparse=True)._charpoly_linbox()
+             x
+         """
++        cdef mpz_t tmp
+         if self._nrows != self._ncols:
+             raise ArithmeticError('only valid for square matrix')
+ 
+@@ -869,7 +870,8 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         cdef size_t i
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+@@ -966,9 +968,11 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         sig_off()
+ 
+         cdef size_t i
++        cdef mpz_t tmp
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
+index 1e3085c9215..0786de7fc81 100644
+--- a/src/sage/rings/complex_arb.pyx
++++ b/src/sage/rings/complex_arb.pyx
+@@ -1360,12 +1360,13 @@ cdef class ComplexBall(RingElement):
+             sage: CBF100(-3r)
+             -3.000000000000000000000000000000
+ 
+-            sage: ComplexBall(CBF100, 10^100)
+-            1.000000000000000000000000000000e+100
+             sage: ComplexBall(CBF100, CIF(1, 2))
+             1.000000000000000000000000000000 + 2.000000000000000000000000000000*I
+             sage: ComplexBall(CBF100, RBF(1/3), RBF(1))
+             [0.3333333333333333 +/- ...e-17] + 1.000000000000000000000000000000*I
++            sage: ComplexBall(CBF100, 10^100)
++            [1.000000000000000000000000000000e+100 +/- ...]
++
+             sage: NF.<a> = QuadraticField(-1, embedding=CC(0, -1))
+             sage: CBF(a)
+             -1.000000000000000*I
+@@ -3009,7 +3010,7 @@ cdef class ComplexBall(RingElement):
+             sage: CBF(1).rising_factorial(2**64)
+             [+/- ...e+347382171326740403407]
+             sage: ComplexBallField(128)(1).rising_factorial(2**64)
+-            [2.343691126796861348e+347382171305201285713 +/- ...e+347382171305201285694]
++            [2.34369112679686134...e+347382171305201285713 +/- ...]
+             sage: CBF(1/2).rising_factorial(CBF(2,3)) # abs tol 1e-15
+             [-0.123060451458124 +/- 3.06e-16] + [0.0406412631676552 +/- 7.57e-17]*I
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+index 04eaefc9fed..d99f0d3b98c 100644
+--- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+@@ -222,7 +222,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef unsigned long n
+         cdef Rational c
+         cdef list L1
+-        cdef mpq_t * L2
++        cdef fmpq_t q
+ 
+         Polynomial.__init__(self, parent, is_gen=is_gen)
+ 
+@@ -253,14 +253,11 @@ cdef class Polynomial_rational_flint(Polynomial):
+             L1 = [e if isinstance(e, Rational) else Rational(e) for e in x]
+             n  = <unsigned long> len(x)
+             sig_on()
+-            L2 = <mpq_t *> check_allocarray(n, sizeof(mpq_t))
++            fmpq_poly_fit_length(self._poly, n)
+             for deg from 0 <= deg < n:
+-                mpq_init(L2[deg])
+-                mpq_set(L2[deg], (<Rational> L1[deg]).value)
+-            fmpq_poly_set_array_mpq(self._poly, L2, n)
+-            for deg from 0 <= deg < n:
+-                mpq_clear(L2[deg])
+-            sig_free(L2)
++                fmpq_init_set_readonly(q, (<Rational> L1[deg]).value)
++                fmpq_poly_set_coeff_fmpq(self._poly, deg, q)
++                fmpq_clear_readonly(q)
+             sig_off()
+ 
+ #           deg = 0
+@@ -435,6 +432,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         utmost care.
+         """
+         cdef bint do_sig = _do_sig(self._poly)
++        cdef fmpz_t tmpfz
+ 
+         if isinstance(value, int):
+             if do_sig: sig_str("FLINT exception")
+@@ -442,7 +440,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+             if do_sig: sig_off()
+         elif isinstance(value, Integer):
+             if do_sig: sig_str("FLINT exception")
+-            fmpq_poly_set_coeff_mpz(self._poly, n, (<Integer> value).value)
++            fmpz_init_set_readonly(tmpfz, (<Integer> value).value)
++            fmpq_poly_set_coeff_fmpz(self._poly, n, tmpfz)
++            fmpz_clear_readonly(tmpfz)
+             if do_sig: sig_off()
+         elif isinstance(value, Rational):
+             if do_sig: sig_str("FLINT exception")
+@@ -492,7 +492,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef Polynomial_rational_flint f
+         cdef Rational r
+         cdef fmpz_t tmpfz
+-        cdef fmpq_t tmpfq
++        cdef fmpq_t tmpfq, tmpfq1
+         cdef RealBall arb_a, arb_z
+         cdef ComplexBall acb_a, acb_z
+ 
+@@ -508,13 +508,23 @@ cdef class Polynomial_rational_flint(Polynomial):
+             elif isinstance(a, Rational):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpq(r.value, self._poly, (<Rational> a).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> a).value)
++                fmpq_init(tmpfq1)
++                fmpq_poly_evaluate_fmpq(tmpfq1, self._poly, tmpfq)
++                fmpq_get_mpq(r.value, tmpfq1)
++                fmpq_clear(tmpfq1)
++                fmpq_clear_readonly(tmpfq)
+                 sig_off()
+                 return r
+             elif isinstance(a, Integer):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpz(r.value, self._poly, (<Integer> a).value)
++                fmpz_init_set_readonly(tmpfz, (<Integer> a).value)
++                fmpq_init(tmpfq)
++                fmpq_poly_evaluate_fmpz(tmpfq, self._poly, tmpfz)
++                fmpq_get_mpq(r.value, tmpfq)
++                fmpq_clear(tmpfq)
++                fmpz_clear_readonly(tmpfz)
+                 sig_off()
+                 return r
+             elif isinstance(a, int):
+@@ -1321,6 +1331,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         """
+         cdef Polynomial_rational_flint res
+         cdef bint do_sig
++        cdef fmpq_t tmpfq
+ 
+         if right == 0:
+             raise ZeroDivisionError("division by zero polynomial")
+@@ -1331,8 +1342,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+                 do_sig = _do_sig(self._poly)
+ 
+                 if do_sig: sig_str("FLINT exception")
+-                fmpq_poly_scalar_div_mpq(res._poly, self._poly,
+-                                                  (<Rational> QQ(right)).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> QQ(right)).value)
++                fmpq_poly_scalar_div_fmpq(res._poly, self._poly, tmpfq)
++                fmpq_clear_readonly(tmpfq)
+                 if do_sig: sig_off()
+                 return res
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+index 6e7f7498329..3a66198d568 100644
+--- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+@@ -658,6 +658,11 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
+             ...
+             NotImplementedError: square free factorization of polynomials over rings with composite characteristic is not implemented
+ 
++        :trac:`20003`::
++
++            sage: P.<x> = GF(7)[]
++            sage: (6*x+3).squarefree_decomposition()
++            (6) * (x + 4)
+         """
+         if not self.base_ring().is_field():
+             raise NotImplementedError("square free factorization of polynomials over rings with composite characteristic is not implemented")
+diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
+index 17961ac36b2..8509b19cc66 100644
+--- a/src/sage/rings/real_arb.pyx
++++ b/src/sage/rings/real_arb.pyx
+@@ -898,7 +898,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+             sage: RBF.gamma(5)
+             24.00000000000000
+             sage: RBF.gamma(10**20)
+-            [+/- ...e+1956570552410610660600]
++            [1.932849514310098...+1956570551809674817225 +/- ...]
+             sage: RBF.gamma(1/3)
+             [2.678938534707747 +/- ...e-16]
+             sage: RBF.gamma(-5)
+@@ -1102,7 +1102,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+              15.00000000000000,
+              48.00000000000000]
+             sage: RBF.double_factorial(2**20)
+-            [1.4483729903e+2928836 +/- ...e+2928825]
++            [1.448372990...e+2928836 +/- ...]
+             sage: RBF.double_factorial(2**1000)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/schemes/plane_conics/con_rational_function_field.py b/src/sage/schemes/plane_conics/con_rational_function_field.py
+index 05d24e78a85..581102b5c5b 100644
+--- a/src/sage/schemes/plane_conics/con_rational_function_field.py
++++ b/src/sage/schemes/plane_conics/con_rational_function_field.py
+@@ -198,38 +198,6 @@ def has_rational_point(self, point=False, algorithm='default',
+             Fraction Field of Univariate Polynomial Ring in u over Rational
+             Field with modulus v^2 - u^3 - 1
+ 
+-        ``has_rational_point`` fails for some conics over function fields
+-        over finite fields, due to :trac:`20003`::
+-
+-            sage: K.<t> = PolynomialRing(GF(7))
+-            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
+-            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
+-            sage: C.has_rational_point()                                                # needs sage.libs.singular
+-            Traceback (most recent call last):
+-            ...
+-            TypeError: self (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (-t^3 + 3*t^2 - 2*t - 2)/(t + 3)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (t^2 + 3*t + 3)*x*y + (-2*t^2 - 2)*y^2 + (-t^2 + 3*t + 2)*x*z + (-3*t + 3)*y*z + (-3*t^2 + t - 2)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x + (2*t - 2)/(t + 3)*y + (3*t^4 + 2*t^3 - 2*t^2 - 2*t + 3)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z
+-                     : y + (-t^3 - t^2 + 3*t - 1)/(t^3 - 3*t^2 + 2*t + 2)*z : z))
+-            domain must equal right (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^3 - t^2 + 3*t + 3)*x^2 + (t - 3)*y^2 + (-t^7 + 2*t^5 + t^4 + 2*t^3 + 3*t^2 - t - 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    -2/(t^3 - 3*t^2 + 2*t + 2)*x^2 + 1/(t^3 + 3*t^2 - 2*t + 1)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^9 - 2*t^8 + t^7 - t^6 + 3*t^5 - 3*t^3 + t^2 - 2*t + 3)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    ((t^3 - 3*t^2 + 2*t + 2)*x : (t^2 - 2)*y : (t^5 - 3*t^4 + t^2 + 3*t + 3)*z))
+-            codomain
+-
+-
+-
+         TESTS::
+ 
+             sage: K.<t> = FractionField(PolynomialRing(QQ, 't'))
+@@ -250,6 +218,16 @@ def has_rational_point(self, point=False, algorithm='default',
+             sage: C.has_rational_point(point=True)  # long time (4 seconds)             # needs sage.libs.singular
+             (True,
+              ((-2/117*t^8 + 304/1053*t^7 + 40/117*t^6 - 1/27*t^5 - 110/351*t^4 - 2/195*t^3 + 11/351*t^2 + 1/117)/(t^4 + 2/39*t^3 + 4/117*t^2 + 2/39*t + 14/39) : -5/3*t^4 + 19*t^3 : 1))
++
++        ``has_rational_point`` used to fail for some conics over function fields
++        over finite fields, due to :trac:`20003`::
++
++            sage: K.<t> = PolynomialRing(GF(7))
++            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
++            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
++            sage: C.has_rational_point()
++            True
++
+         """
+         from .constructor import Conic
+ 
+diff --git a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+index a591cb4cd7c..a90f2050c59 100644
+--- a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
++++ b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+@@ -20,6 +20,7 @@
+ #include "utils.h"
+ 
+ #include "gmp.h"
++#include "flint/fmpz_poly.h"
+ #include "flint/fmpq_poly.h"
+ #include "flint/fmpq.h"
+ 
+@@ -63,7 +64,7 @@ static ex chebyt_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+@@ -122,7 +123,7 @@ static ex chebyu_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+diff --git a/src/sage/symbolic/ginac/useries.cpp b/src/sage/symbolic/ginac/useries.cpp
+index 40fbd7ab360..b9a8b867648 100644
+--- a/src/sage/symbolic/ginac/useries.cpp
++++ b/src/sage/symbolic/ginac/useries.cpp
+@@ -467,10 +467,17 @@ void add::useries(flint_series_t& fp, int order) const
+                 fmpq_poly_set_ui(fp.ft, 0);
+         else if (oc.is_long())
+                 fmpq_poly_set_si(fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ 
+         for (const auto & elem : seq) {
+ 		const ex& t = recombine_pair_to_ex(elem);
+@@ -505,10 +512,17 @@ void mul::useries(flint_series_t& fp, int order) const
+ 
+         if (oc.is_long())
+                 fmpq_poly_scalar_mul_si(fp.ft, fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_scalar_mul_mpz(fp.ft, fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_scalar_mul_mpq(fp.ft, fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_scalar_mul_fmpz(fp.ft, fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp.ft, fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ void power::useries(flint_series_t& fp, int order) const
+@@ -563,7 +577,10 @@ void power::useries(flint_series_t& fp, int order) const
+                 }
+                 check_poly_ccoeff_one(fp1);
+                 fmpq_poly_log_series(fp1.ft, fp1.ft, order);
+-                fmpq_poly_scalar_mul_mpq(fp1.ft, fp1.ft, nexp.as_mpq());
++                fmpq_t tmp;
++                fmpq_init_set_readonly(tmp, nexp.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp1.ft, fp1.ft, tmp);
++                fmpq_clear_readonly(tmp);
+                 fmpq_poly_exp_series(fp.ft, fp1.ft, order);
+                 return;
+         }
+@@ -608,10 +625,17 @@ void numeric::useries(flint_series_t& fp, int order) const
+ {
+         if (is_long())
+                 fmpq_poly_set_si(fp.ft, to_long());
+-        else if (is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, as_mpq());
++        else if (is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ } // namespace GiNaC
+diff --git a/src/sage_setup/library_order.py b/src/sage_setup/library_order.py
+index f40690f8d22..9ae0d2579a7 100644
+--- a/src/sage_setup/library_order.py
++++ b/src/sage_setup/library_order.py
+@@ -16,17 +16,12 @@
+ 
+ aliases = cython_aliases(required_modules=(), optional_modules=modules)
+ 
+-if "ARB_LIBRARY" in aliases:
+-    arb_dylib_names = [aliases["ARB_LIBRARY"]]
+-else:
+-    arb_dylib_names = []
+-
+ library_order_list = aliases.get("SINGULAR_LIBRARIES", []) + [
+     "giac", "intl", "curl",
+     "ec", "ecm"
+ ] + aliases.get("LINBOX_LIBRARIES", []) + aliases.get("FFLASFFPACK_LIBRARIES", []) + aliases.get("GSL_LIBRARIES", []) + [
+     "pari", "flint", "ecl", "glpk", "ppl",
+-] + arb_dylib_names + [
++] + [
+     "mpfi", "mpfr", "mpc", "ntl", "gmp", "gmpxx",
+     "brial",
+     "brial_groebner",
diff --git a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch b/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
deleted file mode 100644
index 7c55bce6e9bb4..0000000000000
--- a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
+++ /dev/null
@@ -1,221 +0,0 @@
-diff --git a/build/pkgs/singular/checksums.ini b/build/pkgs/singular/checksums.ini
-index 313463d2fea..1101fc55700 100644
---- a/build/pkgs/singular/checksums.ini
-+++ b/build/pkgs/singular/checksums.ini
-@@ -1,5 +1,5 @@
- tarball=singular-VERSION.tar.gz
--sha1=28bb3ee97ef48d04dfa96de182fd93eebe08426c
--md5=fc0a4f5720dadba45a52ee94324ce00c
--cksum=1573851737
--upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-1/singular-VERSION.tar.gz
-+sha1=df1997f412580f2073295aba569bb955ad227317
-+md5=50349213e206a18cdaa1bc410dde7ea4
-+cksum=376854707
-+upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-2/singular-VERSION.tar.gz
-diff --git a/build/pkgs/singular/package-version.txt b/build/pkgs/singular/package-version.txt
-index 66e2bede53a..9f1bf008217 100644
---- a/build/pkgs/singular/package-version.txt
-+++ b/build/pkgs/singular/package-version.txt
-@@ -1 +1 @@
--4.3.1p3
-+4.3.2p7
-diff --git a/build/pkgs/singular/spkg-configure.m4 b/build/pkgs/singular/spkg-configure.m4
-index 6a85631f624..f7621ec5fa1 100644
---- a/build/pkgs/singular/spkg-configure.m4
-+++ b/build/pkgs/singular/spkg-configure.m4
-@@ -6,14 +6,27 @@ SAGE_SPKG_CONFIGURE([singular], [
-     AS_IF([test -z "${SINGULAR_BIN}"], [sage_spkg_install_singular=yes], [
-       dnl Use pkg-config to ensure that Singular is new enough.
-       PKG_CHECK_MODULES([SINGULAR], [Singular >= 4.2.1], [
--       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)
--       ], [
--       AC_MSG_RESULT(no)
--       sage_spkg_install_singular=yes
--       ]
--      )], [
-+        AC_MSG_CHECKING([whether Singular is built with FLINT])
-+        AC_COMPILE_IFELSE([
-+          AC_LANG_PROGRAM([
-+            #include <singular/singularconfig.h>
-+            #if !defined(HAVE_FLINT)
-+            #  error "Need Singular compiled with FLINT"
-+          ], [])
-+        ], [
-+          AC_MSG_RESULT([yes])
-+          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)
-+          ], [
-+            AC_MSG_RESULT(no)
-+            sage_spkg_install_singular=yes
-+          ])
-+        ], [
-+          AC_MSG_RESULT([no])
-+          sage_spkg_install_singular=yes
-+        ])
-+      ], [
-       dnl pkg-config version check failed
-       sage_spkg_install_singular=yes
-       ])
-diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py
-index b15cc1c602c..4b5c76e2bfa 100644
---- a/src/sage/interfaces/singular.py
-+++ b/src/sage/interfaces/singular.py
-@@ -604,8 +604,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: i = singular.ideal(['x^2','y^2','z^2'])
-             sage: s = i.std()
-             sage: singular.eval('hilb(%s)'%(s.name()))
--            '// 1 t^0\n// -3 t^2\n// 3 t^4\n// -1 t^6\n\n// 1 t^0\n//
--            3 t^1\n// 3 t^2\n// 1 t^3\n// dimension (affine) = 0\n//
-+            '...// dimension (affine) = 0\n//
-             degree (affine) = 8'
- 
-         ::
-@@ -613,15 +612,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: from sage.misc.verbose import set_verbose
-             sage: set_verbose(1)
-             sage: o = singular.eval('hilb(%s)'%(s.name()))
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
- 
-         This is mainly useful if this method is called implicitly. Because
-@@ -631,15 +622,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-         ::
- 
-             sage: o = s.hilb()
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
-             // ** right side is not a datum, assignment ignored
-             ...
-diff --git a/src/sage/libs/singular/function.pyx b/src/sage/libs/singular/function.pyx
-index f40346d1fd0..c597c63aafe 100644
---- a/src/sage/libs/singular/function.pyx
-+++ b/src/sage/libs/singular/function.pyx
-@@ -1241,32 +1241,22 @@ cdef class SingularFunction(SageObject):
-             sage: I = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5])
-             sage: I = Ideal(I.groebner_basis())
-             sage: hilb = sage.libs.singular.function_factory.ff.hilb
--            sage: hilb(I) # Singular will print // ** _ is no standard basis
--            // ** _ is no standard basis
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: from sage.misc.sage_ostools import redirection
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I) # Singular will print // ** _ is no standard basis
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            True
- 
-         So we tell Singular that ``I`` is indeed a Groebner basis::
- 
--            sage: hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            False
- 
- 
-         TESTS:
-diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-index 22ada6de947..80352700872 100644
---- a/src/sage/rings/polynomial/multi_polynomial_ideal.py
-+++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-@@ -3132,13 +3132,16 @@ def hilbert_numerator(self, grading=None, algorithm='sage'):
-             sage: I.hilbert_numerator()                                                 # needs sage.rings.number_field
-             -t^5 + 1
- 
--        This example returns a wrong answer due to an integer overflow in Singular::
-+        This example returns a wrong answer in singular < 4.3.2p4 due to an integer overflow::
- 
-             sage: n=4; m=11; P = PolynomialRing(QQ, n*m, "x"); x = P.gens(); M = Matrix(n, x)
-             sage: I = P.ideal(M.minors(2))
-             sage: J = P * [m.lm() for m in I.groebner_basis()]
--            sage: J.hilbert_numerator(algorithm='singular')
--            ...120*t^33 - 3465*t^32 + 48180*t^31 - ...
-+            sage: J.hilbert_numerator(algorithm='singular') # known bug
-+            Traceback (most recent call last):
-+            ....
-+            RuntimeError: error in Singular function call 'hilb':
-+            overflow at t^22
- 
-         Our two algorithms should always agree; not tested until
-         :trac:`33178` is fixed::
-diff --git a/src/sage/sandpiles/sandpile.py b/src/sage/sandpiles/sandpile.py
-index 02d2021b2fb..c8e15e06f05 100644
---- a/src/sage/sandpiles/sandpile.py
-+++ b/src/sage/sandpiles/sandpile.py
-@@ -2493,9 +2493,15 @@ def _set_ideal(self):
-             sage: '_ideal' in S.__dict__
-             True
-         """
-+        from sage.libs.singular.function_factory import ff
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
-         R = self.ring()
--        I = self._unsaturated_ideal._singular_()
--        self._ideal = R.ideal(I.sat(prod(R.gens())._singular_())[1])
-+        I = self._unsaturated_ideal
-+        I_sat_gens = sat(I, prod(R.gens()))[0]
-+        self._ideal = R.ideal(I_sat_gens)
- 
-     def unsaturated_ideal(self):
-         r"""
-diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py
-index e6caf19ba74..afd6484d779 100644
---- a/src/sage/schemes/projective/projective_subscheme.py
-+++ b/src/sage/schemes/projective/projective_subscheme.py
-@@ -1001,7 +1001,10 @@ def dual(self):
-         for i in range(n + 1):
-             J = J + S.ideal(z[-1] * f_S.derivative(z[i]) - z[i + n + 1])
- 
--        sat = ff.elim__lib.sat
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
- 
-         max_ideal = S.ideal(z[n + 1: 2 * n + 2])
-         J_sat_gens = sat(J, max_ideal)[0]
diff --git a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch b/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
deleted file mode 100644
index 6a35ec3836550..0000000000000
--- a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-diff --git a/src/sage/ext/memory.pyx b/src/sage/ext/memory.pyx
-index 1de6dedab82..b95130b19dd 100644
---- a/src/sage/ext/memory.pyx
-+++ b/src/sage/ext/memory.pyx
-@@ -3,14 +3,14 @@ Low-level memory allocation functions
- 
- TESTS:
- 
--Check that a ``MemoryError`` is raised if we try to allocate a
-+Check that an error is raised if we try to allocate a
- ridiculously large integer, see :trac:`15363`::
- 
--    sage: 2^(2^63-3)
--    Traceback (most recent call last):
--    ...
--    OverflowError: exponent must be at most 2147483647         # 32-bit
--    RuntimeError: Aborted                                      # 64-bit
-+    sage: try:
-+    ....:     2^(2^63-3)
-+    ....: except (OverflowError, RuntimeError, FloatingPointError):
-+    ....:     print ('Overflow error')
-+    ...Overflow error
- 
- AUTHORS:
- 
-diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx
-index d5e87626d31..37ed9364845 100644
---- a/src/sage/rings/integer.pyx
-+++ b/src/sage/rings/integer.pyx
-@@ -6654,7 +6654,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
-             sage: try:
-             ....:     print('Possible error output from gmp', flush=True)
-             ....:     1 << (2^60)
--            ....: except (MemoryError, OverflowError, RuntimeError):
-+            ....: except (MemoryError, OverflowError, RuntimeError, FloatingPointError):
-             ....:     pass
-             ....: else:
-             ....:     print("Failed to raise exception")
diff --git a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch b/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
deleted file mode 100644
index 3d2a4bd9cd96f..0000000000000
--- a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
+++ /dev/null
@@ -1,740 +0,0 @@
-diff --git a/src/sage/ext_data/valgrind/valgrind-python.supp b/src/sage/ext_data/valgrind/valgrind-python.supp
-new file mode 100644
-index 00000000000..16aa2858484
---- /dev/null
-+++ b/src/sage/ext_data/valgrind/valgrind-python.supp
-@@ -0,0 +1,480 @@
-+# From the CPython repository with the suppressions for _PyObject_Free
-+# and _PyObject_Realloc enabled. See the upstream suppression file for
-+# details:
-+#
-+# https://github.com/python/cpython/blob/main/Misc/valgrind-python.supp
-+
-+# all tool names: Addrcheck,Memcheck,cachegrind,helgrind,massif
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 8 (x86_64 aka amd64)
-+   Memcheck:Value8
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:address_in_range
-+}
-+
-+#
-+# Leaks (including possible leaks)
-+#    Hmmm, I wonder if this masks some real leaks.  I think it does.
-+#    Will need to fix that.
-+#
-+
-+{
-+   Suppress leaking the GIL after a fork.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_allocate_lock
-+   fun:PyEval_ReInitThreads
-+}
-+
-+{
-+   Suppress leaking the autoTLSkey.  This looks like it shouldn't leak though.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_create_key
-+   fun:_PyGILState_Init
-+   fun:Py_InitializeEx
-+   fun:Py_Main
-+}
-+
-+{
-+   Hmmm, is this a real leak or like the GIL?
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_ReInitTLS
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:realloc
-+   fun:_PyObject_GC_Resize
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_New
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_NewVar
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+#
-+# Non-python specific leaks
-+#
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:calloc
-+   fun:allocate_dtv
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:memalign
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Realloc
-+}
-+
-+###
-+### All the suppressions below are for errors that occur within libraries
-+### that Python uses.  The problems to not appear to be related to Python's
-+### use of the libraries.
-+###
-+
-+{
-+   Generic ubuntu ld problems
-+   Memcheck:Addr8
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+}
-+
-+{
-+   Generic gentoo ld problems
-+   Memcheck:Cond
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_close
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Value8
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   GDBM problems, see test_gdbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   fun:gdbm_open
-+
-+}
-+
-+{
-+   Uninitialised byte(s) false alarm, see bpo-35561
-+   Memcheck:Param
-+   epoll_ctl(event)
-+   fun:epoll_ctl
-+   fun:pyepoll_internal_ctl
-+}
-+
-+{
-+   ZLIB problems, see test_gzip
-+   Memcheck:Cond
-+   obj:/lib/libz.so.1.2.3
-+   obj:/lib/libz.so.1.2.3
-+   fun:deflate
-+}
-+
-+{
-+   Avoid problems w/readline doing a putenv and leaking on exit
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:xmalloc
-+   fun:sh_set_lines_and_columns
-+   fun:_rl_get_screen_size
-+   fun:_rl_init_terminal_io
-+   obj:/lib/libreadline.so.4.3
-+   fun:rl_initialize
-+}
-+
-+# Valgrind emits "Conditional jump or move depends on uninitialised value(s)"
-+# false alarms on GCC builtin strcmp() function. The GCC code is correct.
-+#
-+# Valgrind bug: https://bugs.kde.org/show_bug.cgi?id=264936
-+{
-+   bpo-38118: Valgrind emits false alarm on GCC builtin strcmp()
-+   Memcheck:Cond
-+   fun:PyUnicode_Decode
-+}
-+
-+
-+###
-+### These occur from somewhere within the SSL, when running
-+###  test_socket_sll.  They are too general to leave on by default.
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:memset
-+###}
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:memset
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:MD5_Update
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:MD5_Update
-+###}
-+
-+# Fedora's package "openssl-1.0.1-0.1.beta2.fc17.x86_64" on x86_64
-+# See http://bugs.python.org/issue14171
-+{
-+   openssl 1.0.1 prng 1
-+   Memcheck:Cond
-+   fun:bcmp
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 2
-+   Memcheck:Cond
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 3
-+   Memcheck:Value8
-+   fun:_x86_64_AES_encrypt_compact
-+   fun:AES_encrypt
-+}
-+
-+#
-+# All of these problems come from using test_socket_ssl
-+#
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_bin2bn
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libcrypto.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_set_key_unchecked
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_encrypt2
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BUF_MEM_grow_clean
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:memcpy
-+   fun:ssl3_read_bytes
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:SHA1_Update
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:SHA1_Update
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-+{
-+   wcscmp_false_positive
-+   Memcheck:Addr8
-+   fun:wcscmp
-+   fun:_PyOS_GetOpt
-+   fun:Py_Main
-+   fun:main
-+}
-+
-+# Additional suppressions for the unified decimal tests:
-+{
-+   test_decimal
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_decimal2
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index b40ed64edb5..8c55861c147 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -1576,6 +1576,62 @@ const numeric numeric::div(const numeric &other) const {
-         }
- }
- 
-+
-+// Compute `a^b` as an integer, where a is an integer. Assign to ``res``` if it is integral, or return ``false``.
-+// The nonnegative real root is taken for even denominators. To be used inside numeric::integer_rational_power,
-+// to handle the special case of integral ``a``.
-+bool integer_rational_power_of_mpz(
-+        numeric& res,
-+        const numeric& a,
-+        const numeric& b
-+) {
-+        if (a.t != MPZ)
-+                throw std::runtime_error("integer_rational_power_of_mpz: bad input");
-+        mpz_t z;
-+        mpz_init(z);
-+        mpz_set_ui(z, 0);
-+        int sgn = mpz_sgn(a.v._bigint);
-+        if (mpz_cmp_ui(a.v._bigint, 1) == 0
-+            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
-+                mpz_set_ui(z, 1);
-+        else if (sgn == 0) {
-+                res = *_num0_p;
-+                mpz_clear(z);
-+                return true;
-+        }
-+        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1)) {
-+                mpz_clear(z);
-+                return false;
-+        } else {
-+                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-+                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat))) {
-+                        // too big to take roots/powers
-+                        mpz_clear(z);
-+                        return false;
-+                }
-+                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
-+                        if (mpz_perfect_square_p(a.v._bigint)) {
-+                                mpz_sqrt(z, a.v._bigint);
-+                        } else {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                else {
-+                        bool exact = mpz_root(z, a.v._bigint,
-+                                              mpz_get_ui(mpq_denref(b.v._bigrat)));
-+                        if (not exact) {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
-+        }
-+        res = numeric(z);   // transfers ownership, no mpz_clear
-+        return true;
-+}
-+
-+
- // Compute `a^b` as an integer, if it is integral, or return ``false``.
- // The nonnegative real root is taken for even denominators.
- bool numeric::integer_rational_power(numeric& res,
-@@ -1598,13 +1654,12 @@ bool numeric::integer_rational_power(numeric& res,
-                 if (a.v._long < 0
-                     and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
-                         return false;
--                long z;
-                 if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-                     or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
-                 // too big to take roots/powers
-                         return false;
-                 if (b.is_equal(*_num1_2_p)) {
--                        z = std::lround(std::sqrt(a.v._long));
-+                        long z = std::lround(std::sqrt(a.v._long));
-                         if (a.v._long == z*z) {
-                                 res = numeric(z);
-                                 return true;
-@@ -1613,44 +1668,11 @@ bool numeric::integer_rational_power(numeric& res,
-                 }
-                 return integer_rational_power(res, a.to_bigint(), b);
-         }
--        if (a.t != MPZ)
--                throw std::runtime_error("integer_rational_power: bad input");
--        int sgn = mpz_sgn(a.v._bigint);
--        mpz_t z;
--        mpz_init(z);
--        mpz_set_ui(z, 0);
--        if (mpz_cmp_ui(a.v._bigint, 1) == 0
--            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
--                mpz_set_ui(z, 1);
--        else if (sgn == 0) {
--                res = *_num0_p;
--                return true;
--        }
--        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
--                return false;
--        else {
--                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
--                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
--                // too big to take roots/powers
--                        return false;
--                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
--                        if (mpz_perfect_square_p(a.v._bigint))
--                                mpz_sqrt(z, a.v._bigint);
--                        else
--                                return false;
--                }
--                else {
--                        bool exact = mpz_root(z, a.v._bigint,
--                                        mpz_get_ui(mpq_denref(b.v._bigrat)));
--                        if (not exact)
--                                return false;
--                }
--                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
--        }
--        res = numeric(z);
--        return true;
-+        // otherwise: a is integer
-+        return integer_rational_power_of_mpz(res, a, b);
- }
- 
-+
- // for a^b return c,d such that a^b = c*d^b
- // only for MPZ/MPQ base and MPQ exponent
- void rational_power_parts(const numeric& a_orig, const numeric& b_orig,
-diff --git a/src/sage/tests/memcheck/__init__.py b/src/sage/tests/memcheck/__init__.py
-new file mode 100644
-index 00000000000..e69de29bb2d
-diff --git a/src/sage/tests/memcheck/run_tests.py b/src/sage/tests/memcheck/run_tests.py
-new file mode 100644
-index 00000000000..6ff4503a81b
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests.py
-@@ -0,0 +1,24 @@
-+import types
-+
-+
-+def run_tests() -> None:
-+    """
-+    Run all memcheck tests
-+    """
-+    from sage.tests.memcheck import symbolic_expression
-+    run_tests_in_module(symbolic_expression)
-+
-+
-+def run_tests_in_module(mod: types.ModuleType) -> None:
-+    """
-+    Run all memcheck tests in the given module
-+    """
-+    for entry in dir(mod):
-+        if not entry.startswith('test_'):
-+            continue
-+        test_func = getattr(mod, entry)
-+        test_func()
-+
-+
-+if __name__ == '__main__':
-+    run_tests()
-diff --git a/src/sage/tests/memcheck/run_tests_in_valgrind.py b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-new file mode 100644
-index 00000000000..df5ad0e92b2
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-@@ -0,0 +1,35 @@
-+"""
-+Launch valgrind and run the memory leak tests
-+
-+
-+From the commandline, run
-+
-+    sage -python -m sage.tests.memcheck.run_tests_in_valgrind
-+
-+to launch valgrind and execute the memory leak tests. Requires valgrind
-+to be installed. Alternatively, run as a unit test:
-+
-+    sage: from sage.tests.memcheck.run_tests_in_valgrind import run_tests_in_valgrind
-+    sage: run_tests_in_valgrind()    # optional - valgrind
-+"""
-+
-+import subprocess
-+
-+
-+def run_tests_in_valgrind() -> None:
-+    """
-+    Run the sage.tests.memcheck.run_tests module inside valgrind
-+    """
-+    subprocess.check_call([
-+        'valgrind',
-+        '--suppressions=src/sage/ext_data/valgrind/valgrind-python.supp',
-+        '--show-possibly-lost=no',
-+        '--show-reachable=no',
-+        './venv/bin/python',
-+        '-m',
-+        'sage.tests.memcheck.run_tests'
-+    ])
-+
-+
-+if __name__ == '__main__':
-+    run_tests_in_valgrind()
-diff --git a/src/sage/tests/memcheck/symbolic_expression.py b/src/sage/tests/memcheck/symbolic_expression.py
-new file mode 100644
-index 00000000000..52182fbe62d
---- /dev/null
-+++ b/src/sage/tests/memcheck/symbolic_expression.py
-@@ -0,0 +1,11 @@
-+from sage.tests.memcheck.verify_no_leak import verify_no_leak
-+
-+
-+def test_sqrt_sqrt_2() -> None:
-+    from sage.misc.functional import sqrt
-+    T2 = sqrt(2)
-+
-+    def sqrt_T2() -> None:
-+        sqrt(T2)
-+
-+    verify_no_leak(sqrt_T2)
-diff --git a/src/sage/tests/memcheck/verify_no_leak.py b/src/sage/tests/memcheck/verify_no_leak.py
-new file mode 100644
-index 00000000000..89ca90cf89c
---- /dev/null
-+++ b/src/sage/tests/memcheck/verify_no_leak.py
-@@ -0,0 +1,27 @@
-+from typing import Tuple, Sequence, List, Callable, Any
-+import valgrind
-+
-+
-+def verify_no_leak(callback: Callable[[], Any],
-+                   repeat: int = 10000,
-+                   fuzzy: int = 10,
-+                   ) -> None:
-+    """
-+    Verify that the callback does not generate new definitely lost blocks
-+
-+    Raises an assertion if the callback leaks memory
-+    """
-+    callback()   # warm_up
-+    initial_blocks = (0, 0, 0, 0)
-+    valgrind.memcheck_do_leak_check()
-+    initial_blocks = valgrind.memcheck_count_leak_blocks()
-+    for _ in range(repeat):
-+        callback()
-+    valgrind.memcheck_do_leak_check()
-+    leak_blocks = valgrind.memcheck_count_leak_blocks()
-+    leak = leak_blocks[0] - initial_blocks[0]
-+    if leak < repeat - fuzzy:
-+        return  # callback did not leak at least once per call
-+    blocks = round(leak / repeat, 2)
-+    message = f'{callback} leaked {blocks} block on average ({repeat} iterations)'
-+    raise AssertionError(message)
diff --git a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch b/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
deleted file mode 100644
index 684b62affaf5a..0000000000000
--- a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx
-index 8f46570313d..a8e73e57b52 100644
---- a/src/sage/libs/ecl.pyx
-+++ b/src/sage/libs/ecl.pyx
-@@ -563,15 +563,15 @@ cdef class EclObject:
-     Floats in Python are IEEE double, which LISP has as well. However,
-     the printing of floating point types in LISP depends on settings::
- 
--        sage: a = EclObject(float(10^40))
-+        sage: a = EclObject(float(1.234e40))
-         sage: ecl_eval("(setf *read-default-float-format* 'single-float)")
-         <ECL: SINGLE-FLOAT>
-         sage: a
--        <ECL: 1.d40>
-+        <ECL: 1.234d40>
-         sage: ecl_eval("(setf *read-default-float-format* 'double-float)")
-         <ECL: DOUBLE-FLOAT>
-         sage: a
--        <ECL: 1.e40>
-+        <ECL: 1.234e40>
- 
-     Tuples are translated to dotted lists::
- 
-diff --git a/src/sage/libs/eclsig.h b/src/sage/libs/eclsig.h
-index e249ccf6874..005b2d99d0b 100644
---- a/src/sage/libs/eclsig.h
-+++ b/src/sage/libs/eclsig.h
-@@ -45,7 +45,11 @@ static inline void ecl_sig_off(void)
-     sig_off();
- }
- 
-+#if ECL_VERSION_NUMBER < 230909
- #define ecl_mpz_from_bignum(obj) ((obj)->big.big_num)
-+#else
-+#define ecl_mpz_from_bignum(obj) ecl_bignum(obj)
-+#endif
- 
- cl_object ecl_bignum_from_mpz(mpz_t num)
- {
diff --git a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch b/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
deleted file mode 100644
index e858f2fd4a445..0000000000000
--- a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
-index 59f10f6b13f..adcccff059b 100644
---- a/src/sage/plot/graphics.py
-+++ b/src/sage/plot/graphics.py
-@@ -36,6 +36,7 @@
- # ****************************************************************************
- 
- import os
-+from numbers import Integral
- from collections.abc import Iterable
- from math import isnan
- import sage.misc.verbose
-@@ -2874,6 +2875,11 @@ def matplotlib(self, filename=None,
-                 weight=lopts.pop('font_weight', 'medium'),
-                 variant=lopts.pop('font_variant', 'normal'))
-             color = lopts.pop('back_color', 'white')
-+            if 'loc' in lopts:
-+                loc = lopts['loc']
-+                if isinstance(loc, Integral):
-+                    # matplotlib 3.8 doesn't support sage integers
-+                    lopts['loc'] = int(loc)
-             leg = subplot.legend(prop=prop, **lopts)
-             if leg is None:
-                 from warnings import warn
diff --git a/srcpkgs/sagemath/patches/36403-00pre.patch b/srcpkgs/sagemath/patches/36403-00pre.patch
deleted file mode 100644
index 060404d5430de..0000000000000
--- a/srcpkgs/sagemath/patches/36403-00pre.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-Minor patch so that #36403 applies cleanly over sagemath 10.1
-
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 2053bca80c3..86aca6e00d8 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15123,7 +15302,8 @@ cdef class Matrix(Matrix1):
-             sage: N.conjugate_transpose()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object has no attribute 'conjugate'
-+            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
-+            has no attribute 'conjugate'
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 525ea5aa934..52afed49d64 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -55,7 +55,7 @@ cdef class AttributeErrorMessage:
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-         sage: x = polygen(ZZ, 'x')
--        sage: QQ[x].gen().bla                                                           # optional - sage.libs.flint
-+        sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
diff --git a/srcpkgs/sagemath/patches/36407-python_3.12.patch b/srcpkgs/sagemath/patches/36407-python_3.12.patch
deleted file mode 100644
index c75c275c30764..0000000000000
--- a/srcpkgs/sagemath/patches/36407-python_3.12.patch
+++ /dev/null
@@ -1,1744 +0,0 @@
-diff --git a/build/sage_bootstrap/package.py b/build/sage_bootstrap/package.py
-index 15b342223c4..eb82f96e05f 100644
---- a/build/sage_bootstrap/package.py
-+++ b/build/sage_bootstrap/package.py
-@@ -303,7 +303,7 @@ def _init_checksum(self):
-         # Name of the directory containing the checksums.ini file
-         self.__tarball_package_name = os.path.realpath(checksums_ini).split(os.sep)[-2]
- 
--    VERSION_PATCHLEVEL = re.compile('(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
-+    VERSION_PATCHLEVEL = re.compile(r'(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
- 
-     def _init_version(self):
-         try:
-diff --git a/src/doc/en/thematic_tutorials/coercion_and_categories.rst b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-index bb23331c151..7f5712caea7 100644
---- a/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-+++ b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-@@ -1223,7 +1223,7 @@ However, only "elementary" construction functors have a rank::
-     sage: (Fract*Poly).rank
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'
-+    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'...
- 
- .. end of output
- 
-diff --git a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-index 553a946c4d8..3cd71a9bad4 100644
---- a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-+++ b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-@@ -318,7 +318,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: e.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'...
- 
-         sage: id4 = SymmetricGroup(4).one()
-         sage: type(id4)
-@@ -326,7 +326,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: id4.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'
-+        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'...
- 
- .. note::
- 
-diff --git a/src/sage/algebras/cluster_algebra.py b/src/sage/algebras/cluster_algebra.py
-index b72d2a12976..14669dfed5c 100644
---- a/src/sage/algebras/cluster_algebra.py
-+++ b/src/sage/algebras/cluster_algebra.py
-@@ -167,7 +167,7 @@
-     sage: (t*s).g_vector()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'
-+    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'...
-     sage: A = ClusterAlgebra(['A', 2], principal_coefficients=True)
-     sage: A.explore_to_depth(infinity)
-     sage: s = A.cluster_variable((0, -1)); s
-diff --git a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-index e4a91723558..343ee8a66f9 100644
---- a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-+++ b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-@@ -109,7 +109,7 @@ class WeylLieConformalAlgebra(LieConformalAlgebraWithStructureCoefficients):
-         sage: alpha0.degree()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'
-+        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'...
- 
-     TESTS::
- 
-diff --git a/src/sage/algebras/steenrod/steenrod_algebra.py b/src/sage/algebras/steenrod/steenrod_algebra.py
-index 978a3557a9d..7c4d444f81c 100644
---- a/src/sage/algebras/steenrod/steenrod_algebra.py
-+++ b/src/sage/algebras/steenrod/steenrod_algebra.py
-@@ -1080,7 +1080,7 @@ def homogeneous_component(self, n):
-             sage: a.antipode() # not defined
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'
-+            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'...
-             sage: A(a).antipode() # convert to elt of A, then compute antipode
-             Sq(2,1) + Sq(5)
- 
-diff --git a/src/sage/all__sagemath_repl.py b/src/sage/all__sagemath_repl.py
-index 8d0b43679ca..c31b206bcb8 100644
---- a/src/sage/all__sagemath_repl.py
-+++ b/src/sage/all__sagemath_repl.py
-@@ -79,6 +79,23 @@
-                         message=r"Use setlocale\(\), getencoding\(\) and getlocale\(\) instead",
-                         module='docutils.io')
- 
-+# triggered by dateutil 2.8.2 and sphinx 7.0.1 on Python 3.12
-+# see: https://github.com/dateutil/dateutil/pull/1285
-+# see: https://github.com/sphinx-doc/sphinx/pull/11468
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"datetime.datetime.utcfromtimestamp\(\) is deprecated",
-+                        module='dateutil.tz.tz|sphinx.(builders.gettext|util.i18n)')
-+
-+# triggered on Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"This process.* is multi-threaded, "
-+                                r"use of .*\(\) may lead to deadlocks in the child.")
-+
-+# pickling of itertools is deprecated in Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"Pickle, copy, and deepcopy support will be "
-+                                r"removed from itertools in Python 3.14.")
-+
- 
- from .all__sagemath_objects import *
- from .all__sagemath_environment import *
-diff --git a/src/sage/arith/long.pxd b/src/sage/arith/long.pxd
-index 0031a0ae337..3ea70cef571 100644
---- a/src/sage/arith/long.pxd
-+++ b/src/sage/arith/long.pxd
-@@ -19,6 +19,8 @@ from libc.limits cimport LONG_MIN, LONG_MAX
- from cpython.object cimport Py_SIZE
- from cpython.number cimport PyNumber_Index, PyIndex_Check
- from cpython.longintrepr cimport py_long, PyLong_SHIFT, digit
-+from sage.cpython.pycore_long cimport (
-+    ob_digit, _PyLong_IsNegative, _PyLong_DigitCount)
- 
- from sage.libs.gmp.mpz cimport mpz_fits_slong_p, mpz_get_si
- from sage.rings.integer_fake cimport is_Integer, Integer_AS_MPZ
-@@ -299,8 +301,11 @@ cdef inline bint integer_check_long_py(x, long* value, int* err):
-         return 0
- 
-     # x is a Python "int" (aka PyLongObject or py_long in cython)
--    cdef const digit* D = (<py_long>x).ob_digit
--    cdef Py_ssize_t size = Py_SIZE(x)
-+    cdef const digit* D = ob_digit(x)
-+    cdef Py_ssize_t size = _PyLong_DigitCount(x)
-+
-+    if _PyLong_IsNegative(x):
-+        size = -size
- 
-     # We assume PyLong_SHIFT <= BITS_IN_LONG <= 3 * PyLong_SHIFT.
-     # This is true in all the default configurations:
-diff --git a/src/sage/categories/category.py b/src/sage/categories/category.py
-index 57ef7f4184b..29bce8ee415 100644
---- a/src/sage/categories/category.py
-+++ b/src/sage/categories/category.py
-@@ -2129,7 +2129,7 @@ def _with_axioms(self, axioms):
-             sage: Semigroups().Inverse()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'
-+            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'...
-             sage: Semigroups()._with_axioms(["Inverse"])
-             Category of semigroups
- 
-diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py
-index 5227792e725..4775d4e5bf1 100644
---- a/src/sage/categories/category_with_axiom.py
-+++ b/src/sage/categories/category_with_axiom.py
-@@ -554,7 +554,7 @@ class from the base category class::
-     sage: Magmas.Unital.Associative
-     Traceback (most recent call last):
-     ...
--    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'
-+    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'...
- 
- The purpose of this section is to explain the design of the code
- layout and the rationale for this mismatch.
-@@ -769,7 +769,7 @@ def _(): return LazyImport('sage.categories.rngs', 'Rngs', at_startup=True)
-     sage: Semirings().NoZeroDivisors()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'
-+    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'...
- 
- Concretely, this is to be implemented by defining the new axiom in the
- (``SubcategoryMethods`` nested class of the) appropriate category with
-diff --git a/src/sage/categories/enumerated_sets.py b/src/sage/categories/enumerated_sets.py
-index a8bea53f907..b0ea05d0563 100644
---- a/src/sage/categories/enumerated_sets.py
-+++ b/src/sage/categories/enumerated_sets.py
-@@ -610,7 +610,7 @@ def _list_from_iterator(self):
-                 sage: (QQ^2).list()  # indirect test                                    # needs sage.modules
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'
-+                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'...
- 
-             Here we test that for an object that does not know whether it
-             is finite or not.  Calling ``x.list()`` simply tries to create
-@@ -622,11 +622,11 @@ def _list_from_iterator(self):
-                 sage: Q.is_finite()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'...
-                 sage: Q.list()   # indirect test
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'...
- 
-             Here is another example. We artificially create a version of
-             the ring of integers that does not know whether it is finite
-diff --git a/src/sage/categories/examples/sets_cat.py b/src/sage/categories/examples/sets_cat.py
-index e0853d63f94..fbadb9ca405 100644
---- a/src/sage/categories/examples/sets_cat.py
-+++ b/src/sage/categories/examples/sets_cat.py
-@@ -619,7 +619,7 @@ class PrimeNumbers_Facade(PrimeNumbers_Abstract):
-         sage: pf.next()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'...
- 
-     unlike in the other implementations::
- 
-diff --git a/src/sage/categories/homset.py b/src/sage/categories/homset.py
-index 22ba9d047fc..2a8b8aeedeb 100644
---- a/src/sage/categories/homset.py
-+++ b/src/sage/categories/homset.py
-@@ -632,7 +632,7 @@ def __init__(self, X, Y, category=None, base=None, check=True):
-             sage: H = MyHomset(X, Y, category=1, base = ZZ, check = False)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'...
-             sage: P.<t> = ZZ[]
-             sage: f = P.hom([1/2*t])
-             sage: f.parent().domain()
-diff --git a/src/sage/categories/modules_with_basis.py b/src/sage/categories/modules_with_basis.py
-index e97bf851388..c4933d0657f 100644
---- a/src/sage/categories/modules_with_basis.py
-+++ b/src/sage/categories/modules_with_basis.py
-@@ -2456,7 +2456,7 @@ def apply_multilinear_morphism(self, f, codomain=None):
-                     sage: tensor([a, b]).apply_multilinear_morphism(f)                  # needs sage.modules
-                     Traceback (most recent call last):
-                     ...
--                    AttributeError: 'int' object has no attribute 'parent'
-+                    AttributeError: 'int' object has no attribute 'parent'...
- 
-                 Here we consider an example where the codomain is a
-                 module with basis with a different base ring::
-diff --git a/src/sage/categories/monoids.py b/src/sage/categories/monoids.py
-index 38dd7248c9d..28474bd17b6 100644
---- a/src/sage/categories/monoids.py
-+++ b/src/sage/categories/monoids.py
-@@ -556,7 +556,7 @@ def algebra_generators(self):
-                     Traceback (most recent call last):
-                     ...
-                     AttributeError: 'IntegerModMonoid_with_category' object
--                    has no attribute 'monoid_generators'
-+                    has no attribute 'monoid_generators'...
-                     sage: Z12.semigroup_generators()
-                     Family (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
-                     sage: Z12.algebra(QQ).algebra_generators()                          # needs sage.modules
-diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py
-index 494e8154c80..ec5120e41e6 100644
---- a/src/sage/combinat/finite_state_machine.py
-+++ b/src/sage/combinat/finite_state_machine.py
-@@ -1835,7 +1835,7 @@ def __getstate__(self):
-             sage: T1.transitions
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'FSMState' object has no attribute 'transitions'
-+            AttributeError: 'FSMState' object has no attribute 'transitions'...
-             sage: A1 = loads(dumps(A))
-             sage: all(A.state(j) == A1.state(j) for j in [0, 1])
-             True
-diff --git a/src/sage/combinat/growth.py b/src/sage/combinat/growth.py
-index cf8d18c1764..766eea37917 100644
---- a/src/sage/combinat/growth.py
-+++ b/src/sage/combinat/growth.py
-@@ -371,7 +371,7 @@
-     sage: GrowthDiagram(RulePascal(), [3,1,2])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'RulePascal' object has no attribute 'forward_rule'
-+    AttributeError: 'RulePascal' object has no attribute 'forward_rule'...
- 
- We now re-implement the rule where we provide the dual graded graphs::
- 
-diff --git a/src/sage/combinat/integer_lists/lists.py b/src/sage/combinat/integer_lists/lists.py
-index 5143e5cb5e8..9117a6076f7 100644
---- a/src/sage/combinat/integer_lists/lists.py
-+++ b/src/sage/combinat/integer_lists/lists.py
-@@ -261,7 +261,7 @@ def __getattr__(self, name):
-             sage: L.foo
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'foo'
-+            AttributeError: 'NoneType' object has no attribute 'foo'...
-         """
-         return getattr(self.backend, name)
- 
-diff --git a/src/sage/combinat/posets/posets.py b/src/sage/combinat/posets/posets.py
-index c31597c72e9..c74bfc67cee 100644
---- a/src/sage/combinat/posets/posets.py
-+++ b/src/sage/combinat/posets/posets.py
-@@ -8825,7 +8825,7 @@ def is_induced_subposet(self, other):
-             sage: Poset().is_induced_subposet('junk')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'subposet'
-+            AttributeError: 'str' object has no attribute 'subposet'...
-         """
-         if (not self._is_facade or (isinstance(other, FinitePoset) and
-                                     not other._is_facade)):
-diff --git a/src/sage/cpython/atexit.pyx b/src/sage/cpython/atexit.pyx
-index 961aa348d0a..e5a82735137 100644
---- a/src/sage/cpython/atexit.pyx
-+++ b/src/sage/cpython/atexit.pyx
-@@ -154,6 +154,10 @@ cdef extern from *:
-     #undef _PyGC_FINALIZED
-     #include "internal/pycore_interp.h"
-     #include "internal/pycore_pystate.h"
-+    #if PY_VERSION_HEX >= 0x030c0000
-+    // struct atexit_callback was renamed in 3.12 to atexit_py_callback
-+    #define atexit_callback atexit_py_callback
-+    #endif
-     static atexit_callback ** _atexit_callbacks(PyObject *self) {
-         PyInterpreterState *interp = _PyInterpreterState_GET();
-         struct atexit_state state = interp->atexit;
-diff --git a/src/sage/cpython/debug.pyx b/src/sage/cpython/debug.pyx
-index 986abff2a99..cdaca3a4854 100644
---- a/src/sage/cpython/debug.pyx
-+++ b/src/sage/cpython/debug.pyx
-@@ -78,7 +78,7 @@ def getattr_debug(obj, name, default=_no_default):
- 
-     EXAMPLES::
- 
--        sage: _ = getattr_debug(list, "reverse")
-+        sage: _ = getattr_debug(list, "reverse")  # not tested - broken in python 3.12
-         getattr_debug(obj=<class 'list'>, name='reverse'):
-           type(obj) = <class 'type'>
-           object has __dict__ slot (<class 'dict'>)
-@@ -123,7 +123,7 @@ def getattr_debug(obj, name, default=_no_default):
-         sage: _ = getattr_debug(1, "foo")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'...
-         sage: _ = getattr_debug(1, "foo", "xyz")
-         getattr_debug(obj=1, name='foo'):
-           type(obj) = <class 'sage.rings.integer.Integer'>
-diff --git a/src/sage/cpython/dict_internal.h b/src/sage/cpython/dict_internal.h
-index 42a57bcb468..a5ee35bc198 100644
---- a/src/sage/cpython/dict_internal.h
-+++ b/src/sage/cpython/dict_internal.h
-@@ -169,6 +169,7 @@ dictkeys_set_index(PyDictKeysObject *keys, Py_ssize_t i, Py_ssize_t ix)
- #else   /* Python >= 3.11 */
- 
- #define Py_BUILD_CORE
-+#undef _PyGC_FINALIZED
- #include <internal/pycore_dict.h>
- 
- /************************************************************/
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 52afed49d64..1f49e5230c3 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -53,12 +53,12 @@ cdef class AttributeErrorMessage:
-         sage: 1.bla  #indirect doctest
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'...
-         sage: x = polygen(ZZ, 'x')
-         sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'...
- 
-     ::
- 
-@@ -144,7 +144,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(X, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: x = X()
-         sage: raw_getattr(x, "prop")
-         <property object at ...>
-@@ -173,7 +173,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(Y, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: y = Y()
-         sage: raw_getattr(y, "prop")
-         <property object at ...>
-@@ -278,7 +278,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     The integer ring is a parent, so, lazy attributes work::
- 
-@@ -289,7 +289,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(17, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     In general, descriptors are not yet well supported, because they
-     often do not accept to be cheated with the type of their instance::
-@@ -305,7 +305,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__weakref__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-     This was caught by :trac:`8296` for which we do a couple more tests::
- 
-@@ -314,7 +314,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: 1.__weakref__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-         sage: n = 1
-         sage: ip = get_ipython()                 # not tested: only works in interactive shell
-@@ -329,7 +329,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__call__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'...
- 
-     TESTS:
- 
-@@ -339,14 +339,14 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, type, "__name__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'...
- 
-     Non-strings as "name" are handled gracefully::
- 
-         sage: getattr_from_other_class(1, type, None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute None
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute None...
-     """
-     if not isinstance(cls, type):
-         raise TypeError(f"{cls!r} is not a type")
-diff --git a/src/sage/cpython/pycore_long.h b/src/sage/cpython/pycore_long.h
-new file mode 100644
-index 00000000000..ff1a73d097a
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.h
-@@ -0,0 +1,98 @@
-+#include "Python.h"
-+#include <stdbool.h>
-+
-+#if PY_VERSION_HEX >= 0x030C00A5
-+#define ob_digit(o)  (((PyLongObject*)o)->long_value.ob_digit)
-+#else
-+#define ob_digit(o)  (((PyLongObject*)o)->ob_digit)
-+#endif
-+
-+#if PY_VERSION_HEX >= 0x030C00A7
-+// taken from cpython:Include/internal/pycore_long.h @ 3.12
-+
-+/* Long value tag bits:
-+ * 0-1: Sign bits value = (1-sign), ie. negative=2, positive=0, zero=1.
-+ * 2: Reserved for immortality bit
-+ * 3+ Unsigned digit count
-+ */
-+#define SIGN_MASK 3
-+#define SIGN_ZERO 1
-+#define SIGN_NEGATIVE 2
-+#define NON_SIZE_BITS 3
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_ZERO;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_NEGATIVE;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    assert(PyLong_Check(op));
-+    return op->long_value.lv_tag >> NON_SIZE_BITS;
-+}
-+
-+#define TAG_FROM_SIGN_AND_SIZE(sign, size) ((1 - (sign)) | ((size) << NON_SIZE_BITS))
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+    assert(size >= 0);
-+    assert(-1 <= sign && sign <= 1);
-+    assert(sign != 0 || size == 0);
-+    op->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sign, (size_t)size);
-+}
-+
-+#else
-+// fallback for < 3.12
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) == 0;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) < 0;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) > 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    Py_ssize_t size = Py_SIZE(op);
-+    return size < 0 ? -size : size;
-+}
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION < 9)
-+// The function Py_SET_SIZE is defined starting with python 3.9.
-+    Py_SIZE(o) = size;
-+#else
-+    Py_SET_SIZE(op, sign < 0 ? -size : size);
-+#endif
-+}
-+
-+#endif
-diff --git a/src/sage/cpython/pycore_long.pxd b/src/sage/cpython/pycore_long.pxd
-new file mode 100644
-index 00000000000..41de637ff18
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.pxd
-@@ -0,0 +1,9 @@
-+from cpython.longintrepr cimport py_long, digit
-+
-+cdef extern from "pycore_long.h":
-+    digit* ob_digit(py_long o)
-+    bint _PyLong_IsZero(py_long o)
-+    bint _PyLong_IsNegative(py_long o)
-+    bint _PyLong_IsPositive(py_long o)
-+    Py_ssize_t _PyLong_DigitCount(py_long o)
-+    void _PyLong_SetSignAndDigitCount(py_long o, int sign, Py_ssize_t size)
-diff --git a/src/sage/crypto/classical.py b/src/sage/crypto/classical.py
-index 616dc861652..be899c781e5 100644
---- a/src/sage/crypto/classical.py
-+++ b/src/sage/crypto/classical.py
-@@ -494,7 +494,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: A.rank_by_chi_square("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_chi_square(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -703,7 +703,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: A.rank_by_squared_differences("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_squared_differences(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -2114,7 +2114,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: S.rank_by_chi_square("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_chi_square(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-@@ -2351,7 +2351,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: S.rank_by_squared_differences("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_squared_differences(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/crypto/mq/mpolynomialsystemgenerator.py b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-index 9028dab1d98..4416d9ef7f6 100644
---- a/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-+++ b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-@@ -156,7 +156,7 @@ def sbox(self):
-             sage: msg.sbox()
-             Traceback (most recent call last):
-             ...
--            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'
-+            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'...
-         """
-         return self._sbox
- 
-diff --git a/src/sage/data_structures/bitset.pyx b/src/sage/data_structures/bitset.pyx
-index 446062554c1..d9906b5edd2 100644
---- a/src/sage/data_structures/bitset.pyx
-+++ b/src/sage/data_structures/bitset.pyx
-@@ -967,7 +967,7 @@ cdef class FrozenBitset:
-             sage: None | FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute '_union'
-+            AttributeError: 'NoneType' object has no attribute '_union'...
-         """
-         return self._union(other)
- 
-@@ -1037,7 +1037,7 @@ cdef class FrozenBitset:
-             sage: None & FrozenBitset("101011")
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'intersection'
-+            AttributeError: 'NoneType' object has no attribute 'intersection'...
-         """
-         return self.intersection(other)
- 
-@@ -1106,7 +1106,7 @@ cdef class FrozenBitset:
-             sage: None - FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'difference'
-+            AttributeError: 'NoneType' object has no attribute 'difference'...
-         """
-         return self.difference(other)
- 
-@@ -1179,7 +1179,7 @@ cdef class FrozenBitset:
-             sage: None ^^ FrozenBitset('11111' * 10)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'
-+            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'...
-         """
-         return self.symmetric_difference(other)
- 
-diff --git a/src/sage/doctest/reporting.py b/src/sage/doctest/reporting.py
-index 361fea344c2..a3947c07e01 100644
---- a/src/sage/doctest/reporting.py
-+++ b/src/sage/doctest/reporting.py
-@@ -368,7 +368,7 @@ def report(self, source, timeout, return_code, results, output, pid=None):
-             sage: DTR.report(None, None, None, None, None)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'basename'
-+            AttributeError: 'NoneType' object has no attribute 'basename'...
- 
-         The only-errors mode does not output anything on success::
- 
-diff --git a/src/sage/dynamics/finite_dynamical_system.py b/src/sage/dynamics/finite_dynamical_system.py
-index e5fbf568b7e..4295070615a 100644
---- a/src/sage/dynamics/finite_dynamical_system.py
-+++ b/src/sage/dynamics/finite_dynamical_system.py
-@@ -240,7 +240,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-@@ -252,7 +252,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-diff --git a/src/sage/geometry/cone.py b/src/sage/geometry/cone.py
-index f0a8620011a..53f78a4b7b6 100644
---- a/src/sage/geometry/cone.py
-+++ b/src/sage/geometry/cone.py
-@@ -340,7 +340,7 @@ def Cone(rays, lattice=None, check=True, normalize=True):
-         sage: Cone([(1,0), (0,1)], check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     You can construct different "not" cones: not full-dimensional, not
-     strictly convex, not containing any rays::
-diff --git a/src/sage/geometry/fan.py b/src/sage/geometry/fan.py
-index 258544012fe..3aecc84a55b 100644
---- a/src/sage/geometry/fan.py
-+++ b/src/sage/geometry/fan.py
-@@ -443,7 +443,7 @@ def Fan(cones, rays=None, lattice=None, check=True, normalize=True,
-         sage: P2c = Fan(cones, rays, check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     Yet another way is to use functions :func:`FaceFan` and :func:`NormalFan`
-     to construct fans from :class:`lattice polytopes
-diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-index f0ac1e774a7..f03f0f832ff 100644
---- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-+++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-@@ -351,7 +351,7 @@ cdef class FaceIterator_base(SageObject):
-             sage: FaceIterator_base(2)  # indirect doctest
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'...
-         """
-         cdef int i
-         sig_free(self.structure.atom_rep)
-@@ -1945,7 +1945,8 @@ cdef inline int next_face_loop(iter_t structure) nogil except -1:
-         # The function is not supposed to be called,
-         # just prevent it from crashing.
-         # Actually raising an error here results in a bad branch prediction.
--        return -1
-+        # But return -1 results in a crash with python 3.12
-+        raise StopIteration
- 
-     # Getting ``[faces, n_faces, n_visited_all]`` according to dimension.
-     cdef face_list_t* faces = &structure.new_faces[structure.current_dimension]
-diff --git a/src/sage/geometry/toric_plotter.py b/src/sage/geometry/toric_plotter.py
-index 50b4008eb0f..950e3ba7ff8 100644
---- a/src/sage/geometry/toric_plotter.py
-+++ b/src/sage/geometry/toric_plotter.py
-@@ -706,7 +706,7 @@ def set_rays(self, generators):
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ToricPlotter' object has no attribute 'rays'
-+            AttributeError: 'ToricPlotter' object has no attribute 'rays'...
-             sage: tp.set_rays([(0,1)])
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Graphics object consisting of 2 graphics primitives
-diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
-index d0ec214bb3b..c8098ad578a 100644
---- a/src/sage/groups/matrix_gps/finitely_generated.py
-+++ b/src/sage/groups/matrix_gps/finitely_generated.py
-@@ -268,7 +268,7 @@ def MatrixGroup(*gens, **kwds):
-         sage: SL2C.gens()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'
-+        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'...
-     """
-     if isinstance(gens[-1], dict):   # hack for unpickling
-         kwds.update(gens[-1])
-diff --git a/src/sage/homology/chains.py b/src/sage/homology/chains.py
-index 87c0947c0b0..b9a54940943 100644
---- a/src/sage/homology/chains.py
-+++ b/src/sage/homology/chains.py
-@@ -298,7 +298,7 @@ def is_cycle(self):
-                 sage: chain.is_cocycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -325,7 +325,7 @@ def is_boundary(self):
-                 sage: chain.is_coboundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -539,7 +539,7 @@ def is_cocycle(self):
-                 sage: cochain.is_cycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -566,7 +566,7 @@ def is_coboundary(self):
-                 sage: cochain.is_boundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -604,7 +604,7 @@ def eval(self, other):
-                 sage: z.eval(c) # z is not a cochain
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'...
-                 sage: c.eval(c) # can't evaluate a cochain on a cochain
-                 Traceback (most recent call last):
-                 ...
-diff --git a/src/sage/homology/free_resolution.py b/src/sage/homology/free_resolution.py
-index e3d38de4240..280a479b438 100644
---- a/src/sage/homology/free_resolution.py
-+++ b/src/sage/homology/free_resolution.py
-@@ -275,7 +275,7 @@ def differential(self, i):
-             sage: FreeResolution.differiental(r, 1)
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'FreeResolution' has no attribute 'differiental'
-+            AttributeError: type object 'FreeResolution' has no attribute 'differiental'...
-         """
- 
-     def target(self):
-diff --git a/src/sage/interfaces/magma.py b/src/sage/interfaces/magma.py
-index b7a0ac20d03..529bfbc349b 100644
---- a/src/sage/interfaces/magma.py
-+++ b/src/sage/interfaces/magma.py
-@@ -824,7 +824,7 @@ def _coerce_from_special_method(self, x):
-             sage: magma._coerce_from_special_method('2 + 3')  # optional - magma
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute '_magma_init_'
-+            AttributeError: 'str' object has no attribute '_magma_init_'...
-         """
-         s = x._magma_init_(self)
-         a = self(s)
-diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
-index 58499396d6c..16119d20815 100644
---- a/src/sage/lfunctions/dokchitser.py
-+++ b/src/sage/lfunctions/dokchitser.py
-@@ -418,8 +418,8 @@ def init_coeffs(self, v, cutoff=1,
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
-index bbf289aa21c..e4968866303 100644
---- a/src/sage/lfunctions/pari.py
-+++ b/src/sage/lfunctions/pari.py
-@@ -141,8 +141,8 @@ def init_coeffs(self, v, cutoff=None, w=1):
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
-index 478caf9f9d0..363024ae281 100644
---- a/src/sage/libs/gap/element.pyx
-+++ b/src/sage/libs/gap/element.pyx
-@@ -380,7 +380,7 @@ cdef GapElement make_GapElement(parent, Obj obj):
-         sage: libgap(None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute '_libgap_init_'
-+        AttributeError: 'NoneType' object has no attribute '_libgap_init_'...
-     """
-     cdef GapElement r = GapElement.__new__(GapElement)
-     r._initialize(parent, obj)
-diff --git a/src/sage/libs/gmp/pylong.pxd b/src/sage/libs/gmp/pylong.pxd
-index a73f1da6d6f..84e1bb8cd87 100644
---- a/src/sage/libs/gmp/pylong.pxd
-+++ b/src/sage/libs/gmp/pylong.pxd
-@@ -2,9 +2,10 @@
- Various functions to deal with conversion mpz <-> Python int/long
- """
- 
-+from cpython.longintrepr cimport py_long
- from sage.libs.gmp.types cimport *
- 
- cdef mpz_get_pylong(mpz_srcptr z)
- cdef mpz_get_pyintlong(mpz_srcptr z)
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1
- cdef Py_hash_t mpz_pythonhash(mpz_srcptr z)
-diff --git a/src/sage/libs/gmp/pylong.pyx b/src/sage/libs/gmp/pylong.pyx
-index d5993cca5a5..1a36c29d3fa 100644
---- a/src/sage/libs/gmp/pylong.pyx
-+++ b/src/sage/libs/gmp/pylong.pyx
-@@ -28,6 +28,8 @@ AUTHORS:
- from cpython.object cimport Py_SIZE
- from cpython.long cimport PyLong_FromLong
- from cpython.longintrepr cimport _PyLong_New, py_long, digit, PyLong_SHIFT
-+from sage.cpython.pycore_long cimport (ob_digit, _PyLong_IsNegative,
-+    _PyLong_DigitCount, _PyLong_SetSignAndDigitCount)
- from .mpz cimport *
- 
- cdef extern from *:
-@@ -60,12 +62,9 @@ cdef mpz_get_pylong_large(mpz_srcptr z):
-     """
-     cdef size_t nbits = mpz_sizeinbase(z, 2)
-     cdef size_t pylong_size = (nbits + PyLong_SHIFT - 1) // PyLong_SHIFT
--    L = _PyLong_New(pylong_size)
--    mpz_export(L.ob_digit, NULL,
--            -1, sizeof(digit), 0, PyLong_nails, z)
--    if mpz_sgn(z) < 0:
--        # Set correct size
--        Py_SET_SIZE(L, -pylong_size)
-+    cdef py_long L = _PyLong_New(pylong_size)
-+    mpz_export(ob_digit(L), NULL, -1, sizeof(digit), 0, PyLong_nails, z)
-+    _PyLong_SetSignAndDigitCount(L, mpz_sgn(z), pylong_size)
-     return L
- 
- 
-@@ -88,16 +87,13 @@ cdef mpz_get_pyintlong(mpz_srcptr z):
-     return mpz_get_pylong_large(z)
- 
- 
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1:
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1:
-     """
-     Convert a Python ``long`` `L` to an ``mpz``.
-     """
--    cdef Py_ssize_t pylong_size = Py_SIZE(L)
--    if pylong_size < 0:
--        pylong_size = -pylong_size
--    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails,
--            (<py_long>L).ob_digit)
--    if Py_SIZE(L) < 0:
-+    cdef Py_ssize_t pylong_size = _PyLong_DigitCount(L)
-+    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails, ob_digit(L))
-+    if _PyLong_IsNegative(L):
-         mpz_neg(z, z)
- 
- 
-diff --git a/src/sage/manifolds/calculus_method.py b/src/sage/manifolds/calculus_method.py
-index f5830c0bc45..303dde6cd13 100644
---- a/src/sage/manifolds/calculus_method.py
-+++ b/src/sage/manifolds/calculus_method.py
-@@ -257,7 +257,7 @@ def simplify(self, expression, method=None):
-             sage: cm.simplify(f)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'
-+            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'...
- 
-         In the present case, one should either transform ``f`` to a SymPy
-         object::
-diff --git a/src/sage/manifolds/differentiable/vectorfield_module.py b/src/sage/manifolds/differentiable/vectorfield_module.py
-index d954b5d4839..af4bfb0ceec 100644
---- a/src/sage/manifolds/differentiable/vectorfield_module.py
-+++ b/src/sage/manifolds/differentiable/vectorfield_module.py
-@@ -885,7 +885,7 @@ def tensor(self, *args, **kwds):
-             sage: XM.tensor(XM).tensor(XM.dual().tensor(XM.dual()))
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'
-+            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'...
- 
-         .. SEEALSO::
- 
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 86aca6e00d8..a5f6716e731 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15303,7 +15303,7 @@ cdef class Matrix(Matrix1):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
--            has no attribute 'conjugate'
-+            has no attribute 'conjugate'...
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/matrix/matrix_cyclo_dense.pyx b/src/sage/matrix/matrix_cyclo_dense.pyx
-index f54f3423ded..a49bb6240e6 100644
---- a/src/sage/matrix/matrix_cyclo_dense.pyx
-+++ b/src/sage/matrix/matrix_cyclo_dense.pyx
-@@ -847,7 +847,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense):
-             sage: A.set_mutable()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'
-+            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'...
-             sage: B = A.__copy__()
-             sage: B[0,0] = 20
-             sage: B[0,0]
-diff --git a/src/sage/matrix/matrix_gfpn_dense.pyx b/src/sage/matrix/matrix_gfpn_dense.pyx
-index 4cccf473de1..8e8e4d7336b 100644
---- a/src/sage/matrix/matrix_gfpn_dense.pyx
-+++ b/src/sage/matrix/matrix_gfpn_dense.pyx
-@@ -159,7 +159,7 @@ cdef class FieldConverter_class:
-             sage: C.field_to_fel('foo')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'to_integer'
-+            AttributeError: 'str' object has no attribute 'to_integer'...
-         """
-         return FfFromInt(x.to_integer())
- 
-diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py
-index 6aab58352be..b5e6f52349b 100644
---- a/src/sage/matrix/matrix_space.py
-+++ b/src/sage/matrix/matrix_space.py
-@@ -1619,7 +1619,7 @@ def __getitem__(self, x):
-             sage: MS[2]
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'
-+            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'...
-         """
-         if isinstance(x, (integer.Integer, int)):
-             return self.list()[x]
-diff --git a/src/sage/matroids/lean_matrix.pyx b/src/sage/matroids/lean_matrix.pyx
-index 54c68e637c0..a137cbf70e5 100644
---- a/src/sage/matroids/lean_matrix.pyx
-+++ b/src/sage/matroids/lean_matrix.pyx
-@@ -1,5 +1,4 @@
- # sage.doctest: optional - sage.rings.finite_rings
--# cython: profile=True
- """
- Lean matrices
- 
-diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx
-index 36f563aa433..318c82f2b64 100644
---- a/src/sage/matroids/linear_matroid.pyx
-+++ b/src/sage/matroids/linear_matroid.pyx
-@@ -1134,7 +1134,7 @@ cdef class LinearMatroid(BasisExchangeMatroid):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.matroids.basis_matroid.BasisMatroid' object
--            has no attribute 'base_ring'
-+            has no attribute 'base_ring'...
-             sage: from sage.matroids.advanced import *
-             sage: M4 = BinaryMatroid(Matrix(M1))
-             sage: M5 = LinearMatroid(reduced_matrix=Matrix(GF(2), [[-1, 0, 1],
-diff --git a/src/sage/misc/dev_tools.py b/src/sage/misc/dev_tools.py
-index e7bf176592c..3ece7db2894 100644
---- a/src/sage/misc/dev_tools.py
-+++ b/src/sage/misc/dev_tools.py
-@@ -171,6 +171,7 @@ def load_submodules(module=None, exclude_pattern=None):
-         load sage.geometry.polyhedron.ppl_lattice_polygon... succeeded
-     """
-     from .package_dir import walk_packages
-+    import importlib.util
- 
-     if module is None:
-         import sage
-@@ -194,8 +195,12 @@ def load_submodules(module=None, exclude_pattern=None):
-         try:
-             sys.stdout.write("load %s..." % module_name)
-             sys.stdout.flush()
--            loader = importer.find_module(module_name)
--            loader.load_module(module_name)
-+            # see
-+            # https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
-+            spec = importer.find_spec(module_name)
-+            module = importlib.util.module_from_spec(spec)
-+            sys.modules[module_name] = module
-+            spec.loader.exec_module(module)
-             sys.stdout.write(" succeeded\n")
-         except (ValueError, AttributeError, TypeError, ImportError):
-             # we might get error because of cython code that has been
-diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py
-index c922b8f6f12..03697f08b7c 100644
---- a/src/sage/misc/functional.py
-+++ b/src/sage/misc/functional.py
-@@ -86,7 +86,7 @@ def base_field(x):
-         sage: R.base_field()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'
-+        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'...
-     """
-     try:
-         return x.base_field()
-diff --git a/src/sage/misc/instancedoc.pyx b/src/sage/misc/instancedoc.pyx
-index d8e1e4ac536..44ee70f64ba 100644
---- a/src/sage/misc/instancedoc.pyx
-+++ b/src/sage/misc/instancedoc.pyx
-@@ -256,7 +256,7 @@ cdef class InstanceDocDescriptor:
-             sage: descr.__delete__(obj)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'X' object has no attribute '__doc__'
-+            AttributeError: 'X' object has no attribute '__doc__'...
- 
-             sage: descr.__delete__([])
-             Traceback (most recent call last):
-diff --git a/src/sage/misc/lazy_attribute.pyx b/src/sage/misc/lazy_attribute.pyx
-index bdbec3b3ba1..1f07870b8ec 100644
---- a/src/sage/misc/lazy_attribute.pyx
-+++ b/src/sage/misc/lazy_attribute.pyx
-@@ -441,37 +441,37 @@ class lazy_attribute(_lazy_attribute):
-             sage: B().unimplemented_A # todo: not implemented
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'super' object has no attribute 'unimplemented_A'
-+            AttributeError: 'super' object has no attribute 'unimplemented_A'...
- 
-     We now make some systematic checks::
- 
-         sage: B().unimplemented_A
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: B().unimplemented_B
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: B().unimplemented_AB
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: B().unimplemented_B_implemented_A
-         1
- 
-         sage: C().unimplemented_A()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: C().unimplemented_B()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: C().unimplemented_AB()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: C().unimplemented_B_implemented_A # todo: not implemented
-         1
-     """
-diff --git a/src/sage/misc/object_multiplexer.py b/src/sage/misc/object_multiplexer.py
-index d4e811ef16e..00fd89d6652 100644
---- a/src/sage/misc/object_multiplexer.py
-+++ b/src/sage/misc/object_multiplexer.py
-@@ -85,7 +85,7 @@ def __getattr__(self, name):
-             sage: m.__bork__
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Multiplex' has no attribute '__bork__'
-+            AttributeError: 'Multiplex' has no attribute '__bork__'...
-         """
-         if name.startswith("__"):
-             raise AttributeError("'Multiplex' has no attribute '%s'" % name)
-diff --git a/src/sage/misc/sage_input.py b/src/sage/misc/sage_input.py
-index 66e78ecccbc..00e8d96ee9e 100644
---- a/src/sage/misc/sage_input.py
-+++ b/src/sage/misc/sage_input.py
-@@ -3461,7 +3461,7 @@ def verify_same(a, b):
-         sage: verify_same(1, 1r)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_same(1r, 1)
-         Traceback (most recent call last):
-         ...
-@@ -3525,7 +3525,7 @@ def verify_si_answer(x, answer, preparse):
-         sage: verify_si_answer(1, '1', False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_si_answer(1, 'ZZ(1)', None)
-     """
-     from sage.misc.sage_eval import sage_eval
-diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py
-index f0545be7d81..811afc48755 100644
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -602,7 +602,7 @@ def visit_Num(self, node):
-             On Python 3 negative numbers are parsed first, for some reason, as
-             a UnaryOp node.
-         """
--        return node.n
-+        return node.value
- 
-     def visit_Str(self, node):
-         r"""
-@@ -624,7 +624,7 @@ def visit_Str(self, node):
-             sage: [vis(s) for s in ['"abstract"', "'syntax'", r'''r"tr\ee"''']]
-             ['abstract', 'syntax', 'tr\\ee']
-         """
--        return node.s
-+        return node.value
- 
-     def visit_List(self, node):
-         """
-diff --git a/src/sage/modules/fp_graded/steenrod/module.py b/src/sage/modules/fp_graded/steenrod/module.py
-index 18460b0e9a1..4acfa6b4002 100755
---- a/src/sage/modules/fp_graded/steenrod/module.py
-+++ b/src/sage/modules/fp_graded/steenrod/module.py
-@@ -70,7 +70,7 @@
-     sage: SteenrodFPModule(ZZ, [0])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'
-+    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'...
- 
- AUTHORS:
- 
-diff --git a/src/sage/monoids/trace_monoid.py b/src/sage/monoids/trace_monoid.py
-index 00baa4d14f8..f8176a1e1f2 100644
---- a/src/sage/monoids/trace_monoid.py
-+++ b/src/sage/monoids/trace_monoid.py
-@@ -40,7 +40,6 @@
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from collections import OrderedDict
- from itertools import repeat, chain, product
- 
- from sage.misc.cachefunc import cached_method
-@@ -633,14 +632,14 @@ def _compute_dependence_stack(self, x):
-             sage: x = b*a*d*a*c*b
-             sage: M._compute_dependence_stack(x)
-             ({a, b, c, d},
--             OrderedDict([(a, [False, False, True, True, False]),
--                          (b, [True, False, False, False, True]),
--                          (c, [True, False, False, False]),
--                          (d, [False, False, True, False])]))
-+             {a: [False, False, True, True, False],
-+              b: [True, False, False, False, True],
-+              c: [True, False, False, False],
-+              d: [False, False, True, False]})
-         """
-         independence = self._independence
-         generators_set = set(e for e, _ in x)
--        stacks = OrderedDict(sorted((g, []) for g in generators_set))
-+        stacks = dict(sorted((g, []) for g in generators_set))
-         for generator, times in reversed(list(x)):
-             stacks[generator].extend(repeat(True, times))
-             for other_gen in generators_set:
-diff --git a/src/sage/parallel/map_reduce.py b/src/sage/parallel/map_reduce.py
-index 11e0673ee91..5441943731d 100644
---- a/src/sage/parallel/map_reduce.py
-+++ b/src/sage/parallel/map_reduce.py
-@@ -1234,7 +1234,7 @@ def finish(self):
-             sage: S.print_communication_statistics()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'RESetMPExample' object has no attribute '_stats'
-+            AttributeError: 'RESetMPExample' object has no attribute '_stats'...
- 
-             sage: S.finish()
- 
-diff --git a/src/sage/plot/colors.py b/src/sage/plot/colors.py
-index 8c0db2b3c34..3281199400b 100644
---- a/src/sage/plot/colors.py
-+++ b/src/sage/plot/colors.py
-@@ -1099,7 +1099,7 @@ def __getattr__(self, name):
-             sage: cols.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ColorsDict' has no attribute or colormap punk
-+            AttributeError: 'ColorsDict' has no attribute or colormap punk...
-         """
-         try:
-             return self[name]
-@@ -1599,7 +1599,7 @@ def __getattr__(self, name):
-             sage: maps.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Colormaps' has no attribute or colormap punk
-+            AttributeError: 'Colormaps' has no attribute or colormap punk...
-             sage: maps['punk']
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/rings/asymptotic/asymptotic_ring.py b/src/sage/rings/asymptotic/asymptotic_ring.py
-index b07319382d3..994490e6616 100644
---- a/src/sage/rings/asymptotic/asymptotic_ring.py
-+++ b/src/sage/rings/asymptotic/asymptotic_ring.py
-@@ -1091,7 +1091,7 @@ def monomial_coefficient(self, monomial):
-             sage: O(n).monomial_coefficient(n)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'
-+            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'...
- 
-         The ``monomial`` must be exact::
- 
-diff --git a/src/sage/rings/asymptotic/growth_group.py b/src/sage/rings/asymptotic/growth_group.py
-index 27c14592bca..5be12537d62 100644
---- a/src/sage/rings/asymptotic/growth_group.py
-+++ b/src/sage/rings/asymptotic/growth_group.py
-@@ -1572,7 +1572,7 @@ def variable_names(self):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'GenericGrowthGroup_with_category.element_class' object
--            has no attribute 'is_one'
-+            has no attribute 'is_one'...
-         """
-         if self.is_one():
-             return tuple()
-diff --git a/src/sage/rings/ideal.py b/src/sage/rings/ideal.py
-index d36d9406f32..01c9fa3bf2d 100644
---- a/src/sage/rings/ideal.py
-+++ b/src/sage/rings/ideal.py
-@@ -1553,7 +1553,7 @@ def gcd(self, other):
-             sage: J.gcd(I)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Ideal_generic' object has no attribute 'gcd'
-+            AttributeError: 'Ideal_generic' object has no attribute 'gcd'...
- 
-         Note::
- 
-diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
-index 7fe89197011..8832d27e8ea 100644
---- a/src/sage/rings/number_field/number_field.py
-+++ b/src/sage/rings/number_field/number_field.py
-@@ -3823,7 +3823,7 @@ def primes_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
-         """
-         if degree is not None:
-             degree = ZZ(degree)
-@@ -3917,7 +3917,7 @@ def prime_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
- 
-         """
-         ids = self.primes_above(x, degree)
-@@ -5926,7 +5926,7 @@ def factor(self, n):
-             sage: L.factor(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'...
- 
-         AUTHORS:
- 
-@@ -12698,7 +12698,7 @@ def is_real_place(v):
-         sage: is_real_place(v_fin)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'
-+        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'...
- 
-     """
-     RR = sage.rings.real_mpfr.RealField(53)
-diff --git a/src/sage/rings/padics/generic_nodes.py b/src/sage/rings/padics/generic_nodes.py
-index 7047020edec..b6b514d4005 100644
---- a/src/sage/rings/padics/generic_nodes.py
-+++ b/src/sage/rings/padics/generic_nodes.py
-@@ -740,7 +740,7 @@ def _get_element_class(self, name=None):
-             sage: R._get_element_class("foobar")
-             Traceback (most recent call last):
-             ...
--            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'
-+            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'...
-         """
-         if name is None:
-             return self.Element
-diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx
-index c5a1129aecf..a5b7f937cfe 100644
---- a/src/sage/rings/polynomial/polynomial_element.pyx
-+++ b/src/sage/rings/polynomial/polynomial_element.pyx
-@@ -10793,7 +10793,7 @@ cdef class Polynomial(CommutativePolynomial):
-             sage: (y**2 + x).nth_root(2)
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... has no attribute 'nth_root'
-+            AttributeError: ... has no attribute 'nth_root'...
- 
-         TESTS::
- 
-@@ -11831,7 +11831,7 @@ cdef class Polynomial_generic_dense(Polynomial):
-             sage: int(1) // x  # check that this doesn't segfault
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'int' has no attribute 'base_ring'
-+            AttributeError: type object 'int' has no attribute 'base_ring'...
-         """
-         if have_same_parent(self, right):
-             return (<Polynomial_generic_dense>self)._floordiv_(<Polynomial_generic_dense>right)
-diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-index e372be888ee..aca4f08420f 100644
---- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
-+++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-@@ -2362,7 +2362,7 @@ def field_extension(self, names):
-             sage: F, g, h = S.field_extension('b')                                      # needs sage.rings.finite_rings
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'
-+            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'...
- 
-         Over a finite field, the corresponding field extension is not a
-         number field::
-diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx
-index 5273891a5b0..a6e999b8805 100644
---- a/src/sage/rings/ring.pyx
-+++ b/src/sage/rings/ring.pyx
-@@ -1734,7 +1734,7 @@ cdef class IntegralDomain(CommutativeRing):
-             sage: Z5.is_integrally_closed()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'
-+            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'...
-         """
-         raise NotImplementedError
- 
-diff --git a/src/sage/sat/solvers/satsolver.pyx b/src/sage/sat/solvers/satsolver.pyx
-index c2f41b18f55..1c4ac400cb6 100644
---- a/src/sage/sat/solvers/satsolver.pyx
-+++ b/src/sage/sat/solvers/satsolver.pyx
-@@ -375,10 +375,10 @@ def SAT(solver=None, *args, **kwds):
-         DIMACS Solver: 'kissat -q {input}'
-     """
-     if solver is None:
--        import pkgutil
--        if pkgutil.find_loader('pycryptosat') is not None:
-+        from importlib.util import find_spec
-+        if find_spec('pycryptosat') is not None:
-             solver = "cryptominisat"
--        elif pkgutil.find_loader('pycosat') is not None:
-+        elif find_spec('pycosat') is not None:
-             solver = "picosat"
-         else:
-             solver = "LP"
-diff --git a/src/sage/schemes/toric/morphism.py b/src/sage/schemes/toric/morphism.py
-index 1c8944b6dfc..5d64d632f97 100644
---- a/src/sage/schemes/toric/morphism.py
-+++ b/src/sage/schemes/toric/morphism.py
-@@ -246,7 +246,7 @@
-     Traceback (most recent call last):
-     ...
-     AttributeError: 'SchemeMorphism_fan_toric_variety' object
--    has no attribute 'fiber_generic'
-+    has no attribute 'fiber_generic'...
- 
- Let's use factorization mentioned above::
- 
-diff --git a/src/sage/sets/disjoint_union_enumerated_sets.py b/src/sage/sets/disjoint_union_enumerated_sets.py
-index 3dea567a779..5c5e08612f2 100644
---- a/src/sage/sets/disjoint_union_enumerated_sets.py
-+++ b/src/sage/sets/disjoint_union_enumerated_sets.py
-@@ -597,7 +597,7 @@ def Element(self):
-             sage: U.Element
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'
-+            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'...
-         """
-         if not self._facade:
-             return ElementWrapper
-diff --git a/src/sage/sets/set.py b/src/sage/sets/set.py
-index a1789c61300..112d3d8dc3b 100644
---- a/src/sage/sets/set.py
-+++ b/src/sage/sets/set.py
-@@ -163,7 +163,7 @@ def Set(X=None, category=None):
-         sage: sorted(B.list(), key=repr)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'Set_object_with_category' object has no attribute 'list'
-+        AttributeError: 'Set_object_with_category' object has no attribute 'list'...
-         sage: type(B)
-         <class 'sage.sets.set.Set_object_with_category'>
- 
-diff --git a/src/sage/structure/category_object.pyx b/src/sage/structure/category_object.pyx
-index b6a7eaecb5b..c06933494dc 100644
---- a/src/sage/structure/category_object.pyx
-+++ b/src/sage/structure/category_object.pyx
-@@ -836,7 +836,7 @@ cdef class CategoryObject(SageObject):
-             sage: Sets().example().sadfasdf
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'
-+            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'...
-         """
-         return self.getattr_from_category(name)
- 
-diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx
-index caae7e40ffc..543506e9a74 100644
---- a/src/sage/structure/element.pyx
-+++ b/src/sage/structure/element.pyx
-@@ -219,7 +219,7 @@ the parents::
-     sage: x._add_(x)
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-     sage: x + x
-     Traceback (most recent call last):
-     ...
-@@ -478,13 +478,13 @@ cdef class Element(SageObject):
-             sage: 1.blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'...
-             sage: Semigroups().example().an_element().is_idempotent
-             <bound method LeftZeroSemigroup.Element.is_idempotent of 42>
-             sage: Semigroups().example().an_element().blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'
-+            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'...
-         """
-         return self.getattr_from_category(name)
- 
-@@ -1269,7 +1269,7 @@ cdef class Element(SageObject):
-             sage: e._add_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-         """
-         try:
-             python_op = (<object>self)._add_
-@@ -1381,7 +1381,7 @@ cdef class Element(SageObject):
-             sage: e._sub_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'...
-         """
-         try:
-             python_op = (<object>self)._sub_
-@@ -1435,7 +1435,7 @@ cdef class Element(SageObject):
-             sage: e._neg_()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'...
-         """
-         try:
-             python_op = (<object>self)._neg_
-@@ -1549,7 +1549,7 @@ cdef class Element(SageObject):
-             sage: e._mul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'...
-         """
-         try:
-             python_op = (<object>self)._mul_
-@@ -1662,7 +1662,7 @@ cdef class Element(SageObject):
-             sage: e._matmul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'...
-         """
-         try:
-             python_op = (<object>self)._matmul_
-@@ -1765,7 +1765,7 @@ cdef class Element(SageObject):
-             sage: e._div_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'...
-         """
-         try:
-             python_op = (<object>self)._div_
-@@ -1865,7 +1865,7 @@ cdef class Element(SageObject):
-             sage: e._floordiv_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'...
-         """
-         try:
-             python_op = (<object>self)._floordiv_
-@@ -1965,7 +1965,7 @@ cdef class Element(SageObject):
-             sage: e._mod_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'...
-         """
-         try:
-             python_op = (<object>self)._mod_
-@@ -2092,7 +2092,7 @@ cdef class Element(SageObject):
-             sage: e._pow_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'...
-         """
-         try:
-             python_op = (<object>self)._pow_
-@@ -2122,7 +2122,7 @@ cdef class Element(SageObject):
-             sage: e._pow_int(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'...
-         """
-         try:
-             python_op = (<object>self)._pow_int
-@@ -2856,7 +2856,7 @@ cdef class RingElement(ModuleElement):
-             sage: m.is_nilpotent()                                                      # needs sage.modules
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... object has no attribute 'is_nilpotent'
-+            AttributeError: '...' object has no attribute 'is_nilpotent'...
-         """
-         if self.is_unit():
-             return False
-@@ -4671,7 +4671,7 @@ def coerce_binop(method):
-         sage: x.test_add(CC(2))
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'
-+        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'...
- 
-     TESTS:
- 
-diff --git a/src/sage/structure/sequence.py b/src/sage/structure/sequence.py
-index 0c700c1fb81..c3972532ac3 100644
---- a/src/sage/structure/sequence.py
-+++ b/src/sage/structure/sequence.py
-@@ -854,7 +854,7 @@ def __getattr__(self, name):
-             sage: S.universe()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'...
-             sage: S._Sequence__universe = 'foobar'
-             sage: S.universe()
-             'foobar'
-@@ -867,7 +867,7 @@ def __getattr__(self, name):
-             sage: hash(S)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'...
-             sage: S._Sequence__hash = int(34)
-             sage: hash(S)
-             34
-diff --git a/src/sage/symbolic/assumptions.py b/src/sage/symbolic/assumptions.py
-index 7dcb15f0d85..15f6fa07ce6 100644
---- a/src/sage/symbolic/assumptions.py
-+++ b/src/sage/symbolic/assumptions.py
-@@ -636,7 +636,7 @@ def assume(*args):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no
--        attribute 'assume'
-+        attribute 'assume'...
- 
-     Ensure that we can combine the two types of assumptions, as documented::
- 
-diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx
-index 0f251ac4e5c..66f624141b3 100644
---- a/src/sage/symbolic/expression.pyx
-+++ b/src/sage/symbolic/expression.pyx
-@@ -13712,7 +13712,7 @@ cdef get_dynamic_class_for_function(unsigned serial):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.symbolic.expression.Expression' object has no
--        attribute 'argp1'
-+        attribute 'argp1'...
-         sage: t = (e + 1).op[0]; t
-         tfunc(x)
-         sage: t
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index c4152e092e3..4bcf45e8793 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -67,6 +67,7 @@
- #include "archive.h"
- #include "tostring.h"
- #include "utils.h"
-+#include "../../cpython/pycore_long.h"
- 
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wdeprecated-register"
-@@ -706,18 +707,12 @@ static long _mpq_pythonhash(mpq_t the_rat)
- // Initialize an mpz_t from a Python long integer
- static void _mpz_set_pylong(mpz_t z, PyLongObject* l)
- {
--    Py_ssize_t pylong_size = Py_SIZE(l);
--    int sign = 1;
--
--    if (pylong_size < 0) {
--        pylong_size = -pylong_size;
--        sign = -1;
--    }
-+    Py_ssize_t pylong_size = _PyLong_DigitCount(l);
- 
-     mpz_import(z, pylong_size, -1, sizeof(digit), 0,
--               8*sizeof(digit) - PyLong_SHIFT, l->ob_digit);
-+               8*sizeof(digit) - PyLong_SHIFT, ob_digit(l));
- 
--    if (sign < 0)
-+    if (_PyLong_IsNegative(l))
-         mpz_neg(z, z);
- }
- 
-diff --git a/src/sage/symbolic/pynac_impl.pxi b/src/sage/symbolic/pynac_impl.pxi
-index 68c31dcfde7..7fd7c3b314b 100644
---- a/src/sage/symbolic/pynac_impl.pxi
-+++ b/src/sage/symbolic/pynac_impl.pxi
-@@ -619,7 +619,7 @@ def tolerant_is_symbol(a):
-         sage: None.is_symbol()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute 'is_symbol'
-+        AttributeError: 'NoneType' object has no attribute 'is_symbol'...
-     """
-     try:
-         return a.is_symbol()
diff --git a/srcpkgs/sagemath/patches/36769-fix_jmol_detect.patch b/srcpkgs/sagemath/patches/36769-fix_jmol_detect.patch
new file mode 100644
index 0000000000000..a0ac15abef601
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36769-fix_jmol_detect.patch
@@ -0,0 +1,97 @@
+diff --git a/src/sage/interfaces/jmoldata.py b/src/sage/interfaces/jmoldata.py
+index a68e53e2d85..d5c9dfc5456 100644
+--- a/src/sage/interfaces/jmoldata.py
++++ b/src/sage/interfaces/jmoldata.py
+@@ -71,6 +71,52 @@ def is_jvm_available(self):
+         java_version_number = int(re.sub(r'.*version "(0\.|1\.)?(\d*)[\s\S]*', r'\2', version, flags=re.S))
+         return java_version_number >= 7
+ 
++    def jmolpath(self):
++        """
++        Return the path to the jar file.
++
++        EXAMPLES::
++
++            sage: from sage.interfaces.jmoldata import JmolData
++            sage: JData = JmolData()
++            sage: JData.jmolpath()
++            '.../JmolData.jar'
++
++        """
++        jmolpath = os.path.join(JMOL_DIR, "JmolData.jar")
++
++        if sys.platform == 'cygwin':
++            import cygwin
++            jmolpath = cygwin.cygpath(jmolpath, 'w')
++
++        return jmolpath
++
++    def is_jmol_available(self):
++        """
++        Returns True if jmol is available and False if not.
++
++        EXAMPLES:
++
++        Check that it returns a boolean::
++
++            sage: from sage.interfaces.jmoldata import JmolData
++            sage: JData = JmolData()
++            sage: type(JData.is_jmol_available())
++            <... 'bool'>
++        """
++        if not os.path.isfile(self.jmolpath()):
++            return False
++
++        if not self.is_jvm_available():
++            return False
++
++        try:
++            subprocess.check_call(['java', '-jar', self.jmolpath(), '-i'])
++        except (subprocess.CalledProcessError, OSError):
++            return False
++
++        return True
++
+     def export_image(self,
+         targetfile,
+         datafile, #name (path) of data file Jmol can read or script file telling it what to read or load
+@@ -154,12 +200,11 @@ def export_image(self,
+             sage: archive.close()
+         """
+         # Set up paths, file names and scripts
+-        jmolpath = os.path.join(JMOL_DIR, "JmolData.jar")
++        jmolpath = self.jmolpath()
+         target_native = targetfile
+ 
+         if sys.platform == 'cygwin':
+             import cygwin
+-            jmolpath = cygwin.cygpath(jmolpath, 'w')
+             target_native = cygwin.cygpath(target_native, 'w')
+             if datafile_cmd != 'script':
+                 datafile = cygwin.cygpath(datafile, 'w')
+diff --git a/src/sage/plot/plot3d/base.pyx b/src/sage/plot/plot3d/base.pyx
+index 253f152130c..7588cde2e27 100644
+--- a/src/sage/plot/plot3d/base.pyx
++++ b/src/sage/plot/plot3d/base.pyx
+@@ -278,7 +278,7 @@ cdef class Graphics3d(SageObject):
+         T.export_jmol(scene_zip, **opts)
+         from sage.interfaces.jmoldata import JmolData
+         jdata = JmolData()
+-        if not jdata.is_jvm_available():
++        if not jdata.is_jmol_available():
+             # We can only use JMol to generate preview if a jvm is installed
+             from sage.repl.rich_output.output_graphics import OutputImagePng
+             tachyon = self._rich_repr_tachyon(OutputImagePng, **opts)
+diff --git a/src/sage/repl/rich_output/backend_ipython.py b/src/sage/repl/rich_output/backend_ipython.py
+index 69e63b76d60..10ccdc0c2c8 100644
+--- a/src/sage/repl/rich_output/backend_ipython.py
++++ b/src/sage/repl/rich_output/backend_ipython.py
+@@ -369,7 +369,7 @@ def launch_jmol(self, output_jmol, plain_text):
+         from sage.doctest import DOCTEST_MODE
+         from sage.interfaces.jmoldata import JmolData
+         jdata = JmolData()
+-        if not jdata.is_jvm_available() and not DOCTEST_MODE:
++        if not jdata.is_jmol_available() and not DOCTEST_MODE:
+             raise RuntimeError('jmol cannot run, no suitable java version found')
+         launch_script = output_jmol.launch_script_filename()
+         jmol_cmd = 'jmol'
diff --git a/srcpkgs/sagemath/patches/get_patches b/srcpkgs/sagemath/patches/get_patches
index 95a6963432948..b179e2f7f190c 100755
--- a/srcpkgs/sagemath/patches/get_patches
+++ b/srcpkgs/sagemath/patches/get_patches
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-version=10.1
+version=10.2.rc5
 
 URL_BASE_PR="https://github.com/sagemath/sage/pull/"
 URL_BASE_COMPARE="https://github.com/sagemath/sage/compare/${version}..."
@@ -20,24 +20,6 @@ get_pr() {
 # run from patches dir
 cd $(dirname "$0")
 
-# merged in 10.2.beta0
-#get_pr  36018   "singular 4.3.2p4" # included in #35934
-get_pr  36046   "fix memory leak"
-
-# merged in 10.2.beta1
-get_pr  35934   "singular 4.3.2p7"
-
-# merged in 10.2.beta2
-get_pr  36006   "gmp 6.3.0"
-
-# merged in 10.2.beta3
-get_pr  36235   "ecl 23.9.9"
-
-# merged in 10.2.beta4
-get_pr  36279   "matplotlib 3.8.0"
-
-# positive review
-#get_pr  36403   "python 3.12" # included in #36407
-
 # needs review
-get_pr  36407   "python 3.12"
+get_pr  35848   "flintlib 3.0"
+get_pr  36769   "fix jmol detect"
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index a80d8b7187ece..d07fa97a95f11 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,14 +1,14 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=10.1
-revision=4
+version=10.2.rc5
+revision=1
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
 _bindir=/usr/lib/sagemath/$version/bin
 make_install_args="--install-scripts=$_bindir"
-hostmakedepends="m4 pkg-config python3-Cython0.29 python3-Jinja2
+hostmakedepends="m4 pkg-config python3-Cython python3-Jinja2
  python3-pkgconfig python3-setuptools"
-makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
+makedepends="boost-devel brial-devel cliquer-devel ecl eclib-devel
  ecm-devel fflas-ffpack flintlib-devel gap-devel gd-devel giac-devel glpk-devel
  gsl-devel iml-devel lcalc-devel libbraiding-devel libhomfly-devel libmpc-devel
  libpng-devel linbox-devel m4ri-devel m4rie-devel mpfi-devel
@@ -18,7 +18,7 @@ makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
 depends="eclib-devel fflas-ffpack flintlib-devel gcc-fortran gd-devel
  gfan giac gsl-devel gzip libpng-devel linbox-devel m4ri-devel maxima-ecl
  mpfr-devel nauty ntl-devel palp pari-devel pari-elldata-small pari-galdata
- pari-galpol-small pari-seadata-small pkg-config python3-Cython0.29 python3-cypari2
+ pari-galpol-small pari-seadata-small pkg-config python3-Cython python3-cypari2
  python3-cysignals python3-devel python3-fpylll python3-ipython python3-lrcalc
  python3-ipython_ipykernel python3-jupyter_ipywidgets python3-matplotlib
  python3-memory_allocator python3-networkx python3-pip python3-pkgconfig
@@ -33,7 +33,7 @@ license="GPL-2.0-or-later"
 homepage="https://www.sagemath.org/"
 changelog="https://github.com/sagemath/sage/releases"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=a658612b1b2376ddaf207cc8ed0ef458d4c2880c16e19139bedbe8baa42ad62f
+checksum=1156d5e214acc15ebf1a9ec41c726eb82d96d1161880a18fe015c479b282c342
 nocross="due to ntl (flintlib), fflas-ffpack, givaro, linbox, cysignals, sympow, maxima"
 
 post_patch() {
diff --git a/srcpkgs/sagemath/update b/srcpkgs/sagemath/update
index 68be3c5752d06..4e62503e2f8f4 100644
--- a/srcpkgs/sagemath/update
+++ b/srcpkgs/sagemath/update
@@ -1,2 +1,3 @@
 pkgname="sage"
-site="https://mirrors.mit.edu/sage/src/index.html"
+site="https://mirrors.mit.edu/sage/src/
+https://mirrors.mit.edu/sage/devel/"

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

* Re: [PR PATCH] [Updated] [RC] sagemath: update to 10.2, flintlib: update to 3.0.1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (21 preceding siblings ...)
  2023-12-01 11:01 ` [PR PATCH] [Updated] " tornaria
@ 2023-12-01 21:08 ` tornaria
  2023-12-03 14:20 ` tornaria
                   ` (5 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: tornaria @ 2023-12-01 21:08 UTC (permalink / raw)
  To: ml

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

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

https://github.com/tornaria/void-packages flintlib
https://github.com/void-linux/void-packages/pull/46832

[RC] sagemath: update to 10.2, flintlib: update to 3.0.1
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **briefly**

This is a major update. A couple of packages need rebuilding (eclib, singular).

For sagemath, we need a patch (in progress: https://github.com/sagemath/sage/pull/35848).

Since backporting patches is a pain and we are not in a hurry, I'm instead targeting 10.2.beta8. Note this already moves sagemath to cython 3.

The goal is to merge flintlib 3.0 together with sagemath 10.2 when the latter is released.

<!--
#### 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/46832.patch is attached

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

From 73e7dd7731c1e46abdfa8be6fd30e53e36bc3d08 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 11 Sep 2023 20:11:20 -0300
Subject: [PATCH 1/7] flintlib: update to 3.0.1.

---
 common/shlibs                                 |  3 +--
 srcpkgs/arb                                   |  1 +
 srcpkgs/arb-devel                             |  2 +-
 srcpkgs/arb/template                          | 24 -------------------
 .../patches/fix-test-t-sdiv_qrnnd.patch       | 23 ------------------
 srcpkgs/flintlib/template                     | 21 ++++++++++++----
 6 files changed, 20 insertions(+), 54 deletions(-)
 create mode 120000 srcpkgs/arb
 delete mode 100644 srcpkgs/arb/template
 delete mode 100644 srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch

diff --git a/common/shlibs b/common/shlibs
index 90018a5616f86..b61f1d1abe1a5 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3972,8 +3972,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.17 flintlib-2.9.0_1
-libarb.so.2 arb-2.20.0_1
+libflint.so.18 flintlib-3.0.0_1
 libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
diff --git a/srcpkgs/arb b/srcpkgs/arb
new file mode 120000
index 0000000000000..7c2633183069f
--- /dev/null
+++ b/srcpkgs/arb
@@ -0,0 +1 @@
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb-devel b/srcpkgs/arb-devel
index 456b9f00a86cd..7c2633183069f 120000
--- a/srcpkgs/arb-devel
+++ b/srcpkgs/arb-devel
@@ -1 +1 @@
-arb
\ No newline at end of file
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
deleted file mode 100644
index 84a62c7ffdba3..0000000000000
--- a/srcpkgs/arb/template
+++ /dev/null
@@ -1,24 +0,0 @@
-# Template file for 'arb'
-pkgname=arb
-version=2.23.0
-revision=1
-build_style=configure
-configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
-makedepends="flintlib-devel"
-short_desc="C library for arbitrary-precision interval arithmetic"
-maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
-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=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
-
-arb-devel_package() {
-	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"
-	short_desc+=" - development files"
-	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.a"
-		vmove "usr/lib/*.so"
-	}
-}
diff --git a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch b/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
deleted file mode 100644
index cfa109792892c..0000000000000
--- a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From fb8ddbcc06afa2a8f25637032fbb8211f6c6c122 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= <albin.ahlback@gmail.com>
-Date: Fri, 20 May 2022 14:16:38 +0200
-Subject: [PATCH] Fix bug in test code for GCC 12
-
----
- test/t-sdiv_qrnnd.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/test/t-sdiv_qrnnd.c b/test/t-sdiv_qrnnd.c
-index 2e9822e848..2676903826 100644
---- a/test/t-sdiv_qrnnd.c
-+++ b/test/t-sdiv_qrnnd.c
-@@ -33,7 +33,7 @@ int main(void)
-         {
-             d = n_randtest_not_zero(state);
-             nh = n_randtest(state);
--        } while ((FLINT_ABS(nh) >= FLINT_ABS(d)/2) || (nh == WORD_MIN));
-+        } while ((nh == WORD_MIN) || (FLINT_ABS(nh) >= FLINT_ABS(d)/2));
- 
-         nl = n_randtest(state);
- 
-
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index f7442c8052aaa..254d18c42f5b3 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,10 +1,10 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.9.0
+version=3.0.1
 revision=1
-build_style=configure
+build_style=gnu-configure
 configure_args="--prefix=/usr $(vopt_with ntl)
- $(vopt_if openblas --with-blas=${XBPS_CROSS_BASE}/usr/include/openblas)"
+ $(vopt_if openblas --with-blas-include=${XBPS_CROSS_BASE}/usr/include/openblas)"
 makedepends="mpfr-devel $(vopt_if ntl ntl-devel)
  $(vopt_if openblas openblas-devel)"
 short_desc="Fast Library for Number Theory"
@@ -13,7 +13,7 @@ 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=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
+checksum=7b311a00503a863881eb8177dbeb84322f29399f3d7d72f3b1a4c9ba1d5794b4
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
@@ -33,7 +33,20 @@ flintlib-devel_package() {
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
+		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
 		vmove "usr/lib/*.so"
 	}
 }
+
+arb_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}
+
+arb-devel_package() {
+	depends="${sourcepkg}-devel>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From ae52f06ca42832a8506c2ed9fa06bbf20417b5eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:08:05 -0300
Subject: [PATCH 2/7] eclib: rebuild for flintlib-3.0.1

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

diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 1d4ad58f21b7b..12165ca788dd5 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
 version=20230424
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 makedepends="pari-devel ntl-devel flintlib-devel boost-devel"

From adb6d9096d614137719ae4186d325555177b5585 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:13:15 -0300
Subject: [PATCH 3/7] singular: update to 4.3.2p10.

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

diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index 036e19d470354..beb0e6d30118e 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,6 +1,6 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.2p7
+version=4.3.2p10
 revision=1
 _majver=${version%p*}
 build_style=gnu-configure
@@ -20,7 +20,7 @@ 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/${_majver//./-}/singular-${version}.tar.gz"
-checksum=aad23c30066b7fbc011138a98d60532565d76a847eec6bf2938410d93b272ca3
+checksum=28c2c9fcfee954e00dfa56eb1a7d418d5b1de67c4398d25a0f2b8f73e71552a8
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From 8487a19468d1c4511f363079131567b0731d0f88 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 19 Jul 2023 21:04:33 -0300
Subject: [PATCH 4/7] python3-pplpy: use cython 3.

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

diff --git a/srcpkgs/python3-pplpy/template b/srcpkgs/python3-pplpy/template
index 4a9c987b2a859..d3b9aebdf2237 100644
--- a/srcpkgs/python3-pplpy/template
+++ b/srcpkgs/python3-pplpy/template
@@ -1,9 +1,9 @@
 # Template file for 'python3-pplpy'
 pkgname=python3-pplpy
 version=0.8.9
-revision=1
+revision=2
 build_style=python3-pep517
-hostmakedepends="python3-setuptools python3-wheel python3-Cython0.29
+hostmakedepends="python3-setuptools python3-wheel python3-Cython
  python3-cysignals python3-gmpy2"
 makedepends="python3-devel gmp-devel gmpxx-devel ppl-devel mpfr-devel
  libmpc-devel pari-devel"

From d8be650be46c5b695751b63ec4fed54c4ce5bd13 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Thu, 19 Oct 2023 08:52:15 -0300
Subject: [PATCH 5/7] python3-networkx: update to 3.2.1.

---
 srcpkgs/python3-networkx/template | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/python3-networkx/template b/srcpkgs/python3-networkx/template
index 186bf64f7bff9..29283d9e5a032 100644
--- a/srcpkgs/python3-networkx/template
+++ b/srcpkgs/python3-networkx/template
@@ -1,11 +1,11 @@
 # Template file for 'python3-networkx'
 pkgname=python3-networkx
-version=3.1
-revision=2
-build_style=python3-module
+version=3.2.1
+revision=1
+build_style=python3-pep517
 # failing in i686
 make_check_args="--deselect networkx/algorithms/approximation/tests/test_traveling_salesman.py::test_asadpour_tsp"
-hostmakedepends="python3-setuptools"
+hostmakedepends="python3-setuptools python3-wheel"
 depends="python3"
 checkdepends="python3-numpy python3-scipy python3-matplotlib python3-pandas
  python3-lxml python3-sympy python3-pytest-xdist"
@@ -15,7 +15,7 @@ license="BSD-3-Clause"
 homepage="https://networkx.org"
 changelog="https://github.com/networkx/networkx/raw/main/doc/release/release_${version}.rst"
 distfiles="${PYPI_SITE}/n/networkx/networkx-${version}.tar.gz"
-checksum=de346335408f84de0eada6ff9fafafff9bcda11f0a0dfaa931133debb146ab61
+checksum=9f1bb5cf3409bf324e0a722c20bdb4c20ee39bf1c30ce8ae499c8502b0b5e0c6
 
 post_install() {
 	vlicense LICENSE.txt

From ba0828705d9fa27080b89948761f09a2cfc1e730 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Sat, 25 Nov 2023 11:47:44 -0300
Subject: [PATCH 6/7] nauty: update to 2.8.8.

---
 .../nauty-2.8.6-gentreeg-gentourng.patch      | 144 ------------------
 srcpkgs/nauty/template                        |   4 +-
 2 files changed, 2 insertions(+), 146 deletions(-)
 delete mode 100644 srcpkgs/nauty/patches/nauty-2.8.6-gentreeg-gentourng.patch

diff --git a/srcpkgs/nauty/patches/nauty-2.8.6-gentreeg-gentourng.patch b/srcpkgs/nauty/patches/nauty-2.8.6-gentreeg-gentourng.patch
deleted file mode 100644
index 322b25326ee09..0000000000000
--- a/srcpkgs/nauty/patches/nauty-2.8.6-gentreeg-gentourng.patch
+++ /dev/null
@@ -1,144 +0,0 @@
-From edb0474a4db8e69f971e4eebe18716309f5a7bb3 Mon Sep 17 00:00:00 2001
-From: Michael Orlitzky <michael@orlitzky.com>
-Date: Tue, 17 Jan 2023 19:44:49 -0500
-Subject: [PATCH 1/1] Upstream fixes for gentreeg and gentourng.
-
-https://mailman.anu.edu.au/pipermail/nauty/2023-January/000903.html
----
- gentourng.c |  2 +-
- gentreeg.c  | 95 ++++++++++++++++++++++++++++-------------------------
- 2 files changed, 51 insertions(+), 46 deletions(-)
-
-diff --git a/gentourng.c b/gentourng.c
-index 634e5e8..5c7ffff 100644
---- a/gentourng.c
-+++ b/gentourng.c
-@@ -1408,7 +1408,7 @@ PLUGIN_INIT
-                 (*outproc)(outfile,g,1);
-             }
-         }
--        else
-+        else if (!connec || maxn != 2)
-         {
-             makeleveldata();
- 
-diff --git a/gentreeg.c b/gentreeg.c
-index 946d5f8..15bf87b 100644
---- a/gentreeg.c
-+++ b/gentreeg.c
-@@ -1,4 +1,4 @@
--/* gentree version 1.3; Brendan McKay Oct 2022 */
-+/* gentree version 1.4; Brendan McKay Dec 2022 */
- /* This program is a wrapper for the program FreeTrees.c written
-  * by Gang Li & Frank Ruskey.  See below for their original
-  * comments. */
-@@ -32,49 +32,54 @@ Counts for n=1..45:
-  1: 1
-  2: 1
-  3: 1
-- 4: 1
-- 5: 2
-- 6: 3
-- 7: 6
-- 8: 11
-- 9: 23
--10: 47
--11: 106
--12: 235
--13: 551
--14: 1301
--15: 3159
--16: 7741
--17: 19320
--18: 48629
--19: 123867
--20: 317955
--21: 823065
--22: 2144505
--23: 5623756
--24: 14828074
--25: 39299897
--26: 104636890
--27: 279793450
--28: 751065460
--29: 2023443032
--30: 5469566585
--31: 14830871802
--32: 40330829030
--33: 109972410221
--34: 300628862480
--35: 823779631721
--36: 2262366343746
--37: 6226306037178
--38: 17169677490714
--39: 47436313524262
--40: 131290543779126
--41: 363990257783343
--42: 1010748076717151
--43: 2810986483493475
--44: 7828986221515605
--45: 21835027912963086
--********************************/
-+ 4: 2
-+ 5: 3
-+ 6: 6
-+ 7: 11
-+ 8: 23
-+ 9: 47
-+10: 106
-+11: 235
-+12: 551
-+13: 1301
-+14: 3159
-+15: 7741
-+16: 19320
-+17: 48629
-+18: 123867
-+19: 317955
-+20: 823065
-+21: 2144505
-+22: 5623756
-+23: 14828074
-+24: 39299897
-+25: 104636890
-+26: 279793450
-+27: 751065460
-+28: 2023443032
-+29: 5469566585
-+30: 14830871802
-+31: 40330829030
-+32: 109972410221
-+33: 300628862480
-+34: 823779631721
-+35: 2262366343746
-+36: 6226306037178
-+37: 17169677490714
-+38: 47436313524262
-+39: 131290543779126
-+40: 363990257783343
-+41: 1010748076717151
-+42: 2810986483493475
-+43: 7828986221515605
-+44: 21835027912963086
-+45: 60978390985918906
-+46: 170508699155987862
-+47: 477355090753926460
-+48: 1337946100045842285
-+49: 3754194185716399992
-+50: 10545233702911509534
-+*******************************/
- 
- /* Comments on original program by original authors */
- /*==============================================================*/
-@@ -676,7 +681,7 @@ PLUGIN_INIT
-         }
-         else if (nv == 2)
-         {
--            if (res == 0 && maxdeg >= 1 && mindiam <= 1 && maxdiam >= 2)
-+            if (res == 0 && maxdeg >= 1 && mindiam <= 1 && maxdiam >= 1)
-             {
-                 par[1] = 0;
-                 par[2] = 1;
--- 
-2.38.2
-
diff --git a/srcpkgs/nauty/template b/srcpkgs/nauty/template
index 8be5d050920bc..6f85b1d064d4e 100644
--- a/srcpkgs/nauty/template
+++ b/srcpkgs/nauty/template
@@ -1,6 +1,6 @@
 # Template file for 'nauty'
 pkgname=nauty
-version=2.8.6
+version=2.8.8
 revision=1
 build_style=gnu-configure
 make_install_args="includedir=/usr/include/nauty
@@ -12,7 +12,7 @@ license="Apache-2.0"
 homepage="https://pallini.di.uniroma1.it/"
 changelog="https://pallini.di.uniroma1.it/changes24-28.txt"
 distfiles="https://pallini.di.uniroma1.it/nauty${version//./_}.tar.gz"
-checksum=f2ce98225ca8330f5bce35f7d707b629247e09dda15fc479dc00e726fee5e6fa
+checksum=159d2156810a6bb240410cd61eb641add85088d9f15c888cdaa37b8681f929ce
 
 build_options="native_build"
 

From a388eeb3feec800fa01060f1755bc76853547766 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:50:44 -0300
Subject: [PATCH 7/7] sagemath: update to 10.2.rc5.

---
 .../sagemath/patches/35848-flintlib_3.0.patch | 1867 +++++++++++++++++
 .../patches/35934-singular_4.3.2p7.patch      |  221 --
 .../sagemath/patches/36006-gmp_6.3.0.patch    |   38 -
 .../patches/36046-fix_memory_leak.patch       |  740 -------
 .../sagemath/patches/36235-ecl_23.9.9.patch   |   39 -
 .../patches/36279-matplotlib_3.8.0.patch      |   24 -
 srcpkgs/sagemath/patches/36403-00pre.patch    |   29 -
 .../sagemath/patches/36407-python_3.12.patch  | 1744 ---------------
 .../patches/36769-fix_jmol_detect.patch       |   92 +
 srcpkgs/sagemath/patches/get_patches          |   24 +-
 srcpkgs/sagemath/template                     |   12 +-
 srcpkgs/sagemath/update                       |    3 +-
 12 files changed, 1970 insertions(+), 2863 deletions(-)
 create mode 100644 srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
 delete mode 100644 srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
 delete mode 100644 srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
 delete mode 100644 srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36403-00pre.patch
 delete mode 100644 srcpkgs/sagemath/patches/36407-python_3.12.patch
 create mode 100644 srcpkgs/sagemath/patches/36769-fix_jmol_detect.patch

diff --git a/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
new file mode 100644
index 0000000000000..2cad28134f6e6
--- /dev/null
+++ b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
@@ -0,0 +1,1867 @@
+diff --git a/build/pkgs/antic/SPKG.rst b/build/pkgs/antic/SPKG.rst
+deleted file mode 100644
+index d6c32377957..00000000000
+--- a/build/pkgs/antic/SPKG.rst
++++ /dev/null
+@@ -1,18 +0,0 @@
+-antic: Algebraic Number Theory In C
+-===================================
+-
+-Description
+------------
+-
+-Algebraic Number Theory In C
+-
+-License
+--------
+-
+-LGPL 2.1
+-
+-Upstream Contact
+-----------------
+-
+-https://github.com/wbhart/antic
+-
+diff --git a/build/pkgs/antic/checksums.ini b/build/pkgs/antic/checksums.ini
+deleted file mode 100644
+index fc8711ecd13..00000000000
+--- a/build/pkgs/antic/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=antic-VERSION.tar.gz
+-sha1=940d8ea2c3512b9d49ee3101cf043f777764bd8f
+-md5=4e896420dd6344b53b307871efb2cbb4
+-cksum=1938565125
+-upstream_url=https://github.com/wbhart/antic/archive/refs/tags/vVERSION.tar.gz
+diff --git a/build/pkgs/antic/dependencies b/build/pkgs/antic/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/antic/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/antic/distros/arch.txt b/build/pkgs/antic/distros/arch.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/conda.txt b/build/pkgs/antic/distros/conda.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/debian.txt b/build/pkgs/antic/distros/debian.txt
+deleted file mode 100644
+index 8fdcd3e5721..00000000000
+--- a/build/pkgs/antic/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libantic-dev
+diff --git a/build/pkgs/antic/distros/fedora.txt b/build/pkgs/antic/distros/fedora.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/freebsd.txt b/build/pkgs/antic/distros/freebsd.txt
+deleted file mode 100644
+index 116ff3a26f3..00000000000
+--- a/build/pkgs/antic/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/antic
+diff --git a/build/pkgs/antic/distros/opensuse.txt b/build/pkgs/antic/distros/opensuse.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/repology.txt b/build/pkgs/antic/distros/repology.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/package-version.txt b/build/pkgs/antic/package-version.txt
+deleted file mode 100644
+index 3a4036fb450..00000000000
+--- a/build/pkgs/antic/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-0.2.5
+diff --git a/build/pkgs/antic/spkg-install.in b/build/pkgs/antic/spkg-install.in
+deleted file mode 100644
+index c57fa884a20..00000000000
+--- a/build/pkgs/antic/spkg-install.in
++++ /dev/null
+@@ -1,19 +0,0 @@
+-cd src
+-
+-# Copied from build/pkgs/flint/spkg-install.in:
+-#   Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-#   --with-ntl because otherwise FLINT's configure script uses
+-#   /usr/local, which is always wrong.
+-#   This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-#   The value $SAGE_LOCAL is always a safe choice even if the library
+-#   is coming from the system and is found using what is in
+-#   LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-flint="$SAGE_LOCAL"  || sdh_die "Error: Failed to configure antic."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/antic/type b/build/pkgs/antic/type
+deleted file mode 100644
+index 134d9bc32d5..00000000000
+--- a/build/pkgs/antic/type
++++ /dev/null
+@@ -1 +0,0 @@
+-optional
+diff --git a/build/pkgs/arb/SPKG.rst b/build/pkgs/arb/SPKG.rst
+deleted file mode 100644
+index cff49ddb95b..00000000000
+--- a/build/pkgs/arb/SPKG.rst
++++ /dev/null
+@@ -1,27 +0,0 @@
+-arb: Arbitrary-precision floating-point ball arithmetic
+-=======================================================
+-
+-Description
+------------
+-
+-Arb is a C library for arbitrary-precision floating-point ball
+-arithmetic, developed by Fredrik Johansson
+-(fredrik.johansson@gmail.com). It supports efficient high-precision
+-computation with polynomials, power series, matrices and special
+-functions over the real and complex numbers, with automatic, rigorous
+-error control.
+-
+-License
+--------
+-
+-GNU General Public License v2+
+-
+-
+-Upstream Contact
+-----------------
+-
+- - Fredrik Johansson: fredrik.johansson@gmail.com
+-
+- - https://arblib.org/
+-
+- - http://github.com/fredrik-johansson/arb/
+diff --git a/build/pkgs/arb/checksums.ini b/build/pkgs/arb/checksums.ini
+deleted file mode 100644
+index 80ef43dad5d..00000000000
+--- a/build/pkgs/arb/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=arb-VERSION.tar.gz
+-sha1=a1efe035dd3af3613dd685971a156f652b86ff63
+-md5=9b369e29f93cdf2d4f90b57a92526cce
+-cksum=64252121
+-upstream_url=https://github.com/fredrik-johansson/arb/archive/VERSION.tar.gz
+diff --git a/build/pkgs/arb/dependencies b/build/pkgs/arb/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/arb/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/arb/distros/arch.txt b/build/pkgs/arb/distros/arch.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/conda.txt b/build/pkgs/arb/distros/conda.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/debian.txt b/build/pkgs/arb/distros/debian.txt
+deleted file mode 100644
+index 9fe71110712..00000000000
+--- a/build/pkgs/arb/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libflint-arb-dev
+diff --git a/build/pkgs/arb/distros/fedora.txt b/build/pkgs/arb/distros/fedora.txt
+deleted file mode 100644
+index 76794404627..00000000000
+--- a/build/pkgs/arb/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb arb-devel
+diff --git a/build/pkgs/arb/distros/freebsd.txt b/build/pkgs/arb/distros/freebsd.txt
+deleted file mode 100644
+index 2ef8c7cec0f..00000000000
+--- a/build/pkgs/arb/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/arb
+diff --git a/build/pkgs/arb/distros/gentoo.txt b/build/pkgs/arb/distros/gentoo.txt
+deleted file mode 100644
+index 58e3d4f8008..00000000000
+--- a/build/pkgs/arb/distros/gentoo.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-sci-mathematics/arb
+diff --git a/build/pkgs/arb/distros/homebrew.txt b/build/pkgs/arb/distros/homebrew.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/homebrew.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/nix.txt b/build/pkgs/arb/distros/nix.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/nix.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/opensuse.txt b/build/pkgs/arb/distros/opensuse.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/distros/repology.txt b/build/pkgs/arb/distros/repology.txt
+deleted file mode 100644
+index 179c9d507e1..00000000000
+--- a/build/pkgs/arb/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-fp
+diff --git a/build/pkgs/arb/distros/void.txt b/build/pkgs/arb/distros/void.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/void.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/package-version.txt b/build/pkgs/arb/package-version.txt
+deleted file mode 100644
+index e9763f6bfed..00000000000
+--- a/build/pkgs/arb/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-2.23.0
+diff --git a/build/pkgs/arb/spkg-check.in b/build/pkgs/arb/spkg-check.in
+deleted file mode 100644
+index 27cd9419538..00000000000
+--- a/build/pkgs/arb/spkg-check.in
++++ /dev/null
+@@ -1,2 +0,0 @@
+-cd src
+-$MAKE check
+diff --git a/build/pkgs/arb/spkg-configure.m4 b/build/pkgs/arb/spkg-configure.m4
+deleted file mode 100644
+index ef2dd0aac4a..00000000000
+--- a/build/pkgs/arb/spkg-configure.m4
++++ /dev/null
+@@ -1,23 +0,0 @@
+-SAGE_SPKG_CONFIGURE([arb], [
+-    AC_REQUIRE([SAGE_SPKG_CONFIGURE_FLINT])
+-    SAGE_ARB_LIBRARY="arb"
+-    AC_MSG_CHECKING([installing flint? ])
+-    if test x$sage_spkg_install_flint = xyes; then
+-        AC_MSG_RESULT([yes; install arb as well])
+-        sage_spkg_install_arb=yes
+-    else
+-        AC_CHECK_HEADER(arb.h, [
+-        dnl below function added in version 2.16 of arb
+-            AC_CHECK_LIB([arb], [acb_mat_eig_simple], [],
+-              [dnl in Debian the name of dylib is different.
+-               AC_CHECK_LIB([flint-arb], [acb_mat_eig_simple],
+-                [SAGE_ARB_LIBRARY="flint-arb"], [sage_spkg_install_arb=yes])])
+-        ], [sage_spkg_install_arb=yes])
+-    fi
+-], [], [], [
+-    if test x$sage_spkg_install_arb = xyes; then
+-        AC_SUBST(SAGE_ARB_LIBRARY,["arb"])
+-    else
+-        AC_SUBST(SAGE_ARB_LIBRARY,[$SAGE_ARB_LIBRARY])
+-    fi
+-])
+diff --git a/build/pkgs/arb/spkg-install.in b/build/pkgs/arb/spkg-install.in
+deleted file mode 100644
+index 9322f04c912..00000000000
+--- a/build/pkgs/arb/spkg-install.in
++++ /dev/null
+@@ -1,17 +0,0 @@
+-cd src
+-
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-flint because otherwise ARB's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure --disable-static --prefix="$SAGE_LOCAL" \
+-        --with-gmp="$SAGE_LOCAL" \
+-        --with-mpfr="$SAGE_LOCAL" \
+-        --with-flint="$SAGE_LOCAL" || \
+-    sdh_die "Error configuring arb."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/arb/type b/build/pkgs/arb/type
+deleted file mode 100644
+index a6a7b9cd726..00000000000
+--- a/build/pkgs/arb/type
++++ /dev/null
+@@ -1 +0,0 @@
+-standard
+diff --git a/build/pkgs/e_antic/dependencies b/build/pkgs/e_antic/dependencies
+index fea1ffbda45..8e977a55c13 100644
+--- a/build/pkgs/e_antic/dependencies
++++ b/build/pkgs/e_antic/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) flint arb antic boost_cropped
++$(MP_LIBRARY) flint boost_cropped
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/SPKG.rst b/build/pkgs/flint/SPKG.rst
+index f91de70d1ff..d9dcea0903b 100644
+--- a/build/pkgs/flint/SPKG.rst
++++ b/build/pkgs/flint/SPKG.rst
+@@ -4,8 +4,8 @@ flint: Fast Library for Number Theory
+ Description
+ -----------
+ 
+-FLINT is a C library for doing number theory, maintained by William
+-Hart.
++FLINT is a C library for doing number theory, maintained by
++Fredrik Johansson.
+ 
+ Website: http://www.flintlib.org
+ 
+@@ -20,4 +20,4 @@ Upstream Contact
+ 
+ -  flint-devel Gougle Group
+    (http://groups.google.co.uk/group/flint-devel)
+--  William Hart
++-  Fredrik Johansson
+diff --git a/build/pkgs/flint/checksums.ini b/build/pkgs/flint/checksums.ini
+index 3d449d98064..ab836606657 100644
+--- a/build/pkgs/flint/checksums.ini
++++ b/build/pkgs/flint/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=flint-VERSION.tar.gz
+-sha1=63d90f8242c8f8ab4011fbcfb44b86c154f43abd
+-md5=c2d3cec326438f159a530c66eb07fafe
+-cksum=4244948341
+-upstream_url=http://flintlib.org/flint-VERSION.tar.gz
++sha1=65be9297c06edd7e24f20874b7bd6130cee56723
++md5=5189f67b0ec12e4a54d6782851642b81
++cksum=172350473
++upstream_url=https://github.com/flintlib/flint/releases/download/vVERSION/flint-VERSION.tar.gz
+diff --git a/build/pkgs/flint/dependencies b/build/pkgs/flint/dependencies
+index 385df4faa7d..1108dc4fb21 100644
+--- a/build/pkgs/flint/dependencies
++++ b/build/pkgs/flint/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) mpfr ntl
++$(MP_LIBRARY) mpfr
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/package-version.txt b/build/pkgs/flint/package-version.txt
+index c8e38b61405..cb2b00e4f7a 100644
+--- a/build/pkgs/flint/package-version.txt
++++ b/build/pkgs/flint/package-version.txt
+@@ -1 +1 @@
+-2.9.0
++3.0.1
+diff --git a/build/pkgs/flint/patches/0001-Makefile.in-fix-handling-of-DESTDIR.patch b/build/pkgs/flint/patches/0001-Makefile.in-fix-handling-of-DESTDIR.patch
+new file mode 100644
+index 00000000000..48a32f5d894
+--- /dev/null
++++ b/build/pkgs/flint/patches/0001-Makefile.in-fix-handling-of-DESTDIR.patch
+@@ -0,0 +1,106 @@
++From 54277f054f13254898c9a57c2c7eb869877e1252 Mon Sep 17 00:00:00 2001
++From: Marc Mezzarobba <marc@mezzarobba.net>
++Date: Mon, 13 Nov 2023 10:23:54 +0100
++Subject: [PATCH] Makefile.in: fix handling of $DESTDIR
++
++---
++ Makefile.in | 54 ++++++++++++++++++++++++++---------------------------
++ 1 file changed, 27 insertions(+), 27 deletions(-)
++
++diff --git a/Makefile.in b/Makefile.in
++index 08db6837c..2827b9da1 100644
++--- a/Makefile.in
+++++ b/Makefile.in
++@@ -34,9 +34,9 @@ FLINT_SOLIB:=@FLINT_SOLIB@
++ prefix:=@prefix@
++ exec_prefix:=@exec_prefix@
++ 
++-INCLUDEDIR:=$(DESTDIR)@includedir@
++-LIBDIR:=$(DESTDIR)@libdir@
++-BINDIR:=$(DESTDIR)@bindir@
+++INCLUDEDIR:=@includedir@
+++LIBDIR:=@libdir@
+++BINDIR:=@bindir@
++ PKGCONFIGDIR:=$(LIBDIR)/pkgconfig
++ 
++ HOST_OS:=@host_os@
++@@ -202,10 +202,10 @@ BUILD_DIRS +=                                                               \
++ endif
++ 
++ INSTALL_DIRS :=                                                             \
++-        $(LIBDIR)                       $(INCLUDEDIR)/flint                 \
++-        $(PKGCONFIGDIR)
+++        $(DESTDIR)$(LIBDIR)             $(DESTDIR)$(INCLUDEDIR)/flint       \
+++        $(DESTDIR)$(PKGCONFIGDIR)
++ ifneq ($(FLINT_DLLLIB),0)
++-INSTALL_DIRS += $(BINDIR)
+++INSTALL_DIRS += $(DESTDIR)$(BINDIR)
++ endif
++ 
++ ################################################################################
++@@ -722,41 +722,41 @@ distclean: clean
++ ################################################################################
++ 
++ install: library | $(INSTALL_DIRS)
++-	$(CP) flint.pc $(PKGCONFIGDIR)/flint.pc
+++	$(CP) flint.pc $(DESTDIR)$(PKGCONFIGDIR)/flint.pc
++ ifneq ($(SHARED), 0)
++ ifneq ($(FLINT_DLLLIB),0)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(BINDIR)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(BINDIR)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(BINDIR)
++-	$(CP) $(FLINT_DIR)/$(FLINT_IMPLIB) $(LIBDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(DESTDIR)$(BINDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(DESTDIR)$(BINDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(DESTDIR)$(BINDIR)
+++	$(CP) $(FLINT_DIR)/$(FLINT_IMPLIB) $(DESTDIR)$(LIBDIR)
++ else
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(LIBDIR)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(LIBDIR)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(LIBDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(DESTDIR)$(LIBDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(DESTDIR)$(LIBDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(DESTDIR)$(LIBDIR)
++ endif
++ ifneq ($(FLINT_DYLIB),0)
++-	install_name_tool -id $(LIBDIR)/$(FLINT_LIB_FULL) $(LIBDIR)/$(FLINT_LIB)
+++	install_name_tool -id $(LIBDIR)/$(FLINT_LIB_FULL) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB)
++ endif
++ endif
++ ifneq ($(STATIC), 0)
++-	$(CP) $(FLINT_DIR)/$(FLINT_LIB_STATIC) $(LIBDIR)
+++	$(CP) $(FLINT_DIR)/$(FLINT_LIB_STATIC) $(DESTDIR)$(LIBDIR)
++ endif
++-	$(CP) $(HEADERS) $(INCLUDEDIR)/flint
+++	$(CP) $(HEADERS) $(DESTDIR)$(INCLUDEDIR)/flint
++ 
++ uninstall:
++-	$(RM_F) $(PKGCONFIGDIR)/flint.pc
+++	$(RM_F) $(DESTDIR)$(PKGCONFIGDIR)/flint.pc
++ ifneq ($(FLINT_DLLLIB),0)
++-	$(RM_F) $(BINDIR)/$(FLINT_LIB)
++-	$(RM_F) $(BINDIR)/$(FLINT_LIB_MAJOR)
++-	$(RM_F) $(BINDIR)/$(FLINT_LIB_FULL)
++-	$(RM_F) $(LIBDIR)/$(FLINT_IMPLIB)
+++	$(RM_F) $(DESTDIR)$(BINDIR)/$(FLINT_LIB)
+++	$(RM_F) $(DESTDIR)$(BINDIR)/$(FLINT_LIB_MAJOR)
+++	$(RM_F) $(DESTDIR)$(BINDIR)/$(FLINT_LIB_FULL)
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_IMPLIB)
++ else
++-	$(RM_F) $(LIBDIR)/$(FLINT_LIB)
++-	$(RM_F) $(LIBDIR)/$(FLINT_LIB_MAJOR)
++-	$(RM_F) $(LIBDIR)/$(FLINT_LIB_FULL)
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB)
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB_MAJOR)
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB_FULL)
++ endif
++-	$(RM_F) $(LIBDIR)/$(FLINT_LIB_STATIC)
++-	$(RM_RF) $(INCLUDEDIR)/flint
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB_STATIC)
+++	$(RM_RF) $(DESTDIR)$(INCLUDEDIR)/flint
++ 
++ ################################################################################
++ # maintainer stuff
++-- 
++2.42.0
++
+diff --git a/build/pkgs/flint/spkg-build.in b/build/pkgs/flint/spkg-build.in
+new file mode 100644
+index 00000000000..ffb822c8a97
+--- /dev/null
++++ b/build/pkgs/flint/spkg-build.in
+@@ -0,0 +1,3 @@
++cd src
++sdh_configure
++sdh_make
+diff --git a/build/pkgs/flint/spkg-configure.m4 b/build/pkgs/flint/spkg-configure.m4
+index a58108c9d6e..9576e4cc1e9 100644
+--- a/build/pkgs/flint/spkg-configure.m4
++++ b/build/pkgs/flint/spkg-configure.m4
+@@ -1,25 +1,8 @@
+ SAGE_SPKG_CONFIGURE([flint], [
+-    SAGE_SPKG_DEPCHECK([mpfr ntl], [
++    SAGE_SPKG_DEPCHECK([mpfr], [
+         AC_CHECK_HEADER(flint/flint.h, [
+-          dnl flint_parallel_binary_splitting appears in Flint 2.9.0, needed by arb 2.23
+-          AC_SEARCH_LIBS([flint_parallel_binary_splitting], [flint], [
+-            dnl check that NTL is linked in
+-            AC_SEARCH_LIBS([fmpz_poly_get_ZZX], [flint], [
+-
+-              AC_MSG_CHECKING([that GC is not enabled in Flint... ])
+-              AC_RUN_IFELSE([
+-                 AC_LANG_PROGRAM([[#include <flint/flint.h>]], [
+-                                  [#ifdef HAVE_GC]
+-                                     [return HAVE_GC;]
+-                                  [#else]
+-                                     [return 0;]
+-                                  [#endif]])],
+-                 [AC_MSG_RESULT([GC not enabled. Good.])],
+-                        [AC_MSG_RESULT([GC enabled. Incompatible with Sage.])
+-                         sage_spkg_install_flint=yes],
+-                 [AC_MSG_RESULT(["cross compiling. assuming GC is not enabled"])])
+-            ], [sage_spkg_install_flint=yes])
+-          ], [sage_spkg_install_flint=yes])
++          dnl gr_get_fexpr appears in Flint 3.0
++          AC_SEARCH_LIBS([gr_get_fexpr], [flint], [], [sage_spkg_install_flint=yes])
+         ], [sage_spkg_install_flint=yes])
+     ])
+ ], [], [], [
+diff --git a/build/pkgs/flint/spkg-install.in b/build/pkgs/flint/spkg-install.in
+index eacd7b6e491..3ea8c053669 100644
+--- a/build/pkgs/flint/spkg-install.in
++++ b/build/pkgs/flint/spkg-install.in
+@@ -1,36 +1,2 @@
+-###############################################################################
+-#
+-# FLINT Sage install script
+-#
+-###############################################################################
+-if [ "$SAGE_DEBUG" = "yes" ]; then
+-    echo "Building a debug version of FLINT."
+-    FLINT_TUNE=" $FLINT_TUNE"; export FLINT_TUNE
+-    FLINT_CONFIGURE="--enable-assert $FLINT_CONFIGURE"
+-fi
+-
+ cd src
+-
+-echo "Configuring FLINT."
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-ntl because otherwise FLINT's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-ntl="$SAGE_LOCAL" \
+-    $FLINT_CONFIGURE || sdh_die "Error: Failed to configure FLINT."
+-
+-sdh_make verbose
+-
+-echo "Deleting old FLINT files."
+-rm -f $SAGE_LOCAL/lib/libflint*
+-rm -rf $SAGE_LOCAL/include/flint
+-
+ sdh_make_install
+diff --git a/build/pkgs/gmp/spkg-configure.m4 b/build/pkgs/gmp/spkg-configure.m4
+index 61d7c5f3b2f..4000200db2c 100644
+--- a/build/pkgs/gmp/spkg-configure.m4
++++ b/build/pkgs/gmp/spkg-configure.m4
+@@ -2,8 +2,10 @@ SAGE_SPKG_CONFIGURE([gmp], [
+            sage_spkg_install_gmp=no
+             AC_CHECK_HEADER(gmp.h, [], [sage_spkg_install_gmp=yes])
+             AC_CHECK_HEADER(gmpxx.h, [], [sage_spkg_install_gmp=yes])
+-            dnl mpq_cmp_z appeared in GMP 6.1.0 and is used by pynac
+-            AC_SEARCH_LIBS([__gmpq_cmp_z], [gmp], [],
++            dnl mpn_gcd_11 appeared in GMP 6.2.1
++            dnl It is undocumented but is used by Flint when built with default
++            dnl flags.
++            AC_SEARCH_LIBS([__gmpn_gcd_11], [gmp], [],
+                 [sage_spkg_install_gmp=yes])
+ ], [], [], [
+     if test x$sage_spkg_install_gmp = xyes; then
+diff --git a/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+new file mode 100644
+index 00000000000..27a642a13b0
+--- /dev/null
++++ b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+@@ -0,0 +1,53 @@
++From fe730579476de0b2d4181a38efa7f63dff9c81d7 Mon Sep 17 00:00:00 2001
++From: Marc Mezzarobba <marc@mezzarobba.net>
++Date: Tue, 12 Sep 2023 08:23:08 +0200
++Subject: [PATCH] Make msolve build with flint3
++
++---
++ src/fglm/berlekamp_massey.c | 3 +++
++ src/fglm/data_fglm.c        | 7 +++++--
++ 2 files changed, 8 insertions(+), 2 deletions(-)
++
++diff --git a/src/fglm/berlekamp_massey.c b/src/fglm/berlekamp_massey.c
++index b0f2052..998af1c 100644
++--- a/src/fglm/berlekamp_massey.c
+++++ b/src/fglm/berlekamp_massey.c
++@@ -30,6 +30,9 @@
++ */
++ 
++ #include <stdlib.h>
+++#if __FLINT_VERSION >= 3
+++#  include <flint/nmod.h>
+++#endif
++ //#include "nmod_poly.h"
++ //#include "mpn_extras.h"
++ 
++diff --git a/src/fglm/data_fglm.c b/src/fglm/data_fglm.c
++index 0726760..0e1da6f 100644
++--- a/src/fglm/data_fglm.c
+++++ b/src/fglm/data_fglm.c
++@@ -24,6 +24,7 @@
++ #include <flint/mpn_extras.h>
++ #include <flint/nmod_poly.h>
++ #include <flint/nmod_poly_factor.h>
+++#include <flint/ulong_extras.h>
++ 
++ 
++ typedef uint32_t szmat_t;
++@@ -299,9 +300,11 @@ static inline void nmod_poly_set_prime(nmod_poly_t poly,
++   mp_limb_t ninv = n_preinvert_limb(prime);
++   poly->mod.n = prime;
++   poly->mod.ninv = ninv;
+++#if __FLINT_VERSION < 3
++   count_leading_zeros(poly->mod.norm, prime);
++-  /* poly->mod.norm = flint_clz(prime); */
++-
+++#else
+++  poly->mod.norm = flint_clz(prime);
+++#endif
++ }
++ 
++ static inline void fglm_param_set_prime(param_t *param, mp_limb_t prime){
++-- 
++2.40.1
++
+diff --git a/build/pkgs/sagelib/dependencies b/build/pkgs/sagelib/dependencies
+index 5dc2efe1d31..fa6e98df7db 100644
+--- a/build/pkgs/sagelib/dependencies
++++ b/build/pkgs/sagelib/dependencies
+@@ -1,4 +1,4 @@
+-FORCE $(SCRIPTS) arb boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
++FORCE $(SCRIPTS) boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/symengine/dependencies b/build/pkgs/symengine/dependencies
+index 1fc34963eda..7795d486018 100644
+--- a/build/pkgs/symengine/dependencies
++++ b/build/pkgs/symengine/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) arb ecm flint mpc mpfr | cmake
++$(MP_LIBRARY) ecm flint mpc mpfr | cmake
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/pkgs/sage-conf/_sage_conf/_conf.py.in b/pkgs/sage-conf/_sage_conf/_conf.py.in
+index 87b27ca05cb..895d6572d1e 100644
+--- a/pkgs/sage-conf/_sage_conf/_conf.py.in
++++ b/pkgs/sage-conf/_sage_conf/_conf.py.in
+@@ -19,8 +19,6 @@ MAXIMA_FAS = "@SAGE_MAXIMA_FAS@".replace('${prefix}', SAGE_LOCAL)
+ # Delete this line if your ECL can load Kenzo without further prodding.
+ KENZO_FAS = "@SAGE_KENZO_FAS@".replace('${prefix}', SAGE_LOCAL)
+ 
+-ARB_LIBRARY = "@SAGE_ARB_LIBRARY@"
+-
+ NTL_INCDIR = "@NTL_INCDIR@"
+ NTL_LIBDIR = "@NTL_LIBDIR@"
+ 
+diff --git a/src/sage/env.py b/src/sage/env.py
+index 4515e90e912..9ab6b1e1864 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -223,7 +223,6 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st
+ FOURTITWO_PPI = var("FOURTITWO_PPI")
+ FOURTITWO_CIRCUITS = var("FOURTITWO_CIRCUITS")
+ FOURTITWO_GROEBNER = var("FOURTITWO_GROEBNER")
+-ARB_LIBRARY = var("ARB_LIBRARY", "arb")
+ CBLAS_PC_MODULES = var("CBLAS_PC_MODULES", "cblas:openblas:blas")
+ ECL_CONFIG = var("ECL_CONFIG", "ecl-config")
+ NTL_INCDIR = var("NTL_INCDIR")
+@@ -356,8 +355,7 @@ def cython_aliases(required_modules=None,
+         sage: cython_aliases()
+         {...}
+         sage: sorted(cython_aliases().keys())
+-        ['ARB_LIBRARY',
+-         'CBLAS_CFLAGS',
++        ['CBLAS_CFLAGS',
+          ...,
+          'ZLIB_LIBRARIES']
+         sage: cython_aliases(required_modules=('module-that-is-assumed-to-not-exist'))
+@@ -475,8 +473,6 @@ def uname_specific(name, value, alternative):
+     if "LINBOX_CFLAGS" in aliases:
+         aliases["LINBOX_CFLAGS"].append("-std=gnu++11")
+ 
+-    aliases["ARB_LIBRARY"] = ARB_LIBRARY
+-
+     # TODO: Remove Cygwin hack by installing a suitable cblas.pc
+     if os.path.exists('/usr/lib/libblas.dll.a'):
+         aliases["CBLAS_LIBS"] = ['gslcblas']
+diff --git a/src/sage/features/sagemath.py b/src/sage/features/sagemath.py
+index bc34d35dd1c..4097d3512b9 100644
+--- a/src/sage/features/sagemath.py
++++ b/src/sage/features/sagemath.py
+@@ -777,7 +777,7 @@ class sage__rings__number_field(JoinFeature):
+     A :class:`~sage.features.Feature` describing the presence of :mod:`sage.rings.number_field`.
+ 
+     Number fields are implemented in Sage using a complicated mixture of various libraries,
+-    including :ref:`arb <spkg_arb>`, :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
++    including :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
+     :ref:`MPFI <spkg_mpfi>`, :ref:`NTL <spkg_ntl>`, and :ref:`PARI <spkg_pari>`.
+ 
+     EXAMPLES:
+diff --git a/src/sage/libs/arb/acb.pxd b/src/sage/libs/arb/acb.pxd
+index 5148dc43991..851488d803a 100644
+--- a/src/sage/libs/arb/acb.pxd
++++ b/src/sage/libs/arb/acb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -152,10 +152,6 @@ cdef extern from "arb_wrap.h":
+     void acb_sech(acb_t s, const acb_t z, long prec)
+     void acb_csch(acb_t c, const acb_t z, long prec)
+ 
+-    void acb_rising_ui_bs(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui_rs(acb_t z, const acb_t x, unsigned long n, unsigned long step, long prec)
+-    void acb_rising_ui_rec(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui(acb_t z, const acb_t x, unsigned long n, long prec)
+     void acb_rising(acb_t z, const acb_t x, const acb_t n, long prec)
+ 
+     void acb_gamma(acb_t y, const acb_t x, long prec)
+diff --git a/src/sage/libs/arb/acb_calc.pxd b/src/sage/libs/arb/acb_calc.pxd
+index a5dbf360b5e..67bd2ed57dc 100644
+--- a/src/sage/libs/arb/acb_calc.pxd
++++ b/src/sage/libs/arb/acb_calc.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_calc.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_elliptic.pxd b/src/sage/libs/arb/acb_elliptic.pxd
+index 176f68df00e..e3480e9f73b 100644
+--- a/src/sage/libs/arb/acb_elliptic.pxd
++++ b/src/sage/libs/arb/acb_elliptic.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_elliptic.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_hypgeom.pxd b/src/sage/libs/arb/acb_hypgeom.pxd
+index 418e766f10d..c43e5c0623b 100644
+--- a/src/sage/libs/arb/acb_hypgeom.pxd
++++ b/src/sage/libs/arb/acb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_hypgeom.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_modular.pxd b/src/sage/libs/arb/acb_modular.pxd
+index c708e9bf97d..cdc413c92da 100644
+--- a/src/sage/libs/arb/acb_modular.pxd
++++ b/src/sage/libs/arb/acb_modular.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_modular.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_poly.pxd b/src/sage/libs/arb/acb_poly.pxd
+index 69f4320055b..ae02757ffd9 100644
+--- a/src/sage/libs/arb/acb_poly.pxd
++++ b/src/sage/libs/arb/acb_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -79,24 +79,10 @@ cdef extern from "arb_wrap.h":
+     void _acb_poly_divrem(acb_ptr Q, acb_ptr R, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec)
+     bint acb_poly_divrem(acb_poly_t Q, acb_poly_t R, const acb_poly_t A, const acb_poly_t B, long prec)
+     void _acb_poly_div_root(acb_ptr Q, acb_t R, acb_srcptr A, long len, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_horner(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_horner(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_divconquer(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_divconquer(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_convolution(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_convolution(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+     void _acb_poly_taylor_shift(acb_ptr g, const acb_t c, long n, long prec)
+     void acb_poly_taylor_shift(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_compose_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_divconquer(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_divconquer(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+     void _acb_poly_compose(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+     void acb_poly_compose(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_series_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+-    void _acb_poly_compose_series_brent_kung(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_brent_kung(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_compose_series(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+     void acb_poly_compose_series(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_revert_series_lagrange(acb_ptr h, acb_srcptr f, long flen, long n, long prec)
+@@ -161,10 +147,6 @@ cdef extern from "arb_wrap.h":
+     void acb_poly_exp_series_basecase(acb_poly_t f, const acb_poly_t h, long n, long prec)
+     void _acb_poly_exp_series(acb_ptr f, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_exp_series(acb_poly_t f, const acb_poly_t h, long n, long prec)
+-    void _acb_poly_sin_cos_series_basecase(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_basecase(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+-    void _acb_poly_sin_cos_series_tangent(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_tangent(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+     void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_sin_cos_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec)
+     void _acb_poly_sin_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec)
+diff --git a/src/sage/libs/arb/arb.pxd b/src/sage/libs/arb/arb.pxd
+index c82b94de30f..acd232ab816 100644
+--- a/src/sage/libs/arb/arb.pxd
++++ b/src/sage/libs/arb/arb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -224,15 +224,8 @@ cdef extern from "arb_wrap.h":
+ 
+     void arb_lambertw(arb_t res, const arb_t x, int flags, long prec)
+ 
+-    void arb_rising_ui_bs(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui_rs(arb_t z, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising_ui_rec(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui(arb_t z, const arb_t x, unsigned long n, long prec)
+     void arb_rising(arb_t z, const arb_t x, const arb_t n, long prec)
+     void arb_rising_fmpq_ui(arb_t z, const fmpq_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_bs(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_rs(arb_t u, arb_t v, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising2_ui(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+     void arb_fac_ui(arb_t z, unsigned long n, long prec)
+     void arb_bin_ui(arb_t z, const arb_t n, unsigned long k, long prec)
+     void arb_bin_uiui(arb_t z, unsigned long n, unsigned long k, long prec)
+diff --git a/src/sage/libs/arb/arb_fmpz_poly.pxd b/src/sage/libs/arb/arb_fmpz_poly.pxd
+index 079f76e9d9e..55daa705238 100644
+--- a/src/sage/libs/arb/arb_fmpz_poly.pxd
++++ b/src/sage/libs/arb/arb_fmpz_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_fmpz_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -22,5 +22,4 @@ cdef extern from "arb_wrap.h":
+     unsigned long arb_fmpz_poly_deflation(const fmpz_poly_t poly)
+     void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long deflation)
+     void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, long prec)
+-    void arb_fmpz_poly_cos_minpoly(fmpz_poly_t res, unsigned long n)
+     void arb_fmpz_poly_gauss_period_minpoly(fmpz_poly_t res, unsigned long q, unsigned long n)
+diff --git a/src/sage/libs/arb/arb_hypgeom.pxd b/src/sage/libs/arb/arb_hypgeom.pxd
+index fb1c40ddaa8..139b987d669 100644
+--- a/src/sage/libs/arb/arb_hypgeom.pxd
++++ b/src/sage/libs/arb/arb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_hypgeom.h
+ 
+ from sage.libs.flint.types cimport fmpz_t
+diff --git a/src/sage/libs/arb/arb_wrap.h b/src/sage/libs/arb/arb_wrap.h
+index 49997075ee5..488bb376d5e 100644
+--- a/src/sage/libs/arb/arb_wrap.h
++++ b/src/sage/libs/arb/arb_wrap.h
+@@ -5,25 +5,27 @@
+  * by arb, most of which rely on flint's ulong and slong defines.
+  */
+ 
++#include <mpfr.h>
++
+ #undef ulong
+ #undef slong
+ 
+ #define ulong mp_limb_t
+ #define slong mp_limb_signed_t
+ 
+-#include <acb.h>
+-#include <acb_calc.h>
+-#include <acb_elliptic.h>
+-#include <acb_hypgeom.h>
+-#include <acb_mat.h>
+-#include <acb_modular.h>
+-#include <acb_poly.h>
+-#include <arb.h>
+-#include <arb_fmpz_poly.h>
+-#include <arb_hypgeom.h>
+-#include <arf.h>
+-#include <bernoulli.h>
+-#include <mag.h>
++#include <flint/acb.h>
++#include <flint/acb_calc.h>
++#include <flint/acb_elliptic.h>
++#include <flint/acb_hypgeom.h>
++#include <flint/acb_mat.h>
++#include <flint/acb_modular.h>
++#include <flint/acb_poly.h>
++#include <flint/arb.h>
++#include <flint/arb_fmpz_poly.h>
++#include <flint/arb_hypgeom.h>
++#include <flint/arf.h>
++#include <flint/bernoulli.h>
++#include <flint/mag.h>
+ 
+ #undef ulong
+ #undef slong
+diff --git a/src/sage/libs/arb/arf.pxd b/src/sage/libs/arb/arf.pxd
+index b8b83fefcdc..84778fe9f09 100644
+--- a/src/sage/libs/arb/arf.pxd
++++ b/src/sage/libs/arb/arf.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arf.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -30,7 +30,6 @@ cdef extern from "arb_wrap.h":
+     void arf_set_ui(arf_t y, unsigned long x)
+     void arf_set_si(arf_t y, long x)
+     void arf_set_mpfr(arf_t y, const mpfr_t x)
+-    # void arf_set_fmpr(arf_t y, const fmpr_t x)
+     void arf_set_d(arf_t y, double x)
+     void arf_swap(arf_t y, arf_t x)
+     void arf_init_set_ui(arf_t y, unsigned long x)
+@@ -46,7 +45,6 @@ cdef extern from "arb_wrap.h":
+     int arf_set_round_fmpz_2exp(arf_t y, const fmpz_t x, const fmpz_t e, long prec, arf_rnd_t rnd)
+     void arf_get_fmpz_2exp(fmpz_t m, fmpz_t e, const arf_t x)
+     double arf_get_d(const arf_t x, arf_rnd_t rnd)
+-    # void arf_get_fmpr(fmpr_t y, const arf_t x)
+     int arf_get_mpfr(mpfr_t y, const arf_t x, mpfr_rnd_t rnd)
+     void arf_get_fmpz(fmpz_t z, const arf_t x, arf_rnd_t rnd)
+     long arf_get_si(const arf_t x, arf_rnd_t rnd)
+diff --git a/src/sage/libs/arb/bernoulli.pxd b/src/sage/libs/arb/bernoulli.pxd
+index f859ebfb8d7..95a84dd5179 100644
+--- a/src/sage/libs/arb/bernoulli.pxd
++++ b/src/sage/libs/arb/bernoulli.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = bernoulli.h
+ 
+ from sage.libs.flint.types cimport fmpq_t, ulong
+diff --git a/src/sage/libs/arb/mag.pxd b/src/sage/libs/arb/mag.pxd
+index d5d8693ea8f..69dfb990ae0 100644
+--- a/src/sage/libs/arb/mag.pxd
++++ b/src/sage/libs/arb/mag.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = mag.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -27,13 +27,11 @@ cdef extern from "arb_wrap.h":
+     # void mag_randtest(mag_t x, flint_rand_t state, long expbits)
+     # void mag_randtest_special(mag_t x, flint_rand_t state, long expbits)
+     void mag_set_d(mag_t y, double x)
+-    # void mag_set_fmpr(mag_t y, const fmpr_t x)
+     void mag_set_ui(mag_t y, unsigned long x)
+     void mag_set_fmpz(mag_t y, const fmpz_t x)
+     void mag_set_d_2exp_fmpz(mag_t z, double x, const fmpz_t y)
+     void mag_set_fmpz_2exp_fmpz(mag_t z, const fmpz_t x, const fmpz_t y)
+     void mag_set_ui_2exp_si(mag_t z, unsigned long x, long y)
+-    # void mag_get_fmpr(fmpr_t y, const mag_t x)
+     void mag_get_fmpq(fmpq_t y, const mag_t x)
+     void mag_set_ui_lower(mag_t z, unsigned long x)
+     void mag_set_fmpz_lower(mag_t z, const fmpz_t x)
+diff --git a/src/sage/libs/flint/flint_wrap.h b/src/sage/libs/flint/flint_wrap.h
+index 266535c3835..4db72b97660 100644
+--- a/src/sage/libs/flint/flint_wrap.h
++++ b/src/sage/libs/flint/flint_wrap.h
+@@ -15,6 +15,7 @@
+  */
+ 
+ #include <gmp.h>
++#include <mpfr.h>
+ 
+ /* Save previous definition of ulong if any, as pari also uses it */
+ /* Should work on GCC, clang, MSVC */
+@@ -33,6 +34,7 @@
+ 
+ #include <flint/arith.h>
+ #include <flint/fmpq.h>
++#include <flint/fmpq_vec.h>
+ #include <flint/fmpq_mat.h>
+ #include <flint/fmpq_poly.h>
+ #include <flint/fmpz.h>
+@@ -47,6 +49,7 @@
+ #include <flint/fq.h>
+ #include <flint/fq_nmod.h>
+ #include <flint/nmod_poly.h>
++#include <flint/nmod_poly_factor.h>
+ #include <flint/nmod_vec.h>
+ #include <flint/padic.h>
+ #include <flint/padic_poly.h>
+diff --git a/src/sage/libs/flint/fmpq.pxd b/src/sage/libs/flint/fmpq.pxd
+index 5e64c82102f..0616c0a7408 100644
+--- a/src/sage/libs/flint/fmpq.pxd
++++ b/src/sage/libs/flint/fmpq.pxd
+@@ -12,6 +12,8 @@ cdef extern from "flint_wrap.h":
+     fmpz * fmpq_denref(fmpq_t)
+     void fmpq_init(fmpq_t)
+     void fmpq_clear(fmpq_t)
++    void fmpq_init_set_readonly(fmpq_t, const mpq_t)
++    void fmpq_clear_readonly(fmpq_t)
+     void fmpq_one(fmpq_t)
+     void fmpq_zero(fmpq_t)
+     bint fmpq_is_zero(fmpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pxd b/src/sage/libs/flint/fmpq_poly.pxd
+index 6050c487835..afa16e5bbdd 100644
+--- a/src/sage/libs/flint/fmpq_poly.pxd
++++ b/src/sage/libs/flint/fmpq_poly.pxd
+@@ -30,6 +30,9 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_canonicalise(fmpq_poly_t)
+     int fmpq_poly_is_canonical(const fmpq_poly_t)
+ 
++    void _fmpq_poly_set_length(fmpq_poly_t, slong)
++    void _fmpq_poly_normalise(fmpq_poly_t)
++
+     # Polynomial parameters
+     slong fmpq_poly_degree(const fmpq_poly_t)
+     ulong fmpq_poly_length(const fmpq_poly_t)
+@@ -46,10 +49,7 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_ui(fmpq_poly_t, ulong)
+     void fmpq_poly_set_fmpz(fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_set_fmpq(fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+     void fmpq_poly_set_fmpz_poly(fmpq_poly_t, const fmpz_poly_t)
+-    void fmpq_poly_set_array_mpq(fmpq_poly_t, const mpq_t *, slong)
+ 
+     void fmpq_poly_set_str(fmpq_poly_t, const char *)
+     char *fmpq_poly_get_str(const fmpq_poly_t)
+@@ -67,7 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_reverse(fmpq_poly_t, const fmpq_poly_t, slong)
+ 
+     void fmpq_poly_get_coeff_fmpq(fmpq_t, const fmpq_poly_t, slong)
+-    void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_si(slong, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_ui(ulong, const fmpq_poly_t, slong)
+ 
+@@ -75,8 +74,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_coeff_ui(fmpq_poly_t, slong, ulong)
+     void fmpq_poly_set_coeff_fmpz(fmpq_poly_t, slong, const fmpz_t)
+     void fmpq_poly_set_coeff_fmpq(fmpq_poly_t, slong, const fmpq_t)
+-    void fmpq_poly_set_coeff_mpz(fmpq_poly_t, slong, const mpz_t)
+-    void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
+ 
+     # Comparison
+     int fmpq_poly_equal(const fmpq_poly_t, const fmpq_poly_t)
+@@ -100,8 +97,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_mul_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     void fmpq_poly_scalar_div_si(fmpq_poly_t, const fmpq_poly_t, slong)
+     void fmpq_poly_scalar_div_ui(fmpq_poly_t, const fmpq_poly_t, ulong)
+@@ -109,8 +104,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_div_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_div_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_div_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Multiplication
+     void fmpq_poly_mul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -155,8 +148,6 @@ cdef extern from "flint_wrap.h":
+     # Evaluation
+     void fmpq_poly_evaluate_fmpz(fmpq_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_evaluate_fmpq(fmpq_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_evaluate_mpz(mpq_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_evaluate_mpq(mpq_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Composition
+     void fmpq_poly_compose(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -189,3 +180,11 @@ cdef extern from "flint_wrap.h":
+ # since the fmpq_poly header seems to be lacking this inline function
+ cdef inline sage_fmpq_poly_max_limbs(const fmpq_poly_t poly) noexcept:
+     return _fmpz_vec_max_limbs(fmpq_poly_numref(poly), fmpq_poly_length(poly))
++
++# functions removed from flint but still needed in sage
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
++cdef void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
++cdef void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pyx b/src/sage/libs/flint/fmpq_poly.pyx
+new file mode 100644
+index 00000000000..3b8a0cf0c51
+--- /dev/null
++++ b/src/sage/libs/flint/fmpq_poly.pyx
+@@ -0,0 +1,45 @@
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++from sage.libs.gmp.mpq cimport *
++from sage.libs.flint.fmpz cimport *
++from sage.libs.flint.fmpq cimport *
++
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t rop, const fmpq_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t rop, const fmpq_poly_t op, const mpq_t c):
++    cdef fmpq_t f
++    fmpq_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpq(rop, op, f)
++    fmpq_clear_readonly(f)
++
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t poly, slong n, const mpq_t x):
++    cdef fmpq_t t
++    fmpq_init_set_readonly(t, x)
++    fmpq_poly_set_coeff_fmpq(poly, n, t)
++    fmpq_clear_readonly(t)
++
++cdef void fmpq_poly_get_coeff_mpq(mpq_t x, const fmpq_poly_t poly, slong n):
++    cdef fmpq_t t
++    fmpq_init(t)
++    fmpq_poly_get_coeff_fmpq(t, poly, n)
++    fmpq_get_mpq(x, t)
++    fmpq_clear(t)
++
++cdef void fmpq_poly_set_mpq(fmpq_poly_t poly, const mpq_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), mpq_numref(x))
++    fmpz_set_mpz(fmpq_poly_denref(poly), mpq_denref(x))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
++
++cdef void fmpq_poly_set_mpz(fmpq_poly_t poly, const mpz_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), x)
++    fmpz_one(fmpq_poly_denref(poly))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz.pxd b/src/sage/libs/flint/fmpz.pxd
+index 01058d0f130..b97fbe1eae0 100644
+--- a/src/sage/libs/flint/fmpz.pxd
++++ b/src/sage/libs/flint/fmpz.pxd
+@@ -16,6 +16,9 @@ cdef extern from "flint_wrap.h":
+     void fmpz_init_set(fmpz_t, fmpz_t)
+     void fmpz_init_set_ui(fmpz_t, ulong)
+ 
++    void fmpz_init_set_readonly(fmpz_t, const mpz_t)
++    void fmpz_clear_readonly(fmpz_t)
++
+     # Conversion
+     void fmpz_set(fmpz_t f, fmpz_t g)
+     void fmpz_set_ui(fmpz_t, ulong)
+diff --git a/src/sage/libs/flint/fmpz_mod_poly.pxd b/src/sage/libs/flint/fmpz_mod_poly.pxd
+index 24b653eb3b7..2727246da98 100644
+--- a/src/sage/libs/flint/fmpz_mod_poly.pxd
++++ b/src/sage/libs/flint/fmpz_mod_poly.pxd
+@@ -67,13 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_get_coeff_fmpz(fmpz_t x, const fmpz_mod_poly_t poly,
+                                              slong n, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_set_coeff_mpz(fmpz_mod_poly_t poly,
+-                             slong n, const mpz_t x, const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_get_coeff_mpz(mpz_t x,
+-                 const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx)
+-
+-
+     void _fmpz_mod_poly_shift_left(fmpz * res, const fmpz * poly,
+                                                            slong len, slong n)
+ 
+@@ -194,14 +187,6 @@ cdef extern from "flint_wrap.h":
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_div_basecase(fmpz_mod_poly_t Q,
+-                            const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_div_newton_n_preinv(fmpz_mod_poly_t Q,
+-                         const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                         const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem_newton_n_preinv(fmpz_mod_poly_t Q,
+           fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                          const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+@@ -213,10 +198,6 @@ cdef extern from "flint_wrap.h":
+                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_divrem_divconquer(fmpz_mod_poly_t Q,
+-        fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem(fmpz_mod_poly_t Q, fmpz_mod_poly_t R,
+     const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+@@ -254,40 +235,13 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_make_monic_f(fmpz_t f, fmpz_mod_poly_t res,
+                          const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_euclidean(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_gcd_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_hgcd(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-
+     void fmpz_mod_poly_gcd(fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+ 
+-    void fmpz_mod_poly_xgcd_euclidean(fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_hgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S,
+-          fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_xgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                       const fmpz_mod_ctx_t ctx)
+@@ -361,14 +315,6 @@ cdef extern from "flint_wrap.h":
+                         const fmpz_mod_poly_t poly, const fmpz * xs, slong n,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_compose_horner(fmpz_mod_poly_t res,
+-                    const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_compose_divconquer(fmpz_mod_poly_t res,
+-                     const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_compose(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1,
+                          const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx)
+ 
+diff --git a/src/sage/libs/flint/fmpz_poly.pxd b/src/sage/libs/flint/fmpz_poly.pxd
+index 18b36672d30..c8bc6d3ca0a 100644
+--- a/src/sage/libs/flint/fmpz_poly.pxd
++++ b/src/sage/libs/flint/fmpz_poly.pxd
+@@ -28,7 +28,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_poly_set_ui(fmpz_poly_t, ulong)
+     void fmpz_poly_set_si(fmpz_poly_t, slong)
+     void fmpz_poly_set_fmpz(fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+     int fmpz_poly_set_str(fmpz_poly_t, const char *)
+ 
+     char *fmpz_poly_get_str(const fmpz_poly_t)
+@@ -70,7 +69,6 @@ cdef extern from "flint_wrap.h":
+     # Scalar multiplication and division
+     void fmpz_poly_scalar_mul_fmpz(
+             fmpz_poly_t, const fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+     void fmpz_poly_scalar_mul_si(fmpz_poly_t, const fmpz_poly_t, slong)
+     void fmpz_poly_scalar_mul_ui(fmpz_poly_t, const fmpz_poly_t, ulong)
+     void fmpz_poly_scalar_mul_2exp(fmpz_poly_t, const fmpz_poly_t, ulong)
+@@ -310,12 +308,14 @@ cdef extern from "flint_wrap.h":
+             fmpz_poly_t,
+                     const fmpz_poly_t, const fmpz_t, const nmod_poly_t, int)
+ 
+-    # Some functions for backwards compatibility
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
+-    void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++
++# functions removed from flint but still needed in sage
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
++cdef void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++cdef void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+ 
+ 
+ # Wrapper Cython class
+diff --git a/src/sage/libs/flint/fmpz_poly.pyx b/src/sage/libs/flint/fmpz_poly.pyx
+index 74915b37612..cfcbea9090c 100644
+--- a/src/sage/libs/flint/fmpz_poly.pyx
++++ b/src/sage/libs/flint/fmpz_poly.pyx
+@@ -25,10 +25,10 @@ from cysignals.memory cimport sig_free
+ 
+ from sage.arith.long cimport pyobject_to_long
+ from sage.cpython.string cimport char_to_str, str_to_bytes
++from sage.libs.flint.fmpz cimport *
+ from sage.structure.sage_object cimport SageObject
+ from sage.rings.integer cimport Integer
+ 
+-
+ cdef class Fmpz_poly(SageObject):
+ 
+     def __cinit__(self):
+@@ -455,3 +455,44 @@ cdef class Fmpz_poly(SageObject):
+         """
+         from sage.rings.integer_ring import ZZ
+         return ZZ[var](self.list())
++
++
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_divexact_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_fdiv_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t poly, slong n, const mpz_t x):
++    cdef fmpz_t t
++    fmpz_init_set_readonly(t, x)
++    fmpz_poly_set_coeff_fmpz(poly, n, t)
++    fmpz_clear_readonly(t)
++
++cdef void fmpz_poly_get_coeff_mpz(mpz_t x, const fmpz_poly_t poly, slong n):
++    cdef fmpz_t t
++    fmpz_init(t)
++    fmpz_poly_get_coeff_fmpz(t, poly, n)
++    fmpz_get_mpz(x, t)
++    fmpz_clear(t)
++
++cdef void fmpz_poly_set_mpz(fmpz_poly_t poly, const mpz_t x):
++    fmpz_poly_fit_length(poly, 1)
++    fmpz_set_mpz(poly.coeffs, x)
++    _fmpz_poly_set_length(poly, 1)
++    _fmpz_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz_poly_q.pxd b/src/sage/libs/flint/fmpz_poly_q.pxd
+index 846542dc0d8..63c13355bf6 100644
+--- a/src/sage/libs/flint/fmpz_poly_q.pxd
++++ b/src/sage/libs/flint/fmpz_poly_q.pxd
+@@ -49,11 +49,7 @@ cdef extern from "flint_wrap.h":
+ 
+     #* Scalar multiplication and division ****************************************/
+     void fmpz_poly_q_scalar_mul_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_mul_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_mul_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+     void fmpz_poly_q_scalar_div_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_div_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_div_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+ 
+     #* Multiplication and division ***********************************************/
+     void fmpz_poly_q_mul(fmpz_poly_q_t rop, 
+@@ -67,9 +63,6 @@ cdef extern from "flint_wrap.h":
+     #* Derivative ****************************************************************/
+     void fmpz_poly_q_derivative(fmpz_poly_q_t rop, const fmpz_poly_q_t op)
+ 
+-    #* Evaluation ****************************************************************/
+-    int fmpz_poly_q_evaluate(mpq_t rop, const fmpz_poly_q_t f, const mpq_t a)
+-
+     #* Input and output **********************************************************/
+     int fmpz_poly_q_set_str(fmpz_poly_q_t rop, const char *s)
+     char * fmpz_poly_q_get_str(const fmpz_poly_q_t op)
+diff --git a/src/sage/libs/linbox/linbox_flint_interface.pyx b/src/sage/libs/linbox/linbox_flint_interface.pyx
+index 1979ac0f0a4..37a340c457f 100644
+--- a/src/sage/libs/linbox/linbox_flint_interface.pyx
++++ b/src/sage/libs/linbox/linbox_flint_interface.pyx
+@@ -33,6 +33,7 @@ and C. Pernet. The functions available are:
+ #                  https://www.gnu.org/licenses/
+ # ****************************************************************************
+ 
++from sage.libs.gmp.types cimport mpz_t
+ from sage.libs.flint.types cimport fmpz_t
+ from sage.libs.flint.fmpz cimport fmpz_get_mpz, fmpz_set_mpz
+ from sage.libs.flint.fmpz_mat cimport fmpz_mat_entry, fmpz_mat_nrows, fmpz_mat_ncols
+@@ -80,11 +81,13 @@ cdef void fmpz_poly_set_linbox(fmpz_poly_t p, PolynomialRing_integer.Element& q)
+     (the .pxd file) in order to keep the header C-compatible
+     """
+     cdef size_t i
++    cdef mpz_t tmp
+ 
+     fmpz_poly_fit_length(p, q.size())
+ 
+     for i in range(q.size()):
+-        fmpz_poly_set_coeff_mpz(p, i, q[i].get_mpz_const())
++        tmp = q[i].get_mpz_const()
++        fmpz_poly_set_coeff_mpz(p, i, tmp)
+ 
+     _fmpz_poly_set_length(p, q.size())
+ 
+diff --git a/src/sage/matrix/matrix_complex_ball_dense.pyx b/src/sage/matrix/matrix_complex_ball_dense.pyx
+index e5414abdd9e..2f0131f4064 100644
+--- a/src/sage/matrix/matrix_complex_ball_dense.pyx
++++ b/src/sage/matrix/matrix_complex_ball_dense.pyx
+@@ -1,4 +1,4 @@
+-# distutils: libraries = ARB_LIBRARY
++# distutils: libraries = flint
+ r"""
+ Arbitrary precision complex ball matrices using Arb
+ 
+diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx
+index 27f5cdfac0f..6c5c20dbc6b 100644
+--- a/src/sage/matrix/matrix_integer_sparse.pyx
++++ b/src/sage/matrix/matrix_integer_sparse.pyx
+@@ -847,6 +847,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+             sage: matrix(ZZ, 1, 1, sparse=True)._charpoly_linbox()
+             x
+         """
++        cdef mpz_t tmp
+         if self._nrows != self._ncols:
+             raise ArithmeticError('only valid for square matrix')
+ 
+@@ -869,7 +870,8 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         cdef size_t i
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+@@ -966,9 +968,11 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         sig_off()
+ 
+         cdef size_t i
++        cdef mpz_t tmp
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
+index 1e3085c9215..0786de7fc81 100644
+--- a/src/sage/rings/complex_arb.pyx
++++ b/src/sage/rings/complex_arb.pyx
+@@ -1360,12 +1360,13 @@ cdef class ComplexBall(RingElement):
+             sage: CBF100(-3r)
+             -3.000000000000000000000000000000
+ 
+-            sage: ComplexBall(CBF100, 10^100)
+-            1.000000000000000000000000000000e+100
+             sage: ComplexBall(CBF100, CIF(1, 2))
+             1.000000000000000000000000000000 + 2.000000000000000000000000000000*I
+             sage: ComplexBall(CBF100, RBF(1/3), RBF(1))
+             [0.3333333333333333 +/- ...e-17] + 1.000000000000000000000000000000*I
++            sage: ComplexBall(CBF100, 10^100)
++            [1.000000000000000000000000000000e+100 +/- ...]
++
+             sage: NF.<a> = QuadraticField(-1, embedding=CC(0, -1))
+             sage: CBF(a)
+             -1.000000000000000*I
+@@ -3009,7 +3010,7 @@ cdef class ComplexBall(RingElement):
+             sage: CBF(1).rising_factorial(2**64)
+             [+/- ...e+347382171326740403407]
+             sage: ComplexBallField(128)(1).rising_factorial(2**64)
+-            [2.343691126796861348e+347382171305201285713 +/- ...e+347382171305201285694]
++            [2.34369112679686134...e+347382171305201285713 +/- ...]
+             sage: CBF(1/2).rising_factorial(CBF(2,3)) # abs tol 1e-15
+             [-0.123060451458124 +/- 3.06e-16] + [0.0406412631676552 +/- 7.57e-17]*I
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+index 04eaefc9fed..d99f0d3b98c 100644
+--- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+@@ -222,7 +222,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef unsigned long n
+         cdef Rational c
+         cdef list L1
+-        cdef mpq_t * L2
++        cdef fmpq_t q
+ 
+         Polynomial.__init__(self, parent, is_gen=is_gen)
+ 
+@@ -253,14 +253,11 @@ cdef class Polynomial_rational_flint(Polynomial):
+             L1 = [e if isinstance(e, Rational) else Rational(e) for e in x]
+             n  = <unsigned long> len(x)
+             sig_on()
+-            L2 = <mpq_t *> check_allocarray(n, sizeof(mpq_t))
++            fmpq_poly_fit_length(self._poly, n)
+             for deg from 0 <= deg < n:
+-                mpq_init(L2[deg])
+-                mpq_set(L2[deg], (<Rational> L1[deg]).value)
+-            fmpq_poly_set_array_mpq(self._poly, L2, n)
+-            for deg from 0 <= deg < n:
+-                mpq_clear(L2[deg])
+-            sig_free(L2)
++                fmpq_init_set_readonly(q, (<Rational> L1[deg]).value)
++                fmpq_poly_set_coeff_fmpq(self._poly, deg, q)
++                fmpq_clear_readonly(q)
+             sig_off()
+ 
+ #           deg = 0
+@@ -435,6 +432,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         utmost care.
+         """
+         cdef bint do_sig = _do_sig(self._poly)
++        cdef fmpz_t tmpfz
+ 
+         if isinstance(value, int):
+             if do_sig: sig_str("FLINT exception")
+@@ -442,7 +440,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+             if do_sig: sig_off()
+         elif isinstance(value, Integer):
+             if do_sig: sig_str("FLINT exception")
+-            fmpq_poly_set_coeff_mpz(self._poly, n, (<Integer> value).value)
++            fmpz_init_set_readonly(tmpfz, (<Integer> value).value)
++            fmpq_poly_set_coeff_fmpz(self._poly, n, tmpfz)
++            fmpz_clear_readonly(tmpfz)
+             if do_sig: sig_off()
+         elif isinstance(value, Rational):
+             if do_sig: sig_str("FLINT exception")
+@@ -492,7 +492,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef Polynomial_rational_flint f
+         cdef Rational r
+         cdef fmpz_t tmpfz
+-        cdef fmpq_t tmpfq
++        cdef fmpq_t tmpfq, tmpfq1
+         cdef RealBall arb_a, arb_z
+         cdef ComplexBall acb_a, acb_z
+ 
+@@ -508,13 +508,23 @@ cdef class Polynomial_rational_flint(Polynomial):
+             elif isinstance(a, Rational):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpq(r.value, self._poly, (<Rational> a).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> a).value)
++                fmpq_init(tmpfq1)
++                fmpq_poly_evaluate_fmpq(tmpfq1, self._poly, tmpfq)
++                fmpq_get_mpq(r.value, tmpfq1)
++                fmpq_clear(tmpfq1)
++                fmpq_clear_readonly(tmpfq)
+                 sig_off()
+                 return r
+             elif isinstance(a, Integer):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpz(r.value, self._poly, (<Integer> a).value)
++                fmpz_init_set_readonly(tmpfz, (<Integer> a).value)
++                fmpq_init(tmpfq)
++                fmpq_poly_evaluate_fmpz(tmpfq, self._poly, tmpfz)
++                fmpq_get_mpq(r.value, tmpfq)
++                fmpq_clear(tmpfq)
++                fmpz_clear_readonly(tmpfz)
+                 sig_off()
+                 return r
+             elif isinstance(a, int):
+@@ -1321,6 +1331,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         """
+         cdef Polynomial_rational_flint res
+         cdef bint do_sig
++        cdef fmpq_t tmpfq
+ 
+         if right == 0:
+             raise ZeroDivisionError("division by zero polynomial")
+@@ -1331,8 +1342,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+                 do_sig = _do_sig(self._poly)
+ 
+                 if do_sig: sig_str("FLINT exception")
+-                fmpq_poly_scalar_div_mpq(res._poly, self._poly,
+-                                                  (<Rational> QQ(right)).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> QQ(right)).value)
++                fmpq_poly_scalar_div_fmpq(res._poly, self._poly, tmpfq)
++                fmpq_clear_readonly(tmpfq)
+                 if do_sig: sig_off()
+                 return res
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+index 6e7f7498329..3a66198d568 100644
+--- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+@@ -658,6 +658,11 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
+             ...
+             NotImplementedError: square free factorization of polynomials over rings with composite characteristic is not implemented
+ 
++        :trac:`20003`::
++
++            sage: P.<x> = GF(7)[]
++            sage: (6*x+3).squarefree_decomposition()
++            (6) * (x + 4)
+         """
+         if not self.base_ring().is_field():
+             raise NotImplementedError("square free factorization of polynomials over rings with composite characteristic is not implemented")
+diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
+index 17961ac36b2..8509b19cc66 100644
+--- a/src/sage/rings/real_arb.pyx
++++ b/src/sage/rings/real_arb.pyx
+@@ -898,7 +898,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+             sage: RBF.gamma(5)
+             24.00000000000000
+             sage: RBF.gamma(10**20)
+-            [+/- ...e+1956570552410610660600]
++            [1.932849514310098...+1956570551809674817225 +/- ...]
+             sage: RBF.gamma(1/3)
+             [2.678938534707747 +/- ...e-16]
+             sage: RBF.gamma(-5)
+@@ -1102,7 +1102,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+              15.00000000000000,
+              48.00000000000000]
+             sage: RBF.double_factorial(2**20)
+-            [1.4483729903e+2928836 +/- ...e+2928825]
++            [1.448372990...e+2928836 +/- ...]
+             sage: RBF.double_factorial(2**1000)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/schemes/plane_conics/con_rational_function_field.py b/src/sage/schemes/plane_conics/con_rational_function_field.py
+index 05d24e78a85..581102b5c5b 100644
+--- a/src/sage/schemes/plane_conics/con_rational_function_field.py
++++ b/src/sage/schemes/plane_conics/con_rational_function_field.py
+@@ -198,38 +198,6 @@ def has_rational_point(self, point=False, algorithm='default',
+             Fraction Field of Univariate Polynomial Ring in u over Rational
+             Field with modulus v^2 - u^3 - 1
+ 
+-        ``has_rational_point`` fails for some conics over function fields
+-        over finite fields, due to :trac:`20003`::
+-
+-            sage: K.<t> = PolynomialRing(GF(7))
+-            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
+-            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
+-            sage: C.has_rational_point()                                                # needs sage.libs.singular
+-            Traceback (most recent call last):
+-            ...
+-            TypeError: self (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (-t^3 + 3*t^2 - 2*t - 2)/(t + 3)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (t^2 + 3*t + 3)*x*y + (-2*t^2 - 2)*y^2 + (-t^2 + 3*t + 2)*x*z + (-3*t + 3)*y*z + (-3*t^2 + t - 2)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x + (2*t - 2)/(t + 3)*y + (3*t^4 + 2*t^3 - 2*t^2 - 2*t + 3)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z
+-                     : y + (-t^3 - t^2 + 3*t - 1)/(t^3 - 3*t^2 + 2*t + 2)*z : z))
+-            domain must equal right (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^3 - t^2 + 3*t + 3)*x^2 + (t - 3)*y^2 + (-t^7 + 2*t^5 + t^4 + 2*t^3 + 3*t^2 - t - 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    -2/(t^3 - 3*t^2 + 2*t + 2)*x^2 + 1/(t^3 + 3*t^2 - 2*t + 1)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^9 - 2*t^8 + t^7 - t^6 + 3*t^5 - 3*t^3 + t^2 - 2*t + 3)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    ((t^3 - 3*t^2 + 2*t + 2)*x : (t^2 - 2)*y : (t^5 - 3*t^4 + t^2 + 3*t + 3)*z))
+-            codomain
+-
+-
+-
+         TESTS::
+ 
+             sage: K.<t> = FractionField(PolynomialRing(QQ, 't'))
+@@ -250,6 +218,16 @@ def has_rational_point(self, point=False, algorithm='default',
+             sage: C.has_rational_point(point=True)  # long time (4 seconds)             # needs sage.libs.singular
+             (True,
+              ((-2/117*t^8 + 304/1053*t^7 + 40/117*t^6 - 1/27*t^5 - 110/351*t^4 - 2/195*t^3 + 11/351*t^2 + 1/117)/(t^4 + 2/39*t^3 + 4/117*t^2 + 2/39*t + 14/39) : -5/3*t^4 + 19*t^3 : 1))
++
++        ``has_rational_point`` used to fail for some conics over function fields
++        over finite fields, due to :trac:`20003`::
++
++            sage: K.<t> = PolynomialRing(GF(7))
++            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
++            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
++            sage: C.has_rational_point()
++            True
++
+         """
+         from .constructor import Conic
+ 
+diff --git a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+index a591cb4cd7c..a90f2050c59 100644
+--- a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
++++ b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+@@ -20,6 +20,7 @@
+ #include "utils.h"
+ 
+ #include "gmp.h"
++#include "flint/fmpz_poly.h"
+ #include "flint/fmpq_poly.h"
+ #include "flint/fmpq.h"
+ 
+@@ -63,7 +64,7 @@ static ex chebyt_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+@@ -122,7 +123,7 @@ static ex chebyu_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+diff --git a/src/sage/symbolic/ginac/useries.cpp b/src/sage/symbolic/ginac/useries.cpp
+index 40fbd7ab360..b9a8b867648 100644
+--- a/src/sage/symbolic/ginac/useries.cpp
++++ b/src/sage/symbolic/ginac/useries.cpp
+@@ -467,10 +467,17 @@ void add::useries(flint_series_t& fp, int order) const
+                 fmpq_poly_set_ui(fp.ft, 0);
+         else if (oc.is_long())
+                 fmpq_poly_set_si(fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ 
+         for (const auto & elem : seq) {
+ 		const ex& t = recombine_pair_to_ex(elem);
+@@ -505,10 +512,17 @@ void mul::useries(flint_series_t& fp, int order) const
+ 
+         if (oc.is_long())
+                 fmpq_poly_scalar_mul_si(fp.ft, fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_scalar_mul_mpz(fp.ft, fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_scalar_mul_mpq(fp.ft, fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_scalar_mul_fmpz(fp.ft, fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp.ft, fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ void power::useries(flint_series_t& fp, int order) const
+@@ -563,7 +577,10 @@ void power::useries(flint_series_t& fp, int order) const
+                 }
+                 check_poly_ccoeff_one(fp1);
+                 fmpq_poly_log_series(fp1.ft, fp1.ft, order);
+-                fmpq_poly_scalar_mul_mpq(fp1.ft, fp1.ft, nexp.as_mpq());
++                fmpq_t tmp;
++                fmpq_init_set_readonly(tmp, nexp.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp1.ft, fp1.ft, tmp);
++                fmpq_clear_readonly(tmp);
+                 fmpq_poly_exp_series(fp.ft, fp1.ft, order);
+                 return;
+         }
+@@ -608,10 +625,17 @@ void numeric::useries(flint_series_t& fp, int order) const
+ {
+         if (is_long())
+                 fmpq_poly_set_si(fp.ft, to_long());
+-        else if (is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, as_mpq());
++        else if (is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ } // namespace GiNaC
+diff --git a/src/sage_setup/library_order.py b/src/sage_setup/library_order.py
+index f40690f8d22..9ae0d2579a7 100644
+--- a/src/sage_setup/library_order.py
++++ b/src/sage_setup/library_order.py
+@@ -16,17 +16,12 @@
+ 
+ aliases = cython_aliases(required_modules=(), optional_modules=modules)
+ 
+-if "ARB_LIBRARY" in aliases:
+-    arb_dylib_names = [aliases["ARB_LIBRARY"]]
+-else:
+-    arb_dylib_names = []
+-
+ library_order_list = aliases.get("SINGULAR_LIBRARIES", []) + [
+     "giac", "intl", "curl",
+     "ec", "ecm"
+ ] + aliases.get("LINBOX_LIBRARIES", []) + aliases.get("FFLASFFPACK_LIBRARIES", []) + aliases.get("GSL_LIBRARIES", []) + [
+     "pari", "flint", "ecl", "glpk", "ppl",
+-] + arb_dylib_names + [
++] + [
+     "mpfi", "mpfr", "mpc", "ntl", "gmp", "gmpxx",
+     "brial",
+     "brial_groebner",
diff --git a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch b/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
deleted file mode 100644
index 7c55bce6e9bb4..0000000000000
--- a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
+++ /dev/null
@@ -1,221 +0,0 @@
-diff --git a/build/pkgs/singular/checksums.ini b/build/pkgs/singular/checksums.ini
-index 313463d2fea..1101fc55700 100644
---- a/build/pkgs/singular/checksums.ini
-+++ b/build/pkgs/singular/checksums.ini
-@@ -1,5 +1,5 @@
- tarball=singular-VERSION.tar.gz
--sha1=28bb3ee97ef48d04dfa96de182fd93eebe08426c
--md5=fc0a4f5720dadba45a52ee94324ce00c
--cksum=1573851737
--upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-1/singular-VERSION.tar.gz
-+sha1=df1997f412580f2073295aba569bb955ad227317
-+md5=50349213e206a18cdaa1bc410dde7ea4
-+cksum=376854707
-+upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-2/singular-VERSION.tar.gz
-diff --git a/build/pkgs/singular/package-version.txt b/build/pkgs/singular/package-version.txt
-index 66e2bede53a..9f1bf008217 100644
---- a/build/pkgs/singular/package-version.txt
-+++ b/build/pkgs/singular/package-version.txt
-@@ -1 +1 @@
--4.3.1p3
-+4.3.2p7
-diff --git a/build/pkgs/singular/spkg-configure.m4 b/build/pkgs/singular/spkg-configure.m4
-index 6a85631f624..f7621ec5fa1 100644
---- a/build/pkgs/singular/spkg-configure.m4
-+++ b/build/pkgs/singular/spkg-configure.m4
-@@ -6,14 +6,27 @@ SAGE_SPKG_CONFIGURE([singular], [
-     AS_IF([test -z "${SINGULAR_BIN}"], [sage_spkg_install_singular=yes], [
-       dnl Use pkg-config to ensure that Singular is new enough.
-       PKG_CHECK_MODULES([SINGULAR], [Singular >= 4.2.1], [
--       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)
--       ], [
--       AC_MSG_RESULT(no)
--       sage_spkg_install_singular=yes
--       ]
--      )], [
-+        AC_MSG_CHECKING([whether Singular is built with FLINT])
-+        AC_COMPILE_IFELSE([
-+          AC_LANG_PROGRAM([
-+            #include <singular/singularconfig.h>
-+            #if !defined(HAVE_FLINT)
-+            #  error "Need Singular compiled with FLINT"
-+          ], [])
-+        ], [
-+          AC_MSG_RESULT([yes])
-+          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)
-+          ], [
-+            AC_MSG_RESULT(no)
-+            sage_spkg_install_singular=yes
-+          ])
-+        ], [
-+          AC_MSG_RESULT([no])
-+          sage_spkg_install_singular=yes
-+        ])
-+      ], [
-       dnl pkg-config version check failed
-       sage_spkg_install_singular=yes
-       ])
-diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py
-index b15cc1c602c..4b5c76e2bfa 100644
---- a/src/sage/interfaces/singular.py
-+++ b/src/sage/interfaces/singular.py
-@@ -604,8 +604,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: i = singular.ideal(['x^2','y^2','z^2'])
-             sage: s = i.std()
-             sage: singular.eval('hilb(%s)'%(s.name()))
--            '// 1 t^0\n// -3 t^2\n// 3 t^4\n// -1 t^6\n\n// 1 t^0\n//
--            3 t^1\n// 3 t^2\n// 1 t^3\n// dimension (affine) = 0\n//
-+            '...// dimension (affine) = 0\n//
-             degree (affine) = 8'
- 
-         ::
-@@ -613,15 +612,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: from sage.misc.verbose import set_verbose
-             sage: set_verbose(1)
-             sage: o = singular.eval('hilb(%s)'%(s.name()))
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
- 
-         This is mainly useful if this method is called implicitly. Because
-@@ -631,15 +622,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-         ::
- 
-             sage: o = s.hilb()
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
-             // ** right side is not a datum, assignment ignored
-             ...
-diff --git a/src/sage/libs/singular/function.pyx b/src/sage/libs/singular/function.pyx
-index f40346d1fd0..c597c63aafe 100644
---- a/src/sage/libs/singular/function.pyx
-+++ b/src/sage/libs/singular/function.pyx
-@@ -1241,32 +1241,22 @@ cdef class SingularFunction(SageObject):
-             sage: I = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5])
-             sage: I = Ideal(I.groebner_basis())
-             sage: hilb = sage.libs.singular.function_factory.ff.hilb
--            sage: hilb(I) # Singular will print // ** _ is no standard basis
--            // ** _ is no standard basis
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: from sage.misc.sage_ostools import redirection
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I) # Singular will print // ** _ is no standard basis
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            True
- 
-         So we tell Singular that ``I`` is indeed a Groebner basis::
- 
--            sage: hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            False
- 
- 
-         TESTS:
-diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-index 22ada6de947..80352700872 100644
---- a/src/sage/rings/polynomial/multi_polynomial_ideal.py
-+++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-@@ -3132,13 +3132,16 @@ def hilbert_numerator(self, grading=None, algorithm='sage'):
-             sage: I.hilbert_numerator()                                                 # needs sage.rings.number_field
-             -t^5 + 1
- 
--        This example returns a wrong answer due to an integer overflow in Singular::
-+        This example returns a wrong answer in singular < 4.3.2p4 due to an integer overflow::
- 
-             sage: n=4; m=11; P = PolynomialRing(QQ, n*m, "x"); x = P.gens(); M = Matrix(n, x)
-             sage: I = P.ideal(M.minors(2))
-             sage: J = P * [m.lm() for m in I.groebner_basis()]
--            sage: J.hilbert_numerator(algorithm='singular')
--            ...120*t^33 - 3465*t^32 + 48180*t^31 - ...
-+            sage: J.hilbert_numerator(algorithm='singular') # known bug
-+            Traceback (most recent call last):
-+            ....
-+            RuntimeError: error in Singular function call 'hilb':
-+            overflow at t^22
- 
-         Our two algorithms should always agree; not tested until
-         :trac:`33178` is fixed::
-diff --git a/src/sage/sandpiles/sandpile.py b/src/sage/sandpiles/sandpile.py
-index 02d2021b2fb..c8e15e06f05 100644
---- a/src/sage/sandpiles/sandpile.py
-+++ b/src/sage/sandpiles/sandpile.py
-@@ -2493,9 +2493,15 @@ def _set_ideal(self):
-             sage: '_ideal' in S.__dict__
-             True
-         """
-+        from sage.libs.singular.function_factory import ff
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
-         R = self.ring()
--        I = self._unsaturated_ideal._singular_()
--        self._ideal = R.ideal(I.sat(prod(R.gens())._singular_())[1])
-+        I = self._unsaturated_ideal
-+        I_sat_gens = sat(I, prod(R.gens()))[0]
-+        self._ideal = R.ideal(I_sat_gens)
- 
-     def unsaturated_ideal(self):
-         r"""
-diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py
-index e6caf19ba74..afd6484d779 100644
---- a/src/sage/schemes/projective/projective_subscheme.py
-+++ b/src/sage/schemes/projective/projective_subscheme.py
-@@ -1001,7 +1001,10 @@ def dual(self):
-         for i in range(n + 1):
-             J = J + S.ideal(z[-1] * f_S.derivative(z[i]) - z[i + n + 1])
- 
--        sat = ff.elim__lib.sat
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
- 
-         max_ideal = S.ideal(z[n + 1: 2 * n + 2])
-         J_sat_gens = sat(J, max_ideal)[0]
diff --git a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch b/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
deleted file mode 100644
index 6a35ec3836550..0000000000000
--- a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-diff --git a/src/sage/ext/memory.pyx b/src/sage/ext/memory.pyx
-index 1de6dedab82..b95130b19dd 100644
---- a/src/sage/ext/memory.pyx
-+++ b/src/sage/ext/memory.pyx
-@@ -3,14 +3,14 @@ Low-level memory allocation functions
- 
- TESTS:
- 
--Check that a ``MemoryError`` is raised if we try to allocate a
-+Check that an error is raised if we try to allocate a
- ridiculously large integer, see :trac:`15363`::
- 
--    sage: 2^(2^63-3)
--    Traceback (most recent call last):
--    ...
--    OverflowError: exponent must be at most 2147483647         # 32-bit
--    RuntimeError: Aborted                                      # 64-bit
-+    sage: try:
-+    ....:     2^(2^63-3)
-+    ....: except (OverflowError, RuntimeError, FloatingPointError):
-+    ....:     print ('Overflow error')
-+    ...Overflow error
- 
- AUTHORS:
- 
-diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx
-index d5e87626d31..37ed9364845 100644
---- a/src/sage/rings/integer.pyx
-+++ b/src/sage/rings/integer.pyx
-@@ -6654,7 +6654,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
-             sage: try:
-             ....:     print('Possible error output from gmp', flush=True)
-             ....:     1 << (2^60)
--            ....: except (MemoryError, OverflowError, RuntimeError):
-+            ....: except (MemoryError, OverflowError, RuntimeError, FloatingPointError):
-             ....:     pass
-             ....: else:
-             ....:     print("Failed to raise exception")
diff --git a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch b/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
deleted file mode 100644
index 3d2a4bd9cd96f..0000000000000
--- a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
+++ /dev/null
@@ -1,740 +0,0 @@
-diff --git a/src/sage/ext_data/valgrind/valgrind-python.supp b/src/sage/ext_data/valgrind/valgrind-python.supp
-new file mode 100644
-index 00000000000..16aa2858484
---- /dev/null
-+++ b/src/sage/ext_data/valgrind/valgrind-python.supp
-@@ -0,0 +1,480 @@
-+# From the CPython repository with the suppressions for _PyObject_Free
-+# and _PyObject_Realloc enabled. See the upstream suppression file for
-+# details:
-+#
-+# https://github.com/python/cpython/blob/main/Misc/valgrind-python.supp
-+
-+# all tool names: Addrcheck,Memcheck,cachegrind,helgrind,massif
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 8 (x86_64 aka amd64)
-+   Memcheck:Value8
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:address_in_range
-+}
-+
-+#
-+# Leaks (including possible leaks)
-+#    Hmmm, I wonder if this masks some real leaks.  I think it does.
-+#    Will need to fix that.
-+#
-+
-+{
-+   Suppress leaking the GIL after a fork.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_allocate_lock
-+   fun:PyEval_ReInitThreads
-+}
-+
-+{
-+   Suppress leaking the autoTLSkey.  This looks like it shouldn't leak though.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_create_key
-+   fun:_PyGILState_Init
-+   fun:Py_InitializeEx
-+   fun:Py_Main
-+}
-+
-+{
-+   Hmmm, is this a real leak or like the GIL?
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_ReInitTLS
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:realloc
-+   fun:_PyObject_GC_Resize
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_New
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_NewVar
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+#
-+# Non-python specific leaks
-+#
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:calloc
-+   fun:allocate_dtv
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:memalign
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Realloc
-+}
-+
-+###
-+### All the suppressions below are for errors that occur within libraries
-+### that Python uses.  The problems to not appear to be related to Python's
-+### use of the libraries.
-+###
-+
-+{
-+   Generic ubuntu ld problems
-+   Memcheck:Addr8
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+}
-+
-+{
-+   Generic gentoo ld problems
-+   Memcheck:Cond
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_close
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Value8
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   GDBM problems, see test_gdbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   fun:gdbm_open
-+
-+}
-+
-+{
-+   Uninitialised byte(s) false alarm, see bpo-35561
-+   Memcheck:Param
-+   epoll_ctl(event)
-+   fun:epoll_ctl
-+   fun:pyepoll_internal_ctl
-+}
-+
-+{
-+   ZLIB problems, see test_gzip
-+   Memcheck:Cond
-+   obj:/lib/libz.so.1.2.3
-+   obj:/lib/libz.so.1.2.3
-+   fun:deflate
-+}
-+
-+{
-+   Avoid problems w/readline doing a putenv and leaking on exit
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:xmalloc
-+   fun:sh_set_lines_and_columns
-+   fun:_rl_get_screen_size
-+   fun:_rl_init_terminal_io
-+   obj:/lib/libreadline.so.4.3
-+   fun:rl_initialize
-+}
-+
-+# Valgrind emits "Conditional jump or move depends on uninitialised value(s)"
-+# false alarms on GCC builtin strcmp() function. The GCC code is correct.
-+#
-+# Valgrind bug: https://bugs.kde.org/show_bug.cgi?id=264936
-+{
-+   bpo-38118: Valgrind emits false alarm on GCC builtin strcmp()
-+   Memcheck:Cond
-+   fun:PyUnicode_Decode
-+}
-+
-+
-+###
-+### These occur from somewhere within the SSL, when running
-+###  test_socket_sll.  They are too general to leave on by default.
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:memset
-+###}
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:memset
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:MD5_Update
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:MD5_Update
-+###}
-+
-+# Fedora's package "openssl-1.0.1-0.1.beta2.fc17.x86_64" on x86_64
-+# See http://bugs.python.org/issue14171
-+{
-+   openssl 1.0.1 prng 1
-+   Memcheck:Cond
-+   fun:bcmp
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 2
-+   Memcheck:Cond
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 3
-+   Memcheck:Value8
-+   fun:_x86_64_AES_encrypt_compact
-+   fun:AES_encrypt
-+}
-+
-+#
-+# All of these problems come from using test_socket_ssl
-+#
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_bin2bn
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libcrypto.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_set_key_unchecked
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_encrypt2
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BUF_MEM_grow_clean
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:memcpy
-+   fun:ssl3_read_bytes
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:SHA1_Update
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:SHA1_Update
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-+{
-+   wcscmp_false_positive
-+   Memcheck:Addr8
-+   fun:wcscmp
-+   fun:_PyOS_GetOpt
-+   fun:Py_Main
-+   fun:main
-+}
-+
-+# Additional suppressions for the unified decimal tests:
-+{
-+   test_decimal
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_decimal2
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index b40ed64edb5..8c55861c147 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -1576,6 +1576,62 @@ const numeric numeric::div(const numeric &other) const {
-         }
- }
- 
-+
-+// Compute `a^b` as an integer, where a is an integer. Assign to ``res``` if it is integral, or return ``false``.
-+// The nonnegative real root is taken for even denominators. To be used inside numeric::integer_rational_power,
-+// to handle the special case of integral ``a``.
-+bool integer_rational_power_of_mpz(
-+        numeric& res,
-+        const numeric& a,
-+        const numeric& b
-+) {
-+        if (a.t != MPZ)
-+                throw std::runtime_error("integer_rational_power_of_mpz: bad input");
-+        mpz_t z;
-+        mpz_init(z);
-+        mpz_set_ui(z, 0);
-+        int sgn = mpz_sgn(a.v._bigint);
-+        if (mpz_cmp_ui(a.v._bigint, 1) == 0
-+            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
-+                mpz_set_ui(z, 1);
-+        else if (sgn == 0) {
-+                res = *_num0_p;
-+                mpz_clear(z);
-+                return true;
-+        }
-+        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1)) {
-+                mpz_clear(z);
-+                return false;
-+        } else {
-+                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-+                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat))) {
-+                        // too big to take roots/powers
-+                        mpz_clear(z);
-+                        return false;
-+                }
-+                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
-+                        if (mpz_perfect_square_p(a.v._bigint)) {
-+                                mpz_sqrt(z, a.v._bigint);
-+                        } else {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                else {
-+                        bool exact = mpz_root(z, a.v._bigint,
-+                                              mpz_get_ui(mpq_denref(b.v._bigrat)));
-+                        if (not exact) {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
-+        }
-+        res = numeric(z);   // transfers ownership, no mpz_clear
-+        return true;
-+}
-+
-+
- // Compute `a^b` as an integer, if it is integral, or return ``false``.
- // The nonnegative real root is taken for even denominators.
- bool numeric::integer_rational_power(numeric& res,
-@@ -1598,13 +1654,12 @@ bool numeric::integer_rational_power(numeric& res,
-                 if (a.v._long < 0
-                     and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
-                         return false;
--                long z;
-                 if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-                     or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
-                 // too big to take roots/powers
-                         return false;
-                 if (b.is_equal(*_num1_2_p)) {
--                        z = std::lround(std::sqrt(a.v._long));
-+                        long z = std::lround(std::sqrt(a.v._long));
-                         if (a.v._long == z*z) {
-                                 res = numeric(z);
-                                 return true;
-@@ -1613,44 +1668,11 @@ bool numeric::integer_rational_power(numeric& res,
-                 }
-                 return integer_rational_power(res, a.to_bigint(), b);
-         }
--        if (a.t != MPZ)
--                throw std::runtime_error("integer_rational_power: bad input");
--        int sgn = mpz_sgn(a.v._bigint);
--        mpz_t z;
--        mpz_init(z);
--        mpz_set_ui(z, 0);
--        if (mpz_cmp_ui(a.v._bigint, 1) == 0
--            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
--                mpz_set_ui(z, 1);
--        else if (sgn == 0) {
--                res = *_num0_p;
--                return true;
--        }
--        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
--                return false;
--        else {
--                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
--                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
--                // too big to take roots/powers
--                        return false;
--                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
--                        if (mpz_perfect_square_p(a.v._bigint))
--                                mpz_sqrt(z, a.v._bigint);
--                        else
--                                return false;
--                }
--                else {
--                        bool exact = mpz_root(z, a.v._bigint,
--                                        mpz_get_ui(mpq_denref(b.v._bigrat)));
--                        if (not exact)
--                                return false;
--                }
--                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
--        }
--        res = numeric(z);
--        return true;
-+        // otherwise: a is integer
-+        return integer_rational_power_of_mpz(res, a, b);
- }
- 
-+
- // for a^b return c,d such that a^b = c*d^b
- // only for MPZ/MPQ base and MPQ exponent
- void rational_power_parts(const numeric& a_orig, const numeric& b_orig,
-diff --git a/src/sage/tests/memcheck/__init__.py b/src/sage/tests/memcheck/__init__.py
-new file mode 100644
-index 00000000000..e69de29bb2d
-diff --git a/src/sage/tests/memcheck/run_tests.py b/src/sage/tests/memcheck/run_tests.py
-new file mode 100644
-index 00000000000..6ff4503a81b
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests.py
-@@ -0,0 +1,24 @@
-+import types
-+
-+
-+def run_tests() -> None:
-+    """
-+    Run all memcheck tests
-+    """
-+    from sage.tests.memcheck import symbolic_expression
-+    run_tests_in_module(symbolic_expression)
-+
-+
-+def run_tests_in_module(mod: types.ModuleType) -> None:
-+    """
-+    Run all memcheck tests in the given module
-+    """
-+    for entry in dir(mod):
-+        if not entry.startswith('test_'):
-+            continue
-+        test_func = getattr(mod, entry)
-+        test_func()
-+
-+
-+if __name__ == '__main__':
-+    run_tests()
-diff --git a/src/sage/tests/memcheck/run_tests_in_valgrind.py b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-new file mode 100644
-index 00000000000..df5ad0e92b2
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-@@ -0,0 +1,35 @@
-+"""
-+Launch valgrind and run the memory leak tests
-+
-+
-+From the commandline, run
-+
-+    sage -python -m sage.tests.memcheck.run_tests_in_valgrind
-+
-+to launch valgrind and execute the memory leak tests. Requires valgrind
-+to be installed. Alternatively, run as a unit test:
-+
-+    sage: from sage.tests.memcheck.run_tests_in_valgrind import run_tests_in_valgrind
-+    sage: run_tests_in_valgrind()    # optional - valgrind
-+"""
-+
-+import subprocess
-+
-+
-+def run_tests_in_valgrind() -> None:
-+    """
-+    Run the sage.tests.memcheck.run_tests module inside valgrind
-+    """
-+    subprocess.check_call([
-+        'valgrind',
-+        '--suppressions=src/sage/ext_data/valgrind/valgrind-python.supp',
-+        '--show-possibly-lost=no',
-+        '--show-reachable=no',
-+        './venv/bin/python',
-+        '-m',
-+        'sage.tests.memcheck.run_tests'
-+    ])
-+
-+
-+if __name__ == '__main__':
-+    run_tests_in_valgrind()
-diff --git a/src/sage/tests/memcheck/symbolic_expression.py b/src/sage/tests/memcheck/symbolic_expression.py
-new file mode 100644
-index 00000000000..52182fbe62d
---- /dev/null
-+++ b/src/sage/tests/memcheck/symbolic_expression.py
-@@ -0,0 +1,11 @@
-+from sage.tests.memcheck.verify_no_leak import verify_no_leak
-+
-+
-+def test_sqrt_sqrt_2() -> None:
-+    from sage.misc.functional import sqrt
-+    T2 = sqrt(2)
-+
-+    def sqrt_T2() -> None:
-+        sqrt(T2)
-+
-+    verify_no_leak(sqrt_T2)
-diff --git a/src/sage/tests/memcheck/verify_no_leak.py b/src/sage/tests/memcheck/verify_no_leak.py
-new file mode 100644
-index 00000000000..89ca90cf89c
---- /dev/null
-+++ b/src/sage/tests/memcheck/verify_no_leak.py
-@@ -0,0 +1,27 @@
-+from typing import Tuple, Sequence, List, Callable, Any
-+import valgrind
-+
-+
-+def verify_no_leak(callback: Callable[[], Any],
-+                   repeat: int = 10000,
-+                   fuzzy: int = 10,
-+                   ) -> None:
-+    """
-+    Verify that the callback does not generate new definitely lost blocks
-+
-+    Raises an assertion if the callback leaks memory
-+    """
-+    callback()   # warm_up
-+    initial_blocks = (0, 0, 0, 0)
-+    valgrind.memcheck_do_leak_check()
-+    initial_blocks = valgrind.memcheck_count_leak_blocks()
-+    for _ in range(repeat):
-+        callback()
-+    valgrind.memcheck_do_leak_check()
-+    leak_blocks = valgrind.memcheck_count_leak_blocks()
-+    leak = leak_blocks[0] - initial_blocks[0]
-+    if leak < repeat - fuzzy:
-+        return  # callback did not leak at least once per call
-+    blocks = round(leak / repeat, 2)
-+    message = f'{callback} leaked {blocks} block on average ({repeat} iterations)'
-+    raise AssertionError(message)
diff --git a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch b/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
deleted file mode 100644
index 684b62affaf5a..0000000000000
--- a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx
-index 8f46570313d..a8e73e57b52 100644
---- a/src/sage/libs/ecl.pyx
-+++ b/src/sage/libs/ecl.pyx
-@@ -563,15 +563,15 @@ cdef class EclObject:
-     Floats in Python are IEEE double, which LISP has as well. However,
-     the printing of floating point types in LISP depends on settings::
- 
--        sage: a = EclObject(float(10^40))
-+        sage: a = EclObject(float(1.234e40))
-         sage: ecl_eval("(setf *read-default-float-format* 'single-float)")
-         <ECL: SINGLE-FLOAT>
-         sage: a
--        <ECL: 1.d40>
-+        <ECL: 1.234d40>
-         sage: ecl_eval("(setf *read-default-float-format* 'double-float)")
-         <ECL: DOUBLE-FLOAT>
-         sage: a
--        <ECL: 1.e40>
-+        <ECL: 1.234e40>
- 
-     Tuples are translated to dotted lists::
- 
-diff --git a/src/sage/libs/eclsig.h b/src/sage/libs/eclsig.h
-index e249ccf6874..005b2d99d0b 100644
---- a/src/sage/libs/eclsig.h
-+++ b/src/sage/libs/eclsig.h
-@@ -45,7 +45,11 @@ static inline void ecl_sig_off(void)
-     sig_off();
- }
- 
-+#if ECL_VERSION_NUMBER < 230909
- #define ecl_mpz_from_bignum(obj) ((obj)->big.big_num)
-+#else
-+#define ecl_mpz_from_bignum(obj) ecl_bignum(obj)
-+#endif
- 
- cl_object ecl_bignum_from_mpz(mpz_t num)
- {
diff --git a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch b/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
deleted file mode 100644
index e858f2fd4a445..0000000000000
--- a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
-index 59f10f6b13f..adcccff059b 100644
---- a/src/sage/plot/graphics.py
-+++ b/src/sage/plot/graphics.py
-@@ -36,6 +36,7 @@
- # ****************************************************************************
- 
- import os
-+from numbers import Integral
- from collections.abc import Iterable
- from math import isnan
- import sage.misc.verbose
-@@ -2874,6 +2875,11 @@ def matplotlib(self, filename=None,
-                 weight=lopts.pop('font_weight', 'medium'),
-                 variant=lopts.pop('font_variant', 'normal'))
-             color = lopts.pop('back_color', 'white')
-+            if 'loc' in lopts:
-+                loc = lopts['loc']
-+                if isinstance(loc, Integral):
-+                    # matplotlib 3.8 doesn't support sage integers
-+                    lopts['loc'] = int(loc)
-             leg = subplot.legend(prop=prop, **lopts)
-             if leg is None:
-                 from warnings import warn
diff --git a/srcpkgs/sagemath/patches/36403-00pre.patch b/srcpkgs/sagemath/patches/36403-00pre.patch
deleted file mode 100644
index 060404d5430de..0000000000000
--- a/srcpkgs/sagemath/patches/36403-00pre.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-Minor patch so that #36403 applies cleanly over sagemath 10.1
-
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 2053bca80c3..86aca6e00d8 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15123,7 +15302,8 @@ cdef class Matrix(Matrix1):
-             sage: N.conjugate_transpose()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object has no attribute 'conjugate'
-+            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
-+            has no attribute 'conjugate'
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 525ea5aa934..52afed49d64 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -55,7 +55,7 @@ cdef class AttributeErrorMessage:
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-         sage: x = polygen(ZZ, 'x')
--        sage: QQ[x].gen().bla                                                           # optional - sage.libs.flint
-+        sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
diff --git a/srcpkgs/sagemath/patches/36407-python_3.12.patch b/srcpkgs/sagemath/patches/36407-python_3.12.patch
deleted file mode 100644
index c75c275c30764..0000000000000
--- a/srcpkgs/sagemath/patches/36407-python_3.12.patch
+++ /dev/null
@@ -1,1744 +0,0 @@
-diff --git a/build/sage_bootstrap/package.py b/build/sage_bootstrap/package.py
-index 15b342223c4..eb82f96e05f 100644
---- a/build/sage_bootstrap/package.py
-+++ b/build/sage_bootstrap/package.py
-@@ -303,7 +303,7 @@ def _init_checksum(self):
-         # Name of the directory containing the checksums.ini file
-         self.__tarball_package_name = os.path.realpath(checksums_ini).split(os.sep)[-2]
- 
--    VERSION_PATCHLEVEL = re.compile('(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
-+    VERSION_PATCHLEVEL = re.compile(r'(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
- 
-     def _init_version(self):
-         try:
-diff --git a/src/doc/en/thematic_tutorials/coercion_and_categories.rst b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-index bb23331c151..7f5712caea7 100644
---- a/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-+++ b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-@@ -1223,7 +1223,7 @@ However, only "elementary" construction functors have a rank::
-     sage: (Fract*Poly).rank
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'
-+    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'...
- 
- .. end of output
- 
-diff --git a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-index 553a946c4d8..3cd71a9bad4 100644
---- a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-+++ b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-@@ -318,7 +318,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: e.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'...
- 
-         sage: id4 = SymmetricGroup(4).one()
-         sage: type(id4)
-@@ -326,7 +326,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: id4.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'
-+        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'...
- 
- .. note::
- 
-diff --git a/src/sage/algebras/cluster_algebra.py b/src/sage/algebras/cluster_algebra.py
-index b72d2a12976..14669dfed5c 100644
---- a/src/sage/algebras/cluster_algebra.py
-+++ b/src/sage/algebras/cluster_algebra.py
-@@ -167,7 +167,7 @@
-     sage: (t*s).g_vector()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'
-+    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'...
-     sage: A = ClusterAlgebra(['A', 2], principal_coefficients=True)
-     sage: A.explore_to_depth(infinity)
-     sage: s = A.cluster_variable((0, -1)); s
-diff --git a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-index e4a91723558..343ee8a66f9 100644
---- a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-+++ b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-@@ -109,7 +109,7 @@ class WeylLieConformalAlgebra(LieConformalAlgebraWithStructureCoefficients):
-         sage: alpha0.degree()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'
-+        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'...
- 
-     TESTS::
- 
-diff --git a/src/sage/algebras/steenrod/steenrod_algebra.py b/src/sage/algebras/steenrod/steenrod_algebra.py
-index 978a3557a9d..7c4d444f81c 100644
---- a/src/sage/algebras/steenrod/steenrod_algebra.py
-+++ b/src/sage/algebras/steenrod/steenrod_algebra.py
-@@ -1080,7 +1080,7 @@ def homogeneous_component(self, n):
-             sage: a.antipode() # not defined
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'
-+            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'...
-             sage: A(a).antipode() # convert to elt of A, then compute antipode
-             Sq(2,1) + Sq(5)
- 
-diff --git a/src/sage/all__sagemath_repl.py b/src/sage/all__sagemath_repl.py
-index 8d0b43679ca..c31b206bcb8 100644
---- a/src/sage/all__sagemath_repl.py
-+++ b/src/sage/all__sagemath_repl.py
-@@ -79,6 +79,23 @@
-                         message=r"Use setlocale\(\), getencoding\(\) and getlocale\(\) instead",
-                         module='docutils.io')
- 
-+# triggered by dateutil 2.8.2 and sphinx 7.0.1 on Python 3.12
-+# see: https://github.com/dateutil/dateutil/pull/1285
-+# see: https://github.com/sphinx-doc/sphinx/pull/11468
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"datetime.datetime.utcfromtimestamp\(\) is deprecated",
-+                        module='dateutil.tz.tz|sphinx.(builders.gettext|util.i18n)')
-+
-+# triggered on Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"This process.* is multi-threaded, "
-+                                r"use of .*\(\) may lead to deadlocks in the child.")
-+
-+# pickling of itertools is deprecated in Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"Pickle, copy, and deepcopy support will be "
-+                                r"removed from itertools in Python 3.14.")
-+
- 
- from .all__sagemath_objects import *
- from .all__sagemath_environment import *
-diff --git a/src/sage/arith/long.pxd b/src/sage/arith/long.pxd
-index 0031a0ae337..3ea70cef571 100644
---- a/src/sage/arith/long.pxd
-+++ b/src/sage/arith/long.pxd
-@@ -19,6 +19,8 @@ from libc.limits cimport LONG_MIN, LONG_MAX
- from cpython.object cimport Py_SIZE
- from cpython.number cimport PyNumber_Index, PyIndex_Check
- from cpython.longintrepr cimport py_long, PyLong_SHIFT, digit
-+from sage.cpython.pycore_long cimport (
-+    ob_digit, _PyLong_IsNegative, _PyLong_DigitCount)
- 
- from sage.libs.gmp.mpz cimport mpz_fits_slong_p, mpz_get_si
- from sage.rings.integer_fake cimport is_Integer, Integer_AS_MPZ
-@@ -299,8 +301,11 @@ cdef inline bint integer_check_long_py(x, long* value, int* err):
-         return 0
- 
-     # x is a Python "int" (aka PyLongObject or py_long in cython)
--    cdef const digit* D = (<py_long>x).ob_digit
--    cdef Py_ssize_t size = Py_SIZE(x)
-+    cdef const digit* D = ob_digit(x)
-+    cdef Py_ssize_t size = _PyLong_DigitCount(x)
-+
-+    if _PyLong_IsNegative(x):
-+        size = -size
- 
-     # We assume PyLong_SHIFT <= BITS_IN_LONG <= 3 * PyLong_SHIFT.
-     # This is true in all the default configurations:
-diff --git a/src/sage/categories/category.py b/src/sage/categories/category.py
-index 57ef7f4184b..29bce8ee415 100644
---- a/src/sage/categories/category.py
-+++ b/src/sage/categories/category.py
-@@ -2129,7 +2129,7 @@ def _with_axioms(self, axioms):
-             sage: Semigroups().Inverse()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'
-+            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'...
-             sage: Semigroups()._with_axioms(["Inverse"])
-             Category of semigroups
- 
-diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py
-index 5227792e725..4775d4e5bf1 100644
---- a/src/sage/categories/category_with_axiom.py
-+++ b/src/sage/categories/category_with_axiom.py
-@@ -554,7 +554,7 @@ class from the base category class::
-     sage: Magmas.Unital.Associative
-     Traceback (most recent call last):
-     ...
--    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'
-+    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'...
- 
- The purpose of this section is to explain the design of the code
- layout and the rationale for this mismatch.
-@@ -769,7 +769,7 @@ def _(): return LazyImport('sage.categories.rngs', 'Rngs', at_startup=True)
-     sage: Semirings().NoZeroDivisors()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'
-+    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'...
- 
- Concretely, this is to be implemented by defining the new axiom in the
- (``SubcategoryMethods`` nested class of the) appropriate category with
-diff --git a/src/sage/categories/enumerated_sets.py b/src/sage/categories/enumerated_sets.py
-index a8bea53f907..b0ea05d0563 100644
---- a/src/sage/categories/enumerated_sets.py
-+++ b/src/sage/categories/enumerated_sets.py
-@@ -610,7 +610,7 @@ def _list_from_iterator(self):
-                 sage: (QQ^2).list()  # indirect test                                    # needs sage.modules
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'
-+                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'...
- 
-             Here we test that for an object that does not know whether it
-             is finite or not.  Calling ``x.list()`` simply tries to create
-@@ -622,11 +622,11 @@ def _list_from_iterator(self):
-                 sage: Q.is_finite()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'...
-                 sage: Q.list()   # indirect test
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'...
- 
-             Here is another example. We artificially create a version of
-             the ring of integers that does not know whether it is finite
-diff --git a/src/sage/categories/examples/sets_cat.py b/src/sage/categories/examples/sets_cat.py
-index e0853d63f94..fbadb9ca405 100644
---- a/src/sage/categories/examples/sets_cat.py
-+++ b/src/sage/categories/examples/sets_cat.py
-@@ -619,7 +619,7 @@ class PrimeNumbers_Facade(PrimeNumbers_Abstract):
-         sage: pf.next()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'...
- 
-     unlike in the other implementations::
- 
-diff --git a/src/sage/categories/homset.py b/src/sage/categories/homset.py
-index 22ba9d047fc..2a8b8aeedeb 100644
---- a/src/sage/categories/homset.py
-+++ b/src/sage/categories/homset.py
-@@ -632,7 +632,7 @@ def __init__(self, X, Y, category=None, base=None, check=True):
-             sage: H = MyHomset(X, Y, category=1, base = ZZ, check = False)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'...
-             sage: P.<t> = ZZ[]
-             sage: f = P.hom([1/2*t])
-             sage: f.parent().domain()
-diff --git a/src/sage/categories/modules_with_basis.py b/src/sage/categories/modules_with_basis.py
-index e97bf851388..c4933d0657f 100644
---- a/src/sage/categories/modules_with_basis.py
-+++ b/src/sage/categories/modules_with_basis.py
-@@ -2456,7 +2456,7 @@ def apply_multilinear_morphism(self, f, codomain=None):
-                     sage: tensor([a, b]).apply_multilinear_morphism(f)                  # needs sage.modules
-                     Traceback (most recent call last):
-                     ...
--                    AttributeError: 'int' object has no attribute 'parent'
-+                    AttributeError: 'int' object has no attribute 'parent'...
- 
-                 Here we consider an example where the codomain is a
-                 module with basis with a different base ring::
-diff --git a/src/sage/categories/monoids.py b/src/sage/categories/monoids.py
-index 38dd7248c9d..28474bd17b6 100644
---- a/src/sage/categories/monoids.py
-+++ b/src/sage/categories/monoids.py
-@@ -556,7 +556,7 @@ def algebra_generators(self):
-                     Traceback (most recent call last):
-                     ...
-                     AttributeError: 'IntegerModMonoid_with_category' object
--                    has no attribute 'monoid_generators'
-+                    has no attribute 'monoid_generators'...
-                     sage: Z12.semigroup_generators()
-                     Family (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
-                     sage: Z12.algebra(QQ).algebra_generators()                          # needs sage.modules
-diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py
-index 494e8154c80..ec5120e41e6 100644
---- a/src/sage/combinat/finite_state_machine.py
-+++ b/src/sage/combinat/finite_state_machine.py
-@@ -1835,7 +1835,7 @@ def __getstate__(self):
-             sage: T1.transitions
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'FSMState' object has no attribute 'transitions'
-+            AttributeError: 'FSMState' object has no attribute 'transitions'...
-             sage: A1 = loads(dumps(A))
-             sage: all(A.state(j) == A1.state(j) for j in [0, 1])
-             True
-diff --git a/src/sage/combinat/growth.py b/src/sage/combinat/growth.py
-index cf8d18c1764..766eea37917 100644
---- a/src/sage/combinat/growth.py
-+++ b/src/sage/combinat/growth.py
-@@ -371,7 +371,7 @@
-     sage: GrowthDiagram(RulePascal(), [3,1,2])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'RulePascal' object has no attribute 'forward_rule'
-+    AttributeError: 'RulePascal' object has no attribute 'forward_rule'...
- 
- We now re-implement the rule where we provide the dual graded graphs::
- 
-diff --git a/src/sage/combinat/integer_lists/lists.py b/src/sage/combinat/integer_lists/lists.py
-index 5143e5cb5e8..9117a6076f7 100644
---- a/src/sage/combinat/integer_lists/lists.py
-+++ b/src/sage/combinat/integer_lists/lists.py
-@@ -261,7 +261,7 @@ def __getattr__(self, name):
-             sage: L.foo
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'foo'
-+            AttributeError: 'NoneType' object has no attribute 'foo'...
-         """
-         return getattr(self.backend, name)
- 
-diff --git a/src/sage/combinat/posets/posets.py b/src/sage/combinat/posets/posets.py
-index c31597c72e9..c74bfc67cee 100644
---- a/src/sage/combinat/posets/posets.py
-+++ b/src/sage/combinat/posets/posets.py
-@@ -8825,7 +8825,7 @@ def is_induced_subposet(self, other):
-             sage: Poset().is_induced_subposet('junk')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'subposet'
-+            AttributeError: 'str' object has no attribute 'subposet'...
-         """
-         if (not self._is_facade or (isinstance(other, FinitePoset) and
-                                     not other._is_facade)):
-diff --git a/src/sage/cpython/atexit.pyx b/src/sage/cpython/atexit.pyx
-index 961aa348d0a..e5a82735137 100644
---- a/src/sage/cpython/atexit.pyx
-+++ b/src/sage/cpython/atexit.pyx
-@@ -154,6 +154,10 @@ cdef extern from *:
-     #undef _PyGC_FINALIZED
-     #include "internal/pycore_interp.h"
-     #include "internal/pycore_pystate.h"
-+    #if PY_VERSION_HEX >= 0x030c0000
-+    // struct atexit_callback was renamed in 3.12 to atexit_py_callback
-+    #define atexit_callback atexit_py_callback
-+    #endif
-     static atexit_callback ** _atexit_callbacks(PyObject *self) {
-         PyInterpreterState *interp = _PyInterpreterState_GET();
-         struct atexit_state state = interp->atexit;
-diff --git a/src/sage/cpython/debug.pyx b/src/sage/cpython/debug.pyx
-index 986abff2a99..cdaca3a4854 100644
---- a/src/sage/cpython/debug.pyx
-+++ b/src/sage/cpython/debug.pyx
-@@ -78,7 +78,7 @@ def getattr_debug(obj, name, default=_no_default):
- 
-     EXAMPLES::
- 
--        sage: _ = getattr_debug(list, "reverse")
-+        sage: _ = getattr_debug(list, "reverse")  # not tested - broken in python 3.12
-         getattr_debug(obj=<class 'list'>, name='reverse'):
-           type(obj) = <class 'type'>
-           object has __dict__ slot (<class 'dict'>)
-@@ -123,7 +123,7 @@ def getattr_debug(obj, name, default=_no_default):
-         sage: _ = getattr_debug(1, "foo")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'...
-         sage: _ = getattr_debug(1, "foo", "xyz")
-         getattr_debug(obj=1, name='foo'):
-           type(obj) = <class 'sage.rings.integer.Integer'>
-diff --git a/src/sage/cpython/dict_internal.h b/src/sage/cpython/dict_internal.h
-index 42a57bcb468..a5ee35bc198 100644
---- a/src/sage/cpython/dict_internal.h
-+++ b/src/sage/cpython/dict_internal.h
-@@ -169,6 +169,7 @@ dictkeys_set_index(PyDictKeysObject *keys, Py_ssize_t i, Py_ssize_t ix)
- #else   /* Python >= 3.11 */
- 
- #define Py_BUILD_CORE
-+#undef _PyGC_FINALIZED
- #include <internal/pycore_dict.h>
- 
- /************************************************************/
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 52afed49d64..1f49e5230c3 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -53,12 +53,12 @@ cdef class AttributeErrorMessage:
-         sage: 1.bla  #indirect doctest
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'...
-         sage: x = polygen(ZZ, 'x')
-         sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'...
- 
-     ::
- 
-@@ -144,7 +144,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(X, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: x = X()
-         sage: raw_getattr(x, "prop")
-         <property object at ...>
-@@ -173,7 +173,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(Y, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: y = Y()
-         sage: raw_getattr(y, "prop")
-         <property object at ...>
-@@ -278,7 +278,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     The integer ring is a parent, so, lazy attributes work::
- 
-@@ -289,7 +289,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(17, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     In general, descriptors are not yet well supported, because they
-     often do not accept to be cheated with the type of their instance::
-@@ -305,7 +305,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__weakref__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-     This was caught by :trac:`8296` for which we do a couple more tests::
- 
-@@ -314,7 +314,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: 1.__weakref__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-         sage: n = 1
-         sage: ip = get_ipython()                 # not tested: only works in interactive shell
-@@ -329,7 +329,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__call__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'...
- 
-     TESTS:
- 
-@@ -339,14 +339,14 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, type, "__name__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'...
- 
-     Non-strings as "name" are handled gracefully::
- 
-         sage: getattr_from_other_class(1, type, None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute None
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute None...
-     """
-     if not isinstance(cls, type):
-         raise TypeError(f"{cls!r} is not a type")
-diff --git a/src/sage/cpython/pycore_long.h b/src/sage/cpython/pycore_long.h
-new file mode 100644
-index 00000000000..ff1a73d097a
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.h
-@@ -0,0 +1,98 @@
-+#include "Python.h"
-+#include <stdbool.h>
-+
-+#if PY_VERSION_HEX >= 0x030C00A5
-+#define ob_digit(o)  (((PyLongObject*)o)->long_value.ob_digit)
-+#else
-+#define ob_digit(o)  (((PyLongObject*)o)->ob_digit)
-+#endif
-+
-+#if PY_VERSION_HEX >= 0x030C00A7
-+// taken from cpython:Include/internal/pycore_long.h @ 3.12
-+
-+/* Long value tag bits:
-+ * 0-1: Sign bits value = (1-sign), ie. negative=2, positive=0, zero=1.
-+ * 2: Reserved for immortality bit
-+ * 3+ Unsigned digit count
-+ */
-+#define SIGN_MASK 3
-+#define SIGN_ZERO 1
-+#define SIGN_NEGATIVE 2
-+#define NON_SIZE_BITS 3
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_ZERO;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_NEGATIVE;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    assert(PyLong_Check(op));
-+    return op->long_value.lv_tag >> NON_SIZE_BITS;
-+}
-+
-+#define TAG_FROM_SIGN_AND_SIZE(sign, size) ((1 - (sign)) | ((size) << NON_SIZE_BITS))
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+    assert(size >= 0);
-+    assert(-1 <= sign && sign <= 1);
-+    assert(sign != 0 || size == 0);
-+    op->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sign, (size_t)size);
-+}
-+
-+#else
-+// fallback for < 3.12
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) == 0;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) < 0;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) > 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    Py_ssize_t size = Py_SIZE(op);
-+    return size < 0 ? -size : size;
-+}
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION < 9)
-+// The function Py_SET_SIZE is defined starting with python 3.9.
-+    Py_SIZE(o) = size;
-+#else
-+    Py_SET_SIZE(op, sign < 0 ? -size : size);
-+#endif
-+}
-+
-+#endif
-diff --git a/src/sage/cpython/pycore_long.pxd b/src/sage/cpython/pycore_long.pxd
-new file mode 100644
-index 00000000000..41de637ff18
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.pxd
-@@ -0,0 +1,9 @@
-+from cpython.longintrepr cimport py_long, digit
-+
-+cdef extern from "pycore_long.h":
-+    digit* ob_digit(py_long o)
-+    bint _PyLong_IsZero(py_long o)
-+    bint _PyLong_IsNegative(py_long o)
-+    bint _PyLong_IsPositive(py_long o)
-+    Py_ssize_t _PyLong_DigitCount(py_long o)
-+    void _PyLong_SetSignAndDigitCount(py_long o, int sign, Py_ssize_t size)
-diff --git a/src/sage/crypto/classical.py b/src/sage/crypto/classical.py
-index 616dc861652..be899c781e5 100644
---- a/src/sage/crypto/classical.py
-+++ b/src/sage/crypto/classical.py
-@@ -494,7 +494,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: A.rank_by_chi_square("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_chi_square(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -703,7 +703,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: A.rank_by_squared_differences("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_squared_differences(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -2114,7 +2114,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: S.rank_by_chi_square("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_chi_square(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-@@ -2351,7 +2351,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: S.rank_by_squared_differences("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_squared_differences(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/crypto/mq/mpolynomialsystemgenerator.py b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-index 9028dab1d98..4416d9ef7f6 100644
---- a/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-+++ b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-@@ -156,7 +156,7 @@ def sbox(self):
-             sage: msg.sbox()
-             Traceback (most recent call last):
-             ...
--            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'
-+            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'...
-         """
-         return self._sbox
- 
-diff --git a/src/sage/data_structures/bitset.pyx b/src/sage/data_structures/bitset.pyx
-index 446062554c1..d9906b5edd2 100644
---- a/src/sage/data_structures/bitset.pyx
-+++ b/src/sage/data_structures/bitset.pyx
-@@ -967,7 +967,7 @@ cdef class FrozenBitset:
-             sage: None | FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute '_union'
-+            AttributeError: 'NoneType' object has no attribute '_union'...
-         """
-         return self._union(other)
- 
-@@ -1037,7 +1037,7 @@ cdef class FrozenBitset:
-             sage: None & FrozenBitset("101011")
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'intersection'
-+            AttributeError: 'NoneType' object has no attribute 'intersection'...
-         """
-         return self.intersection(other)
- 
-@@ -1106,7 +1106,7 @@ cdef class FrozenBitset:
-             sage: None - FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'difference'
-+            AttributeError: 'NoneType' object has no attribute 'difference'...
-         """
-         return self.difference(other)
- 
-@@ -1179,7 +1179,7 @@ cdef class FrozenBitset:
-             sage: None ^^ FrozenBitset('11111' * 10)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'
-+            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'...
-         """
-         return self.symmetric_difference(other)
- 
-diff --git a/src/sage/doctest/reporting.py b/src/sage/doctest/reporting.py
-index 361fea344c2..a3947c07e01 100644
---- a/src/sage/doctest/reporting.py
-+++ b/src/sage/doctest/reporting.py
-@@ -368,7 +368,7 @@ def report(self, source, timeout, return_code, results, output, pid=None):
-             sage: DTR.report(None, None, None, None, None)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'basename'
-+            AttributeError: 'NoneType' object has no attribute 'basename'...
- 
-         The only-errors mode does not output anything on success::
- 
-diff --git a/src/sage/dynamics/finite_dynamical_system.py b/src/sage/dynamics/finite_dynamical_system.py
-index e5fbf568b7e..4295070615a 100644
---- a/src/sage/dynamics/finite_dynamical_system.py
-+++ b/src/sage/dynamics/finite_dynamical_system.py
-@@ -240,7 +240,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-@@ -252,7 +252,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-diff --git a/src/sage/geometry/cone.py b/src/sage/geometry/cone.py
-index f0a8620011a..53f78a4b7b6 100644
---- a/src/sage/geometry/cone.py
-+++ b/src/sage/geometry/cone.py
-@@ -340,7 +340,7 @@ def Cone(rays, lattice=None, check=True, normalize=True):
-         sage: Cone([(1,0), (0,1)], check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     You can construct different "not" cones: not full-dimensional, not
-     strictly convex, not containing any rays::
-diff --git a/src/sage/geometry/fan.py b/src/sage/geometry/fan.py
-index 258544012fe..3aecc84a55b 100644
---- a/src/sage/geometry/fan.py
-+++ b/src/sage/geometry/fan.py
-@@ -443,7 +443,7 @@ def Fan(cones, rays=None, lattice=None, check=True, normalize=True,
-         sage: P2c = Fan(cones, rays, check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     Yet another way is to use functions :func:`FaceFan` and :func:`NormalFan`
-     to construct fans from :class:`lattice polytopes
-diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-index f0ac1e774a7..f03f0f832ff 100644
---- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-+++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-@@ -351,7 +351,7 @@ cdef class FaceIterator_base(SageObject):
-             sage: FaceIterator_base(2)  # indirect doctest
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'...
-         """
-         cdef int i
-         sig_free(self.structure.atom_rep)
-@@ -1945,7 +1945,8 @@ cdef inline int next_face_loop(iter_t structure) nogil except -1:
-         # The function is not supposed to be called,
-         # just prevent it from crashing.
-         # Actually raising an error here results in a bad branch prediction.
--        return -1
-+        # But return -1 results in a crash with python 3.12
-+        raise StopIteration
- 
-     # Getting ``[faces, n_faces, n_visited_all]`` according to dimension.
-     cdef face_list_t* faces = &structure.new_faces[structure.current_dimension]
-diff --git a/src/sage/geometry/toric_plotter.py b/src/sage/geometry/toric_plotter.py
-index 50b4008eb0f..950e3ba7ff8 100644
---- a/src/sage/geometry/toric_plotter.py
-+++ b/src/sage/geometry/toric_plotter.py
-@@ -706,7 +706,7 @@ def set_rays(self, generators):
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ToricPlotter' object has no attribute 'rays'
-+            AttributeError: 'ToricPlotter' object has no attribute 'rays'...
-             sage: tp.set_rays([(0,1)])
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Graphics object consisting of 2 graphics primitives
-diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
-index d0ec214bb3b..c8098ad578a 100644
---- a/src/sage/groups/matrix_gps/finitely_generated.py
-+++ b/src/sage/groups/matrix_gps/finitely_generated.py
-@@ -268,7 +268,7 @@ def MatrixGroup(*gens, **kwds):
-         sage: SL2C.gens()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'
-+        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'...
-     """
-     if isinstance(gens[-1], dict):   # hack for unpickling
-         kwds.update(gens[-1])
-diff --git a/src/sage/homology/chains.py b/src/sage/homology/chains.py
-index 87c0947c0b0..b9a54940943 100644
---- a/src/sage/homology/chains.py
-+++ b/src/sage/homology/chains.py
-@@ -298,7 +298,7 @@ def is_cycle(self):
-                 sage: chain.is_cocycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -325,7 +325,7 @@ def is_boundary(self):
-                 sage: chain.is_coboundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -539,7 +539,7 @@ def is_cocycle(self):
-                 sage: cochain.is_cycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -566,7 +566,7 @@ def is_coboundary(self):
-                 sage: cochain.is_boundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -604,7 +604,7 @@ def eval(self, other):
-                 sage: z.eval(c) # z is not a cochain
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'...
-                 sage: c.eval(c) # can't evaluate a cochain on a cochain
-                 Traceback (most recent call last):
-                 ...
-diff --git a/src/sage/homology/free_resolution.py b/src/sage/homology/free_resolution.py
-index e3d38de4240..280a479b438 100644
---- a/src/sage/homology/free_resolution.py
-+++ b/src/sage/homology/free_resolution.py
-@@ -275,7 +275,7 @@ def differential(self, i):
-             sage: FreeResolution.differiental(r, 1)
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'FreeResolution' has no attribute 'differiental'
-+            AttributeError: type object 'FreeResolution' has no attribute 'differiental'...
-         """
- 
-     def target(self):
-diff --git a/src/sage/interfaces/magma.py b/src/sage/interfaces/magma.py
-index b7a0ac20d03..529bfbc349b 100644
---- a/src/sage/interfaces/magma.py
-+++ b/src/sage/interfaces/magma.py
-@@ -824,7 +824,7 @@ def _coerce_from_special_method(self, x):
-             sage: magma._coerce_from_special_method('2 + 3')  # optional - magma
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute '_magma_init_'
-+            AttributeError: 'str' object has no attribute '_magma_init_'...
-         """
-         s = x._magma_init_(self)
-         a = self(s)
-diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
-index 58499396d6c..16119d20815 100644
---- a/src/sage/lfunctions/dokchitser.py
-+++ b/src/sage/lfunctions/dokchitser.py
-@@ -418,8 +418,8 @@ def init_coeffs(self, v, cutoff=1,
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
-index bbf289aa21c..e4968866303 100644
---- a/src/sage/lfunctions/pari.py
-+++ b/src/sage/lfunctions/pari.py
-@@ -141,8 +141,8 @@ def init_coeffs(self, v, cutoff=None, w=1):
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
-index 478caf9f9d0..363024ae281 100644
---- a/src/sage/libs/gap/element.pyx
-+++ b/src/sage/libs/gap/element.pyx
-@@ -380,7 +380,7 @@ cdef GapElement make_GapElement(parent, Obj obj):
-         sage: libgap(None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute '_libgap_init_'
-+        AttributeError: 'NoneType' object has no attribute '_libgap_init_'...
-     """
-     cdef GapElement r = GapElement.__new__(GapElement)
-     r._initialize(parent, obj)
-diff --git a/src/sage/libs/gmp/pylong.pxd b/src/sage/libs/gmp/pylong.pxd
-index a73f1da6d6f..84e1bb8cd87 100644
---- a/src/sage/libs/gmp/pylong.pxd
-+++ b/src/sage/libs/gmp/pylong.pxd
-@@ -2,9 +2,10 @@
- Various functions to deal with conversion mpz <-> Python int/long
- """
- 
-+from cpython.longintrepr cimport py_long
- from sage.libs.gmp.types cimport *
- 
- cdef mpz_get_pylong(mpz_srcptr z)
- cdef mpz_get_pyintlong(mpz_srcptr z)
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1
- cdef Py_hash_t mpz_pythonhash(mpz_srcptr z)
-diff --git a/src/sage/libs/gmp/pylong.pyx b/src/sage/libs/gmp/pylong.pyx
-index d5993cca5a5..1a36c29d3fa 100644
---- a/src/sage/libs/gmp/pylong.pyx
-+++ b/src/sage/libs/gmp/pylong.pyx
-@@ -28,6 +28,8 @@ AUTHORS:
- from cpython.object cimport Py_SIZE
- from cpython.long cimport PyLong_FromLong
- from cpython.longintrepr cimport _PyLong_New, py_long, digit, PyLong_SHIFT
-+from sage.cpython.pycore_long cimport (ob_digit, _PyLong_IsNegative,
-+    _PyLong_DigitCount, _PyLong_SetSignAndDigitCount)
- from .mpz cimport *
- 
- cdef extern from *:
-@@ -60,12 +62,9 @@ cdef mpz_get_pylong_large(mpz_srcptr z):
-     """
-     cdef size_t nbits = mpz_sizeinbase(z, 2)
-     cdef size_t pylong_size = (nbits + PyLong_SHIFT - 1) // PyLong_SHIFT
--    L = _PyLong_New(pylong_size)
--    mpz_export(L.ob_digit, NULL,
--            -1, sizeof(digit), 0, PyLong_nails, z)
--    if mpz_sgn(z) < 0:
--        # Set correct size
--        Py_SET_SIZE(L, -pylong_size)
-+    cdef py_long L = _PyLong_New(pylong_size)
-+    mpz_export(ob_digit(L), NULL, -1, sizeof(digit), 0, PyLong_nails, z)
-+    _PyLong_SetSignAndDigitCount(L, mpz_sgn(z), pylong_size)
-     return L
- 
- 
-@@ -88,16 +87,13 @@ cdef mpz_get_pyintlong(mpz_srcptr z):
-     return mpz_get_pylong_large(z)
- 
- 
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1:
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1:
-     """
-     Convert a Python ``long`` `L` to an ``mpz``.
-     """
--    cdef Py_ssize_t pylong_size = Py_SIZE(L)
--    if pylong_size < 0:
--        pylong_size = -pylong_size
--    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails,
--            (<py_long>L).ob_digit)
--    if Py_SIZE(L) < 0:
-+    cdef Py_ssize_t pylong_size = _PyLong_DigitCount(L)
-+    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails, ob_digit(L))
-+    if _PyLong_IsNegative(L):
-         mpz_neg(z, z)
- 
- 
-diff --git a/src/sage/manifolds/calculus_method.py b/src/sage/manifolds/calculus_method.py
-index f5830c0bc45..303dde6cd13 100644
---- a/src/sage/manifolds/calculus_method.py
-+++ b/src/sage/manifolds/calculus_method.py
-@@ -257,7 +257,7 @@ def simplify(self, expression, method=None):
-             sage: cm.simplify(f)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'
-+            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'...
- 
-         In the present case, one should either transform ``f`` to a SymPy
-         object::
-diff --git a/src/sage/manifolds/differentiable/vectorfield_module.py b/src/sage/manifolds/differentiable/vectorfield_module.py
-index d954b5d4839..af4bfb0ceec 100644
---- a/src/sage/manifolds/differentiable/vectorfield_module.py
-+++ b/src/sage/manifolds/differentiable/vectorfield_module.py
-@@ -885,7 +885,7 @@ def tensor(self, *args, **kwds):
-             sage: XM.tensor(XM).tensor(XM.dual().tensor(XM.dual()))
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'
-+            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'...
- 
-         .. SEEALSO::
- 
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 86aca6e00d8..a5f6716e731 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15303,7 +15303,7 @@ cdef class Matrix(Matrix1):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
--            has no attribute 'conjugate'
-+            has no attribute 'conjugate'...
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/matrix/matrix_cyclo_dense.pyx b/src/sage/matrix/matrix_cyclo_dense.pyx
-index f54f3423ded..a49bb6240e6 100644
---- a/src/sage/matrix/matrix_cyclo_dense.pyx
-+++ b/src/sage/matrix/matrix_cyclo_dense.pyx
-@@ -847,7 +847,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense):
-             sage: A.set_mutable()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'
-+            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'...
-             sage: B = A.__copy__()
-             sage: B[0,0] = 20
-             sage: B[0,0]
-diff --git a/src/sage/matrix/matrix_gfpn_dense.pyx b/src/sage/matrix/matrix_gfpn_dense.pyx
-index 4cccf473de1..8e8e4d7336b 100644
---- a/src/sage/matrix/matrix_gfpn_dense.pyx
-+++ b/src/sage/matrix/matrix_gfpn_dense.pyx
-@@ -159,7 +159,7 @@ cdef class FieldConverter_class:
-             sage: C.field_to_fel('foo')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'to_integer'
-+            AttributeError: 'str' object has no attribute 'to_integer'...
-         """
-         return FfFromInt(x.to_integer())
- 
-diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py
-index 6aab58352be..b5e6f52349b 100644
---- a/src/sage/matrix/matrix_space.py
-+++ b/src/sage/matrix/matrix_space.py
-@@ -1619,7 +1619,7 @@ def __getitem__(self, x):
-             sage: MS[2]
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'
-+            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'...
-         """
-         if isinstance(x, (integer.Integer, int)):
-             return self.list()[x]
-diff --git a/src/sage/matroids/lean_matrix.pyx b/src/sage/matroids/lean_matrix.pyx
-index 54c68e637c0..a137cbf70e5 100644
---- a/src/sage/matroids/lean_matrix.pyx
-+++ b/src/sage/matroids/lean_matrix.pyx
-@@ -1,5 +1,4 @@
- # sage.doctest: optional - sage.rings.finite_rings
--# cython: profile=True
- """
- Lean matrices
- 
-diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx
-index 36f563aa433..318c82f2b64 100644
---- a/src/sage/matroids/linear_matroid.pyx
-+++ b/src/sage/matroids/linear_matroid.pyx
-@@ -1134,7 +1134,7 @@ cdef class LinearMatroid(BasisExchangeMatroid):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.matroids.basis_matroid.BasisMatroid' object
--            has no attribute 'base_ring'
-+            has no attribute 'base_ring'...
-             sage: from sage.matroids.advanced import *
-             sage: M4 = BinaryMatroid(Matrix(M1))
-             sage: M5 = LinearMatroid(reduced_matrix=Matrix(GF(2), [[-1, 0, 1],
-diff --git a/src/sage/misc/dev_tools.py b/src/sage/misc/dev_tools.py
-index e7bf176592c..3ece7db2894 100644
---- a/src/sage/misc/dev_tools.py
-+++ b/src/sage/misc/dev_tools.py
-@@ -171,6 +171,7 @@ def load_submodules(module=None, exclude_pattern=None):
-         load sage.geometry.polyhedron.ppl_lattice_polygon... succeeded
-     """
-     from .package_dir import walk_packages
-+    import importlib.util
- 
-     if module is None:
-         import sage
-@@ -194,8 +195,12 @@ def load_submodules(module=None, exclude_pattern=None):
-         try:
-             sys.stdout.write("load %s..." % module_name)
-             sys.stdout.flush()
--            loader = importer.find_module(module_name)
--            loader.load_module(module_name)
-+            # see
-+            # https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
-+            spec = importer.find_spec(module_name)
-+            module = importlib.util.module_from_spec(spec)
-+            sys.modules[module_name] = module
-+            spec.loader.exec_module(module)
-             sys.stdout.write(" succeeded\n")
-         except (ValueError, AttributeError, TypeError, ImportError):
-             # we might get error because of cython code that has been
-diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py
-index c922b8f6f12..03697f08b7c 100644
---- a/src/sage/misc/functional.py
-+++ b/src/sage/misc/functional.py
-@@ -86,7 +86,7 @@ def base_field(x):
-         sage: R.base_field()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'
-+        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'...
-     """
-     try:
-         return x.base_field()
-diff --git a/src/sage/misc/instancedoc.pyx b/src/sage/misc/instancedoc.pyx
-index d8e1e4ac536..44ee70f64ba 100644
---- a/src/sage/misc/instancedoc.pyx
-+++ b/src/sage/misc/instancedoc.pyx
-@@ -256,7 +256,7 @@ cdef class InstanceDocDescriptor:
-             sage: descr.__delete__(obj)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'X' object has no attribute '__doc__'
-+            AttributeError: 'X' object has no attribute '__doc__'...
- 
-             sage: descr.__delete__([])
-             Traceback (most recent call last):
-diff --git a/src/sage/misc/lazy_attribute.pyx b/src/sage/misc/lazy_attribute.pyx
-index bdbec3b3ba1..1f07870b8ec 100644
---- a/src/sage/misc/lazy_attribute.pyx
-+++ b/src/sage/misc/lazy_attribute.pyx
-@@ -441,37 +441,37 @@ class lazy_attribute(_lazy_attribute):
-             sage: B().unimplemented_A # todo: not implemented
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'super' object has no attribute 'unimplemented_A'
-+            AttributeError: 'super' object has no attribute 'unimplemented_A'...
- 
-     We now make some systematic checks::
- 
-         sage: B().unimplemented_A
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: B().unimplemented_B
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: B().unimplemented_AB
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: B().unimplemented_B_implemented_A
-         1
- 
-         sage: C().unimplemented_A()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: C().unimplemented_B()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: C().unimplemented_AB()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: C().unimplemented_B_implemented_A # todo: not implemented
-         1
-     """
-diff --git a/src/sage/misc/object_multiplexer.py b/src/sage/misc/object_multiplexer.py
-index d4e811ef16e..00fd89d6652 100644
---- a/src/sage/misc/object_multiplexer.py
-+++ b/src/sage/misc/object_multiplexer.py
-@@ -85,7 +85,7 @@ def __getattr__(self, name):
-             sage: m.__bork__
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Multiplex' has no attribute '__bork__'
-+            AttributeError: 'Multiplex' has no attribute '__bork__'...
-         """
-         if name.startswith("__"):
-             raise AttributeError("'Multiplex' has no attribute '%s'" % name)
-diff --git a/src/sage/misc/sage_input.py b/src/sage/misc/sage_input.py
-index 66e78ecccbc..00e8d96ee9e 100644
---- a/src/sage/misc/sage_input.py
-+++ b/src/sage/misc/sage_input.py
-@@ -3461,7 +3461,7 @@ def verify_same(a, b):
-         sage: verify_same(1, 1r)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_same(1r, 1)
-         Traceback (most recent call last):
-         ...
-@@ -3525,7 +3525,7 @@ def verify_si_answer(x, answer, preparse):
-         sage: verify_si_answer(1, '1', False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_si_answer(1, 'ZZ(1)', None)
-     """
-     from sage.misc.sage_eval import sage_eval
-diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py
-index f0545be7d81..811afc48755 100644
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -602,7 +602,7 @@ def visit_Num(self, node):
-             On Python 3 negative numbers are parsed first, for some reason, as
-             a UnaryOp node.
-         """
--        return node.n
-+        return node.value
- 
-     def visit_Str(self, node):
-         r"""
-@@ -624,7 +624,7 @@ def visit_Str(self, node):
-             sage: [vis(s) for s in ['"abstract"', "'syntax'", r'''r"tr\ee"''']]
-             ['abstract', 'syntax', 'tr\\ee']
-         """
--        return node.s
-+        return node.value
- 
-     def visit_List(self, node):
-         """
-diff --git a/src/sage/modules/fp_graded/steenrod/module.py b/src/sage/modules/fp_graded/steenrod/module.py
-index 18460b0e9a1..4acfa6b4002 100755
---- a/src/sage/modules/fp_graded/steenrod/module.py
-+++ b/src/sage/modules/fp_graded/steenrod/module.py
-@@ -70,7 +70,7 @@
-     sage: SteenrodFPModule(ZZ, [0])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'
-+    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'...
- 
- AUTHORS:
- 
-diff --git a/src/sage/monoids/trace_monoid.py b/src/sage/monoids/trace_monoid.py
-index 00baa4d14f8..f8176a1e1f2 100644
---- a/src/sage/monoids/trace_monoid.py
-+++ b/src/sage/monoids/trace_monoid.py
-@@ -40,7 +40,6 @@
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from collections import OrderedDict
- from itertools import repeat, chain, product
- 
- from sage.misc.cachefunc import cached_method
-@@ -633,14 +632,14 @@ def _compute_dependence_stack(self, x):
-             sage: x = b*a*d*a*c*b
-             sage: M._compute_dependence_stack(x)
-             ({a, b, c, d},
--             OrderedDict([(a, [False, False, True, True, False]),
--                          (b, [True, False, False, False, True]),
--                          (c, [True, False, False, False]),
--                          (d, [False, False, True, False])]))
-+             {a: [False, False, True, True, False],
-+              b: [True, False, False, False, True],
-+              c: [True, False, False, False],
-+              d: [False, False, True, False]})
-         """
-         independence = self._independence
-         generators_set = set(e for e, _ in x)
--        stacks = OrderedDict(sorted((g, []) for g in generators_set))
-+        stacks = dict(sorted((g, []) for g in generators_set))
-         for generator, times in reversed(list(x)):
-             stacks[generator].extend(repeat(True, times))
-             for other_gen in generators_set:
-diff --git a/src/sage/parallel/map_reduce.py b/src/sage/parallel/map_reduce.py
-index 11e0673ee91..5441943731d 100644
---- a/src/sage/parallel/map_reduce.py
-+++ b/src/sage/parallel/map_reduce.py
-@@ -1234,7 +1234,7 @@ def finish(self):
-             sage: S.print_communication_statistics()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'RESetMPExample' object has no attribute '_stats'
-+            AttributeError: 'RESetMPExample' object has no attribute '_stats'...
- 
-             sage: S.finish()
- 
-diff --git a/src/sage/plot/colors.py b/src/sage/plot/colors.py
-index 8c0db2b3c34..3281199400b 100644
---- a/src/sage/plot/colors.py
-+++ b/src/sage/plot/colors.py
-@@ -1099,7 +1099,7 @@ def __getattr__(self, name):
-             sage: cols.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ColorsDict' has no attribute or colormap punk
-+            AttributeError: 'ColorsDict' has no attribute or colormap punk...
-         """
-         try:
-             return self[name]
-@@ -1599,7 +1599,7 @@ def __getattr__(self, name):
-             sage: maps.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Colormaps' has no attribute or colormap punk
-+            AttributeError: 'Colormaps' has no attribute or colormap punk...
-             sage: maps['punk']
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/rings/asymptotic/asymptotic_ring.py b/src/sage/rings/asymptotic/asymptotic_ring.py
-index b07319382d3..994490e6616 100644
---- a/src/sage/rings/asymptotic/asymptotic_ring.py
-+++ b/src/sage/rings/asymptotic/asymptotic_ring.py
-@@ -1091,7 +1091,7 @@ def monomial_coefficient(self, monomial):
-             sage: O(n).monomial_coefficient(n)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'
-+            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'...
- 
-         The ``monomial`` must be exact::
- 
-diff --git a/src/sage/rings/asymptotic/growth_group.py b/src/sage/rings/asymptotic/growth_group.py
-index 27c14592bca..5be12537d62 100644
---- a/src/sage/rings/asymptotic/growth_group.py
-+++ b/src/sage/rings/asymptotic/growth_group.py
-@@ -1572,7 +1572,7 @@ def variable_names(self):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'GenericGrowthGroup_with_category.element_class' object
--            has no attribute 'is_one'
-+            has no attribute 'is_one'...
-         """
-         if self.is_one():
-             return tuple()
-diff --git a/src/sage/rings/ideal.py b/src/sage/rings/ideal.py
-index d36d9406f32..01c9fa3bf2d 100644
---- a/src/sage/rings/ideal.py
-+++ b/src/sage/rings/ideal.py
-@@ -1553,7 +1553,7 @@ def gcd(self, other):
-             sage: J.gcd(I)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Ideal_generic' object has no attribute 'gcd'
-+            AttributeError: 'Ideal_generic' object has no attribute 'gcd'...
- 
-         Note::
- 
-diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
-index 7fe89197011..8832d27e8ea 100644
---- a/src/sage/rings/number_field/number_field.py
-+++ b/src/sage/rings/number_field/number_field.py
-@@ -3823,7 +3823,7 @@ def primes_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
-         """
-         if degree is not None:
-             degree = ZZ(degree)
-@@ -3917,7 +3917,7 @@ def prime_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
- 
-         """
-         ids = self.primes_above(x, degree)
-@@ -5926,7 +5926,7 @@ def factor(self, n):
-             sage: L.factor(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'...
- 
-         AUTHORS:
- 
-@@ -12698,7 +12698,7 @@ def is_real_place(v):
-         sage: is_real_place(v_fin)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'
-+        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'...
- 
-     """
-     RR = sage.rings.real_mpfr.RealField(53)
-diff --git a/src/sage/rings/padics/generic_nodes.py b/src/sage/rings/padics/generic_nodes.py
-index 7047020edec..b6b514d4005 100644
---- a/src/sage/rings/padics/generic_nodes.py
-+++ b/src/sage/rings/padics/generic_nodes.py
-@@ -740,7 +740,7 @@ def _get_element_class(self, name=None):
-             sage: R._get_element_class("foobar")
-             Traceback (most recent call last):
-             ...
--            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'
-+            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'...
-         """
-         if name is None:
-             return self.Element
-diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx
-index c5a1129aecf..a5b7f937cfe 100644
---- a/src/sage/rings/polynomial/polynomial_element.pyx
-+++ b/src/sage/rings/polynomial/polynomial_element.pyx
-@@ -10793,7 +10793,7 @@ cdef class Polynomial(CommutativePolynomial):
-             sage: (y**2 + x).nth_root(2)
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... has no attribute 'nth_root'
-+            AttributeError: ... has no attribute 'nth_root'...
- 
-         TESTS::
- 
-@@ -11831,7 +11831,7 @@ cdef class Polynomial_generic_dense(Polynomial):
-             sage: int(1) // x  # check that this doesn't segfault
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'int' has no attribute 'base_ring'
-+            AttributeError: type object 'int' has no attribute 'base_ring'...
-         """
-         if have_same_parent(self, right):
-             return (<Polynomial_generic_dense>self)._floordiv_(<Polynomial_generic_dense>right)
-diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-index e372be888ee..aca4f08420f 100644
---- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
-+++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-@@ -2362,7 +2362,7 @@ def field_extension(self, names):
-             sage: F, g, h = S.field_extension('b')                                      # needs sage.rings.finite_rings
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'
-+            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'...
- 
-         Over a finite field, the corresponding field extension is not a
-         number field::
-diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx
-index 5273891a5b0..a6e999b8805 100644
---- a/src/sage/rings/ring.pyx
-+++ b/src/sage/rings/ring.pyx
-@@ -1734,7 +1734,7 @@ cdef class IntegralDomain(CommutativeRing):
-             sage: Z5.is_integrally_closed()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'
-+            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'...
-         """
-         raise NotImplementedError
- 
-diff --git a/src/sage/sat/solvers/satsolver.pyx b/src/sage/sat/solvers/satsolver.pyx
-index c2f41b18f55..1c4ac400cb6 100644
---- a/src/sage/sat/solvers/satsolver.pyx
-+++ b/src/sage/sat/solvers/satsolver.pyx
-@@ -375,10 +375,10 @@ def SAT(solver=None, *args, **kwds):
-         DIMACS Solver: 'kissat -q {input}'
-     """
-     if solver is None:
--        import pkgutil
--        if pkgutil.find_loader('pycryptosat') is not None:
-+        from importlib.util import find_spec
-+        if find_spec('pycryptosat') is not None:
-             solver = "cryptominisat"
--        elif pkgutil.find_loader('pycosat') is not None:
-+        elif find_spec('pycosat') is not None:
-             solver = "picosat"
-         else:
-             solver = "LP"
-diff --git a/src/sage/schemes/toric/morphism.py b/src/sage/schemes/toric/morphism.py
-index 1c8944b6dfc..5d64d632f97 100644
---- a/src/sage/schemes/toric/morphism.py
-+++ b/src/sage/schemes/toric/morphism.py
-@@ -246,7 +246,7 @@
-     Traceback (most recent call last):
-     ...
-     AttributeError: 'SchemeMorphism_fan_toric_variety' object
--    has no attribute 'fiber_generic'
-+    has no attribute 'fiber_generic'...
- 
- Let's use factorization mentioned above::
- 
-diff --git a/src/sage/sets/disjoint_union_enumerated_sets.py b/src/sage/sets/disjoint_union_enumerated_sets.py
-index 3dea567a779..5c5e08612f2 100644
---- a/src/sage/sets/disjoint_union_enumerated_sets.py
-+++ b/src/sage/sets/disjoint_union_enumerated_sets.py
-@@ -597,7 +597,7 @@ def Element(self):
-             sage: U.Element
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'
-+            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'...
-         """
-         if not self._facade:
-             return ElementWrapper
-diff --git a/src/sage/sets/set.py b/src/sage/sets/set.py
-index a1789c61300..112d3d8dc3b 100644
---- a/src/sage/sets/set.py
-+++ b/src/sage/sets/set.py
-@@ -163,7 +163,7 @@ def Set(X=None, category=None):
-         sage: sorted(B.list(), key=repr)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'Set_object_with_category' object has no attribute 'list'
-+        AttributeError: 'Set_object_with_category' object has no attribute 'list'...
-         sage: type(B)
-         <class 'sage.sets.set.Set_object_with_category'>
- 
-diff --git a/src/sage/structure/category_object.pyx b/src/sage/structure/category_object.pyx
-index b6a7eaecb5b..c06933494dc 100644
---- a/src/sage/structure/category_object.pyx
-+++ b/src/sage/structure/category_object.pyx
-@@ -836,7 +836,7 @@ cdef class CategoryObject(SageObject):
-             sage: Sets().example().sadfasdf
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'
-+            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'...
-         """
-         return self.getattr_from_category(name)
- 
-diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx
-index caae7e40ffc..543506e9a74 100644
---- a/src/sage/structure/element.pyx
-+++ b/src/sage/structure/element.pyx
-@@ -219,7 +219,7 @@ the parents::
-     sage: x._add_(x)
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-     sage: x + x
-     Traceback (most recent call last):
-     ...
-@@ -478,13 +478,13 @@ cdef class Element(SageObject):
-             sage: 1.blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'...
-             sage: Semigroups().example().an_element().is_idempotent
-             <bound method LeftZeroSemigroup.Element.is_idempotent of 42>
-             sage: Semigroups().example().an_element().blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'
-+            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'...
-         """
-         return self.getattr_from_category(name)
- 
-@@ -1269,7 +1269,7 @@ cdef class Element(SageObject):
-             sage: e._add_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-         """
-         try:
-             python_op = (<object>self)._add_
-@@ -1381,7 +1381,7 @@ cdef class Element(SageObject):
-             sage: e._sub_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'...
-         """
-         try:
-             python_op = (<object>self)._sub_
-@@ -1435,7 +1435,7 @@ cdef class Element(SageObject):
-             sage: e._neg_()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'...
-         """
-         try:
-             python_op = (<object>self)._neg_
-@@ -1549,7 +1549,7 @@ cdef class Element(SageObject):
-             sage: e._mul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'...
-         """
-         try:
-             python_op = (<object>self)._mul_
-@@ -1662,7 +1662,7 @@ cdef class Element(SageObject):
-             sage: e._matmul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'...
-         """
-         try:
-             python_op = (<object>self)._matmul_
-@@ -1765,7 +1765,7 @@ cdef class Element(SageObject):
-             sage: e._div_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'...
-         """
-         try:
-             python_op = (<object>self)._div_
-@@ -1865,7 +1865,7 @@ cdef class Element(SageObject):
-             sage: e._floordiv_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'...
-         """
-         try:
-             python_op = (<object>self)._floordiv_
-@@ -1965,7 +1965,7 @@ cdef class Element(SageObject):
-             sage: e._mod_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'...
-         """
-         try:
-             python_op = (<object>self)._mod_
-@@ -2092,7 +2092,7 @@ cdef class Element(SageObject):
-             sage: e._pow_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'...
-         """
-         try:
-             python_op = (<object>self)._pow_
-@@ -2122,7 +2122,7 @@ cdef class Element(SageObject):
-             sage: e._pow_int(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'...
-         """
-         try:
-             python_op = (<object>self)._pow_int
-@@ -2856,7 +2856,7 @@ cdef class RingElement(ModuleElement):
-             sage: m.is_nilpotent()                                                      # needs sage.modules
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... object has no attribute 'is_nilpotent'
-+            AttributeError: '...' object has no attribute 'is_nilpotent'...
-         """
-         if self.is_unit():
-             return False
-@@ -4671,7 +4671,7 @@ def coerce_binop(method):
-         sage: x.test_add(CC(2))
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'
-+        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'...
- 
-     TESTS:
- 
-diff --git a/src/sage/structure/sequence.py b/src/sage/structure/sequence.py
-index 0c700c1fb81..c3972532ac3 100644
---- a/src/sage/structure/sequence.py
-+++ b/src/sage/structure/sequence.py
-@@ -854,7 +854,7 @@ def __getattr__(self, name):
-             sage: S.universe()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'...
-             sage: S._Sequence__universe = 'foobar'
-             sage: S.universe()
-             'foobar'
-@@ -867,7 +867,7 @@ def __getattr__(self, name):
-             sage: hash(S)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'...
-             sage: S._Sequence__hash = int(34)
-             sage: hash(S)
-             34
-diff --git a/src/sage/symbolic/assumptions.py b/src/sage/symbolic/assumptions.py
-index 7dcb15f0d85..15f6fa07ce6 100644
---- a/src/sage/symbolic/assumptions.py
-+++ b/src/sage/symbolic/assumptions.py
-@@ -636,7 +636,7 @@ def assume(*args):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no
--        attribute 'assume'
-+        attribute 'assume'...
- 
-     Ensure that we can combine the two types of assumptions, as documented::
- 
-diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx
-index 0f251ac4e5c..66f624141b3 100644
---- a/src/sage/symbolic/expression.pyx
-+++ b/src/sage/symbolic/expression.pyx
-@@ -13712,7 +13712,7 @@ cdef get_dynamic_class_for_function(unsigned serial):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.symbolic.expression.Expression' object has no
--        attribute 'argp1'
-+        attribute 'argp1'...
-         sage: t = (e + 1).op[0]; t
-         tfunc(x)
-         sage: t
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index c4152e092e3..4bcf45e8793 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -67,6 +67,7 @@
- #include "archive.h"
- #include "tostring.h"
- #include "utils.h"
-+#include "../../cpython/pycore_long.h"
- 
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wdeprecated-register"
-@@ -706,18 +707,12 @@ static long _mpq_pythonhash(mpq_t the_rat)
- // Initialize an mpz_t from a Python long integer
- static void _mpz_set_pylong(mpz_t z, PyLongObject* l)
- {
--    Py_ssize_t pylong_size = Py_SIZE(l);
--    int sign = 1;
--
--    if (pylong_size < 0) {
--        pylong_size = -pylong_size;
--        sign = -1;
--    }
-+    Py_ssize_t pylong_size = _PyLong_DigitCount(l);
- 
-     mpz_import(z, pylong_size, -1, sizeof(digit), 0,
--               8*sizeof(digit) - PyLong_SHIFT, l->ob_digit);
-+               8*sizeof(digit) - PyLong_SHIFT, ob_digit(l));
- 
--    if (sign < 0)
-+    if (_PyLong_IsNegative(l))
-         mpz_neg(z, z);
- }
- 
-diff --git a/src/sage/symbolic/pynac_impl.pxi b/src/sage/symbolic/pynac_impl.pxi
-index 68c31dcfde7..7fd7c3b314b 100644
---- a/src/sage/symbolic/pynac_impl.pxi
-+++ b/src/sage/symbolic/pynac_impl.pxi
-@@ -619,7 +619,7 @@ def tolerant_is_symbol(a):
-         sage: None.is_symbol()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute 'is_symbol'
-+        AttributeError: 'NoneType' object has no attribute 'is_symbol'...
-     """
-     try:
-         return a.is_symbol()
diff --git a/srcpkgs/sagemath/patches/36769-fix_jmol_detect.patch b/srcpkgs/sagemath/patches/36769-fix_jmol_detect.patch
new file mode 100644
index 0000000000000..c7c983fe50c0d
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36769-fix_jmol_detect.patch
@@ -0,0 +1,92 @@
+diff --git a/src/sage/interfaces/jmoldata.py b/src/sage/interfaces/jmoldata.py
+index a68e53e2d85..55c07255b74 100644
+--- a/src/sage/interfaces/jmoldata.py
++++ b/src/sage/interfaces/jmoldata.py
+@@ -71,6 +71,47 @@ def is_jvm_available(self):
+         java_version_number = int(re.sub(r'.*version "(0\.|1\.)?(\d*)[\s\S]*', r'\2', version, flags=re.S))
+         return java_version_number >= 7
+ 
++    def jmolpath(self):
++        """
++        Return the path to the jar file.
++
++        EXAMPLES::
++
++            sage: from sage.interfaces.jmoldata import JmolData
++            sage: JData = JmolData()
++            sage: JData.jmolpath()
++            '.../JmolData.jar'
++
++        """
++        jmolpath = os.path.join(JMOL_DIR, "JmolData.jar")
++
++        if sys.platform == 'cygwin':
++            import cygwin
++            jmolpath = cygwin.cygpath(jmolpath, 'w')
++
++        return jmolpath
++
++    def is_jmol_available(self):
++        """
++        Returns True if jmol is available and False if not.
++
++        EXAMPLES:
++
++        Check that it returns a boolean::
++
++            sage: from sage.interfaces.jmoldata import JmolData
++            sage: JData = JmolData()
++            sage: type(JData.is_jmol_available())
++            <... 'bool'>
++        """
++        if not os.path.isfile(self.jmolpath()):
++            return False
++
++        if not self.is_jvm_available():
++            return False
++
++        return True
++
+     def export_image(self,
+         targetfile,
+         datafile, #name (path) of data file Jmol can read or script file telling it what to read or load
+@@ -154,12 +195,11 @@ def export_image(self,
+             sage: archive.close()
+         """
+         # Set up paths, file names and scripts
+-        jmolpath = os.path.join(JMOL_DIR, "JmolData.jar")
++        jmolpath = self.jmolpath()
+         target_native = targetfile
+ 
+         if sys.platform == 'cygwin':
+             import cygwin
+-            jmolpath = cygwin.cygpath(jmolpath, 'w')
+             target_native = cygwin.cygpath(target_native, 'w')
+             if datafile_cmd != 'script':
+                 datafile = cygwin.cygpath(datafile, 'w')
+diff --git a/src/sage/plot/plot3d/base.pyx b/src/sage/plot/plot3d/base.pyx
+index 253f152130c..7588cde2e27 100644
+--- a/src/sage/plot/plot3d/base.pyx
++++ b/src/sage/plot/plot3d/base.pyx
+@@ -278,7 +278,7 @@ cdef class Graphics3d(SageObject):
+         T.export_jmol(scene_zip, **opts)
+         from sage.interfaces.jmoldata import JmolData
+         jdata = JmolData()
+-        if not jdata.is_jvm_available():
++        if not jdata.is_jmol_available():
+             # We can only use JMol to generate preview if a jvm is installed
+             from sage.repl.rich_output.output_graphics import OutputImagePng
+             tachyon = self._rich_repr_tachyon(OutputImagePng, **opts)
+diff --git a/src/sage/repl/rich_output/backend_ipython.py b/src/sage/repl/rich_output/backend_ipython.py
+index 69e63b76d60..10ccdc0c2c8 100644
+--- a/src/sage/repl/rich_output/backend_ipython.py
++++ b/src/sage/repl/rich_output/backend_ipython.py
+@@ -369,7 +369,7 @@ def launch_jmol(self, output_jmol, plain_text):
+         from sage.doctest import DOCTEST_MODE
+         from sage.interfaces.jmoldata import JmolData
+         jdata = JmolData()
+-        if not jdata.is_jvm_available() and not DOCTEST_MODE:
++        if not jdata.is_jmol_available() and not DOCTEST_MODE:
+             raise RuntimeError('jmol cannot run, no suitable java version found')
+         launch_script = output_jmol.launch_script_filename()
+         jmol_cmd = 'jmol'
diff --git a/srcpkgs/sagemath/patches/get_patches b/srcpkgs/sagemath/patches/get_patches
index 95a6963432948..b179e2f7f190c 100755
--- a/srcpkgs/sagemath/patches/get_patches
+++ b/srcpkgs/sagemath/patches/get_patches
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-version=10.1
+version=10.2.rc5
 
 URL_BASE_PR="https://github.com/sagemath/sage/pull/"
 URL_BASE_COMPARE="https://github.com/sagemath/sage/compare/${version}..."
@@ -20,24 +20,6 @@ get_pr() {
 # run from patches dir
 cd $(dirname "$0")
 
-# merged in 10.2.beta0
-#get_pr  36018   "singular 4.3.2p4" # included in #35934
-get_pr  36046   "fix memory leak"
-
-# merged in 10.2.beta1
-get_pr  35934   "singular 4.3.2p7"
-
-# merged in 10.2.beta2
-get_pr  36006   "gmp 6.3.0"
-
-# merged in 10.2.beta3
-get_pr  36235   "ecl 23.9.9"
-
-# merged in 10.2.beta4
-get_pr  36279   "matplotlib 3.8.0"
-
-# positive review
-#get_pr  36403   "python 3.12" # included in #36407
-
 # needs review
-get_pr  36407   "python 3.12"
+get_pr  35848   "flintlib 3.0"
+get_pr  36769   "fix jmol detect"
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index a80d8b7187ece..d07fa97a95f11 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,14 +1,14 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=10.1
-revision=4
+version=10.2.rc5
+revision=1
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
 _bindir=/usr/lib/sagemath/$version/bin
 make_install_args="--install-scripts=$_bindir"
-hostmakedepends="m4 pkg-config python3-Cython0.29 python3-Jinja2
+hostmakedepends="m4 pkg-config python3-Cython python3-Jinja2
  python3-pkgconfig python3-setuptools"
-makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
+makedepends="boost-devel brial-devel cliquer-devel ecl eclib-devel
  ecm-devel fflas-ffpack flintlib-devel gap-devel gd-devel giac-devel glpk-devel
  gsl-devel iml-devel lcalc-devel libbraiding-devel libhomfly-devel libmpc-devel
  libpng-devel linbox-devel m4ri-devel m4rie-devel mpfi-devel
@@ -18,7 +18,7 @@ makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
 depends="eclib-devel fflas-ffpack flintlib-devel gcc-fortran gd-devel
  gfan giac gsl-devel gzip libpng-devel linbox-devel m4ri-devel maxima-ecl
  mpfr-devel nauty ntl-devel palp pari-devel pari-elldata-small pari-galdata
- pari-galpol-small pari-seadata-small pkg-config python3-Cython0.29 python3-cypari2
+ pari-galpol-small pari-seadata-small pkg-config python3-Cython python3-cypari2
  python3-cysignals python3-devel python3-fpylll python3-ipython python3-lrcalc
  python3-ipython_ipykernel python3-jupyter_ipywidgets python3-matplotlib
  python3-memory_allocator python3-networkx python3-pip python3-pkgconfig
@@ -33,7 +33,7 @@ license="GPL-2.0-or-later"
 homepage="https://www.sagemath.org/"
 changelog="https://github.com/sagemath/sage/releases"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=a658612b1b2376ddaf207cc8ed0ef458d4c2880c16e19139bedbe8baa42ad62f
+checksum=1156d5e214acc15ebf1a9ec41c726eb82d96d1161880a18fe015c479b282c342
 nocross="due to ntl (flintlib), fflas-ffpack, givaro, linbox, cysignals, sympow, maxima"
 
 post_patch() {
diff --git a/srcpkgs/sagemath/update b/srcpkgs/sagemath/update
index 68be3c5752d06..4e62503e2f8f4 100644
--- a/srcpkgs/sagemath/update
+++ b/srcpkgs/sagemath/update
@@ -1,2 +1,3 @@
 pkgname="sage"
-site="https://mirrors.mit.edu/sage/src/index.html"
+site="https://mirrors.mit.edu/sage/src/
+https://mirrors.mit.edu/sage/devel/"

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

* Re: [PR PATCH] [Updated] [RC] sagemath: update to 10.2, flintlib: update to 3.0.1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (22 preceding siblings ...)
  2023-12-01 21:08 ` tornaria
@ 2023-12-03 14:20 ` tornaria
  2023-12-03 16:18 ` [PR PATCH] [Updated] " tornaria
                   ` (4 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: tornaria @ 2023-12-03 14:20 UTC (permalink / raw)
  To: ml

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

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

https://github.com/tornaria/void-packages flintlib
https://github.com/void-linux/void-packages/pull/46832

[RC] sagemath: update to 10.2, flintlib: update to 3.0.1
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **briefly**

This is a major update. A couple of packages need rebuilding (eclib, singular).

For sagemath, we need a patch (in progress: https://github.com/sagemath/sage/pull/35848).

Since backporting patches is a pain and we are not in a hurry, I'm instead targeting 10.2.beta8. Note this already moves sagemath to cython 3.

The goal is to merge flintlib 3.0 together with sagemath 10.2 when the latter is released.

<!--
#### 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/46832.patch is attached

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

From 4b4bc7718a0974b6657328d3344c99b1f0168224 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 11 Sep 2023 20:11:20 -0300
Subject: [PATCH 1/6] flintlib: update to 3.0.1.

---
 common/shlibs                                 |  3 +--
 srcpkgs/arb                                   |  1 +
 srcpkgs/arb-devel                             |  2 +-
 srcpkgs/arb/template                          | 24 -------------------
 .../patches/fix-test-t-sdiv_qrnnd.patch       | 23 ------------------
 srcpkgs/flintlib/template                     | 21 ++++++++++++----
 6 files changed, 20 insertions(+), 54 deletions(-)
 create mode 120000 srcpkgs/arb
 delete mode 100644 srcpkgs/arb/template
 delete mode 100644 srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch

diff --git a/common/shlibs b/common/shlibs
index 1b25a12956eeb..ca04472aec634 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3971,8 +3971,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.17 flintlib-2.9.0_1
-libarb.so.2 arb-2.20.0_1
+libflint.so.18 flintlib-3.0.0_1
 libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
diff --git a/srcpkgs/arb b/srcpkgs/arb
new file mode 120000
index 0000000000000..7c2633183069f
--- /dev/null
+++ b/srcpkgs/arb
@@ -0,0 +1 @@
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb-devel b/srcpkgs/arb-devel
index 456b9f00a86cd..7c2633183069f 120000
--- a/srcpkgs/arb-devel
+++ b/srcpkgs/arb-devel
@@ -1 +1 @@
-arb
\ No newline at end of file
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
deleted file mode 100644
index 84a62c7ffdba3..0000000000000
--- a/srcpkgs/arb/template
+++ /dev/null
@@ -1,24 +0,0 @@
-# Template file for 'arb'
-pkgname=arb
-version=2.23.0
-revision=1
-build_style=configure
-configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
-makedepends="flintlib-devel"
-short_desc="C library for arbitrary-precision interval arithmetic"
-maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
-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=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
-
-arb-devel_package() {
-	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"
-	short_desc+=" - development files"
-	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.a"
-		vmove "usr/lib/*.so"
-	}
-}
diff --git a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch b/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
deleted file mode 100644
index cfa109792892c..0000000000000
--- a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From fb8ddbcc06afa2a8f25637032fbb8211f6c6c122 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= <albin.ahlback@gmail.com>
-Date: Fri, 20 May 2022 14:16:38 +0200
-Subject: [PATCH] Fix bug in test code for GCC 12
-
----
- test/t-sdiv_qrnnd.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/test/t-sdiv_qrnnd.c b/test/t-sdiv_qrnnd.c
-index 2e9822e848..2676903826 100644
---- a/test/t-sdiv_qrnnd.c
-+++ b/test/t-sdiv_qrnnd.c
-@@ -33,7 +33,7 @@ int main(void)
-         {
-             d = n_randtest_not_zero(state);
-             nh = n_randtest(state);
--        } while ((FLINT_ABS(nh) >= FLINT_ABS(d)/2) || (nh == WORD_MIN));
-+        } while ((nh == WORD_MIN) || (FLINT_ABS(nh) >= FLINT_ABS(d)/2));
- 
-         nl = n_randtest(state);
- 
-
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index f7442c8052aaa..254d18c42f5b3 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,10 +1,10 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.9.0
+version=3.0.1
 revision=1
-build_style=configure
+build_style=gnu-configure
 configure_args="--prefix=/usr $(vopt_with ntl)
- $(vopt_if openblas --with-blas=${XBPS_CROSS_BASE}/usr/include/openblas)"
+ $(vopt_if openblas --with-blas-include=${XBPS_CROSS_BASE}/usr/include/openblas)"
 makedepends="mpfr-devel $(vopt_if ntl ntl-devel)
  $(vopt_if openblas openblas-devel)"
 short_desc="Fast Library for Number Theory"
@@ -13,7 +13,7 @@ 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=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
+checksum=7b311a00503a863881eb8177dbeb84322f29399f3d7d72f3b1a4c9ba1d5794b4
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
@@ -33,7 +33,20 @@ flintlib-devel_package() {
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
+		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
 		vmove "usr/lib/*.so"
 	}
 }
+
+arb_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}
+
+arb-devel_package() {
+	depends="${sourcepkg}-devel>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From f22e5c7930f0c652d238112f86624f27aee47d6e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:08:05 -0300
Subject: [PATCH 2/6] eclib: rebuild for flintlib-3.0.1

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

diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 1d4ad58f21b7b..12165ca788dd5 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
 version=20230424
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 makedepends="pari-devel ntl-devel flintlib-devel boost-devel"

From 8dd09094107f3ddb71b2e102eba132017aefcc81 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:13:15 -0300
Subject: [PATCH 3/6] singular: update to 4.3.2p10.

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

diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index 036e19d470354..beb0e6d30118e 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,6 +1,6 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.2p7
+version=4.3.2p10
 revision=1
 _majver=${version%p*}
 build_style=gnu-configure
@@ -20,7 +20,7 @@ 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/${_majver//./-}/singular-${version}.tar.gz"
-checksum=aad23c30066b7fbc011138a98d60532565d76a847eec6bf2938410d93b272ca3
+checksum=28c2c9fcfee954e00dfa56eb1a7d418d5b1de67c4398d25a0f2b8f73e71552a8
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From e7a1d725324c3bbb57006038708ecece95ec3776 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 19 Jul 2023 21:04:33 -0300
Subject: [PATCH 4/6] python3-pplpy: use cython 3.

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

diff --git a/srcpkgs/python3-pplpy/template b/srcpkgs/python3-pplpy/template
index 4a9c987b2a859..d3b9aebdf2237 100644
--- a/srcpkgs/python3-pplpy/template
+++ b/srcpkgs/python3-pplpy/template
@@ -1,9 +1,9 @@
 # Template file for 'python3-pplpy'
 pkgname=python3-pplpy
 version=0.8.9
-revision=1
+revision=2
 build_style=python3-pep517
-hostmakedepends="python3-setuptools python3-wheel python3-Cython0.29
+hostmakedepends="python3-setuptools python3-wheel python3-Cython
  python3-cysignals python3-gmpy2"
 makedepends="python3-devel gmp-devel gmpxx-devel ppl-devel mpfr-devel
  libmpc-devel pari-devel"

From 9bb81d7bcf3e6c87454d16e919cad5845e213a2d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Thu, 19 Oct 2023 08:52:15 -0300
Subject: [PATCH 5/6] python3-networkx: update to 3.2.1.

---
 srcpkgs/python3-networkx/template | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/python3-networkx/template b/srcpkgs/python3-networkx/template
index 186bf64f7bff9..29283d9e5a032 100644
--- a/srcpkgs/python3-networkx/template
+++ b/srcpkgs/python3-networkx/template
@@ -1,11 +1,11 @@
 # Template file for 'python3-networkx'
 pkgname=python3-networkx
-version=3.1
-revision=2
-build_style=python3-module
+version=3.2.1
+revision=1
+build_style=python3-pep517
 # failing in i686
 make_check_args="--deselect networkx/algorithms/approximation/tests/test_traveling_salesman.py::test_asadpour_tsp"
-hostmakedepends="python3-setuptools"
+hostmakedepends="python3-setuptools python3-wheel"
 depends="python3"
 checkdepends="python3-numpy python3-scipy python3-matplotlib python3-pandas
  python3-lxml python3-sympy python3-pytest-xdist"
@@ -15,7 +15,7 @@ license="BSD-3-Clause"
 homepage="https://networkx.org"
 changelog="https://github.com/networkx/networkx/raw/main/doc/release/release_${version}.rst"
 distfiles="${PYPI_SITE}/n/networkx/networkx-${version}.tar.gz"
-checksum=de346335408f84de0eada6ff9fafafff9bcda11f0a0dfaa931133debb146ab61
+checksum=9f1bb5cf3409bf324e0a722c20bdb4c20ee39bf1c30ce8ae499c8502b0b5e0c6
 
 post_install() {
 	vlicense LICENSE.txt

From 0f69a335c1dadfcfabcc2b1f8a772920a862214f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:50:44 -0300
Subject: [PATCH 6/6] sagemath: update to 10.2.

---
 .../sagemath/patches/35848-flintlib_3.0.patch | 1867 +++++++++++++++++
 .../patches/35934-singular_4.3.2p7.patch      |  221 --
 .../sagemath/patches/36006-gmp_6.3.0.patch    |   38 -
 .../patches/36046-fix_memory_leak.patch       |  740 -------
 .../sagemath/patches/36235-ecl_23.9.9.patch   |   39 -
 .../patches/36279-matplotlib_3.8.0.patch      |   24 -
 srcpkgs/sagemath/patches/36403-00pre.patch    |   29 -
 .../sagemath/patches/36407-python_3.12.patch  | 1744 ---------------
 .../patches/36769-fix_jmol_detect.patch       |   92 +
 srcpkgs/sagemath/patches/get_patches          |   24 +-
 srcpkgs/sagemath/template                     |   14 +-
 srcpkgs/sagemath/update                       |    3 +-
 12 files changed, 1971 insertions(+), 2864 deletions(-)
 create mode 100644 srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
 delete mode 100644 srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
 delete mode 100644 srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
 delete mode 100644 srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36403-00pre.patch
 delete mode 100644 srcpkgs/sagemath/patches/36407-python_3.12.patch
 create mode 100644 srcpkgs/sagemath/patches/36769-fix_jmol_detect.patch

diff --git a/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
new file mode 100644
index 0000000000000..2cad28134f6e6
--- /dev/null
+++ b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
@@ -0,0 +1,1867 @@
+diff --git a/build/pkgs/antic/SPKG.rst b/build/pkgs/antic/SPKG.rst
+deleted file mode 100644
+index d6c32377957..00000000000
+--- a/build/pkgs/antic/SPKG.rst
++++ /dev/null
+@@ -1,18 +0,0 @@
+-antic: Algebraic Number Theory In C
+-===================================
+-
+-Description
+------------
+-
+-Algebraic Number Theory In C
+-
+-License
+--------
+-
+-LGPL 2.1
+-
+-Upstream Contact
+-----------------
+-
+-https://github.com/wbhart/antic
+-
+diff --git a/build/pkgs/antic/checksums.ini b/build/pkgs/antic/checksums.ini
+deleted file mode 100644
+index fc8711ecd13..00000000000
+--- a/build/pkgs/antic/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=antic-VERSION.tar.gz
+-sha1=940d8ea2c3512b9d49ee3101cf043f777764bd8f
+-md5=4e896420dd6344b53b307871efb2cbb4
+-cksum=1938565125
+-upstream_url=https://github.com/wbhart/antic/archive/refs/tags/vVERSION.tar.gz
+diff --git a/build/pkgs/antic/dependencies b/build/pkgs/antic/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/antic/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/antic/distros/arch.txt b/build/pkgs/antic/distros/arch.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/conda.txt b/build/pkgs/antic/distros/conda.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/debian.txt b/build/pkgs/antic/distros/debian.txt
+deleted file mode 100644
+index 8fdcd3e5721..00000000000
+--- a/build/pkgs/antic/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libantic-dev
+diff --git a/build/pkgs/antic/distros/fedora.txt b/build/pkgs/antic/distros/fedora.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/freebsd.txt b/build/pkgs/antic/distros/freebsd.txt
+deleted file mode 100644
+index 116ff3a26f3..00000000000
+--- a/build/pkgs/antic/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/antic
+diff --git a/build/pkgs/antic/distros/opensuse.txt b/build/pkgs/antic/distros/opensuse.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/repology.txt b/build/pkgs/antic/distros/repology.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/package-version.txt b/build/pkgs/antic/package-version.txt
+deleted file mode 100644
+index 3a4036fb450..00000000000
+--- a/build/pkgs/antic/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-0.2.5
+diff --git a/build/pkgs/antic/spkg-install.in b/build/pkgs/antic/spkg-install.in
+deleted file mode 100644
+index c57fa884a20..00000000000
+--- a/build/pkgs/antic/spkg-install.in
++++ /dev/null
+@@ -1,19 +0,0 @@
+-cd src
+-
+-# Copied from build/pkgs/flint/spkg-install.in:
+-#   Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-#   --with-ntl because otherwise FLINT's configure script uses
+-#   /usr/local, which is always wrong.
+-#   This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-#   The value $SAGE_LOCAL is always a safe choice even if the library
+-#   is coming from the system and is found using what is in
+-#   LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-flint="$SAGE_LOCAL"  || sdh_die "Error: Failed to configure antic."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/antic/type b/build/pkgs/antic/type
+deleted file mode 100644
+index 134d9bc32d5..00000000000
+--- a/build/pkgs/antic/type
++++ /dev/null
+@@ -1 +0,0 @@
+-optional
+diff --git a/build/pkgs/arb/SPKG.rst b/build/pkgs/arb/SPKG.rst
+deleted file mode 100644
+index cff49ddb95b..00000000000
+--- a/build/pkgs/arb/SPKG.rst
++++ /dev/null
+@@ -1,27 +0,0 @@
+-arb: Arbitrary-precision floating-point ball arithmetic
+-=======================================================
+-
+-Description
+------------
+-
+-Arb is a C library for arbitrary-precision floating-point ball
+-arithmetic, developed by Fredrik Johansson
+-(fredrik.johansson@gmail.com). It supports efficient high-precision
+-computation with polynomials, power series, matrices and special
+-functions over the real and complex numbers, with automatic, rigorous
+-error control.
+-
+-License
+--------
+-
+-GNU General Public License v2+
+-
+-
+-Upstream Contact
+-----------------
+-
+- - Fredrik Johansson: fredrik.johansson@gmail.com
+-
+- - https://arblib.org/
+-
+- - http://github.com/fredrik-johansson/arb/
+diff --git a/build/pkgs/arb/checksums.ini b/build/pkgs/arb/checksums.ini
+deleted file mode 100644
+index 80ef43dad5d..00000000000
+--- a/build/pkgs/arb/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=arb-VERSION.tar.gz
+-sha1=a1efe035dd3af3613dd685971a156f652b86ff63
+-md5=9b369e29f93cdf2d4f90b57a92526cce
+-cksum=64252121
+-upstream_url=https://github.com/fredrik-johansson/arb/archive/VERSION.tar.gz
+diff --git a/build/pkgs/arb/dependencies b/build/pkgs/arb/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/arb/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/arb/distros/arch.txt b/build/pkgs/arb/distros/arch.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/conda.txt b/build/pkgs/arb/distros/conda.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/debian.txt b/build/pkgs/arb/distros/debian.txt
+deleted file mode 100644
+index 9fe71110712..00000000000
+--- a/build/pkgs/arb/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libflint-arb-dev
+diff --git a/build/pkgs/arb/distros/fedora.txt b/build/pkgs/arb/distros/fedora.txt
+deleted file mode 100644
+index 76794404627..00000000000
+--- a/build/pkgs/arb/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb arb-devel
+diff --git a/build/pkgs/arb/distros/freebsd.txt b/build/pkgs/arb/distros/freebsd.txt
+deleted file mode 100644
+index 2ef8c7cec0f..00000000000
+--- a/build/pkgs/arb/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/arb
+diff --git a/build/pkgs/arb/distros/gentoo.txt b/build/pkgs/arb/distros/gentoo.txt
+deleted file mode 100644
+index 58e3d4f8008..00000000000
+--- a/build/pkgs/arb/distros/gentoo.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-sci-mathematics/arb
+diff --git a/build/pkgs/arb/distros/homebrew.txt b/build/pkgs/arb/distros/homebrew.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/homebrew.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/nix.txt b/build/pkgs/arb/distros/nix.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/nix.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/opensuse.txt b/build/pkgs/arb/distros/opensuse.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/distros/repology.txt b/build/pkgs/arb/distros/repology.txt
+deleted file mode 100644
+index 179c9d507e1..00000000000
+--- a/build/pkgs/arb/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-fp
+diff --git a/build/pkgs/arb/distros/void.txt b/build/pkgs/arb/distros/void.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/void.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/package-version.txt b/build/pkgs/arb/package-version.txt
+deleted file mode 100644
+index e9763f6bfed..00000000000
+--- a/build/pkgs/arb/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-2.23.0
+diff --git a/build/pkgs/arb/spkg-check.in b/build/pkgs/arb/spkg-check.in
+deleted file mode 100644
+index 27cd9419538..00000000000
+--- a/build/pkgs/arb/spkg-check.in
++++ /dev/null
+@@ -1,2 +0,0 @@
+-cd src
+-$MAKE check
+diff --git a/build/pkgs/arb/spkg-configure.m4 b/build/pkgs/arb/spkg-configure.m4
+deleted file mode 100644
+index ef2dd0aac4a..00000000000
+--- a/build/pkgs/arb/spkg-configure.m4
++++ /dev/null
+@@ -1,23 +0,0 @@
+-SAGE_SPKG_CONFIGURE([arb], [
+-    AC_REQUIRE([SAGE_SPKG_CONFIGURE_FLINT])
+-    SAGE_ARB_LIBRARY="arb"
+-    AC_MSG_CHECKING([installing flint? ])
+-    if test x$sage_spkg_install_flint = xyes; then
+-        AC_MSG_RESULT([yes; install arb as well])
+-        sage_spkg_install_arb=yes
+-    else
+-        AC_CHECK_HEADER(arb.h, [
+-        dnl below function added in version 2.16 of arb
+-            AC_CHECK_LIB([arb], [acb_mat_eig_simple], [],
+-              [dnl in Debian the name of dylib is different.
+-               AC_CHECK_LIB([flint-arb], [acb_mat_eig_simple],
+-                [SAGE_ARB_LIBRARY="flint-arb"], [sage_spkg_install_arb=yes])])
+-        ], [sage_spkg_install_arb=yes])
+-    fi
+-], [], [], [
+-    if test x$sage_spkg_install_arb = xyes; then
+-        AC_SUBST(SAGE_ARB_LIBRARY,["arb"])
+-    else
+-        AC_SUBST(SAGE_ARB_LIBRARY,[$SAGE_ARB_LIBRARY])
+-    fi
+-])
+diff --git a/build/pkgs/arb/spkg-install.in b/build/pkgs/arb/spkg-install.in
+deleted file mode 100644
+index 9322f04c912..00000000000
+--- a/build/pkgs/arb/spkg-install.in
++++ /dev/null
+@@ -1,17 +0,0 @@
+-cd src
+-
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-flint because otherwise ARB's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure --disable-static --prefix="$SAGE_LOCAL" \
+-        --with-gmp="$SAGE_LOCAL" \
+-        --with-mpfr="$SAGE_LOCAL" \
+-        --with-flint="$SAGE_LOCAL" || \
+-    sdh_die "Error configuring arb."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/arb/type b/build/pkgs/arb/type
+deleted file mode 100644
+index a6a7b9cd726..00000000000
+--- a/build/pkgs/arb/type
++++ /dev/null
+@@ -1 +0,0 @@
+-standard
+diff --git a/build/pkgs/e_antic/dependencies b/build/pkgs/e_antic/dependencies
+index fea1ffbda45..8e977a55c13 100644
+--- a/build/pkgs/e_antic/dependencies
++++ b/build/pkgs/e_antic/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) flint arb antic boost_cropped
++$(MP_LIBRARY) flint boost_cropped
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/SPKG.rst b/build/pkgs/flint/SPKG.rst
+index f91de70d1ff..d9dcea0903b 100644
+--- a/build/pkgs/flint/SPKG.rst
++++ b/build/pkgs/flint/SPKG.rst
+@@ -4,8 +4,8 @@ flint: Fast Library for Number Theory
+ Description
+ -----------
+ 
+-FLINT is a C library for doing number theory, maintained by William
+-Hart.
++FLINT is a C library for doing number theory, maintained by
++Fredrik Johansson.
+ 
+ Website: http://www.flintlib.org
+ 
+@@ -20,4 +20,4 @@ Upstream Contact
+ 
+ -  flint-devel Gougle Group
+    (http://groups.google.co.uk/group/flint-devel)
+--  William Hart
++-  Fredrik Johansson
+diff --git a/build/pkgs/flint/checksums.ini b/build/pkgs/flint/checksums.ini
+index 3d449d98064..ab836606657 100644
+--- a/build/pkgs/flint/checksums.ini
++++ b/build/pkgs/flint/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=flint-VERSION.tar.gz
+-sha1=63d90f8242c8f8ab4011fbcfb44b86c154f43abd
+-md5=c2d3cec326438f159a530c66eb07fafe
+-cksum=4244948341
+-upstream_url=http://flintlib.org/flint-VERSION.tar.gz
++sha1=65be9297c06edd7e24f20874b7bd6130cee56723
++md5=5189f67b0ec12e4a54d6782851642b81
++cksum=172350473
++upstream_url=https://github.com/flintlib/flint/releases/download/vVERSION/flint-VERSION.tar.gz
+diff --git a/build/pkgs/flint/dependencies b/build/pkgs/flint/dependencies
+index 385df4faa7d..1108dc4fb21 100644
+--- a/build/pkgs/flint/dependencies
++++ b/build/pkgs/flint/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) mpfr ntl
++$(MP_LIBRARY) mpfr
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/package-version.txt b/build/pkgs/flint/package-version.txt
+index c8e38b61405..cb2b00e4f7a 100644
+--- a/build/pkgs/flint/package-version.txt
++++ b/build/pkgs/flint/package-version.txt
+@@ -1 +1 @@
+-2.9.0
++3.0.1
+diff --git a/build/pkgs/flint/patches/0001-Makefile.in-fix-handling-of-DESTDIR.patch b/build/pkgs/flint/patches/0001-Makefile.in-fix-handling-of-DESTDIR.patch
+new file mode 100644
+index 00000000000..48a32f5d894
+--- /dev/null
++++ b/build/pkgs/flint/patches/0001-Makefile.in-fix-handling-of-DESTDIR.patch
+@@ -0,0 +1,106 @@
++From 54277f054f13254898c9a57c2c7eb869877e1252 Mon Sep 17 00:00:00 2001
++From: Marc Mezzarobba <marc@mezzarobba.net>
++Date: Mon, 13 Nov 2023 10:23:54 +0100
++Subject: [PATCH] Makefile.in: fix handling of $DESTDIR
++
++---
++ Makefile.in | 54 ++++++++++++++++++++++++++---------------------------
++ 1 file changed, 27 insertions(+), 27 deletions(-)
++
++diff --git a/Makefile.in b/Makefile.in
++index 08db6837c..2827b9da1 100644
++--- a/Makefile.in
+++++ b/Makefile.in
++@@ -34,9 +34,9 @@ FLINT_SOLIB:=@FLINT_SOLIB@
++ prefix:=@prefix@
++ exec_prefix:=@exec_prefix@
++ 
++-INCLUDEDIR:=$(DESTDIR)@includedir@
++-LIBDIR:=$(DESTDIR)@libdir@
++-BINDIR:=$(DESTDIR)@bindir@
+++INCLUDEDIR:=@includedir@
+++LIBDIR:=@libdir@
+++BINDIR:=@bindir@
++ PKGCONFIGDIR:=$(LIBDIR)/pkgconfig
++ 
++ HOST_OS:=@host_os@
++@@ -202,10 +202,10 @@ BUILD_DIRS +=                                                               \
++ endif
++ 
++ INSTALL_DIRS :=                                                             \
++-        $(LIBDIR)                       $(INCLUDEDIR)/flint                 \
++-        $(PKGCONFIGDIR)
+++        $(DESTDIR)$(LIBDIR)             $(DESTDIR)$(INCLUDEDIR)/flint       \
+++        $(DESTDIR)$(PKGCONFIGDIR)
++ ifneq ($(FLINT_DLLLIB),0)
++-INSTALL_DIRS += $(BINDIR)
+++INSTALL_DIRS += $(DESTDIR)$(BINDIR)
++ endif
++ 
++ ################################################################################
++@@ -722,41 +722,41 @@ distclean: clean
++ ################################################################################
++ 
++ install: library | $(INSTALL_DIRS)
++-	$(CP) flint.pc $(PKGCONFIGDIR)/flint.pc
+++	$(CP) flint.pc $(DESTDIR)$(PKGCONFIGDIR)/flint.pc
++ ifneq ($(SHARED), 0)
++ ifneq ($(FLINT_DLLLIB),0)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(BINDIR)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(BINDIR)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(BINDIR)
++-	$(CP) $(FLINT_DIR)/$(FLINT_IMPLIB) $(LIBDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(DESTDIR)$(BINDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(DESTDIR)$(BINDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(DESTDIR)$(BINDIR)
+++	$(CP) $(FLINT_DIR)/$(FLINT_IMPLIB) $(DESTDIR)$(LIBDIR)
++ else
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(LIBDIR)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(LIBDIR)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(LIBDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(DESTDIR)$(LIBDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(DESTDIR)$(LIBDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(DESTDIR)$(LIBDIR)
++ endif
++ ifneq ($(FLINT_DYLIB),0)
++-	install_name_tool -id $(LIBDIR)/$(FLINT_LIB_FULL) $(LIBDIR)/$(FLINT_LIB)
+++	install_name_tool -id $(LIBDIR)/$(FLINT_LIB_FULL) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB)
++ endif
++ endif
++ ifneq ($(STATIC), 0)
++-	$(CP) $(FLINT_DIR)/$(FLINT_LIB_STATIC) $(LIBDIR)
+++	$(CP) $(FLINT_DIR)/$(FLINT_LIB_STATIC) $(DESTDIR)$(LIBDIR)
++ endif
++-	$(CP) $(HEADERS) $(INCLUDEDIR)/flint
+++	$(CP) $(HEADERS) $(DESTDIR)$(INCLUDEDIR)/flint
++ 
++ uninstall:
++-	$(RM_F) $(PKGCONFIGDIR)/flint.pc
+++	$(RM_F) $(DESTDIR)$(PKGCONFIGDIR)/flint.pc
++ ifneq ($(FLINT_DLLLIB),0)
++-	$(RM_F) $(BINDIR)/$(FLINT_LIB)
++-	$(RM_F) $(BINDIR)/$(FLINT_LIB_MAJOR)
++-	$(RM_F) $(BINDIR)/$(FLINT_LIB_FULL)
++-	$(RM_F) $(LIBDIR)/$(FLINT_IMPLIB)
+++	$(RM_F) $(DESTDIR)$(BINDIR)/$(FLINT_LIB)
+++	$(RM_F) $(DESTDIR)$(BINDIR)/$(FLINT_LIB_MAJOR)
+++	$(RM_F) $(DESTDIR)$(BINDIR)/$(FLINT_LIB_FULL)
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_IMPLIB)
++ else
++-	$(RM_F) $(LIBDIR)/$(FLINT_LIB)
++-	$(RM_F) $(LIBDIR)/$(FLINT_LIB_MAJOR)
++-	$(RM_F) $(LIBDIR)/$(FLINT_LIB_FULL)
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB)
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB_MAJOR)
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB_FULL)
++ endif
++-	$(RM_F) $(LIBDIR)/$(FLINT_LIB_STATIC)
++-	$(RM_RF) $(INCLUDEDIR)/flint
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB_STATIC)
+++	$(RM_RF) $(DESTDIR)$(INCLUDEDIR)/flint
++ 
++ ################################################################################
++ # maintainer stuff
++-- 
++2.42.0
++
+diff --git a/build/pkgs/flint/spkg-build.in b/build/pkgs/flint/spkg-build.in
+new file mode 100644
+index 00000000000..ffb822c8a97
+--- /dev/null
++++ b/build/pkgs/flint/spkg-build.in
+@@ -0,0 +1,3 @@
++cd src
++sdh_configure
++sdh_make
+diff --git a/build/pkgs/flint/spkg-configure.m4 b/build/pkgs/flint/spkg-configure.m4
+index a58108c9d6e..9576e4cc1e9 100644
+--- a/build/pkgs/flint/spkg-configure.m4
++++ b/build/pkgs/flint/spkg-configure.m4
+@@ -1,25 +1,8 @@
+ SAGE_SPKG_CONFIGURE([flint], [
+-    SAGE_SPKG_DEPCHECK([mpfr ntl], [
++    SAGE_SPKG_DEPCHECK([mpfr], [
+         AC_CHECK_HEADER(flint/flint.h, [
+-          dnl flint_parallel_binary_splitting appears in Flint 2.9.0, needed by arb 2.23
+-          AC_SEARCH_LIBS([flint_parallel_binary_splitting], [flint], [
+-            dnl check that NTL is linked in
+-            AC_SEARCH_LIBS([fmpz_poly_get_ZZX], [flint], [
+-
+-              AC_MSG_CHECKING([that GC is not enabled in Flint... ])
+-              AC_RUN_IFELSE([
+-                 AC_LANG_PROGRAM([[#include <flint/flint.h>]], [
+-                                  [#ifdef HAVE_GC]
+-                                     [return HAVE_GC;]
+-                                  [#else]
+-                                     [return 0;]
+-                                  [#endif]])],
+-                 [AC_MSG_RESULT([GC not enabled. Good.])],
+-                        [AC_MSG_RESULT([GC enabled. Incompatible with Sage.])
+-                         sage_spkg_install_flint=yes],
+-                 [AC_MSG_RESULT(["cross compiling. assuming GC is not enabled"])])
+-            ], [sage_spkg_install_flint=yes])
+-          ], [sage_spkg_install_flint=yes])
++          dnl gr_get_fexpr appears in Flint 3.0
++          AC_SEARCH_LIBS([gr_get_fexpr], [flint], [], [sage_spkg_install_flint=yes])
+         ], [sage_spkg_install_flint=yes])
+     ])
+ ], [], [], [
+diff --git a/build/pkgs/flint/spkg-install.in b/build/pkgs/flint/spkg-install.in
+index eacd7b6e491..3ea8c053669 100644
+--- a/build/pkgs/flint/spkg-install.in
++++ b/build/pkgs/flint/spkg-install.in
+@@ -1,36 +1,2 @@
+-###############################################################################
+-#
+-# FLINT Sage install script
+-#
+-###############################################################################
+-if [ "$SAGE_DEBUG" = "yes" ]; then
+-    echo "Building a debug version of FLINT."
+-    FLINT_TUNE=" $FLINT_TUNE"; export FLINT_TUNE
+-    FLINT_CONFIGURE="--enable-assert $FLINT_CONFIGURE"
+-fi
+-
+ cd src
+-
+-echo "Configuring FLINT."
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-ntl because otherwise FLINT's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-ntl="$SAGE_LOCAL" \
+-    $FLINT_CONFIGURE || sdh_die "Error: Failed to configure FLINT."
+-
+-sdh_make verbose
+-
+-echo "Deleting old FLINT files."
+-rm -f $SAGE_LOCAL/lib/libflint*
+-rm -rf $SAGE_LOCAL/include/flint
+-
+ sdh_make_install
+diff --git a/build/pkgs/gmp/spkg-configure.m4 b/build/pkgs/gmp/spkg-configure.m4
+index 61d7c5f3b2f..4000200db2c 100644
+--- a/build/pkgs/gmp/spkg-configure.m4
++++ b/build/pkgs/gmp/spkg-configure.m4
+@@ -2,8 +2,10 @@ SAGE_SPKG_CONFIGURE([gmp], [
+            sage_spkg_install_gmp=no
+             AC_CHECK_HEADER(gmp.h, [], [sage_spkg_install_gmp=yes])
+             AC_CHECK_HEADER(gmpxx.h, [], [sage_spkg_install_gmp=yes])
+-            dnl mpq_cmp_z appeared in GMP 6.1.0 and is used by pynac
+-            AC_SEARCH_LIBS([__gmpq_cmp_z], [gmp], [],
++            dnl mpn_gcd_11 appeared in GMP 6.2.1
++            dnl It is undocumented but is used by Flint when built with default
++            dnl flags.
++            AC_SEARCH_LIBS([__gmpn_gcd_11], [gmp], [],
+                 [sage_spkg_install_gmp=yes])
+ ], [], [], [
+     if test x$sage_spkg_install_gmp = xyes; then
+diff --git a/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+new file mode 100644
+index 00000000000..27a642a13b0
+--- /dev/null
++++ b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+@@ -0,0 +1,53 @@
++From fe730579476de0b2d4181a38efa7f63dff9c81d7 Mon Sep 17 00:00:00 2001
++From: Marc Mezzarobba <marc@mezzarobba.net>
++Date: Tue, 12 Sep 2023 08:23:08 +0200
++Subject: [PATCH] Make msolve build with flint3
++
++---
++ src/fglm/berlekamp_massey.c | 3 +++
++ src/fglm/data_fglm.c        | 7 +++++--
++ 2 files changed, 8 insertions(+), 2 deletions(-)
++
++diff --git a/src/fglm/berlekamp_massey.c b/src/fglm/berlekamp_massey.c
++index b0f2052..998af1c 100644
++--- a/src/fglm/berlekamp_massey.c
+++++ b/src/fglm/berlekamp_massey.c
++@@ -30,6 +30,9 @@
++ */
++ 
++ #include <stdlib.h>
+++#if __FLINT_VERSION >= 3
+++#  include <flint/nmod.h>
+++#endif
++ //#include "nmod_poly.h"
++ //#include "mpn_extras.h"
++ 
++diff --git a/src/fglm/data_fglm.c b/src/fglm/data_fglm.c
++index 0726760..0e1da6f 100644
++--- a/src/fglm/data_fglm.c
+++++ b/src/fglm/data_fglm.c
++@@ -24,6 +24,7 @@
++ #include <flint/mpn_extras.h>
++ #include <flint/nmod_poly.h>
++ #include <flint/nmod_poly_factor.h>
+++#include <flint/ulong_extras.h>
++ 
++ 
++ typedef uint32_t szmat_t;
++@@ -299,9 +300,11 @@ static inline void nmod_poly_set_prime(nmod_poly_t poly,
++   mp_limb_t ninv = n_preinvert_limb(prime);
++   poly->mod.n = prime;
++   poly->mod.ninv = ninv;
+++#if __FLINT_VERSION < 3
++   count_leading_zeros(poly->mod.norm, prime);
++-  /* poly->mod.norm = flint_clz(prime); */
++-
+++#else
+++  poly->mod.norm = flint_clz(prime);
+++#endif
++ }
++ 
++ static inline void fglm_param_set_prime(param_t *param, mp_limb_t prime){
++-- 
++2.40.1
++
+diff --git a/build/pkgs/sagelib/dependencies b/build/pkgs/sagelib/dependencies
+index 5dc2efe1d31..fa6e98df7db 100644
+--- a/build/pkgs/sagelib/dependencies
++++ b/build/pkgs/sagelib/dependencies
+@@ -1,4 +1,4 @@
+-FORCE $(SCRIPTS) arb boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
++FORCE $(SCRIPTS) boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/symengine/dependencies b/build/pkgs/symengine/dependencies
+index 1fc34963eda..7795d486018 100644
+--- a/build/pkgs/symengine/dependencies
++++ b/build/pkgs/symengine/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) arb ecm flint mpc mpfr | cmake
++$(MP_LIBRARY) ecm flint mpc mpfr | cmake
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/pkgs/sage-conf/_sage_conf/_conf.py.in b/pkgs/sage-conf/_sage_conf/_conf.py.in
+index 87b27ca05cb..895d6572d1e 100644
+--- a/pkgs/sage-conf/_sage_conf/_conf.py.in
++++ b/pkgs/sage-conf/_sage_conf/_conf.py.in
+@@ -19,8 +19,6 @@ MAXIMA_FAS = "@SAGE_MAXIMA_FAS@".replace('${prefix}', SAGE_LOCAL)
+ # Delete this line if your ECL can load Kenzo without further prodding.
+ KENZO_FAS = "@SAGE_KENZO_FAS@".replace('${prefix}', SAGE_LOCAL)
+ 
+-ARB_LIBRARY = "@SAGE_ARB_LIBRARY@"
+-
+ NTL_INCDIR = "@NTL_INCDIR@"
+ NTL_LIBDIR = "@NTL_LIBDIR@"
+ 
+diff --git a/src/sage/env.py b/src/sage/env.py
+index 4515e90e912..9ab6b1e1864 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -223,7 +223,6 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st
+ FOURTITWO_PPI = var("FOURTITWO_PPI")
+ FOURTITWO_CIRCUITS = var("FOURTITWO_CIRCUITS")
+ FOURTITWO_GROEBNER = var("FOURTITWO_GROEBNER")
+-ARB_LIBRARY = var("ARB_LIBRARY", "arb")
+ CBLAS_PC_MODULES = var("CBLAS_PC_MODULES", "cblas:openblas:blas")
+ ECL_CONFIG = var("ECL_CONFIG", "ecl-config")
+ NTL_INCDIR = var("NTL_INCDIR")
+@@ -356,8 +355,7 @@ def cython_aliases(required_modules=None,
+         sage: cython_aliases()
+         {...}
+         sage: sorted(cython_aliases().keys())
+-        ['ARB_LIBRARY',
+-         'CBLAS_CFLAGS',
++        ['CBLAS_CFLAGS',
+          ...,
+          'ZLIB_LIBRARIES']
+         sage: cython_aliases(required_modules=('module-that-is-assumed-to-not-exist'))
+@@ -475,8 +473,6 @@ def uname_specific(name, value, alternative):
+     if "LINBOX_CFLAGS" in aliases:
+         aliases["LINBOX_CFLAGS"].append("-std=gnu++11")
+ 
+-    aliases["ARB_LIBRARY"] = ARB_LIBRARY
+-
+     # TODO: Remove Cygwin hack by installing a suitable cblas.pc
+     if os.path.exists('/usr/lib/libblas.dll.a'):
+         aliases["CBLAS_LIBS"] = ['gslcblas']
+diff --git a/src/sage/features/sagemath.py b/src/sage/features/sagemath.py
+index bc34d35dd1c..4097d3512b9 100644
+--- a/src/sage/features/sagemath.py
++++ b/src/sage/features/sagemath.py
+@@ -777,7 +777,7 @@ class sage__rings__number_field(JoinFeature):
+     A :class:`~sage.features.Feature` describing the presence of :mod:`sage.rings.number_field`.
+ 
+     Number fields are implemented in Sage using a complicated mixture of various libraries,
+-    including :ref:`arb <spkg_arb>`, :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
++    including :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
+     :ref:`MPFI <spkg_mpfi>`, :ref:`NTL <spkg_ntl>`, and :ref:`PARI <spkg_pari>`.
+ 
+     EXAMPLES:
+diff --git a/src/sage/libs/arb/acb.pxd b/src/sage/libs/arb/acb.pxd
+index 5148dc43991..851488d803a 100644
+--- a/src/sage/libs/arb/acb.pxd
++++ b/src/sage/libs/arb/acb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -152,10 +152,6 @@ cdef extern from "arb_wrap.h":
+     void acb_sech(acb_t s, const acb_t z, long prec)
+     void acb_csch(acb_t c, const acb_t z, long prec)
+ 
+-    void acb_rising_ui_bs(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui_rs(acb_t z, const acb_t x, unsigned long n, unsigned long step, long prec)
+-    void acb_rising_ui_rec(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui(acb_t z, const acb_t x, unsigned long n, long prec)
+     void acb_rising(acb_t z, const acb_t x, const acb_t n, long prec)
+ 
+     void acb_gamma(acb_t y, const acb_t x, long prec)
+diff --git a/src/sage/libs/arb/acb_calc.pxd b/src/sage/libs/arb/acb_calc.pxd
+index a5dbf360b5e..67bd2ed57dc 100644
+--- a/src/sage/libs/arb/acb_calc.pxd
++++ b/src/sage/libs/arb/acb_calc.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_calc.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_elliptic.pxd b/src/sage/libs/arb/acb_elliptic.pxd
+index 176f68df00e..e3480e9f73b 100644
+--- a/src/sage/libs/arb/acb_elliptic.pxd
++++ b/src/sage/libs/arb/acb_elliptic.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_elliptic.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_hypgeom.pxd b/src/sage/libs/arb/acb_hypgeom.pxd
+index 418e766f10d..c43e5c0623b 100644
+--- a/src/sage/libs/arb/acb_hypgeom.pxd
++++ b/src/sage/libs/arb/acb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_hypgeom.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_modular.pxd b/src/sage/libs/arb/acb_modular.pxd
+index c708e9bf97d..cdc413c92da 100644
+--- a/src/sage/libs/arb/acb_modular.pxd
++++ b/src/sage/libs/arb/acb_modular.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_modular.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_poly.pxd b/src/sage/libs/arb/acb_poly.pxd
+index 69f4320055b..ae02757ffd9 100644
+--- a/src/sage/libs/arb/acb_poly.pxd
++++ b/src/sage/libs/arb/acb_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -79,24 +79,10 @@ cdef extern from "arb_wrap.h":
+     void _acb_poly_divrem(acb_ptr Q, acb_ptr R, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec)
+     bint acb_poly_divrem(acb_poly_t Q, acb_poly_t R, const acb_poly_t A, const acb_poly_t B, long prec)
+     void _acb_poly_div_root(acb_ptr Q, acb_t R, acb_srcptr A, long len, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_horner(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_horner(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_divconquer(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_divconquer(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_convolution(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_convolution(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+     void _acb_poly_taylor_shift(acb_ptr g, const acb_t c, long n, long prec)
+     void acb_poly_taylor_shift(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_compose_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_divconquer(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_divconquer(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+     void _acb_poly_compose(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+     void acb_poly_compose(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_series_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+-    void _acb_poly_compose_series_brent_kung(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_brent_kung(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_compose_series(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+     void acb_poly_compose_series(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_revert_series_lagrange(acb_ptr h, acb_srcptr f, long flen, long n, long prec)
+@@ -161,10 +147,6 @@ cdef extern from "arb_wrap.h":
+     void acb_poly_exp_series_basecase(acb_poly_t f, const acb_poly_t h, long n, long prec)
+     void _acb_poly_exp_series(acb_ptr f, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_exp_series(acb_poly_t f, const acb_poly_t h, long n, long prec)
+-    void _acb_poly_sin_cos_series_basecase(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_basecase(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+-    void _acb_poly_sin_cos_series_tangent(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_tangent(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+     void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_sin_cos_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec)
+     void _acb_poly_sin_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec)
+diff --git a/src/sage/libs/arb/arb.pxd b/src/sage/libs/arb/arb.pxd
+index c82b94de30f..acd232ab816 100644
+--- a/src/sage/libs/arb/arb.pxd
++++ b/src/sage/libs/arb/arb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -224,15 +224,8 @@ cdef extern from "arb_wrap.h":
+ 
+     void arb_lambertw(arb_t res, const arb_t x, int flags, long prec)
+ 
+-    void arb_rising_ui_bs(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui_rs(arb_t z, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising_ui_rec(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui(arb_t z, const arb_t x, unsigned long n, long prec)
+     void arb_rising(arb_t z, const arb_t x, const arb_t n, long prec)
+     void arb_rising_fmpq_ui(arb_t z, const fmpq_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_bs(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_rs(arb_t u, arb_t v, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising2_ui(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+     void arb_fac_ui(arb_t z, unsigned long n, long prec)
+     void arb_bin_ui(arb_t z, const arb_t n, unsigned long k, long prec)
+     void arb_bin_uiui(arb_t z, unsigned long n, unsigned long k, long prec)
+diff --git a/src/sage/libs/arb/arb_fmpz_poly.pxd b/src/sage/libs/arb/arb_fmpz_poly.pxd
+index 079f76e9d9e..55daa705238 100644
+--- a/src/sage/libs/arb/arb_fmpz_poly.pxd
++++ b/src/sage/libs/arb/arb_fmpz_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_fmpz_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -22,5 +22,4 @@ cdef extern from "arb_wrap.h":
+     unsigned long arb_fmpz_poly_deflation(const fmpz_poly_t poly)
+     void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long deflation)
+     void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, long prec)
+-    void arb_fmpz_poly_cos_minpoly(fmpz_poly_t res, unsigned long n)
+     void arb_fmpz_poly_gauss_period_minpoly(fmpz_poly_t res, unsigned long q, unsigned long n)
+diff --git a/src/sage/libs/arb/arb_hypgeom.pxd b/src/sage/libs/arb/arb_hypgeom.pxd
+index fb1c40ddaa8..139b987d669 100644
+--- a/src/sage/libs/arb/arb_hypgeom.pxd
++++ b/src/sage/libs/arb/arb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_hypgeom.h
+ 
+ from sage.libs.flint.types cimport fmpz_t
+diff --git a/src/sage/libs/arb/arb_wrap.h b/src/sage/libs/arb/arb_wrap.h
+index 49997075ee5..488bb376d5e 100644
+--- a/src/sage/libs/arb/arb_wrap.h
++++ b/src/sage/libs/arb/arb_wrap.h
+@@ -5,25 +5,27 @@
+  * by arb, most of which rely on flint's ulong and slong defines.
+  */
+ 
++#include <mpfr.h>
++
+ #undef ulong
+ #undef slong
+ 
+ #define ulong mp_limb_t
+ #define slong mp_limb_signed_t
+ 
+-#include <acb.h>
+-#include <acb_calc.h>
+-#include <acb_elliptic.h>
+-#include <acb_hypgeom.h>
+-#include <acb_mat.h>
+-#include <acb_modular.h>
+-#include <acb_poly.h>
+-#include <arb.h>
+-#include <arb_fmpz_poly.h>
+-#include <arb_hypgeom.h>
+-#include <arf.h>
+-#include <bernoulli.h>
+-#include <mag.h>
++#include <flint/acb.h>
++#include <flint/acb_calc.h>
++#include <flint/acb_elliptic.h>
++#include <flint/acb_hypgeom.h>
++#include <flint/acb_mat.h>
++#include <flint/acb_modular.h>
++#include <flint/acb_poly.h>
++#include <flint/arb.h>
++#include <flint/arb_fmpz_poly.h>
++#include <flint/arb_hypgeom.h>
++#include <flint/arf.h>
++#include <flint/bernoulli.h>
++#include <flint/mag.h>
+ 
+ #undef ulong
+ #undef slong
+diff --git a/src/sage/libs/arb/arf.pxd b/src/sage/libs/arb/arf.pxd
+index b8b83fefcdc..84778fe9f09 100644
+--- a/src/sage/libs/arb/arf.pxd
++++ b/src/sage/libs/arb/arf.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arf.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -30,7 +30,6 @@ cdef extern from "arb_wrap.h":
+     void arf_set_ui(arf_t y, unsigned long x)
+     void arf_set_si(arf_t y, long x)
+     void arf_set_mpfr(arf_t y, const mpfr_t x)
+-    # void arf_set_fmpr(arf_t y, const fmpr_t x)
+     void arf_set_d(arf_t y, double x)
+     void arf_swap(arf_t y, arf_t x)
+     void arf_init_set_ui(arf_t y, unsigned long x)
+@@ -46,7 +45,6 @@ cdef extern from "arb_wrap.h":
+     int arf_set_round_fmpz_2exp(arf_t y, const fmpz_t x, const fmpz_t e, long prec, arf_rnd_t rnd)
+     void arf_get_fmpz_2exp(fmpz_t m, fmpz_t e, const arf_t x)
+     double arf_get_d(const arf_t x, arf_rnd_t rnd)
+-    # void arf_get_fmpr(fmpr_t y, const arf_t x)
+     int arf_get_mpfr(mpfr_t y, const arf_t x, mpfr_rnd_t rnd)
+     void arf_get_fmpz(fmpz_t z, const arf_t x, arf_rnd_t rnd)
+     long arf_get_si(const arf_t x, arf_rnd_t rnd)
+diff --git a/src/sage/libs/arb/bernoulli.pxd b/src/sage/libs/arb/bernoulli.pxd
+index f859ebfb8d7..95a84dd5179 100644
+--- a/src/sage/libs/arb/bernoulli.pxd
++++ b/src/sage/libs/arb/bernoulli.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = bernoulli.h
+ 
+ from sage.libs.flint.types cimport fmpq_t, ulong
+diff --git a/src/sage/libs/arb/mag.pxd b/src/sage/libs/arb/mag.pxd
+index d5d8693ea8f..69dfb990ae0 100644
+--- a/src/sage/libs/arb/mag.pxd
++++ b/src/sage/libs/arb/mag.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = mag.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -27,13 +27,11 @@ cdef extern from "arb_wrap.h":
+     # void mag_randtest(mag_t x, flint_rand_t state, long expbits)
+     # void mag_randtest_special(mag_t x, flint_rand_t state, long expbits)
+     void mag_set_d(mag_t y, double x)
+-    # void mag_set_fmpr(mag_t y, const fmpr_t x)
+     void mag_set_ui(mag_t y, unsigned long x)
+     void mag_set_fmpz(mag_t y, const fmpz_t x)
+     void mag_set_d_2exp_fmpz(mag_t z, double x, const fmpz_t y)
+     void mag_set_fmpz_2exp_fmpz(mag_t z, const fmpz_t x, const fmpz_t y)
+     void mag_set_ui_2exp_si(mag_t z, unsigned long x, long y)
+-    # void mag_get_fmpr(fmpr_t y, const mag_t x)
+     void mag_get_fmpq(fmpq_t y, const mag_t x)
+     void mag_set_ui_lower(mag_t z, unsigned long x)
+     void mag_set_fmpz_lower(mag_t z, const fmpz_t x)
+diff --git a/src/sage/libs/flint/flint_wrap.h b/src/sage/libs/flint/flint_wrap.h
+index 266535c3835..4db72b97660 100644
+--- a/src/sage/libs/flint/flint_wrap.h
++++ b/src/sage/libs/flint/flint_wrap.h
+@@ -15,6 +15,7 @@
+  */
+ 
+ #include <gmp.h>
++#include <mpfr.h>
+ 
+ /* Save previous definition of ulong if any, as pari also uses it */
+ /* Should work on GCC, clang, MSVC */
+@@ -33,6 +34,7 @@
+ 
+ #include <flint/arith.h>
+ #include <flint/fmpq.h>
++#include <flint/fmpq_vec.h>
+ #include <flint/fmpq_mat.h>
+ #include <flint/fmpq_poly.h>
+ #include <flint/fmpz.h>
+@@ -47,6 +49,7 @@
+ #include <flint/fq.h>
+ #include <flint/fq_nmod.h>
+ #include <flint/nmod_poly.h>
++#include <flint/nmod_poly_factor.h>
+ #include <flint/nmod_vec.h>
+ #include <flint/padic.h>
+ #include <flint/padic_poly.h>
+diff --git a/src/sage/libs/flint/fmpq.pxd b/src/sage/libs/flint/fmpq.pxd
+index 5e64c82102f..0616c0a7408 100644
+--- a/src/sage/libs/flint/fmpq.pxd
++++ b/src/sage/libs/flint/fmpq.pxd
+@@ -12,6 +12,8 @@ cdef extern from "flint_wrap.h":
+     fmpz * fmpq_denref(fmpq_t)
+     void fmpq_init(fmpq_t)
+     void fmpq_clear(fmpq_t)
++    void fmpq_init_set_readonly(fmpq_t, const mpq_t)
++    void fmpq_clear_readonly(fmpq_t)
+     void fmpq_one(fmpq_t)
+     void fmpq_zero(fmpq_t)
+     bint fmpq_is_zero(fmpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pxd b/src/sage/libs/flint/fmpq_poly.pxd
+index 6050c487835..afa16e5bbdd 100644
+--- a/src/sage/libs/flint/fmpq_poly.pxd
++++ b/src/sage/libs/flint/fmpq_poly.pxd
+@@ -30,6 +30,9 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_canonicalise(fmpq_poly_t)
+     int fmpq_poly_is_canonical(const fmpq_poly_t)
+ 
++    void _fmpq_poly_set_length(fmpq_poly_t, slong)
++    void _fmpq_poly_normalise(fmpq_poly_t)
++
+     # Polynomial parameters
+     slong fmpq_poly_degree(const fmpq_poly_t)
+     ulong fmpq_poly_length(const fmpq_poly_t)
+@@ -46,10 +49,7 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_ui(fmpq_poly_t, ulong)
+     void fmpq_poly_set_fmpz(fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_set_fmpq(fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+     void fmpq_poly_set_fmpz_poly(fmpq_poly_t, const fmpz_poly_t)
+-    void fmpq_poly_set_array_mpq(fmpq_poly_t, const mpq_t *, slong)
+ 
+     void fmpq_poly_set_str(fmpq_poly_t, const char *)
+     char *fmpq_poly_get_str(const fmpq_poly_t)
+@@ -67,7 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_reverse(fmpq_poly_t, const fmpq_poly_t, slong)
+ 
+     void fmpq_poly_get_coeff_fmpq(fmpq_t, const fmpq_poly_t, slong)
+-    void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_si(slong, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_ui(ulong, const fmpq_poly_t, slong)
+ 
+@@ -75,8 +74,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_coeff_ui(fmpq_poly_t, slong, ulong)
+     void fmpq_poly_set_coeff_fmpz(fmpq_poly_t, slong, const fmpz_t)
+     void fmpq_poly_set_coeff_fmpq(fmpq_poly_t, slong, const fmpq_t)
+-    void fmpq_poly_set_coeff_mpz(fmpq_poly_t, slong, const mpz_t)
+-    void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
+ 
+     # Comparison
+     int fmpq_poly_equal(const fmpq_poly_t, const fmpq_poly_t)
+@@ -100,8 +97,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_mul_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     void fmpq_poly_scalar_div_si(fmpq_poly_t, const fmpq_poly_t, slong)
+     void fmpq_poly_scalar_div_ui(fmpq_poly_t, const fmpq_poly_t, ulong)
+@@ -109,8 +104,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_div_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_div_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_div_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Multiplication
+     void fmpq_poly_mul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -155,8 +148,6 @@ cdef extern from "flint_wrap.h":
+     # Evaluation
+     void fmpq_poly_evaluate_fmpz(fmpq_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_evaluate_fmpq(fmpq_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_evaluate_mpz(mpq_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_evaluate_mpq(mpq_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Composition
+     void fmpq_poly_compose(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -189,3 +180,11 @@ cdef extern from "flint_wrap.h":
+ # since the fmpq_poly header seems to be lacking this inline function
+ cdef inline sage_fmpq_poly_max_limbs(const fmpq_poly_t poly) noexcept:
+     return _fmpz_vec_max_limbs(fmpq_poly_numref(poly), fmpq_poly_length(poly))
++
++# functions removed from flint but still needed in sage
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
++cdef void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
++cdef void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pyx b/src/sage/libs/flint/fmpq_poly.pyx
+new file mode 100644
+index 00000000000..3b8a0cf0c51
+--- /dev/null
++++ b/src/sage/libs/flint/fmpq_poly.pyx
+@@ -0,0 +1,45 @@
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++from sage.libs.gmp.mpq cimport *
++from sage.libs.flint.fmpz cimport *
++from sage.libs.flint.fmpq cimport *
++
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t rop, const fmpq_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t rop, const fmpq_poly_t op, const mpq_t c):
++    cdef fmpq_t f
++    fmpq_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpq(rop, op, f)
++    fmpq_clear_readonly(f)
++
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t poly, slong n, const mpq_t x):
++    cdef fmpq_t t
++    fmpq_init_set_readonly(t, x)
++    fmpq_poly_set_coeff_fmpq(poly, n, t)
++    fmpq_clear_readonly(t)
++
++cdef void fmpq_poly_get_coeff_mpq(mpq_t x, const fmpq_poly_t poly, slong n):
++    cdef fmpq_t t
++    fmpq_init(t)
++    fmpq_poly_get_coeff_fmpq(t, poly, n)
++    fmpq_get_mpq(x, t)
++    fmpq_clear(t)
++
++cdef void fmpq_poly_set_mpq(fmpq_poly_t poly, const mpq_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), mpq_numref(x))
++    fmpz_set_mpz(fmpq_poly_denref(poly), mpq_denref(x))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
++
++cdef void fmpq_poly_set_mpz(fmpq_poly_t poly, const mpz_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), x)
++    fmpz_one(fmpq_poly_denref(poly))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz.pxd b/src/sage/libs/flint/fmpz.pxd
+index 01058d0f130..b97fbe1eae0 100644
+--- a/src/sage/libs/flint/fmpz.pxd
++++ b/src/sage/libs/flint/fmpz.pxd
+@@ -16,6 +16,9 @@ cdef extern from "flint_wrap.h":
+     void fmpz_init_set(fmpz_t, fmpz_t)
+     void fmpz_init_set_ui(fmpz_t, ulong)
+ 
++    void fmpz_init_set_readonly(fmpz_t, const mpz_t)
++    void fmpz_clear_readonly(fmpz_t)
++
+     # Conversion
+     void fmpz_set(fmpz_t f, fmpz_t g)
+     void fmpz_set_ui(fmpz_t, ulong)
+diff --git a/src/sage/libs/flint/fmpz_mod_poly.pxd b/src/sage/libs/flint/fmpz_mod_poly.pxd
+index 24b653eb3b7..2727246da98 100644
+--- a/src/sage/libs/flint/fmpz_mod_poly.pxd
++++ b/src/sage/libs/flint/fmpz_mod_poly.pxd
+@@ -67,13 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_get_coeff_fmpz(fmpz_t x, const fmpz_mod_poly_t poly,
+                                              slong n, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_set_coeff_mpz(fmpz_mod_poly_t poly,
+-                             slong n, const mpz_t x, const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_get_coeff_mpz(mpz_t x,
+-                 const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx)
+-
+-
+     void _fmpz_mod_poly_shift_left(fmpz * res, const fmpz * poly,
+                                                            slong len, slong n)
+ 
+@@ -194,14 +187,6 @@ cdef extern from "flint_wrap.h":
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_div_basecase(fmpz_mod_poly_t Q,
+-                            const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_div_newton_n_preinv(fmpz_mod_poly_t Q,
+-                         const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                         const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem_newton_n_preinv(fmpz_mod_poly_t Q,
+           fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                          const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+@@ -213,10 +198,6 @@ cdef extern from "flint_wrap.h":
+                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_divrem_divconquer(fmpz_mod_poly_t Q,
+-        fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem(fmpz_mod_poly_t Q, fmpz_mod_poly_t R,
+     const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+@@ -254,40 +235,13 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_make_monic_f(fmpz_t f, fmpz_mod_poly_t res,
+                          const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_euclidean(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_gcd_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_hgcd(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-
+     void fmpz_mod_poly_gcd(fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+ 
+-    void fmpz_mod_poly_xgcd_euclidean(fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_hgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S,
+-          fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_xgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                       const fmpz_mod_ctx_t ctx)
+@@ -361,14 +315,6 @@ cdef extern from "flint_wrap.h":
+                         const fmpz_mod_poly_t poly, const fmpz * xs, slong n,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_compose_horner(fmpz_mod_poly_t res,
+-                    const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_compose_divconquer(fmpz_mod_poly_t res,
+-                     const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_compose(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1,
+                          const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx)
+ 
+diff --git a/src/sage/libs/flint/fmpz_poly.pxd b/src/sage/libs/flint/fmpz_poly.pxd
+index 18b36672d30..c8bc6d3ca0a 100644
+--- a/src/sage/libs/flint/fmpz_poly.pxd
++++ b/src/sage/libs/flint/fmpz_poly.pxd
+@@ -28,7 +28,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_poly_set_ui(fmpz_poly_t, ulong)
+     void fmpz_poly_set_si(fmpz_poly_t, slong)
+     void fmpz_poly_set_fmpz(fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+     int fmpz_poly_set_str(fmpz_poly_t, const char *)
+ 
+     char *fmpz_poly_get_str(const fmpz_poly_t)
+@@ -70,7 +69,6 @@ cdef extern from "flint_wrap.h":
+     # Scalar multiplication and division
+     void fmpz_poly_scalar_mul_fmpz(
+             fmpz_poly_t, const fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+     void fmpz_poly_scalar_mul_si(fmpz_poly_t, const fmpz_poly_t, slong)
+     void fmpz_poly_scalar_mul_ui(fmpz_poly_t, const fmpz_poly_t, ulong)
+     void fmpz_poly_scalar_mul_2exp(fmpz_poly_t, const fmpz_poly_t, ulong)
+@@ -310,12 +308,14 @@ cdef extern from "flint_wrap.h":
+             fmpz_poly_t,
+                     const fmpz_poly_t, const fmpz_t, const nmod_poly_t, int)
+ 
+-    # Some functions for backwards compatibility
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
+-    void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++
++# functions removed from flint but still needed in sage
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
++cdef void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++cdef void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+ 
+ 
+ # Wrapper Cython class
+diff --git a/src/sage/libs/flint/fmpz_poly.pyx b/src/sage/libs/flint/fmpz_poly.pyx
+index 74915b37612..cfcbea9090c 100644
+--- a/src/sage/libs/flint/fmpz_poly.pyx
++++ b/src/sage/libs/flint/fmpz_poly.pyx
+@@ -25,10 +25,10 @@ from cysignals.memory cimport sig_free
+ 
+ from sage.arith.long cimport pyobject_to_long
+ from sage.cpython.string cimport char_to_str, str_to_bytes
++from sage.libs.flint.fmpz cimport *
+ from sage.structure.sage_object cimport SageObject
+ from sage.rings.integer cimport Integer
+ 
+-
+ cdef class Fmpz_poly(SageObject):
+ 
+     def __cinit__(self):
+@@ -455,3 +455,44 @@ cdef class Fmpz_poly(SageObject):
+         """
+         from sage.rings.integer_ring import ZZ
+         return ZZ[var](self.list())
++
++
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_divexact_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_fdiv_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t poly, slong n, const mpz_t x):
++    cdef fmpz_t t
++    fmpz_init_set_readonly(t, x)
++    fmpz_poly_set_coeff_fmpz(poly, n, t)
++    fmpz_clear_readonly(t)
++
++cdef void fmpz_poly_get_coeff_mpz(mpz_t x, const fmpz_poly_t poly, slong n):
++    cdef fmpz_t t
++    fmpz_init(t)
++    fmpz_poly_get_coeff_fmpz(t, poly, n)
++    fmpz_get_mpz(x, t)
++    fmpz_clear(t)
++
++cdef void fmpz_poly_set_mpz(fmpz_poly_t poly, const mpz_t x):
++    fmpz_poly_fit_length(poly, 1)
++    fmpz_set_mpz(poly.coeffs, x)
++    _fmpz_poly_set_length(poly, 1)
++    _fmpz_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz_poly_q.pxd b/src/sage/libs/flint/fmpz_poly_q.pxd
+index 846542dc0d8..63c13355bf6 100644
+--- a/src/sage/libs/flint/fmpz_poly_q.pxd
++++ b/src/sage/libs/flint/fmpz_poly_q.pxd
+@@ -49,11 +49,7 @@ cdef extern from "flint_wrap.h":
+ 
+     #* Scalar multiplication and division ****************************************/
+     void fmpz_poly_q_scalar_mul_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_mul_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_mul_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+     void fmpz_poly_q_scalar_div_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_div_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_div_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+ 
+     #* Multiplication and division ***********************************************/
+     void fmpz_poly_q_mul(fmpz_poly_q_t rop, 
+@@ -67,9 +63,6 @@ cdef extern from "flint_wrap.h":
+     #* Derivative ****************************************************************/
+     void fmpz_poly_q_derivative(fmpz_poly_q_t rop, const fmpz_poly_q_t op)
+ 
+-    #* Evaluation ****************************************************************/
+-    int fmpz_poly_q_evaluate(mpq_t rop, const fmpz_poly_q_t f, const mpq_t a)
+-
+     #* Input and output **********************************************************/
+     int fmpz_poly_q_set_str(fmpz_poly_q_t rop, const char *s)
+     char * fmpz_poly_q_get_str(const fmpz_poly_q_t op)
+diff --git a/src/sage/libs/linbox/linbox_flint_interface.pyx b/src/sage/libs/linbox/linbox_flint_interface.pyx
+index 1979ac0f0a4..37a340c457f 100644
+--- a/src/sage/libs/linbox/linbox_flint_interface.pyx
++++ b/src/sage/libs/linbox/linbox_flint_interface.pyx
+@@ -33,6 +33,7 @@ and C. Pernet. The functions available are:
+ #                  https://www.gnu.org/licenses/
+ # ****************************************************************************
+ 
++from sage.libs.gmp.types cimport mpz_t
+ from sage.libs.flint.types cimport fmpz_t
+ from sage.libs.flint.fmpz cimport fmpz_get_mpz, fmpz_set_mpz
+ from sage.libs.flint.fmpz_mat cimport fmpz_mat_entry, fmpz_mat_nrows, fmpz_mat_ncols
+@@ -80,11 +81,13 @@ cdef void fmpz_poly_set_linbox(fmpz_poly_t p, PolynomialRing_integer.Element& q)
+     (the .pxd file) in order to keep the header C-compatible
+     """
+     cdef size_t i
++    cdef mpz_t tmp
+ 
+     fmpz_poly_fit_length(p, q.size())
+ 
+     for i in range(q.size()):
+-        fmpz_poly_set_coeff_mpz(p, i, q[i].get_mpz_const())
++        tmp = q[i].get_mpz_const()
++        fmpz_poly_set_coeff_mpz(p, i, tmp)
+ 
+     _fmpz_poly_set_length(p, q.size())
+ 
+diff --git a/src/sage/matrix/matrix_complex_ball_dense.pyx b/src/sage/matrix/matrix_complex_ball_dense.pyx
+index e5414abdd9e..2f0131f4064 100644
+--- a/src/sage/matrix/matrix_complex_ball_dense.pyx
++++ b/src/sage/matrix/matrix_complex_ball_dense.pyx
+@@ -1,4 +1,4 @@
+-# distutils: libraries = ARB_LIBRARY
++# distutils: libraries = flint
+ r"""
+ Arbitrary precision complex ball matrices using Arb
+ 
+diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx
+index 27f5cdfac0f..6c5c20dbc6b 100644
+--- a/src/sage/matrix/matrix_integer_sparse.pyx
++++ b/src/sage/matrix/matrix_integer_sparse.pyx
+@@ -847,6 +847,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+             sage: matrix(ZZ, 1, 1, sparse=True)._charpoly_linbox()
+             x
+         """
++        cdef mpz_t tmp
+         if self._nrows != self._ncols:
+             raise ArithmeticError('only valid for square matrix')
+ 
+@@ -869,7 +870,8 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         cdef size_t i
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+@@ -966,9 +968,11 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         sig_off()
+ 
+         cdef size_t i
++        cdef mpz_t tmp
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
+index 1e3085c9215..0786de7fc81 100644
+--- a/src/sage/rings/complex_arb.pyx
++++ b/src/sage/rings/complex_arb.pyx
+@@ -1360,12 +1360,13 @@ cdef class ComplexBall(RingElement):
+             sage: CBF100(-3r)
+             -3.000000000000000000000000000000
+ 
+-            sage: ComplexBall(CBF100, 10^100)
+-            1.000000000000000000000000000000e+100
+             sage: ComplexBall(CBF100, CIF(1, 2))
+             1.000000000000000000000000000000 + 2.000000000000000000000000000000*I
+             sage: ComplexBall(CBF100, RBF(1/3), RBF(1))
+             [0.3333333333333333 +/- ...e-17] + 1.000000000000000000000000000000*I
++            sage: ComplexBall(CBF100, 10^100)
++            [1.000000000000000000000000000000e+100 +/- ...]
++
+             sage: NF.<a> = QuadraticField(-1, embedding=CC(0, -1))
+             sage: CBF(a)
+             -1.000000000000000*I
+@@ -3009,7 +3010,7 @@ cdef class ComplexBall(RingElement):
+             sage: CBF(1).rising_factorial(2**64)
+             [+/- ...e+347382171326740403407]
+             sage: ComplexBallField(128)(1).rising_factorial(2**64)
+-            [2.343691126796861348e+347382171305201285713 +/- ...e+347382171305201285694]
++            [2.34369112679686134...e+347382171305201285713 +/- ...]
+             sage: CBF(1/2).rising_factorial(CBF(2,3)) # abs tol 1e-15
+             [-0.123060451458124 +/- 3.06e-16] + [0.0406412631676552 +/- 7.57e-17]*I
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+index 04eaefc9fed..d99f0d3b98c 100644
+--- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+@@ -222,7 +222,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef unsigned long n
+         cdef Rational c
+         cdef list L1
+-        cdef mpq_t * L2
++        cdef fmpq_t q
+ 
+         Polynomial.__init__(self, parent, is_gen=is_gen)
+ 
+@@ -253,14 +253,11 @@ cdef class Polynomial_rational_flint(Polynomial):
+             L1 = [e if isinstance(e, Rational) else Rational(e) for e in x]
+             n  = <unsigned long> len(x)
+             sig_on()
+-            L2 = <mpq_t *> check_allocarray(n, sizeof(mpq_t))
++            fmpq_poly_fit_length(self._poly, n)
+             for deg from 0 <= deg < n:
+-                mpq_init(L2[deg])
+-                mpq_set(L2[deg], (<Rational> L1[deg]).value)
+-            fmpq_poly_set_array_mpq(self._poly, L2, n)
+-            for deg from 0 <= deg < n:
+-                mpq_clear(L2[deg])
+-            sig_free(L2)
++                fmpq_init_set_readonly(q, (<Rational> L1[deg]).value)
++                fmpq_poly_set_coeff_fmpq(self._poly, deg, q)
++                fmpq_clear_readonly(q)
+             sig_off()
+ 
+ #           deg = 0
+@@ -435,6 +432,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         utmost care.
+         """
+         cdef bint do_sig = _do_sig(self._poly)
++        cdef fmpz_t tmpfz
+ 
+         if isinstance(value, int):
+             if do_sig: sig_str("FLINT exception")
+@@ -442,7 +440,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+             if do_sig: sig_off()
+         elif isinstance(value, Integer):
+             if do_sig: sig_str("FLINT exception")
+-            fmpq_poly_set_coeff_mpz(self._poly, n, (<Integer> value).value)
++            fmpz_init_set_readonly(tmpfz, (<Integer> value).value)
++            fmpq_poly_set_coeff_fmpz(self._poly, n, tmpfz)
++            fmpz_clear_readonly(tmpfz)
+             if do_sig: sig_off()
+         elif isinstance(value, Rational):
+             if do_sig: sig_str("FLINT exception")
+@@ -492,7 +492,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef Polynomial_rational_flint f
+         cdef Rational r
+         cdef fmpz_t tmpfz
+-        cdef fmpq_t tmpfq
++        cdef fmpq_t tmpfq, tmpfq1
+         cdef RealBall arb_a, arb_z
+         cdef ComplexBall acb_a, acb_z
+ 
+@@ -508,13 +508,23 @@ cdef class Polynomial_rational_flint(Polynomial):
+             elif isinstance(a, Rational):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpq(r.value, self._poly, (<Rational> a).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> a).value)
++                fmpq_init(tmpfq1)
++                fmpq_poly_evaluate_fmpq(tmpfq1, self._poly, tmpfq)
++                fmpq_get_mpq(r.value, tmpfq1)
++                fmpq_clear(tmpfq1)
++                fmpq_clear_readonly(tmpfq)
+                 sig_off()
+                 return r
+             elif isinstance(a, Integer):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpz(r.value, self._poly, (<Integer> a).value)
++                fmpz_init_set_readonly(tmpfz, (<Integer> a).value)
++                fmpq_init(tmpfq)
++                fmpq_poly_evaluate_fmpz(tmpfq, self._poly, tmpfz)
++                fmpq_get_mpq(r.value, tmpfq)
++                fmpq_clear(tmpfq)
++                fmpz_clear_readonly(tmpfz)
+                 sig_off()
+                 return r
+             elif isinstance(a, int):
+@@ -1321,6 +1331,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         """
+         cdef Polynomial_rational_flint res
+         cdef bint do_sig
++        cdef fmpq_t tmpfq
+ 
+         if right == 0:
+             raise ZeroDivisionError("division by zero polynomial")
+@@ -1331,8 +1342,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+                 do_sig = _do_sig(self._poly)
+ 
+                 if do_sig: sig_str("FLINT exception")
+-                fmpq_poly_scalar_div_mpq(res._poly, self._poly,
+-                                                  (<Rational> QQ(right)).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> QQ(right)).value)
++                fmpq_poly_scalar_div_fmpq(res._poly, self._poly, tmpfq)
++                fmpq_clear_readonly(tmpfq)
+                 if do_sig: sig_off()
+                 return res
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+index 6e7f7498329..3a66198d568 100644
+--- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+@@ -658,6 +658,11 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
+             ...
+             NotImplementedError: square free factorization of polynomials over rings with composite characteristic is not implemented
+ 
++        :trac:`20003`::
++
++            sage: P.<x> = GF(7)[]
++            sage: (6*x+3).squarefree_decomposition()
++            (6) * (x + 4)
+         """
+         if not self.base_ring().is_field():
+             raise NotImplementedError("square free factorization of polynomials over rings with composite characteristic is not implemented")
+diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
+index 17961ac36b2..8509b19cc66 100644
+--- a/src/sage/rings/real_arb.pyx
++++ b/src/sage/rings/real_arb.pyx
+@@ -898,7 +898,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+             sage: RBF.gamma(5)
+             24.00000000000000
+             sage: RBF.gamma(10**20)
+-            [+/- ...e+1956570552410610660600]
++            [1.932849514310098...+1956570551809674817225 +/- ...]
+             sage: RBF.gamma(1/3)
+             [2.678938534707747 +/- ...e-16]
+             sage: RBF.gamma(-5)
+@@ -1102,7 +1102,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+              15.00000000000000,
+              48.00000000000000]
+             sage: RBF.double_factorial(2**20)
+-            [1.4483729903e+2928836 +/- ...e+2928825]
++            [1.448372990...e+2928836 +/- ...]
+             sage: RBF.double_factorial(2**1000)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/schemes/plane_conics/con_rational_function_field.py b/src/sage/schemes/plane_conics/con_rational_function_field.py
+index 05d24e78a85..581102b5c5b 100644
+--- a/src/sage/schemes/plane_conics/con_rational_function_field.py
++++ b/src/sage/schemes/plane_conics/con_rational_function_field.py
+@@ -198,38 +198,6 @@ def has_rational_point(self, point=False, algorithm='default',
+             Fraction Field of Univariate Polynomial Ring in u over Rational
+             Field with modulus v^2 - u^3 - 1
+ 
+-        ``has_rational_point`` fails for some conics over function fields
+-        over finite fields, due to :trac:`20003`::
+-
+-            sage: K.<t> = PolynomialRing(GF(7))
+-            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
+-            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
+-            sage: C.has_rational_point()                                                # needs sage.libs.singular
+-            Traceback (most recent call last):
+-            ...
+-            TypeError: self (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (-t^3 + 3*t^2 - 2*t - 2)/(t + 3)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (t^2 + 3*t + 3)*x*y + (-2*t^2 - 2)*y^2 + (-t^2 + 3*t + 2)*x*z + (-3*t + 3)*y*z + (-3*t^2 + t - 2)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x + (2*t - 2)/(t + 3)*y + (3*t^4 + 2*t^3 - 2*t^2 - 2*t + 3)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z
+-                     : y + (-t^3 - t^2 + 3*t - 1)/(t^3 - 3*t^2 + 2*t + 2)*z : z))
+-            domain must equal right (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^3 - t^2 + 3*t + 3)*x^2 + (t - 3)*y^2 + (-t^7 + 2*t^5 + t^4 + 2*t^3 + 3*t^2 - t - 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    -2/(t^3 - 3*t^2 + 2*t + 2)*x^2 + 1/(t^3 + 3*t^2 - 2*t + 1)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^9 - 2*t^8 + t^7 - t^6 + 3*t^5 - 3*t^3 + t^2 - 2*t + 3)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    ((t^3 - 3*t^2 + 2*t + 2)*x : (t^2 - 2)*y : (t^5 - 3*t^4 + t^2 + 3*t + 3)*z))
+-            codomain
+-
+-
+-
+         TESTS::
+ 
+             sage: K.<t> = FractionField(PolynomialRing(QQ, 't'))
+@@ -250,6 +218,16 @@ def has_rational_point(self, point=False, algorithm='default',
+             sage: C.has_rational_point(point=True)  # long time (4 seconds)             # needs sage.libs.singular
+             (True,
+              ((-2/117*t^8 + 304/1053*t^7 + 40/117*t^6 - 1/27*t^5 - 110/351*t^4 - 2/195*t^3 + 11/351*t^2 + 1/117)/(t^4 + 2/39*t^3 + 4/117*t^2 + 2/39*t + 14/39) : -5/3*t^4 + 19*t^3 : 1))
++
++        ``has_rational_point`` used to fail for some conics over function fields
++        over finite fields, due to :trac:`20003`::
++
++            sage: K.<t> = PolynomialRing(GF(7))
++            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
++            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
++            sage: C.has_rational_point()
++            True
++
+         """
+         from .constructor import Conic
+ 
+diff --git a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+index a591cb4cd7c..a90f2050c59 100644
+--- a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
++++ b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+@@ -20,6 +20,7 @@
+ #include "utils.h"
+ 
+ #include "gmp.h"
++#include "flint/fmpz_poly.h"
+ #include "flint/fmpq_poly.h"
+ #include "flint/fmpq.h"
+ 
+@@ -63,7 +64,7 @@ static ex chebyt_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+@@ -122,7 +123,7 @@ static ex chebyu_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+diff --git a/src/sage/symbolic/ginac/useries.cpp b/src/sage/symbolic/ginac/useries.cpp
+index 40fbd7ab360..b9a8b867648 100644
+--- a/src/sage/symbolic/ginac/useries.cpp
++++ b/src/sage/symbolic/ginac/useries.cpp
+@@ -467,10 +467,17 @@ void add::useries(flint_series_t& fp, int order) const
+                 fmpq_poly_set_ui(fp.ft, 0);
+         else if (oc.is_long())
+                 fmpq_poly_set_si(fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ 
+         for (const auto & elem : seq) {
+ 		const ex& t = recombine_pair_to_ex(elem);
+@@ -505,10 +512,17 @@ void mul::useries(flint_series_t& fp, int order) const
+ 
+         if (oc.is_long())
+                 fmpq_poly_scalar_mul_si(fp.ft, fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_scalar_mul_mpz(fp.ft, fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_scalar_mul_mpq(fp.ft, fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_scalar_mul_fmpz(fp.ft, fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp.ft, fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ void power::useries(flint_series_t& fp, int order) const
+@@ -563,7 +577,10 @@ void power::useries(flint_series_t& fp, int order) const
+                 }
+                 check_poly_ccoeff_one(fp1);
+                 fmpq_poly_log_series(fp1.ft, fp1.ft, order);
+-                fmpq_poly_scalar_mul_mpq(fp1.ft, fp1.ft, nexp.as_mpq());
++                fmpq_t tmp;
++                fmpq_init_set_readonly(tmp, nexp.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp1.ft, fp1.ft, tmp);
++                fmpq_clear_readonly(tmp);
+                 fmpq_poly_exp_series(fp.ft, fp1.ft, order);
+                 return;
+         }
+@@ -608,10 +625,17 @@ void numeric::useries(flint_series_t& fp, int order) const
+ {
+         if (is_long())
+                 fmpq_poly_set_si(fp.ft, to_long());
+-        else if (is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, as_mpq());
++        else if (is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ } // namespace GiNaC
+diff --git a/src/sage_setup/library_order.py b/src/sage_setup/library_order.py
+index f40690f8d22..9ae0d2579a7 100644
+--- a/src/sage_setup/library_order.py
++++ b/src/sage_setup/library_order.py
+@@ -16,17 +16,12 @@
+ 
+ aliases = cython_aliases(required_modules=(), optional_modules=modules)
+ 
+-if "ARB_LIBRARY" in aliases:
+-    arb_dylib_names = [aliases["ARB_LIBRARY"]]
+-else:
+-    arb_dylib_names = []
+-
+ library_order_list = aliases.get("SINGULAR_LIBRARIES", []) + [
+     "giac", "intl", "curl",
+     "ec", "ecm"
+ ] + aliases.get("LINBOX_LIBRARIES", []) + aliases.get("FFLASFFPACK_LIBRARIES", []) + aliases.get("GSL_LIBRARIES", []) + [
+     "pari", "flint", "ecl", "glpk", "ppl",
+-] + arb_dylib_names + [
++] + [
+     "mpfi", "mpfr", "mpc", "ntl", "gmp", "gmpxx",
+     "brial",
+     "brial_groebner",
diff --git a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch b/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
deleted file mode 100644
index 7c55bce6e9bb4..0000000000000
--- a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
+++ /dev/null
@@ -1,221 +0,0 @@
-diff --git a/build/pkgs/singular/checksums.ini b/build/pkgs/singular/checksums.ini
-index 313463d2fea..1101fc55700 100644
---- a/build/pkgs/singular/checksums.ini
-+++ b/build/pkgs/singular/checksums.ini
-@@ -1,5 +1,5 @@
- tarball=singular-VERSION.tar.gz
--sha1=28bb3ee97ef48d04dfa96de182fd93eebe08426c
--md5=fc0a4f5720dadba45a52ee94324ce00c
--cksum=1573851737
--upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-1/singular-VERSION.tar.gz
-+sha1=df1997f412580f2073295aba569bb955ad227317
-+md5=50349213e206a18cdaa1bc410dde7ea4
-+cksum=376854707
-+upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-2/singular-VERSION.tar.gz
-diff --git a/build/pkgs/singular/package-version.txt b/build/pkgs/singular/package-version.txt
-index 66e2bede53a..9f1bf008217 100644
---- a/build/pkgs/singular/package-version.txt
-+++ b/build/pkgs/singular/package-version.txt
-@@ -1 +1 @@
--4.3.1p3
-+4.3.2p7
-diff --git a/build/pkgs/singular/spkg-configure.m4 b/build/pkgs/singular/spkg-configure.m4
-index 6a85631f624..f7621ec5fa1 100644
---- a/build/pkgs/singular/spkg-configure.m4
-+++ b/build/pkgs/singular/spkg-configure.m4
-@@ -6,14 +6,27 @@ SAGE_SPKG_CONFIGURE([singular], [
-     AS_IF([test -z "${SINGULAR_BIN}"], [sage_spkg_install_singular=yes], [
-       dnl Use pkg-config to ensure that Singular is new enough.
-       PKG_CHECK_MODULES([SINGULAR], [Singular >= 4.2.1], [
--       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)
--       ], [
--       AC_MSG_RESULT(no)
--       sage_spkg_install_singular=yes
--       ]
--      )], [
-+        AC_MSG_CHECKING([whether Singular is built with FLINT])
-+        AC_COMPILE_IFELSE([
-+          AC_LANG_PROGRAM([
-+            #include <singular/singularconfig.h>
-+            #if !defined(HAVE_FLINT)
-+            #  error "Need Singular compiled with FLINT"
-+          ], [])
-+        ], [
-+          AC_MSG_RESULT([yes])
-+          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)
-+          ], [
-+            AC_MSG_RESULT(no)
-+            sage_spkg_install_singular=yes
-+          ])
-+        ], [
-+          AC_MSG_RESULT([no])
-+          sage_spkg_install_singular=yes
-+        ])
-+      ], [
-       dnl pkg-config version check failed
-       sage_spkg_install_singular=yes
-       ])
-diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py
-index b15cc1c602c..4b5c76e2bfa 100644
---- a/src/sage/interfaces/singular.py
-+++ b/src/sage/interfaces/singular.py
-@@ -604,8 +604,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: i = singular.ideal(['x^2','y^2','z^2'])
-             sage: s = i.std()
-             sage: singular.eval('hilb(%s)'%(s.name()))
--            '// 1 t^0\n// -3 t^2\n// 3 t^4\n// -1 t^6\n\n// 1 t^0\n//
--            3 t^1\n// 3 t^2\n// 1 t^3\n// dimension (affine) = 0\n//
-+            '...// dimension (affine) = 0\n//
-             degree (affine) = 8'
- 
-         ::
-@@ -613,15 +612,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: from sage.misc.verbose import set_verbose
-             sage: set_verbose(1)
-             sage: o = singular.eval('hilb(%s)'%(s.name()))
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
- 
-         This is mainly useful if this method is called implicitly. Because
-@@ -631,15 +622,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-         ::
- 
-             sage: o = s.hilb()
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
-             // ** right side is not a datum, assignment ignored
-             ...
-diff --git a/src/sage/libs/singular/function.pyx b/src/sage/libs/singular/function.pyx
-index f40346d1fd0..c597c63aafe 100644
---- a/src/sage/libs/singular/function.pyx
-+++ b/src/sage/libs/singular/function.pyx
-@@ -1241,32 +1241,22 @@ cdef class SingularFunction(SageObject):
-             sage: I = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5])
-             sage: I = Ideal(I.groebner_basis())
-             sage: hilb = sage.libs.singular.function_factory.ff.hilb
--            sage: hilb(I) # Singular will print // ** _ is no standard basis
--            // ** _ is no standard basis
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: from sage.misc.sage_ostools import redirection
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I) # Singular will print // ** _ is no standard basis
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            True
- 
-         So we tell Singular that ``I`` is indeed a Groebner basis::
- 
--            sage: hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            False
- 
- 
-         TESTS:
-diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-index 22ada6de947..80352700872 100644
---- a/src/sage/rings/polynomial/multi_polynomial_ideal.py
-+++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-@@ -3132,13 +3132,16 @@ def hilbert_numerator(self, grading=None, algorithm='sage'):
-             sage: I.hilbert_numerator()                                                 # needs sage.rings.number_field
-             -t^5 + 1
- 
--        This example returns a wrong answer due to an integer overflow in Singular::
-+        This example returns a wrong answer in singular < 4.3.2p4 due to an integer overflow::
- 
-             sage: n=4; m=11; P = PolynomialRing(QQ, n*m, "x"); x = P.gens(); M = Matrix(n, x)
-             sage: I = P.ideal(M.minors(2))
-             sage: J = P * [m.lm() for m in I.groebner_basis()]
--            sage: J.hilbert_numerator(algorithm='singular')
--            ...120*t^33 - 3465*t^32 + 48180*t^31 - ...
-+            sage: J.hilbert_numerator(algorithm='singular') # known bug
-+            Traceback (most recent call last):
-+            ....
-+            RuntimeError: error in Singular function call 'hilb':
-+            overflow at t^22
- 
-         Our two algorithms should always agree; not tested until
-         :trac:`33178` is fixed::
-diff --git a/src/sage/sandpiles/sandpile.py b/src/sage/sandpiles/sandpile.py
-index 02d2021b2fb..c8e15e06f05 100644
---- a/src/sage/sandpiles/sandpile.py
-+++ b/src/sage/sandpiles/sandpile.py
-@@ -2493,9 +2493,15 @@ def _set_ideal(self):
-             sage: '_ideal' in S.__dict__
-             True
-         """
-+        from sage.libs.singular.function_factory import ff
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
-         R = self.ring()
--        I = self._unsaturated_ideal._singular_()
--        self._ideal = R.ideal(I.sat(prod(R.gens())._singular_())[1])
-+        I = self._unsaturated_ideal
-+        I_sat_gens = sat(I, prod(R.gens()))[0]
-+        self._ideal = R.ideal(I_sat_gens)
- 
-     def unsaturated_ideal(self):
-         r"""
-diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py
-index e6caf19ba74..afd6484d779 100644
---- a/src/sage/schemes/projective/projective_subscheme.py
-+++ b/src/sage/schemes/projective/projective_subscheme.py
-@@ -1001,7 +1001,10 @@ def dual(self):
-         for i in range(n + 1):
-             J = J + S.ideal(z[-1] * f_S.derivative(z[i]) - z[i + n + 1])
- 
--        sat = ff.elim__lib.sat
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
- 
-         max_ideal = S.ideal(z[n + 1: 2 * n + 2])
-         J_sat_gens = sat(J, max_ideal)[0]
diff --git a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch b/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
deleted file mode 100644
index 6a35ec3836550..0000000000000
--- a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-diff --git a/src/sage/ext/memory.pyx b/src/sage/ext/memory.pyx
-index 1de6dedab82..b95130b19dd 100644
---- a/src/sage/ext/memory.pyx
-+++ b/src/sage/ext/memory.pyx
-@@ -3,14 +3,14 @@ Low-level memory allocation functions
- 
- TESTS:
- 
--Check that a ``MemoryError`` is raised if we try to allocate a
-+Check that an error is raised if we try to allocate a
- ridiculously large integer, see :trac:`15363`::
- 
--    sage: 2^(2^63-3)
--    Traceback (most recent call last):
--    ...
--    OverflowError: exponent must be at most 2147483647         # 32-bit
--    RuntimeError: Aborted                                      # 64-bit
-+    sage: try:
-+    ....:     2^(2^63-3)
-+    ....: except (OverflowError, RuntimeError, FloatingPointError):
-+    ....:     print ('Overflow error')
-+    ...Overflow error
- 
- AUTHORS:
- 
-diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx
-index d5e87626d31..37ed9364845 100644
---- a/src/sage/rings/integer.pyx
-+++ b/src/sage/rings/integer.pyx
-@@ -6654,7 +6654,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
-             sage: try:
-             ....:     print('Possible error output from gmp', flush=True)
-             ....:     1 << (2^60)
--            ....: except (MemoryError, OverflowError, RuntimeError):
-+            ....: except (MemoryError, OverflowError, RuntimeError, FloatingPointError):
-             ....:     pass
-             ....: else:
-             ....:     print("Failed to raise exception")
diff --git a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch b/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
deleted file mode 100644
index 3d2a4bd9cd96f..0000000000000
--- a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
+++ /dev/null
@@ -1,740 +0,0 @@
-diff --git a/src/sage/ext_data/valgrind/valgrind-python.supp b/src/sage/ext_data/valgrind/valgrind-python.supp
-new file mode 100644
-index 00000000000..16aa2858484
---- /dev/null
-+++ b/src/sage/ext_data/valgrind/valgrind-python.supp
-@@ -0,0 +1,480 @@
-+# From the CPython repository with the suppressions for _PyObject_Free
-+# and _PyObject_Realloc enabled. See the upstream suppression file for
-+# details:
-+#
-+# https://github.com/python/cpython/blob/main/Misc/valgrind-python.supp
-+
-+# all tool names: Addrcheck,Memcheck,cachegrind,helgrind,massif
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 8 (x86_64 aka amd64)
-+   Memcheck:Value8
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:address_in_range
-+}
-+
-+#
-+# Leaks (including possible leaks)
-+#    Hmmm, I wonder if this masks some real leaks.  I think it does.
-+#    Will need to fix that.
-+#
-+
-+{
-+   Suppress leaking the GIL after a fork.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_allocate_lock
-+   fun:PyEval_ReInitThreads
-+}
-+
-+{
-+   Suppress leaking the autoTLSkey.  This looks like it shouldn't leak though.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_create_key
-+   fun:_PyGILState_Init
-+   fun:Py_InitializeEx
-+   fun:Py_Main
-+}
-+
-+{
-+   Hmmm, is this a real leak or like the GIL?
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_ReInitTLS
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:realloc
-+   fun:_PyObject_GC_Resize
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_New
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_NewVar
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+#
-+# Non-python specific leaks
-+#
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:calloc
-+   fun:allocate_dtv
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:memalign
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Realloc
-+}
-+
-+###
-+### All the suppressions below are for errors that occur within libraries
-+### that Python uses.  The problems to not appear to be related to Python's
-+### use of the libraries.
-+###
-+
-+{
-+   Generic ubuntu ld problems
-+   Memcheck:Addr8
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+}
-+
-+{
-+   Generic gentoo ld problems
-+   Memcheck:Cond
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_close
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Value8
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   GDBM problems, see test_gdbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   fun:gdbm_open
-+
-+}
-+
-+{
-+   Uninitialised byte(s) false alarm, see bpo-35561
-+   Memcheck:Param
-+   epoll_ctl(event)
-+   fun:epoll_ctl
-+   fun:pyepoll_internal_ctl
-+}
-+
-+{
-+   ZLIB problems, see test_gzip
-+   Memcheck:Cond
-+   obj:/lib/libz.so.1.2.3
-+   obj:/lib/libz.so.1.2.3
-+   fun:deflate
-+}
-+
-+{
-+   Avoid problems w/readline doing a putenv and leaking on exit
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:xmalloc
-+   fun:sh_set_lines_and_columns
-+   fun:_rl_get_screen_size
-+   fun:_rl_init_terminal_io
-+   obj:/lib/libreadline.so.4.3
-+   fun:rl_initialize
-+}
-+
-+# Valgrind emits "Conditional jump or move depends on uninitialised value(s)"
-+# false alarms on GCC builtin strcmp() function. The GCC code is correct.
-+#
-+# Valgrind bug: https://bugs.kde.org/show_bug.cgi?id=264936
-+{
-+   bpo-38118: Valgrind emits false alarm on GCC builtin strcmp()
-+   Memcheck:Cond
-+   fun:PyUnicode_Decode
-+}
-+
-+
-+###
-+### These occur from somewhere within the SSL, when running
-+###  test_socket_sll.  They are too general to leave on by default.
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:memset
-+###}
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:memset
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:MD5_Update
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:MD5_Update
-+###}
-+
-+# Fedora's package "openssl-1.0.1-0.1.beta2.fc17.x86_64" on x86_64
-+# See http://bugs.python.org/issue14171
-+{
-+   openssl 1.0.1 prng 1
-+   Memcheck:Cond
-+   fun:bcmp
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 2
-+   Memcheck:Cond
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 3
-+   Memcheck:Value8
-+   fun:_x86_64_AES_encrypt_compact
-+   fun:AES_encrypt
-+}
-+
-+#
-+# All of these problems come from using test_socket_ssl
-+#
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_bin2bn
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libcrypto.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_set_key_unchecked
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_encrypt2
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BUF_MEM_grow_clean
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:memcpy
-+   fun:ssl3_read_bytes
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:SHA1_Update
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:SHA1_Update
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-+{
-+   wcscmp_false_positive
-+   Memcheck:Addr8
-+   fun:wcscmp
-+   fun:_PyOS_GetOpt
-+   fun:Py_Main
-+   fun:main
-+}
-+
-+# Additional suppressions for the unified decimal tests:
-+{
-+   test_decimal
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_decimal2
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index b40ed64edb5..8c55861c147 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -1576,6 +1576,62 @@ const numeric numeric::div(const numeric &other) const {
-         }
- }
- 
-+
-+// Compute `a^b` as an integer, where a is an integer. Assign to ``res``` if it is integral, or return ``false``.
-+// The nonnegative real root is taken for even denominators. To be used inside numeric::integer_rational_power,
-+// to handle the special case of integral ``a``.
-+bool integer_rational_power_of_mpz(
-+        numeric& res,
-+        const numeric& a,
-+        const numeric& b
-+) {
-+        if (a.t != MPZ)
-+                throw std::runtime_error("integer_rational_power_of_mpz: bad input");
-+        mpz_t z;
-+        mpz_init(z);
-+        mpz_set_ui(z, 0);
-+        int sgn = mpz_sgn(a.v._bigint);
-+        if (mpz_cmp_ui(a.v._bigint, 1) == 0
-+            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
-+                mpz_set_ui(z, 1);
-+        else if (sgn == 0) {
-+                res = *_num0_p;
-+                mpz_clear(z);
-+                return true;
-+        }
-+        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1)) {
-+                mpz_clear(z);
-+                return false;
-+        } else {
-+                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-+                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat))) {
-+                        // too big to take roots/powers
-+                        mpz_clear(z);
-+                        return false;
-+                }
-+                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
-+                        if (mpz_perfect_square_p(a.v._bigint)) {
-+                                mpz_sqrt(z, a.v._bigint);
-+                        } else {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                else {
-+                        bool exact = mpz_root(z, a.v._bigint,
-+                                              mpz_get_ui(mpq_denref(b.v._bigrat)));
-+                        if (not exact) {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
-+        }
-+        res = numeric(z);   // transfers ownership, no mpz_clear
-+        return true;
-+}
-+
-+
- // Compute `a^b` as an integer, if it is integral, or return ``false``.
- // The nonnegative real root is taken for even denominators.
- bool numeric::integer_rational_power(numeric& res,
-@@ -1598,13 +1654,12 @@ bool numeric::integer_rational_power(numeric& res,
-                 if (a.v._long < 0
-                     and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
-                         return false;
--                long z;
-                 if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-                     or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
-                 // too big to take roots/powers
-                         return false;
-                 if (b.is_equal(*_num1_2_p)) {
--                        z = std::lround(std::sqrt(a.v._long));
-+                        long z = std::lround(std::sqrt(a.v._long));
-                         if (a.v._long == z*z) {
-                                 res = numeric(z);
-                                 return true;
-@@ -1613,44 +1668,11 @@ bool numeric::integer_rational_power(numeric& res,
-                 }
-                 return integer_rational_power(res, a.to_bigint(), b);
-         }
--        if (a.t != MPZ)
--                throw std::runtime_error("integer_rational_power: bad input");
--        int sgn = mpz_sgn(a.v._bigint);
--        mpz_t z;
--        mpz_init(z);
--        mpz_set_ui(z, 0);
--        if (mpz_cmp_ui(a.v._bigint, 1) == 0
--            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
--                mpz_set_ui(z, 1);
--        else if (sgn == 0) {
--                res = *_num0_p;
--                return true;
--        }
--        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
--                return false;
--        else {
--                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
--                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
--                // too big to take roots/powers
--                        return false;
--                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
--                        if (mpz_perfect_square_p(a.v._bigint))
--                                mpz_sqrt(z, a.v._bigint);
--                        else
--                                return false;
--                }
--                else {
--                        bool exact = mpz_root(z, a.v._bigint,
--                                        mpz_get_ui(mpq_denref(b.v._bigrat)));
--                        if (not exact)
--                                return false;
--                }
--                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
--        }
--        res = numeric(z);
--        return true;
-+        // otherwise: a is integer
-+        return integer_rational_power_of_mpz(res, a, b);
- }
- 
-+
- // for a^b return c,d such that a^b = c*d^b
- // only for MPZ/MPQ base and MPQ exponent
- void rational_power_parts(const numeric& a_orig, const numeric& b_orig,
-diff --git a/src/sage/tests/memcheck/__init__.py b/src/sage/tests/memcheck/__init__.py
-new file mode 100644
-index 00000000000..e69de29bb2d
-diff --git a/src/sage/tests/memcheck/run_tests.py b/src/sage/tests/memcheck/run_tests.py
-new file mode 100644
-index 00000000000..6ff4503a81b
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests.py
-@@ -0,0 +1,24 @@
-+import types
-+
-+
-+def run_tests() -> None:
-+    """
-+    Run all memcheck tests
-+    """
-+    from sage.tests.memcheck import symbolic_expression
-+    run_tests_in_module(symbolic_expression)
-+
-+
-+def run_tests_in_module(mod: types.ModuleType) -> None:
-+    """
-+    Run all memcheck tests in the given module
-+    """
-+    for entry in dir(mod):
-+        if not entry.startswith('test_'):
-+            continue
-+        test_func = getattr(mod, entry)
-+        test_func()
-+
-+
-+if __name__ == '__main__':
-+    run_tests()
-diff --git a/src/sage/tests/memcheck/run_tests_in_valgrind.py b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-new file mode 100644
-index 00000000000..df5ad0e92b2
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-@@ -0,0 +1,35 @@
-+"""
-+Launch valgrind and run the memory leak tests
-+
-+
-+From the commandline, run
-+
-+    sage -python -m sage.tests.memcheck.run_tests_in_valgrind
-+
-+to launch valgrind and execute the memory leak tests. Requires valgrind
-+to be installed. Alternatively, run as a unit test:
-+
-+    sage: from sage.tests.memcheck.run_tests_in_valgrind import run_tests_in_valgrind
-+    sage: run_tests_in_valgrind()    # optional - valgrind
-+"""
-+
-+import subprocess
-+
-+
-+def run_tests_in_valgrind() -> None:
-+    """
-+    Run the sage.tests.memcheck.run_tests module inside valgrind
-+    """
-+    subprocess.check_call([
-+        'valgrind',
-+        '--suppressions=src/sage/ext_data/valgrind/valgrind-python.supp',
-+        '--show-possibly-lost=no',
-+        '--show-reachable=no',
-+        './venv/bin/python',
-+        '-m',
-+        'sage.tests.memcheck.run_tests'
-+    ])
-+
-+
-+if __name__ == '__main__':
-+    run_tests_in_valgrind()
-diff --git a/src/sage/tests/memcheck/symbolic_expression.py b/src/sage/tests/memcheck/symbolic_expression.py
-new file mode 100644
-index 00000000000..52182fbe62d
---- /dev/null
-+++ b/src/sage/tests/memcheck/symbolic_expression.py
-@@ -0,0 +1,11 @@
-+from sage.tests.memcheck.verify_no_leak import verify_no_leak
-+
-+
-+def test_sqrt_sqrt_2() -> None:
-+    from sage.misc.functional import sqrt
-+    T2 = sqrt(2)
-+
-+    def sqrt_T2() -> None:
-+        sqrt(T2)
-+
-+    verify_no_leak(sqrt_T2)
-diff --git a/src/sage/tests/memcheck/verify_no_leak.py b/src/sage/tests/memcheck/verify_no_leak.py
-new file mode 100644
-index 00000000000..89ca90cf89c
---- /dev/null
-+++ b/src/sage/tests/memcheck/verify_no_leak.py
-@@ -0,0 +1,27 @@
-+from typing import Tuple, Sequence, List, Callable, Any
-+import valgrind
-+
-+
-+def verify_no_leak(callback: Callable[[], Any],
-+                   repeat: int = 10000,
-+                   fuzzy: int = 10,
-+                   ) -> None:
-+    """
-+    Verify that the callback does not generate new definitely lost blocks
-+
-+    Raises an assertion if the callback leaks memory
-+    """
-+    callback()   # warm_up
-+    initial_blocks = (0, 0, 0, 0)
-+    valgrind.memcheck_do_leak_check()
-+    initial_blocks = valgrind.memcheck_count_leak_blocks()
-+    for _ in range(repeat):
-+        callback()
-+    valgrind.memcheck_do_leak_check()
-+    leak_blocks = valgrind.memcheck_count_leak_blocks()
-+    leak = leak_blocks[0] - initial_blocks[0]
-+    if leak < repeat - fuzzy:
-+        return  # callback did not leak at least once per call
-+    blocks = round(leak / repeat, 2)
-+    message = f'{callback} leaked {blocks} block on average ({repeat} iterations)'
-+    raise AssertionError(message)
diff --git a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch b/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
deleted file mode 100644
index 684b62affaf5a..0000000000000
--- a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx
-index 8f46570313d..a8e73e57b52 100644
---- a/src/sage/libs/ecl.pyx
-+++ b/src/sage/libs/ecl.pyx
-@@ -563,15 +563,15 @@ cdef class EclObject:
-     Floats in Python are IEEE double, which LISP has as well. However,
-     the printing of floating point types in LISP depends on settings::
- 
--        sage: a = EclObject(float(10^40))
-+        sage: a = EclObject(float(1.234e40))
-         sage: ecl_eval("(setf *read-default-float-format* 'single-float)")
-         <ECL: SINGLE-FLOAT>
-         sage: a
--        <ECL: 1.d40>
-+        <ECL: 1.234d40>
-         sage: ecl_eval("(setf *read-default-float-format* 'double-float)")
-         <ECL: DOUBLE-FLOAT>
-         sage: a
--        <ECL: 1.e40>
-+        <ECL: 1.234e40>
- 
-     Tuples are translated to dotted lists::
- 
-diff --git a/src/sage/libs/eclsig.h b/src/sage/libs/eclsig.h
-index e249ccf6874..005b2d99d0b 100644
---- a/src/sage/libs/eclsig.h
-+++ b/src/sage/libs/eclsig.h
-@@ -45,7 +45,11 @@ static inline void ecl_sig_off(void)
-     sig_off();
- }
- 
-+#if ECL_VERSION_NUMBER < 230909
- #define ecl_mpz_from_bignum(obj) ((obj)->big.big_num)
-+#else
-+#define ecl_mpz_from_bignum(obj) ecl_bignum(obj)
-+#endif
- 
- cl_object ecl_bignum_from_mpz(mpz_t num)
- {
diff --git a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch b/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
deleted file mode 100644
index e858f2fd4a445..0000000000000
--- a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
-index 59f10f6b13f..adcccff059b 100644
---- a/src/sage/plot/graphics.py
-+++ b/src/sage/plot/graphics.py
-@@ -36,6 +36,7 @@
- # ****************************************************************************
- 
- import os
-+from numbers import Integral
- from collections.abc import Iterable
- from math import isnan
- import sage.misc.verbose
-@@ -2874,6 +2875,11 @@ def matplotlib(self, filename=None,
-                 weight=lopts.pop('font_weight', 'medium'),
-                 variant=lopts.pop('font_variant', 'normal'))
-             color = lopts.pop('back_color', 'white')
-+            if 'loc' in lopts:
-+                loc = lopts['loc']
-+                if isinstance(loc, Integral):
-+                    # matplotlib 3.8 doesn't support sage integers
-+                    lopts['loc'] = int(loc)
-             leg = subplot.legend(prop=prop, **lopts)
-             if leg is None:
-                 from warnings import warn
diff --git a/srcpkgs/sagemath/patches/36403-00pre.patch b/srcpkgs/sagemath/patches/36403-00pre.patch
deleted file mode 100644
index 060404d5430de..0000000000000
--- a/srcpkgs/sagemath/patches/36403-00pre.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-Minor patch so that #36403 applies cleanly over sagemath 10.1
-
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 2053bca80c3..86aca6e00d8 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15123,7 +15302,8 @@ cdef class Matrix(Matrix1):
-             sage: N.conjugate_transpose()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object has no attribute 'conjugate'
-+            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
-+            has no attribute 'conjugate'
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 525ea5aa934..52afed49d64 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -55,7 +55,7 @@ cdef class AttributeErrorMessage:
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-         sage: x = polygen(ZZ, 'x')
--        sage: QQ[x].gen().bla                                                           # optional - sage.libs.flint
-+        sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
diff --git a/srcpkgs/sagemath/patches/36407-python_3.12.patch b/srcpkgs/sagemath/patches/36407-python_3.12.patch
deleted file mode 100644
index c75c275c30764..0000000000000
--- a/srcpkgs/sagemath/patches/36407-python_3.12.patch
+++ /dev/null
@@ -1,1744 +0,0 @@
-diff --git a/build/sage_bootstrap/package.py b/build/sage_bootstrap/package.py
-index 15b342223c4..eb82f96e05f 100644
---- a/build/sage_bootstrap/package.py
-+++ b/build/sage_bootstrap/package.py
-@@ -303,7 +303,7 @@ def _init_checksum(self):
-         # Name of the directory containing the checksums.ini file
-         self.__tarball_package_name = os.path.realpath(checksums_ini).split(os.sep)[-2]
- 
--    VERSION_PATCHLEVEL = re.compile('(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
-+    VERSION_PATCHLEVEL = re.compile(r'(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
- 
-     def _init_version(self):
-         try:
-diff --git a/src/doc/en/thematic_tutorials/coercion_and_categories.rst b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-index bb23331c151..7f5712caea7 100644
---- a/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-+++ b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-@@ -1223,7 +1223,7 @@ However, only "elementary" construction functors have a rank::
-     sage: (Fract*Poly).rank
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'
-+    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'...
- 
- .. end of output
- 
-diff --git a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-index 553a946c4d8..3cd71a9bad4 100644
---- a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-+++ b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-@@ -318,7 +318,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: e.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'...
- 
-         sage: id4 = SymmetricGroup(4).one()
-         sage: type(id4)
-@@ -326,7 +326,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: id4.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'
-+        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'...
- 
- .. note::
- 
-diff --git a/src/sage/algebras/cluster_algebra.py b/src/sage/algebras/cluster_algebra.py
-index b72d2a12976..14669dfed5c 100644
---- a/src/sage/algebras/cluster_algebra.py
-+++ b/src/sage/algebras/cluster_algebra.py
-@@ -167,7 +167,7 @@
-     sage: (t*s).g_vector()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'
-+    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'...
-     sage: A = ClusterAlgebra(['A', 2], principal_coefficients=True)
-     sage: A.explore_to_depth(infinity)
-     sage: s = A.cluster_variable((0, -1)); s
-diff --git a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-index e4a91723558..343ee8a66f9 100644
---- a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-+++ b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-@@ -109,7 +109,7 @@ class WeylLieConformalAlgebra(LieConformalAlgebraWithStructureCoefficients):
-         sage: alpha0.degree()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'
-+        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'...
- 
-     TESTS::
- 
-diff --git a/src/sage/algebras/steenrod/steenrod_algebra.py b/src/sage/algebras/steenrod/steenrod_algebra.py
-index 978a3557a9d..7c4d444f81c 100644
---- a/src/sage/algebras/steenrod/steenrod_algebra.py
-+++ b/src/sage/algebras/steenrod/steenrod_algebra.py
-@@ -1080,7 +1080,7 @@ def homogeneous_component(self, n):
-             sage: a.antipode() # not defined
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'
-+            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'...
-             sage: A(a).antipode() # convert to elt of A, then compute antipode
-             Sq(2,1) + Sq(5)
- 
-diff --git a/src/sage/all__sagemath_repl.py b/src/sage/all__sagemath_repl.py
-index 8d0b43679ca..c31b206bcb8 100644
---- a/src/sage/all__sagemath_repl.py
-+++ b/src/sage/all__sagemath_repl.py
-@@ -79,6 +79,23 @@
-                         message=r"Use setlocale\(\), getencoding\(\) and getlocale\(\) instead",
-                         module='docutils.io')
- 
-+# triggered by dateutil 2.8.2 and sphinx 7.0.1 on Python 3.12
-+# see: https://github.com/dateutil/dateutil/pull/1285
-+# see: https://github.com/sphinx-doc/sphinx/pull/11468
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"datetime.datetime.utcfromtimestamp\(\) is deprecated",
-+                        module='dateutil.tz.tz|sphinx.(builders.gettext|util.i18n)')
-+
-+# triggered on Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"This process.* is multi-threaded, "
-+                                r"use of .*\(\) may lead to deadlocks in the child.")
-+
-+# pickling of itertools is deprecated in Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"Pickle, copy, and deepcopy support will be "
-+                                r"removed from itertools in Python 3.14.")
-+
- 
- from .all__sagemath_objects import *
- from .all__sagemath_environment import *
-diff --git a/src/sage/arith/long.pxd b/src/sage/arith/long.pxd
-index 0031a0ae337..3ea70cef571 100644
---- a/src/sage/arith/long.pxd
-+++ b/src/sage/arith/long.pxd
-@@ -19,6 +19,8 @@ from libc.limits cimport LONG_MIN, LONG_MAX
- from cpython.object cimport Py_SIZE
- from cpython.number cimport PyNumber_Index, PyIndex_Check
- from cpython.longintrepr cimport py_long, PyLong_SHIFT, digit
-+from sage.cpython.pycore_long cimport (
-+    ob_digit, _PyLong_IsNegative, _PyLong_DigitCount)
- 
- from sage.libs.gmp.mpz cimport mpz_fits_slong_p, mpz_get_si
- from sage.rings.integer_fake cimport is_Integer, Integer_AS_MPZ
-@@ -299,8 +301,11 @@ cdef inline bint integer_check_long_py(x, long* value, int* err):
-         return 0
- 
-     # x is a Python "int" (aka PyLongObject or py_long in cython)
--    cdef const digit* D = (<py_long>x).ob_digit
--    cdef Py_ssize_t size = Py_SIZE(x)
-+    cdef const digit* D = ob_digit(x)
-+    cdef Py_ssize_t size = _PyLong_DigitCount(x)
-+
-+    if _PyLong_IsNegative(x):
-+        size = -size
- 
-     # We assume PyLong_SHIFT <= BITS_IN_LONG <= 3 * PyLong_SHIFT.
-     # This is true in all the default configurations:
-diff --git a/src/sage/categories/category.py b/src/sage/categories/category.py
-index 57ef7f4184b..29bce8ee415 100644
---- a/src/sage/categories/category.py
-+++ b/src/sage/categories/category.py
-@@ -2129,7 +2129,7 @@ def _with_axioms(self, axioms):
-             sage: Semigroups().Inverse()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'
-+            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'...
-             sage: Semigroups()._with_axioms(["Inverse"])
-             Category of semigroups
- 
-diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py
-index 5227792e725..4775d4e5bf1 100644
---- a/src/sage/categories/category_with_axiom.py
-+++ b/src/sage/categories/category_with_axiom.py
-@@ -554,7 +554,7 @@ class from the base category class::
-     sage: Magmas.Unital.Associative
-     Traceback (most recent call last):
-     ...
--    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'
-+    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'...
- 
- The purpose of this section is to explain the design of the code
- layout and the rationale for this mismatch.
-@@ -769,7 +769,7 @@ def _(): return LazyImport('sage.categories.rngs', 'Rngs', at_startup=True)
-     sage: Semirings().NoZeroDivisors()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'
-+    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'...
- 
- Concretely, this is to be implemented by defining the new axiom in the
- (``SubcategoryMethods`` nested class of the) appropriate category with
-diff --git a/src/sage/categories/enumerated_sets.py b/src/sage/categories/enumerated_sets.py
-index a8bea53f907..b0ea05d0563 100644
---- a/src/sage/categories/enumerated_sets.py
-+++ b/src/sage/categories/enumerated_sets.py
-@@ -610,7 +610,7 @@ def _list_from_iterator(self):
-                 sage: (QQ^2).list()  # indirect test                                    # needs sage.modules
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'
-+                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'...
- 
-             Here we test that for an object that does not know whether it
-             is finite or not.  Calling ``x.list()`` simply tries to create
-@@ -622,11 +622,11 @@ def _list_from_iterator(self):
-                 sage: Q.is_finite()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'...
-                 sage: Q.list()   # indirect test
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'...
- 
-             Here is another example. We artificially create a version of
-             the ring of integers that does not know whether it is finite
-diff --git a/src/sage/categories/examples/sets_cat.py b/src/sage/categories/examples/sets_cat.py
-index e0853d63f94..fbadb9ca405 100644
---- a/src/sage/categories/examples/sets_cat.py
-+++ b/src/sage/categories/examples/sets_cat.py
-@@ -619,7 +619,7 @@ class PrimeNumbers_Facade(PrimeNumbers_Abstract):
-         sage: pf.next()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'...
- 
-     unlike in the other implementations::
- 
-diff --git a/src/sage/categories/homset.py b/src/sage/categories/homset.py
-index 22ba9d047fc..2a8b8aeedeb 100644
---- a/src/sage/categories/homset.py
-+++ b/src/sage/categories/homset.py
-@@ -632,7 +632,7 @@ def __init__(self, X, Y, category=None, base=None, check=True):
-             sage: H = MyHomset(X, Y, category=1, base = ZZ, check = False)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'...
-             sage: P.<t> = ZZ[]
-             sage: f = P.hom([1/2*t])
-             sage: f.parent().domain()
-diff --git a/src/sage/categories/modules_with_basis.py b/src/sage/categories/modules_with_basis.py
-index e97bf851388..c4933d0657f 100644
---- a/src/sage/categories/modules_with_basis.py
-+++ b/src/sage/categories/modules_with_basis.py
-@@ -2456,7 +2456,7 @@ def apply_multilinear_morphism(self, f, codomain=None):
-                     sage: tensor([a, b]).apply_multilinear_morphism(f)                  # needs sage.modules
-                     Traceback (most recent call last):
-                     ...
--                    AttributeError: 'int' object has no attribute 'parent'
-+                    AttributeError: 'int' object has no attribute 'parent'...
- 
-                 Here we consider an example where the codomain is a
-                 module with basis with a different base ring::
-diff --git a/src/sage/categories/monoids.py b/src/sage/categories/monoids.py
-index 38dd7248c9d..28474bd17b6 100644
---- a/src/sage/categories/monoids.py
-+++ b/src/sage/categories/monoids.py
-@@ -556,7 +556,7 @@ def algebra_generators(self):
-                     Traceback (most recent call last):
-                     ...
-                     AttributeError: 'IntegerModMonoid_with_category' object
--                    has no attribute 'monoid_generators'
-+                    has no attribute 'monoid_generators'...
-                     sage: Z12.semigroup_generators()
-                     Family (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
-                     sage: Z12.algebra(QQ).algebra_generators()                          # needs sage.modules
-diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py
-index 494e8154c80..ec5120e41e6 100644
---- a/src/sage/combinat/finite_state_machine.py
-+++ b/src/sage/combinat/finite_state_machine.py
-@@ -1835,7 +1835,7 @@ def __getstate__(self):
-             sage: T1.transitions
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'FSMState' object has no attribute 'transitions'
-+            AttributeError: 'FSMState' object has no attribute 'transitions'...
-             sage: A1 = loads(dumps(A))
-             sage: all(A.state(j) == A1.state(j) for j in [0, 1])
-             True
-diff --git a/src/sage/combinat/growth.py b/src/sage/combinat/growth.py
-index cf8d18c1764..766eea37917 100644
---- a/src/sage/combinat/growth.py
-+++ b/src/sage/combinat/growth.py
-@@ -371,7 +371,7 @@
-     sage: GrowthDiagram(RulePascal(), [3,1,2])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'RulePascal' object has no attribute 'forward_rule'
-+    AttributeError: 'RulePascal' object has no attribute 'forward_rule'...
- 
- We now re-implement the rule where we provide the dual graded graphs::
- 
-diff --git a/src/sage/combinat/integer_lists/lists.py b/src/sage/combinat/integer_lists/lists.py
-index 5143e5cb5e8..9117a6076f7 100644
---- a/src/sage/combinat/integer_lists/lists.py
-+++ b/src/sage/combinat/integer_lists/lists.py
-@@ -261,7 +261,7 @@ def __getattr__(self, name):
-             sage: L.foo
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'foo'
-+            AttributeError: 'NoneType' object has no attribute 'foo'...
-         """
-         return getattr(self.backend, name)
- 
-diff --git a/src/sage/combinat/posets/posets.py b/src/sage/combinat/posets/posets.py
-index c31597c72e9..c74bfc67cee 100644
---- a/src/sage/combinat/posets/posets.py
-+++ b/src/sage/combinat/posets/posets.py
-@@ -8825,7 +8825,7 @@ def is_induced_subposet(self, other):
-             sage: Poset().is_induced_subposet('junk')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'subposet'
-+            AttributeError: 'str' object has no attribute 'subposet'...
-         """
-         if (not self._is_facade or (isinstance(other, FinitePoset) and
-                                     not other._is_facade)):
-diff --git a/src/sage/cpython/atexit.pyx b/src/sage/cpython/atexit.pyx
-index 961aa348d0a..e5a82735137 100644
---- a/src/sage/cpython/atexit.pyx
-+++ b/src/sage/cpython/atexit.pyx
-@@ -154,6 +154,10 @@ cdef extern from *:
-     #undef _PyGC_FINALIZED
-     #include "internal/pycore_interp.h"
-     #include "internal/pycore_pystate.h"
-+    #if PY_VERSION_HEX >= 0x030c0000
-+    // struct atexit_callback was renamed in 3.12 to atexit_py_callback
-+    #define atexit_callback atexit_py_callback
-+    #endif
-     static atexit_callback ** _atexit_callbacks(PyObject *self) {
-         PyInterpreterState *interp = _PyInterpreterState_GET();
-         struct atexit_state state = interp->atexit;
-diff --git a/src/sage/cpython/debug.pyx b/src/sage/cpython/debug.pyx
-index 986abff2a99..cdaca3a4854 100644
---- a/src/sage/cpython/debug.pyx
-+++ b/src/sage/cpython/debug.pyx
-@@ -78,7 +78,7 @@ def getattr_debug(obj, name, default=_no_default):
- 
-     EXAMPLES::
- 
--        sage: _ = getattr_debug(list, "reverse")
-+        sage: _ = getattr_debug(list, "reverse")  # not tested - broken in python 3.12
-         getattr_debug(obj=<class 'list'>, name='reverse'):
-           type(obj) = <class 'type'>
-           object has __dict__ slot (<class 'dict'>)
-@@ -123,7 +123,7 @@ def getattr_debug(obj, name, default=_no_default):
-         sage: _ = getattr_debug(1, "foo")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'...
-         sage: _ = getattr_debug(1, "foo", "xyz")
-         getattr_debug(obj=1, name='foo'):
-           type(obj) = <class 'sage.rings.integer.Integer'>
-diff --git a/src/sage/cpython/dict_internal.h b/src/sage/cpython/dict_internal.h
-index 42a57bcb468..a5ee35bc198 100644
---- a/src/sage/cpython/dict_internal.h
-+++ b/src/sage/cpython/dict_internal.h
-@@ -169,6 +169,7 @@ dictkeys_set_index(PyDictKeysObject *keys, Py_ssize_t i, Py_ssize_t ix)
- #else   /* Python >= 3.11 */
- 
- #define Py_BUILD_CORE
-+#undef _PyGC_FINALIZED
- #include <internal/pycore_dict.h>
- 
- /************************************************************/
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 52afed49d64..1f49e5230c3 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -53,12 +53,12 @@ cdef class AttributeErrorMessage:
-         sage: 1.bla  #indirect doctest
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'...
-         sage: x = polygen(ZZ, 'x')
-         sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'...
- 
-     ::
- 
-@@ -144,7 +144,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(X, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: x = X()
-         sage: raw_getattr(x, "prop")
-         <property object at ...>
-@@ -173,7 +173,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(Y, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: y = Y()
-         sage: raw_getattr(y, "prop")
-         <property object at ...>
-@@ -278,7 +278,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     The integer ring is a parent, so, lazy attributes work::
- 
-@@ -289,7 +289,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(17, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     In general, descriptors are not yet well supported, because they
-     often do not accept to be cheated with the type of their instance::
-@@ -305,7 +305,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__weakref__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-     This was caught by :trac:`8296` for which we do a couple more tests::
- 
-@@ -314,7 +314,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: 1.__weakref__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-         sage: n = 1
-         sage: ip = get_ipython()                 # not tested: only works in interactive shell
-@@ -329,7 +329,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__call__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'...
- 
-     TESTS:
- 
-@@ -339,14 +339,14 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, type, "__name__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'...
- 
-     Non-strings as "name" are handled gracefully::
- 
-         sage: getattr_from_other_class(1, type, None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute None
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute None...
-     """
-     if not isinstance(cls, type):
-         raise TypeError(f"{cls!r} is not a type")
-diff --git a/src/sage/cpython/pycore_long.h b/src/sage/cpython/pycore_long.h
-new file mode 100644
-index 00000000000..ff1a73d097a
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.h
-@@ -0,0 +1,98 @@
-+#include "Python.h"
-+#include <stdbool.h>
-+
-+#if PY_VERSION_HEX >= 0x030C00A5
-+#define ob_digit(o)  (((PyLongObject*)o)->long_value.ob_digit)
-+#else
-+#define ob_digit(o)  (((PyLongObject*)o)->ob_digit)
-+#endif
-+
-+#if PY_VERSION_HEX >= 0x030C00A7
-+// taken from cpython:Include/internal/pycore_long.h @ 3.12
-+
-+/* Long value tag bits:
-+ * 0-1: Sign bits value = (1-sign), ie. negative=2, positive=0, zero=1.
-+ * 2: Reserved for immortality bit
-+ * 3+ Unsigned digit count
-+ */
-+#define SIGN_MASK 3
-+#define SIGN_ZERO 1
-+#define SIGN_NEGATIVE 2
-+#define NON_SIZE_BITS 3
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_ZERO;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_NEGATIVE;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    assert(PyLong_Check(op));
-+    return op->long_value.lv_tag >> NON_SIZE_BITS;
-+}
-+
-+#define TAG_FROM_SIGN_AND_SIZE(sign, size) ((1 - (sign)) | ((size) << NON_SIZE_BITS))
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+    assert(size >= 0);
-+    assert(-1 <= sign && sign <= 1);
-+    assert(sign != 0 || size == 0);
-+    op->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sign, (size_t)size);
-+}
-+
-+#else
-+// fallback for < 3.12
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) == 0;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) < 0;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) > 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    Py_ssize_t size = Py_SIZE(op);
-+    return size < 0 ? -size : size;
-+}
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION < 9)
-+// The function Py_SET_SIZE is defined starting with python 3.9.
-+    Py_SIZE(o) = size;
-+#else
-+    Py_SET_SIZE(op, sign < 0 ? -size : size);
-+#endif
-+}
-+
-+#endif
-diff --git a/src/sage/cpython/pycore_long.pxd b/src/sage/cpython/pycore_long.pxd
-new file mode 100644
-index 00000000000..41de637ff18
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.pxd
-@@ -0,0 +1,9 @@
-+from cpython.longintrepr cimport py_long, digit
-+
-+cdef extern from "pycore_long.h":
-+    digit* ob_digit(py_long o)
-+    bint _PyLong_IsZero(py_long o)
-+    bint _PyLong_IsNegative(py_long o)
-+    bint _PyLong_IsPositive(py_long o)
-+    Py_ssize_t _PyLong_DigitCount(py_long o)
-+    void _PyLong_SetSignAndDigitCount(py_long o, int sign, Py_ssize_t size)
-diff --git a/src/sage/crypto/classical.py b/src/sage/crypto/classical.py
-index 616dc861652..be899c781e5 100644
---- a/src/sage/crypto/classical.py
-+++ b/src/sage/crypto/classical.py
-@@ -494,7 +494,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: A.rank_by_chi_square("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_chi_square(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -703,7 +703,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: A.rank_by_squared_differences("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_squared_differences(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -2114,7 +2114,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: S.rank_by_chi_square("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_chi_square(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-@@ -2351,7 +2351,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: S.rank_by_squared_differences("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_squared_differences(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/crypto/mq/mpolynomialsystemgenerator.py b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-index 9028dab1d98..4416d9ef7f6 100644
---- a/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-+++ b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-@@ -156,7 +156,7 @@ def sbox(self):
-             sage: msg.sbox()
-             Traceback (most recent call last):
-             ...
--            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'
-+            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'...
-         """
-         return self._sbox
- 
-diff --git a/src/sage/data_structures/bitset.pyx b/src/sage/data_structures/bitset.pyx
-index 446062554c1..d9906b5edd2 100644
---- a/src/sage/data_structures/bitset.pyx
-+++ b/src/sage/data_structures/bitset.pyx
-@@ -967,7 +967,7 @@ cdef class FrozenBitset:
-             sage: None | FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute '_union'
-+            AttributeError: 'NoneType' object has no attribute '_union'...
-         """
-         return self._union(other)
- 
-@@ -1037,7 +1037,7 @@ cdef class FrozenBitset:
-             sage: None & FrozenBitset("101011")
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'intersection'
-+            AttributeError: 'NoneType' object has no attribute 'intersection'...
-         """
-         return self.intersection(other)
- 
-@@ -1106,7 +1106,7 @@ cdef class FrozenBitset:
-             sage: None - FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'difference'
-+            AttributeError: 'NoneType' object has no attribute 'difference'...
-         """
-         return self.difference(other)
- 
-@@ -1179,7 +1179,7 @@ cdef class FrozenBitset:
-             sage: None ^^ FrozenBitset('11111' * 10)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'
-+            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'...
-         """
-         return self.symmetric_difference(other)
- 
-diff --git a/src/sage/doctest/reporting.py b/src/sage/doctest/reporting.py
-index 361fea344c2..a3947c07e01 100644
---- a/src/sage/doctest/reporting.py
-+++ b/src/sage/doctest/reporting.py
-@@ -368,7 +368,7 @@ def report(self, source, timeout, return_code, results, output, pid=None):
-             sage: DTR.report(None, None, None, None, None)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'basename'
-+            AttributeError: 'NoneType' object has no attribute 'basename'...
- 
-         The only-errors mode does not output anything on success::
- 
-diff --git a/src/sage/dynamics/finite_dynamical_system.py b/src/sage/dynamics/finite_dynamical_system.py
-index e5fbf568b7e..4295070615a 100644
---- a/src/sage/dynamics/finite_dynamical_system.py
-+++ b/src/sage/dynamics/finite_dynamical_system.py
-@@ -240,7 +240,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-@@ -252,7 +252,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-diff --git a/src/sage/geometry/cone.py b/src/sage/geometry/cone.py
-index f0a8620011a..53f78a4b7b6 100644
---- a/src/sage/geometry/cone.py
-+++ b/src/sage/geometry/cone.py
-@@ -340,7 +340,7 @@ def Cone(rays, lattice=None, check=True, normalize=True):
-         sage: Cone([(1,0), (0,1)], check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     You can construct different "not" cones: not full-dimensional, not
-     strictly convex, not containing any rays::
-diff --git a/src/sage/geometry/fan.py b/src/sage/geometry/fan.py
-index 258544012fe..3aecc84a55b 100644
---- a/src/sage/geometry/fan.py
-+++ b/src/sage/geometry/fan.py
-@@ -443,7 +443,7 @@ def Fan(cones, rays=None, lattice=None, check=True, normalize=True,
-         sage: P2c = Fan(cones, rays, check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     Yet another way is to use functions :func:`FaceFan` and :func:`NormalFan`
-     to construct fans from :class:`lattice polytopes
-diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-index f0ac1e774a7..f03f0f832ff 100644
---- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-+++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-@@ -351,7 +351,7 @@ cdef class FaceIterator_base(SageObject):
-             sage: FaceIterator_base(2)  # indirect doctest
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'...
-         """
-         cdef int i
-         sig_free(self.structure.atom_rep)
-@@ -1945,7 +1945,8 @@ cdef inline int next_face_loop(iter_t structure) nogil except -1:
-         # The function is not supposed to be called,
-         # just prevent it from crashing.
-         # Actually raising an error here results in a bad branch prediction.
--        return -1
-+        # But return -1 results in a crash with python 3.12
-+        raise StopIteration
- 
-     # Getting ``[faces, n_faces, n_visited_all]`` according to dimension.
-     cdef face_list_t* faces = &structure.new_faces[structure.current_dimension]
-diff --git a/src/sage/geometry/toric_plotter.py b/src/sage/geometry/toric_plotter.py
-index 50b4008eb0f..950e3ba7ff8 100644
---- a/src/sage/geometry/toric_plotter.py
-+++ b/src/sage/geometry/toric_plotter.py
-@@ -706,7 +706,7 @@ def set_rays(self, generators):
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ToricPlotter' object has no attribute 'rays'
-+            AttributeError: 'ToricPlotter' object has no attribute 'rays'...
-             sage: tp.set_rays([(0,1)])
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Graphics object consisting of 2 graphics primitives
-diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
-index d0ec214bb3b..c8098ad578a 100644
---- a/src/sage/groups/matrix_gps/finitely_generated.py
-+++ b/src/sage/groups/matrix_gps/finitely_generated.py
-@@ -268,7 +268,7 @@ def MatrixGroup(*gens, **kwds):
-         sage: SL2C.gens()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'
-+        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'...
-     """
-     if isinstance(gens[-1], dict):   # hack for unpickling
-         kwds.update(gens[-1])
-diff --git a/src/sage/homology/chains.py b/src/sage/homology/chains.py
-index 87c0947c0b0..b9a54940943 100644
---- a/src/sage/homology/chains.py
-+++ b/src/sage/homology/chains.py
-@@ -298,7 +298,7 @@ def is_cycle(self):
-                 sage: chain.is_cocycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -325,7 +325,7 @@ def is_boundary(self):
-                 sage: chain.is_coboundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -539,7 +539,7 @@ def is_cocycle(self):
-                 sage: cochain.is_cycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -566,7 +566,7 @@ def is_coboundary(self):
-                 sage: cochain.is_boundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -604,7 +604,7 @@ def eval(self, other):
-                 sage: z.eval(c) # z is not a cochain
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'...
-                 sage: c.eval(c) # can't evaluate a cochain on a cochain
-                 Traceback (most recent call last):
-                 ...
-diff --git a/src/sage/homology/free_resolution.py b/src/sage/homology/free_resolution.py
-index e3d38de4240..280a479b438 100644
---- a/src/sage/homology/free_resolution.py
-+++ b/src/sage/homology/free_resolution.py
-@@ -275,7 +275,7 @@ def differential(self, i):
-             sage: FreeResolution.differiental(r, 1)
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'FreeResolution' has no attribute 'differiental'
-+            AttributeError: type object 'FreeResolution' has no attribute 'differiental'...
-         """
- 
-     def target(self):
-diff --git a/src/sage/interfaces/magma.py b/src/sage/interfaces/magma.py
-index b7a0ac20d03..529bfbc349b 100644
---- a/src/sage/interfaces/magma.py
-+++ b/src/sage/interfaces/magma.py
-@@ -824,7 +824,7 @@ def _coerce_from_special_method(self, x):
-             sage: magma._coerce_from_special_method('2 + 3')  # optional - magma
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute '_magma_init_'
-+            AttributeError: 'str' object has no attribute '_magma_init_'...
-         """
-         s = x._magma_init_(self)
-         a = self(s)
-diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
-index 58499396d6c..16119d20815 100644
---- a/src/sage/lfunctions/dokchitser.py
-+++ b/src/sage/lfunctions/dokchitser.py
-@@ -418,8 +418,8 @@ def init_coeffs(self, v, cutoff=1,
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
-index bbf289aa21c..e4968866303 100644
---- a/src/sage/lfunctions/pari.py
-+++ b/src/sage/lfunctions/pari.py
-@@ -141,8 +141,8 @@ def init_coeffs(self, v, cutoff=None, w=1):
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
-index 478caf9f9d0..363024ae281 100644
---- a/src/sage/libs/gap/element.pyx
-+++ b/src/sage/libs/gap/element.pyx
-@@ -380,7 +380,7 @@ cdef GapElement make_GapElement(parent, Obj obj):
-         sage: libgap(None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute '_libgap_init_'
-+        AttributeError: 'NoneType' object has no attribute '_libgap_init_'...
-     """
-     cdef GapElement r = GapElement.__new__(GapElement)
-     r._initialize(parent, obj)
-diff --git a/src/sage/libs/gmp/pylong.pxd b/src/sage/libs/gmp/pylong.pxd
-index a73f1da6d6f..84e1bb8cd87 100644
---- a/src/sage/libs/gmp/pylong.pxd
-+++ b/src/sage/libs/gmp/pylong.pxd
-@@ -2,9 +2,10 @@
- Various functions to deal with conversion mpz <-> Python int/long
- """
- 
-+from cpython.longintrepr cimport py_long
- from sage.libs.gmp.types cimport *
- 
- cdef mpz_get_pylong(mpz_srcptr z)
- cdef mpz_get_pyintlong(mpz_srcptr z)
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1
- cdef Py_hash_t mpz_pythonhash(mpz_srcptr z)
-diff --git a/src/sage/libs/gmp/pylong.pyx b/src/sage/libs/gmp/pylong.pyx
-index d5993cca5a5..1a36c29d3fa 100644
---- a/src/sage/libs/gmp/pylong.pyx
-+++ b/src/sage/libs/gmp/pylong.pyx
-@@ -28,6 +28,8 @@ AUTHORS:
- from cpython.object cimport Py_SIZE
- from cpython.long cimport PyLong_FromLong
- from cpython.longintrepr cimport _PyLong_New, py_long, digit, PyLong_SHIFT
-+from sage.cpython.pycore_long cimport (ob_digit, _PyLong_IsNegative,
-+    _PyLong_DigitCount, _PyLong_SetSignAndDigitCount)
- from .mpz cimport *
- 
- cdef extern from *:
-@@ -60,12 +62,9 @@ cdef mpz_get_pylong_large(mpz_srcptr z):
-     """
-     cdef size_t nbits = mpz_sizeinbase(z, 2)
-     cdef size_t pylong_size = (nbits + PyLong_SHIFT - 1) // PyLong_SHIFT
--    L = _PyLong_New(pylong_size)
--    mpz_export(L.ob_digit, NULL,
--            -1, sizeof(digit), 0, PyLong_nails, z)
--    if mpz_sgn(z) < 0:
--        # Set correct size
--        Py_SET_SIZE(L, -pylong_size)
-+    cdef py_long L = _PyLong_New(pylong_size)
-+    mpz_export(ob_digit(L), NULL, -1, sizeof(digit), 0, PyLong_nails, z)
-+    _PyLong_SetSignAndDigitCount(L, mpz_sgn(z), pylong_size)
-     return L
- 
- 
-@@ -88,16 +87,13 @@ cdef mpz_get_pyintlong(mpz_srcptr z):
-     return mpz_get_pylong_large(z)
- 
- 
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1:
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1:
-     """
-     Convert a Python ``long`` `L` to an ``mpz``.
-     """
--    cdef Py_ssize_t pylong_size = Py_SIZE(L)
--    if pylong_size < 0:
--        pylong_size = -pylong_size
--    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails,
--            (<py_long>L).ob_digit)
--    if Py_SIZE(L) < 0:
-+    cdef Py_ssize_t pylong_size = _PyLong_DigitCount(L)
-+    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails, ob_digit(L))
-+    if _PyLong_IsNegative(L):
-         mpz_neg(z, z)
- 
- 
-diff --git a/src/sage/manifolds/calculus_method.py b/src/sage/manifolds/calculus_method.py
-index f5830c0bc45..303dde6cd13 100644
---- a/src/sage/manifolds/calculus_method.py
-+++ b/src/sage/manifolds/calculus_method.py
-@@ -257,7 +257,7 @@ def simplify(self, expression, method=None):
-             sage: cm.simplify(f)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'
-+            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'...
- 
-         In the present case, one should either transform ``f`` to a SymPy
-         object::
-diff --git a/src/sage/manifolds/differentiable/vectorfield_module.py b/src/sage/manifolds/differentiable/vectorfield_module.py
-index d954b5d4839..af4bfb0ceec 100644
---- a/src/sage/manifolds/differentiable/vectorfield_module.py
-+++ b/src/sage/manifolds/differentiable/vectorfield_module.py
-@@ -885,7 +885,7 @@ def tensor(self, *args, **kwds):
-             sage: XM.tensor(XM).tensor(XM.dual().tensor(XM.dual()))
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'
-+            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'...
- 
-         .. SEEALSO::
- 
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 86aca6e00d8..a5f6716e731 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15303,7 +15303,7 @@ cdef class Matrix(Matrix1):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
--            has no attribute 'conjugate'
-+            has no attribute 'conjugate'...
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/matrix/matrix_cyclo_dense.pyx b/src/sage/matrix/matrix_cyclo_dense.pyx
-index f54f3423ded..a49bb6240e6 100644
---- a/src/sage/matrix/matrix_cyclo_dense.pyx
-+++ b/src/sage/matrix/matrix_cyclo_dense.pyx
-@@ -847,7 +847,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense):
-             sage: A.set_mutable()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'
-+            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'...
-             sage: B = A.__copy__()
-             sage: B[0,0] = 20
-             sage: B[0,0]
-diff --git a/src/sage/matrix/matrix_gfpn_dense.pyx b/src/sage/matrix/matrix_gfpn_dense.pyx
-index 4cccf473de1..8e8e4d7336b 100644
---- a/src/sage/matrix/matrix_gfpn_dense.pyx
-+++ b/src/sage/matrix/matrix_gfpn_dense.pyx
-@@ -159,7 +159,7 @@ cdef class FieldConverter_class:
-             sage: C.field_to_fel('foo')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'to_integer'
-+            AttributeError: 'str' object has no attribute 'to_integer'...
-         """
-         return FfFromInt(x.to_integer())
- 
-diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py
-index 6aab58352be..b5e6f52349b 100644
---- a/src/sage/matrix/matrix_space.py
-+++ b/src/sage/matrix/matrix_space.py
-@@ -1619,7 +1619,7 @@ def __getitem__(self, x):
-             sage: MS[2]
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'
-+            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'...
-         """
-         if isinstance(x, (integer.Integer, int)):
-             return self.list()[x]
-diff --git a/src/sage/matroids/lean_matrix.pyx b/src/sage/matroids/lean_matrix.pyx
-index 54c68e637c0..a137cbf70e5 100644
---- a/src/sage/matroids/lean_matrix.pyx
-+++ b/src/sage/matroids/lean_matrix.pyx
-@@ -1,5 +1,4 @@
- # sage.doctest: optional - sage.rings.finite_rings
--# cython: profile=True
- """
- Lean matrices
- 
-diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx
-index 36f563aa433..318c82f2b64 100644
---- a/src/sage/matroids/linear_matroid.pyx
-+++ b/src/sage/matroids/linear_matroid.pyx
-@@ -1134,7 +1134,7 @@ cdef class LinearMatroid(BasisExchangeMatroid):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.matroids.basis_matroid.BasisMatroid' object
--            has no attribute 'base_ring'
-+            has no attribute 'base_ring'...
-             sage: from sage.matroids.advanced import *
-             sage: M4 = BinaryMatroid(Matrix(M1))
-             sage: M5 = LinearMatroid(reduced_matrix=Matrix(GF(2), [[-1, 0, 1],
-diff --git a/src/sage/misc/dev_tools.py b/src/sage/misc/dev_tools.py
-index e7bf176592c..3ece7db2894 100644
---- a/src/sage/misc/dev_tools.py
-+++ b/src/sage/misc/dev_tools.py
-@@ -171,6 +171,7 @@ def load_submodules(module=None, exclude_pattern=None):
-         load sage.geometry.polyhedron.ppl_lattice_polygon... succeeded
-     """
-     from .package_dir import walk_packages
-+    import importlib.util
- 
-     if module is None:
-         import sage
-@@ -194,8 +195,12 @@ def load_submodules(module=None, exclude_pattern=None):
-         try:
-             sys.stdout.write("load %s..." % module_name)
-             sys.stdout.flush()
--            loader = importer.find_module(module_name)
--            loader.load_module(module_name)
-+            # see
-+            # https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
-+            spec = importer.find_spec(module_name)
-+            module = importlib.util.module_from_spec(spec)
-+            sys.modules[module_name] = module
-+            spec.loader.exec_module(module)
-             sys.stdout.write(" succeeded\n")
-         except (ValueError, AttributeError, TypeError, ImportError):
-             # we might get error because of cython code that has been
-diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py
-index c922b8f6f12..03697f08b7c 100644
---- a/src/sage/misc/functional.py
-+++ b/src/sage/misc/functional.py
-@@ -86,7 +86,7 @@ def base_field(x):
-         sage: R.base_field()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'
-+        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'...
-     """
-     try:
-         return x.base_field()
-diff --git a/src/sage/misc/instancedoc.pyx b/src/sage/misc/instancedoc.pyx
-index d8e1e4ac536..44ee70f64ba 100644
---- a/src/sage/misc/instancedoc.pyx
-+++ b/src/sage/misc/instancedoc.pyx
-@@ -256,7 +256,7 @@ cdef class InstanceDocDescriptor:
-             sage: descr.__delete__(obj)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'X' object has no attribute '__doc__'
-+            AttributeError: 'X' object has no attribute '__doc__'...
- 
-             sage: descr.__delete__([])
-             Traceback (most recent call last):
-diff --git a/src/sage/misc/lazy_attribute.pyx b/src/sage/misc/lazy_attribute.pyx
-index bdbec3b3ba1..1f07870b8ec 100644
---- a/src/sage/misc/lazy_attribute.pyx
-+++ b/src/sage/misc/lazy_attribute.pyx
-@@ -441,37 +441,37 @@ class lazy_attribute(_lazy_attribute):
-             sage: B().unimplemented_A # todo: not implemented
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'super' object has no attribute 'unimplemented_A'
-+            AttributeError: 'super' object has no attribute 'unimplemented_A'...
- 
-     We now make some systematic checks::
- 
-         sage: B().unimplemented_A
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: B().unimplemented_B
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: B().unimplemented_AB
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: B().unimplemented_B_implemented_A
-         1
- 
-         sage: C().unimplemented_A()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: C().unimplemented_B()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: C().unimplemented_AB()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: C().unimplemented_B_implemented_A # todo: not implemented
-         1
-     """
-diff --git a/src/sage/misc/object_multiplexer.py b/src/sage/misc/object_multiplexer.py
-index d4e811ef16e..00fd89d6652 100644
---- a/src/sage/misc/object_multiplexer.py
-+++ b/src/sage/misc/object_multiplexer.py
-@@ -85,7 +85,7 @@ def __getattr__(self, name):
-             sage: m.__bork__
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Multiplex' has no attribute '__bork__'
-+            AttributeError: 'Multiplex' has no attribute '__bork__'...
-         """
-         if name.startswith("__"):
-             raise AttributeError("'Multiplex' has no attribute '%s'" % name)
-diff --git a/src/sage/misc/sage_input.py b/src/sage/misc/sage_input.py
-index 66e78ecccbc..00e8d96ee9e 100644
---- a/src/sage/misc/sage_input.py
-+++ b/src/sage/misc/sage_input.py
-@@ -3461,7 +3461,7 @@ def verify_same(a, b):
-         sage: verify_same(1, 1r)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_same(1r, 1)
-         Traceback (most recent call last):
-         ...
-@@ -3525,7 +3525,7 @@ def verify_si_answer(x, answer, preparse):
-         sage: verify_si_answer(1, '1', False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_si_answer(1, 'ZZ(1)', None)
-     """
-     from sage.misc.sage_eval import sage_eval
-diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py
-index f0545be7d81..811afc48755 100644
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -602,7 +602,7 @@ def visit_Num(self, node):
-             On Python 3 negative numbers are parsed first, for some reason, as
-             a UnaryOp node.
-         """
--        return node.n
-+        return node.value
- 
-     def visit_Str(self, node):
-         r"""
-@@ -624,7 +624,7 @@ def visit_Str(self, node):
-             sage: [vis(s) for s in ['"abstract"', "'syntax'", r'''r"tr\ee"''']]
-             ['abstract', 'syntax', 'tr\\ee']
-         """
--        return node.s
-+        return node.value
- 
-     def visit_List(self, node):
-         """
-diff --git a/src/sage/modules/fp_graded/steenrod/module.py b/src/sage/modules/fp_graded/steenrod/module.py
-index 18460b0e9a1..4acfa6b4002 100755
---- a/src/sage/modules/fp_graded/steenrod/module.py
-+++ b/src/sage/modules/fp_graded/steenrod/module.py
-@@ -70,7 +70,7 @@
-     sage: SteenrodFPModule(ZZ, [0])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'
-+    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'...
- 
- AUTHORS:
- 
-diff --git a/src/sage/monoids/trace_monoid.py b/src/sage/monoids/trace_monoid.py
-index 00baa4d14f8..f8176a1e1f2 100644
---- a/src/sage/monoids/trace_monoid.py
-+++ b/src/sage/monoids/trace_monoid.py
-@@ -40,7 +40,6 @@
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from collections import OrderedDict
- from itertools import repeat, chain, product
- 
- from sage.misc.cachefunc import cached_method
-@@ -633,14 +632,14 @@ def _compute_dependence_stack(self, x):
-             sage: x = b*a*d*a*c*b
-             sage: M._compute_dependence_stack(x)
-             ({a, b, c, d},
--             OrderedDict([(a, [False, False, True, True, False]),
--                          (b, [True, False, False, False, True]),
--                          (c, [True, False, False, False]),
--                          (d, [False, False, True, False])]))
-+             {a: [False, False, True, True, False],
-+              b: [True, False, False, False, True],
-+              c: [True, False, False, False],
-+              d: [False, False, True, False]})
-         """
-         independence = self._independence
-         generators_set = set(e for e, _ in x)
--        stacks = OrderedDict(sorted((g, []) for g in generators_set))
-+        stacks = dict(sorted((g, []) for g in generators_set))
-         for generator, times in reversed(list(x)):
-             stacks[generator].extend(repeat(True, times))
-             for other_gen in generators_set:
-diff --git a/src/sage/parallel/map_reduce.py b/src/sage/parallel/map_reduce.py
-index 11e0673ee91..5441943731d 100644
---- a/src/sage/parallel/map_reduce.py
-+++ b/src/sage/parallel/map_reduce.py
-@@ -1234,7 +1234,7 @@ def finish(self):
-             sage: S.print_communication_statistics()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'RESetMPExample' object has no attribute '_stats'
-+            AttributeError: 'RESetMPExample' object has no attribute '_stats'...
- 
-             sage: S.finish()
- 
-diff --git a/src/sage/plot/colors.py b/src/sage/plot/colors.py
-index 8c0db2b3c34..3281199400b 100644
---- a/src/sage/plot/colors.py
-+++ b/src/sage/plot/colors.py
-@@ -1099,7 +1099,7 @@ def __getattr__(self, name):
-             sage: cols.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ColorsDict' has no attribute or colormap punk
-+            AttributeError: 'ColorsDict' has no attribute or colormap punk...
-         """
-         try:
-             return self[name]
-@@ -1599,7 +1599,7 @@ def __getattr__(self, name):
-             sage: maps.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Colormaps' has no attribute or colormap punk
-+            AttributeError: 'Colormaps' has no attribute or colormap punk...
-             sage: maps['punk']
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/rings/asymptotic/asymptotic_ring.py b/src/sage/rings/asymptotic/asymptotic_ring.py
-index b07319382d3..994490e6616 100644
---- a/src/sage/rings/asymptotic/asymptotic_ring.py
-+++ b/src/sage/rings/asymptotic/asymptotic_ring.py
-@@ -1091,7 +1091,7 @@ def monomial_coefficient(self, monomial):
-             sage: O(n).monomial_coefficient(n)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'
-+            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'...
- 
-         The ``monomial`` must be exact::
- 
-diff --git a/src/sage/rings/asymptotic/growth_group.py b/src/sage/rings/asymptotic/growth_group.py
-index 27c14592bca..5be12537d62 100644
---- a/src/sage/rings/asymptotic/growth_group.py
-+++ b/src/sage/rings/asymptotic/growth_group.py
-@@ -1572,7 +1572,7 @@ def variable_names(self):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'GenericGrowthGroup_with_category.element_class' object
--            has no attribute 'is_one'
-+            has no attribute 'is_one'...
-         """
-         if self.is_one():
-             return tuple()
-diff --git a/src/sage/rings/ideal.py b/src/sage/rings/ideal.py
-index d36d9406f32..01c9fa3bf2d 100644
---- a/src/sage/rings/ideal.py
-+++ b/src/sage/rings/ideal.py
-@@ -1553,7 +1553,7 @@ def gcd(self, other):
-             sage: J.gcd(I)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Ideal_generic' object has no attribute 'gcd'
-+            AttributeError: 'Ideal_generic' object has no attribute 'gcd'...
- 
-         Note::
- 
-diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
-index 7fe89197011..8832d27e8ea 100644
---- a/src/sage/rings/number_field/number_field.py
-+++ b/src/sage/rings/number_field/number_field.py
-@@ -3823,7 +3823,7 @@ def primes_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
-         """
-         if degree is not None:
-             degree = ZZ(degree)
-@@ -3917,7 +3917,7 @@ def prime_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
- 
-         """
-         ids = self.primes_above(x, degree)
-@@ -5926,7 +5926,7 @@ def factor(self, n):
-             sage: L.factor(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'...
- 
-         AUTHORS:
- 
-@@ -12698,7 +12698,7 @@ def is_real_place(v):
-         sage: is_real_place(v_fin)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'
-+        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'...
- 
-     """
-     RR = sage.rings.real_mpfr.RealField(53)
-diff --git a/src/sage/rings/padics/generic_nodes.py b/src/sage/rings/padics/generic_nodes.py
-index 7047020edec..b6b514d4005 100644
---- a/src/sage/rings/padics/generic_nodes.py
-+++ b/src/sage/rings/padics/generic_nodes.py
-@@ -740,7 +740,7 @@ def _get_element_class(self, name=None):
-             sage: R._get_element_class("foobar")
-             Traceback (most recent call last):
-             ...
--            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'
-+            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'...
-         """
-         if name is None:
-             return self.Element
-diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx
-index c5a1129aecf..a5b7f937cfe 100644
---- a/src/sage/rings/polynomial/polynomial_element.pyx
-+++ b/src/sage/rings/polynomial/polynomial_element.pyx
-@@ -10793,7 +10793,7 @@ cdef class Polynomial(CommutativePolynomial):
-             sage: (y**2 + x).nth_root(2)
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... has no attribute 'nth_root'
-+            AttributeError: ... has no attribute 'nth_root'...
- 
-         TESTS::
- 
-@@ -11831,7 +11831,7 @@ cdef class Polynomial_generic_dense(Polynomial):
-             sage: int(1) // x  # check that this doesn't segfault
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'int' has no attribute 'base_ring'
-+            AttributeError: type object 'int' has no attribute 'base_ring'...
-         """
-         if have_same_parent(self, right):
-             return (<Polynomial_generic_dense>self)._floordiv_(<Polynomial_generic_dense>right)
-diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-index e372be888ee..aca4f08420f 100644
---- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
-+++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-@@ -2362,7 +2362,7 @@ def field_extension(self, names):
-             sage: F, g, h = S.field_extension('b')                                      # needs sage.rings.finite_rings
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'
-+            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'...
- 
-         Over a finite field, the corresponding field extension is not a
-         number field::
-diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx
-index 5273891a5b0..a6e999b8805 100644
---- a/src/sage/rings/ring.pyx
-+++ b/src/sage/rings/ring.pyx
-@@ -1734,7 +1734,7 @@ cdef class IntegralDomain(CommutativeRing):
-             sage: Z5.is_integrally_closed()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'
-+            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'...
-         """
-         raise NotImplementedError
- 
-diff --git a/src/sage/sat/solvers/satsolver.pyx b/src/sage/sat/solvers/satsolver.pyx
-index c2f41b18f55..1c4ac400cb6 100644
---- a/src/sage/sat/solvers/satsolver.pyx
-+++ b/src/sage/sat/solvers/satsolver.pyx
-@@ -375,10 +375,10 @@ def SAT(solver=None, *args, **kwds):
-         DIMACS Solver: 'kissat -q {input}'
-     """
-     if solver is None:
--        import pkgutil
--        if pkgutil.find_loader('pycryptosat') is not None:
-+        from importlib.util import find_spec
-+        if find_spec('pycryptosat') is not None:
-             solver = "cryptominisat"
--        elif pkgutil.find_loader('pycosat') is not None:
-+        elif find_spec('pycosat') is not None:
-             solver = "picosat"
-         else:
-             solver = "LP"
-diff --git a/src/sage/schemes/toric/morphism.py b/src/sage/schemes/toric/morphism.py
-index 1c8944b6dfc..5d64d632f97 100644
---- a/src/sage/schemes/toric/morphism.py
-+++ b/src/sage/schemes/toric/morphism.py
-@@ -246,7 +246,7 @@
-     Traceback (most recent call last):
-     ...
-     AttributeError: 'SchemeMorphism_fan_toric_variety' object
--    has no attribute 'fiber_generic'
-+    has no attribute 'fiber_generic'...
- 
- Let's use factorization mentioned above::
- 
-diff --git a/src/sage/sets/disjoint_union_enumerated_sets.py b/src/sage/sets/disjoint_union_enumerated_sets.py
-index 3dea567a779..5c5e08612f2 100644
---- a/src/sage/sets/disjoint_union_enumerated_sets.py
-+++ b/src/sage/sets/disjoint_union_enumerated_sets.py
-@@ -597,7 +597,7 @@ def Element(self):
-             sage: U.Element
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'
-+            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'...
-         """
-         if not self._facade:
-             return ElementWrapper
-diff --git a/src/sage/sets/set.py b/src/sage/sets/set.py
-index a1789c61300..112d3d8dc3b 100644
---- a/src/sage/sets/set.py
-+++ b/src/sage/sets/set.py
-@@ -163,7 +163,7 @@ def Set(X=None, category=None):
-         sage: sorted(B.list(), key=repr)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'Set_object_with_category' object has no attribute 'list'
-+        AttributeError: 'Set_object_with_category' object has no attribute 'list'...
-         sage: type(B)
-         <class 'sage.sets.set.Set_object_with_category'>
- 
-diff --git a/src/sage/structure/category_object.pyx b/src/sage/structure/category_object.pyx
-index b6a7eaecb5b..c06933494dc 100644
---- a/src/sage/structure/category_object.pyx
-+++ b/src/sage/structure/category_object.pyx
-@@ -836,7 +836,7 @@ cdef class CategoryObject(SageObject):
-             sage: Sets().example().sadfasdf
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'
-+            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'...
-         """
-         return self.getattr_from_category(name)
- 
-diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx
-index caae7e40ffc..543506e9a74 100644
---- a/src/sage/structure/element.pyx
-+++ b/src/sage/structure/element.pyx
-@@ -219,7 +219,7 @@ the parents::
-     sage: x._add_(x)
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-     sage: x + x
-     Traceback (most recent call last):
-     ...
-@@ -478,13 +478,13 @@ cdef class Element(SageObject):
-             sage: 1.blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'...
-             sage: Semigroups().example().an_element().is_idempotent
-             <bound method LeftZeroSemigroup.Element.is_idempotent of 42>
-             sage: Semigroups().example().an_element().blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'
-+            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'...
-         """
-         return self.getattr_from_category(name)
- 
-@@ -1269,7 +1269,7 @@ cdef class Element(SageObject):
-             sage: e._add_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-         """
-         try:
-             python_op = (<object>self)._add_
-@@ -1381,7 +1381,7 @@ cdef class Element(SageObject):
-             sage: e._sub_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'...
-         """
-         try:
-             python_op = (<object>self)._sub_
-@@ -1435,7 +1435,7 @@ cdef class Element(SageObject):
-             sage: e._neg_()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'...
-         """
-         try:
-             python_op = (<object>self)._neg_
-@@ -1549,7 +1549,7 @@ cdef class Element(SageObject):
-             sage: e._mul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'...
-         """
-         try:
-             python_op = (<object>self)._mul_
-@@ -1662,7 +1662,7 @@ cdef class Element(SageObject):
-             sage: e._matmul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'...
-         """
-         try:
-             python_op = (<object>self)._matmul_
-@@ -1765,7 +1765,7 @@ cdef class Element(SageObject):
-             sage: e._div_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'...
-         """
-         try:
-             python_op = (<object>self)._div_
-@@ -1865,7 +1865,7 @@ cdef class Element(SageObject):
-             sage: e._floordiv_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'...
-         """
-         try:
-             python_op = (<object>self)._floordiv_
-@@ -1965,7 +1965,7 @@ cdef class Element(SageObject):
-             sage: e._mod_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'...
-         """
-         try:
-             python_op = (<object>self)._mod_
-@@ -2092,7 +2092,7 @@ cdef class Element(SageObject):
-             sage: e._pow_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'...
-         """
-         try:
-             python_op = (<object>self)._pow_
-@@ -2122,7 +2122,7 @@ cdef class Element(SageObject):
-             sage: e._pow_int(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'...
-         """
-         try:
-             python_op = (<object>self)._pow_int
-@@ -2856,7 +2856,7 @@ cdef class RingElement(ModuleElement):
-             sage: m.is_nilpotent()                                                      # needs sage.modules
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... object has no attribute 'is_nilpotent'
-+            AttributeError: '...' object has no attribute 'is_nilpotent'...
-         """
-         if self.is_unit():
-             return False
-@@ -4671,7 +4671,7 @@ def coerce_binop(method):
-         sage: x.test_add(CC(2))
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'
-+        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'...
- 
-     TESTS:
- 
-diff --git a/src/sage/structure/sequence.py b/src/sage/structure/sequence.py
-index 0c700c1fb81..c3972532ac3 100644
---- a/src/sage/structure/sequence.py
-+++ b/src/sage/structure/sequence.py
-@@ -854,7 +854,7 @@ def __getattr__(self, name):
-             sage: S.universe()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'...
-             sage: S._Sequence__universe = 'foobar'
-             sage: S.universe()
-             'foobar'
-@@ -867,7 +867,7 @@ def __getattr__(self, name):
-             sage: hash(S)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'...
-             sage: S._Sequence__hash = int(34)
-             sage: hash(S)
-             34
-diff --git a/src/sage/symbolic/assumptions.py b/src/sage/symbolic/assumptions.py
-index 7dcb15f0d85..15f6fa07ce6 100644
---- a/src/sage/symbolic/assumptions.py
-+++ b/src/sage/symbolic/assumptions.py
-@@ -636,7 +636,7 @@ def assume(*args):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no
--        attribute 'assume'
-+        attribute 'assume'...
- 
-     Ensure that we can combine the two types of assumptions, as documented::
- 
-diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx
-index 0f251ac4e5c..66f624141b3 100644
---- a/src/sage/symbolic/expression.pyx
-+++ b/src/sage/symbolic/expression.pyx
-@@ -13712,7 +13712,7 @@ cdef get_dynamic_class_for_function(unsigned serial):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.symbolic.expression.Expression' object has no
--        attribute 'argp1'
-+        attribute 'argp1'...
-         sage: t = (e + 1).op[0]; t
-         tfunc(x)
-         sage: t
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index c4152e092e3..4bcf45e8793 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -67,6 +67,7 @@
- #include "archive.h"
- #include "tostring.h"
- #include "utils.h"
-+#include "../../cpython/pycore_long.h"
- 
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wdeprecated-register"
-@@ -706,18 +707,12 @@ static long _mpq_pythonhash(mpq_t the_rat)
- // Initialize an mpz_t from a Python long integer
- static void _mpz_set_pylong(mpz_t z, PyLongObject* l)
- {
--    Py_ssize_t pylong_size = Py_SIZE(l);
--    int sign = 1;
--
--    if (pylong_size < 0) {
--        pylong_size = -pylong_size;
--        sign = -1;
--    }
-+    Py_ssize_t pylong_size = _PyLong_DigitCount(l);
- 
-     mpz_import(z, pylong_size, -1, sizeof(digit), 0,
--               8*sizeof(digit) - PyLong_SHIFT, l->ob_digit);
-+               8*sizeof(digit) - PyLong_SHIFT, ob_digit(l));
- 
--    if (sign < 0)
-+    if (_PyLong_IsNegative(l))
-         mpz_neg(z, z);
- }
- 
-diff --git a/src/sage/symbolic/pynac_impl.pxi b/src/sage/symbolic/pynac_impl.pxi
-index 68c31dcfde7..7fd7c3b314b 100644
---- a/src/sage/symbolic/pynac_impl.pxi
-+++ b/src/sage/symbolic/pynac_impl.pxi
-@@ -619,7 +619,7 @@ def tolerant_is_symbol(a):
-         sage: None.is_symbol()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute 'is_symbol'
-+        AttributeError: 'NoneType' object has no attribute 'is_symbol'...
-     """
-     try:
-         return a.is_symbol()
diff --git a/srcpkgs/sagemath/patches/36769-fix_jmol_detect.patch b/srcpkgs/sagemath/patches/36769-fix_jmol_detect.patch
new file mode 100644
index 0000000000000..c7c983fe50c0d
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36769-fix_jmol_detect.patch
@@ -0,0 +1,92 @@
+diff --git a/src/sage/interfaces/jmoldata.py b/src/sage/interfaces/jmoldata.py
+index a68e53e2d85..55c07255b74 100644
+--- a/src/sage/interfaces/jmoldata.py
++++ b/src/sage/interfaces/jmoldata.py
+@@ -71,6 +71,47 @@ def is_jvm_available(self):
+         java_version_number = int(re.sub(r'.*version "(0\.|1\.)?(\d*)[\s\S]*', r'\2', version, flags=re.S))
+         return java_version_number >= 7
+ 
++    def jmolpath(self):
++        """
++        Return the path to the jar file.
++
++        EXAMPLES::
++
++            sage: from sage.interfaces.jmoldata import JmolData
++            sage: JData = JmolData()
++            sage: JData.jmolpath()
++            '.../JmolData.jar'
++
++        """
++        jmolpath = os.path.join(JMOL_DIR, "JmolData.jar")
++
++        if sys.platform == 'cygwin':
++            import cygwin
++            jmolpath = cygwin.cygpath(jmolpath, 'w')
++
++        return jmolpath
++
++    def is_jmol_available(self):
++        """
++        Returns True if jmol is available and False if not.
++
++        EXAMPLES:
++
++        Check that it returns a boolean::
++
++            sage: from sage.interfaces.jmoldata import JmolData
++            sage: JData = JmolData()
++            sage: type(JData.is_jmol_available())
++            <... 'bool'>
++        """
++        if not os.path.isfile(self.jmolpath()):
++            return False
++
++        if not self.is_jvm_available():
++            return False
++
++        return True
++
+     def export_image(self,
+         targetfile,
+         datafile, #name (path) of data file Jmol can read or script file telling it what to read or load
+@@ -154,12 +195,11 @@ def export_image(self,
+             sage: archive.close()
+         """
+         # Set up paths, file names and scripts
+-        jmolpath = os.path.join(JMOL_DIR, "JmolData.jar")
++        jmolpath = self.jmolpath()
+         target_native = targetfile
+ 
+         if sys.platform == 'cygwin':
+             import cygwin
+-            jmolpath = cygwin.cygpath(jmolpath, 'w')
+             target_native = cygwin.cygpath(target_native, 'w')
+             if datafile_cmd != 'script':
+                 datafile = cygwin.cygpath(datafile, 'w')
+diff --git a/src/sage/plot/plot3d/base.pyx b/src/sage/plot/plot3d/base.pyx
+index 253f152130c..7588cde2e27 100644
+--- a/src/sage/plot/plot3d/base.pyx
++++ b/src/sage/plot/plot3d/base.pyx
+@@ -278,7 +278,7 @@ cdef class Graphics3d(SageObject):
+         T.export_jmol(scene_zip, **opts)
+         from sage.interfaces.jmoldata import JmolData
+         jdata = JmolData()
+-        if not jdata.is_jvm_available():
++        if not jdata.is_jmol_available():
+             # We can only use JMol to generate preview if a jvm is installed
+             from sage.repl.rich_output.output_graphics import OutputImagePng
+             tachyon = self._rich_repr_tachyon(OutputImagePng, **opts)
+diff --git a/src/sage/repl/rich_output/backend_ipython.py b/src/sage/repl/rich_output/backend_ipython.py
+index 69e63b76d60..10ccdc0c2c8 100644
+--- a/src/sage/repl/rich_output/backend_ipython.py
++++ b/src/sage/repl/rich_output/backend_ipython.py
+@@ -369,7 +369,7 @@ def launch_jmol(self, output_jmol, plain_text):
+         from sage.doctest import DOCTEST_MODE
+         from sage.interfaces.jmoldata import JmolData
+         jdata = JmolData()
+-        if not jdata.is_jvm_available() and not DOCTEST_MODE:
++        if not jdata.is_jmol_available() and not DOCTEST_MODE:
+             raise RuntimeError('jmol cannot run, no suitable java version found')
+         launch_script = output_jmol.launch_script_filename()
+         jmol_cmd = 'jmol'
diff --git a/srcpkgs/sagemath/patches/get_patches b/srcpkgs/sagemath/patches/get_patches
index 95a6963432948..a552b402727d3 100755
--- a/srcpkgs/sagemath/patches/get_patches
+++ b/srcpkgs/sagemath/patches/get_patches
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-version=10.1
+version=10.2
 
 URL_BASE_PR="https://github.com/sagemath/sage/pull/"
 URL_BASE_COMPARE="https://github.com/sagemath/sage/compare/${version}..."
@@ -20,24 +20,6 @@ get_pr() {
 # run from patches dir
 cd $(dirname "$0")
 
-# merged in 10.2.beta0
-#get_pr  36018   "singular 4.3.2p4" # included in #35934
-get_pr  36046   "fix memory leak"
-
-# merged in 10.2.beta1
-get_pr  35934   "singular 4.3.2p7"
-
-# merged in 10.2.beta2
-get_pr  36006   "gmp 6.3.0"
-
-# merged in 10.2.beta3
-get_pr  36235   "ecl 23.9.9"
-
-# merged in 10.2.beta4
-get_pr  36279   "matplotlib 3.8.0"
-
-# positive review
-#get_pr  36403   "python 3.12" # included in #36407
-
 # needs review
-get_pr  36407   "python 3.12"
+get_pr  35848   "flintlib 3.0"
+get_pr  36769   "fix jmol detect"
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index a80d8b7187ece..5d5bdccd70a25 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,14 +1,14 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=10.1
-revision=4
+version=10.2
+revision=1
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
 _bindir=/usr/lib/sagemath/$version/bin
 make_install_args="--install-scripts=$_bindir"
-hostmakedepends="m4 pkg-config python3-Cython0.29 python3-Jinja2
+hostmakedepends="m4 pkg-config python3-Cython python3-Jinja2
  python3-pkgconfig python3-setuptools"
-makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
+makedepends="boost-devel brial-devel cliquer-devel ecl eclib-devel
  ecm-devel fflas-ffpack flintlib-devel gap-devel gd-devel giac-devel glpk-devel
  gsl-devel iml-devel lcalc-devel libbraiding-devel libhomfly-devel libmpc-devel
  libpng-devel linbox-devel m4ri-devel m4rie-devel mpfi-devel
@@ -18,7 +18,7 @@ makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
 depends="eclib-devel fflas-ffpack flintlib-devel gcc-fortran gd-devel
  gfan giac gsl-devel gzip libpng-devel linbox-devel m4ri-devel maxima-ecl
  mpfr-devel nauty ntl-devel palp pari-devel pari-elldata-small pari-galdata
- pari-galpol-small pari-seadata-small pkg-config python3-Cython0.29 python3-cypari2
+ pari-galpol-small pari-seadata-small pkg-config python3-Cython python3-cypari2
  python3-cysignals python3-devel python3-fpylll python3-ipython python3-lrcalc
  python3-ipython_ipykernel python3-jupyter_ipywidgets python3-matplotlib
  python3-memory_allocator python3-networkx python3-pip python3-pkgconfig
@@ -33,8 +33,8 @@ license="GPL-2.0-or-later"
 homepage="https://www.sagemath.org/"
 changelog="https://github.com/sagemath/sage/releases"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=a658612b1b2376ddaf207cc8ed0ef458d4c2880c16e19139bedbe8baa42ad62f
-nocross="due to ntl (flintlib), fflas-ffpack, givaro, linbox, cysignals, sympow, maxima"
+checksum=e7125f13495e1068edab73735aca7f9b2c655688096e9d109e628c023e76411f
+nocross="due to ntl (eclib), fflas-ffpack, givaro, linbox, sympow, maxima"
 
 post_patch() {
 	# git tree needs bootstrapping
diff --git a/srcpkgs/sagemath/update b/srcpkgs/sagemath/update
index 68be3c5752d06..4e62503e2f8f4 100644
--- a/srcpkgs/sagemath/update
+++ b/srcpkgs/sagemath/update
@@ -1,2 +1,3 @@
 pkgname="sage"
-site="https://mirrors.mit.edu/sage/src/index.html"
+site="https://mirrors.mit.edu/sage/src/
+https://mirrors.mit.edu/sage/devel/"

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

* Re: [PR PATCH] [Updated] sagemath: update to 10.2, flintlib: update to 3.0.1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (23 preceding siblings ...)
  2023-12-03 14:20 ` tornaria
@ 2023-12-03 16:18 ` tornaria
  2023-12-03 16:21 ` tornaria
                   ` (3 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: tornaria @ 2023-12-03 16:18 UTC (permalink / raw)
  To: ml

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

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

https://github.com/tornaria/void-packages flintlib
https://github.com/void-linux/void-packages/pull/46832

sagemath: update to 10.2, flintlib: update to 3.0.1
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **YES**

This is a major update for both sagemath and flintlib.

Sagemath moves to cython 3.

A couple of packages need rebuild or update:

 - eclib: rbuild for flintlib-3.0.1
 - singular: update to 4.3.2p10
 - python3-pplpy: rebuild using cython 3
 - python3-networkx: update to 3.2.1.


<!--
#### 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/46832.patch is attached

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

From 4b4bc7718a0974b6657328d3344c99b1f0168224 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 11 Sep 2023 20:11:20 -0300
Subject: [PATCH 1/6] flintlib: update to 3.0.1.

---
 common/shlibs                                 |  3 +--
 srcpkgs/arb                                   |  1 +
 srcpkgs/arb-devel                             |  2 +-
 srcpkgs/arb/template                          | 24 -------------------
 .../patches/fix-test-t-sdiv_qrnnd.patch       | 23 ------------------
 srcpkgs/flintlib/template                     | 21 ++++++++++++----
 6 files changed, 20 insertions(+), 54 deletions(-)
 create mode 120000 srcpkgs/arb
 delete mode 100644 srcpkgs/arb/template
 delete mode 100644 srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch

diff --git a/common/shlibs b/common/shlibs
index 1b25a12956eeb..ca04472aec634 100644
--- a/common/shlibs
+++ b/common/shlibs
@@ -3971,8 +3971,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.17 flintlib-2.9.0_1
-libarb.so.2 arb-2.20.0_1
+libflint.so.18 flintlib-3.0.0_1
 libec.so.10 eclib-20220621_1
 libsymmetrica.so.2 symmetrica-3.0.1_1
 libLfunction.so.1 lcalc-2.0.4_1
diff --git a/srcpkgs/arb b/srcpkgs/arb
new file mode 120000
index 0000000000000..7c2633183069f
--- /dev/null
+++ b/srcpkgs/arb
@@ -0,0 +1 @@
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb-devel b/srcpkgs/arb-devel
index 456b9f00a86cd..7c2633183069f 120000
--- a/srcpkgs/arb-devel
+++ b/srcpkgs/arb-devel
@@ -1 +1 @@
-arb
\ No newline at end of file
+flintlib
\ No newline at end of file
diff --git a/srcpkgs/arb/template b/srcpkgs/arb/template
deleted file mode 100644
index 84a62c7ffdba3..0000000000000
--- a/srcpkgs/arb/template
+++ /dev/null
@@ -1,24 +0,0 @@
-# Template file for 'arb'
-pkgname=arb
-version=2.23.0
-revision=1
-build_style=configure
-configure_args="--prefix=/usr --with-gmp=/usr --with-mpfr=/usr --with-flint=/usr"
-makedepends="flintlib-devel"
-short_desc="C library for arbitrary-precision interval arithmetic"
-maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
-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=977d41bde46f5442511d5165c705cec32c03e852c84d7d1836135d412ce702bb
-
-arb-devel_package() {
-	depends="${sourcepkg}>=${version}_${revision} ${makedepends}"
-	short_desc+=" - development files"
-	pkg_install() {
-		vmove usr/include
-		vmove "usr/lib/*.a"
-		vmove "usr/lib/*.so"
-	}
-}
diff --git a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch b/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
deleted file mode 100644
index cfa109792892c..0000000000000
--- a/srcpkgs/flintlib/patches/fix-test-t-sdiv_qrnnd.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-From fb8ddbcc06afa2a8f25637032fbb8211f6c6c122 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Albin=20Ahlb=C3=A4ck?= <albin.ahlback@gmail.com>
-Date: Fri, 20 May 2022 14:16:38 +0200
-Subject: [PATCH] Fix bug in test code for GCC 12
-
----
- test/t-sdiv_qrnnd.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/test/t-sdiv_qrnnd.c b/test/t-sdiv_qrnnd.c
-index 2e9822e848..2676903826 100644
---- a/test/t-sdiv_qrnnd.c
-+++ b/test/t-sdiv_qrnnd.c
-@@ -33,7 +33,7 @@ int main(void)
-         {
-             d = n_randtest_not_zero(state);
-             nh = n_randtest(state);
--        } while ((FLINT_ABS(nh) >= FLINT_ABS(d)/2) || (nh == WORD_MIN));
-+        } while ((nh == WORD_MIN) || (FLINT_ABS(nh) >= FLINT_ABS(d)/2));
- 
-         nl = n_randtest(state);
- 
-
diff --git a/srcpkgs/flintlib/template b/srcpkgs/flintlib/template
index f7442c8052aaa..254d18c42f5b3 100644
--- a/srcpkgs/flintlib/template
+++ b/srcpkgs/flintlib/template
@@ -1,10 +1,10 @@
 # Template file for 'flintlib'
 pkgname=flintlib
-version=2.9.0
+version=3.0.1
 revision=1
-build_style=configure
+build_style=gnu-configure
 configure_args="--prefix=/usr $(vopt_with ntl)
- $(vopt_if openblas --with-blas=${XBPS_CROSS_BASE}/usr/include/openblas)"
+ $(vopt_if openblas --with-blas-include=${XBPS_CROSS_BASE}/usr/include/openblas)"
 makedepends="mpfr-devel $(vopt_if ntl ntl-devel)
  $(vopt_if openblas openblas-devel)"
 short_desc="Fast Library for Number Theory"
@@ -13,7 +13,7 @@ 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=2fc090d51033c93208e6c10d406397a53c983ae5343b958eb25f72a57a4ce76a
+checksum=7b311a00503a863881eb8177dbeb84322f29399f3d7d72f3b1a4c9ba1d5794b4
 
 build_options="ntl openblas"
 desc_option_ntl="enable NTL support"
@@ -33,7 +33,20 @@ flintlib-devel_package() {
 	short_desc+=" - development files"
 	pkg_install() {
 		vmove usr/include
+		vmove usr/lib/pkgconfig
 		vmove "usr/lib/*.a"
 		vmove "usr/lib/*.so"
 	}
 }
+
+arb_package() {
+	depends="${sourcepkg}>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}
+
+arb-devel_package() {
+	depends="${sourcepkg}-devel>=${version}_${revision}"
+	short_desc+=" - transitional dummy package"
+	build_style=meta
+}

From f22e5c7930f0c652d238112f86624f27aee47d6e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:08:05 -0300
Subject: [PATCH 2/6] eclib: rebuild for flintlib-3.0.1

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

diff --git a/srcpkgs/eclib/template b/srcpkgs/eclib/template
index 1d4ad58f21b7b..12165ca788dd5 100644
--- a/srcpkgs/eclib/template
+++ b/srcpkgs/eclib/template
@@ -1,7 +1,7 @@
 # Template file for 'eclib'
 pkgname=eclib
 version=20230424
-revision=3
+revision=4
 build_style=gnu-configure
 configure_args="--with-flint --with-boost"
 makedepends="pari-devel ntl-devel flintlib-devel boost-devel"

From 8dd09094107f3ddb71b2e102eba132017aefcc81 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:13:15 -0300
Subject: [PATCH 3/6] singular: update to 4.3.2p10.

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

diff --git a/srcpkgs/singular/template b/srcpkgs/singular/template
index 036e19d470354..beb0e6d30118e 100644
--- a/srcpkgs/singular/template
+++ b/srcpkgs/singular/template
@@ -1,6 +1,6 @@
 # Template file for 'singular'
 pkgname=singular
-version=4.3.2p7
+version=4.3.2p10
 revision=1
 _majver=${version%p*}
 build_style=gnu-configure
@@ -20,7 +20,7 @@ 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/${_majver//./-}/singular-${version}.tar.gz"
-checksum=aad23c30066b7fbc011138a98d60532565d76a847eec6bf2938410d93b272ca3
+checksum=28c2c9fcfee954e00dfa56eb1a7d418d5b1de67c4398d25a0f2b8f73e71552a8
 
 if [ -z "$CROSS_BUILD" ]; then
 	makedepends+=" ntl-devel"

From e7a1d725324c3bbb57006038708ecece95ec3776 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 19 Jul 2023 21:04:33 -0300
Subject: [PATCH 4/6] python3-pplpy: use cython 3.

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

diff --git a/srcpkgs/python3-pplpy/template b/srcpkgs/python3-pplpy/template
index 4a9c987b2a859..d3b9aebdf2237 100644
--- a/srcpkgs/python3-pplpy/template
+++ b/srcpkgs/python3-pplpy/template
@@ -1,9 +1,9 @@
 # Template file for 'python3-pplpy'
 pkgname=python3-pplpy
 version=0.8.9
-revision=1
+revision=2
 build_style=python3-pep517
-hostmakedepends="python3-setuptools python3-wheel python3-Cython0.29
+hostmakedepends="python3-setuptools python3-wheel python3-Cython
  python3-cysignals python3-gmpy2"
 makedepends="python3-devel gmp-devel gmpxx-devel ppl-devel mpfr-devel
  libmpc-devel pari-devel"

From 9bb81d7bcf3e6c87454d16e919cad5845e213a2d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Thu, 19 Oct 2023 08:52:15 -0300
Subject: [PATCH 5/6] python3-networkx: update to 3.2.1.

---
 srcpkgs/python3-networkx/template | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/python3-networkx/template b/srcpkgs/python3-networkx/template
index 186bf64f7bff9..29283d9e5a032 100644
--- a/srcpkgs/python3-networkx/template
+++ b/srcpkgs/python3-networkx/template
@@ -1,11 +1,11 @@
 # Template file for 'python3-networkx'
 pkgname=python3-networkx
-version=3.1
-revision=2
-build_style=python3-module
+version=3.2.1
+revision=1
+build_style=python3-pep517
 # failing in i686
 make_check_args="--deselect networkx/algorithms/approximation/tests/test_traveling_salesman.py::test_asadpour_tsp"
-hostmakedepends="python3-setuptools"
+hostmakedepends="python3-setuptools python3-wheel"
 depends="python3"
 checkdepends="python3-numpy python3-scipy python3-matplotlib python3-pandas
  python3-lxml python3-sympy python3-pytest-xdist"
@@ -15,7 +15,7 @@ license="BSD-3-Clause"
 homepage="https://networkx.org"
 changelog="https://github.com/networkx/networkx/raw/main/doc/release/release_${version}.rst"
 distfiles="${PYPI_SITE}/n/networkx/networkx-${version}.tar.gz"
-checksum=de346335408f84de0eada6ff9fafafff9bcda11f0a0dfaa931133debb146ab61
+checksum=9f1bb5cf3409bf324e0a722c20bdb4c20ee39bf1c30ce8ae499c8502b0b5e0c6
 
 post_install() {
 	vlicense LICENSE.txt

From 05e209f1d6abbd01ae1635c4daa8d64a59f23135 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Wed, 13 Sep 2023 19:50:44 -0300
Subject: [PATCH 6/6] sagemath: update to 10.2.

---
 .../sagemath/patches/35848-flintlib_3.0.patch | 1867 +++++++++++++++++
 .../patches/35934-singular_4.3.2p7.patch      |  221 --
 .../sagemath/patches/36006-gmp_6.3.0.patch    |   38 -
 .../patches/36046-fix_memory_leak.patch       |  740 -------
 .../sagemath/patches/36235-ecl_23.9.9.patch   |   39 -
 .../patches/36279-matplotlib_3.8.0.patch      |   24 -
 srcpkgs/sagemath/patches/36403-00pre.patch    |   29 -
 .../sagemath/patches/36407-python_3.12.patch  | 1744 ---------------
 .../patches/36769-fix_jmol_detect.patch       |   92 +
 srcpkgs/sagemath/patches/get_patches          |   24 +-
 srcpkgs/sagemath/template                     |   14 +-
 srcpkgs/sagemath/update                       |    6 +-
 12 files changed, 1974 insertions(+), 2864 deletions(-)
 create mode 100644 srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
 delete mode 100644 srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
 delete mode 100644 srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
 delete mode 100644 srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
 delete mode 100644 srcpkgs/sagemath/patches/36403-00pre.patch
 delete mode 100644 srcpkgs/sagemath/patches/36407-python_3.12.patch
 create mode 100644 srcpkgs/sagemath/patches/36769-fix_jmol_detect.patch

diff --git a/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
new file mode 100644
index 0000000000000..2cad28134f6e6
--- /dev/null
+++ b/srcpkgs/sagemath/patches/35848-flintlib_3.0.patch
@@ -0,0 +1,1867 @@
+diff --git a/build/pkgs/antic/SPKG.rst b/build/pkgs/antic/SPKG.rst
+deleted file mode 100644
+index d6c32377957..00000000000
+--- a/build/pkgs/antic/SPKG.rst
++++ /dev/null
+@@ -1,18 +0,0 @@
+-antic: Algebraic Number Theory In C
+-===================================
+-
+-Description
+------------
+-
+-Algebraic Number Theory In C
+-
+-License
+--------
+-
+-LGPL 2.1
+-
+-Upstream Contact
+-----------------
+-
+-https://github.com/wbhart/antic
+-
+diff --git a/build/pkgs/antic/checksums.ini b/build/pkgs/antic/checksums.ini
+deleted file mode 100644
+index fc8711ecd13..00000000000
+--- a/build/pkgs/antic/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=antic-VERSION.tar.gz
+-sha1=940d8ea2c3512b9d49ee3101cf043f777764bd8f
+-md5=4e896420dd6344b53b307871efb2cbb4
+-cksum=1938565125
+-upstream_url=https://github.com/wbhart/antic/archive/refs/tags/vVERSION.tar.gz
+diff --git a/build/pkgs/antic/dependencies b/build/pkgs/antic/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/antic/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/antic/distros/arch.txt b/build/pkgs/antic/distros/arch.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/conda.txt b/build/pkgs/antic/distros/conda.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/distros/debian.txt b/build/pkgs/antic/distros/debian.txt
+deleted file mode 100644
+index 8fdcd3e5721..00000000000
+--- a/build/pkgs/antic/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libantic-dev
+diff --git a/build/pkgs/antic/distros/fedora.txt b/build/pkgs/antic/distros/fedora.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/freebsd.txt b/build/pkgs/antic/distros/freebsd.txt
+deleted file mode 100644
+index 116ff3a26f3..00000000000
+--- a/build/pkgs/antic/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/antic
+diff --git a/build/pkgs/antic/distros/opensuse.txt b/build/pkgs/antic/distros/opensuse.txt
+deleted file mode 100644
+index 1b16da9f64b..00000000000
+--- a/build/pkgs/antic/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic-devel
+diff --git a/build/pkgs/antic/distros/repology.txt b/build/pkgs/antic/distros/repology.txt
+deleted file mode 100644
+index 83c7cab14e4..00000000000
+--- a/build/pkgs/antic/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-antic
+diff --git a/build/pkgs/antic/package-version.txt b/build/pkgs/antic/package-version.txt
+deleted file mode 100644
+index 3a4036fb450..00000000000
+--- a/build/pkgs/antic/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-0.2.5
+diff --git a/build/pkgs/antic/spkg-install.in b/build/pkgs/antic/spkg-install.in
+deleted file mode 100644
+index c57fa884a20..00000000000
+--- a/build/pkgs/antic/spkg-install.in
++++ /dev/null
+@@ -1,19 +0,0 @@
+-cd src
+-
+-# Copied from build/pkgs/flint/spkg-install.in:
+-#   Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-#   --with-ntl because otherwise FLINT's configure script uses
+-#   /usr/local, which is always wrong.
+-#   This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-#   The value $SAGE_LOCAL is always a safe choice even if the library
+-#   is coming from the system and is found using what is in
+-#   LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-flint="$SAGE_LOCAL"  || sdh_die "Error: Failed to configure antic."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/antic/type b/build/pkgs/antic/type
+deleted file mode 100644
+index 134d9bc32d5..00000000000
+--- a/build/pkgs/antic/type
++++ /dev/null
+@@ -1 +0,0 @@
+-optional
+diff --git a/build/pkgs/arb/SPKG.rst b/build/pkgs/arb/SPKG.rst
+deleted file mode 100644
+index cff49ddb95b..00000000000
+--- a/build/pkgs/arb/SPKG.rst
++++ /dev/null
+@@ -1,27 +0,0 @@
+-arb: Arbitrary-precision floating-point ball arithmetic
+-=======================================================
+-
+-Description
+------------
+-
+-Arb is a C library for arbitrary-precision floating-point ball
+-arithmetic, developed by Fredrik Johansson
+-(fredrik.johansson@gmail.com). It supports efficient high-precision
+-computation with polynomials, power series, matrices and special
+-functions over the real and complex numbers, with automatic, rigorous
+-error control.
+-
+-License
+--------
+-
+-GNU General Public License v2+
+-
+-
+-Upstream Contact
+-----------------
+-
+- - Fredrik Johansson: fredrik.johansson@gmail.com
+-
+- - https://arblib.org/
+-
+- - http://github.com/fredrik-johansson/arb/
+diff --git a/build/pkgs/arb/checksums.ini b/build/pkgs/arb/checksums.ini
+deleted file mode 100644
+index 80ef43dad5d..00000000000
+--- a/build/pkgs/arb/checksums.ini
++++ /dev/null
+@@ -1,5 +0,0 @@
+-tarball=arb-VERSION.tar.gz
+-sha1=a1efe035dd3af3613dd685971a156f652b86ff63
+-md5=9b369e29f93cdf2d4f90b57a92526cce
+-cksum=64252121
+-upstream_url=https://github.com/fredrik-johansson/arb/archive/VERSION.tar.gz
+diff --git a/build/pkgs/arb/dependencies b/build/pkgs/arb/dependencies
+deleted file mode 100644
+index c95d2836ce5..00000000000
+--- a/build/pkgs/arb/dependencies
++++ /dev/null
+@@ -1,4 +0,0 @@
+-$(MP_LIBRARY) mpfr flint
+-
+-----------
+-All lines of this file are ignored except the first.
+diff --git a/build/pkgs/arb/distros/arch.txt b/build/pkgs/arb/distros/arch.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/arch.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/conda.txt b/build/pkgs/arb/distros/conda.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/conda.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/debian.txt b/build/pkgs/arb/distros/debian.txt
+deleted file mode 100644
+index 9fe71110712..00000000000
+--- a/build/pkgs/arb/distros/debian.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-libflint-arb-dev
+diff --git a/build/pkgs/arb/distros/fedora.txt b/build/pkgs/arb/distros/fedora.txt
+deleted file mode 100644
+index 76794404627..00000000000
+--- a/build/pkgs/arb/distros/fedora.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb arb-devel
+diff --git a/build/pkgs/arb/distros/freebsd.txt b/build/pkgs/arb/distros/freebsd.txt
+deleted file mode 100644
+index 2ef8c7cec0f..00000000000
+--- a/build/pkgs/arb/distros/freebsd.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-math/arb
+diff --git a/build/pkgs/arb/distros/gentoo.txt b/build/pkgs/arb/distros/gentoo.txt
+deleted file mode 100644
+index 58e3d4f8008..00000000000
+--- a/build/pkgs/arb/distros/gentoo.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-sci-mathematics/arb
+diff --git a/build/pkgs/arb/distros/homebrew.txt b/build/pkgs/arb/distros/homebrew.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/homebrew.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/nix.txt b/build/pkgs/arb/distros/nix.txt
+deleted file mode 100644
+index 86c41dbaa5f..00000000000
+--- a/build/pkgs/arb/distros/nix.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb
+diff --git a/build/pkgs/arb/distros/opensuse.txt b/build/pkgs/arb/distros/opensuse.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/opensuse.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/distros/repology.txt b/build/pkgs/arb/distros/repology.txt
+deleted file mode 100644
+index 179c9d507e1..00000000000
+--- a/build/pkgs/arb/distros/repology.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-fp
+diff --git a/build/pkgs/arb/distros/void.txt b/build/pkgs/arb/distros/void.txt
+deleted file mode 100644
+index 3319855150c..00000000000
+--- a/build/pkgs/arb/distros/void.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-arb-devel
+diff --git a/build/pkgs/arb/package-version.txt b/build/pkgs/arb/package-version.txt
+deleted file mode 100644
+index e9763f6bfed..00000000000
+--- a/build/pkgs/arb/package-version.txt
++++ /dev/null
+@@ -1 +0,0 @@
+-2.23.0
+diff --git a/build/pkgs/arb/spkg-check.in b/build/pkgs/arb/spkg-check.in
+deleted file mode 100644
+index 27cd9419538..00000000000
+--- a/build/pkgs/arb/spkg-check.in
++++ /dev/null
+@@ -1,2 +0,0 @@
+-cd src
+-$MAKE check
+diff --git a/build/pkgs/arb/spkg-configure.m4 b/build/pkgs/arb/spkg-configure.m4
+deleted file mode 100644
+index ef2dd0aac4a..00000000000
+--- a/build/pkgs/arb/spkg-configure.m4
++++ /dev/null
+@@ -1,23 +0,0 @@
+-SAGE_SPKG_CONFIGURE([arb], [
+-    AC_REQUIRE([SAGE_SPKG_CONFIGURE_FLINT])
+-    SAGE_ARB_LIBRARY="arb"
+-    AC_MSG_CHECKING([installing flint? ])
+-    if test x$sage_spkg_install_flint = xyes; then
+-        AC_MSG_RESULT([yes; install arb as well])
+-        sage_spkg_install_arb=yes
+-    else
+-        AC_CHECK_HEADER(arb.h, [
+-        dnl below function added in version 2.16 of arb
+-            AC_CHECK_LIB([arb], [acb_mat_eig_simple], [],
+-              [dnl in Debian the name of dylib is different.
+-               AC_CHECK_LIB([flint-arb], [acb_mat_eig_simple],
+-                [SAGE_ARB_LIBRARY="flint-arb"], [sage_spkg_install_arb=yes])])
+-        ], [sage_spkg_install_arb=yes])
+-    fi
+-], [], [], [
+-    if test x$sage_spkg_install_arb = xyes; then
+-        AC_SUBST(SAGE_ARB_LIBRARY,["arb"])
+-    else
+-        AC_SUBST(SAGE_ARB_LIBRARY,[$SAGE_ARB_LIBRARY])
+-    fi
+-])
+diff --git a/build/pkgs/arb/spkg-install.in b/build/pkgs/arb/spkg-install.in
+deleted file mode 100644
+index 9322f04c912..00000000000
+--- a/build/pkgs/arb/spkg-install.in
++++ /dev/null
+@@ -1,17 +0,0 @@
+-cd src
+-
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-flint because otherwise ARB's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure --disable-static --prefix="$SAGE_LOCAL" \
+-        --with-gmp="$SAGE_LOCAL" \
+-        --with-mpfr="$SAGE_LOCAL" \
+-        --with-flint="$SAGE_LOCAL" || \
+-    sdh_die "Error configuring arb."
+-
+-sdh_make verbose
+-sdh_make_install
+diff --git a/build/pkgs/arb/type b/build/pkgs/arb/type
+deleted file mode 100644
+index a6a7b9cd726..00000000000
+--- a/build/pkgs/arb/type
++++ /dev/null
+@@ -1 +0,0 @@
+-standard
+diff --git a/build/pkgs/e_antic/dependencies b/build/pkgs/e_antic/dependencies
+index fea1ffbda45..8e977a55c13 100644
+--- a/build/pkgs/e_antic/dependencies
++++ b/build/pkgs/e_antic/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) flint arb antic boost_cropped
++$(MP_LIBRARY) flint boost_cropped
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/SPKG.rst b/build/pkgs/flint/SPKG.rst
+index f91de70d1ff..d9dcea0903b 100644
+--- a/build/pkgs/flint/SPKG.rst
++++ b/build/pkgs/flint/SPKG.rst
+@@ -4,8 +4,8 @@ flint: Fast Library for Number Theory
+ Description
+ -----------
+ 
+-FLINT is a C library for doing number theory, maintained by William
+-Hart.
++FLINT is a C library for doing number theory, maintained by
++Fredrik Johansson.
+ 
+ Website: http://www.flintlib.org
+ 
+@@ -20,4 +20,4 @@ Upstream Contact
+ 
+ -  flint-devel Gougle Group
+    (http://groups.google.co.uk/group/flint-devel)
+--  William Hart
++-  Fredrik Johansson
+diff --git a/build/pkgs/flint/checksums.ini b/build/pkgs/flint/checksums.ini
+index 3d449d98064..ab836606657 100644
+--- a/build/pkgs/flint/checksums.ini
++++ b/build/pkgs/flint/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=flint-VERSION.tar.gz
+-sha1=63d90f8242c8f8ab4011fbcfb44b86c154f43abd
+-md5=c2d3cec326438f159a530c66eb07fafe
+-cksum=4244948341
+-upstream_url=http://flintlib.org/flint-VERSION.tar.gz
++sha1=65be9297c06edd7e24f20874b7bd6130cee56723
++md5=5189f67b0ec12e4a54d6782851642b81
++cksum=172350473
++upstream_url=https://github.com/flintlib/flint/releases/download/vVERSION/flint-VERSION.tar.gz
+diff --git a/build/pkgs/flint/dependencies b/build/pkgs/flint/dependencies
+index 385df4faa7d..1108dc4fb21 100644
+--- a/build/pkgs/flint/dependencies
++++ b/build/pkgs/flint/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) mpfr ntl
++$(MP_LIBRARY) mpfr
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/flint/package-version.txt b/build/pkgs/flint/package-version.txt
+index c8e38b61405..cb2b00e4f7a 100644
+--- a/build/pkgs/flint/package-version.txt
++++ b/build/pkgs/flint/package-version.txt
+@@ -1 +1 @@
+-2.9.0
++3.0.1
+diff --git a/build/pkgs/flint/patches/0001-Makefile.in-fix-handling-of-DESTDIR.patch b/build/pkgs/flint/patches/0001-Makefile.in-fix-handling-of-DESTDIR.patch
+new file mode 100644
+index 00000000000..48a32f5d894
+--- /dev/null
++++ b/build/pkgs/flint/patches/0001-Makefile.in-fix-handling-of-DESTDIR.patch
+@@ -0,0 +1,106 @@
++From 54277f054f13254898c9a57c2c7eb869877e1252 Mon Sep 17 00:00:00 2001
++From: Marc Mezzarobba <marc@mezzarobba.net>
++Date: Mon, 13 Nov 2023 10:23:54 +0100
++Subject: [PATCH] Makefile.in: fix handling of $DESTDIR
++
++---
++ Makefile.in | 54 ++++++++++++++++++++++++++---------------------------
++ 1 file changed, 27 insertions(+), 27 deletions(-)
++
++diff --git a/Makefile.in b/Makefile.in
++index 08db6837c..2827b9da1 100644
++--- a/Makefile.in
+++++ b/Makefile.in
++@@ -34,9 +34,9 @@ FLINT_SOLIB:=@FLINT_SOLIB@
++ prefix:=@prefix@
++ exec_prefix:=@exec_prefix@
++ 
++-INCLUDEDIR:=$(DESTDIR)@includedir@
++-LIBDIR:=$(DESTDIR)@libdir@
++-BINDIR:=$(DESTDIR)@bindir@
+++INCLUDEDIR:=@includedir@
+++LIBDIR:=@libdir@
+++BINDIR:=@bindir@
++ PKGCONFIGDIR:=$(LIBDIR)/pkgconfig
++ 
++ HOST_OS:=@host_os@
++@@ -202,10 +202,10 @@ BUILD_DIRS +=                                                               \
++ endif
++ 
++ INSTALL_DIRS :=                                                             \
++-        $(LIBDIR)                       $(INCLUDEDIR)/flint                 \
++-        $(PKGCONFIGDIR)
+++        $(DESTDIR)$(LIBDIR)             $(DESTDIR)$(INCLUDEDIR)/flint       \
+++        $(DESTDIR)$(PKGCONFIGDIR)
++ ifneq ($(FLINT_DLLLIB),0)
++-INSTALL_DIRS += $(BINDIR)
+++INSTALL_DIRS += $(DESTDIR)$(BINDIR)
++ endif
++ 
++ ################################################################################
++@@ -722,41 +722,41 @@ distclean: clean
++ ################################################################################
++ 
++ install: library | $(INSTALL_DIRS)
++-	$(CP) flint.pc $(PKGCONFIGDIR)/flint.pc
+++	$(CP) flint.pc $(DESTDIR)$(PKGCONFIGDIR)/flint.pc
++ ifneq ($(SHARED), 0)
++ ifneq ($(FLINT_DLLLIB),0)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(BINDIR)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(BINDIR)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(BINDIR)
++-	$(CP) $(FLINT_DIR)/$(FLINT_IMPLIB) $(LIBDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(DESTDIR)$(BINDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(DESTDIR)$(BINDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(DESTDIR)$(BINDIR)
+++	$(CP) $(FLINT_DIR)/$(FLINT_IMPLIB) $(DESTDIR)$(LIBDIR)
++ else
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(LIBDIR)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(LIBDIR)
++-	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(LIBDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB) $(DESTDIR)$(LIBDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_MAJOR) $(DESTDIR)$(LIBDIR)
+++	$(CP_A) $(FLINT_DIR)/$(FLINT_LIB_FULL) $(DESTDIR)$(LIBDIR)
++ endif
++ ifneq ($(FLINT_DYLIB),0)
++-	install_name_tool -id $(LIBDIR)/$(FLINT_LIB_FULL) $(LIBDIR)/$(FLINT_LIB)
+++	install_name_tool -id $(LIBDIR)/$(FLINT_LIB_FULL) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB)
++ endif
++ endif
++ ifneq ($(STATIC), 0)
++-	$(CP) $(FLINT_DIR)/$(FLINT_LIB_STATIC) $(LIBDIR)
+++	$(CP) $(FLINT_DIR)/$(FLINT_LIB_STATIC) $(DESTDIR)$(LIBDIR)
++ endif
++-	$(CP) $(HEADERS) $(INCLUDEDIR)/flint
+++	$(CP) $(HEADERS) $(DESTDIR)$(INCLUDEDIR)/flint
++ 
++ uninstall:
++-	$(RM_F) $(PKGCONFIGDIR)/flint.pc
+++	$(RM_F) $(DESTDIR)$(PKGCONFIGDIR)/flint.pc
++ ifneq ($(FLINT_DLLLIB),0)
++-	$(RM_F) $(BINDIR)/$(FLINT_LIB)
++-	$(RM_F) $(BINDIR)/$(FLINT_LIB_MAJOR)
++-	$(RM_F) $(BINDIR)/$(FLINT_LIB_FULL)
++-	$(RM_F) $(LIBDIR)/$(FLINT_IMPLIB)
+++	$(RM_F) $(DESTDIR)$(BINDIR)/$(FLINT_LIB)
+++	$(RM_F) $(DESTDIR)$(BINDIR)/$(FLINT_LIB_MAJOR)
+++	$(RM_F) $(DESTDIR)$(BINDIR)/$(FLINT_LIB_FULL)
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_IMPLIB)
++ else
++-	$(RM_F) $(LIBDIR)/$(FLINT_LIB)
++-	$(RM_F) $(LIBDIR)/$(FLINT_LIB_MAJOR)
++-	$(RM_F) $(LIBDIR)/$(FLINT_LIB_FULL)
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB)
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB_MAJOR)
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB_FULL)
++ endif
++-	$(RM_F) $(LIBDIR)/$(FLINT_LIB_STATIC)
++-	$(RM_RF) $(INCLUDEDIR)/flint
+++	$(RM_F) $(DESTDIR)$(LIBDIR)/$(FLINT_LIB_STATIC)
+++	$(RM_RF) $(DESTDIR)$(INCLUDEDIR)/flint
++ 
++ ################################################################################
++ # maintainer stuff
++-- 
++2.42.0
++
+diff --git a/build/pkgs/flint/spkg-build.in b/build/pkgs/flint/spkg-build.in
+new file mode 100644
+index 00000000000..ffb822c8a97
+--- /dev/null
++++ b/build/pkgs/flint/spkg-build.in
+@@ -0,0 +1,3 @@
++cd src
++sdh_configure
++sdh_make
+diff --git a/build/pkgs/flint/spkg-configure.m4 b/build/pkgs/flint/spkg-configure.m4
+index a58108c9d6e..9576e4cc1e9 100644
+--- a/build/pkgs/flint/spkg-configure.m4
++++ b/build/pkgs/flint/spkg-configure.m4
+@@ -1,25 +1,8 @@
+ SAGE_SPKG_CONFIGURE([flint], [
+-    SAGE_SPKG_DEPCHECK([mpfr ntl], [
++    SAGE_SPKG_DEPCHECK([mpfr], [
+         AC_CHECK_HEADER(flint/flint.h, [
+-          dnl flint_parallel_binary_splitting appears in Flint 2.9.0, needed by arb 2.23
+-          AC_SEARCH_LIBS([flint_parallel_binary_splitting], [flint], [
+-            dnl check that NTL is linked in
+-            AC_SEARCH_LIBS([fmpz_poly_get_ZZX], [flint], [
+-
+-              AC_MSG_CHECKING([that GC is not enabled in Flint... ])
+-              AC_RUN_IFELSE([
+-                 AC_LANG_PROGRAM([[#include <flint/flint.h>]], [
+-                                  [#ifdef HAVE_GC]
+-                                     [return HAVE_GC;]
+-                                  [#else]
+-                                     [return 0;]
+-                                  [#endif]])],
+-                 [AC_MSG_RESULT([GC not enabled. Good.])],
+-                        [AC_MSG_RESULT([GC enabled. Incompatible with Sage.])
+-                         sage_spkg_install_flint=yes],
+-                 [AC_MSG_RESULT(["cross compiling. assuming GC is not enabled"])])
+-            ], [sage_spkg_install_flint=yes])
+-          ], [sage_spkg_install_flint=yes])
++          dnl gr_get_fexpr appears in Flint 3.0
++          AC_SEARCH_LIBS([gr_get_fexpr], [flint], [], [sage_spkg_install_flint=yes])
+         ], [sage_spkg_install_flint=yes])
+     ])
+ ], [], [], [
+diff --git a/build/pkgs/flint/spkg-install.in b/build/pkgs/flint/spkg-install.in
+index eacd7b6e491..3ea8c053669 100644
+--- a/build/pkgs/flint/spkg-install.in
++++ b/build/pkgs/flint/spkg-install.in
+@@ -1,36 +1,2 @@
+-###############################################################################
+-#
+-# FLINT Sage install script
+-#
+-###############################################################################
+-if [ "$SAGE_DEBUG" = "yes" ]; then
+-    echo "Building a debug version of FLINT."
+-    FLINT_TUNE=" $FLINT_TUNE"; export FLINT_TUNE
+-    FLINT_CONFIGURE="--enable-assert $FLINT_CONFIGURE"
+-fi
+-
+ cd src
+-
+-echo "Configuring FLINT."
+-# Trac #29607: We must always supply --with-gmp, --with-mpfr,
+-# --with-ntl because otherwise FLINT's configure script uses
+-# /usr/local, which is always wrong.
+-# This is why we do not use $SAGE_CONFIGURE_GMP etc. here.
+-# The value $SAGE_LOCAL is always a safe choice even if the library
+-# is coming from the system and is found using what is in
+-# LIBRARY_PATH or LDFLAGS etc.
+-./configure \
+-    --disable-static \
+-    --prefix="$SAGE_LOCAL" \
+-    --with-gmp="$SAGE_LOCAL" \
+-    --with-mpfr="$SAGE_LOCAL" \
+-    --with-ntl="$SAGE_LOCAL" \
+-    $FLINT_CONFIGURE || sdh_die "Error: Failed to configure FLINT."
+-
+-sdh_make verbose
+-
+-echo "Deleting old FLINT files."
+-rm -f $SAGE_LOCAL/lib/libflint*
+-rm -rf $SAGE_LOCAL/include/flint
+-
+ sdh_make_install
+diff --git a/build/pkgs/gmp/spkg-configure.m4 b/build/pkgs/gmp/spkg-configure.m4
+index 61d7c5f3b2f..4000200db2c 100644
+--- a/build/pkgs/gmp/spkg-configure.m4
++++ b/build/pkgs/gmp/spkg-configure.m4
+@@ -2,8 +2,10 @@ SAGE_SPKG_CONFIGURE([gmp], [
+            sage_spkg_install_gmp=no
+             AC_CHECK_HEADER(gmp.h, [], [sage_spkg_install_gmp=yes])
+             AC_CHECK_HEADER(gmpxx.h, [], [sage_spkg_install_gmp=yes])
+-            dnl mpq_cmp_z appeared in GMP 6.1.0 and is used by pynac
+-            AC_SEARCH_LIBS([__gmpq_cmp_z], [gmp], [],
++            dnl mpn_gcd_11 appeared in GMP 6.2.1
++            dnl It is undocumented but is used by Flint when built with default
++            dnl flags.
++            AC_SEARCH_LIBS([__gmpn_gcd_11], [gmp], [],
+                 [sage_spkg_install_gmp=yes])
+ ], [], [], [
+     if test x$sage_spkg_install_gmp = xyes; then
+diff --git a/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+new file mode 100644
+index 00000000000..27a642a13b0
+--- /dev/null
++++ b/build/pkgs/msolve/patches/0001-Make-msolve-build-with-flint3.patch
+@@ -0,0 +1,53 @@
++From fe730579476de0b2d4181a38efa7f63dff9c81d7 Mon Sep 17 00:00:00 2001
++From: Marc Mezzarobba <marc@mezzarobba.net>
++Date: Tue, 12 Sep 2023 08:23:08 +0200
++Subject: [PATCH] Make msolve build with flint3
++
++---
++ src/fglm/berlekamp_massey.c | 3 +++
++ src/fglm/data_fglm.c        | 7 +++++--
++ 2 files changed, 8 insertions(+), 2 deletions(-)
++
++diff --git a/src/fglm/berlekamp_massey.c b/src/fglm/berlekamp_massey.c
++index b0f2052..998af1c 100644
++--- a/src/fglm/berlekamp_massey.c
+++++ b/src/fglm/berlekamp_massey.c
++@@ -30,6 +30,9 @@
++ */
++ 
++ #include <stdlib.h>
+++#if __FLINT_VERSION >= 3
+++#  include <flint/nmod.h>
+++#endif
++ //#include "nmod_poly.h"
++ //#include "mpn_extras.h"
++ 
++diff --git a/src/fglm/data_fglm.c b/src/fglm/data_fglm.c
++index 0726760..0e1da6f 100644
++--- a/src/fglm/data_fglm.c
+++++ b/src/fglm/data_fglm.c
++@@ -24,6 +24,7 @@
++ #include <flint/mpn_extras.h>
++ #include <flint/nmod_poly.h>
++ #include <flint/nmod_poly_factor.h>
+++#include <flint/ulong_extras.h>
++ 
++ 
++ typedef uint32_t szmat_t;
++@@ -299,9 +300,11 @@ static inline void nmod_poly_set_prime(nmod_poly_t poly,
++   mp_limb_t ninv = n_preinvert_limb(prime);
++   poly->mod.n = prime;
++   poly->mod.ninv = ninv;
+++#if __FLINT_VERSION < 3
++   count_leading_zeros(poly->mod.norm, prime);
++-  /* poly->mod.norm = flint_clz(prime); */
++-
+++#else
+++  poly->mod.norm = flint_clz(prime);
+++#endif
++ }
++ 
++ static inline void fglm_param_set_prime(param_t *param, mp_limb_t prime){
++-- 
++2.40.1
++
+diff --git a/build/pkgs/sagelib/dependencies b/build/pkgs/sagelib/dependencies
+index 5dc2efe1d31..fa6e98df7db 100644
+--- a/build/pkgs/sagelib/dependencies
++++ b/build/pkgs/sagelib/dependencies
+@@ -1,4 +1,4 @@
+-FORCE $(SCRIPTS) arb boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
++FORCE $(SCRIPTS) boost_cropped $(BLAS) brial cliquer cypari cysignals cython ecl eclib ecm flint libgd gap giac givaro glpk gmpy2 gsl iml importlib_metadata importlib_resources jupyter_core lcalc lrcalc_python libbraiding libhomfly libpng linbox m4ri m4rie memory_allocator mpc mpfi mpfr $(MP_LIBRARY) ntl numpy pari pip pkgconfig planarity ppl pplpy primesieve primecount primecountpy pycygwin $(PYTHON) requests rw sage_conf singular symmetrica typing_extensions $(PCFILES) | $(PYTHON_TOOLCHAIN) sage_setup $(PYTHON) pythran
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/build/pkgs/symengine/dependencies b/build/pkgs/symengine/dependencies
+index 1fc34963eda..7795d486018 100644
+--- a/build/pkgs/symengine/dependencies
++++ b/build/pkgs/symengine/dependencies
+@@ -1,4 +1,4 @@
+-$(MP_LIBRARY) arb ecm flint mpc mpfr | cmake
++$(MP_LIBRARY) ecm flint mpc mpfr | cmake
+ 
+ ----------
+ All lines of this file are ignored except the first.
+diff --git a/pkgs/sage-conf/_sage_conf/_conf.py.in b/pkgs/sage-conf/_sage_conf/_conf.py.in
+index 87b27ca05cb..895d6572d1e 100644
+--- a/pkgs/sage-conf/_sage_conf/_conf.py.in
++++ b/pkgs/sage-conf/_sage_conf/_conf.py.in
+@@ -19,8 +19,6 @@ MAXIMA_FAS = "@SAGE_MAXIMA_FAS@".replace('${prefix}', SAGE_LOCAL)
+ # Delete this line if your ECL can load Kenzo without further prodding.
+ KENZO_FAS = "@SAGE_KENZO_FAS@".replace('${prefix}', SAGE_LOCAL)
+ 
+-ARB_LIBRARY = "@SAGE_ARB_LIBRARY@"
+-
+ NTL_INCDIR = "@NTL_INCDIR@"
+ NTL_LIBDIR = "@NTL_LIBDIR@"
+ 
+diff --git a/src/sage/env.py b/src/sage/env.py
+index 4515e90e912..9ab6b1e1864 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -223,7 +223,6 @@ def var(key: str, *fallbacks: Optional[str], force: bool = False) -> Optional[st
+ FOURTITWO_PPI = var("FOURTITWO_PPI")
+ FOURTITWO_CIRCUITS = var("FOURTITWO_CIRCUITS")
+ FOURTITWO_GROEBNER = var("FOURTITWO_GROEBNER")
+-ARB_LIBRARY = var("ARB_LIBRARY", "arb")
+ CBLAS_PC_MODULES = var("CBLAS_PC_MODULES", "cblas:openblas:blas")
+ ECL_CONFIG = var("ECL_CONFIG", "ecl-config")
+ NTL_INCDIR = var("NTL_INCDIR")
+@@ -356,8 +355,7 @@ def cython_aliases(required_modules=None,
+         sage: cython_aliases()
+         {...}
+         sage: sorted(cython_aliases().keys())
+-        ['ARB_LIBRARY',
+-         'CBLAS_CFLAGS',
++        ['CBLAS_CFLAGS',
+          ...,
+          'ZLIB_LIBRARIES']
+         sage: cython_aliases(required_modules=('module-that-is-assumed-to-not-exist'))
+@@ -475,8 +473,6 @@ def uname_specific(name, value, alternative):
+     if "LINBOX_CFLAGS" in aliases:
+         aliases["LINBOX_CFLAGS"].append("-std=gnu++11")
+ 
+-    aliases["ARB_LIBRARY"] = ARB_LIBRARY
+-
+     # TODO: Remove Cygwin hack by installing a suitable cblas.pc
+     if os.path.exists('/usr/lib/libblas.dll.a'):
+         aliases["CBLAS_LIBS"] = ['gslcblas']
+diff --git a/src/sage/features/sagemath.py b/src/sage/features/sagemath.py
+index bc34d35dd1c..4097d3512b9 100644
+--- a/src/sage/features/sagemath.py
++++ b/src/sage/features/sagemath.py
+@@ -777,7 +777,7 @@ class sage__rings__number_field(JoinFeature):
+     A :class:`~sage.features.Feature` describing the presence of :mod:`sage.rings.number_field`.
+ 
+     Number fields are implemented in Sage using a complicated mixture of various libraries,
+-    including :ref:`arb <spkg_arb>`, :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
++    including :ref:`FLINT <spkg_flint>`, :ref:`GAP <spkg_gap>`,
+     :ref:`MPFI <spkg_mpfi>`, :ref:`NTL <spkg_ntl>`, and :ref:`PARI <spkg_pari>`.
+ 
+     EXAMPLES:
+diff --git a/src/sage/libs/arb/acb.pxd b/src/sage/libs/arb/acb.pxd
+index 5148dc43991..851488d803a 100644
+--- a/src/sage/libs/arb/acb.pxd
++++ b/src/sage/libs/arb/acb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -152,10 +152,6 @@ cdef extern from "arb_wrap.h":
+     void acb_sech(acb_t s, const acb_t z, long prec)
+     void acb_csch(acb_t c, const acb_t z, long prec)
+ 
+-    void acb_rising_ui_bs(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui_rs(acb_t z, const acb_t x, unsigned long n, unsigned long step, long prec)
+-    void acb_rising_ui_rec(acb_t z, const acb_t x, unsigned long n, long prec)
+-    void acb_rising_ui(acb_t z, const acb_t x, unsigned long n, long prec)
+     void acb_rising(acb_t z, const acb_t x, const acb_t n, long prec)
+ 
+     void acb_gamma(acb_t y, const acb_t x, long prec)
+diff --git a/src/sage/libs/arb/acb_calc.pxd b/src/sage/libs/arb/acb_calc.pxd
+index a5dbf360b5e..67bd2ed57dc 100644
+--- a/src/sage/libs/arb/acb_calc.pxd
++++ b/src/sage/libs/arb/acb_calc.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_calc.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_elliptic.pxd b/src/sage/libs/arb/acb_elliptic.pxd
+index 176f68df00e..e3480e9f73b 100644
+--- a/src/sage/libs/arb/acb_elliptic.pxd
++++ b/src/sage/libs/arb/acb_elliptic.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_elliptic.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_hypgeom.pxd b/src/sage/libs/arb/acb_hypgeom.pxd
+index 418e766f10d..c43e5c0623b 100644
+--- a/src/sage/libs/arb/acb_hypgeom.pxd
++++ b/src/sage/libs/arb/acb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_hypgeom.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_modular.pxd b/src/sage/libs/arb/acb_modular.pxd
+index c708e9bf97d..cdc413c92da 100644
+--- a/src/sage/libs/arb/acb_modular.pxd
++++ b/src/sage/libs/arb/acb_modular.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_modular.h
+ 
+ from sage.libs.arb.types cimport *
+diff --git a/src/sage/libs/arb/acb_poly.pxd b/src/sage/libs/arb/acb_poly.pxd
+index 69f4320055b..ae02757ffd9 100644
+--- a/src/sage/libs/arb/acb_poly.pxd
++++ b/src/sage/libs/arb/acb_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = acb_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -79,24 +79,10 @@ cdef extern from "arb_wrap.h":
+     void _acb_poly_divrem(acb_ptr Q, acb_ptr R, acb_srcptr A, long lenA, acb_srcptr B, long lenB, long prec)
+     bint acb_poly_divrem(acb_poly_t Q, acb_poly_t R, const acb_poly_t A, const acb_poly_t B, long prec)
+     void _acb_poly_div_root(acb_ptr Q, acb_t R, acb_srcptr A, long len, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_horner(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_horner(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_divconquer(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_divconquer(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_taylor_shift_convolution(acb_ptr g, const acb_t c, long n, long prec)
+-    void acb_poly_taylor_shift_convolution(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+     void _acb_poly_taylor_shift(acb_ptr g, const acb_t c, long n, long prec)
+     void acb_poly_taylor_shift(acb_poly_t g, const acb_poly_t f, const acb_t c, long prec)
+-    void _acb_poly_compose_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_divconquer(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+-    void acb_poly_compose_divconquer(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+     void _acb_poly_compose(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long prec)
+     void acb_poly_compose(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long prec)
+-    void _acb_poly_compose_series_horner(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_horner(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+-    void _acb_poly_compose_series_brent_kung(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+-    void acb_poly_compose_series_brent_kung(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_compose_series(acb_ptr res, acb_srcptr poly1, long len1, acb_srcptr poly2, long len2, long n, long prec)
+     void acb_poly_compose_series(acb_poly_t res, const acb_poly_t poly1, const acb_poly_t poly2, long n, long prec)
+     void _acb_poly_revert_series_lagrange(acb_ptr h, acb_srcptr f, long flen, long n, long prec)
+@@ -161,10 +147,6 @@ cdef extern from "arb_wrap.h":
+     void acb_poly_exp_series_basecase(acb_poly_t f, const acb_poly_t h, long n, long prec)
+     void _acb_poly_exp_series(acb_ptr f, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_exp_series(acb_poly_t f, const acb_poly_t h, long n, long prec)
+-    void _acb_poly_sin_cos_series_basecase(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_basecase(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+-    void _acb_poly_sin_cos_series_tangent(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec, int times_pi)
+-    void acb_poly_sin_cos_series_tangent(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec, int times_pi)
+     void _acb_poly_sin_cos_series(acb_ptr s, acb_ptr c, acb_srcptr h, long hlen, long n, long prec)
+     void acb_poly_sin_cos_series(acb_poly_t s, acb_poly_t c, const acb_poly_t h, long n, long prec)
+     void _acb_poly_sin_series(acb_ptr s, acb_srcptr h, long hlen, long n, long prec)
+diff --git a/src/sage/libs/arb/arb.pxd b/src/sage/libs/arb/arb.pxd
+index c82b94de30f..acd232ab816 100644
+--- a/src/sage/libs/arb/arb.pxd
++++ b/src/sage/libs/arb/arb.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -224,15 +224,8 @@ cdef extern from "arb_wrap.h":
+ 
+     void arb_lambertw(arb_t res, const arb_t x, int flags, long prec)
+ 
+-    void arb_rising_ui_bs(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui_rs(arb_t z, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising_ui_rec(arb_t z, const arb_t x, unsigned long n, long prec)
+-    void arb_rising_ui(arb_t z, const arb_t x, unsigned long n, long prec)
+     void arb_rising(arb_t z, const arb_t x, const arb_t n, long prec)
+     void arb_rising_fmpq_ui(arb_t z, const fmpq_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_bs(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+-    void arb_rising2_ui_rs(arb_t u, arb_t v, const arb_t x, unsigned long n, unsigned long step, long prec)
+-    void arb_rising2_ui(arb_t u, arb_t v, const arb_t x, unsigned long n, long prec)
+     void arb_fac_ui(arb_t z, unsigned long n, long prec)
+     void arb_bin_ui(arb_t z, const arb_t n, unsigned long k, long prec)
+     void arb_bin_uiui(arb_t z, unsigned long n, unsigned long k, long prec)
+diff --git a/src/sage/libs/arb/arb_fmpz_poly.pxd b/src/sage/libs/arb/arb_fmpz_poly.pxd
+index 079f76e9d9e..55daa705238 100644
+--- a/src/sage/libs/arb/arb_fmpz_poly.pxd
++++ b/src/sage/libs/arb/arb_fmpz_poly.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_fmpz_poly.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -22,5 +22,4 @@ cdef extern from "arb_wrap.h":
+     unsigned long arb_fmpz_poly_deflation(const fmpz_poly_t poly)
+     void arb_fmpz_poly_deflate(fmpz_poly_t res, const fmpz_poly_t poly, unsigned long deflation)
+     void arb_fmpz_poly_complex_roots(acb_ptr roots, const fmpz_poly_t poly, int flags, long prec)
+-    void arb_fmpz_poly_cos_minpoly(fmpz_poly_t res, unsigned long n)
+     void arb_fmpz_poly_gauss_period_minpoly(fmpz_poly_t res, unsigned long q, unsigned long n)
+diff --git a/src/sage/libs/arb/arb_hypgeom.pxd b/src/sage/libs/arb/arb_hypgeom.pxd
+index fb1c40ddaa8..139b987d669 100644
+--- a/src/sage/libs/arb/arb_hypgeom.pxd
++++ b/src/sage/libs/arb/arb_hypgeom.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arb_hypgeom.h
+ 
+ from sage.libs.flint.types cimport fmpz_t
+diff --git a/src/sage/libs/arb/arb_wrap.h b/src/sage/libs/arb/arb_wrap.h
+index 49997075ee5..488bb376d5e 100644
+--- a/src/sage/libs/arb/arb_wrap.h
++++ b/src/sage/libs/arb/arb_wrap.h
+@@ -5,25 +5,27 @@
+  * by arb, most of which rely on flint's ulong and slong defines.
+  */
+ 
++#include <mpfr.h>
++
+ #undef ulong
+ #undef slong
+ 
+ #define ulong mp_limb_t
+ #define slong mp_limb_signed_t
+ 
+-#include <acb.h>
+-#include <acb_calc.h>
+-#include <acb_elliptic.h>
+-#include <acb_hypgeom.h>
+-#include <acb_mat.h>
+-#include <acb_modular.h>
+-#include <acb_poly.h>
+-#include <arb.h>
+-#include <arb_fmpz_poly.h>
+-#include <arb_hypgeom.h>
+-#include <arf.h>
+-#include <bernoulli.h>
+-#include <mag.h>
++#include <flint/acb.h>
++#include <flint/acb_calc.h>
++#include <flint/acb_elliptic.h>
++#include <flint/acb_hypgeom.h>
++#include <flint/acb_mat.h>
++#include <flint/acb_modular.h>
++#include <flint/acb_poly.h>
++#include <flint/arb.h>
++#include <flint/arb_fmpz_poly.h>
++#include <flint/arb_hypgeom.h>
++#include <flint/arf.h>
++#include <flint/bernoulli.h>
++#include <flint/mag.h>
+ 
+ #undef ulong
+ #undef slong
+diff --git a/src/sage/libs/arb/arf.pxd b/src/sage/libs/arb/arf.pxd
+index b8b83fefcdc..84778fe9f09 100644
+--- a/src/sage/libs/arb/arf.pxd
++++ b/src/sage/libs/arb/arf.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = arf.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -30,7 +30,6 @@ cdef extern from "arb_wrap.h":
+     void arf_set_ui(arf_t y, unsigned long x)
+     void arf_set_si(arf_t y, long x)
+     void arf_set_mpfr(arf_t y, const mpfr_t x)
+-    # void arf_set_fmpr(arf_t y, const fmpr_t x)
+     void arf_set_d(arf_t y, double x)
+     void arf_swap(arf_t y, arf_t x)
+     void arf_init_set_ui(arf_t y, unsigned long x)
+@@ -46,7 +45,6 @@ cdef extern from "arb_wrap.h":
+     int arf_set_round_fmpz_2exp(arf_t y, const fmpz_t x, const fmpz_t e, long prec, arf_rnd_t rnd)
+     void arf_get_fmpz_2exp(fmpz_t m, fmpz_t e, const arf_t x)
+     double arf_get_d(const arf_t x, arf_rnd_t rnd)
+-    # void arf_get_fmpr(fmpr_t y, const arf_t x)
+     int arf_get_mpfr(mpfr_t y, const arf_t x, mpfr_rnd_t rnd)
+     void arf_get_fmpz(fmpz_t z, const arf_t x, arf_rnd_t rnd)
+     long arf_get_si(const arf_t x, arf_rnd_t rnd)
+diff --git a/src/sage/libs/arb/bernoulli.pxd b/src/sage/libs/arb/bernoulli.pxd
+index f859ebfb8d7..95a84dd5179 100644
+--- a/src/sage/libs/arb/bernoulli.pxd
++++ b/src/sage/libs/arb/bernoulli.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = bernoulli.h
+ 
+ from sage.libs.flint.types cimport fmpq_t, ulong
+diff --git a/src/sage/libs/arb/mag.pxd b/src/sage/libs/arb/mag.pxd
+index d5d8693ea8f..69dfb990ae0 100644
+--- a/src/sage/libs/arb/mag.pxd
++++ b/src/sage/libs/arb/mag.pxd
+@@ -1,4 +1,4 @@
+-# distutils: libraries = gmp flint ARB_LIBRARY
++# distutils: libraries = gmp flint
+ # distutils: depends = mag.h
+ 
+ from sage.libs.arb.types cimport *
+@@ -27,13 +27,11 @@ cdef extern from "arb_wrap.h":
+     # void mag_randtest(mag_t x, flint_rand_t state, long expbits)
+     # void mag_randtest_special(mag_t x, flint_rand_t state, long expbits)
+     void mag_set_d(mag_t y, double x)
+-    # void mag_set_fmpr(mag_t y, const fmpr_t x)
+     void mag_set_ui(mag_t y, unsigned long x)
+     void mag_set_fmpz(mag_t y, const fmpz_t x)
+     void mag_set_d_2exp_fmpz(mag_t z, double x, const fmpz_t y)
+     void mag_set_fmpz_2exp_fmpz(mag_t z, const fmpz_t x, const fmpz_t y)
+     void mag_set_ui_2exp_si(mag_t z, unsigned long x, long y)
+-    # void mag_get_fmpr(fmpr_t y, const mag_t x)
+     void mag_get_fmpq(fmpq_t y, const mag_t x)
+     void mag_set_ui_lower(mag_t z, unsigned long x)
+     void mag_set_fmpz_lower(mag_t z, const fmpz_t x)
+diff --git a/src/sage/libs/flint/flint_wrap.h b/src/sage/libs/flint/flint_wrap.h
+index 266535c3835..4db72b97660 100644
+--- a/src/sage/libs/flint/flint_wrap.h
++++ b/src/sage/libs/flint/flint_wrap.h
+@@ -15,6 +15,7 @@
+  */
+ 
+ #include <gmp.h>
++#include <mpfr.h>
+ 
+ /* Save previous definition of ulong if any, as pari also uses it */
+ /* Should work on GCC, clang, MSVC */
+@@ -33,6 +34,7 @@
+ 
+ #include <flint/arith.h>
+ #include <flint/fmpq.h>
++#include <flint/fmpq_vec.h>
+ #include <flint/fmpq_mat.h>
+ #include <flint/fmpq_poly.h>
+ #include <flint/fmpz.h>
+@@ -47,6 +49,7 @@
+ #include <flint/fq.h>
+ #include <flint/fq_nmod.h>
+ #include <flint/nmod_poly.h>
++#include <flint/nmod_poly_factor.h>
+ #include <flint/nmod_vec.h>
+ #include <flint/padic.h>
+ #include <flint/padic_poly.h>
+diff --git a/src/sage/libs/flint/fmpq.pxd b/src/sage/libs/flint/fmpq.pxd
+index 5e64c82102f..0616c0a7408 100644
+--- a/src/sage/libs/flint/fmpq.pxd
++++ b/src/sage/libs/flint/fmpq.pxd
+@@ -12,6 +12,8 @@ cdef extern from "flint_wrap.h":
+     fmpz * fmpq_denref(fmpq_t)
+     void fmpq_init(fmpq_t)
+     void fmpq_clear(fmpq_t)
++    void fmpq_init_set_readonly(fmpq_t, const mpq_t)
++    void fmpq_clear_readonly(fmpq_t)
+     void fmpq_one(fmpq_t)
+     void fmpq_zero(fmpq_t)
+     bint fmpq_is_zero(fmpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pxd b/src/sage/libs/flint/fmpq_poly.pxd
+index 6050c487835..afa16e5bbdd 100644
+--- a/src/sage/libs/flint/fmpq_poly.pxd
++++ b/src/sage/libs/flint/fmpq_poly.pxd
+@@ -30,6 +30,9 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_canonicalise(fmpq_poly_t)
+     int fmpq_poly_is_canonical(const fmpq_poly_t)
+ 
++    void _fmpq_poly_set_length(fmpq_poly_t, slong)
++    void _fmpq_poly_normalise(fmpq_poly_t)
++
+     # Polynomial parameters
+     slong fmpq_poly_degree(const fmpq_poly_t)
+     ulong fmpq_poly_length(const fmpq_poly_t)
+@@ -46,10 +49,7 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_ui(fmpq_poly_t, ulong)
+     void fmpq_poly_set_fmpz(fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_set_fmpq(fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+     void fmpq_poly_set_fmpz_poly(fmpq_poly_t, const fmpz_poly_t)
+-    void fmpq_poly_set_array_mpq(fmpq_poly_t, const mpq_t *, slong)
+ 
+     void fmpq_poly_set_str(fmpq_poly_t, const char *)
+     char *fmpq_poly_get_str(const fmpq_poly_t)
+@@ -67,7 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_reverse(fmpq_poly_t, const fmpq_poly_t, slong)
+ 
+     void fmpq_poly_get_coeff_fmpq(fmpq_t, const fmpq_poly_t, slong)
+-    void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_si(slong, const fmpq_poly_t, slong)
+     void fmpq_poly_get_coeff_ui(ulong, const fmpq_poly_t, slong)
+ 
+@@ -75,8 +74,6 @@ cdef extern from "flint_wrap.h":
+     void fmpq_poly_set_coeff_ui(fmpq_poly_t, slong, ulong)
+     void fmpq_poly_set_coeff_fmpz(fmpq_poly_t, slong, const fmpz_t)
+     void fmpq_poly_set_coeff_fmpq(fmpq_poly_t, slong, const fmpq_t)
+-    void fmpq_poly_set_coeff_mpz(fmpq_poly_t, slong, const mpz_t)
+-    void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
+ 
+     # Comparison
+     int fmpq_poly_equal(const fmpq_poly_t, const fmpq_poly_t)
+@@ -100,8 +97,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_mul_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     void fmpq_poly_scalar_div_si(fmpq_poly_t, const fmpq_poly_t, slong)
+     void fmpq_poly_scalar_div_ui(fmpq_poly_t, const fmpq_poly_t, ulong)
+@@ -109,8 +104,6 @@ cdef extern from "flint_wrap.h":
+             fmpq_poly_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_scalar_div_fmpq(
+             fmpq_poly_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_scalar_div_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_scalar_div_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Multiplication
+     void fmpq_poly_mul(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -155,8 +148,6 @@ cdef extern from "flint_wrap.h":
+     # Evaluation
+     void fmpq_poly_evaluate_fmpz(fmpq_t, const fmpq_poly_t, const fmpz_t)
+     void fmpq_poly_evaluate_fmpq(fmpq_t, const fmpq_poly_t, const fmpq_t)
+-    void fmpq_poly_evaluate_mpz(mpq_t, const fmpq_poly_t, const mpz_t)
+-    void fmpq_poly_evaluate_mpq(mpq_t, const fmpq_poly_t, const mpq_t)
+ 
+     # Composition
+     void fmpq_poly_compose(fmpq_poly_t, const fmpq_poly_t, const fmpq_poly_t)
+@@ -189,3 +180,11 @@ cdef extern from "flint_wrap.h":
+ # since the fmpq_poly header seems to be lacking this inline function
+ cdef inline sage_fmpq_poly_max_limbs(const fmpq_poly_t poly) noexcept:
+     return _fmpz_vec_max_limbs(fmpq_poly_numref(poly), fmpq_poly_length(poly))
++
++# functions removed from flint but still needed in sage
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t, const fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t, const fmpq_poly_t, const mpq_t)
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t, slong, const mpq_t)
++cdef void fmpq_poly_get_coeff_mpq(mpq_t, const fmpq_poly_t, slong)
++cdef void fmpq_poly_set_mpz(fmpq_poly_t, const mpz_t)
++cdef void fmpq_poly_set_mpq(fmpq_poly_t, const mpq_t)
+diff --git a/src/sage/libs/flint/fmpq_poly.pyx b/src/sage/libs/flint/fmpq_poly.pyx
+new file mode 100644
+index 00000000000..3b8a0cf0c51
+--- /dev/null
++++ b/src/sage/libs/flint/fmpq_poly.pyx
+@@ -0,0 +1,45 @@
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++from sage.libs.gmp.mpq cimport *
++from sage.libs.flint.fmpz cimport *
++from sage.libs.flint.fmpq cimport *
++
++cdef void fmpq_poly_scalar_mul_mpz(fmpq_poly_t rop, const fmpq_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpq_poly_scalar_mul_mpq(fmpq_poly_t rop, const fmpq_poly_t op, const mpq_t c):
++    cdef fmpq_t f
++    fmpq_init_set_readonly(f, c)
++    fmpq_poly_scalar_mul_fmpq(rop, op, f)
++    fmpq_clear_readonly(f)
++
++cdef void fmpq_poly_set_coeff_mpq(fmpq_poly_t poly, slong n, const mpq_t x):
++    cdef fmpq_t t
++    fmpq_init_set_readonly(t, x)
++    fmpq_poly_set_coeff_fmpq(poly, n, t)
++    fmpq_clear_readonly(t)
++
++cdef void fmpq_poly_get_coeff_mpq(mpq_t x, const fmpq_poly_t poly, slong n):
++    cdef fmpq_t t
++    fmpq_init(t)
++    fmpq_poly_get_coeff_fmpq(t, poly, n)
++    fmpq_get_mpq(x, t)
++    fmpq_clear(t)
++
++cdef void fmpq_poly_set_mpq(fmpq_poly_t poly, const mpq_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), mpq_numref(x))
++    fmpz_set_mpz(fmpq_poly_denref(poly), mpq_denref(x))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
++
++cdef void fmpq_poly_set_mpz(fmpq_poly_t poly, const mpz_t x):
++    fmpq_poly_fit_length(poly, 1)
++    fmpz_set_mpz(fmpq_poly_numref(poly), x)
++    fmpz_one(fmpq_poly_denref(poly))
++    _fmpq_poly_set_length(poly, 1)
++    _fmpq_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz.pxd b/src/sage/libs/flint/fmpz.pxd
+index 01058d0f130..b97fbe1eae0 100644
+--- a/src/sage/libs/flint/fmpz.pxd
++++ b/src/sage/libs/flint/fmpz.pxd
+@@ -16,6 +16,9 @@ cdef extern from "flint_wrap.h":
+     void fmpz_init_set(fmpz_t, fmpz_t)
+     void fmpz_init_set_ui(fmpz_t, ulong)
+ 
++    void fmpz_init_set_readonly(fmpz_t, const mpz_t)
++    void fmpz_clear_readonly(fmpz_t)
++
+     # Conversion
+     void fmpz_set(fmpz_t f, fmpz_t g)
+     void fmpz_set_ui(fmpz_t, ulong)
+diff --git a/src/sage/libs/flint/fmpz_mod_poly.pxd b/src/sage/libs/flint/fmpz_mod_poly.pxd
+index 24b653eb3b7..2727246da98 100644
+--- a/src/sage/libs/flint/fmpz_mod_poly.pxd
++++ b/src/sage/libs/flint/fmpz_mod_poly.pxd
+@@ -67,13 +67,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_get_coeff_fmpz(fmpz_t x, const fmpz_mod_poly_t poly,
+                                              slong n, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_set_coeff_mpz(fmpz_mod_poly_t poly,
+-                             slong n, const mpz_t x, const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_get_coeff_mpz(mpz_t x,
+-                 const fmpz_mod_poly_t poly, slong n, const fmpz_mod_ctx_t ctx)
+-
+-
+     void _fmpz_mod_poly_shift_left(fmpz * res, const fmpz * poly,
+                                                            slong len, slong n)
+ 
+@@ -194,14 +187,6 @@ cdef extern from "flint_wrap.h":
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_div_basecase(fmpz_mod_poly_t Q,
+-                            const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_div_newton_n_preinv(fmpz_mod_poly_t Q,
+-                         const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                         const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem_newton_n_preinv(fmpz_mod_poly_t Q,
+           fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                          const fmpz_mod_poly_t Binv, const fmpz_mod_ctx_t ctx)
+@@ -213,10 +198,6 @@ cdef extern from "flint_wrap.h":
+                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_divrem_divconquer(fmpz_mod_poly_t Q,
+-        fmpz_mod_poly_t R, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_divrem(fmpz_mod_poly_t Q, fmpz_mod_poly_t R,
+     const fmpz_mod_poly_t A, const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+@@ -254,40 +235,13 @@ cdef extern from "flint_wrap.h":
+     void fmpz_mod_poly_make_monic_f(fmpz_t f, fmpz_mod_poly_t res,
+                          const fmpz_mod_poly_t poly, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_euclidean(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_gcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_gcd_f(fmpz_t f, fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_gcd_hgcd(fmpz_mod_poly_t G,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-
+     void fmpz_mod_poly_gcd(fmpz_mod_poly_t G, const fmpz_mod_poly_t A,
+                              const fmpz_mod_poly_t B, const fmpz_mod_ctx_t ctx)
+ 
+ 
+-    void fmpz_mod_poly_xgcd_euclidean(fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_euclidean_f(fmpz_t f, fmpz_mod_poly_t G,
+-                             fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+-                             const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_xgcd_hgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S,
+-          fmpz_mod_poly_t T, const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_xgcd(fmpz_mod_poly_t G, fmpz_mod_poly_t S, fmpz_mod_poly_t T,
+                              const fmpz_mod_poly_t A, const fmpz_mod_poly_t B,
+                                                       const fmpz_mod_ctx_t ctx)
+@@ -361,14 +315,6 @@ cdef extern from "flint_wrap.h":
+                         const fmpz_mod_poly_t poly, const fmpz * xs, slong n,
+                                                      const fmpz_mod_ctx_t ctx)
+ 
+-    void fmpz_mod_poly_compose_horner(fmpz_mod_poly_t res,
+-                    const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+-    void fmpz_mod_poly_compose_divconquer(fmpz_mod_poly_t res,
+-                     const fmpz_mod_poly_t poly1, const fmpz_mod_poly_t poly2,
+-                                                     const fmpz_mod_ctx_t ctx)
+-
+     void fmpz_mod_poly_compose(fmpz_mod_poly_t res, const fmpz_mod_poly_t poly1,
+                          const fmpz_mod_poly_t poly2, const fmpz_mod_ctx_t ctx)
+ 
+diff --git a/src/sage/libs/flint/fmpz_poly.pxd b/src/sage/libs/flint/fmpz_poly.pxd
+index 18b36672d30..c8bc6d3ca0a 100644
+--- a/src/sage/libs/flint/fmpz_poly.pxd
++++ b/src/sage/libs/flint/fmpz_poly.pxd
+@@ -28,7 +28,6 @@ cdef extern from "flint_wrap.h":
+     void fmpz_poly_set_ui(fmpz_poly_t, ulong)
+     void fmpz_poly_set_si(fmpz_poly_t, slong)
+     void fmpz_poly_set_fmpz(fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+     int fmpz_poly_set_str(fmpz_poly_t, const char *)
+ 
+     char *fmpz_poly_get_str(const fmpz_poly_t)
+@@ -70,7 +69,6 @@ cdef extern from "flint_wrap.h":
+     # Scalar multiplication and division
+     void fmpz_poly_scalar_mul_fmpz(
+             fmpz_poly_t, const fmpz_poly_t, const fmpz_t)
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+     void fmpz_poly_scalar_mul_si(fmpz_poly_t, const fmpz_poly_t, slong)
+     void fmpz_poly_scalar_mul_ui(fmpz_poly_t, const fmpz_poly_t, ulong)
+     void fmpz_poly_scalar_mul_2exp(fmpz_poly_t, const fmpz_poly_t, ulong)
+@@ -310,12 +308,14 @@ cdef extern from "flint_wrap.h":
+             fmpz_poly_t,
+                     const fmpz_poly_t, const fmpz_t, const nmod_poly_t, int)
+ 
+-    # Some functions for backwards compatibility
+-    void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
+-    void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
+-    void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++
++# functions removed from flint but still needed in sage
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t, const fmpz_poly_t, const mpz_t)
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t, slong, const mpz_t)
++cdef void fmpz_poly_get_coeff_mpz(mpz_t, const fmpz_poly_t, slong)
++cdef void fmpz_poly_set_mpz(fmpz_poly_t, const mpz_t)
+ 
+ 
+ # Wrapper Cython class
+diff --git a/src/sage/libs/flint/fmpz_poly.pyx b/src/sage/libs/flint/fmpz_poly.pyx
+index 74915b37612..cfcbea9090c 100644
+--- a/src/sage/libs/flint/fmpz_poly.pyx
++++ b/src/sage/libs/flint/fmpz_poly.pyx
+@@ -25,10 +25,10 @@ from cysignals.memory cimport sig_free
+ 
+ from sage.arith.long cimport pyobject_to_long
+ from sage.cpython.string cimport char_to_str, str_to_bytes
++from sage.libs.flint.fmpz cimport *
+ from sage.structure.sage_object cimport SageObject
+ from sage.rings.integer cimport Integer
+ 
+-
+ cdef class Fmpz_poly(SageObject):
+ 
+     def __cinit__(self):
+@@ -455,3 +455,44 @@ cdef class Fmpz_poly(SageObject):
+         """
+         from sage.rings.integer_ring import ZZ
+         return ZZ[var](self.list())
++
++
++# Functions removed from flint but still needed in Sage. Code adapted from
++# earlier versions of flint.
++
++cdef void fmpz_poly_scalar_mul_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_mul_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_divexact_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_divexact_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_scalar_fdiv_mpz(fmpz_poly_t rop, const fmpz_poly_t op, const mpz_t c):
++    cdef fmpz_t f
++    fmpz_init_set_readonly(f, c)
++    fmpz_poly_scalar_fdiv_fmpz(rop, op, f)
++    fmpz_clear_readonly(f)
++
++cdef void fmpz_poly_set_coeff_mpz(fmpz_poly_t poly, slong n, const mpz_t x):
++    cdef fmpz_t t
++    fmpz_init_set_readonly(t, x)
++    fmpz_poly_set_coeff_fmpz(poly, n, t)
++    fmpz_clear_readonly(t)
++
++cdef void fmpz_poly_get_coeff_mpz(mpz_t x, const fmpz_poly_t poly, slong n):
++    cdef fmpz_t t
++    fmpz_init(t)
++    fmpz_poly_get_coeff_fmpz(t, poly, n)
++    fmpz_get_mpz(x, t)
++    fmpz_clear(t)
++
++cdef void fmpz_poly_set_mpz(fmpz_poly_t poly, const mpz_t x):
++    fmpz_poly_fit_length(poly, 1)
++    fmpz_set_mpz(poly.coeffs, x)
++    _fmpz_poly_set_length(poly, 1)
++    _fmpz_poly_normalise(poly)
+diff --git a/src/sage/libs/flint/fmpz_poly_q.pxd b/src/sage/libs/flint/fmpz_poly_q.pxd
+index 846542dc0d8..63c13355bf6 100644
+--- a/src/sage/libs/flint/fmpz_poly_q.pxd
++++ b/src/sage/libs/flint/fmpz_poly_q.pxd
+@@ -49,11 +49,7 @@ cdef extern from "flint_wrap.h":
+ 
+     #* Scalar multiplication and division ****************************************/
+     void fmpz_poly_q_scalar_mul_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_mul_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_mul_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+     void fmpz_poly_q_scalar_div_si(fmpz_poly_q_t rop, const fmpz_poly_q_t op, long x)
+-    void fmpz_poly_q_scalar_div_mpz(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpz_t x)
+-    void fmpz_poly_q_scalar_div_mpq(fmpz_poly_q_t rop, const fmpz_poly_q_t op, const mpq_t x)
+ 
+     #* Multiplication and division ***********************************************/
+     void fmpz_poly_q_mul(fmpz_poly_q_t rop, 
+@@ -67,9 +63,6 @@ cdef extern from "flint_wrap.h":
+     #* Derivative ****************************************************************/
+     void fmpz_poly_q_derivative(fmpz_poly_q_t rop, const fmpz_poly_q_t op)
+ 
+-    #* Evaluation ****************************************************************/
+-    int fmpz_poly_q_evaluate(mpq_t rop, const fmpz_poly_q_t f, const mpq_t a)
+-
+     #* Input and output **********************************************************/
+     int fmpz_poly_q_set_str(fmpz_poly_q_t rop, const char *s)
+     char * fmpz_poly_q_get_str(const fmpz_poly_q_t op)
+diff --git a/src/sage/libs/linbox/linbox_flint_interface.pyx b/src/sage/libs/linbox/linbox_flint_interface.pyx
+index 1979ac0f0a4..37a340c457f 100644
+--- a/src/sage/libs/linbox/linbox_flint_interface.pyx
++++ b/src/sage/libs/linbox/linbox_flint_interface.pyx
+@@ -33,6 +33,7 @@ and C. Pernet. The functions available are:
+ #                  https://www.gnu.org/licenses/
+ # ****************************************************************************
+ 
++from sage.libs.gmp.types cimport mpz_t
+ from sage.libs.flint.types cimport fmpz_t
+ from sage.libs.flint.fmpz cimport fmpz_get_mpz, fmpz_set_mpz
+ from sage.libs.flint.fmpz_mat cimport fmpz_mat_entry, fmpz_mat_nrows, fmpz_mat_ncols
+@@ -80,11 +81,13 @@ cdef void fmpz_poly_set_linbox(fmpz_poly_t p, PolynomialRing_integer.Element& q)
+     (the .pxd file) in order to keep the header C-compatible
+     """
+     cdef size_t i
++    cdef mpz_t tmp
+ 
+     fmpz_poly_fit_length(p, q.size())
+ 
+     for i in range(q.size()):
+-        fmpz_poly_set_coeff_mpz(p, i, q[i].get_mpz_const())
++        tmp = q[i].get_mpz_const()
++        fmpz_poly_set_coeff_mpz(p, i, tmp)
+ 
+     _fmpz_poly_set_length(p, q.size())
+ 
+diff --git a/src/sage/matrix/matrix_complex_ball_dense.pyx b/src/sage/matrix/matrix_complex_ball_dense.pyx
+index e5414abdd9e..2f0131f4064 100644
+--- a/src/sage/matrix/matrix_complex_ball_dense.pyx
++++ b/src/sage/matrix/matrix_complex_ball_dense.pyx
+@@ -1,4 +1,4 @@
+-# distutils: libraries = ARB_LIBRARY
++# distutils: libraries = flint
+ r"""
+ Arbitrary precision complex ball matrices using Arb
+ 
+diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx
+index 27f5cdfac0f..6c5c20dbc6b 100644
+--- a/src/sage/matrix/matrix_integer_sparse.pyx
++++ b/src/sage/matrix/matrix_integer_sparse.pyx
+@@ -847,6 +847,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+             sage: matrix(ZZ, 1, 1, sparse=True)._charpoly_linbox()
+             x
+         """
++        cdef mpz_t tmp
+         if self._nrows != self._ncols:
+             raise ArithmeticError('only valid for square matrix')
+ 
+@@ -869,7 +870,8 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         cdef size_t i
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+@@ -966,9 +968,11 @@ cdef class Matrix_integer_sparse(Matrix_sparse):
+         sig_off()
+ 
+         cdef size_t i
++        cdef mpz_t tmp
+         fmpz_poly_fit_length(g._poly, p.size())
+         for i in range(p.size()):
+-            fmpz_poly_set_coeff_mpz(g._poly, i, p[0][i].get_mpz_const())
++            tmp = p[0][i].get_mpz_const()
++            fmpz_poly_set_coeff_mpz(g._poly, i, tmp)
+         _fmpz_poly_set_length(g._poly, p.size())
+ 
+         del M
+diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
+index 1e3085c9215..0786de7fc81 100644
+--- a/src/sage/rings/complex_arb.pyx
++++ b/src/sage/rings/complex_arb.pyx
+@@ -1360,12 +1360,13 @@ cdef class ComplexBall(RingElement):
+             sage: CBF100(-3r)
+             -3.000000000000000000000000000000
+ 
+-            sage: ComplexBall(CBF100, 10^100)
+-            1.000000000000000000000000000000e+100
+             sage: ComplexBall(CBF100, CIF(1, 2))
+             1.000000000000000000000000000000 + 2.000000000000000000000000000000*I
+             sage: ComplexBall(CBF100, RBF(1/3), RBF(1))
+             [0.3333333333333333 +/- ...e-17] + 1.000000000000000000000000000000*I
++            sage: ComplexBall(CBF100, 10^100)
++            [1.000000000000000000000000000000e+100 +/- ...]
++
+             sage: NF.<a> = QuadraticField(-1, embedding=CC(0, -1))
+             sage: CBF(a)
+             -1.000000000000000*I
+@@ -3009,7 +3010,7 @@ cdef class ComplexBall(RingElement):
+             sage: CBF(1).rising_factorial(2**64)
+             [+/- ...e+347382171326740403407]
+             sage: ComplexBallField(128)(1).rising_factorial(2**64)
+-            [2.343691126796861348e+347382171305201285713 +/- ...e+347382171305201285694]
++            [2.34369112679686134...e+347382171305201285713 +/- ...]
+             sage: CBF(1/2).rising_factorial(CBF(2,3)) # abs tol 1e-15
+             [-0.123060451458124 +/- 3.06e-16] + [0.0406412631676552 +/- 7.57e-17]*I
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_rational_flint.pyx b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+index 04eaefc9fed..d99f0d3b98c 100644
+--- a/src/sage/rings/polynomial/polynomial_rational_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_rational_flint.pyx
+@@ -222,7 +222,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef unsigned long n
+         cdef Rational c
+         cdef list L1
+-        cdef mpq_t * L2
++        cdef fmpq_t q
+ 
+         Polynomial.__init__(self, parent, is_gen=is_gen)
+ 
+@@ -253,14 +253,11 @@ cdef class Polynomial_rational_flint(Polynomial):
+             L1 = [e if isinstance(e, Rational) else Rational(e) for e in x]
+             n  = <unsigned long> len(x)
+             sig_on()
+-            L2 = <mpq_t *> check_allocarray(n, sizeof(mpq_t))
++            fmpq_poly_fit_length(self._poly, n)
+             for deg from 0 <= deg < n:
+-                mpq_init(L2[deg])
+-                mpq_set(L2[deg], (<Rational> L1[deg]).value)
+-            fmpq_poly_set_array_mpq(self._poly, L2, n)
+-            for deg from 0 <= deg < n:
+-                mpq_clear(L2[deg])
+-            sig_free(L2)
++                fmpq_init_set_readonly(q, (<Rational> L1[deg]).value)
++                fmpq_poly_set_coeff_fmpq(self._poly, deg, q)
++                fmpq_clear_readonly(q)
+             sig_off()
+ 
+ #           deg = 0
+@@ -435,6 +432,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         utmost care.
+         """
+         cdef bint do_sig = _do_sig(self._poly)
++        cdef fmpz_t tmpfz
+ 
+         if isinstance(value, int):
+             if do_sig: sig_str("FLINT exception")
+@@ -442,7 +440,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+             if do_sig: sig_off()
+         elif isinstance(value, Integer):
+             if do_sig: sig_str("FLINT exception")
+-            fmpq_poly_set_coeff_mpz(self._poly, n, (<Integer> value).value)
++            fmpz_init_set_readonly(tmpfz, (<Integer> value).value)
++            fmpq_poly_set_coeff_fmpz(self._poly, n, tmpfz)
++            fmpz_clear_readonly(tmpfz)
+             if do_sig: sig_off()
+         elif isinstance(value, Rational):
+             if do_sig: sig_str("FLINT exception")
+@@ -492,7 +492,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         cdef Polynomial_rational_flint f
+         cdef Rational r
+         cdef fmpz_t tmpfz
+-        cdef fmpq_t tmpfq
++        cdef fmpq_t tmpfq, tmpfq1
+         cdef RealBall arb_a, arb_z
+         cdef ComplexBall acb_a, acb_z
+ 
+@@ -508,13 +508,23 @@ cdef class Polynomial_rational_flint(Polynomial):
+             elif isinstance(a, Rational):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpq(r.value, self._poly, (<Rational> a).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> a).value)
++                fmpq_init(tmpfq1)
++                fmpq_poly_evaluate_fmpq(tmpfq1, self._poly, tmpfq)
++                fmpq_get_mpq(r.value, tmpfq1)
++                fmpq_clear(tmpfq1)
++                fmpq_clear_readonly(tmpfq)
+                 sig_off()
+                 return r
+             elif isinstance(a, Integer):
+                 r = Rational.__new__(Rational)
+                 sig_str("FLINT exception")
+-                fmpq_poly_evaluate_mpz(r.value, self._poly, (<Integer> a).value)
++                fmpz_init_set_readonly(tmpfz, (<Integer> a).value)
++                fmpq_init(tmpfq)
++                fmpq_poly_evaluate_fmpz(tmpfq, self._poly, tmpfz)
++                fmpq_get_mpq(r.value, tmpfq)
++                fmpq_clear(tmpfq)
++                fmpz_clear_readonly(tmpfz)
+                 sig_off()
+                 return r
+             elif isinstance(a, int):
+@@ -1321,6 +1331,7 @@ cdef class Polynomial_rational_flint(Polynomial):
+         """
+         cdef Polynomial_rational_flint res
+         cdef bint do_sig
++        cdef fmpq_t tmpfq
+ 
+         if right == 0:
+             raise ZeroDivisionError("division by zero polynomial")
+@@ -1331,8 +1342,9 @@ cdef class Polynomial_rational_flint(Polynomial):
+                 do_sig = _do_sig(self._poly)
+ 
+                 if do_sig: sig_str("FLINT exception")
+-                fmpq_poly_scalar_div_mpq(res._poly, self._poly,
+-                                                  (<Rational> QQ(right)).value)
++                fmpq_init_set_readonly(tmpfq, (<Rational> QQ(right)).value)
++                fmpq_poly_scalar_div_fmpq(res._poly, self._poly, tmpfq)
++                fmpq_clear_readonly(tmpfq)
+                 if do_sig: sig_off()
+                 return res
+ 
+diff --git a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+index 6e7f7498329..3a66198d568 100644
+--- a/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
++++ b/src/sage/rings/polynomial/polynomial_zmod_flint.pyx
+@@ -658,6 +658,11 @@ cdef class Polynomial_zmod_flint(Polynomial_template):
+             ...
+             NotImplementedError: square free factorization of polynomials over rings with composite characteristic is not implemented
+ 
++        :trac:`20003`::
++
++            sage: P.<x> = GF(7)[]
++            sage: (6*x+3).squarefree_decomposition()
++            (6) * (x + 4)
+         """
+         if not self.base_ring().is_field():
+             raise NotImplementedError("square free factorization of polynomials over rings with composite characteristic is not implemented")
+diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
+index 17961ac36b2..8509b19cc66 100644
+--- a/src/sage/rings/real_arb.pyx
++++ b/src/sage/rings/real_arb.pyx
+@@ -898,7 +898,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+             sage: RBF.gamma(5)
+             24.00000000000000
+             sage: RBF.gamma(10**20)
+-            [+/- ...e+1956570552410610660600]
++            [1.932849514310098...+1956570551809674817225 +/- ...]
+             sage: RBF.gamma(1/3)
+             [2.678938534707747 +/- ...e-16]
+             sage: RBF.gamma(-5)
+@@ -1102,7 +1102,7 @@ class RealBallField(UniqueRepresentation, sage.rings.abc.RealBallField):
+              15.00000000000000,
+              48.00000000000000]
+             sage: RBF.double_factorial(2**20)
+-            [1.4483729903e+2928836 +/- ...e+2928825]
++            [1.448372990...e+2928836 +/- ...]
+             sage: RBF.double_factorial(2**1000)
+             Traceback (most recent call last):
+             ...
+diff --git a/src/sage/schemes/plane_conics/con_rational_function_field.py b/src/sage/schemes/plane_conics/con_rational_function_field.py
+index 05d24e78a85..581102b5c5b 100644
+--- a/src/sage/schemes/plane_conics/con_rational_function_field.py
++++ b/src/sage/schemes/plane_conics/con_rational_function_field.py
+@@ -198,38 +198,6 @@ def has_rational_point(self, point=False, algorithm='default',
+             Fraction Field of Univariate Polynomial Ring in u over Rational
+             Field with modulus v^2 - u^3 - 1
+ 
+-        ``has_rational_point`` fails for some conics over function fields
+-        over finite fields, due to :trac:`20003`::
+-
+-            sage: K.<t> = PolynomialRing(GF(7))
+-            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
+-            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
+-            sage: C.has_rational_point()                                                # needs sage.libs.singular
+-            Traceback (most recent call last):
+-            ...
+-            TypeError: self (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (-t^3 + 3*t^2 - 2*t - 2)/(t + 3)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^2 - 3)*x^2 + (t^2 + 3*t + 3)*x*y + (-2*t^2 - 2)*y^2 + (-t^2 + 3*t + 2)*x*z + (-3*t + 3)*y*z + (-3*t^2 + t - 2)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    (x + (2*t - 2)/(t + 3)*y + (3*t^4 + 2*t^3 - 2*t^2 - 2*t + 3)/(t^4 + t^3 - 3*t^2 + 3*t + 1)*z
+-                     : y + (-t^3 - t^2 + 3*t - 1)/(t^3 - 3*t^2 + 2*t + 2)*z : z))
+-            domain must equal right (=Scheme morphism:
+-              From: Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    (-2*t^3 - t^2 + 3*t + 3)*x^2 + (t - 3)*y^2 + (-t^7 + 2*t^5 + t^4 + 2*t^3 + 3*t^2 - t - 1)*z^2
+-              To:   Projective Conic Curve over Fraction Field of Univariate
+-                    Polynomial Ring in t over Finite Field of size 7 defined by
+-                    -2/(t^3 - 3*t^2 + 2*t + 2)*x^2 + 1/(t^3 + 3*t^2 - 2*t + 1)*y^2 + (-t^6 + 3*t^5 + t^3 - t^2 - t + 2)/(t^9 - 2*t^8 + t^7 - t^6 + 3*t^5 - 3*t^3 + t^2 - 2*t + 3)*z^2
+-              Defn: Defined on coordinates by sending (x : y : z) to
+-                    ((t^3 - 3*t^2 + 2*t + 2)*x : (t^2 - 2)*y : (t^5 - 3*t^4 + t^2 + 3*t + 3)*z))
+-            codomain
+-
+-
+-
+         TESTS::
+ 
+             sage: K.<t> = FractionField(PolynomialRing(QQ, 't'))
+@@ -250,6 +218,16 @@ def has_rational_point(self, point=False, algorithm='default',
+             sage: C.has_rational_point(point=True)  # long time (4 seconds)             # needs sage.libs.singular
+             (True,
+              ((-2/117*t^8 + 304/1053*t^7 + 40/117*t^6 - 1/27*t^5 - 110/351*t^4 - 2/195*t^3 + 11/351*t^2 + 1/117)/(t^4 + 2/39*t^3 + 4/117*t^2 + 2/39*t + 14/39) : -5/3*t^4 + 19*t^3 : 1))
++
++        ``has_rational_point`` used to fail for some conics over function fields
++        over finite fields, due to :trac:`20003`::
++
++            sage: K.<t> = PolynomialRing(GF(7))
++            sage: C = Conic([5*t^2 + 4, t^2 + 3*t + 3, 6*t^2 + 3*t + 2,
++            ....:            5*t^2 + 5, 4*t + 3, 4*t^2 + t + 5])
++            sage: C.has_rational_point()
++            True
++
+         """
+         from .constructor import Conic
+ 
+diff --git a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+index a591cb4cd7c..a90f2050c59 100644
+--- a/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
++++ b/src/sage/symbolic/ginac/inifcns_orthopoly.cpp
+@@ -20,6 +20,7 @@
+ #include "utils.h"
+ 
+ #include "gmp.h"
++#include "flint/fmpz_poly.h"
+ #include "flint/fmpq_poly.h"
+ #include "flint/fmpq.h"
+ 
+@@ -63,7 +64,7 @@ static ex chebyt_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+@@ -122,7 +123,7 @@ static ex chebyu_eval(const ex& n_, const ex& x)
+         for (int i = 0; i<len; ++i) {
+                 mpz_t bigint;
+                 mpz_init(bigint);
+-                fmpz_poly_get_coeff_mpz(bigint, p, i);
++                fmpz_get_mpz(bigint, fmpz_poly_get_coeff_ptr(p, i));
+                 numeric coeff(bigint);
+                 if (not coeff.is_zero())
+                         vec.emplace_back(currx, coeff);
+diff --git a/src/sage/symbolic/ginac/useries.cpp b/src/sage/symbolic/ginac/useries.cpp
+index 40fbd7ab360..b9a8b867648 100644
+--- a/src/sage/symbolic/ginac/useries.cpp
++++ b/src/sage/symbolic/ginac/useries.cpp
+@@ -467,10 +467,17 @@ void add::useries(flint_series_t& fp, int order) const
+                 fmpq_poly_set_ui(fp.ft, 0);
+         else if (oc.is_long())
+                 fmpq_poly_set_si(fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ 
+         for (const auto & elem : seq) {
+ 		const ex& t = recombine_pair_to_ex(elem);
+@@ -505,10 +512,17 @@ void mul::useries(flint_series_t& fp, int order) const
+ 
+         if (oc.is_long())
+                 fmpq_poly_scalar_mul_si(fp.ft, fp.ft, oc.to_long());
+-        else if (oc.is_mpz())
+-                fmpq_poly_scalar_mul_mpz(fp.ft, fp.ft, oc.as_mpz());
+-        else
+-                fmpq_poly_scalar_mul_mpq(fp.ft, fp.ft, oc.as_mpq());
++        else if (oc.is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, oc.as_mpz());
++                fmpq_poly_scalar_mul_fmpz(fp.ft, fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, oc.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp.ft, fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ void power::useries(flint_series_t& fp, int order) const
+@@ -563,7 +577,10 @@ void power::useries(flint_series_t& fp, int order) const
+                 }
+                 check_poly_ccoeff_one(fp1);
+                 fmpq_poly_log_series(fp1.ft, fp1.ft, order);
+-                fmpq_poly_scalar_mul_mpq(fp1.ft, fp1.ft, nexp.as_mpq());
++                fmpq_t tmp;
++                fmpq_init_set_readonly(tmp, nexp.as_mpq());
++                fmpq_poly_scalar_mul_fmpq(fp1.ft, fp1.ft, tmp);
++                fmpq_clear_readonly(tmp);
+                 fmpq_poly_exp_series(fp.ft, fp1.ft, order);
+                 return;
+         }
+@@ -608,10 +625,17 @@ void numeric::useries(flint_series_t& fp, int order) const
+ {
+         if (is_long())
+                 fmpq_poly_set_si(fp.ft, to_long());
+-        else if (is_mpz())
+-                fmpq_poly_set_mpz(fp.ft, as_mpz());
+-        else
+-                fmpq_poly_set_mpq(fp.ft, as_mpq());
++        else if (is_mpz()) {
++                fmpz_t tmpfz;
++                fmpz_init_set_readonly(tmpfz, as_mpz());
++                fmpq_poly_set_fmpz(fp.ft, tmpfz);
++                fmpz_clear_readonly(tmpfz);
++        } else {
++                fmpq_t tmpfq;
++                fmpq_init_set_readonly(tmpfq, as_mpq());
++                fmpq_poly_set_fmpq(fp.ft, tmpfq);
++                fmpq_clear_readonly(tmpfq);
++        }
+ }
+ 
+ } // namespace GiNaC
+diff --git a/src/sage_setup/library_order.py b/src/sage_setup/library_order.py
+index f40690f8d22..9ae0d2579a7 100644
+--- a/src/sage_setup/library_order.py
++++ b/src/sage_setup/library_order.py
+@@ -16,17 +16,12 @@
+ 
+ aliases = cython_aliases(required_modules=(), optional_modules=modules)
+ 
+-if "ARB_LIBRARY" in aliases:
+-    arb_dylib_names = [aliases["ARB_LIBRARY"]]
+-else:
+-    arb_dylib_names = []
+-
+ library_order_list = aliases.get("SINGULAR_LIBRARIES", []) + [
+     "giac", "intl", "curl",
+     "ec", "ecm"
+ ] + aliases.get("LINBOX_LIBRARIES", []) + aliases.get("FFLASFFPACK_LIBRARIES", []) + aliases.get("GSL_LIBRARIES", []) + [
+     "pari", "flint", "ecl", "glpk", "ppl",
+-] + arb_dylib_names + [
++] + [
+     "mpfi", "mpfr", "mpc", "ntl", "gmp", "gmpxx",
+     "brial",
+     "brial_groebner",
diff --git a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch b/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
deleted file mode 100644
index 7c55bce6e9bb4..0000000000000
--- a/srcpkgs/sagemath/patches/35934-singular_4.3.2p7.patch
+++ /dev/null
@@ -1,221 +0,0 @@
-diff --git a/build/pkgs/singular/checksums.ini b/build/pkgs/singular/checksums.ini
-index 313463d2fea..1101fc55700 100644
---- a/build/pkgs/singular/checksums.ini
-+++ b/build/pkgs/singular/checksums.ini
-@@ -1,5 +1,5 @@
- tarball=singular-VERSION.tar.gz
--sha1=28bb3ee97ef48d04dfa96de182fd93eebe08426c
--md5=fc0a4f5720dadba45a52ee94324ce00c
--cksum=1573851737
--upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-1/singular-VERSION.tar.gz
-+sha1=df1997f412580f2073295aba569bb955ad227317
-+md5=50349213e206a18cdaa1bc410dde7ea4
-+cksum=376854707
-+upstream_url=ftp://jim.mathematik.uni-kl.de/pub/Math/Singular/SOURCES/4-3-2/singular-VERSION.tar.gz
-diff --git a/build/pkgs/singular/package-version.txt b/build/pkgs/singular/package-version.txt
-index 66e2bede53a..9f1bf008217 100644
---- a/build/pkgs/singular/package-version.txt
-+++ b/build/pkgs/singular/package-version.txt
-@@ -1 +1 @@
--4.3.1p3
-+4.3.2p7
-diff --git a/build/pkgs/singular/spkg-configure.m4 b/build/pkgs/singular/spkg-configure.m4
-index 6a85631f624..f7621ec5fa1 100644
---- a/build/pkgs/singular/spkg-configure.m4
-+++ b/build/pkgs/singular/spkg-configure.m4
-@@ -6,14 +6,27 @@ SAGE_SPKG_CONFIGURE([singular], [
-     AS_IF([test -z "${SINGULAR_BIN}"], [sage_spkg_install_singular=yes], [
-       dnl Use pkg-config to ensure that Singular is new enough.
-       PKG_CHECK_MODULES([SINGULAR], [Singular >= 4.2.1], [
--       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)
--       ], [
--       AC_MSG_RESULT(no)
--       sage_spkg_install_singular=yes
--       ]
--      )], [
-+        AC_MSG_CHECKING([whether Singular is built with FLINT])
-+        AC_COMPILE_IFELSE([
-+          AC_LANG_PROGRAM([
-+            #include <singular/singularconfig.h>
-+            #if !defined(HAVE_FLINT)
-+            #  error "Need Singular compiled with FLINT"
-+          ], [])
-+        ], [
-+          AC_MSG_RESULT([yes])
-+          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)
-+          ], [
-+            AC_MSG_RESULT(no)
-+            sage_spkg_install_singular=yes
-+          ])
-+        ], [
-+          AC_MSG_RESULT([no])
-+          sage_spkg_install_singular=yes
-+        ])
-+      ], [
-       dnl pkg-config version check failed
-       sage_spkg_install_singular=yes
-       ])
-diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py
-index b15cc1c602c..4b5c76e2bfa 100644
---- a/src/sage/interfaces/singular.py
-+++ b/src/sage/interfaces/singular.py
-@@ -604,8 +604,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: i = singular.ideal(['x^2','y^2','z^2'])
-             sage: s = i.std()
-             sage: singular.eval('hilb(%s)'%(s.name()))
--            '// 1 t^0\n// -3 t^2\n// 3 t^4\n// -1 t^6\n\n// 1 t^0\n//
--            3 t^1\n// 3 t^2\n// 1 t^3\n// dimension (affine) = 0\n//
-+            '...// dimension (affine) = 0\n//
-             degree (affine) = 8'
- 
-         ::
-@@ -613,15 +612,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-             sage: from sage.misc.verbose import set_verbose
-             sage: set_verbose(1)
-             sage: o = singular.eval('hilb(%s)'%(s.name()))
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
- 
-         This is mainly useful if this method is called implicitly. Because
-@@ -631,15 +622,7 @@ def eval(self, x, allow_semicolon=True, strip=True, **kwds):
-         ::
- 
-             sage: o = s.hilb()
--            //         1 t^0
--            //        -3 t^2
--            //         3 t^4
--            //        -1 t^6
--            //         1 t^0
--            //         3 t^1
--            //         3 t^2
--            //         1 t^3
--            // dimension (affine) = 0
-+            ...// dimension (affine) = 0
-             // degree (affine)  = 8
-             // ** right side is not a datum, assignment ignored
-             ...
-diff --git a/src/sage/libs/singular/function.pyx b/src/sage/libs/singular/function.pyx
-index f40346d1fd0..c597c63aafe 100644
---- a/src/sage/libs/singular/function.pyx
-+++ b/src/sage/libs/singular/function.pyx
-@@ -1241,32 +1241,22 @@ cdef class SingularFunction(SageObject):
-             sage: I = Ideal([x^3*y^2 + 3*x^2*y^2*z + y^3*z^2 + z^5])
-             sage: I = Ideal(I.groebner_basis())
-             sage: hilb = sage.libs.singular.function_factory.ff.hilb
--            sage: hilb(I) # Singular will print // ** _ is no standard basis
--            // ** _ is no standard basis
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: from sage.misc.sage_ostools import redirection
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I) # Singular will print // ** _ is no standard basis
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            True
- 
-         So we tell Singular that ``I`` is indeed a Groebner basis::
- 
--            sage: hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
--            //         1 t^0
--            //        -1 t^5
--            <BLANKLINE>
--            //         1 t^0
--            //         1 t^1
--            //         1 t^2
--            //         1 t^3
--            //         1 t^4
--            // dimension (proj.)  = 1
--            // degree (proj.)   = 5
-+            sage: out = tmp_filename()
-+            sage: with redirection(sys.stdout,  open(out, 'w')):
-+            ....:     hilb(I,attributes={I:{'isSB':1}}) # no complaint from Singular
-+            sage: with open(out) as f:
-+            ....:     'is no standard basis' in f.read()
-+            False
- 
- 
-         TESTS:
-diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-index 22ada6de947..80352700872 100644
---- a/src/sage/rings/polynomial/multi_polynomial_ideal.py
-+++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py
-@@ -3132,13 +3132,16 @@ def hilbert_numerator(self, grading=None, algorithm='sage'):
-             sage: I.hilbert_numerator()                                                 # needs sage.rings.number_field
-             -t^5 + 1
- 
--        This example returns a wrong answer due to an integer overflow in Singular::
-+        This example returns a wrong answer in singular < 4.3.2p4 due to an integer overflow::
- 
-             sage: n=4; m=11; P = PolynomialRing(QQ, n*m, "x"); x = P.gens(); M = Matrix(n, x)
-             sage: I = P.ideal(M.minors(2))
-             sage: J = P * [m.lm() for m in I.groebner_basis()]
--            sage: J.hilbert_numerator(algorithm='singular')
--            ...120*t^33 - 3465*t^32 + 48180*t^31 - ...
-+            sage: J.hilbert_numerator(algorithm='singular') # known bug
-+            Traceback (most recent call last):
-+            ....
-+            RuntimeError: error in Singular function call 'hilb':
-+            overflow at t^22
- 
-         Our two algorithms should always agree; not tested until
-         :trac:`33178` is fixed::
-diff --git a/src/sage/sandpiles/sandpile.py b/src/sage/sandpiles/sandpile.py
-index 02d2021b2fb..c8e15e06f05 100644
---- a/src/sage/sandpiles/sandpile.py
-+++ b/src/sage/sandpiles/sandpile.py
-@@ -2493,9 +2493,15 @@ def _set_ideal(self):
-             sage: '_ideal' in S.__dict__
-             True
-         """
-+        from sage.libs.singular.function_factory import ff
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
-         R = self.ring()
--        I = self._unsaturated_ideal._singular_()
--        self._ideal = R.ideal(I.sat(prod(R.gens())._singular_())[1])
-+        I = self._unsaturated_ideal
-+        I_sat_gens = sat(I, prod(R.gens()))[0]
-+        self._ideal = R.ideal(I_sat_gens)
- 
-     def unsaturated_ideal(self):
-         r"""
-diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py
-index e6caf19ba74..afd6484d779 100644
---- a/src/sage/schemes/projective/projective_subscheme.py
-+++ b/src/sage/schemes/projective/projective_subscheme.py
-@@ -1001,7 +1001,10 @@ def dual(self):
-         for i in range(n + 1):
-             J = J + S.ideal(z[-1] * f_S.derivative(z[i]) - z[i + n + 1])
- 
--        sat = ff.elim__lib.sat
-+        try:
-+            sat = ff.elim__lib.sat_with_exp
-+        except NameError:
-+            sat = ff.elim__lib.sat
- 
-         max_ideal = S.ideal(z[n + 1: 2 * n + 2])
-         J_sat_gens = sat(J, max_ideal)[0]
diff --git a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch b/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
deleted file mode 100644
index 6a35ec3836550..0000000000000
--- a/srcpkgs/sagemath/patches/36006-gmp_6.3.0.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-diff --git a/src/sage/ext/memory.pyx b/src/sage/ext/memory.pyx
-index 1de6dedab82..b95130b19dd 100644
---- a/src/sage/ext/memory.pyx
-+++ b/src/sage/ext/memory.pyx
-@@ -3,14 +3,14 @@ Low-level memory allocation functions
- 
- TESTS:
- 
--Check that a ``MemoryError`` is raised if we try to allocate a
-+Check that an error is raised if we try to allocate a
- ridiculously large integer, see :trac:`15363`::
- 
--    sage: 2^(2^63-3)
--    Traceback (most recent call last):
--    ...
--    OverflowError: exponent must be at most 2147483647         # 32-bit
--    RuntimeError: Aborted                                      # 64-bit
-+    sage: try:
-+    ....:     2^(2^63-3)
-+    ....: except (OverflowError, RuntimeError, FloatingPointError):
-+    ....:     print ('Overflow error')
-+    ...Overflow error
- 
- AUTHORS:
- 
-diff --git a/src/sage/rings/integer.pyx b/src/sage/rings/integer.pyx
-index d5e87626d31..37ed9364845 100644
---- a/src/sage/rings/integer.pyx
-+++ b/src/sage/rings/integer.pyx
-@@ -6654,7 +6654,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
-             sage: try:
-             ....:     print('Possible error output from gmp', flush=True)
-             ....:     1 << (2^60)
--            ....: except (MemoryError, OverflowError, RuntimeError):
-+            ....: except (MemoryError, OverflowError, RuntimeError, FloatingPointError):
-             ....:     pass
-             ....: else:
-             ....:     print("Failed to raise exception")
diff --git a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch b/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
deleted file mode 100644
index 3d2a4bd9cd96f..0000000000000
--- a/srcpkgs/sagemath/patches/36046-fix_memory_leak.patch
+++ /dev/null
@@ -1,740 +0,0 @@
-diff --git a/src/sage/ext_data/valgrind/valgrind-python.supp b/src/sage/ext_data/valgrind/valgrind-python.supp
-new file mode 100644
-index 00000000000..16aa2858484
---- /dev/null
-+++ b/src/sage/ext_data/valgrind/valgrind-python.supp
-@@ -0,0 +1,480 @@
-+# From the CPython repository with the suppressions for _PyObject_Free
-+# and _PyObject_Realloc enabled. See the upstream suppression file for
-+# details:
-+#
-+# https://github.com/python/cpython/blob/main/Misc/valgrind-python.supp
-+
-+# all tool names: Addrcheck,Memcheck,cachegrind,helgrind,massif
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 8 (x86_64 aka amd64)
-+   Memcheck:Value8
-+   fun:address_in_range
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:address_in_range
-+}
-+
-+#
-+# Leaks (including possible leaks)
-+#    Hmmm, I wonder if this masks some real leaks.  I think it does.
-+#    Will need to fix that.
-+#
-+
-+{
-+   Suppress leaking the GIL after a fork.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_allocate_lock
-+   fun:PyEval_ReInitThreads
-+}
-+
-+{
-+   Suppress leaking the autoTLSkey.  This looks like it shouldn't leak though.
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_create_key
-+   fun:_PyGILState_Init
-+   fun:Py_InitializeEx
-+   fun:Py_Main
-+}
-+
-+{
-+   Hmmm, is this a real leak or like the GIL?
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:PyThread_ReInitTLS
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:realloc
-+   fun:_PyObject_GC_Resize
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_New
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+{
-+   Handle PyMalloc confusing valgrind (possibly leaked)
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:_PyObject_GC_NewVar
-+   fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
-+}
-+
-+#
-+# Non-python specific leaks
-+#
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:calloc
-+   fun:allocate_dtv
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   Handle pthread issue (possibly leaked)
-+   Memcheck:Leak
-+   fun:memalign
-+   fun:_dl_allocate_tls_storage
-+   fun:_dl_allocate_tls
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Free
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Addr4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Invalid read of size 4
-+   Memcheck:Value4
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Addr8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Use of uninitialised value of size 8
-+   Memcheck:Value8
-+   fun:_PyObject_Realloc
-+}
-+
-+{
-+   ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
-+   Memcheck:Cond
-+   fun:_PyObject_Realloc
-+}
-+
-+###
-+### All the suppressions below are for errors that occur within libraries
-+### that Python uses.  The problems to not appear to be related to Python's
-+### use of the libraries.
-+###
-+
-+{
-+   Generic ubuntu ld problems
-+   Memcheck:Addr8
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+   obj:/lib/ld-2.4.so
-+}
-+
-+{
-+   Generic gentoo ld problems
-+   Memcheck:Cond
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+   obj:/lib/ld-2.3.4.so
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_close
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Value8
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   DBM problems, see test_dbm
-+   Memcheck:Cond
-+   fun:memmove
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   obj:/usr/lib/libdb1.so.2
-+   fun:dbm_store
-+   fun:dbm_ass_sub
-+}
-+
-+{
-+   GDBM problems, see test_gdbm
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   fun:gdbm_open
-+
-+}
-+
-+{
-+   Uninitialised byte(s) false alarm, see bpo-35561
-+   Memcheck:Param
-+   epoll_ctl(event)
-+   fun:epoll_ctl
-+   fun:pyepoll_internal_ctl
-+}
-+
-+{
-+   ZLIB problems, see test_gzip
-+   Memcheck:Cond
-+   obj:/lib/libz.so.1.2.3
-+   obj:/lib/libz.so.1.2.3
-+   fun:deflate
-+}
-+
-+{
-+   Avoid problems w/readline doing a putenv and leaking on exit
-+   Memcheck:Leak
-+   fun:malloc
-+   fun:xmalloc
-+   fun:sh_set_lines_and_columns
-+   fun:_rl_get_screen_size
-+   fun:_rl_init_terminal_io
-+   obj:/lib/libreadline.so.4.3
-+   fun:rl_initialize
-+}
-+
-+# Valgrind emits "Conditional jump or move depends on uninitialised value(s)"
-+# false alarms on GCC builtin strcmp() function. The GCC code is correct.
-+#
-+# Valgrind bug: https://bugs.kde.org/show_bug.cgi?id=264936
-+{
-+   bpo-38118: Valgrind emits false alarm on GCC builtin strcmp()
-+   Memcheck:Cond
-+   fun:PyUnicode_Decode
-+}
-+
-+
-+###
-+### These occur from somewhere within the SSL, when running
-+###  test_socket_sll.  They are too general to leave on by default.
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:memset
-+###}
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:memset
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Cond
-+###   fun:MD5_Update
-+###}
-+###
-+###{
-+###   somewhere in SSL stuff
-+###   Memcheck:Value4
-+###   fun:MD5_Update
-+###}
-+
-+# Fedora's package "openssl-1.0.1-0.1.beta2.fc17.x86_64" on x86_64
-+# See http://bugs.python.org/issue14171
-+{
-+   openssl 1.0.1 prng 1
-+   Memcheck:Cond
-+   fun:bcmp
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 2
-+   Memcheck:Cond
-+   fun:fips_get_entropy
-+   fun:FIPS_drbg_instantiate
-+   fun:RAND_init_fips
-+   fun:OPENSSL_init_library
-+   fun:SSL_library_init
-+   fun:init_hashlib
-+}
-+
-+{
-+   openssl 1.0.1 prng 3
-+   Memcheck:Value8
-+   fun:_x86_64_AES_encrypt_compact
-+   fun:AES_encrypt
-+}
-+
-+#
-+# All of these problems come from using test_socket_ssl
-+#
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_bin2bn
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:BN_num_bits_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont_word
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BN_mod_exp_mont
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Param
-+   write(buf)
-+   fun:write
-+   obj:/usr/lib/libcrypto.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:RSA_verify
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_set_key_unchecked
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:DES_encrypt2
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   obj:/usr/lib/libssl.so.0.9.7
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:BUF_MEM_grow_clean
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:memcpy
-+   fun:ssl3_read_bytes
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Cond
-+   fun:SHA1_Update
-+}
-+
-+{
-+   from test_socket_ssl
-+   Memcheck:Value4
-+   fun:SHA1_Update
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_buffer_non_debug
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-+{
-+   wcscmp_false_positive
-+   Memcheck:Addr8
-+   fun:wcscmp
-+   fun:_PyOS_GetOpt
-+   fun:Py_Main
-+   fun:main
-+}
-+
-+# Additional suppressions for the unified decimal tests:
-+{
-+   test_decimal
-+   Memcheck:Addr4
-+   fun:PyUnicodeUCS2_FSConverter
-+}
-+
-+{
-+   test_decimal2
-+   Memcheck:Addr4
-+   fun:PyUnicode_FSConverter
-+}
-+
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index b40ed64edb5..8c55861c147 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -1576,6 +1576,62 @@ const numeric numeric::div(const numeric &other) const {
-         }
- }
- 
-+
-+// Compute `a^b` as an integer, where a is an integer. Assign to ``res``` if it is integral, or return ``false``.
-+// The nonnegative real root is taken for even denominators. To be used inside numeric::integer_rational_power,
-+// to handle the special case of integral ``a``.
-+bool integer_rational_power_of_mpz(
-+        numeric& res,
-+        const numeric& a,
-+        const numeric& b
-+) {
-+        if (a.t != MPZ)
-+                throw std::runtime_error("integer_rational_power_of_mpz: bad input");
-+        mpz_t z;
-+        mpz_init(z);
-+        mpz_set_ui(z, 0);
-+        int sgn = mpz_sgn(a.v._bigint);
-+        if (mpz_cmp_ui(a.v._bigint, 1) == 0
-+            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
-+                mpz_set_ui(z, 1);
-+        else if (sgn == 0) {
-+                res = *_num0_p;
-+                mpz_clear(z);
-+                return true;
-+        }
-+        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1)) {
-+                mpz_clear(z);
-+                return false;
-+        } else {
-+                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-+                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat))) {
-+                        // too big to take roots/powers
-+                        mpz_clear(z);
-+                        return false;
-+                }
-+                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
-+                        if (mpz_perfect_square_p(a.v._bigint)) {
-+                                mpz_sqrt(z, a.v._bigint);
-+                        } else {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                else {
-+                        bool exact = mpz_root(z, a.v._bigint,
-+                                              mpz_get_ui(mpq_denref(b.v._bigrat)));
-+                        if (not exact) {
-+                                mpz_clear(z);
-+                                return false;
-+                        }
-+                }
-+                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
-+        }
-+        res = numeric(z);   // transfers ownership, no mpz_clear
-+        return true;
-+}
-+
-+
- // Compute `a^b` as an integer, if it is integral, or return ``false``.
- // The nonnegative real root is taken for even denominators.
- bool numeric::integer_rational_power(numeric& res,
-@@ -1598,13 +1654,12 @@ bool numeric::integer_rational_power(numeric& res,
-                 if (a.v._long < 0
-                     and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
-                         return false;
--                long z;
-                 if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
-                     or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
-                 // too big to take roots/powers
-                         return false;
-                 if (b.is_equal(*_num1_2_p)) {
--                        z = std::lround(std::sqrt(a.v._long));
-+                        long z = std::lround(std::sqrt(a.v._long));
-                         if (a.v._long == z*z) {
-                                 res = numeric(z);
-                                 return true;
-@@ -1613,44 +1668,11 @@ bool numeric::integer_rational_power(numeric& res,
-                 }
-                 return integer_rational_power(res, a.to_bigint(), b);
-         }
--        if (a.t != MPZ)
--                throw std::runtime_error("integer_rational_power: bad input");
--        int sgn = mpz_sgn(a.v._bigint);
--        mpz_t z;
--        mpz_init(z);
--        mpz_set_ui(z, 0);
--        if (mpz_cmp_ui(a.v._bigint, 1) == 0
--            or mpz_cmp_ui(mpq_numref(b.v._bigrat), 0) == 0)
--                mpz_set_ui(z, 1);
--        else if (sgn == 0) {
--                res = *_num0_p;
--                return true;
--        }
--        else if (sgn < 0 and mpz_cmp_ui(mpq_denref(b.v._bigrat), 1))
--                return false;
--        else {
--                if (not mpz_fits_ulong_p(mpq_numref(b.v._bigrat))
--                    or not mpz_fits_ulong_p(mpq_denref(b.v._bigrat)))
--                // too big to take roots/powers
--                        return false;
--                if (mpz_cmp_ui(mpq_denref(b.v._bigrat), 2) == 0) {
--                        if (mpz_perfect_square_p(a.v._bigint))
--                                mpz_sqrt(z, a.v._bigint);
--                        else
--                                return false;
--                }
--                else {
--                        bool exact = mpz_root(z, a.v._bigint,
--                                        mpz_get_ui(mpq_denref(b.v._bigrat)));
--                        if (not exact)
--                                return false;
--                }
--                mpz_pow_ui(z, z, mpz_get_ui(mpq_numref(b.v._bigrat)));
--        }
--        res = numeric(z);
--        return true;
-+        // otherwise: a is integer
-+        return integer_rational_power_of_mpz(res, a, b);
- }
- 
-+
- // for a^b return c,d such that a^b = c*d^b
- // only for MPZ/MPQ base and MPQ exponent
- void rational_power_parts(const numeric& a_orig, const numeric& b_orig,
-diff --git a/src/sage/tests/memcheck/__init__.py b/src/sage/tests/memcheck/__init__.py
-new file mode 100644
-index 00000000000..e69de29bb2d
-diff --git a/src/sage/tests/memcheck/run_tests.py b/src/sage/tests/memcheck/run_tests.py
-new file mode 100644
-index 00000000000..6ff4503a81b
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests.py
-@@ -0,0 +1,24 @@
-+import types
-+
-+
-+def run_tests() -> None:
-+    """
-+    Run all memcheck tests
-+    """
-+    from sage.tests.memcheck import symbolic_expression
-+    run_tests_in_module(symbolic_expression)
-+
-+
-+def run_tests_in_module(mod: types.ModuleType) -> None:
-+    """
-+    Run all memcheck tests in the given module
-+    """
-+    for entry in dir(mod):
-+        if not entry.startswith('test_'):
-+            continue
-+        test_func = getattr(mod, entry)
-+        test_func()
-+
-+
-+if __name__ == '__main__':
-+    run_tests()
-diff --git a/src/sage/tests/memcheck/run_tests_in_valgrind.py b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-new file mode 100644
-index 00000000000..df5ad0e92b2
---- /dev/null
-+++ b/src/sage/tests/memcheck/run_tests_in_valgrind.py
-@@ -0,0 +1,35 @@
-+"""
-+Launch valgrind and run the memory leak tests
-+
-+
-+From the commandline, run
-+
-+    sage -python -m sage.tests.memcheck.run_tests_in_valgrind
-+
-+to launch valgrind and execute the memory leak tests. Requires valgrind
-+to be installed. Alternatively, run as a unit test:
-+
-+    sage: from sage.tests.memcheck.run_tests_in_valgrind import run_tests_in_valgrind
-+    sage: run_tests_in_valgrind()    # optional - valgrind
-+"""
-+
-+import subprocess
-+
-+
-+def run_tests_in_valgrind() -> None:
-+    """
-+    Run the sage.tests.memcheck.run_tests module inside valgrind
-+    """
-+    subprocess.check_call([
-+        'valgrind',
-+        '--suppressions=src/sage/ext_data/valgrind/valgrind-python.supp',
-+        '--show-possibly-lost=no',
-+        '--show-reachable=no',
-+        './venv/bin/python',
-+        '-m',
-+        'sage.tests.memcheck.run_tests'
-+    ])
-+
-+
-+if __name__ == '__main__':
-+    run_tests_in_valgrind()
-diff --git a/src/sage/tests/memcheck/symbolic_expression.py b/src/sage/tests/memcheck/symbolic_expression.py
-new file mode 100644
-index 00000000000..52182fbe62d
---- /dev/null
-+++ b/src/sage/tests/memcheck/symbolic_expression.py
-@@ -0,0 +1,11 @@
-+from sage.tests.memcheck.verify_no_leak import verify_no_leak
-+
-+
-+def test_sqrt_sqrt_2() -> None:
-+    from sage.misc.functional import sqrt
-+    T2 = sqrt(2)
-+
-+    def sqrt_T2() -> None:
-+        sqrt(T2)
-+
-+    verify_no_leak(sqrt_T2)
-diff --git a/src/sage/tests/memcheck/verify_no_leak.py b/src/sage/tests/memcheck/verify_no_leak.py
-new file mode 100644
-index 00000000000..89ca90cf89c
---- /dev/null
-+++ b/src/sage/tests/memcheck/verify_no_leak.py
-@@ -0,0 +1,27 @@
-+from typing import Tuple, Sequence, List, Callable, Any
-+import valgrind
-+
-+
-+def verify_no_leak(callback: Callable[[], Any],
-+                   repeat: int = 10000,
-+                   fuzzy: int = 10,
-+                   ) -> None:
-+    """
-+    Verify that the callback does not generate new definitely lost blocks
-+
-+    Raises an assertion if the callback leaks memory
-+    """
-+    callback()   # warm_up
-+    initial_blocks = (0, 0, 0, 0)
-+    valgrind.memcheck_do_leak_check()
-+    initial_blocks = valgrind.memcheck_count_leak_blocks()
-+    for _ in range(repeat):
-+        callback()
-+    valgrind.memcheck_do_leak_check()
-+    leak_blocks = valgrind.memcheck_count_leak_blocks()
-+    leak = leak_blocks[0] - initial_blocks[0]
-+    if leak < repeat - fuzzy:
-+        return  # callback did not leak at least once per call
-+    blocks = round(leak / repeat, 2)
-+    message = f'{callback} leaked {blocks} block on average ({repeat} iterations)'
-+    raise AssertionError(message)
diff --git a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch b/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
deleted file mode 100644
index 684b62affaf5a..0000000000000
--- a/srcpkgs/sagemath/patches/36235-ecl_23.9.9.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx
-index 8f46570313d..a8e73e57b52 100644
---- a/src/sage/libs/ecl.pyx
-+++ b/src/sage/libs/ecl.pyx
-@@ -563,15 +563,15 @@ cdef class EclObject:
-     Floats in Python are IEEE double, which LISP has as well. However,
-     the printing of floating point types in LISP depends on settings::
- 
--        sage: a = EclObject(float(10^40))
-+        sage: a = EclObject(float(1.234e40))
-         sage: ecl_eval("(setf *read-default-float-format* 'single-float)")
-         <ECL: SINGLE-FLOAT>
-         sage: a
--        <ECL: 1.d40>
-+        <ECL: 1.234d40>
-         sage: ecl_eval("(setf *read-default-float-format* 'double-float)")
-         <ECL: DOUBLE-FLOAT>
-         sage: a
--        <ECL: 1.e40>
-+        <ECL: 1.234e40>
- 
-     Tuples are translated to dotted lists::
- 
-diff --git a/src/sage/libs/eclsig.h b/src/sage/libs/eclsig.h
-index e249ccf6874..005b2d99d0b 100644
---- a/src/sage/libs/eclsig.h
-+++ b/src/sage/libs/eclsig.h
-@@ -45,7 +45,11 @@ static inline void ecl_sig_off(void)
-     sig_off();
- }
- 
-+#if ECL_VERSION_NUMBER < 230909
- #define ecl_mpz_from_bignum(obj) ((obj)->big.big_num)
-+#else
-+#define ecl_mpz_from_bignum(obj) ecl_bignum(obj)
-+#endif
- 
- cl_object ecl_bignum_from_mpz(mpz_t num)
- {
diff --git a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch b/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
deleted file mode 100644
index e858f2fd4a445..0000000000000
--- a/srcpkgs/sagemath/patches/36279-matplotlib_3.8.0.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff --git a/src/sage/plot/graphics.py b/src/sage/plot/graphics.py
-index 59f10f6b13f..adcccff059b 100644
---- a/src/sage/plot/graphics.py
-+++ b/src/sage/plot/graphics.py
-@@ -36,6 +36,7 @@
- # ****************************************************************************
- 
- import os
-+from numbers import Integral
- from collections.abc import Iterable
- from math import isnan
- import sage.misc.verbose
-@@ -2874,6 +2875,11 @@ def matplotlib(self, filename=None,
-                 weight=lopts.pop('font_weight', 'medium'),
-                 variant=lopts.pop('font_variant', 'normal'))
-             color = lopts.pop('back_color', 'white')
-+            if 'loc' in lopts:
-+                loc = lopts['loc']
-+                if isinstance(loc, Integral):
-+                    # matplotlib 3.8 doesn't support sage integers
-+                    lopts['loc'] = int(loc)
-             leg = subplot.legend(prop=prop, **lopts)
-             if leg is None:
-                 from warnings import warn
diff --git a/srcpkgs/sagemath/patches/36403-00pre.patch b/srcpkgs/sagemath/patches/36403-00pre.patch
deleted file mode 100644
index 060404d5430de..0000000000000
--- a/srcpkgs/sagemath/patches/36403-00pre.patch
+++ /dev/null
@@ -1,29 +0,0 @@
-Minor patch so that #36403 applies cleanly over sagemath 10.1
-
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 2053bca80c3..86aca6e00d8 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15123,7 +15302,8 @@ cdef class Matrix(Matrix1):
-             sage: N.conjugate_transpose()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object has no attribute 'conjugate'
-+            AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
-+            has no attribute 'conjugate'
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 525ea5aa934..52afed49d64 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -55,7 +55,7 @@ cdef class AttributeErrorMessage:
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-         sage: x = polygen(ZZ, 'x')
--        sage: QQ[x].gen().bla                                                           # optional - sage.libs.flint
-+        sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
diff --git a/srcpkgs/sagemath/patches/36407-python_3.12.patch b/srcpkgs/sagemath/patches/36407-python_3.12.patch
deleted file mode 100644
index c75c275c30764..0000000000000
--- a/srcpkgs/sagemath/patches/36407-python_3.12.patch
+++ /dev/null
@@ -1,1744 +0,0 @@
-diff --git a/build/sage_bootstrap/package.py b/build/sage_bootstrap/package.py
-index 15b342223c4..eb82f96e05f 100644
---- a/build/sage_bootstrap/package.py
-+++ b/build/sage_bootstrap/package.py
-@@ -303,7 +303,7 @@ def _init_checksum(self):
-         # Name of the directory containing the checksums.ini file
-         self.__tarball_package_name = os.path.realpath(checksums_ini).split(os.sep)[-2]
- 
--    VERSION_PATCHLEVEL = re.compile('(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
-+    VERSION_PATCHLEVEL = re.compile(r'(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')
- 
-     def _init_version(self):
-         try:
-diff --git a/src/doc/en/thematic_tutorials/coercion_and_categories.rst b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-index bb23331c151..7f5712caea7 100644
---- a/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-+++ b/src/doc/en/thematic_tutorials/coercion_and_categories.rst
-@@ -1223,7 +1223,7 @@ However, only "elementary" construction functors have a rank::
-     sage: (Fract*Poly).rank
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'
-+    AttributeError: 'CompositeConstructionFunctor' object has no attribute 'rank'...
- 
- .. end of output
- 
-diff --git a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-index 553a946c4d8..3cd71a9bad4 100644
---- a/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-+++ b/src/doc/en/thematic_tutorials/tutorial-objects-and-classes.rst
-@@ -318,7 +318,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: e.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__dict__'...
- 
-         sage: id4 = SymmetricGroup(4).one()
-         sage: type(id4)
-@@ -326,7 +326,7 @@ http://docs.python.org/library/ for a complete list. ::
-         sage: id4.__dict__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'
-+        AttributeError: 'sage.groups.perm_gps.permgroup_element.SymmetricGroupElement' object has no attribute '__dict__'...
- 
- .. note::
- 
-diff --git a/src/sage/algebras/cluster_algebra.py b/src/sage/algebras/cluster_algebra.py
-index b72d2a12976..14669dfed5c 100644
---- a/src/sage/algebras/cluster_algebra.py
-+++ b/src/sage/algebras/cluster_algebra.py
-@@ -167,7 +167,7 @@
-     sage: (t*s).g_vector()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'
-+    AttributeError: 'ClusterAlgebra_with_category.element_class' object has no attribute 'g_vector'...
-     sage: A = ClusterAlgebra(['A', 2], principal_coefficients=True)
-     sage: A.explore_to_depth(infinity)
-     sage: s = A.cluster_variable((0, -1)); s
-diff --git a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-index e4a91723558..343ee8a66f9 100644
---- a/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-+++ b/src/sage/algebras/lie_conformal_algebras/weyl_lie_conformal_algebra.py
-@@ -109,7 +109,7 @@ class WeylLieConformalAlgebra(LieConformalAlgebraWithStructureCoefficients):
-         sage: alpha0.degree()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'
-+        AttributeError: 'WeylLieConformalAlgebra_with_category.element_class' object has no attribute 'degree'...
- 
-     TESTS::
- 
-diff --git a/src/sage/algebras/steenrod/steenrod_algebra.py b/src/sage/algebras/steenrod/steenrod_algebra.py
-index 978a3557a9d..7c4d444f81c 100644
---- a/src/sage/algebras/steenrod/steenrod_algebra.py
-+++ b/src/sage/algebras/steenrod/steenrod_algebra.py
-@@ -1080,7 +1080,7 @@ def homogeneous_component(self, n):
-             sage: a.antipode() # not defined
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'
-+            AttributeError: 'CombinatorialFreeModule_with_category.element_class' object has no attribute 'antipode'...
-             sage: A(a).antipode() # convert to elt of A, then compute antipode
-             Sq(2,1) + Sq(5)
- 
-diff --git a/src/sage/all__sagemath_repl.py b/src/sage/all__sagemath_repl.py
-index 8d0b43679ca..c31b206bcb8 100644
---- a/src/sage/all__sagemath_repl.py
-+++ b/src/sage/all__sagemath_repl.py
-@@ -79,6 +79,23 @@
-                         message=r"Use setlocale\(\), getencoding\(\) and getlocale\(\) instead",
-                         module='docutils.io')
- 
-+# triggered by dateutil 2.8.2 and sphinx 7.0.1 on Python 3.12
-+# see: https://github.com/dateutil/dateutil/pull/1285
-+# see: https://github.com/sphinx-doc/sphinx/pull/11468
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"datetime.datetime.utcfromtimestamp\(\) is deprecated",
-+                        module='dateutil.tz.tz|sphinx.(builders.gettext|util.i18n)')
-+
-+# triggered on Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"This process.* is multi-threaded, "
-+                                r"use of .*\(\) may lead to deadlocks in the child.")
-+
-+# pickling of itertools is deprecated in Python 3.12
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+                        message=r"Pickle, copy, and deepcopy support will be "
-+                                r"removed from itertools in Python 3.14.")
-+
- 
- from .all__sagemath_objects import *
- from .all__sagemath_environment import *
-diff --git a/src/sage/arith/long.pxd b/src/sage/arith/long.pxd
-index 0031a0ae337..3ea70cef571 100644
---- a/src/sage/arith/long.pxd
-+++ b/src/sage/arith/long.pxd
-@@ -19,6 +19,8 @@ from libc.limits cimport LONG_MIN, LONG_MAX
- from cpython.object cimport Py_SIZE
- from cpython.number cimport PyNumber_Index, PyIndex_Check
- from cpython.longintrepr cimport py_long, PyLong_SHIFT, digit
-+from sage.cpython.pycore_long cimport (
-+    ob_digit, _PyLong_IsNegative, _PyLong_DigitCount)
- 
- from sage.libs.gmp.mpz cimport mpz_fits_slong_p, mpz_get_si
- from sage.rings.integer_fake cimport is_Integer, Integer_AS_MPZ
-@@ -299,8 +301,11 @@ cdef inline bint integer_check_long_py(x, long* value, int* err):
-         return 0
- 
-     # x is a Python "int" (aka PyLongObject or py_long in cython)
--    cdef const digit* D = (<py_long>x).ob_digit
--    cdef Py_ssize_t size = Py_SIZE(x)
-+    cdef const digit* D = ob_digit(x)
-+    cdef Py_ssize_t size = _PyLong_DigitCount(x)
-+
-+    if _PyLong_IsNegative(x):
-+        size = -size
- 
-     # We assume PyLong_SHIFT <= BITS_IN_LONG <= 3 * PyLong_SHIFT.
-     # This is true in all the default configurations:
-diff --git a/src/sage/categories/category.py b/src/sage/categories/category.py
-index 57ef7f4184b..29bce8ee415 100644
---- a/src/sage/categories/category.py
-+++ b/src/sage/categories/category.py
-@@ -2129,7 +2129,7 @@ def _with_axioms(self, axioms):
-             sage: Semigroups().Inverse()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'
-+            AttributeError: 'Semigroups_with_category' object has no attribute 'Inverse'...
-             sage: Semigroups()._with_axioms(["Inverse"])
-             Category of semigroups
- 
-diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py
-index 5227792e725..4775d4e5bf1 100644
---- a/src/sage/categories/category_with_axiom.py
-+++ b/src/sage/categories/category_with_axiom.py
-@@ -554,7 +554,7 @@ class from the base category class::
-     sage: Magmas.Unital.Associative
-     Traceback (most recent call last):
-     ...
--    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'
-+    AttributeError: type object 'Magmas.Unital' has no attribute 'Associative'...
- 
- The purpose of this section is to explain the design of the code
- layout and the rationale for this mismatch.
-@@ -769,7 +769,7 @@ def _(): return LazyImport('sage.categories.rngs', 'Rngs', at_startup=True)
-     sage: Semirings().NoZeroDivisors()
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'
-+    AttributeError: 'Semirings_with_category' object has no attribute 'NoZeroDivisors'...
- 
- Concretely, this is to be implemented by defining the new axiom in the
- (``SubcategoryMethods`` nested class of the) appropriate category with
-diff --git a/src/sage/categories/enumerated_sets.py b/src/sage/categories/enumerated_sets.py
-index a8bea53f907..b0ea05d0563 100644
---- a/src/sage/categories/enumerated_sets.py
-+++ b/src/sage/categories/enumerated_sets.py
-@@ -610,7 +610,7 @@ def _list_from_iterator(self):
-                 sage: (QQ^2).list()  # indirect test                                    # needs sage.modules
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'
-+                AttributeError: 'FreeModule_ambient_field_with_category' object has no attribute 'list'...
- 
-             Here we test that for an object that does not know whether it
-             is finite or not.  Calling ``x.list()`` simply tries to create
-@@ -622,11 +622,11 @@ def _list_from_iterator(self):
-                 sage: Q.is_finite()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'is_finite'...
-                 sage: Q.list()   # indirect test
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'
-+                AttributeError: 'QuotientRing_generic_with_category' object has no attribute 'list'...
- 
-             Here is another example. We artificially create a version of
-             the ring of integers that does not know whether it is finite
-diff --git a/src/sage/categories/examples/sets_cat.py b/src/sage/categories/examples/sets_cat.py
-index e0853d63f94..fbadb9ca405 100644
---- a/src/sage/categories/examples/sets_cat.py
-+++ b/src/sage/categories/examples/sets_cat.py
-@@ -619,7 +619,7 @@ class PrimeNumbers_Facade(PrimeNumbers_Abstract):
-         sage: pf.next()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'next'...
- 
-     unlike in the other implementations::
- 
-diff --git a/src/sage/categories/homset.py b/src/sage/categories/homset.py
-index 22ba9d047fc..2a8b8aeedeb 100644
---- a/src/sage/categories/homset.py
-+++ b/src/sage/categories/homset.py
-@@ -632,7 +632,7 @@ def __init__(self, X, Y, category=None, base=None, check=True):
-             sage: H = MyHomset(X, Y, category=1, base = ZZ, check = False)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'Homsets'...
-             sage: P.<t> = ZZ[]
-             sage: f = P.hom([1/2*t])
-             sage: f.parent().domain()
-diff --git a/src/sage/categories/modules_with_basis.py b/src/sage/categories/modules_with_basis.py
-index e97bf851388..c4933d0657f 100644
---- a/src/sage/categories/modules_with_basis.py
-+++ b/src/sage/categories/modules_with_basis.py
-@@ -2456,7 +2456,7 @@ def apply_multilinear_morphism(self, f, codomain=None):
-                     sage: tensor([a, b]).apply_multilinear_morphism(f)                  # needs sage.modules
-                     Traceback (most recent call last):
-                     ...
--                    AttributeError: 'int' object has no attribute 'parent'
-+                    AttributeError: 'int' object has no attribute 'parent'...
- 
-                 Here we consider an example where the codomain is a
-                 module with basis with a different base ring::
-diff --git a/src/sage/categories/monoids.py b/src/sage/categories/monoids.py
-index 38dd7248c9d..28474bd17b6 100644
---- a/src/sage/categories/monoids.py
-+++ b/src/sage/categories/monoids.py
-@@ -556,7 +556,7 @@ def algebra_generators(self):
-                     Traceback (most recent call last):
-                     ...
-                     AttributeError: 'IntegerModMonoid_with_category' object
--                    has no attribute 'monoid_generators'
-+                    has no attribute 'monoid_generators'...
-                     sage: Z12.semigroup_generators()
-                     Family (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
-                     sage: Z12.algebra(QQ).algebra_generators()                          # needs sage.modules
-diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py
-index 494e8154c80..ec5120e41e6 100644
---- a/src/sage/combinat/finite_state_machine.py
-+++ b/src/sage/combinat/finite_state_machine.py
-@@ -1835,7 +1835,7 @@ def __getstate__(self):
-             sage: T1.transitions
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'FSMState' object has no attribute 'transitions'
-+            AttributeError: 'FSMState' object has no attribute 'transitions'...
-             sage: A1 = loads(dumps(A))
-             sage: all(A.state(j) == A1.state(j) for j in [0, 1])
-             True
-diff --git a/src/sage/combinat/growth.py b/src/sage/combinat/growth.py
-index cf8d18c1764..766eea37917 100644
---- a/src/sage/combinat/growth.py
-+++ b/src/sage/combinat/growth.py
-@@ -371,7 +371,7 @@
-     sage: GrowthDiagram(RulePascal(), [3,1,2])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'RulePascal' object has no attribute 'forward_rule'
-+    AttributeError: 'RulePascal' object has no attribute 'forward_rule'...
- 
- We now re-implement the rule where we provide the dual graded graphs::
- 
-diff --git a/src/sage/combinat/integer_lists/lists.py b/src/sage/combinat/integer_lists/lists.py
-index 5143e5cb5e8..9117a6076f7 100644
---- a/src/sage/combinat/integer_lists/lists.py
-+++ b/src/sage/combinat/integer_lists/lists.py
-@@ -261,7 +261,7 @@ def __getattr__(self, name):
-             sage: L.foo
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'foo'
-+            AttributeError: 'NoneType' object has no attribute 'foo'...
-         """
-         return getattr(self.backend, name)
- 
-diff --git a/src/sage/combinat/posets/posets.py b/src/sage/combinat/posets/posets.py
-index c31597c72e9..c74bfc67cee 100644
---- a/src/sage/combinat/posets/posets.py
-+++ b/src/sage/combinat/posets/posets.py
-@@ -8825,7 +8825,7 @@ def is_induced_subposet(self, other):
-             sage: Poset().is_induced_subposet('junk')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'subposet'
-+            AttributeError: 'str' object has no attribute 'subposet'...
-         """
-         if (not self._is_facade or (isinstance(other, FinitePoset) and
-                                     not other._is_facade)):
-diff --git a/src/sage/cpython/atexit.pyx b/src/sage/cpython/atexit.pyx
-index 961aa348d0a..e5a82735137 100644
---- a/src/sage/cpython/atexit.pyx
-+++ b/src/sage/cpython/atexit.pyx
-@@ -154,6 +154,10 @@ cdef extern from *:
-     #undef _PyGC_FINALIZED
-     #include "internal/pycore_interp.h"
-     #include "internal/pycore_pystate.h"
-+    #if PY_VERSION_HEX >= 0x030c0000
-+    // struct atexit_callback was renamed in 3.12 to atexit_py_callback
-+    #define atexit_callback atexit_py_callback
-+    #endif
-     static atexit_callback ** _atexit_callbacks(PyObject *self) {
-         PyInterpreterState *interp = _PyInterpreterState_GET();
-         struct atexit_state state = interp->atexit;
-diff --git a/src/sage/cpython/debug.pyx b/src/sage/cpython/debug.pyx
-index 986abff2a99..cdaca3a4854 100644
---- a/src/sage/cpython/debug.pyx
-+++ b/src/sage/cpython/debug.pyx
-@@ -78,7 +78,7 @@ def getattr_debug(obj, name, default=_no_default):
- 
-     EXAMPLES::
- 
--        sage: _ = getattr_debug(list, "reverse")
-+        sage: _ = getattr_debug(list, "reverse")  # not tested - broken in python 3.12
-         getattr_debug(obj=<class 'list'>, name='reverse'):
-           type(obj) = <class 'type'>
-           object has __dict__ slot (<class 'dict'>)
-@@ -123,7 +123,7 @@ def getattr_debug(obj, name, default=_no_default):
-         sage: _ = getattr_debug(1, "foo")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'foo'...
-         sage: _ = getattr_debug(1, "foo", "xyz")
-         getattr_debug(obj=1, name='foo'):
-           type(obj) = <class 'sage.rings.integer.Integer'>
-diff --git a/src/sage/cpython/dict_internal.h b/src/sage/cpython/dict_internal.h
-index 42a57bcb468..a5ee35bc198 100644
---- a/src/sage/cpython/dict_internal.h
-+++ b/src/sage/cpython/dict_internal.h
-@@ -169,6 +169,7 @@ dictkeys_set_index(PyDictKeysObject *keys, Py_ssize_t i, Py_ssize_t ix)
- #else   /* Python >= 3.11 */
- 
- #define Py_BUILD_CORE
-+#undef _PyGC_FINALIZED
- #include <internal/pycore_dict.h>
- 
- /************************************************************/
-diff --git a/src/sage/cpython/getattr.pyx b/src/sage/cpython/getattr.pyx
-index 52afed49d64..1f49e5230c3 100644
---- a/src/sage/cpython/getattr.pyx
-+++ b/src/sage/cpython/getattr.pyx
-@@ -53,12 +53,12 @@ cdef class AttributeErrorMessage:
-         sage: 1.bla  #indirect doctest
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'bla'...
-         sage: x = polygen(ZZ, 'x')
-         sage: QQ[x].gen().bla                                                           # needs sage.libs.flint
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'
-+        AttributeError: 'sage.rings.polynomial.polynomial_rational_flint.Polynomial_rational_flint' object has no attribute 'bla'...
- 
-     ::
- 
-@@ -144,7 +144,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(X, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: x = X()
-         sage: raw_getattr(x, "prop")
-         <property object at ...>
-@@ -173,7 +173,7 @@ cpdef raw_getattr(obj, name):
-         sage: raw_getattr(Y, "attr")
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'attr'
-+        AttributeError: '...' object has no attribute 'attr'...
-         sage: y = Y()
-         sage: raw_getattr(y, "prop")
-         <property object at ...>
-@@ -278,7 +278,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     The integer ring is a parent, so, lazy attributes work::
- 
-@@ -289,7 +289,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(17, A, "lazy_attribute")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute 'lazy_attribute'...
- 
-     In general, descriptors are not yet well supported, because they
-     often do not accept to be cheated with the type of their instance::
-@@ -305,7 +305,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__weakref__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-     This was caught by :trac:`8296` for which we do a couple more tests::
- 
-@@ -314,7 +314,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: 1.__weakref__
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__weakref__'...
- 
-         sage: n = 1
-         sage: ip = get_ipython()                 # not tested: only works in interactive shell
-@@ -329,7 +329,7 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, A, "__call__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__call__'...
- 
-     TESTS:
- 
-@@ -339,14 +339,14 @@ cpdef getattr_from_other_class(self, cls, name):
-         sage: getattr_from_other_class(1, type, "__name__")
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute '__name__'...
- 
-     Non-strings as "name" are handled gracefully::
- 
-         sage: getattr_from_other_class(1, type, None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.integer.Integer' object has no attribute None
-+        AttributeError: 'sage.rings.integer.Integer' object has no attribute None...
-     """
-     if not isinstance(cls, type):
-         raise TypeError(f"{cls!r} is not a type")
-diff --git a/src/sage/cpython/pycore_long.h b/src/sage/cpython/pycore_long.h
-new file mode 100644
-index 00000000000..ff1a73d097a
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.h
-@@ -0,0 +1,98 @@
-+#include "Python.h"
-+#include <stdbool.h>
-+
-+#if PY_VERSION_HEX >= 0x030C00A5
-+#define ob_digit(o)  (((PyLongObject*)o)->long_value.ob_digit)
-+#else
-+#define ob_digit(o)  (((PyLongObject*)o)->ob_digit)
-+#endif
-+
-+#if PY_VERSION_HEX >= 0x030C00A7
-+// taken from cpython:Include/internal/pycore_long.h @ 3.12
-+
-+/* Long value tag bits:
-+ * 0-1: Sign bits value = (1-sign), ie. negative=2, positive=0, zero=1.
-+ * 2: Reserved for immortality bit
-+ * 3+ Unsigned digit count
-+ */
-+#define SIGN_MASK 3
-+#define SIGN_ZERO 1
-+#define SIGN_NEGATIVE 2
-+#define NON_SIZE_BITS 3
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_ZERO;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == SIGN_NEGATIVE;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return (op->long_value.lv_tag & SIGN_MASK) == 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    assert(PyLong_Check(op));
-+    return op->long_value.lv_tag >> NON_SIZE_BITS;
-+}
-+
-+#define TAG_FROM_SIGN_AND_SIZE(sign, size) ((1 - (sign)) | ((size) << NON_SIZE_BITS))
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+    assert(size >= 0);
-+    assert(-1 <= sign && sign <= 1);
-+    assert(sign != 0 || size == 0);
-+    op->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sign, (size_t)size);
-+}
-+
-+#else
-+// fallback for < 3.12
-+
-+static inline bool
-+_PyLong_IsZero(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) == 0;
-+}
-+
-+static inline bool
-+_PyLong_IsNegative(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) < 0;
-+}
-+
-+static inline bool
-+_PyLong_IsPositive(const PyLongObject *op)
-+{
-+    return Py_SIZE(op) > 0;
-+}
-+
-+static inline Py_ssize_t
-+_PyLong_DigitCount(const PyLongObject *op)
-+{
-+    Py_ssize_t size = Py_SIZE(op);
-+    return size < 0 ? -size : size;
-+}
-+
-+static inline void
-+_PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
-+{
-+#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION < 9)
-+// The function Py_SET_SIZE is defined starting with python 3.9.
-+    Py_SIZE(o) = size;
-+#else
-+    Py_SET_SIZE(op, sign < 0 ? -size : size);
-+#endif
-+}
-+
-+#endif
-diff --git a/src/sage/cpython/pycore_long.pxd b/src/sage/cpython/pycore_long.pxd
-new file mode 100644
-index 00000000000..41de637ff18
---- /dev/null
-+++ b/src/sage/cpython/pycore_long.pxd
-@@ -0,0 +1,9 @@
-+from cpython.longintrepr cimport py_long, digit
-+
-+cdef extern from "pycore_long.h":
-+    digit* ob_digit(py_long o)
-+    bint _PyLong_IsZero(py_long o)
-+    bint _PyLong_IsNegative(py_long o)
-+    bint _PyLong_IsPositive(py_long o)
-+    Py_ssize_t _PyLong_DigitCount(py_long o)
-+    void _PyLong_SetSignAndDigitCount(py_long o, int sign, Py_ssize_t size)
-diff --git a/src/sage/crypto/classical.py b/src/sage/crypto/classical.py
-index 616dc861652..be899c781e5 100644
---- a/src/sage/crypto/classical.py
-+++ b/src/sage/crypto/classical.py
-@@ -494,7 +494,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: A.rank_by_chi_square("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_chi_square(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -703,7 +703,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: A.rank_by_squared_differences("", Plist)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: A.rank_by_squared_differences(A.encoding(""), Plist)
-             Traceback (most recent call last):
-             ...
-@@ -2114,7 +2114,7 @@ def rank_by_chi_square(self, C, pdict):
-             sage: S.rank_by_chi_square("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_chi_square(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-@@ -2351,7 +2351,7 @@ def rank_by_squared_differences(self, C, pdict):
-             sage: S.rank_by_squared_differences("", Pdict)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'parent'
-+            AttributeError: 'str' object has no attribute 'parent'...
-             sage: S.rank_by_squared_differences(S.encoding(""), Pdict)
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/crypto/mq/mpolynomialsystemgenerator.py b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-index 9028dab1d98..4416d9ef7f6 100644
---- a/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-+++ b/src/sage/crypto/mq/mpolynomialsystemgenerator.py
-@@ -156,7 +156,7 @@ def sbox(self):
-             sage: msg.sbox()
-             Traceback (most recent call last):
-             ...
--            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'
-+            AttributeError: '<class 'sage.crypto.mq.mpolynomialsystemgenerator.MPolynomialSystemGenerator'>' object has no attribute '_sbox'...
-         """
-         return self._sbox
- 
-diff --git a/src/sage/data_structures/bitset.pyx b/src/sage/data_structures/bitset.pyx
-index 446062554c1..d9906b5edd2 100644
---- a/src/sage/data_structures/bitset.pyx
-+++ b/src/sage/data_structures/bitset.pyx
-@@ -967,7 +967,7 @@ cdef class FrozenBitset:
-             sage: None | FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute '_union'
-+            AttributeError: 'NoneType' object has no attribute '_union'...
-         """
-         return self._union(other)
- 
-@@ -1037,7 +1037,7 @@ cdef class FrozenBitset:
-             sage: None & FrozenBitset("101011")
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'intersection'
-+            AttributeError: 'NoneType' object has no attribute 'intersection'...
-         """
-         return self.intersection(other)
- 
-@@ -1106,7 +1106,7 @@ cdef class FrozenBitset:
-             sage: None - FrozenBitset('10101')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'difference'
-+            AttributeError: 'NoneType' object has no attribute 'difference'...
-         """
-         return self.difference(other)
- 
-@@ -1179,7 +1179,7 @@ cdef class FrozenBitset:
-             sage: None ^^ FrozenBitset('11111' * 10)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'
-+            AttributeError: 'NoneType' object has no attribute 'symmetric_difference'...
-         """
-         return self.symmetric_difference(other)
- 
-diff --git a/src/sage/doctest/reporting.py b/src/sage/doctest/reporting.py
-index 361fea344c2..a3947c07e01 100644
---- a/src/sage/doctest/reporting.py
-+++ b/src/sage/doctest/reporting.py
-@@ -368,7 +368,7 @@ def report(self, source, timeout, return_code, results, output, pid=None):
-             sage: DTR.report(None, None, None, None, None)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NoneType' object has no attribute 'basename'
-+            AttributeError: 'NoneType' object has no attribute 'basename'...
- 
-         The only-errors mode does not output anything on success::
- 
-diff --git a/src/sage/dynamics/finite_dynamical_system.py b/src/sage/dynamics/finite_dynamical_system.py
-index e5fbf568b7e..4295070615a 100644
---- a/src/sage/dynamics/finite_dynamical_system.py
-+++ b/src/sage/dynamics/finite_dynamical_system.py
-@@ -240,7 +240,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-@@ -252,7 +252,7 @@ class DiscreteDynamicalSystem(SageObject, metaclass=ClasscallMetaclass):
-         sage: D.inverse_evolution()(4)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'
-+        AttributeError: 'DiscreteDynamicalSystem' object has no attribute 'inverse_evolution'...
-         sage: D.orbit(3)
-         [3, 5, 1]
- 
-diff --git a/src/sage/geometry/cone.py b/src/sage/geometry/cone.py
-index f0a8620011a..53f78a4b7b6 100644
---- a/src/sage/geometry/cone.py
-+++ b/src/sage/geometry/cone.py
-@@ -340,7 +340,7 @@ def Cone(rays, lattice=None, check=True, normalize=True):
-         sage: Cone([(1,0), (0,1)], check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     You can construct different "not" cones: not full-dimensional, not
-     strictly convex, not containing any rays::
-diff --git a/src/sage/geometry/fan.py b/src/sage/geometry/fan.py
-index 258544012fe..3aecc84a55b 100644
---- a/src/sage/geometry/fan.py
-+++ b/src/sage/geometry/fan.py
-@@ -443,7 +443,7 @@ def Fan(cones, rays=None, lattice=None, check=True, normalize=True,
-         sage: P2c = Fan(cones, rays, check=False, normalize=False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'tuple' object has no attribute 'parent'
-+        AttributeError: 'tuple' object has no attribute 'parent'...
- 
-     Yet another way is to use functions :func:`FaceFan` and :func:`NormalFan`
-     to construct fans from :class:`lattice polytopes
-diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-index f0ac1e774a7..f03f0f832ff 100644
---- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-+++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx
-@@ -351,7 +351,7 @@ cdef class FaceIterator_base(SageObject):
-             sage: FaceIterator_base(2)  # indirect doctest
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'combinatorial_polyhedron'...
-         """
-         cdef int i
-         sig_free(self.structure.atom_rep)
-@@ -1945,7 +1945,8 @@ cdef inline int next_face_loop(iter_t structure) nogil except -1:
-         # The function is not supposed to be called,
-         # just prevent it from crashing.
-         # Actually raising an error here results in a bad branch prediction.
--        return -1
-+        # But return -1 results in a crash with python 3.12
-+        raise StopIteration
- 
-     # Getting ``[faces, n_faces, n_visited_all]`` according to dimension.
-     cdef face_list_t* faces = &structure.new_faces[structure.current_dimension]
-diff --git a/src/sage/geometry/toric_plotter.py b/src/sage/geometry/toric_plotter.py
-index 50b4008eb0f..950e3ba7ff8 100644
---- a/src/sage/geometry/toric_plotter.py
-+++ b/src/sage/geometry/toric_plotter.py
-@@ -706,7 +706,7 @@ def set_rays(self, generators):
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ToricPlotter' object has no attribute 'rays'
-+            AttributeError: 'ToricPlotter' object has no attribute 'rays'...
-             sage: tp.set_rays([(0,1)])
-             sage: tp.plot_rays()                                                        # needs sage.plot
-             Graphics object consisting of 2 graphics primitives
-diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
-index d0ec214bb3b..c8098ad578a 100644
---- a/src/sage/groups/matrix_gps/finitely_generated.py
-+++ b/src/sage/groups/matrix_gps/finitely_generated.py
-@@ -268,7 +268,7 @@ def MatrixGroup(*gens, **kwds):
-         sage: SL2C.gens()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'
-+        AttributeError: 'LinearMatrixGroup_generic_with_category' object has no attribute 'gens'...
-     """
-     if isinstance(gens[-1], dict):   # hack for unpickling
-         kwds.update(gens[-1])
-diff --git a/src/sage/homology/chains.py b/src/sage/homology/chains.py
-index 87c0947c0b0..b9a54940943 100644
---- a/src/sage/homology/chains.py
-+++ b/src/sage/homology/chains.py
-@@ -298,7 +298,7 @@ def is_cycle(self):
-                 sage: chain.is_cocycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_cocycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -325,7 +325,7 @@ def is_boundary(self):
-                 sage: chain.is_coboundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'is_coboundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -539,7 +539,7 @@ def is_cocycle(self):
-                 sage: cochain.is_cycle()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_cycle'...
-             """
-             return self.to_complex().is_cycle()
- 
-@@ -566,7 +566,7 @@ def is_coboundary(self):
-                 sage: cochain.is_boundary()
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'
-+                AttributeError: 'Cochains_with_category.element_class' object has no attribute 'is_boundary'...
-             """
-             return self.to_complex().is_boundary()
- 
-@@ -604,7 +604,7 @@ def eval(self, other):
-                 sage: z.eval(c) # z is not a cochain
-                 Traceback (most recent call last):
-                 ...
--                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'
-+                AttributeError: 'Chains_with_category.element_class' object has no attribute 'eval'...
-                 sage: c.eval(c) # can't evaluate a cochain on a cochain
-                 Traceback (most recent call last):
-                 ...
-diff --git a/src/sage/homology/free_resolution.py b/src/sage/homology/free_resolution.py
-index e3d38de4240..280a479b438 100644
---- a/src/sage/homology/free_resolution.py
-+++ b/src/sage/homology/free_resolution.py
-@@ -275,7 +275,7 @@ def differential(self, i):
-             sage: FreeResolution.differiental(r, 1)
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'FreeResolution' has no attribute 'differiental'
-+            AttributeError: type object 'FreeResolution' has no attribute 'differiental'...
-         """
- 
-     def target(self):
-diff --git a/src/sage/interfaces/magma.py b/src/sage/interfaces/magma.py
-index b7a0ac20d03..529bfbc349b 100644
---- a/src/sage/interfaces/magma.py
-+++ b/src/sage/interfaces/magma.py
-@@ -824,7 +824,7 @@ def _coerce_from_special_method(self, x):
-             sage: magma._coerce_from_special_method('2 + 3')  # optional - magma
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute '_magma_init_'
-+            AttributeError: 'str' object has no attribute '_magma_init_'...
-         """
-         s = x._magma_init_(self)
-         a = self(s)
-diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
-index 58499396d6c..16119d20815 100644
---- a/src/sage/lfunctions/dokchitser.py
-+++ b/src/sage/lfunctions/dokchitser.py
-@@ -418,8 +418,8 @@ def init_coeffs(self, v, cutoff=1,
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
-index bbf289aa21c..e4968866303 100644
---- a/src/sage/lfunctions/pari.py
-+++ b/src/sage/lfunctions/pari.py
-@@ -141,8 +141,8 @@ def init_coeffs(self, v, cutoff=None, w=1):
-             sage: L(14)
-             0.998583063162746
-             sage: a = delta_qexp(1000)
--            sage: sum(a[n]/float(n)^14 for n in range(1,1000))
--            0.9985830631627459
-+            sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000)))
-+            0.9985830631627461
- 
-         Illustrate that one can give a list of complex numbers for v
-         (see :trac:`10937`)::
-diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
-index 478caf9f9d0..363024ae281 100644
---- a/src/sage/libs/gap/element.pyx
-+++ b/src/sage/libs/gap/element.pyx
-@@ -380,7 +380,7 @@ cdef GapElement make_GapElement(parent, Obj obj):
-         sage: libgap(None)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute '_libgap_init_'
-+        AttributeError: 'NoneType' object has no attribute '_libgap_init_'...
-     """
-     cdef GapElement r = GapElement.__new__(GapElement)
-     r._initialize(parent, obj)
-diff --git a/src/sage/libs/gmp/pylong.pxd b/src/sage/libs/gmp/pylong.pxd
-index a73f1da6d6f..84e1bb8cd87 100644
---- a/src/sage/libs/gmp/pylong.pxd
-+++ b/src/sage/libs/gmp/pylong.pxd
-@@ -2,9 +2,10 @@
- Various functions to deal with conversion mpz <-> Python int/long
- """
- 
-+from cpython.longintrepr cimport py_long
- from sage.libs.gmp.types cimport *
- 
- cdef mpz_get_pylong(mpz_srcptr z)
- cdef mpz_get_pyintlong(mpz_srcptr z)
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1
- cdef Py_hash_t mpz_pythonhash(mpz_srcptr z)
-diff --git a/src/sage/libs/gmp/pylong.pyx b/src/sage/libs/gmp/pylong.pyx
-index d5993cca5a5..1a36c29d3fa 100644
---- a/src/sage/libs/gmp/pylong.pyx
-+++ b/src/sage/libs/gmp/pylong.pyx
-@@ -28,6 +28,8 @@ AUTHORS:
- from cpython.object cimport Py_SIZE
- from cpython.long cimport PyLong_FromLong
- from cpython.longintrepr cimport _PyLong_New, py_long, digit, PyLong_SHIFT
-+from sage.cpython.pycore_long cimport (ob_digit, _PyLong_IsNegative,
-+    _PyLong_DigitCount, _PyLong_SetSignAndDigitCount)
- from .mpz cimport *
- 
- cdef extern from *:
-@@ -60,12 +62,9 @@ cdef mpz_get_pylong_large(mpz_srcptr z):
-     """
-     cdef size_t nbits = mpz_sizeinbase(z, 2)
-     cdef size_t pylong_size = (nbits + PyLong_SHIFT - 1) // PyLong_SHIFT
--    L = _PyLong_New(pylong_size)
--    mpz_export(L.ob_digit, NULL,
--            -1, sizeof(digit), 0, PyLong_nails, z)
--    if mpz_sgn(z) < 0:
--        # Set correct size
--        Py_SET_SIZE(L, -pylong_size)
-+    cdef py_long L = _PyLong_New(pylong_size)
-+    mpz_export(ob_digit(L), NULL, -1, sizeof(digit), 0, PyLong_nails, z)
-+    _PyLong_SetSignAndDigitCount(L, mpz_sgn(z), pylong_size)
-     return L
- 
- 
-@@ -88,16 +87,13 @@ cdef mpz_get_pyintlong(mpz_srcptr z):
-     return mpz_get_pylong_large(z)
- 
- 
--cdef int mpz_set_pylong(mpz_ptr z, L) except -1:
-+cdef int mpz_set_pylong(mpz_ptr z, py_long L) except -1:
-     """
-     Convert a Python ``long`` `L` to an ``mpz``.
-     """
--    cdef Py_ssize_t pylong_size = Py_SIZE(L)
--    if pylong_size < 0:
--        pylong_size = -pylong_size
--    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails,
--            (<py_long>L).ob_digit)
--    if Py_SIZE(L) < 0:
-+    cdef Py_ssize_t pylong_size = _PyLong_DigitCount(L)
-+    mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails, ob_digit(L))
-+    if _PyLong_IsNegative(L):
-         mpz_neg(z, z)
- 
- 
-diff --git a/src/sage/manifolds/calculus_method.py b/src/sage/manifolds/calculus_method.py
-index f5830c0bc45..303dde6cd13 100644
---- a/src/sage/manifolds/calculus_method.py
-+++ b/src/sage/manifolds/calculus_method.py
-@@ -257,7 +257,7 @@ def simplify(self, expression, method=None):
-             sage: cm.simplify(f)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'
-+            AttributeError: 'sage.symbolic.expression.Expression' object has no attribute 'combsimp'...
- 
-         In the present case, one should either transform ``f`` to a SymPy
-         object::
-diff --git a/src/sage/manifolds/differentiable/vectorfield_module.py b/src/sage/manifolds/differentiable/vectorfield_module.py
-index d954b5d4839..af4bfb0ceec 100644
---- a/src/sage/manifolds/differentiable/vectorfield_module.py
-+++ b/src/sage/manifolds/differentiable/vectorfield_module.py
-@@ -885,7 +885,7 @@ def tensor(self, *args, **kwds):
-             sage: XM.tensor(XM).tensor(XM.dual().tensor(XM.dual()))
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'
-+            AttributeError: 'TensorFieldModule_with_category' object has no attribute '_basis_sym'...
- 
-         .. SEEALSO::
- 
-diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx
-index 86aca6e00d8..a5f6716e731 100644
---- a/src/sage/matrix/matrix2.pyx
-+++ b/src/sage/matrix/matrix2.pyx
-@@ -15303,7 +15303,7 @@ cdef class Matrix(Matrix1):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.rings.finite_rings.integer_mod.IntegerMod_int' object
--            has no attribute 'conjugate'
-+            has no attribute 'conjugate'...
-         """
-         # limited testing on a 1000 x 1000 matrix over CC:
-         #   transpose is fast, conjugate is slow
-diff --git a/src/sage/matrix/matrix_cyclo_dense.pyx b/src/sage/matrix/matrix_cyclo_dense.pyx
-index f54f3423ded..a49bb6240e6 100644
---- a/src/sage/matrix/matrix_cyclo_dense.pyx
-+++ b/src/sage/matrix/matrix_cyclo_dense.pyx
-@@ -847,7 +847,7 @@ cdef class Matrix_cyclo_dense(Matrix_dense):
-             sage: A.set_mutable()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'
-+            AttributeError: 'sage.matrix.matrix_cyclo_dense.Matrix_cyclo_dense' object has no attribute 'set_mutable'...
-             sage: B = A.__copy__()
-             sage: B[0,0] = 20
-             sage: B[0,0]
-diff --git a/src/sage/matrix/matrix_gfpn_dense.pyx b/src/sage/matrix/matrix_gfpn_dense.pyx
-index 4cccf473de1..8e8e4d7336b 100644
---- a/src/sage/matrix/matrix_gfpn_dense.pyx
-+++ b/src/sage/matrix/matrix_gfpn_dense.pyx
-@@ -159,7 +159,7 @@ cdef class FieldConverter_class:
-             sage: C.field_to_fel('foo')
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'str' object has no attribute 'to_integer'
-+            AttributeError: 'str' object has no attribute 'to_integer'...
-         """
-         return FfFromInt(x.to_integer())
- 
-diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py
-index 6aab58352be..b5e6f52349b 100644
---- a/src/sage/matrix/matrix_space.py
-+++ b/src/sage/matrix/matrix_space.py
-@@ -1619,7 +1619,7 @@ def __getitem__(self, x):
-             sage: MS[2]
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'
-+            AttributeError: 'MatrixSpace_with_category' object has no attribute 'list'...
-         """
-         if isinstance(x, (integer.Integer, int)):
-             return self.list()[x]
-diff --git a/src/sage/matroids/lean_matrix.pyx b/src/sage/matroids/lean_matrix.pyx
-index 54c68e637c0..a137cbf70e5 100644
---- a/src/sage/matroids/lean_matrix.pyx
-+++ b/src/sage/matroids/lean_matrix.pyx
-@@ -1,5 +1,4 @@
- # sage.doctest: optional - sage.rings.finite_rings
--# cython: profile=True
- """
- Lean matrices
- 
-diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx
-index 36f563aa433..318c82f2b64 100644
---- a/src/sage/matroids/linear_matroid.pyx
-+++ b/src/sage/matroids/linear_matroid.pyx
-@@ -1134,7 +1134,7 @@ cdef class LinearMatroid(BasisExchangeMatroid):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'sage.matroids.basis_matroid.BasisMatroid' object
--            has no attribute 'base_ring'
-+            has no attribute 'base_ring'...
-             sage: from sage.matroids.advanced import *
-             sage: M4 = BinaryMatroid(Matrix(M1))
-             sage: M5 = LinearMatroid(reduced_matrix=Matrix(GF(2), [[-1, 0, 1],
-diff --git a/src/sage/misc/dev_tools.py b/src/sage/misc/dev_tools.py
-index e7bf176592c..3ece7db2894 100644
---- a/src/sage/misc/dev_tools.py
-+++ b/src/sage/misc/dev_tools.py
-@@ -171,6 +171,7 @@ def load_submodules(module=None, exclude_pattern=None):
-         load sage.geometry.polyhedron.ppl_lattice_polygon... succeeded
-     """
-     from .package_dir import walk_packages
-+    import importlib.util
- 
-     if module is None:
-         import sage
-@@ -194,8 +195,12 @@ def load_submodules(module=None, exclude_pattern=None):
-         try:
-             sys.stdout.write("load %s..." % module_name)
-             sys.stdout.flush()
--            loader = importer.find_module(module_name)
--            loader.load_module(module_name)
-+            # see
-+            # https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly
-+            spec = importer.find_spec(module_name)
-+            module = importlib.util.module_from_spec(spec)
-+            sys.modules[module_name] = module
-+            spec.loader.exec_module(module)
-             sys.stdout.write(" succeeded\n")
-         except (ValueError, AttributeError, TypeError, ImportError):
-             # we might get error because of cython code that has been
-diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py
-index c922b8f6f12..03697f08b7c 100644
---- a/src/sage/misc/functional.py
-+++ b/src/sage/misc/functional.py
-@@ -86,7 +86,7 @@ def base_field(x):
-         sage: R.base_field()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'
-+        AttributeError: 'PolynomialRing_dense_mod_p_with_category' object has no attribute 'base_field'...
-     """
-     try:
-         return x.base_field()
-diff --git a/src/sage/misc/instancedoc.pyx b/src/sage/misc/instancedoc.pyx
-index d8e1e4ac536..44ee70f64ba 100644
---- a/src/sage/misc/instancedoc.pyx
-+++ b/src/sage/misc/instancedoc.pyx
-@@ -256,7 +256,7 @@ cdef class InstanceDocDescriptor:
-             sage: descr.__delete__(obj)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'X' object has no attribute '__doc__'
-+            AttributeError: 'X' object has no attribute '__doc__'...
- 
-             sage: descr.__delete__([])
-             Traceback (most recent call last):
-diff --git a/src/sage/misc/lazy_attribute.pyx b/src/sage/misc/lazy_attribute.pyx
-index bdbec3b3ba1..1f07870b8ec 100644
---- a/src/sage/misc/lazy_attribute.pyx
-+++ b/src/sage/misc/lazy_attribute.pyx
-@@ -441,37 +441,37 @@ class lazy_attribute(_lazy_attribute):
-             sage: B().unimplemented_A # todo: not implemented
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'super' object has no attribute 'unimplemented_A'
-+            AttributeError: 'super' object has no attribute 'unimplemented_A'...
- 
-     We now make some systematic checks::
- 
-         sage: B().unimplemented_A
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: B().unimplemented_B
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: B().unimplemented_AB
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: B().unimplemented_B_implemented_A
-         1
- 
-         sage: C().unimplemented_A()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_A'
-+        AttributeError: '...' object has no attribute 'unimplemented_A'...
-         sage: C().unimplemented_B()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_B'
-+        AttributeError: '...' object has no attribute 'unimplemented_B'...
-         sage: C().unimplemented_AB()
-         Traceback (most recent call last):
-         ...
--        AttributeError: '...' object has no attribute 'unimplemented_AB'
-+        AttributeError: '...' object has no attribute 'unimplemented_AB'...
-         sage: C().unimplemented_B_implemented_A # todo: not implemented
-         1
-     """
-diff --git a/src/sage/misc/object_multiplexer.py b/src/sage/misc/object_multiplexer.py
-index d4e811ef16e..00fd89d6652 100644
---- a/src/sage/misc/object_multiplexer.py
-+++ b/src/sage/misc/object_multiplexer.py
-@@ -85,7 +85,7 @@ def __getattr__(self, name):
-             sage: m.__bork__
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Multiplex' has no attribute '__bork__'
-+            AttributeError: 'Multiplex' has no attribute '__bork__'...
-         """
-         if name.startswith("__"):
-             raise AttributeError("'Multiplex' has no attribute '%s'" % name)
-diff --git a/src/sage/misc/sage_input.py b/src/sage/misc/sage_input.py
-index 66e78ecccbc..00e8d96ee9e 100644
---- a/src/sage/misc/sage_input.py
-+++ b/src/sage/misc/sage_input.py
-@@ -3461,7 +3461,7 @@ def verify_same(a, b):
-         sage: verify_same(1, 1r)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_same(1r, 1)
-         Traceback (most recent call last):
-         ...
-@@ -3525,7 +3525,7 @@ def verify_si_answer(x, answer, preparse):
-         sage: verify_si_answer(1, '1', False)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'int' object has no attribute 'parent'
-+        AttributeError: 'int' object has no attribute 'parent'...
-         sage: verify_si_answer(1, 'ZZ(1)', None)
-     """
-     from sage.misc.sage_eval import sage_eval
-diff --git a/src/sage/misc/sageinspect.py b/src/sage/misc/sageinspect.py
-index f0545be7d81..811afc48755 100644
---- a/src/sage/misc/sageinspect.py
-+++ b/src/sage/misc/sageinspect.py
-@@ -602,7 +602,7 @@ def visit_Num(self, node):
-             On Python 3 negative numbers are parsed first, for some reason, as
-             a UnaryOp node.
-         """
--        return node.n
-+        return node.value
- 
-     def visit_Str(self, node):
-         r"""
-@@ -624,7 +624,7 @@ def visit_Str(self, node):
-             sage: [vis(s) for s in ['"abstract"', "'syntax'", r'''r"tr\ee"''']]
-             ['abstract', 'syntax', 'tr\\ee']
-         """
--        return node.s
-+        return node.value
- 
-     def visit_List(self, node):
-         """
-diff --git a/src/sage/modules/fp_graded/steenrod/module.py b/src/sage/modules/fp_graded/steenrod/module.py
-index 18460b0e9a1..4acfa6b4002 100755
---- a/src/sage/modules/fp_graded/steenrod/module.py
-+++ b/src/sage/modules/fp_graded/steenrod/module.py
-@@ -70,7 +70,7 @@
-     sage: SteenrodFPModule(ZZ, [0])
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'
-+    AttributeError: 'sage.rings.integer_ring.IntegerRing_class' object has no attribute 'free_graded_module'...
- 
- AUTHORS:
- 
-diff --git a/src/sage/monoids/trace_monoid.py b/src/sage/monoids/trace_monoid.py
-index 00baa4d14f8..f8176a1e1f2 100644
---- a/src/sage/monoids/trace_monoid.py
-+++ b/src/sage/monoids/trace_monoid.py
-@@ -40,7 +40,6 @@
- #                  https://www.gnu.org/licenses/
- # ****************************************************************************
- 
--from collections import OrderedDict
- from itertools import repeat, chain, product
- 
- from sage.misc.cachefunc import cached_method
-@@ -633,14 +632,14 @@ def _compute_dependence_stack(self, x):
-             sage: x = b*a*d*a*c*b
-             sage: M._compute_dependence_stack(x)
-             ({a, b, c, d},
--             OrderedDict([(a, [False, False, True, True, False]),
--                          (b, [True, False, False, False, True]),
--                          (c, [True, False, False, False]),
--                          (d, [False, False, True, False])]))
-+             {a: [False, False, True, True, False],
-+              b: [True, False, False, False, True],
-+              c: [True, False, False, False],
-+              d: [False, False, True, False]})
-         """
-         independence = self._independence
-         generators_set = set(e for e, _ in x)
--        stacks = OrderedDict(sorted((g, []) for g in generators_set))
-+        stacks = dict(sorted((g, []) for g in generators_set))
-         for generator, times in reversed(list(x)):
-             stacks[generator].extend(repeat(True, times))
-             for other_gen in generators_set:
-diff --git a/src/sage/parallel/map_reduce.py b/src/sage/parallel/map_reduce.py
-index 11e0673ee91..5441943731d 100644
---- a/src/sage/parallel/map_reduce.py
-+++ b/src/sage/parallel/map_reduce.py
-@@ -1234,7 +1234,7 @@ def finish(self):
-             sage: S.print_communication_statistics()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'RESetMPExample' object has no attribute '_stats'
-+            AttributeError: 'RESetMPExample' object has no attribute '_stats'...
- 
-             sage: S.finish()
- 
-diff --git a/src/sage/plot/colors.py b/src/sage/plot/colors.py
-index 8c0db2b3c34..3281199400b 100644
---- a/src/sage/plot/colors.py
-+++ b/src/sage/plot/colors.py
-@@ -1099,7 +1099,7 @@ def __getattr__(self, name):
-             sage: cols.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'ColorsDict' has no attribute or colormap punk
-+            AttributeError: 'ColorsDict' has no attribute or colormap punk...
-         """
-         try:
-             return self[name]
-@@ -1599,7 +1599,7 @@ def __getattr__(self, name):
-             sage: maps.punk
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Colormaps' has no attribute or colormap punk
-+            AttributeError: 'Colormaps' has no attribute or colormap punk...
-             sage: maps['punk']
-             Traceback (most recent call last):
-             ...
-diff --git a/src/sage/rings/asymptotic/asymptotic_ring.py b/src/sage/rings/asymptotic/asymptotic_ring.py
-index b07319382d3..994490e6616 100644
---- a/src/sage/rings/asymptotic/asymptotic_ring.py
-+++ b/src/sage/rings/asymptotic/asymptotic_ring.py
-@@ -1091,7 +1091,7 @@ def monomial_coefficient(self, monomial):
-             sage: O(n).monomial_coefficient(n)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'
-+            AttributeError: 'OTermMonoid_with_category.element_class' object has no attribute 'coefficient'...
- 
-         The ``monomial`` must be exact::
- 
-diff --git a/src/sage/rings/asymptotic/growth_group.py b/src/sage/rings/asymptotic/growth_group.py
-index 27c14592bca..5be12537d62 100644
---- a/src/sage/rings/asymptotic/growth_group.py
-+++ b/src/sage/rings/asymptotic/growth_group.py
-@@ -1572,7 +1572,7 @@ def variable_names(self):
-             Traceback (most recent call last):
-             ...
-             AttributeError: 'GenericGrowthGroup_with_category.element_class' object
--            has no attribute 'is_one'
-+            has no attribute 'is_one'...
-         """
-         if self.is_one():
-             return tuple()
-diff --git a/src/sage/rings/ideal.py b/src/sage/rings/ideal.py
-index d36d9406f32..01c9fa3bf2d 100644
---- a/src/sage/rings/ideal.py
-+++ b/src/sage/rings/ideal.py
-@@ -1553,7 +1553,7 @@ def gcd(self, other):
-             sage: J.gcd(I)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Ideal_generic' object has no attribute 'gcd'
-+            AttributeError: 'Ideal_generic' object has no attribute 'gcd'...
- 
-         Note::
- 
-diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
-index 7fe89197011..8832d27e8ea 100644
---- a/src/sage/rings/number_field/number_field.py
-+++ b/src/sage/rings/number_field/number_field.py
-@@ -3823,7 +3823,7 @@ def primes_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
-         """
-         if degree is not None:
-             degree = ZZ(degree)
-@@ -3917,7 +3917,7 @@ def prime_above(self, x, degree=None):
-             sage: F.prime_above(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'prime_factors'...
- 
-         """
-         ids = self.primes_above(x, degree)
-@@ -5926,7 +5926,7 @@ def factor(self, n):
-             sage: L.factor(0)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'
-+            AttributeError: 'NumberFieldIdeal' object has no attribute 'factor'...
- 
-         AUTHORS:
- 
-@@ -12698,7 +12698,7 @@ def is_real_place(v):
-         sage: is_real_place(v_fin)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'
-+        AttributeError: 'NumberFieldFractionalIdeal' object has no attribute 'im_gens'...
- 
-     """
-     RR = sage.rings.real_mpfr.RealField(53)
-diff --git a/src/sage/rings/padics/generic_nodes.py b/src/sage/rings/padics/generic_nodes.py
-index 7047020edec..b6b514d4005 100644
---- a/src/sage/rings/padics/generic_nodes.py
-+++ b/src/sage/rings/padics/generic_nodes.py
-@@ -740,7 +740,7 @@ def _get_element_class(self, name=None):
-             sage: R._get_element_class("foobar")
-             Traceback (most recent call last):
-             ...
--            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'
-+            AttributeError: module 'sage.rings.padics.padic_relaxed_element' has no attribute 'pAdicRelaxedElement_foobar'...
-         """
-         if name is None:
-             return self.Element
-diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx
-index c5a1129aecf..a5b7f937cfe 100644
---- a/src/sage/rings/polynomial/polynomial_element.pyx
-+++ b/src/sage/rings/polynomial/polynomial_element.pyx
-@@ -10793,7 +10793,7 @@ cdef class Polynomial(CommutativePolynomial):
-             sage: (y**2 + x).nth_root(2)
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... has no attribute 'nth_root'
-+            AttributeError: ... has no attribute 'nth_root'...
- 
-         TESTS::
- 
-@@ -11831,7 +11831,7 @@ cdef class Polynomial_generic_dense(Polynomial):
-             sage: int(1) // x  # check that this doesn't segfault
-             Traceback (most recent call last):
-             ...
--            AttributeError: type object 'int' has no attribute 'base_ring'
-+            AttributeError: type object 'int' has no attribute 'base_ring'...
-         """
-         if have_same_parent(self, right):
-             return (<Polynomial_generic_dense>self)._floordiv_(<Polynomial_generic_dense>right)
-diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-index e372be888ee..aca4f08420f 100644
---- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
-+++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
-@@ -2362,7 +2362,7 @@ def field_extension(self, names):
-             sage: F, g, h = S.field_extension('b')                                      # needs sage.rings.finite_rings
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'
-+            AttributeError: 'PolynomialQuotientRing_generic_with_category' object has no attribute 'field_extension'...
- 
-         Over a finite field, the corresponding field extension is not a
-         number field::
-diff --git a/src/sage/rings/ring.pyx b/src/sage/rings/ring.pyx
-index 5273891a5b0..a6e999b8805 100644
---- a/src/sage/rings/ring.pyx
-+++ b/src/sage/rings/ring.pyx
-@@ -1734,7 +1734,7 @@ cdef class IntegralDomain(CommutativeRing):
-             sage: Z5.is_integrally_closed()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'
-+            AttributeError: 'IntegerModRing_generic_with_category' object has no attribute 'is_integrally_closed'...
-         """
-         raise NotImplementedError
- 
-diff --git a/src/sage/sat/solvers/satsolver.pyx b/src/sage/sat/solvers/satsolver.pyx
-index c2f41b18f55..1c4ac400cb6 100644
---- a/src/sage/sat/solvers/satsolver.pyx
-+++ b/src/sage/sat/solvers/satsolver.pyx
-@@ -375,10 +375,10 @@ def SAT(solver=None, *args, **kwds):
-         DIMACS Solver: 'kissat -q {input}'
-     """
-     if solver is None:
--        import pkgutil
--        if pkgutil.find_loader('pycryptosat') is not None:
-+        from importlib.util import find_spec
-+        if find_spec('pycryptosat') is not None:
-             solver = "cryptominisat"
--        elif pkgutil.find_loader('pycosat') is not None:
-+        elif find_spec('pycosat') is not None:
-             solver = "picosat"
-         else:
-             solver = "LP"
-diff --git a/src/sage/schemes/toric/morphism.py b/src/sage/schemes/toric/morphism.py
-index 1c8944b6dfc..5d64d632f97 100644
---- a/src/sage/schemes/toric/morphism.py
-+++ b/src/sage/schemes/toric/morphism.py
-@@ -246,7 +246,7 @@
-     Traceback (most recent call last):
-     ...
-     AttributeError: 'SchemeMorphism_fan_toric_variety' object
--    has no attribute 'fiber_generic'
-+    has no attribute 'fiber_generic'...
- 
- Let's use factorization mentioned above::
- 
-diff --git a/src/sage/sets/disjoint_union_enumerated_sets.py b/src/sage/sets/disjoint_union_enumerated_sets.py
-index 3dea567a779..5c5e08612f2 100644
---- a/src/sage/sets/disjoint_union_enumerated_sets.py
-+++ b/src/sage/sets/disjoint_union_enumerated_sets.py
-@@ -597,7 +597,7 @@ def Element(self):
-             sage: U.Element
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'
-+            AttributeError: 'DisjointUnionEnumeratedSets_with_category' object has no attribute 'Element'...
-         """
-         if not self._facade:
-             return ElementWrapper
-diff --git a/src/sage/sets/set.py b/src/sage/sets/set.py
-index a1789c61300..112d3d8dc3b 100644
---- a/src/sage/sets/set.py
-+++ b/src/sage/sets/set.py
-@@ -163,7 +163,7 @@ def Set(X=None, category=None):
-         sage: sorted(B.list(), key=repr)
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'Set_object_with_category' object has no attribute 'list'
-+        AttributeError: 'Set_object_with_category' object has no attribute 'list'...
-         sage: type(B)
-         <class 'sage.sets.set.Set_object_with_category'>
- 
-diff --git a/src/sage/structure/category_object.pyx b/src/sage/structure/category_object.pyx
-index b6a7eaecb5b..c06933494dc 100644
---- a/src/sage/structure/category_object.pyx
-+++ b/src/sage/structure/category_object.pyx
-@@ -836,7 +836,7 @@ cdef class CategoryObject(SageObject):
-             sage: Sets().example().sadfasdf
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'
-+            AttributeError: 'PrimeNumbers_with_category' object has no attribute 'sadfasdf'...
-         """
-         return self.getattr_from_category(name)
- 
-diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx
-index caae7e40ffc..543506e9a74 100644
---- a/src/sage/structure/element.pyx
-+++ b/src/sage/structure/element.pyx
-@@ -219,7 +219,7 @@ the parents::
-     sage: x._add_(x)
-     Traceback (most recent call last):
-     ...
--    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+    AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-     sage: x + x
-     Traceback (most recent call last):
-     ...
-@@ -478,13 +478,13 @@ cdef class Element(SageObject):
-             sage: 1.blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'
-+            AttributeError: 'sage.rings.integer.Integer' object has no attribute 'blah_blah'...
-             sage: Semigroups().example().an_element().is_idempotent
-             <bound method LeftZeroSemigroup.Element.is_idempotent of 42>
-             sage: Semigroups().example().an_element().blah_blah
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'
-+            AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'...
-         """
-         return self.getattr_from_category(name)
- 
-@@ -1269,7 +1269,7 @@ cdef class Element(SageObject):
-             sage: e._add_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_add_'...
-         """
-         try:
-             python_op = (<object>self)._add_
-@@ -1381,7 +1381,7 @@ cdef class Element(SageObject):
-             sage: e._sub_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_sub_'...
-         """
-         try:
-             python_op = (<object>self)._sub_
-@@ -1435,7 +1435,7 @@ cdef class Element(SageObject):
-             sage: e._neg_()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_neg_'...
-         """
-         try:
-             python_op = (<object>self)._neg_
-@@ -1549,7 +1549,7 @@ cdef class Element(SageObject):
-             sage: e._mul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mul_'...
-         """
-         try:
-             python_op = (<object>self)._mul_
-@@ -1662,7 +1662,7 @@ cdef class Element(SageObject):
-             sage: e._matmul_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_matmul_'...
-         """
-         try:
-             python_op = (<object>self)._matmul_
-@@ -1765,7 +1765,7 @@ cdef class Element(SageObject):
-             sage: e._div_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_div_'...
-         """
-         try:
-             python_op = (<object>self)._div_
-@@ -1865,7 +1865,7 @@ cdef class Element(SageObject):
-             sage: e._floordiv_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_floordiv_'...
-         """
-         try:
-             python_op = (<object>self)._floordiv_
-@@ -1965,7 +1965,7 @@ cdef class Element(SageObject):
-             sage: e._mod_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_mod_'...
-         """
-         try:
-             python_op = (<object>self)._mod_
-@@ -2092,7 +2092,7 @@ cdef class Element(SageObject):
-             sage: e._pow_(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_'...
-         """
-         try:
-             python_op = (<object>self)._pow_
-@@ -2122,7 +2122,7 @@ cdef class Element(SageObject):
-             sage: e._pow_int(e)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'
-+            AttributeError: 'sage.structure.element.Element' object has no attribute '_pow_int'...
-         """
-         try:
-             python_op = (<object>self)._pow_int
-@@ -2856,7 +2856,7 @@ cdef class RingElement(ModuleElement):
-             sage: m.is_nilpotent()                                                      # needs sage.modules
-             Traceback (most recent call last):
-             ...
--            AttributeError: ... object has no attribute 'is_nilpotent'
-+            AttributeError: '...' object has no attribute 'is_nilpotent'...
-         """
-         if self.is_unit():
-             return False
-@@ -4671,7 +4671,7 @@ def coerce_binop(method):
-         sage: x.test_add(CC(2))
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'
-+        AttributeError: 'sage.rings.complex_mpfr.ComplexNumber' object has no attribute 'test_add'...
- 
-     TESTS:
- 
-diff --git a/src/sage/structure/sequence.py b/src/sage/structure/sequence.py
-index 0c700c1fb81..c3972532ac3 100644
---- a/src/sage/structure/sequence.py
-+++ b/src/sage/structure/sequence.py
-@@ -854,7 +854,7 @@ def __getattr__(self, name):
-             sage: S.universe()
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__universe'...
-             sage: S._Sequence__universe = 'foobar'
-             sage: S.universe()
-             'foobar'
-@@ -867,7 +867,7 @@ def __getattr__(self, name):
-             sage: hash(S)
-             Traceback (most recent call last):
-             ...
--            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'
-+            AttributeError: 'Sequence_generic' object has no attribute '_Sequence_generic__hash'...
-             sage: S._Sequence__hash = int(34)
-             sage: hash(S)
-             34
-diff --git a/src/sage/symbolic/assumptions.py b/src/sage/symbolic/assumptions.py
-index 7dcb15f0d85..15f6fa07ce6 100644
---- a/src/sage/symbolic/assumptions.py
-+++ b/src/sage/symbolic/assumptions.py
-@@ -636,7 +636,7 @@ def assume(*args):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.rings.integer.Integer' object has no
--        attribute 'assume'
-+        attribute 'assume'...
- 
-     Ensure that we can combine the two types of assumptions, as documented::
- 
-diff --git a/src/sage/symbolic/expression.pyx b/src/sage/symbolic/expression.pyx
-index 0f251ac4e5c..66f624141b3 100644
---- a/src/sage/symbolic/expression.pyx
-+++ b/src/sage/symbolic/expression.pyx
-@@ -13712,7 +13712,7 @@ cdef get_dynamic_class_for_function(unsigned serial):
-         Traceback (most recent call last):
-         ...
-         AttributeError: 'sage.symbolic.expression.Expression' object has no
--        attribute 'argp1'
-+        attribute 'argp1'...
-         sage: t = (e + 1).op[0]; t
-         tfunc(x)
-         sage: t
-diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
-index c4152e092e3..4bcf45e8793 100644
---- a/src/sage/symbolic/ginac/numeric.cpp
-+++ b/src/sage/symbolic/ginac/numeric.cpp
-@@ -67,6 +67,7 @@
- #include "archive.h"
- #include "tostring.h"
- #include "utils.h"
-+#include "../../cpython/pycore_long.h"
- 
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wdeprecated-register"
-@@ -706,18 +707,12 @@ static long _mpq_pythonhash(mpq_t the_rat)
- // Initialize an mpz_t from a Python long integer
- static void _mpz_set_pylong(mpz_t z, PyLongObject* l)
- {
--    Py_ssize_t pylong_size = Py_SIZE(l);
--    int sign = 1;
--
--    if (pylong_size < 0) {
--        pylong_size = -pylong_size;
--        sign = -1;
--    }
-+    Py_ssize_t pylong_size = _PyLong_DigitCount(l);
- 
-     mpz_import(z, pylong_size, -1, sizeof(digit), 0,
--               8*sizeof(digit) - PyLong_SHIFT, l->ob_digit);
-+               8*sizeof(digit) - PyLong_SHIFT, ob_digit(l));
- 
--    if (sign < 0)
-+    if (_PyLong_IsNegative(l))
-         mpz_neg(z, z);
- }
- 
-diff --git a/src/sage/symbolic/pynac_impl.pxi b/src/sage/symbolic/pynac_impl.pxi
-index 68c31dcfde7..7fd7c3b314b 100644
---- a/src/sage/symbolic/pynac_impl.pxi
-+++ b/src/sage/symbolic/pynac_impl.pxi
-@@ -619,7 +619,7 @@ def tolerant_is_symbol(a):
-         sage: None.is_symbol()
-         Traceback (most recent call last):
-         ...
--        AttributeError: 'NoneType' object has no attribute 'is_symbol'
-+        AttributeError: 'NoneType' object has no attribute 'is_symbol'...
-     """
-     try:
-         return a.is_symbol()
diff --git a/srcpkgs/sagemath/patches/36769-fix_jmol_detect.patch b/srcpkgs/sagemath/patches/36769-fix_jmol_detect.patch
new file mode 100644
index 0000000000000..c7c983fe50c0d
--- /dev/null
+++ b/srcpkgs/sagemath/patches/36769-fix_jmol_detect.patch
@@ -0,0 +1,92 @@
+diff --git a/src/sage/interfaces/jmoldata.py b/src/sage/interfaces/jmoldata.py
+index a68e53e2d85..55c07255b74 100644
+--- a/src/sage/interfaces/jmoldata.py
++++ b/src/sage/interfaces/jmoldata.py
+@@ -71,6 +71,47 @@ def is_jvm_available(self):
+         java_version_number = int(re.sub(r'.*version "(0\.|1\.)?(\d*)[\s\S]*', r'\2', version, flags=re.S))
+         return java_version_number >= 7
+ 
++    def jmolpath(self):
++        """
++        Return the path to the jar file.
++
++        EXAMPLES::
++
++            sage: from sage.interfaces.jmoldata import JmolData
++            sage: JData = JmolData()
++            sage: JData.jmolpath()
++            '.../JmolData.jar'
++
++        """
++        jmolpath = os.path.join(JMOL_DIR, "JmolData.jar")
++
++        if sys.platform == 'cygwin':
++            import cygwin
++            jmolpath = cygwin.cygpath(jmolpath, 'w')
++
++        return jmolpath
++
++    def is_jmol_available(self):
++        """
++        Returns True if jmol is available and False if not.
++
++        EXAMPLES:
++
++        Check that it returns a boolean::
++
++            sage: from sage.interfaces.jmoldata import JmolData
++            sage: JData = JmolData()
++            sage: type(JData.is_jmol_available())
++            <... 'bool'>
++        """
++        if not os.path.isfile(self.jmolpath()):
++            return False
++
++        if not self.is_jvm_available():
++            return False
++
++        return True
++
+     def export_image(self,
+         targetfile,
+         datafile, #name (path) of data file Jmol can read or script file telling it what to read or load
+@@ -154,12 +195,11 @@ def export_image(self,
+             sage: archive.close()
+         """
+         # Set up paths, file names and scripts
+-        jmolpath = os.path.join(JMOL_DIR, "JmolData.jar")
++        jmolpath = self.jmolpath()
+         target_native = targetfile
+ 
+         if sys.platform == 'cygwin':
+             import cygwin
+-            jmolpath = cygwin.cygpath(jmolpath, 'w')
+             target_native = cygwin.cygpath(target_native, 'w')
+             if datafile_cmd != 'script':
+                 datafile = cygwin.cygpath(datafile, 'w')
+diff --git a/src/sage/plot/plot3d/base.pyx b/src/sage/plot/plot3d/base.pyx
+index 253f152130c..7588cde2e27 100644
+--- a/src/sage/plot/plot3d/base.pyx
++++ b/src/sage/plot/plot3d/base.pyx
+@@ -278,7 +278,7 @@ cdef class Graphics3d(SageObject):
+         T.export_jmol(scene_zip, **opts)
+         from sage.interfaces.jmoldata import JmolData
+         jdata = JmolData()
+-        if not jdata.is_jvm_available():
++        if not jdata.is_jmol_available():
+             # We can only use JMol to generate preview if a jvm is installed
+             from sage.repl.rich_output.output_graphics import OutputImagePng
+             tachyon = self._rich_repr_tachyon(OutputImagePng, **opts)
+diff --git a/src/sage/repl/rich_output/backend_ipython.py b/src/sage/repl/rich_output/backend_ipython.py
+index 69e63b76d60..10ccdc0c2c8 100644
+--- a/src/sage/repl/rich_output/backend_ipython.py
++++ b/src/sage/repl/rich_output/backend_ipython.py
+@@ -369,7 +369,7 @@ def launch_jmol(self, output_jmol, plain_text):
+         from sage.doctest import DOCTEST_MODE
+         from sage.interfaces.jmoldata import JmolData
+         jdata = JmolData()
+-        if not jdata.is_jvm_available() and not DOCTEST_MODE:
++        if not jdata.is_jmol_available() and not DOCTEST_MODE:
+             raise RuntimeError('jmol cannot run, no suitable java version found')
+         launch_script = output_jmol.launch_script_filename()
+         jmol_cmd = 'jmol'
diff --git a/srcpkgs/sagemath/patches/get_patches b/srcpkgs/sagemath/patches/get_patches
index 95a6963432948..a552b402727d3 100755
--- a/srcpkgs/sagemath/patches/get_patches
+++ b/srcpkgs/sagemath/patches/get_patches
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-version=10.1
+version=10.2
 
 URL_BASE_PR="https://github.com/sagemath/sage/pull/"
 URL_BASE_COMPARE="https://github.com/sagemath/sage/compare/${version}..."
@@ -20,24 +20,6 @@ get_pr() {
 # run from patches dir
 cd $(dirname "$0")
 
-# merged in 10.2.beta0
-#get_pr  36018   "singular 4.3.2p4" # included in #35934
-get_pr  36046   "fix memory leak"
-
-# merged in 10.2.beta1
-get_pr  35934   "singular 4.3.2p7"
-
-# merged in 10.2.beta2
-get_pr  36006   "gmp 6.3.0"
-
-# merged in 10.2.beta3
-get_pr  36235   "ecl 23.9.9"
-
-# merged in 10.2.beta4
-get_pr  36279   "matplotlib 3.8.0"
-
-# positive review
-#get_pr  36403   "python 3.12" # included in #36407
-
 # needs review
-get_pr  36407   "python 3.12"
+get_pr  35848   "flintlib 3.0"
+get_pr  36769   "fix jmol detect"
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index a80d8b7187ece..5d5bdccd70a25 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,14 +1,14 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=10.1
-revision=4
+version=10.2
+revision=1
 build_wrksrc=pkgs/sagemath-standard
 build_style=python3-module
 _bindir=/usr/lib/sagemath/$version/bin
 make_install_args="--install-scripts=$_bindir"
-hostmakedepends="m4 pkg-config python3-Cython0.29 python3-Jinja2
+hostmakedepends="m4 pkg-config python3-Cython python3-Jinja2
  python3-pkgconfig python3-setuptools"
-makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
+makedepends="boost-devel brial-devel cliquer-devel ecl eclib-devel
  ecm-devel fflas-ffpack flintlib-devel gap-devel gd-devel giac-devel glpk-devel
  gsl-devel iml-devel lcalc-devel libbraiding-devel libhomfly-devel libmpc-devel
  libpng-devel linbox-devel m4ri-devel m4rie-devel mpfi-devel
@@ -18,7 +18,7 @@ makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
 depends="eclib-devel fflas-ffpack flintlib-devel gcc-fortran gd-devel
  gfan giac gsl-devel gzip libpng-devel linbox-devel m4ri-devel maxima-ecl
  mpfr-devel nauty ntl-devel palp pari-devel pari-elldata-small pari-galdata
- pari-galpol-small pari-seadata-small pkg-config python3-Cython0.29 python3-cypari2
+ pari-galpol-small pari-seadata-small pkg-config python3-Cython python3-cypari2
  python3-cysignals python3-devel python3-fpylll python3-ipython python3-lrcalc
  python3-ipython_ipykernel python3-jupyter_ipywidgets python3-matplotlib
  python3-memory_allocator python3-networkx python3-pip python3-pkgconfig
@@ -33,8 +33,8 @@ license="GPL-2.0-or-later"
 homepage="https://www.sagemath.org/"
 changelog="https://github.com/sagemath/sage/releases"
 distfiles="https://github.com/sagemath/sage/archive/refs/tags/$version.tar.gz"
-checksum=a658612b1b2376ddaf207cc8ed0ef458d4c2880c16e19139bedbe8baa42ad62f
-nocross="due to ntl (flintlib), fflas-ffpack, givaro, linbox, cysignals, sympow, maxima"
+checksum=e7125f13495e1068edab73735aca7f9b2c655688096e9d109e628c023e76411f
+nocross="due to ntl (eclib), fflas-ffpack, givaro, linbox, sympow, maxima"
 
 post_patch() {
 	# git tree needs bootstrapping
diff --git a/srcpkgs/sagemath/update b/srcpkgs/sagemath/update
index 68be3c5752d06..1a4e4049af025 100644
--- a/srcpkgs/sagemath/update
+++ b/srcpkgs/sagemath/update
@@ -1,2 +1,6 @@
 pkgname="sage"
-site="https://mirrors.mit.edu/sage/src/index.html"
+site="https://mirrors.mit.edu/sage/src/"
+if [[ "$version" == *[abr]* ]]; then
+	site+="
+https://mirrors.mit.edu/sage/devel/"
+fi

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

* Re: sagemath: update to 10.2, flintlib: update to 3.0.1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (24 preceding siblings ...)
  2023-12-03 16:18 ` [PR PATCH] [Updated] " tornaria
@ 2023-12-03 16:21 ` tornaria
  2023-12-03 18:29 ` dkwo
                   ` (2 subsequent siblings)
  28 siblings, 0 replies; 29+ messages in thread
From: tornaria @ 2023-12-03 16:21 UTC (permalink / raw)
  To: ml

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

New comment by tornaria on void-packages repository

https://github.com/void-linux/void-packages/pull/46832#issuecomment-1837529874

Comment:
@dkwo this is ready to merge, any comments?

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

* Re: sagemath: update to 10.2, flintlib: update to 3.0.1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (25 preceding siblings ...)
  2023-12-03 16:21 ` tornaria
@ 2023-12-03 18:29 ` dkwo
  2023-12-03 19:21 ` dkwo
  2023-12-08 16:05 ` [PR PATCH] [Merged]: " leahneukirchen
  28 siblings, 0 replies; 29+ messages in thread
From: dkwo @ 2023-12-03 18:29 UTC (permalink / raw)
  To: ml

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

New comment by dkwo on void-packages repository

https://github.com/void-linux/void-packages/pull/46832#issuecomment-1837560783

Comment:
looks good to me.
i only see this failure on aarch64 with full check: sage/graphs/generic_graph.py (timed out).
@leahneukirchen can this be merged?

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

* Re: sagemath: update to 10.2, flintlib: update to 3.0.1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (26 preceding siblings ...)
  2023-12-03 18:29 ` dkwo
@ 2023-12-03 19:21 ` dkwo
  2023-12-08 16:05 ` [PR PATCH] [Merged]: " leahneukirchen
  28 siblings, 0 replies; 29+ messages in thread
From: dkwo @ 2023-12-03 19:21 UTC (permalink / raw)
  To: ml

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

New comment by dkwo on void-packages repository

https://github.com/void-linux/void-packages/pull/46832#issuecomment-1837574199

Comment:
that test passes when run from within installed sage.
all looks good :)

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

* Re: [PR PATCH] [Merged]: sagemath: update to 10.2, flintlib: update to 3.0.1
       [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
                   ` (27 preceding siblings ...)
  2023-12-03 19:21 ` dkwo
@ 2023-12-08 16:05 ` leahneukirchen
  28 siblings, 0 replies; 29+ messages in thread
From: leahneukirchen @ 2023-12-08 16:05 UTC (permalink / raw)
  To: ml

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

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

sagemath: update to 10.2, flintlib: update to 3.0.1
https://github.com/void-linux/void-packages/pull/46832

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

#### Testing the changes
- I tested the changes in this PR: **YES**

This is a major update for both sagemath and flintlib.

Sagemath moves to cython 3.

A couple of packages need rebuild or update:

 - eclib: rbuild for flintlib-3.0.1
 - singular: update to 4.3.2p10
 - python3-pplpy: rebuild using cython 3
 - python3-networkx: update to 3.2.1.


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

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


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

end of thread, other threads:[~2023-12-08 16:05 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-46832@inbox.vuxu.org>
2023-10-26 12:12 ` [PR PATCH] [Updated] [WIP] flintlib: update to 3.0.0 tornaria
2023-10-29 16:05 ` dkwo
2023-10-30 19:23 ` [PR PATCH] [Updated] " tornaria
2023-10-31  1:28 ` tornaria
2023-10-31  1:43 ` [PR PATCH] [Updated] [WIP] flintlib: update to 3.0.0 / track sagemath-10.2 prereleases tornaria
2023-11-07  2:21 ` tornaria
2023-11-10 23:49 ` [PR PATCH] [Updated] [RC] sagemath: update to 10.2, flintlib: update to 3.0.1 tornaria
2023-11-11 12:21 ` tornaria
2023-11-12 19:38 ` [PR PATCH] [Updated] " tornaria
2023-11-14 21:56 ` tornaria
2023-11-15  0:51 ` tornaria
2023-11-15  8:05 ` dkwo
2023-11-15  8:08 ` dkwo
2023-11-16  1:16 ` tornaria
2023-11-16  1:19 ` [PR PATCH] [Updated] " tornaria
2023-11-18  4:51 ` tornaria
2023-11-19 18:06 ` [PR REVIEW] " dkwo
2023-11-19 18:08 ` dkwo
2023-11-20 14:24 ` dkwo
2023-11-21 20:39 ` [PR REVIEW] " dkwo
2023-11-22 17:23 ` tornaria
2023-12-01 11:01 ` [PR PATCH] [Updated] " tornaria
2023-12-01 21:08 ` tornaria
2023-12-03 14:20 ` tornaria
2023-12-03 16:18 ` [PR PATCH] [Updated] " tornaria
2023-12-03 16:21 ` tornaria
2023-12-03 18:29 ` dkwo
2023-12-03 19:21 ` dkwo
2023-12-08 16:05 ` [PR PATCH] [Merged]: " leahneukirchen

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).