Skip to content

Commit

Permalink
Surround GAP_ValueGlobalVariable calls by GAP_Enter/GAP_Leave
Browse files Browse the repository at this point in the history
  • Loading branch information
collares committed Feb 13, 2023
1 parent c70ae12 commit d458e35
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/sage/libs/gap/element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,13 @@ cdef char *gap_element_repr(Obj obj):
GAP on the command-line (i.e. when evaluating an expression that returns
that object.
"""

cdef Obj func = GAP_ValueGlobalVariable("ViewObj")
return capture_stdout(func, obj)
cdef Obj func
try:
GAP_Enter()
func = GAP_ValueGlobalVariable("ViewObj")
return capture_stdout(func, obj)
finally:
GAP_Leave()


cdef char *gap_element_str(Obj obj):
Expand All @@ -179,8 +183,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:
Expand Down

0 comments on commit d458e35

Please sign in to comment.