From 9dc050d6e437419f4ad9151caeda8273bf95f549 Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Tue, 19 Dec 2023 19:11:39 -0800 Subject: [PATCH] src/sage/rings/finite_rings/element_ntl_gf2e.pyx: Fix test for libgap element --- src/sage/rings/finite_rings/element_ntl_gf2e.pyx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/sage/rings/finite_rings/element_ntl_gf2e.pyx b/src/sage/rings/finite_rings/element_ntl_gf2e.pyx index de58a60e720..bb490c163a8 100644 --- a/src/sage/rings/finite_rings/element_ntl_gf2e.pyx +++ b/src/sage/rings/finite_rings/element_ntl_gf2e.pyx @@ -334,16 +334,17 @@ cdef class Cache_ntl_gf2e(Cache_base): e = e.__pari__() elif isinstance(e, GapElement): - from sage.libs.gap.element import GapElement_FiniteField - - if isinstance(e, GapElement_FiniteField): - return e.sage(ring=self._parent) - from sage.libs.gap.libgap import libgap - return libgap(e).sage(ring=self._parent) else: + try: + from sage.libs.gap.element import GapElement_FiniteField + except ImportError: + pass + else: + if isinstance(e, GapElement_FiniteField): + return e.sage(ring=self._parent) raise TypeError("unable to coerce %r" % type(e)) cdef GEN t