mirror of
https://src.fedoraproject.org/rpms/sagemath.git
synced 2025-04-21 11:19:02 -04:00
84 lines
3.5 KiB
Diff
84 lines
3.5 KiB
Diff
diff -up src/sage/libs/pari/handle_error.pxd.orig src/sage/libs/pari/handle_error.pxd
|
|
--- src/sage/libs/pari/handle_error.pxd.orig 2015-10-11 17:43:43.037782565 -0300
|
|
+++ src/sage/libs/pari/handle_error.pxd 2015-10-11 17:46:28.004788882 -0300
|
|
@@ -1,5 +1,5 @@
|
|
include 'sage/libs/pari/decl.pxi'
|
|
|
|
cdef void _pari_init_error_handling()
|
|
-cdef int _pari_err_handle(GEN E) except 0
|
|
+cdef int _pari_handle_exception(long errnum_unused) except 0
|
|
cdef void _pari_err_recover(long errnum)
|
|
diff -up src/sage/libs/pari/handle_error.pyx.orig src/sage/libs/pari/handle_error.pyx
|
|
--- src/sage/libs/pari/handle_error.pyx.orig 2015-10-11 17:43:43.023782564 -0300
|
|
+++ src/sage/libs/pari/handle_error.pyx 2015-10-11 17:45:11.844785966 -0300
|
|
@@ -131,13 +131,13 @@ cdef void _pari_init_error_handling():
|
|
sage: pari('warning("test")')
|
|
*** user warning: test
|
|
"""
|
|
- global cb_pari_err_handle
|
|
+ global cb_pari_handle_exception
|
|
global cb_pari_err_recover
|
|
- cb_pari_err_handle = _pari_err_handle
|
|
+ cb_pari_handle_exception = _pari_handle_exception
|
|
cb_pari_err_recover = _pari_err_recover
|
|
|
|
|
|
-cdef int _pari_err_handle(GEN E) except 0:
|
|
+cdef int _pari_handle_exception(long errnum_unused) except 0:
|
|
"""
|
|
Convert a PARI error into a Sage exception, unless the error was
|
|
a stack overflow, in which case we enlarge the stack.
|
|
@@ -156,6 +156,7 @@ cdef int _pari_err_handle(GEN E) except
|
|
PariError: impossible inverse in gdiv: 0
|
|
|
|
"""
|
|
+ cdef GEN E = pari_err_last()
|
|
cdef long errnum = E[1]
|
|
if errnum == e_STACK:
|
|
# PARI is out of memory. We double the size of the PARI stack
|
|
@@ -165,15 +166,10 @@ cdef int _pari_err_handle(GEN E) except
|
|
|
|
sig_block()
|
|
cdef char* errstr
|
|
- cdef char* s
|
|
try:
|
|
errstr = pari_err2str(E)
|
|
pari_error_string = errstr.decode('ascii')
|
|
|
|
- s = closure_func_err()
|
|
- if s is not NULL:
|
|
- pari_error_string = s.decode('ascii') + ": " + pari_error_string
|
|
-
|
|
raise PariError(errnum, pari_error_string, pari_instance.new_gen_noclear(E))
|
|
finally:
|
|
pari_free(errstr)
|
|
diff -up src/sage/libs/pari/pari_instance.pxd.orig src/sage/libs/pari/pari_instance.pxd
|
|
--- src/sage/libs/pari/pari_instance.pxd.orig 2015-10-11 17:43:43.028782564 -0300
|
|
+++ src/sage/libs/pari/pari_instance.pxd 2015-10-11 17:45:37.884786963 -0300
|
|
@@ -7,6 +7,10 @@ cimport cython
|
|
|
|
from sage.libs.pari.gen cimport gen
|
|
|
|
+cdef extern from "gmp.h":
|
|
+ cdef void mp_get_memory_functions(void**, void**, void**)
|
|
+ cdef void mp_set_memory_functions(void*, void*, void*)
|
|
+
|
|
cpdef long prec_bits_to_words(unsigned long prec_in_bits)
|
|
|
|
cdef class PariInstance_auto(ParentWithBase):
|
|
diff -up src/sage/libs/pari/pari_instance.pyx.orig src/sage/libs/pari/pari_instance.pyx
|
|
--- src/sage/libs/pari/pari_instance.pyx.orig 2015-10-11 17:43:43.032782565 -0300
|
|
+++ src/sage/libs/pari/pari_instance.pyx 2015-10-11 17:46:14.596788369 -0300
|
|
@@ -429,7 +429,12 @@ cdef class PariInstance(PariInstance_aut
|
|
# The size here doesn't really matter, because we will allocate
|
|
# our own stack anyway. We ask PARI not to set up signal and
|
|
# error handlers.
|
|
+ cdef void *_gmp_malloc
|
|
+ cdef void *_gmp_realloc
|
|
+ cdef void *_gmp_free
|
|
+ mp_get_memory_functions(&_gmp_malloc, &_gmp_realloc, &_gmp_free)
|
|
pari_init_opts(10000, maxprime, INIT_DFTm)
|
|
+ mp_set_memory_functions(_gmp_malloc, _gmp_realloc, _gmp_free)
|
|
|
|
# Disable PARI's stack overflow checking which is incompatible
|
|
# with multi-threading.
|