diff -up src/doc/en/thematic_tutorials/lie/weyl_groups.rst.orig src/doc/en/thematic_tutorials/lie/weyl_groups.rst --- src/doc/en/thematic_tutorials/lie/weyl_groups.rst.orig 2023-02-11 06:25:15.000000000 -0700 +++ src/doc/en/thematic_tutorials/lie/weyl_groups.rst 2023-03-13 09:42:01.111404689 -0600 @@ -139,12 +139,12 @@ string, which you can print:: X.1 1 1 1 1 1 1 1 1 1 1 1 1 1 X.2 1 -1 1 1 -1 1 1 -1 -1 -1 1 1 1 X.3 2 . 2 -1 . 2 2 . . . -1 2 2 - X.4 3 -1 -1 . 1 -1 3 -1 1 -1 . -1 3 - X.5 3 -1 -1 . 1 3 -1 -1 -1 1 . -1 3 - X.6 3 1 -1 . -1 -1 3 1 -1 1 . -1 3 - X.7 3 1 -1 . -1 3 -1 1 1 -1 . -1 3 - X.8 3 -1 3 . -1 -1 -1 -1 1 1 . -1 3 - X.9 3 1 3 . 1 -1 -1 1 -1 -1 . -1 3 + X.4 3 -1 -1 . 1 3 -1 -1 -1 1 . -1 3 + X.5 3 1 -1 . -1 3 -1 1 1 -1 . -1 3 + X.6 3 -1 3 . -1 -1 -1 -1 1 1 . -1 3 + X.7 3 -1 -1 . 1 -1 3 -1 1 -1 . -1 3 + X.8 3 1 3 . 1 -1 -1 1 -1 -1 . -1 3 + X.9 3 1 -1 . -1 -1 3 1 -1 1 . -1 3 X.10 4 -2 . -1 . . . 2 . . 1 . -4 X.11 4 2 . -1 . . . -2 . . 1 . -4 X.12 6 . -2 . . -2 -2 . . . . 2 6 diff -up src/sage/coding/linear_code.py.orig src/sage/coding/linear_code.py --- src/sage/coding/linear_code.py.orig 2023-02-11 06:25:15.000000000 -0700 +++ src/sage/coding/linear_code.py 2023-03-13 09:42:01.112404670 -0600 @@ -465,7 +465,10 @@ class AbstractLinearCode(AbstractLinearC 0 sage: C = codes.HammingCode(GF(4, 'z'), 3) sage: C.automorphism_group_gens() - ([((1, 1, 1, 1, 1, z + 1, z, z + 1, z, z, z, 1, 1, z + 1, z + 1, z, z + 1, z, z + 1, z + 1, z + 1); (1,14,6,7,4,10,11,19)(2,8,16,13,3,17,21,15)(9,12,18,20), Ring endomorphism of Finite Field in z of size 2^2 + ([((1, 1, 1, z, z + 1, 1, 1, 1, 1, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z); (1,13,14,20)(2,21,8,18,7,16,19,15)(3,10,5,12,17,9,6,4), Ring endomorphism of Finite Field in z of size 2^2 + Defn: z |--> z + 1), + ((z, 1, z, z, z, z + 1, z, z, z, z, z, z, z + 1, z, z, z, z, z + 1, z, z, z); (1,11,5,12,3,19)(2,8)(6,18,13)(7,17,15)(9,10,14,16,20,21), Ring endomorphism of Finite Field in z of size 2^2 + Defn: z |--> z + 1), Defn: z |--> z + 1), ((z + 1, 1, 1, z, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z + 1, 1, z, z + 1, z + 1, z); (1,18,6,19,2,9,17,10,13,14,21,11,4,5,12)(3,20,7,16,8), Ring endomorphism of Finite Field in z of size 2^2 Defn: z |--> z), @@ -473,19 +476,20 @@ class AbstractLinearCode(AbstractLinearC Defn: z |--> z)], 362880) sage: C.automorphism_group_gens(equivalence="linear") - ([((z + 1, 1, z + 1, z + 1, z + 1, z, 1, z, 1, 1, 1, 1, z + 1, z + 1, z + 1, z, z, 1, z, z, z); (1,15,2,8,16,18,3)(4,9,12,13,20,10,11)(5,21,14,6,7,19,17), Ring endomorphism of Finite Field in z of size 2^2 + ([((z, 1, z + 1, z + 1, 1, z + 1, z, 1, z + 1, z + 1, 1, z, 1, z + 1, z, 1, z, 1, z + 1, 1, 1); (1,12,11,10,6,8,9,20,13,21,5,14,3,16,17,19,7,4,2,15,18), Ring endomorphism of Finite Field in z of size 2^2 Defn: z |--> z), - ((z + 1, z + 1, z + 1, z + 1, z + 1, 1, z, 1, z, z, z, 1, z, 1, 1, 1, z + 1, z + 1, z + 1, 1, z); (1,15,21,8,9)(2,18,5,3,11,16,7,10,19,13,12,4,17,6,20), Ring endomorphism of Finite Field in z of size 2^2 + ((z + 1, z + 1, z + 1, z, 1, 1, z, z, 1, z + 1, z, 1, 1, z, 1, z + 1, z, z + 1, z + 1, 1, z); (1,3,18,2,17,6,19)(4,15,13,20,7,14,16)(5,11,8,21,12,9,10), Ring endomorphism of Finite Field in z of size 2^2 + Defn: z |--> z), Defn: z |--> z), ((z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1); (), Ring endomorphism of Finite Field in z of size 2^2 Defn: z |--> z)], 181440) sage: C.automorphism_group_gens(equivalence="permutational") - ([((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,19)(3,17)(4,21)(5,20)(7,14)(9,12)(10,16)(11,15), Ring endomorphism of Finite Field in z of size 2^2 + ([((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,11)(3,10)(4,9)(5,7)(12,21)(14,20)(15,19)(16,17), Ring endomorphism of Finite Field in z of size 2^2 Defn: z |--> z), - ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,11)(3,10)(4,9)(5,7)(12,21)(14,20)(15,19)(16,17), Ring endomorphism of Finite Field in z of size 2^2 + ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (2,18)(3,19)(4,10)(5,16)(8,13)(9,14)(11,21)(15,20), Ring endomorphism of Finite Field in z of size 2^2 Defn: z |--> z), - ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,17)(2,8)(3,14)(4,10)(7,12)(9,19)(13,18)(15,20), Ring endomorphism of Finite Field in z of size 2^2 + ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,19)(3,17)(4,21)(5,20)(7,14)(9,12)(10,16)(11,15), Ring endomorphism of Finite Field in z of size 2^2 Defn: z |--> z), ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (2,13)(3,14)(4,20)(5,11)(8,18)(9,19)(10,15)(16,21), Ring endomorphism of Finite Field in z of size 2^2 Defn: z |--> z)], @@ -691,10 +695,10 @@ class AbstractLinearCode(AbstractLinearC sage: C_iso == aut_group_can_label.get_canonical_form() True sage: aut_group_can_label.get_autom_gens() - [((1, 1, 1, 1, 1, z + 1, z, z + 1, z, z, z, 1, 1, z + 1, z + 1, z, z + 1, z, z + 1, z + 1, z + 1); (1,14,6,7,4,10,11,19)(2,8,16,13,3,17,21,15)(9,12,18,20), Ring endomorphism of Finite Field in z of size 2^2 + [((1, 1, 1, z, z + 1, 1, 1, 1, 1, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z); (1,13,14,20)(2,21,8,18,7,16,19,15)(3,10,5,12,17,9,6,4), Ring endomorphism of Finite Field in z of size 2^2 ++ Defn: z |--> z + 1), ++ ((z, 1, z, z, z, z + 1, z, z, z, z, z, z, z + 1, z, z, z, z, z + 1, z, z, z); (1,11,5,12,3,19)(2,8)(6,18,13)(7,17,15)(9,10,14,16,20,21), Ring endomorphism of Finite Field in z of size 2^2 Defn: z |--> z + 1), - ((z + 1, 1, 1, z, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z + 1, 1, z, z + 1, z + 1, z); (1,18,6,19,2,9,17,10,13,14,21,11,4,5,12)(3,20,7,16,8), Ring endomorphism of Finite Field in z of size 2^2 - Defn: z |--> z), ((z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z); (), Ring endomorphism of Finite Field in z of size 2^2 Defn: z |--> z)] """ diff -up src/sage/combinat/root_system/hecke_algebra_representation.py.orig src/sage/combinat/root_system/hecke_algebra_representation.py --- src/sage/combinat/root_system/hecke_algebra_representation.py.orig 2023-02-11 06:25:15.000000000 -0700 +++ src/sage/combinat/root_system/hecke_algebra_representation.py 2023-03-13 09:42:01.112404670 -0600 @@ -357,7 +357,7 @@ class HeckeAlgebraRepresentation(WithEqu sage: q1, q2 = K.gens() sage: KW = W.algebra(K) sage: x = KW.an_element(); x - 123 + 3*32 + 2*3 + e + 123 + 3*2312 + 2*31 + e sage: T = KW.demazure_lusztig_operators(q1,q2) sage: T12 = T.Tw( (1,2) ) diff -up src/sage/combinat/symmetric_group_algebra.py.orig src/sage/combinat/symmetric_group_algebra.py --- src/sage/combinat/symmetric_group_algebra.py.orig 2023-02-11 06:25:15.000000000 -0700 +++ src/sage/combinat/symmetric_group_algebra.py 2023-03-13 09:42:01.113404652 -0600 @@ -101,7 +101,7 @@ def SymmetricGroupAlgebra(R, W, category sage: SGA.group() Weyl Group of type ['A', 3] (as a matrix group acting on the ambient space) sage: SGA.an_element() - s1*s2*s3 + 3*s3*s2 + 2*s3 + 1 + s1*s2*s3 + 3*s2*s3*s1*s2 + 2*s3*s1 + 1 The preferred way to construct the symmetric group algebra is to go through the usual ``algebra`` method:: diff -up src/sage/env.py.orig src/sage/env.py --- src/sage/env.py.orig 2023-03-13 09:26:16.468693261 -0600 +++ src/sage/env.py 2023-03-13 14:09:36.725081542 -0600 @@ -197,7 +197,7 @@ CONWAY_POLYNOMIALS_DATA_DIR = var("CONWA GRAPHS_DATA_DIR = var("GRAPHS_DATA_DIR", join(SAGE_SHARE, "graphs")) ELLCURVE_DATA_DIR = var("ELLCURVE_DATA_DIR", join(SAGE_SHARE, "ellcurves")) POLYTOPE_DATA_DIR = var("POLYTOPE_DATA_DIR", join(SAGE_SHARE, "reflexive_polytopes")) -GAP_ROOT_DIR = var("GAP_ROOT_DIR", join(SAGE_SHARE, "gap")) +GAP_ROOT_DIRS = var("GAP_ROOT_DIR", ["/usr/share/gap", "/usr/lib64/gap"]) THEBE_DIR = var("THEBE_DIR", join(SAGE_SHARE, "thebe")) COMBINATORIAL_DESIGN_DATA_DIR = var("COMBINATORIAL_DESIGN_DATA_DIR", join(SAGE_SHARE, "combinatorial_designs")) CREMONA_MINI_DATA_DIR = var("CREMONA_MINI_DATA_DIR", join(SAGE_SHARE, "cremona")) diff -up src/sage/groups/abelian_gps/abelian_group_gap.py.orig src/sage/groups/abelian_gps/abelian_group_gap.py --- src/sage/groups/abelian_gps/abelian_group_gap.py.orig 2023-02-11 06:25:15.000000000 -0700 +++ src/sage/groups/abelian_gps/abelian_group_gap.py 2023-03-13 09:42:01.113404652 -0600 @@ -338,7 +338,7 @@ class AbelianGroup_gap(UniqueRepresentat if isinstance(x, AbelianGroupElement_gap): try: if x in self._cover: - x = self.gap().NaturalHomomorphism().Image(x.gap()) + x = self._cover.gap().NaturalHomomorphismByNormalSubgroup(self._relations).Image(x.gap()) else: x = x.gap() except AttributeError: @@ -1043,7 +1043,7 @@ class AbelianGroupQuotient_gap(AbelianGr From: Abelian group with gap, generator orders (4,) To: Quotient abelian group with generator orders (2,) """ - phi = self.gap().NaturalHomomorphism() + phi = self._cover.gap().NaturalHomomorphismByNormalSubgroup(self._relations) Hom = self._cover.Hom(self) return Hom(phi) diff -up src/sage/groups/finitely_presented.py.orig src/sage/groups/finitely_presented.py --- src/sage/groups/finitely_presented.py.orig 2023-02-11 06:25:15.000000000 -0700 +++ src/sage/groups/finitely_presented.py 2023-03-13 09:42:01.113404652 -0600 @@ -596,9 +596,9 @@ class RewritingSystem(): sage: k = G.rewriting_system() sage: k.gap() Knuth Bendix Rewriting System for Monoid( [ a, A, b, B ] ) with rules - [ [ a^2, ], [ a*A, ], - [ A*a, ], [ b^2, ], - [ b*B, ], [ B*b, ] ] + [ [ a*A, ], [ A*a, ], + [ b*B, ], [ B*b, ], + [ a^2, ], [ b^2, ] ] """ return self._gap diff -up src/sage/groups/fqf_orthogonal.py.orig src/sage/groups/fqf_orthogonal.py --- src/sage/groups/fqf_orthogonal.py.orig 2023-02-11 06:25:15.000000000 -0700 +++ src/sage/groups/fqf_orthogonal.py 2023-03-13 09:42:01.114404634 -0600 @@ -143,7 +143,7 @@ class FqfOrthogonalGroup(AbelianGroupAut [2/3 0 0] [ 0 2/3 0] [ 0 0 4/3] - generated by 2 elements + generated by 3 elements sage: q = matrix.diagonal(QQ, [3/2, 1/4, 1/4]) sage: T = TorsionQuadraticForm(q) sage: T.orthogonal_group().order() diff -up src/sage/groups/libgap_wrapper.pyx.orig src/sage/groups/libgap_wrapper.pyx --- src/sage/groups/libgap_wrapper.pyx.orig 2023-02-11 06:25:15.000000000 -0700 +++ src/sage/groups/libgap_wrapper.pyx 2023-03-13 09:42:01.114404634 -0600 @@ -25,7 +25,7 @@ Note how we call the constructor of both its output via LibGAP:: sage: FooGroup() - + sage: type(FooGroup().gap()) @@ -106,7 +106,7 @@ class ParentLibGAP(SageObject): ....: ParentLibGAP.__init__(self, lg) ....: Group.__init__(self) sage: FooGroup() - + """ def __init__(self, libgap_parent, ambient=None): @@ -461,7 +461,7 @@ cdef class ElementLibGAP(MultiplicativeG ....: ParentLibGAP.__init__(self, lg) ....: Group.__init__(self) sage: FooGroup() - + sage: FooGroup().gens() (f1,) """ diff -up src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx.orig src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx --- src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx.orig 2023-02-11 06:25:15.000000000 -0700 +++ src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx 2023-03-13 09:42:01.114404634 -0600 @@ -427,7 +427,7 @@ cdef class LabelledBranching: sage: from sage.groups.perm_gps.partn_ref2.refinement_generic import LabelledBranching sage: L = LabelledBranching(3) sage: L.small_generating_set() - [] + [()] sage: L.add_gen(libgap.eval('(1,2,3)')) sage: L.small_generating_set() [(1,2,3)] diff -up src/sage/groups/perm_gps/permgroup.py.orig src/sage/groups/perm_gps/permgroup.py --- src/sage/groups/perm_gps/permgroup.py.orig 2023-02-11 06:25:15.000000000 -0700 +++ src/sage/groups/perm_gps/permgroup.py 2023-03-13 09:42:01.115404615 -0600 @@ -926,7 +926,7 @@ class PermutationGroup_generic(FiniteGro sage: f = PG._coerce_map_from_(MG) sage: mg = MG.an_element() sage: p = f(mg); p - (2,33,32,23,31,55)(3,49,38,44,40,28)(4,17,59,62,58,46)(5,21,47,20,43,8)(6,53,50)(7,37,12,57,14,29)(9,41,56,34,64,10)(11,25,19)(13,61,26,51,22,15)(16,45,36)(18,27,35,48,52,54)(24,63,42)(30,39,60) + (1,2,6,19,35,33)(3,9,26,14,31,23)(4,13,5)(7,22,17)(8,24,12)(10,16,32,27,20,28)(11,30,18)(15,25,36,34,29,21) sage: PG(p._gap_()) == p True @@ -972,12 +972,12 @@ class PermutationGroup_generic(FiniteGro sage: P = G.as_permutation_group(algorithm='smaller', seed=5) sage: P1 = G.as_permutation_group() sage: P == P1 - False + True sage: g1, g2, g3 = G.gens() sage: P(g1*g2) - (1,3,7,12)(2,4,8,10)(5,11)(6,9) + (1,4,13,11)(2,5,14,18)(3,15,8,16)(6,7)(9,20,19,12)(10,17) sage: P1(g1*g2) - (2,29,25,68)(3,57,13,54)(4,11,72,37)(5,39,60,23)(6,64,75,63)(7,21,50,73)(8,46,38,32)(9,74,35,18)(10,44,49,48)(12,16,34,71)(14,79,27,40)(15,26)(17,62,59,76)(19,78,70,65)(20,22,58,51)(24,33,36,43)(28,81,80,52)(30,53,56,69)(31,61)(41,42,67,55)(45,77)(47,66) + (1,4,13,11)(2,5,14,18)(3,15,8,16)(6,7)(9,20,19,12)(10,17) Another check for :trac:`5583`:: @@ -4372,7 +4372,7 @@ class PermutationGroup_generic(FiniteGro sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)]]) #S_5 on [1..5] sage: G.is_transitive([1,4,5]) - True + False sage: G.is_transitive([2..6]) False sage: G.is_transitive(G.non_fixed_points()) @@ -4437,7 +4437,7 @@ class PermutationGroup_generic(FiniteGro sage: G.is_primitive([1..4]) False sage: G.is_primitive([1,2,3]) - True + False sage: G = PermutationGroup([[(3,4,5,6)],[(3,4)]]) #S_4 on [3..6] sage: G.is_primitive(G.non_fixed_points()) True diff -up src/sage/interfaces/gap.py.orig src/sage/interfaces/gap.py --- src/sage/interfaces/gap.py.orig 2023-02-11 06:25:15.000000000 -0700 +++ src/sage/interfaces/gap.py 2023-03-13 09:42:01.115404615 -0600 @@ -1512,6 +1512,8 @@ def gap_reset_workspace(max_workspace_si """ # Create new workspace with filename WORKSPACE g = Gap(use_workspace_cache=False, max_workspace_size=None) + g.eval('ColorPrompt(false)') + g.eval('SetUserPreference("UseColorPrompt", false)') g.eval('SetUserPreference("HistoryMaxLines", 30)') from sage.tests.gap_packages import all_installed_packages for pkg in all_installed_packages(gap=g): diff -up src/sage/libs/gap/element.pxd.orig src/sage/libs/gap/element.pxd --- src/sage/libs/gap/element.pxd.orig 2023-02-11 06:25:15.000000000 -0700 +++ src/sage/libs/gap/element.pxd 2023-03-13 09:42:01.116404597 -0600 @@ -29,9 +29,9 @@ cdef GapElement_Boolean make_GapElement_ cdef GapElement_Function make_GapElement_Function(parent, Obj obj) cdef GapElement_Permutation make_GapElement_Permutation(parent, Obj obj) -cdef char *capture_stdout(Obj, Obj) -cdef char *gap_element_str(Obj) -cdef char *gap_element_repr(Obj) +cdef str capture_stdout(Obj, Obj) +cdef str gap_element_str(Obj) +cdef str gap_element_repr(Obj) cdef class GapElement(RingElement): diff -up src/sage/libs/gap/element.pyx.orig src/sage/libs/gap/element.pyx --- src/sage/libs/gap/element.pyx.orig 2023-02-11 06:25:15.000000000 -0700 +++ src/sage/libs/gap/element.pyx 2023-03-13 09:42:01.116404597 -0600 @@ -120,7 +120,7 @@ cdef Obj make_gap_matrix(sage_list, gap_ return l.value -cdef char *capture_stdout(Obj func, Obj obj): +cdef str capture_stdout(Obj func, Obj obj): """ Call a single-argument GAP function ``func`` with the argument ``obj`` and return the stdout from that function call. @@ -130,6 +130,7 @@ cdef char *capture_stdout(Obj func, Obj """ cdef Obj s, stream, output_text_string cdef UInt res + cdef TypOutputFile output # The only way to get a string representation of an object that is truly # consistent with how it would be represented at the GAP REPL is to call # ViewObj on it. Unfortunately, ViewObj *prints* to the output stream, @@ -139,36 +140,35 @@ cdef char *capture_stdout(Obj func, Obj # that does not give consistent results. # TODO: This is probably needlessly slow, but we might need better # support from GAP to improve this... - try: - GAP_Enter() - s = NEW_STRING(0) - output_text_string = GAP_ValueGlobalVariable("OutputTextString") - stream = CALL_2ARGS(output_text_string, s, GAP_True) + s = NEW_STRING(0) + output_text_string = GAP_ValueGlobalVariable("OutputTextString") + stream = CALL_2ARGS(output_text_string, s, GAP_True) - if not OpenOutputStream(stream): - raise GAPError("failed to open output capture stream for " - "representing GAP object") + if not OpenOutputStream(&output, stream): + raise GAPError("failed to open output capture stream for " + "representing GAP object") - CALL_1ARGS(func, obj) - CloseOutput() - return CSTR_STRING(s) - finally: - GAP_Leave() + CALL_1ARGS(func, obj) + CloseOutput(&output) + return char_to_str(CSTR_STRING(s)) -cdef char *gap_element_repr(Obj obj): +cdef str gap_element_repr(Obj obj): """ Implement ``repr()`` of ``GapElement``s using the ``ViewObj()`` function, which is by default closest to what you get when displaying an object in GAP on the command-line (i.e. when evaluating an expression that returns that object. """ + cdef Obj func + try: + GAP_Enter() + func = GAP_ValueGlobalVariable("ViewObj") + return capture_stdout(func, obj) + finally: + GAP_Leave() - cdef Obj func = GAP_ValueGlobalVariable("ViewObj") - return capture_stdout(func, obj) - - -cdef char *gap_element_str(Obj obj): +cdef str gap_element_str(Obj obj): """ Implement ``str()`` of ``GapElement``s using the ``Print()`` function. @@ -178,9 +178,13 @@ cdef char *gap_element_str(Obj obj): slightly different approach more closely mirroring Python's str/repr difference (though this does not map perfectly onto GAP). """ - cdef Obj func = GAP_ValueGlobalVariable("Print") - return capture_stdout(func, obj) - + cdef Obj func + try: + GAP_Enter() + func = GAP_ValueGlobalVariable("Print") + return capture_stdout(func, obj) + finally: + GAP_Leave() cdef Obj make_gap_record(sage_dict) except NULL: """ @@ -760,7 +764,7 @@ cdef class GapElement(RingElement): if self.value == NULL: return 'NULL' - s = char_to_str(gap_element_str(self.value)) + s = gap_element_str(self.value) return s.strip() def _repr_(self): @@ -782,7 +786,7 @@ cdef class GapElement(RingElement): if self.value == NULL: return 'NULL' - s = char_to_str(gap_element_repr(self.value)) + s = gap_element_repr(self.value) return s.strip() cpdef _set_compare_by_id(self): @@ -955,7 +959,7 @@ cdef class GapElement(RingElement): sig_on() try: GAP_Enter() - return EQ(self.value, c_other.value) + return EQ(self.value, c_other.value) finally: GAP_Leave() sig_off() @@ -977,7 +981,7 @@ cdef class GapElement(RingElement): sig_on() try: GAP_Enter() - return LT(self.value, c_other.value) + return LT(self.value, c_other.value) finally: GAP_Leave() sig_off() @@ -1205,7 +1209,7 @@ cdef class GapElement(RingElement): sage: a.is_function() False """ - return IS_FUNC(self.value) + return IS_FUNC(self.value) def is_list(self): r""" @@ -1222,7 +1226,7 @@ cdef class GapElement(RingElement): sage: libgap.eval('3/2').is_list() False """ - return IS_LIST(self.value) + return IS_LIST(self.value) def is_record(self): r""" @@ -1239,7 +1243,7 @@ cdef class GapElement(RingElement): sage: libgap.eval('rec(a:=1, b:=3)').is_record() True """ - return IS_REC(self.value) + return IS_REC(self.value) cpdef is_bool(self): r""" @@ -1272,7 +1276,7 @@ cdef class GapElement(RingElement): sage: libgap('this is a string').is_string() True """ - return IS_STRING(self.value) + return IS_STRING(self.value) def is_permutation(self): r""" @@ -1469,7 +1473,7 @@ cdef class GapElement_Integer(GapElement sage: N.IsInt() true """ - return IS_INTOBJ(self.value) + return IS_INTOBJ(self.value) def _rational_(self): r""" @@ -2806,7 +2810,7 @@ cdef class GapElement_List(GapElement): ... ValueError: too many indices """ - cdef int j + cdef Int j cdef Obj obj = self.value if isinstance(i, tuple): @@ -2877,7 +2881,7 @@ cdef class GapElement_List(GapElement): if not IS_MUTABLE_OBJ(self.value): raise TypeError('immutable Gap object does not support item assignment') - cdef int j + cdef Int j cdef Obj obj = self.value if isinstance(i, tuple): diff -up src/sage/libs/gap/gap_includes.pxd.orig src/sage/libs/gap/gap_includes.pxd --- src/sage/libs/gap/gap_includes.pxd.orig 2023-02-11 06:25:15.000000000 -0700 +++ src/sage/libs/gap/gap_includes.pxd 2023-03-13 09:49:35.192090058 -0600 @@ -13,8 +13,8 @@ from libc.stdint cimport uintptr_t, uint cdef extern from "gap/system.h" nogil: ctypedef char Char - ctypedef int Int - ctypedef uintptr_t UInt + ctypedef long Int + ctypedef unsigned long UInt ctypedef uint8_t UInt1 ctypedef uint16_t UInt2 ctypedef uint32_t UInt4 @@ -29,8 +29,8 @@ cdef extern from "gap/ariths.h" nogil: Obj QUO(Obj, Obj) Obj POW(Obj, Obj) Obj MOD(Obj, Obj) - bint EQ(Obj opL, Obj opR) - bint LT(Obj opL, Obj opR) + Int EQ(Obj opL, Obj opR) + Int LT(Obj opL, Obj opR) cdef extern from "gap/bool.h" nogil: @@ -39,7 +39,7 @@ cdef extern from "gap/bool.h" nogil: cdef extern from "gap/calls.h" nogil: - bint IS_FUNC(Obj) + Int IS_FUNC(Obj) Obj CALL_0ARGS(Obj f) # 0 arguments Obj CALL_1ARGS(Obj f, Obj a1) # 1 argument Obj CALL_2ARGS(Obj f, Obj a1, Obj a2) @@ -61,7 +61,7 @@ cdef extern from "gap/gasman_intern.h" n cdef extern from "gap/gvars.h" nogil: - UInt GVarName "GVarName"(char* name) + UInt GVarName "GVarName"(const char* name) void AssGVar "AssGVar"(UInt gvar, Obj val) @@ -70,14 +70,16 @@ cdef extern from "gap/integer.h" nogil: cdef extern from "gap/intobj.h" nogil: - bint IS_INTOBJ(Obj obj) + Int IS_INTOBJ(Obj obj) Obj INTOBJ_INT(Int) Int INT_INTOBJ(Obj) cdef extern from "gap/io.h" nogil: - UInt OpenOutputStream(Obj stream) - UInt CloseOutput() + ctypedef struct TypOutputFile: + pass + UInt OpenOutputStream(TypOutputFile* output, Obj stream) + UInt CloseOutput(TypOutputFile* output) cdef extern from "gap/libgap-api.h" nogil: @@ -100,11 +102,11 @@ cdef extern from "gap/libgap-api.h" nogi cdef extern from "gap/lists.h" nogil: - bint IS_LIST(Obj lst) - int LEN_LIST(Obj lst) - Obj ELM_LIST(Obj lst, int pos) - Obj ELM0_LIST(Obj lst, int pos) - void ASS_LIST(Obj lst, int pos, Obj elt) + Int IS_LIST(Obj lst) + Int LEN_LIST(Obj lst) + Obj ELM_LIST(Obj lst, Int pos) + Obj ELM0_LIST(Obj lst, Int pos) + void ASS_LIST(Obj lst, Int pos, Obj elt) cdef extern from "gap/listfunc.h" nogil: @@ -116,13 +118,13 @@ cdef extern from "gap/macfloat.h" nogil: cdef extern from "gap/objects.h" nogil: - bint IS_MUTABLE_OBJ(Obj obj) + Int IS_MUTABLE_OBJ(Obj obj) Obj SHALLOW_COPY_OBJ(Obj obj) - Obj CopyObj(Obj obj, int mut) + Obj CopyObj(Obj obj, Int mut) UInt SIZE_OBJ(Obj obj) UInt TNUM_OBJ(Obj obj) - char* TNAM_OBJ(Obj obj) + const char* TNAM_OBJ(Obj obj) cdef enum TNUM: T_INT @@ -163,23 +165,23 @@ cdef extern from "gap/permutat.h" nogil: cdef extern from "gap/precord.h" nogil: - Obj NEW_PREC(int len) - int LEN_PREC(Obj rec) - int GET_RNAM_PREC(Obj rec, int i) - Obj GET_ELM_PREC(Obj rec, int i) + Obj NEW_PREC(UInt len) + UInt LEN_PREC(Obj rec) + Int GET_RNAM_PREC(Obj rec, UInt i) + Obj GET_ELM_PREC(Obj rec, UInt i) void AssPRec(Obj rec, UInt rnam, Obj val) cdef extern from "gap/records.h" nogil: - char* NAME_RNAM(UInt rnam) - bint IS_REC(Obj obj) + Obj NAME_RNAM(UInt rnam) + Int IS_REC(Obj obj) Obj ELM_REC(Obj rec, UInt rnam) - UInt RNamName(Char* name) + UInt RNamName(const Char* name) cdef extern from "gap/stringobj.h" nogil: char* CSTR_STRING(Obj list) - bint IS_STRING(Obj obj) - bint IsStringConv(Obj obj) - Obj NEW_STRING(Int) + Int IS_STRING(Obj obj) + Int IsStringConv(Obj obj) + Obj NEW_STRING(Int len) Obj MakeStringWithLen(const char* buf, size_t len) diff -up src/sage/libs/gap/libgap.pyx.orig src/sage/libs/gap/libgap.pyx --- src/sage/libs/gap/libgap.pyx.orig 2023-02-11 06:25:15.000000000 -0700 +++ src/sage/libs/gap/libgap.pyx 2023-03-13 09:42:01.117404579 -0600 @@ -695,7 +695,7 @@ class Gap(Parent): sage: libgap.List sage: libgap.GlobalRandomSource - + """ if name in dir(self.__class__): return getattr(self.__class__, name) diff -up src/sage/libs/gap/saved_workspace.py.orig src/sage/libs/gap/saved_workspace.py --- src/sage/libs/gap/saved_workspace.py.orig 2023-02-11 06:25:15.000000000 -0700 +++ src/sage/libs/gap/saved_workspace.py 2023-03-13 12:49:01.821288928 -0600 @@ -8,7 +8,7 @@ workspaces. import os import glob -from sage.env import GAP_ROOT_DIR +from sage.env import GAP_ROOT_DIRS from sage.interfaces.gap_workspace import gap_workspace_file @@ -31,7 +31,9 @@ def timestamp(): """ libgap_dir = os.path.dirname(__file__) libgap_files = glob.glob(os.path.join(libgap_dir, '*')) - gap_packages = glob.glob(os.path.join(GAP_ROOT_DIR, 'pkg', '*')) + gap_packages = [] + for path in GAP_ROOT_DIRS: + gap_packages += glob.glob(os.path.join(path, 'pkg', '*')) files = libgap_files + gap_packages if len(files) == 0: print('Unable to find LibGAP files.') diff -up src/sage/libs/gap/util.pyx.orig src/sage/libs/gap/util.pyx --- src/sage/libs/gap/util.pyx.orig 2023-02-11 06:25:15.000000000 -0700 +++ src/sage/libs/gap/util.pyx 2023-03-13 14:13:48.497467652 -0600 @@ -173,22 +173,9 @@ def gap_root(): sage: from sage.libs.gap.util import gap_root sage: gap_root() # random output - '/home/vbraun/opt/sage-5.3.rc0/local/gap/latest' + '/usr/share/gap;/usr/lib64/gap'] """ - if os.path.exists(sage.env.GAP_ROOT_DIR): - return sage.env.GAP_ROOT_DIR - - # Attempt to figure out the appropriate GAP_ROOT by reading the - # local/bin/gap shell script; this is an ugly hack that exists for - # historical reasons; the best approach to setting where Sage looks for - # the appropriate GAP_ROOT is to set the GAP_ROOT_DIR variable - SAGE_LOCAL = sage.env.SAGE_LOCAL - with open(os.path.join(SAGE_LOCAL, 'bin', 'gap')) as f: - gap_sh = f.read().splitlines() - gapdir = next(x for x in gap_sh if x.strip().startswith('GAP_ROOT')) - gapdir = gapdir.split('"')[1] - gapdir = gapdir.replace('$SAGE_LOCAL', SAGE_LOCAL) - return gapdir + return ';'.join(sage.env.GAP_ROOT_DIRS) # To ensure that we call initialize_libgap only once. @@ -362,15 +349,9 @@ cdef Obj gap_eval(str gap_string) except GAPError: Error, Variable: 'Complex' must have a value Syntax error: ; expected in stream:1 Complex Field with 53 bits of precision;; - ^^^^^^^^^^^^ + ^^^^^ Error, Variable: 'with' must have a value - Syntax error: ; expected in stream:1 - Complex Field with 53 bits of precision;; - ^^^^^^^^^^^^^^^^^^^^ Error, Variable: 'bits' must have a value - Syntax error: ; expected in stream:1 - Complex Field with 53 bits of precision;; - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Error, Variable: 'precision' must have a value Test that on a subsequent attempt we get the same message (no garbage was @@ -388,7 +369,7 @@ cdef Obj gap_eval(str gap_string) except """ initialize() cdef Obj result - cdef int i, j, nresults + cdef Int nresults # Careful: We need to keep a reference to the bytes object here # so that Cython doesn't deallocate it before GAP is done with diff -up src/sage/tests/gap_packages.py.orig src/sage/tests/gap_packages.py --- src/sage/tests/gap_packages.py.orig 2023-02-11 06:25:15.000000000 -0700 +++ src/sage/tests/gap_packages.py 2023-03-13 09:42:01.117404579 -0600 @@ -103,7 +103,7 @@ def all_installed_packages(ignore_dot_ga sage: from sage.tests.gap_packages import all_installed_packages sage: all_installed_packages() - (...'GAPDoc'...) + (...'gapdoc'...) sage: all_installed_packages(ignore_dot_gap=True) == all_installed_packages(gap=gap, ignore_dot_gap=True) True """