diff --git a/README.rst b/README.rst index 64b68f9..46b1acf 100644 --- a/README.rst +++ b/README.rst @@ -48,6 +48,8 @@ Requirements: or install from source. - Python >= 3.9 - pip +- `cysignals `_ >= 1.7 +- Cython >= 3.0 Install cypari2 via the Python Package Index (PyPI) via diff --git a/cypari2/closure.pyx b/cypari2/closure.pyx index 44615fe..42c370e 100644 --- a/cypari2/closure.pyx +++ b/cypari2/closure.pyx @@ -31,8 +31,6 @@ Examples: # https://www.gnu.org/licenses/ # **************************************************************************** -from __future__ import absolute_import, division, print_function - from cysignals.signals cimport sig_on, sig_off, sig_block, sig_unblock, sig_error from cpython.tuple cimport * diff --git a/cypari2/convert.pyx b/cypari2/convert.pyx index 667f922..c8f93cf 100644 --- a/cypari2/convert.pyx +++ b/cypari2/convert.pyx @@ -39,8 +39,6 @@ some bit shuffling. # https://www.gnu.org/licenses/ # **************************************************************************** -from __future__ import absolute_import, division, print_function - from cysignals.signals cimport sig_on, sig_off, sig_error from cpython.version cimport PY_MAJOR_VERSION diff --git a/cypari2/gen.pxd b/cypari2/gen.pxd index 0d51866..9579dee 100644 --- a/cypari2/gen.pxd +++ b/cypari2/gen.pxd @@ -1,3 +1,4 @@ +cimport cython from cpython.object cimport PyObject from .types cimport GEN, pari_sp diff --git a/cypari2/gen.pyx b/cypari2/gen.pyx index 60a4b4f..a109244 100644 --- a/cypari2/gen.pyx +++ b/cypari2/gen.pyx @@ -55,8 +55,6 @@ AUTHORS: # https://www.gnu.org/licenses/ # **************************************************************************** -from __future__ import absolute_import, division, print_function - cimport cython from cpython.object cimport (Py_EQ, Py_NE, Py_LE, Py_GE, Py_LT, PyTypeObject) @@ -143,6 +141,7 @@ cdef extern from *: GEN old_nfbasis(GEN x, GEN * y, GEN p) +@cython.trashcan(True) cdef class Gen(Gen_base): """ Wrapper for a PARI ``GEN`` with memory management. diff --git a/cypari2/handle_error.pyx b/cypari2/handle_error.pyx index f32664b..5789ee2 100644 --- a/cypari2/handle_error.pyx +++ b/cypari2/handle_error.pyx @@ -21,7 +21,7 @@ AUTHORS: # https://www.gnu.org/licenses/ # **************************************************************************** -from __future__ import absolute_import, division, print_function +from cpython cimport PyErr_Occurred from cysignals.signals cimport sig_block, sig_unblock, sig_error diff --git a/cypari2/pari_instance.pyx b/cypari2/pari_instance.pyx index 9a57fbc..65d705a 100644 --- a/cypari2/pari_instance.pyx +++ b/cypari2/pari_instance.pyx @@ -243,6 +243,15 @@ Reset default precision for the following tests: >>> pari.set_real_precision_bits(53) +Test the trashcan mechanism (without the trashcan, this would cause +a stack overflow): + +>>> pari.allocatemem(2**27, silent=True) +>>> L = [pari(i) for i in range(2**20)] +>>> x = pari.Pi() +>>> del L +>>> del x + Test that interrupts work properly: >>> pari.allocatemem(8000000, 2**29) @@ -275,8 +284,6 @@ Test that changing the stack size using ``default`` works properly: # https://www.gnu.org/licenses/ # **************************************************************************** -from __future__ import absolute_import, division - import sys from libc.stdio cimport * cimport cython diff --git a/cypari2/stack.pyx b/cypari2/stack.pyx index 04ffcca..b4d51fe 100644 --- a/cypari2/stack.pyx +++ b/cypari2/stack.pyx @@ -14,7 +14,6 @@ Memory management for Gens on the PARI stack or the heap # http://www.gnu.org/licenses/ # **************************************************************************** -from __future__ import absolute_import, division, print_function cimport cython from cpython.ref cimport PyObject diff --git a/pyproject.toml b/pyproject.toml index ff82406..a2c5735 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] requires = ["setuptools", - "Cython>=0.29", + "Cython>=3.0", "cysignals>=1.7"] # We need access to the autogen package at build time. # Hence we declare a custom build backend. diff --git a/setup.py b/setup.py index 51f4c95..c1775b5 100755 --- a/setup.py +++ b/setup.py @@ -35,9 +35,9 @@ def finalize_options(self): "autotestdict.cdef": True, "binding": True, "cdivision": True, - "language_level": 2, "legacy_implicit_noexcept": True, "c_api_binop_methods": True, + "language_level": "3str", } _build_ext.finalize_options(self)