diff -Nru cypari2-1.2.1/autogen/args.py cypari2-1.3.1/autogen/args.py --- cypari2-1.2.1/autogen/args.py 2017-08-24 13:26:24.000000000 +0000 +++ cypari2-1.3.1/autogen/args.py 2018-10-03 13:53:56.000000000 +0000 @@ -61,6 +61,9 @@ else: self.default = default + # Name for a temporary variable. Only a few classes actually use this. + self.tmpname = "_" + self.name + def __repr__(self): s = self._typerepr() + " " + self.name if self.default is not None: @@ -145,10 +148,6 @@ """ Class for arguments which are passed as generic Python ``object``. """ - def __init__(self, *args, **kwds): - super(PariArgumentObject, self).__init__(*args, **kwds) - self.tmpname = "_" + self.name - def prototype_code(self): """ Return code to appear in the prototype of the Cython wrapper. diff -Nru cypari2-1.2.1/autogen/generator.py cypari2-1.3.1/autogen/generator.py --- cypari2-1.2.1/autogen/generator.py 2018-02-05 08:24:29.000000000 +0000 +++ cypari2-1.3.1/autogen/generator.py 2018-10-05 13:52:50.000000000 +0000 @@ -55,6 +55,7 @@ function_blacklist = {"O", # O(p^e) needs special parser support "alias", # Not needed and difficult documentation "listcreate", # "redundant and obsolete" according to PARI + "print", # Conflicts with Python builtin "allocatemem", # Better hand-written support in Pari class "global", # Invalid in Python (and obsolete) "inline", # Total confusion @@ -184,20 +185,33 @@ setrand(_n) clear_stack() - >>> G.handle_pari_function("bernvec", - ... cname="bernvec", prototype="L", - ... help="bernvec(x): this routine is obsolete, use bernfrac repeatedly.", - ... obsolete="2007-03-30", - ... **{"class":"basic", "section":"transcendental"}) - GEN bernvec(long) - def bernvec(self, long x): + >>> G.handle_pari_function("polredord", + ... cname="polredord", prototype="G", + ... help="polredord(x): this function is obsolete, use polredbest.", + ... obsolete="2008-07-20", + ... **{"class":"basic", "section":"number_fields"}) + GEN polredord(GEN) + def polredord(x): + r''' + This function is obsolete, use polredbest. + ''' + from warnings import warn + warn('the PARI/GP function polredord is obsolete (2008-07-20)', DeprecationWarning) + cdef GEN _x = x.g + sig_on() + cdef GEN _ret = polredord(_x) + return new_gen(_ret) + + def polredord(self, x): r''' - This routine is obsolete, kept for backward compatibility only. + This function is obsolete, use polredbest. ''' from warnings import warn - warn('the PARI/GP function bernvec is obsolete (2007-03-30)', DeprecationWarning) + warn('the PARI/GP function polredord is obsolete (2008-07-20)', DeprecationWarning) + x = objtogen(x) + cdef GEN _x = (x).g sig_on() - cdef GEN _ret = bernvec(x) + cdef GEN _ret = polredord(_x) return new_gen(_ret) """ diff -Nru cypari2-1.2.1/autogen/paths.py cypari2-1.3.1/autogen/paths.py --- cypari2-1.2.1/autogen/paths.py 2017-08-31 13:04:13.000000000 +0000 +++ cypari2-1.3.1/autogen/paths.py 2018-08-16 12:00:53.000000000 +0000 @@ -35,14 +35,18 @@ EXAMPLES:: + >>> import os >>> from autogen.parser import pari_share - >>> pari_share().endswith('/share/pari') + >>> os.path.isfile(os.path.join(pari_share(), "pari.desc")) True """ from subprocess import Popen, PIPE if not gppath: raise EnvironmentError("cannot find an installation of PARI/GP: make sure that the 'gp' program is in your $PATH") - gp = Popen([gppath, "-f", "-q"], stdin=PIPE, stdout=PIPE) + # Ignore GP_DATA_DIR environment variable + env = dict(os.environ) + env.pop("GP_DATA_DIR", None) + gp = Popen([gppath, "-f", "-q"], stdin=PIPE, stdout=PIPE, env=env) out = gp.communicate(b"print(default(datadir))")[0] # Convert out to str if needed if not isinstance(out, str): diff -Nru cypari2-1.2.1/cypari2/convert.pyx cypari2-1.3.1/cypari2/convert.pyx --- cypari2-1.2.1/cypari2/convert.pyx 2018-03-16 13:08:10.000000000 +0000 +++ cypari2-1.3.1/cypari2/convert.pyx 2018-10-02 15:06:07.000000000 +0000 @@ -45,7 +45,7 @@ from cpython.object cimport Py_SIZE from cpython.int cimport PyInt_AS_LONG -from cpython.longintrepr cimport (_PyLong_New, PyLongObject, +from cpython.longintrepr cimport (_PyLong_New, digit, PyLong_SHIFT, PyLong_MASK) from libc.limits cimport LONG_MIN, LONG_MAX from libc.math cimport INFINITY @@ -55,8 +55,12 @@ from .string_utils cimport to_string cdef extern from *: + ctypedef struct PyLongObject: + digit* ob_digit + Py_ssize_t* Py_SIZE_PTR "&Py_SIZE"(object) + #################################### # Integers #################################### diff -Nru cypari2-1.2.1/cypari2/gen.pxd cypari2-1.3.1/cypari2/gen.pxd --- cypari2-1.2.1/cypari2/gen.pxd 2018-02-05 08:24:29.000000000 +0000 +++ cypari2-1.3.1/cypari2/gen.pxd 2018-09-14 15:31:48.000000000 +0000 @@ -24,11 +24,12 @@ cdef dict itemcache cdef inline int cache(self, key, value) except -1: - """Add ``(key, value)`` to ``self.itemcache``.""" + """ + Add ``(key, value)`` to ``self.itemcache``. + """ if self.itemcache is None: - self.itemcache = {key: value} - else: - self.itemcache[key] = value + self.itemcache = {} + self.itemcache[key] = value @cython.final cdef class Gen(Gen_auto): diff -Nru cypari2-1.2.1/cypari2/gen.pyx cypari2-1.3.1/cypari2/gen.pyx --- cypari2-1.2.1/cypari2/gen.pyx 2018-07-13 10:08:51.000000000 +0000 +++ cypari2-1.3.1/cypari2/gen.pyx 2018-10-02 15:06:07.000000000 +0000 @@ -2813,7 +2813,7 @@ lift_centered = Gen_auto.centerlift - def padicprime(x): + def padicprime(self): """ The uniformizer of the p-adic ring this element lies in, as a t_INT. @@ -2836,8 +2836,7 @@ >>> y.padicprime().type() 't_INT' """ - sig_on() - return new_gen(gel(x.g, 2)) + return self.new_ref(gel(self.g, 2)) def precision(x, long n=-1): """ @@ -3405,7 +3404,7 @@ cdef Gen t0 = objtogen(n) sig_on() cdef long t = Zn_issquare(self.g, t0.g) - sig_off() + clear_stack() return t != 0 def Zn_sqrt(self, n): @@ -4695,7 +4694,10 @@ >>> pari('oo').type() 't_INFINITY' """ - return to_string(type_name(typ(self.g))) + sig_on() + s = type_name(typ(self.g)) + sig_off() + return to_string(s) def polinterpolate(self, ya, x): """ @@ -4796,7 +4798,7 @@ set_gel(r, 2, gmulgs(gel(r, 2), 2)) return new_gen(r) - def debug(self, long depth = -1): + def debug(self, long depth=-1): r""" Show the internal structure of self (like the ``\x`` command in gp). @@ -4816,40 +4818,9 @@ """ sig_on() dbgGEN(self.g, depth) - sig_off() + clear_stack() return - def bernvec(x): - r""" - Creates a vector containing, as rational numbers, the Bernoulli - numbers `B_0, B_2,\ldots, B_{2x}`. This routine is - obsolete. Use bernfrac instead each time you need a Bernoulli - number in exact form. - - Note: this routine is implemented using repeated independent calls - to bernfrac, which is faster than the standard recursion in exact - arithmetic. - - Examples: - - >>> from cypari2 import Pari - >>> pari = Pari() - - >>> import warnings - >>> with warnings.catch_warnings(record=True) as w: - ... warnings.simplefilter('always') - ... pari(8).bernvec() - ... assert len(w) == 1 - ... assert issubclass(w[0].category, DeprecationWarning) - [1, 1/6, -1/30, 1/42, -1/30, 5/66, -691/2730, 7/6, -3617/510] - >>> [pari(2*n).bernfrac() for n in range(9)] - [1, 1/6, -1/30, 1/42, -1/30, 5/66, -691/2730, 7/6, -3617/510] - """ - from warnings import warn - warn('the PARI/GP function bernvec() is obsolete: use repeated calls to bernfrac() instead', DeprecationWarning) - sig_on() - return new_gen(bernvec(x)) - def allocatemem(self, *args): """ Do not use this. Use ``pari.allocatemem()`` instead. diff -Nru cypari2-1.2.1/cypari2/handle_error.pyx cypari2-1.3.1/cypari2/handle_error.pyx --- cypari2-1.2.1/cypari2/handle_error.pyx 2018-01-11 13:14:52.000000000 +0000 +++ cypari2-1.3.1/cypari2/handle_error.pyx 2018-09-14 15:31:48.000000000 +0000 @@ -87,7 +87,7 @@ error("impossible inverse in Fp_inv: Mod(2, 6).") >>> E.component(2) Mod(2, 6) - """ + """ return self.args[2] def __repr__(self): @@ -98,7 +98,7 @@ >>> pari = cypari2.Pari() >>> PariError(11) PariError(11) - """ + """ return "PariError(%d)"%self.errnum() def __str__(self): @@ -118,7 +118,7 @@ ... print(err) _/_: impossible inverse in gdiv: 0 - A syntax error:: + A syntax error: >>> pari('!@#$%^&*()') Traceback (most recent call last): @@ -201,19 +201,6 @@ Reset the error string and jump back to ``sig_on()``, either to retry the code (in case of no error) or to make the already-raised exception known to Python. - - TEST: - - Perform a computation that requires doubling the default stack - several times: - - >>> import cypari2 - >>> pari = cypari2.Pari() - >>> pari.allocatemem(2**12, 2**26) - PARI stack size set to 4096 bytes, maximum size set to 67108864 - >>> x = pari('2^(2^26)') - >>> x == 2**(2**26) - True """ # An exception was raised. Jump to the signal-handling code # which will cause sig_on() to see the exception. diff -Nru cypari2-1.2.1/cypari2/paridecl.pxd cypari2-1.3.1/cypari2/paridecl.pxd --- cypari2-1.2.1/cypari2/paridecl.pxd 2018-07-10 10:30:54.000000000 +0000 +++ cypari2-1.3.1/cypari2/paridecl.pxd 2018-10-05 14:02:29.000000000 +0000 @@ -83,6 +83,7 @@ GEN ghalf GEN gen_0 GEN gnil + GEN err_e_STACK int PARI_SIGINT_block, PARI_SIGINT_pending void NEXT_PRIME_VIADIFF(long, byteptr) void PREC_PRIME_VIADIFF(long, byteptr) @@ -2715,7 +2716,6 @@ void out_term_color(PariOUT *out, long c) void out_vprintf(PariOUT *out, const char *fmt, va_list ap) char* pari_sprint0(const char *msg, GEN g, long flag) - void print(GEN g) extern int f_RAW, f_PRETTYMAT, f_PRETTY, f_TEX void print0(GEN g, long flag) void print1(GEN g) @@ -4937,7 +4937,7 @@ int is_real_t(long t) int is_recursive_t(long t) int is_scalar_t(long t) - int is_universal_constant(GEN x) + int _is_universal_constant "is_universal_constant"(GEN x) int is_vec_t(long t) int isint1(GEN x) int isintm1(GEN x) @@ -5166,6 +5166,12 @@ void pari_err_VAR(const char *f, GEN x, GEN y) void pari_err_ROOTS0(const char *f) + +# Work around a bug in PARI's is_universal_constant() +cdef inline int is_universal_constant(GEN x): + return _is_universal_constant(x) or (x is err_e_STACK) + + # Auto-generated declarations. There are taken from the PARI version # on the system, so they more up-to-date than the above. In case of # conflicting declarations, auto_paridecl should have priority. diff -Nru cypari2-1.2.1/cypari2/pari_instance.pyx cypari2-1.3.1/cypari2/pari_instance.pyx --- cypari2-1.2.1/cypari2/pari_instance.pyx 2018-02-05 08:24:29.000000000 +0000 +++ cypari2-1.3.1/cypari2/pari_instance.pyx 2018-09-14 15:31:48.000000000 +0000 @@ -572,11 +572,9 @@ self.init_primes(maxprime) # Initialize some constants - sig_on() self.PARI_ZERO = new_gen_noclear(gen_0) self.PARI_ONE = new_gen_noclear(gen_1) self.PARI_TWO = new_gen_noclear(gen_2) - sig_off() IF HAVE_PLOT_SVG: # If we are running under IPython, setup for displaying SVG plots. @@ -600,6 +598,10 @@ >>> pari.stacksize() 1000000 + Disable stack size warnings again: + + >>> pari.default("debugmem", 0) + .. WARNING:: Calling this method is dangerous since any further use of @@ -636,7 +638,7 @@ return "Interface to the PARI C library" def __hash__(self): - return 907629390 # hash('pari') + return 907629390 def set_debug_level(self, level): """ diff -Nru cypari2-1.2.1/cypari2.egg-info/PKG-INFO cypari2-1.3.1/cypari2.egg-info/PKG-INFO --- cypari2-1.2.1/cypari2.egg-info/PKG-INFO 2018-07-13 11:37:19.000000000 +0000 +++ cypari2-1.3.1/cypari2.egg-info/PKG-INFO 2018-10-05 17:20:24.000000000 +0000 @@ -1,12 +1,11 @@ Metadata-Version: 1.0 Name: cypari2 -Version: 1.2.1 +Version: 1.3.1 Summary: An interface to the number theory library libpari Home-page: https://github.com/defeo/cypari2 Author: Many people Author-email: sage-devel@googlegroups.com License: GNU General Public License, version 2 or later -Description-Content-Type: UNKNOWN Description: UNKNOWN Keywords: PARI/GP number theory Platform: UNKNOWN diff -Nru cypari2-1.2.1/debian/changelog cypari2-1.3.1/debian/changelog --- cypari2-1.2.1/debian/changelog 2018-12-19 01:26:11.000000000 +0000 +++ cypari2-1.3.1/debian/changelog 2019-01-15 12:32:37.000000000 +0000 @@ -1,3 +1,17 @@ +cypari2 (1.3.1-2) unstable; urgency=medium + + * Upload to unstable. + * Depend on cysignals (>= 1.8.1). + + -- Tobias Hansen Tue, 15 Jan 2019 13:32:37 +0100 + +cypari2 (1.3.1-1) experimental; urgency=medium + + * New upstream version. + * Drop 'Multi-Arch: same' for python-cypari2 and python3-cypari2. + + -- Tobias Hansen Wed, 02 Jan 2019 16:34:07 +0000 + cypari2 (1.2.1-3) unstable; urgency=medium * Team upload. diff -Nru cypari2-1.2.1/debian/control cypari2-1.3.1/debian/control --- cypari2-1.2.1/debian/control 2018-12-19 01:23:27.000000000 +0000 +++ cypari2-1.3.1/debian/control 2019-01-15 12:32:08.000000000 +0000 @@ -15,8 +15,8 @@ libjs-mathjax, python-all-dev, python3-all-dev, - python-cysignals-pari (>= 1.6.6), - python3-cysignals-pari (>= 1.6.6), + python-cysignals-pari (>= 1.8.1), + python3-cysignals-pari (>= 1.8.1), python-setuptools, python3-setuptools, python-sphinx, @@ -29,7 +29,6 @@ Package: python-cypari2 Architecture: any -Multi-Arch: same Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends} Breaks: sagemath (<< 8.1~) Description: Python interface to PARI -- Python 2 @@ -39,7 +38,6 @@ Package: python3-cypari2 Architecture: any -Multi-Arch: same Depends: ${python3:Depends}, ${shlibs:Depends}, ${misc:Depends} Breaks: sagemath (<< 8.1~) Description: Python interface to PARI -- Python 3 diff -Nru cypari2-1.2.1/debian/patches/disable-test-with-pari-bug.patch cypari2-1.3.1/debian/patches/disable-test-with-pari-bug.patch --- cypari2-1.2.1/debian/patches/disable-test-with-pari-bug.patch 2018-12-19 01:20:33.000000000 +0000 +++ cypari2-1.3.1/debian/patches/disable-test-with-pari-bug.patch 2019-01-02 16:05:55.000000000 +0000 @@ -6,7 +6,7 @@ --- a/cypari2/gen.pyx +++ b/cypari2/gen.pyx -@@ -3808,8 +3808,6 @@ +@@ -3833,8 +3833,6 @@ >>> G.galoissubfields(flag=1) [x, x^2 + 972, x^3 + 54, x^3 + 864, x^3 - 54, x^6 + 108] >>> G = pari('x^4 + 1').galoisinit() diff -Nru cypari2-1.2.1/PKG-INFO cypari2-1.3.1/PKG-INFO --- cypari2-1.2.1/PKG-INFO 2018-07-13 11:38:14.000000000 +0000 +++ cypari2-1.3.1/PKG-INFO 2018-10-05 17:20:54.000000000 +0000 @@ -1,12 +1,11 @@ Metadata-Version: 1.0 Name: cypari2 -Version: 1.2.1 +Version: 1.3.1 Summary: An interface to the number theory library libpari Home-page: https://github.com/defeo/cypari2 Author: Many people Author-email: sage-devel@googlegroups.com License: GNU General Public License, version 2 or later -Description-Content-Type: UNKNOWN Description: UNKNOWN Keywords: PARI/GP number theory Platform: UNKNOWN diff -Nru cypari2-1.2.1/setup.py cypari2-1.3.1/setup.py --- cypari2-1.2.1/setup.py 2017-07-28 12:49:19.000000000 +0000 +++ cypari2-1.3.1/setup.py 2018-10-02 15:06:07.000000000 +0000 @@ -52,6 +52,8 @@ self.directives = { "autotestdict.cdef": True, "binding": True, + "cdivision": True, + "language_level": 2, } self.distribution.ext_modules[:] = cythonize( diff -Nru cypari2-1.2.1/tests/rundoctest.py cypari2-1.3.1/tests/rundoctest.py --- cypari2-1.2.1/tests/rundoctest.py 2018-01-16 14:14:58.000000000 +0000 +++ cypari2-1.3.1/tests/rundoctest.py 2018-09-13 13:46:42.000000000 +0000 @@ -20,6 +20,11 @@ # the module to be __main__. cypari2.handle_error.PariError.__module__ = "__main__" +# Disable stack size warning messages +pari = cypari2.Pari() +pari.default("debugmem", 0) + + failed = 0 attempted = 0 for mod in [cypari2.closure, cypari2.convert, cypari2.gen, @@ -30,7 +35,7 @@ print("="*80) print("Testing {}".format(mod.__name__)) - test = doctest.testmod(mod, optionflags=doctest.ELLIPSIS|doctest.REPORT_NDIFF) + test = doctest.testmod(mod, optionflags=doctest.ELLIPSIS|doctest.REPORT_NDIFF, verbose=False) failed += test.failed attempted += test.attempted @@ -39,4 +44,4 @@ print(" attempted = {}".format(attempted)) print(" failed = {}".format(failed)) -sys.exit(failed) +sys.exit(1 if failed else 0) diff -Nru cypari2-1.2.1/VERSION cypari2-1.3.1/VERSION --- cypari2-1.2.1/VERSION 2018-07-13 10:08:51.000000000 +0000 +++ cypari2-1.3.1/VERSION 2018-10-05 14:45:31.000000000 +0000 @@ -1 +1 @@ -1.2.1 +1.3.1