diff --git a/build/pkgs/gmpy2/checksums.ini b/build/pkgs/gmpy2/checksums.ini index 63839391b4d..ebfd4a8cd75 100644 --- a/build/pkgs/gmpy2/checksums.ini +++ b/build/pkgs/gmpy2/checksums.ini @@ -1,4 +1,4 @@ tarball=gmpy2-VERSION.tar.gz -sha1=e8d72cd656ca0552b9d1cb88b1fb88eb442afc9c -md5=988143fd8996835c0784c0eda640d5f5 -cksum=1488318046 +sha1=03a0f6737febaa9ca2bc633b2358211d13968599 +md5=688995ca86881c384c30b6d2dd2807e7 +cksum=3437641682 diff --git a/build/pkgs/gmpy2/package-version.txt b/build/pkgs/gmpy2/package-version.txt index bee4f7e8826..55c98c93cd5 100644 --- a/build/pkgs/gmpy2/package-version.txt +++ b/build/pkgs/gmpy2/package-version.txt @@ -1 +1 @@ -2.1.0a1.p1 +2.1.0a2 diff --git a/build/pkgs/gmpy2/patches/PR-173-fix_segfault.patch b/build/pkgs/gmpy2/patches/PR-173-fix_segfault.patch deleted file mode 100644 index b39945b8fee..00000000000 --- a/build/pkgs/gmpy2/patches/PR-173-fix_segfault.patch +++ /dev/null @@ -1,151 +0,0 @@ -commit d915d9c4e2254798f54cfbcd0e292e9af21f5976 -Author: Vincent Klein -Date: Tue Nov 28 16:08:53 2017 +0100 - - gmpy2_cache.c : Fix issue #173 - - - Fix segfault when objects have custom `__mpz__`, `__mpq__`, - `__mpfr__` or `__mpc__` methods raising errors. - - - add doctests for these cases. - -diff --git a/src/gmpy2_cache.c b/src/gmpy2_cache.c -index 0d4b4f4..4588c29 100644 ---- a/src/gmpy2_cache.c -+++ b/src/gmpy2_cache.c -@@ -150,14 +150,17 @@ GMPy_MPZ_NewInit(PyTypeObject *type, PyObject *args, PyObject *keywds) - } - - if (PyObject_HasAttrString(n, "__mpz__")) { -- out = (PyObject*) PyObject_CallMethod(n, "__mpz__", NULL); -- if (!MPZ_Check(out)) { -- PyErr_Format(PyExc_TypeError, -- "object of type '%.200s' can not be interpreted as mpz", -- out->ob_type->tp_name); -- return NULL; -- } -- return out; -+ out = (PyObject *) PyObject_CallMethod(n, "__mpz__", NULL); -+ -+ if (out == NULL) -+ return out; -+ if (!MPZ_Check(out)) { -+ PyErr_Format(PyExc_TypeError, -+ "object of type '%.200s' can not be interpreted as mpz", -+ out->ob_type->tp_name); -+ return NULL; -+ } -+ return out; - } - - /* Try converting to integer. */ -@@ -455,18 +458,20 @@ GMPy_MPQ_NewInit(PyTypeObject *type, PyObject *args, PyObject *keywds) - /* Handle 1 argument. It must be non-complex number or an object with a __mpq__ method. */ - if (argc == 1) { - if (IS_REAL(n)) { -- return (PyObject*)GMPy_MPQ_From_Number(n, context); -+ return (PyObject *) GMPy_MPQ_From_Number(n, context); - } - - if (PyObject_HasAttrString(n, "__mpq__")) { -- out = (PyObject*) PyObject_CallMethod(n, "__mpq__", NULL); -- if (!MPQ_Check(out)) { -- PyErr_Format(PyExc_TypeError, -- "object of type '%.200s' can not be interpreted as mpq", -- out->ob_type->tp_name); -- return NULL; -- } -- return out; -+ out = (PyObject *) PyObject_CallMethod(n, "__mpq__", NULL); -+ if (out == NULL) -+ return out; -+ if (!MPQ_Check(out)) { -+ PyErr_Format(PyExc_TypeError, -+ "object of type '%.200s' can not be interpreted as mpq", -+ out->ob_type->tp_name); -+ return NULL; -+ } -+ return out; - } - - } -@@ -663,14 +668,17 @@ GMPy_MPFR_NewInit(PyTypeObject *type, PyObject *args, PyObject *keywds) - } - - if (PyObject_HasAttrString(arg0, "__mpfr__")) { -- out = (PyObject*) PyObject_CallMethod(arg0, "__mpfr__", NULL); -- if (!MPFR_Check(out)) { -- PyErr_Format(PyExc_TypeError, -- "object of type '%.200s' can not be interpreted as mpfr", -- out->ob_type->tp_name); -- return NULL; -- } -- return out; -+ out = (PyObject *) PyObject_CallMethod(arg0, "__mpfr__", NULL); -+ -+ if(out == NULL) -+ return out; -+ if (!MPFR_Check(out)) { -+ PyErr_Format(PyExc_TypeError, -+ "object of type '%.200s' can not be interpreted as mpfr", -+ out->ob_type->tp_name); -+ return NULL; -+ } -+ return out; - } - - TYPE_ERROR("mpfr() requires numeric or string argument"); -@@ -963,6 +971,8 @@ GMPy_MPC_NewInit(PyTypeObject *type, PyObject *args, PyObject *keywds) - - if (PyObject_HasAttrString(arg0, "__mpc__")) { - out = (PyObject*) PyObject_CallMethod(arg0, "__mpc__", NULL); -+ if(out == NULL) -+ return out; - if (!MPC_Check(out)) { - PyErr_Format(PyExc_TypeError, - "object of type '%.200s' can not be interpreted as mpc", -diff --git a/test/test_gmpy2_constructors.txt b/test/test_gmpy2_constructors.txt -index 2e53ddd..c52f119 100644 ---- a/test/test_gmpy2_constructors.txt -+++ b/test/test_gmpy2_constructors.txt -@@ -14,10 +14,16 @@ Test constructors via special methods - ... def __mpc__(self): return 'hello' - >>> class C: - ... pass -+>>> class D: -+... def __mpz__(self): raise TypeError -+... def __mpq__(self): raise TypeError -+... def __mpfr__(self): raise TypeError -+... def __mpc__(self): raise TypeError - - >>> a = A() - >>> b = B() - >>> c = C() -+>>> d = D() - - Test mpz conversion - ------------------- -@@ -94,3 +100,23 @@ TypeError: object of type 'str' can not be interpreted as mpc - Traceback (most recent call last): - ... - TypeError: mpc() requires numeric or string argument -+ -+Test special methods raising errors -+-------------------- -+>>> mpz(d) -+Traceback (most recent call last): -+... -+TypeError -+>>> mpq(d) -+Traceback (most recent call last): -+... -+TypeError -+>>> mpfr(d) -+Traceback (most recent call last): -+... -+TypeError -+>>> mpc(d) -+Traceback (most recent call last): -+... -+TypeError -+ diff --git a/build/pkgs/gmpy2/patches/PR-180-add_data_struct.patch b/build/pkgs/gmpy2/patches/PR-180-add_data_struct.patch deleted file mode 100644 index d0ccab0e107..00000000000 --- a/build/pkgs/gmpy2/patches/PR-180-add_data_struct.patch +++ /dev/null @@ -1,80 +0,0 @@ -commit 916b4eaefa2cbd09defbd57b1f89b3fcced4c9fe -Author: Jeroen Demeyer -Date: Thu Jan 25 10:25:15 2018 +0100 - - Replace mpc_set_fr_fr by two mpfr_set calls - -commit 82cfcac492b69ce3741d036e1741f58896ad1e48 -Author: Jeroen Demeyer -Date: Thu Jan 25 10:23:49 2018 +0100 - - Add data structures for the various types - -diff --git a/src/gmpy2.pxd b/src/gmpy2.pxd -index 7cdcc72..6d7d092 100644 ---- a/src/gmpy2.pxd -+++ b/src/gmpy2.pxd -@@ -1,14 +1,21 @@ - cdef extern from "gmp.h": - # gmp integers -+ ctypedef long mp_limb_t -+ - ctypedef struct __mpz_struct: -- pass -+ int _mp_alloc -+ int _mp_size -+ mp_limb_t* _mp_d -+ - ctypedef __mpz_struct mpz_t[1] - ctypedef __mpz_struct *mpz_ptr - ctypedef const __mpz_struct *mpz_srcptr - - # gmp rationals - ctypedef struct __mpq_struct: -- pass -+ __mpz_struct _mp_num -+ __mpz_struct _mp_den -+ - ctypedef __mpq_struct mpq_t[1] - ctypedef __mpq_struct *mpq_ptr - ctypedef const __mpq_struct *mpq_srcptr -@@ -21,8 +28,16 @@ cdef extern from "gmp.h": - - cdef extern from "mpfr.h": - # mpfr reals -+ ctypedef int mpfr_sign_t -+ ctypedef long mpfr_prec_t -+ ctypedef long mpfr_exp_t -+ - ctypedef struct __mpfr_struct: -- pass -+ mpfr_prec_t _mpfr_prec -+ mpfr_sign_t _mpfr_sign -+ mpfr_exp_t _mpfr_exp -+ mp_limb_t* _mpfr_d -+ - ctypedef __mpfr_struct mpfr_t[1] - ctypedef __mpfr_struct *mpfr_ptr - ctypedef const __mpfr_struct *mpfr_srcptr -@@ -45,7 +60,9 @@ cdef extern from "mpfr.h": - cdef extern from "mpc.h": - # mpc complexes - ctypedef struct __mpc_struct: -- pass -+ mpfr_t re -+ mpfr_t im -+ - ctypedef __mpc_struct mpc_t[1]; - ctypedef __mpc_struct *mpc_ptr; - ctypedef const __mpc_struct *mpc_srcptr; -@@ -147,5 +164,9 @@ cdef inline mpc GMPy_MPC_From_mpc(mpc_srcptr c): - # Build a gmpy2 mpc from a real part mpfr and an imaginary part mpfr - cdef inline mpc GMPy_MPC_From_mpfr(mpfr_srcptr re, mpfr_srcptr im): - cdef mpc res = GMPy_MPC_New(mpfr_get_prec(re), mpfr_get_prec(im), NULL) -- mpc_set_fr_fr(res.c, re, im, MPC_RNDNN) -+ # We intentionally use MPFR funtions instead of MPC functions here -+ # in order not to add an unneeded dependency on MPC. It's probably -+ # faster too this way. -+ mpfr_set(res.c.re, re, MPFR_RNDN) -+ mpfr_set(res.c.im, im, MPFR_RNDN) - return res diff --git a/build/pkgs/gmpy2/patches/PR-181-Fix_mpc_precision_issue.patch b/build/pkgs/gmpy2/patches/PR-181-Fix_mpc_precision_issue.patch deleted file mode 100644 index 4f44205be44..00000000000 --- a/build/pkgs/gmpy2/patches/PR-181-Fix_mpc_precision_issue.patch +++ /dev/null @@ -1,105 +0,0 @@ -commit a8c5d96e5821d8afec235a24669b93cd24c03380 -Author: Vincent Klein -Date: Thu Jan 25 15:49:13 2018 +0100 - - gmpy2_mpc_misc.c : Fix issue #179 - - - .real and .imag now return the same precision as their mpc - - - add doctests for these cases. - -commit f2a4f8b9ddfd53e66c6cfeee5f5e7f5d638cf755 -Author: Case Van Horsen -Date: Mon Jan 8 22:57:05 2018 -0800 - - Update copyright year. - -commit 76d96272c4f00a7894a218ca0dfabe325859de0d -Author: Case Van Horsen -Date: Mon Jan 8 22:24:27 2018 -0800 - - Remove unused macros. - -diff --git a/src/gmpy2_mpc_misc.c b/src/gmpy2_mpc_misc.c -index 12fb254..90aa99c 100644 ---- a/src/gmpy2_mpc_misc.c -+++ b/src/gmpy2_mpc_misc.c -@@ -8,7 +8,7 @@ - * 2008, 2009 Alex Martelli * - * * - * Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, * -- * 2015, 2016, 2017 Case Van Horsen * -+ * 2015, 2016, 2017, 2018 Case Van Horsen * - * * - * This file is part of GMPY2. * - * * -@@ -48,8 +48,6 @@ GMPy_Complex_Phase(PyObject *x, CTXT_Object *context) - return NULL; - } - -- SET_MPC_WAS_NAN(context, tempx); -- - result->rc = mpc_arg(result->f, tempx->c, GET_MPFR_ROUND(context)); - Py_DECREF((PyObject*)tempx); - -@@ -112,7 +110,6 @@ GMPy_Complex_Norm(PyObject *x, CTXT_Object *context) - } - - mpfr_clear_flags(); -- SET_MPC_WAS_NAN(context, tempx); - - result->rc = mpc_norm(result->f, tempx->c, GET_MPFR_ROUND(context)); - Py_DECREF((PyObject*)tempx); -@@ -245,8 +242,6 @@ GMPy_Complex_Rect(PyObject *x, PyObject *y, CTXT_Object *context) - return NULL; - } - -- SET_MPFR_MPFR_WAS_NAN(context, tempx, tempy); -- - mpfr_cos(mpc_realref(result->c), tempy->f, GET_REAL_ROUND(context)); - mpfr_mul(mpc_realref(result->c), mpc_realref(result->c), tempx->f, GET_REAL_ROUND(context)); - mpfr_sin(mpc_imagref(result->c), tempy->f, GET_IMAG_ROUND(context)); -@@ -309,8 +304,6 @@ GMPy_Complex_Proj(PyObject *x, CTXT_Object *context) - return NULL; - } - -- SET_MPC_WAS_NAN(context, tempx); -- - result->rc = mpc_proj(result->c, tempx->c, GET_MPC_ROUND(context)); - Py_DECREF((PyObject*)tempx); - -@@ -365,8 +358,6 @@ GMPy_MPC_Conjugate_Method(PyObject *self, PyObject *args) - return NULL; - } - -- SET_MPC_WAS_NAN(context, self); -- - result->rc = mpc_conj(result->c, MPC(self), GET_MPC_ROUND(context)); - - _GMPy_MPC_Cleanup(&result, context); -@@ -402,8 +393,10 @@ GMPy_MPC_GetImag_Attrib(MPC_Object *self, void *closure) - - CHECK_CONTEXT(context); - -- if ((result = GMPy_MPFR_New(0, context))) { -- SET_MPC_WAS_NAN(context, self); -+ mpfr_prec_t rprec = 0, iprec = 0; -+ mpc_get_prec2(&rprec, &iprec, self->c); -+ -+ if ((result = GMPy_MPFR_New(iprec, context))) { - result->rc = mpc_imag(result->f, self->c, GET_MPFR_ROUND(context)); - _GMPy_MPFR_Cleanup(&result, context); - } -@@ -420,8 +413,10 @@ GMPy_MPC_GetReal_Attrib(MPC_Object *self, void *closure) - - CHECK_CONTEXT(context); - -- if ((result = GMPy_MPFR_New(0, context))) { -- SET_MPC_WAS_NAN(context, self); -+ mpfr_prec_t rprec = 0, iprec = 0; -+ mpc_get_prec2(&rprec, &iprec, self->c); -+ -+ if ((result = GMPy_MPFR_New(rprec, context))) { - result->rc = mpc_real(result->f, self->c, context->ctx.mpfr_round); - _GMPy_MPFR_Cleanup(&result, context); - }