diff -up src/sage/env.py.orig src/sage/env.py --- src/sage/env.py.orig 2019-04-08 12:21:12.403515647 -0600 +++ src/sage/env.py 2019-04-08 12:22:37.165993394 -0600 @@ -174,7 +174,7 @@ var('CONWAY_POLYNOMIALS_DATA_DIR', joi var('GRAPHS_DATA_DIR', join(SAGE_SHARE, 'graphs')) var('ELLCURVE_DATA_DIR', join(SAGE_SHARE, 'ellcurves')) var('POLYTOPE_DATA_DIR', join(SAGE_SHARE, 'reflexive_polytopes')) -var('GAP_ROOT_DIR', join(SAGE_SHARE, 'gap')) +var('GAP_ROOT_DIR', join('/usr','lib','gap')) var('THEBE_DIR', join(SAGE_SHARE, 'thebe')) var('COMBINATORIAL_DESIGN_DATA_DIR', join(SAGE_SHARE, 'combinatorial_designs')) var('CREMONA_MINI_DATA_DIR', join(SAGE_SHARE, 'cremona')) diff -up src/sage/interfaces/tests.py.orig src/sage/interfaces/tests.py --- src/sage/interfaces/tests.py.orig 2019-03-23 16:20:41.000000000 -0600 +++ src/sage/interfaces/tests.py 2019-04-08 12:32:57.223857758 -0600 @@ -33,7 +33,7 @@ Test that write errors to stderr are han sage: kwds = dict(shell=True, stdout=f, stderr=f) sage: subprocess.call("echo syntax error | ecl", **kwds) 0 - sage: subprocess.call("echo syntax error | gap", **kwds) + sage: subprocess.call("echo syntax error | gap", **kwds) in (0, 1) 0 sage: subprocess.call("echo syntax error | gp", **kwds) 0 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 2019-03-23 16:20:41.000000000 -0600 +++ src/sage/libs/gap/gap_includes.pxd 2019-04-08 12:34:27.782231417 -0600 @@ -76,18 +76,16 @@ cdef extern from "": cdef extern from "": - ctypedef void (*CallbackFunc)() - void GAP_Initialize(int argc, char ** argv, char ** env, - CallbackFunc, CallbackFunc) + """ + #define sig_GAP_Enter() {int t = GAP_Enter(); if (!t) sig_error();} + """ + ctypedef void (*GAP_CallbackFunc)() + void GAP_Initialize(int argc, char ** argv, + GAP_CallbackFunc markBagsCallback, GAP_CallbackFunc errorCallback, + int handleSignals) Obj GAP_EvalString(const char *) except * Obj GAP_EvalStringNoExcept "GAP_EvalString"(const char *) Obj GAP_ValueGlobalVariable(const char *) - - -cdef extern from "" nogil: - """ - #define sig_GAP_Enter() {int t = GAP_Enter(); if (!t) sig_error();} - """ cdef void GAP_EnterStack() cdef void GAP_LeaveStack() cdef int GAP_Enter() except 0 @@ -121,26 +119,31 @@ cdef extern from "": UInt TNUM_OBJ(Obj obj) char* TNAM_OBJ(Obj obj) - cdef int T_INTPOS - cdef int T_INTNEG - cdef int T_RAT - cdef int T_CYC - cdef int T_FFE - cdef int T_PERM2 - cdef int T_PERM4 - cdef int T_BOOL - cdef int T_CHAR - cdef int T_FUNCTION - cdef int T_MACFLOAT - cdef int T_PLIST - cdef int T_PLIST_CYC - cdef int T_BLIST - cdef int T_STRING - cdef int T_COMOBJ - cdef int T_POSOBJ - cdef int T_DATOBJ - cdef int T_WPOBJ - + cdef enum TNUM: + T_INT + T_INTPOS + T_INTNEG + T_RAT + T_CYC + T_FFE + T_MACFLOAT + T_PERM2 + T_PERM4 + T_TRANS2 + T_TRANS4 + T_PPERM2 + T_PPERM4 + T_BOOL + T_CHAR + T_FUNCTION + T_PLIST + T_PLIST_CYC + T_BLIST + T_STRING + T_COMOBJ + T_POSOBJ + T_DATOBJ + T_WPOBJ cdef extern from "": Obj NEW_PREC(int len) diff -up src/sage/libs/gap/libgap.pyx.orig src/sage/libs/gap/libgap.pyx --- src/sage/libs/gap/libgap.pyx.orig 2019-03-23 16:20:41.000000000 -0600 +++ src/sage/libs/gap/libgap.pyx 2019-04-08 12:25:35.700787082 -0600 @@ -233,14 +233,6 @@ from sage.misc.superseded import depreca ############################################################################ -cdef void report(Obj bag): - print(TNAM_OBJ(bag), SIZE_OBJ(bag)) - - -cdef void print_gasman_objects(): - CallbackForAllBags(report) - - from sage.misc.lazy_import import is_during_startup if is_during_startup(): import sys, traceback diff -up src/sage/libs/gap/util.pyx.orig src/sage/libs/gap/util.pyx --- src/sage/libs/gap/util.pyx.orig 2019-03-23 16:20:41.000000000 -0600 +++ src/sage/libs/gap/util.pyx 2019-04-08 12:37:02.323035697 -0600 @@ -14,19 +14,16 @@ Utility functions for GAP from __future__ import print_function, absolute_import -import os -import signal -import warnings +from libc.signal cimport signal, SIGCHLD, SIG_DFL from posix.dlfcn cimport dlopen, dlclose, RTLD_NOW, RTLD_GLOBAL -from libc.string cimport strcpy, strlen from cpython.exc cimport PyErr_Fetch, PyErr_Restore from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE from cpython.ref cimport PyObject, Py_XINCREF, Py_XDECREF -from cysignals.memory cimport sig_malloc -from cysignals.pysignals import containsignals -from cysignals.signals cimport sig_on, sig_off, sig_error +from cysignals.signals cimport sig_on, sig_off +import os +import warnings import sage.env from .gap_includes cimport * @@ -105,7 +102,7 @@ cdef class ObjWrapper(object): sage: hash(x) 0 """ - return (self.value) + return (self.value) cdef ObjWrapper wrap_obj(Obj obj): @@ -178,7 +175,7 @@ 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/lib/gap' """ if os.path.exists(sage.env.GAP_ROOT_DIR): return sage.env.GAP_ROOT_DIR @@ -197,7 +194,6 @@ def gap_root(): # To ensure that we call initialize_libgap only once. cdef bint _gap_is_initialized = False -cdef extern char **environ cdef char* _reset_error_output_cmd = """\ @@ -216,33 +212,6 @@ MakeImmutable(libgap_errout); """ -cdef char** copy_environ(char** env): - """ - Make a copy of the environment block given by ``env``. - - Returns a pointer to the copy, which is the caller's responsibility to - free. - """ - - cdef char** env_copy - cdef int envc = 0; - cdef int idx - cdef size_t size - - while env[envc]: - envc += 1 - - env_copy = sig_malloc((envc + 1) * sizeof(char*)) - - for idx in range(envc): - size = strlen(env[idx]) + 1 - env_copy[idx] = sig_malloc(size) - strcpy(env_copy[idx], env[idx]) - - env_copy[envc] = NULL - return env_copy - - cdef initialize(): """ Initialize the GAP library, if it hasn't already been @@ -253,25 +222,23 @@ cdef initialize(): sage: libgap(123) # indirect doctest 123 """ - global _gap_is_initialized, environ + global _gap_is_initialized if _gap_is_initialized: return # Hack to ensure that all symbols provided by libgap are loaded into the # global symbol table # Note: we could use RTLD_NOLOAD and avoid the subsequent dlclose() but # this isn't portable cdef void* handle - libgapname = str_to_bytes(sage.env.GAP_SO) - handle = dlopen(libgapname, RTLD_NOW | RTLD_GLOBAL) + handle = dlopen("libgap.so", RTLD_NOW | RTLD_GLOBAL) if handle is NULL: raise RuntimeError( "Could not dlopen() libgap even though it should already " "be loaded!") dlclose(handle) - # Define argv and environ variables, which we will pass in to + # Define argv variable, which we will pass in to # initialize GAP. Note that we must pass define the memory pool # size! - cdef char** env cdef char* argv[18] argv[0] = "sage" argv[1] = "-l" @@ -318,21 +285,15 @@ cdef initialize(): argv[argc] = NULL - env = copy_environ(environ) + sig_on() + # Initialize GAP but disable their SIGINT handler + GAP_Initialize(argc, argv, gasman_callback, error_handler, + handleSignals=False) + sig_off() - # Need to save/restore current SIGINT handling since GAP_Initialize - # currently clobbers it; it doesn't matter what we set SIGINT to - # temporarily. - with containsignals(): - sig_on() - try: - # Initialize GAP and capture any error messages. The - # initialization just prints any errors and does not - # use the error handler. - GAP_Initialize(argc, argv, env, &gasman_callback, - &error_handler) - finally: - sig_off() + # Disable GAP's SIGCHLD handler ChildStatusChanged(), which calls + # waitpid() on random child processes. + signal(SIGCHLD, SIG_DFL) # Set the ERROR_OUTPUT global in GAP to an output stream in which to # receive error output diff -up src/sage/tests/books/judson-abstract-algebra/sylow-sage.py.orig src/sage/tests/books/judson-abstract-algebra/sylow-sage.py --- src/sage/tests/books/judson-abstract-algebra/sylow-sage.py.orig 2019-03-23 16:20:43.000000000 -0600 +++ src/sage/tests/books/judson-abstract-algebra/sylow-sage.py 2019-04-08 12:37:39.859183332 -0600 @@ -225,8 +225,8 @@ r""" ~~~~~~~~~~~~~~~~~~~~~~ :: - sage: gap.version() - '4.10.0' + sage: gap.version() # random + '4.10.1' ~~~~~~~~~~~~~~~~~~~~~~ ::