From 402fc0b238ec5e33db8d60cd99c4db5c91f70c0e Mon Sep 17 00:00:00 2001
From: Oscar Benjamin <oscar.j.benjamin@gmail.com>
Date: Thu, 8 Aug 2024 11:07:27 +0100
Subject: [PATCH 1/2] Remove old Py3 bits as newer Cython will reject them

---
 src/flint/types/arb.pyx       | 7 -------
 src/flint/types/fmpz.pxd      | 6 ------
 src/flint/types/fmpz_poly.pyx | 2 --
 3 files changed, 15 deletions(-)

diff --git a/src/flint/types/arb.pyx b/src/flint/types/arb.pyx
index ad84c41c..3a28a4ea 100644
--- a/src/flint/types/arb.pyx
+++ b/src/flint/types/arb.pyx
@@ -1,8 +1,5 @@
 from cpython.float cimport PyFloat_AS_DOUBLE
-from cpython.version cimport PY_MAJOR_VERSION
-from cpython.int cimport PyInt_AS_LONG
 from cpython.long cimport PyLong_Check
-from cpython.int cimport PyInt_Check
 
 from flint.flint_base.flint_context cimport getprec
 from flint.flint_base.flint_context cimport thectx
@@ -86,10 +83,6 @@ cdef int arb_set_python(arb_t x, obj, bint allow_conversion) except -1:
         arb_set_fmpq(x, (<fmpq>obj).val, getprec())
         return 1
 
-    if PY_MAJOR_VERSION < 3 and PyInt_Check(obj):
-        arb_set_si(x, PyInt_AS_LONG(obj))
-        return 1
-
     if PyLong_Check(obj):
         fmpz_init(t)
         fmpz_set_pylong(t, obj)
diff --git a/src/flint/types/fmpz.pxd b/src/flint/types/fmpz.pxd
index 074aa411..dee5b194 100644
--- a/src/flint/types/fmpz.pxd
+++ b/src/flint/types/fmpz.pxd
@@ -1,4 +1,3 @@
-from cpython.int cimport PyInt_Check, PyInt_AS_LONG
 from cpython.long cimport PyLong_Check
 from flint.flint_base.flint_base cimport flint_scalar
 from flint.utils.conversion cimport chars_from_str
@@ -7,8 +6,6 @@ from flint.flintlib.flint cimport slong, pylong_as_slong
 from flint.flintlib.flint cimport PyObject
 from flint.flintlib.fmpz cimport fmpz_t, fmpz_set_str, fmpz_set_si
 
-from cpython.version cimport PY_MAJOR_VERSION
-
 cdef int fmpz_set_any_ref(fmpz_t x, obj)
 cdef fmpz_get_intlong(fmpz_t x)
 
@@ -23,9 +20,6 @@ cdef inline int fmpz_set_pylong(fmpz_t x, obj):
         fmpz_set_si(x, longval)
 
 cdef inline int fmpz_set_python(fmpz_t x, obj):
-    if PY_MAJOR_VERSION < 3 and PyInt_Check(obj):
-        fmpz_set_si(x, PyInt_AS_LONG(obj))
-        return 1
     if PyLong_Check(obj):
         fmpz_set_pylong(x, obj)
         return 1
diff --git a/src/flint/types/fmpz_poly.pyx b/src/flint/types/fmpz_poly.pyx
index 14d5631e..6d72a5d3 100644
--- a/src/flint/types/fmpz_poly.pyx
+++ b/src/flint/types/fmpz_poly.pyx
@@ -1,7 +1,5 @@
-from cpython.int cimport PyInt_AS_LONG
 from cpython.list cimport PyList_GET_SIZE
 from cpython.long cimport PyLong_Check
-from cpython.int cimport PyInt_Check
 
 from flint.flint_base.flint_context cimport getprec
 from flint.flint_base.flint_base cimport flint_poly

From d9a02966b7faf50f26f1ab0b33aeb30dd5dd7216 Mon Sep 17 00:00:00 2001
From: Oscar Benjamin <oscar.j.benjamin@gmail.com>
Date: Thu, 8 Aug 2024 11:13:33 +0100
Subject: [PATCH 2/2] Remove duplicate nmod_poly length/degree methods

---
 src/flint/types/nmod_poly.pyx | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/src/flint/types/nmod_poly.pyx b/src/flint/types/nmod_poly.pyx
index a5b7fadd..65f11666 100644
--- a/src/flint/types/nmod_poly.pyx
+++ b/src/flint/types/nmod_poly.pyx
@@ -183,12 +183,6 @@ cdef class nmod_poly(flint_poly):
         else:
             raise TypeError("cannot set element of type %s" % type(x))
 
-    def degree(self):
-        return nmod_poly_degree(self.val)
-
-    def length(self):
-        return nmod_poly_length(self.val)
-
     def __bool__(self):
         return not nmod_poly_is_zero(self.val)