Skip to content

Commit b7ebe5e

Browse files
Jonathan Kliemvidelec
authored andcommitted
only depend on Cython 0.29 instead of 0.29.20
1 parent 26a622f commit b7ebe5e

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

cypari2/Py_SET_SIZE.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "Python.h"
2+
3+
#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION < 9)
4+
// The function Py_SET_SIZE is defined starting with python 3.9.
5+
void Py_SET_SIZE(PyVarObject *o, Py_ssize_t size){
6+
Py_SIZE(o) = size;
7+
}
8+
#endif

cypari2/convert.pxd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ from .gen cimport Gen
44
from cpython.int cimport PyInt_AS_LONG
55
from cpython.float cimport PyFloat_AS_DOUBLE
66
from cpython.complex cimport PyComplex_RealAsDouble, PyComplex_ImagAsDouble
7+
from cpython.longintrepr cimport py_long
78

89

910
# Conversion PARI -> Python
@@ -59,7 +60,7 @@ cdef inline GEN doubles_to_COMPLEX(double re, double im):
5960
cdef inline GEN PyInt_AS_GEN(x):
6061
return stoi(PyInt_AS_LONG(x))
6162

62-
cdef GEN PyLong_AS_GEN(x)
63+
cdef GEN PyLong_AS_GEN(py_long x)
6364

6465
cdef inline GEN PyFloat_AS_GEN(x):
6566
return double_to_REAL(PyFloat_AS_DOUBLE(x))

cypari2/convert.pyx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ cdef extern from *:
5959
ctypedef struct PyLongObject:
6060
digit* ob_digit
6161

62-
void __Pyx_SET_SIZE(object, Py_ssize_t)
62+
cdef extern from "Py_SET_SIZE.h":
63+
void Py_SET_SIZE(py_long o, Py_ssize_t size)
6364

6465

6566
########################################################################
@@ -422,8 +423,8 @@ cdef PyLong_FromINT(GEN g):
422423
# Actual correct computed size
423424
cdef Py_ssize_t sizedigits_final = 0
424425

425-
x = _PyLong_New(sizedigits)
426-
cdef digit* D = (<PyLongObject*>x).ob_digit
426+
cdef py_long x = _PyLong_New(sizedigits)
427+
cdef digit* D = x.ob_digit
427428

428429
cdef digit d
429430
cdef ulong w
@@ -452,9 +453,9 @@ cdef PyLong_FromINT(GEN g):
452453

453454
# Set correct size
454455
if signe(g) > 0:
455-
__Pyx_SET_SIZE(x, sizedigits_final)
456+
Py_SET_SIZE(x, sizedigits_final)
456457
else:
457-
__Pyx_SET_SIZE(x, -sizedigits_final)
458+
Py_SET_SIZE(x, -sizedigits_final)
458459

459460
return x
460461

@@ -463,8 +464,8 @@ cdef PyLong_FromINT(GEN g):
463464
# Conversion Python -> PARI
464465
########################################################################
465466

466-
cdef GEN PyLong_AS_GEN(x):
467-
cdef const digit* D = (<PyLongObject*>x).ob_digit
467+
cdef GEN PyLong_AS_GEN(py_long x):
468+
cdef const digit* D = x.ob_digit
468469

469470
# Size of the input
470471
cdef size_t sizedigits

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def run(self):
6666
setup(
6767
name='cypari2',
6868
version=VERSION,
69-
setup_requires=['Cython>=0.28'],
69+
setup_requires=['Cython>=0.29'],
7070
install_requires=['cysignals>=1.7'],
7171
description="A Python interface to the number theory library PARI/GP",
7272
long_description=README,

0 commit comments

Comments
 (0)