Commits (1)
......@@ -19,7 +19,7 @@ from cpython.object cimport Py_SIZE
from cpython.int cimport PyInt_AS_LONG
from cpython.long cimport PyLong_AsLong
from cpython.number cimport PyNumber_Index, PyIndex_Check
from cpython.longintrepr cimport PyLongObject, PyLong_SHIFT, digit
from cpython.longintrepr cimport py_long, PyLong_SHIFT, digit
from sage.libs.gmp.mpz cimport mpz_fits_slong_p, mpz_get_si
from sage.rings.integer_fake cimport is_Integer, Integer_AS_MPZ
......@@ -208,7 +208,7 @@ cdef inline bint integer_check_long_py(x, long* value, int* err):
return 0
# x is a Python "long" (called "int" on Python 3)
cdef const digit* D = (<PyLongObject*>x).ob_digit
cdef const digit* D = (<py_long>x).ob_digit
cdef Py_ssize_t size = Py_SIZE(x)
# We assume that PyLong_SHIFT is 15 on a 32-bit system and 30 on a
......
......@@ -28,7 +28,7 @@ AUTHORS:
from cpython.object cimport Py_SIZE
from cpython.int cimport PyInt_FromLong
from cpython.long cimport PyLong_FromLong
from cpython.longintrepr cimport _PyLong_New, PyLongObject, digit, PyLong_SHIFT
from cpython.longintrepr cimport _PyLong_New, py_long, digit, PyLong_SHIFT
from .mpz cimport *
cdef extern from *:
......@@ -54,7 +54,7 @@ cdef mpz_get_pylong_large(mpz_srcptr z):
cdef size_t nbits = mpz_sizeinbase(z, 2)
cdef size_t pylong_size = (nbits + PyLong_SHIFT - 1) // PyLong_SHIFT
L = _PyLong_New(pylong_size)
mpz_export((<PyLongObject*>L).ob_digit, NULL,
mpz_export(L.ob_digit, NULL,
-1, sizeof(digit), 0, PyLong_nails, z)
if mpz_sgn(z) < 0:
# Set correct size (use a pointer to hack around Cython's
......@@ -91,7 +91,7 @@ cdef int mpz_set_pylong(mpz_ptr z, L) except -1:
if pylong_size < 0:
pylong_size = -pylong_size
mpz_import(z, pylong_size, -1, sizeof(digit), 0, PyLong_nails,
(<PyLongObject*>L).ob_digit)
(<py_long>L).ob_digit)
if Py_SIZE(L) < 0:
mpz_neg(z, z)
......