File tree Expand file tree Collapse file tree 2 files changed +9
-11
lines changed Expand file tree Collapse file tree 2 files changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ from libc.limits cimport LONG_MIN, LONG_MAX
52
52
from libc.math cimport INFINITY
53
53
54
54
from .paridecl cimport *
55
- from .stack cimport new_gen
55
+ from .stack cimport new_gen, reset_avma
56
56
from .string_utils cimport to_string, to_bytes
57
57
58
58
cdef extern from * :
@@ -351,15 +351,13 @@ cdef PyObject_FromGEN(GEN g):
351
351
352
352
353
353
cdef PyInt_FromGEN(GEN g):
354
- global avma
355
- av = avma
356
-
357
354
# First convert the input to a t_INT
358
- g = gtoi(g)
359
-
360
- # Reset avma now. This is OK as long as we are not calling further
361
- # PARI functions before this function returns.
362
- avma = av
355
+ try :
356
+ g = gtoi(g)
357
+ finally :
358
+ # Reset avma now. This is OK as long as we are not calling further
359
+ # PARI functions before this function returns.
360
+ reset_avma()
363
361
364
362
if not signe(g):
365
363
return PyInt_FromLong(0 )
Original file line number Diff line number Diff line change @@ -3046,7 +3046,7 @@ cdef class Gen(Gen_base):
3046
3046
return False , None
3047
3047
else :
3048
3048
t = itos(gissquare(x.g))
3049
- sig_off ()
3049
+ clear_stack ()
3050
3050
return t != 0
3051
3051
3052
3052
def issquarefree (self ):
@@ -3153,7 +3153,7 @@ cdef class Gen(Gen_base):
3153
3153
sig_on()
3154
3154
s = Zn_sqrt(self .g, t0.g)
3155
3155
if s == NULL :
3156
- sig_off ()
3156
+ clear_stack ()
3157
3157
raise ValueError (" %s is not a square modulo %s " % (self , n))
3158
3158
return new_gen(s)
3159
3159
You can’t perform that action at this time.
0 commit comments