Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 90acc7f

Browse files
committed
Surround GAP_ValueGlobalVariable calls by GAP_Enter/GAP_Leave
1 parent eb8cd42 commit 90acc7f

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/sage/libs/gap/element.pyx

+14-5
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,13 @@ cdef char *gap_element_repr(Obj obj):
164164
GAP on the command-line (i.e. when evaluating an expression that returns
165165
that object.
166166
"""
167-
168-
cdef Obj func = GAP_ValueGlobalVariable("ViewObj")
169-
return capture_stdout(func, obj)
167+
cdef Obj func
168+
try:
169+
GAP_Enter()
170+
func = GAP_ValueGlobalVariable("ViewObj")
171+
return capture_stdout(func, obj)
172+
finally:
173+
GAP_Leave()
170174

171175

172176
cdef char *gap_element_str(Obj obj):
@@ -179,8 +183,13 @@ cdef char *gap_element_str(Obj obj):
179183
slightly different approach more closely mirroring Python's str/repr
180184
difference (though this does not map perfectly onto GAP).
181185
"""
182-
cdef Obj func = GAP_ValueGlobalVariable("Print")
183-
return capture_stdout(func, obj)
186+
cdef Obj func
187+
try:
188+
GAP_Enter()
189+
func = GAP_ValueGlobalVariable("Print")
190+
return capture_stdout(func, obj)
191+
finally:
192+
GAP_Leave()
184193

185194

186195
cdef Obj make_gap_record(sage_dict) except NULL:

0 commit comments

Comments
 (0)