@@ -42,7 +42,7 @@ some bit shuffling.
42
42
from cysignals.signals cimport sig_on, sig_off, sig_error
43
43
44
44
from cpython.version cimport PY_MAJOR_VERSION
45
- from cpython.int cimport PyInt_AS_LONG, PyInt_FromLong
45
+ from cpython.long cimport PyLong_AsLong, PyLong_FromLong
46
46
from cpython.longintrepr cimport (_PyLong_New,
47
47
digit, PyLong_SHIFT, PyLong_MASK)
48
48
from libc.limits cimport LONG_MIN, LONG_MAX
@@ -353,7 +353,7 @@ cdef PyInt_FromGEN(GEN g):
353
353
reset_avma()
354
354
355
355
if not signe(g):
356
- return PyInt_FromLong (0 )
356
+ return PyLong_FromLong (0 )
357
357
358
358
cdef ulong u
359
359
if PY_MAJOR_VERSION == 2 :
@@ -365,10 +365,10 @@ cdef PyInt_FromGEN(GEN g):
365
365
# Check that <long>(u) or <long>(-u) does not overflow
366
366
if signe(g) >= 0 :
367
367
if u <= < ulong> LONG_MAX:
368
- return PyInt_FromLong (u)
368
+ return PyLong_FromLong (u)
369
369
else :
370
370
if u <= - < ulong> LONG_MIN:
371
- return PyInt_FromLong (- u)
371
+ return PyLong_FromLong (- u)
372
372
373
373
# Result does not fit in a C long
374
374
res = PyLong_FromINT(g)
@@ -545,13 +545,9 @@ cdef GEN PyObject_AsGEN(x) except? NULL:
545
545
sig_on()
546
546
g = gp_read_str(< bytes> x)
547
547
sig_off()
548
- elif isinstance (x, long ):
549
- sig_on()
550
- g = PyLong_AS_GEN(x)
551
- sig_off()
552
548
elif isinstance (x, int ):
553
549
sig_on()
554
- g = PyInt_AS_GEN (x)
550
+ g = PyLong_AS_GEN (x)
555
551
sig_off()
556
552
elif isinstance (x, float ):
557
553
sig_on()
@@ -609,11 +605,8 @@ def integer_to_gen(x):
609
605
... if pari(long(x)) != pari(x) or pari(int(x)) != pari(x):
610
606
... print(x)
611
607
"""
612
- if isinstance (x, long ):
613
- sig_on()
614
- return new_gen(PyLong_AS_GEN(x))
615
608
if isinstance (x, int ):
616
609
sig_on()
617
- return new_gen(stoi(PyInt_AS_LONG(x) ))
610
+ return new_gen(PyLong_AS_GEN(x ))
618
611
raise TypeError (" integer_to_gen() needs an int or long "
619
612
" argument, not {}" .format(type (x).__name__))
0 commit comments