diff options
Diffstat (limited to 'numpy')
21 files changed, 94 insertions, 631 deletions
diff --git a/numpy/_pytesttester.py b/numpy/_pytesttester.py index 56eb3ac67..8b6e3217e 100644 --- a/numpy/_pytesttester.py +++ b/numpy/_pytesttester.py @@ -164,8 +164,6 @@ class PytestTester: # Ignore python2.7 -3 warnings pytest_args += [ - r"-W ignore:in 3\.x, __setslice__:DeprecationWarning", - r"-W ignore:in 3\.x, __getslice__:DeprecationWarning", r"-W ignore:buffer\(\) not supported in 3\.x:DeprecationWarning", r"-W ignore:CObject type is not supported in 3\.x:DeprecationWarning", r"-W ignore:comparing unequal types not supported in 3\.x:DeprecationWarning", diff --git a/numpy/core/include/numpy/ndarraytypes.h b/numpy/core/include/numpy/ndarraytypes.h index ad98d562b..bec6fcf30 100644 --- a/numpy/core/include/numpy/ndarraytypes.h +++ b/numpy/core/include/numpy/ndarraytypes.h @@ -353,21 +353,12 @@ struct NpyAuxData_tag { #define NPY_USE_PYMEM 1 + #if NPY_USE_PYMEM == 1 - /* numpy sometimes calls PyArray_malloc() with the GIL released. On Python - 3.3 and older, it was safe to call PyMem_Malloc() with the GIL released. - On Python 3.4 and newer, it's better to use PyMem_RawMalloc() to be able - to use tracemalloc. On Python 3.6, calling PyMem_Malloc() with the GIL - released is now a fatal error in debug mode. */ -# if PY_VERSION_HEX >= 0x03040000 -# define PyArray_malloc PyMem_RawMalloc -# define PyArray_free PyMem_RawFree -# define PyArray_realloc PyMem_RawRealloc -# else -# define PyArray_malloc PyMem_Malloc -# define PyArray_free PyMem_Free -# define PyArray_realloc PyMem_Realloc -# endif +/* use the Raw versions which are safe to call with the GIL released */ +#define PyArray_malloc PyMem_RawMalloc +#define PyArray_free PyMem_RawFree +#define PyArray_realloc PyMem_RawRealloc #else #define PyArray_malloc malloc #define PyArray_free free diff --git a/numpy/core/include/numpy/npy_3kcompat.h b/numpy/core/include/numpy/npy_3kcompat.h index 6fe53caa1..dbb5bd506 100644 --- a/numpy/core/include/numpy/npy_3kcompat.h +++ b/numpy/core/include/numpy/npy_3kcompat.h @@ -60,13 +60,7 @@ static NPY_INLINE int PyInt_Check(PyObject *op) { PySlice_GetIndicesEx((PySliceObject *)op, nop, start, end, step, slicelength) #endif -/* <2.7.11 and <3.4.4 have the wrong argument type for Py_EnterRecursiveCall */ -#if (PY_VERSION_HEX < 0x02070B00) || \ - ((0x03000000 <= PY_VERSION_HEX) && (PY_VERSION_HEX < 0x03040400)) - #define Npy_EnterRecursiveCall(x) Py_EnterRecursiveCall((char *)(x)) -#else - #define Npy_EnterRecursiveCall(x) Py_EnterRecursiveCall(x) -#endif +#define Npy_EnterRecursiveCall(x) Py_EnterRecursiveCall(x) /* Py_SETREF was added in 3.5.2, and only if Py_LIMITED_API is absent */ #if PY_VERSION_HEX < 0x03050200 @@ -488,8 +482,6 @@ PyObject_Cmp(PyObject *i1, PyObject *i2, int *cmp) * The main job here is to get rid of the improved error handling * of PyCapsules. It's a shame... */ -#if PY_VERSION_HEX >= 0x03000000 - static NPY_INLINE PyObject * NpyCapsule_FromVoidPtr(void *ptr, void (*dtor)(PyObject *)) { @@ -534,41 +526,6 @@ NpyCapsule_Check(PyObject *ptr) return PyCapsule_CheckExact(ptr); } -#else - -static NPY_INLINE PyObject * -NpyCapsule_FromVoidPtr(void *ptr, void (*dtor)(void *)) -{ - return PyCObject_FromVoidPtr(ptr, dtor); -} - -static NPY_INLINE PyObject * -NpyCapsule_FromVoidPtrAndDesc(void *ptr, void* context, - void (*dtor)(void *, void *)) -{ - return PyCObject_FromVoidPtrAndDesc(ptr, context, dtor); -} - -static NPY_INLINE void * -NpyCapsule_AsVoidPtr(PyObject *ptr) -{ - return PyCObject_AsVoidPtr(ptr); -} - -static NPY_INLINE void * -NpyCapsule_GetDesc(PyObject *obj) -{ - return PyCObject_GetDesc(obj); -} - -static NPY_INLINE int -NpyCapsule_Check(PyObject *ptr) -{ - return PyCObject_Check(ptr); -} - -#endif - #ifdef __cplusplus } #endif diff --git a/numpy/core/include/numpy/npy_common.h b/numpy/core/include/numpy/npy_common.h index 27b83f7b5..c2e755958 100644 --- a/numpy/core/include/numpy/npy_common.h +++ b/numpy/core/include/numpy/npy_common.h @@ -369,18 +369,8 @@ typedef long npy_long; typedef float npy_float; typedef double npy_double; -/* - * Hash value compatibility. - * As of Python 3.2 hash values are of type Py_hash_t. - * Previous versions use C long. - */ -#if PY_VERSION_HEX < 0x03020000 -typedef long npy_hash_t; -#define NPY_SIZEOF_HASH_T NPY_SIZEOF_LONG -#else typedef Py_hash_t npy_hash_t; #define NPY_SIZEOF_HASH_T NPY_SIZEOF_INTP -#endif /* * Disabling C99 complex usage: a lot of C code in numpy/scipy rely on being diff --git a/numpy/core/src/common/ucsnarrow.c b/numpy/core/src/common/ucsnarrow.c index 125235381..946a72257 100644 --- a/numpy/core/src/common/ucsnarrow.c +++ b/numpy/core/src/common/ucsnarrow.c @@ -107,12 +107,11 @@ PyUCS2Buffer_AsUCS4(Py_UNICODE const *ucs2, npy_ucs4 *ucs4, int ucs2len, int ucs * new_reference: PyUnicodeObject */ NPY_NO_EXPORT PyUnicodeObject * -PyUnicode_FromUCS4(char const *src, Py_ssize_t size, int swap, int align) +PyUnicode_FromUCS4(char const *src_char, Py_ssize_t size, int swap, int align) { Py_ssize_t ucs4len = size / sizeof(npy_ucs4); - /* FIXME: This is safe, but better to rewrite to not cast away const */ - npy_ucs4 *buf = (npy_ucs4 *)(char *)src; - int alloc = 0; + npy_ucs4 const *src = (npy_ucs4 const *)src_char; + npy_ucs4 *buf = NULL; PyUnicodeObject *ret; /* swap and align if needed */ @@ -122,22 +121,22 @@ PyUnicode_FromUCS4(char const *src, Py_ssize_t size, int swap, int align) PyErr_NoMemory(); goto fail; } - alloc = 1; memcpy(buf, src, size); if (swap) { byte_swap_vector(buf, ucs4len, sizeof(npy_ucs4)); } + src = buf; } /* trim trailing zeros */ - while (ucs4len > 0 && buf[ucs4len - 1] == 0) { + while (ucs4len > 0 && src[ucs4len - 1] == 0) { ucs4len--; } /* produce PyUnicode object */ #ifdef Py_UNICODE_WIDE { - ret = (PyUnicodeObject *)PyUnicode_FromUnicode((Py_UNICODE const*)buf, + ret = (PyUnicodeObject *)PyUnicode_FromUnicode((Py_UNICODE const*)src, (Py_ssize_t) ucs4len); if (ret == NULL) { goto fail; @@ -153,7 +152,7 @@ PyUnicode_FromUCS4(char const *src, Py_ssize_t size, int swap, int align) PyErr_NoMemory(); goto fail; } - ucs2len = PyUCS2Buffer_FromUCS4(tmp, buf, ucs4len); + ucs2len = PyUCS2Buffer_FromUCS4(tmp, src, ucs4len); ret = (PyUnicodeObject *)PyUnicode_FromUnicode(tmp, (Py_ssize_t) ucs2len); free(tmp); if (ret == NULL) { @@ -162,13 +161,13 @@ PyUnicode_FromUCS4(char const *src, Py_ssize_t size, int swap, int align) } #endif - if (alloc) { + if (buf) { free(buf); } return ret; fail: - if (alloc) { + if (buf) { free(buf); } return NULL; diff --git a/numpy/core/src/multiarray/arrayobject.c b/numpy/core/src/multiarray/arrayobject.c index 5a7f85b1a..82eda3464 100644 --- a/numpy/core/src/multiarray/arrayobject.c +++ b/numpy/core/src/multiarray/arrayobject.c @@ -706,35 +706,37 @@ static int _myunincmp(npy_ucs4 const *s1, npy_ucs4 const *s2, int len1, int len2) { npy_ucs4 const *sptr; - /* FIXME: Casting away const makes the below easier to write, but should - * still be safe. - */ - npy_ucs4 *s1t = (npy_ucs4 *)s1, *s2t = (npy_ucs4 *)s2; + npy_ucs4 *s1t = NULL; + npy_ucs4 *s2t = NULL; int val; npy_intp size; int diff; + /* Replace `s1` and `s2` with aligned copies if needed */ if ((npy_intp)s1 % sizeof(npy_ucs4) != 0) { size = len1*sizeof(npy_ucs4); s1t = malloc(size); memcpy(s1t, s1, size); + s1 = s1t; } if ((npy_intp)s2 % sizeof(npy_ucs4) != 0) { size = len2*sizeof(npy_ucs4); s2t = malloc(size); memcpy(s2t, s2, size); + s2 = s1t; } - val = PyArray_CompareUCS4(s1t, s2t, PyArray_MIN(len1,len2)); + + val = PyArray_CompareUCS4(s1, s2, PyArray_MIN(len1,len2)); if ((val != 0) || (len1 == len2)) { goto finish; } if (len2 > len1) { - sptr = s2t+len1; + sptr = s2+len1; val = -1; diff = len2-len1; } else { - sptr = s1t+len2; + sptr = s1+len2; val = 1; diff=len1-len2; } @@ -747,10 +749,11 @@ _myunincmp(npy_ucs4 const *s1, npy_ucs4 const *s2, int len1, int len2) val = 0; finish: - if (s1t != s1) { + /* Cleanup the aligned copies */ + if (s1t) { free(s1t); } - if (s2t != s2) { + if (s2t) { free(s2t); } return val; diff --git a/numpy/core/src/multiarray/buffer.c b/numpy/core/src/multiarray/buffer.c index c04c14a61..892a4db68 100644 --- a/numpy/core/src/multiarray/buffer.c +++ b/numpy/core/src/multiarray/buffer.c @@ -21,59 +21,6 @@ **************** Implement Buffer Protocol **************************** *************************************************************************/ -/* removed multiple segment interface */ - -#if !defined(NPY_PY3K) -static Py_ssize_t -array_getsegcount(PyArrayObject *self, Py_ssize_t *lenp) -{ - if (lenp) { - *lenp = PyArray_NBYTES(self); - } - if (PyArray_ISONESEGMENT(self)) { - return 1; - } - if (lenp) { - *lenp = 0; - } - return 0; -} - -static Py_ssize_t -array_getreadbuf(PyArrayObject *self, Py_ssize_t segment, void **ptrptr) -{ - if (segment != 0) { - PyErr_SetString(PyExc_ValueError, - "accessing non-existing array segment"); - return -1; - } - if (PyArray_ISONESEGMENT(self)) { - *ptrptr = PyArray_DATA(self); - return PyArray_NBYTES(self); - } - PyErr_SetString(PyExc_ValueError, "array is not a single segment"); - *ptrptr = NULL; - return -1; -} - - -static Py_ssize_t -array_getwritebuf(PyArrayObject *self, Py_ssize_t segment, void **ptrptr) -{ - if (PyArray_FailUnlessWriteable(self, "buffer source array") < 0) { - return -1; - } - return array_getreadbuf(self, segment, (void **) ptrptr); -} - -static Py_ssize_t -array_getcharbuf(PyArrayObject *self, Py_ssize_t segment, constchar **ptrptr) -{ - return array_getreadbuf(self, segment, (void **) ptrptr); -} -#endif /* !defined(NPY_PY3K) */ - - /************************************************************************* * PEP 3118 buffer protocol * @@ -952,12 +899,6 @@ _dealloc_cached_buffer_info(PyObject *self) /*************************************************************************/ NPY_NO_EXPORT PyBufferProcs array_as_buffer = { -#if !defined(NPY_PY3K) - (readbufferproc)array_getreadbuf, /*bf_getreadbuffer*/ - (writebufferproc)array_getwritebuf, /*bf_getwritebuffer*/ - (segcountproc)array_getsegcount, /*bf_getsegcount*/ - (charbufferproc)array_getcharbuf, /*bf_getcharbuffer*/ -#endif (getbufferproc)array_getbuffer, (releasebufferproc)0, }; diff --git a/numpy/core/src/multiarray/common.c b/numpy/core/src/multiarray/common.c index 141bc2fd6..11139c99f 100644 --- a/numpy/core/src/multiarray/common.c +++ b/numpy/core/src/multiarray/common.c @@ -166,11 +166,7 @@ PyArray_DTypeFromObjectHelper(PyObject *obj, int maxdims, goto fail; } #if defined(NPY_PY3K) - #if PY_VERSION_HEX >= 0x03030000 itemsize = PyUnicode_GetLength(temp); - #else - itemsize = PyUnicode_GET_SIZE(temp); - #endif #else itemsize = PyString_GET_SIZE(temp); #endif @@ -222,11 +218,7 @@ PyArray_DTypeFromObjectHelper(PyObject *obj, int maxdims, goto fail; } #if defined(NPY_PY3K) - #if PY_VERSION_HEX >= 0x03030000 itemsize = PyUnicode_GetLength(temp); - #else - itemsize = PyUnicode_GET_SIZE(temp); - #endif #else itemsize = PyString_GET_SIZE(temp); #endif diff --git a/numpy/core/src/multiarray/descriptor.c b/numpy/core/src/multiarray/descriptor.c index 8f3225dba..9a242033d 100644 --- a/numpy/core/src/multiarray/descriptor.c +++ b/numpy/core/src/multiarray/descriptor.c @@ -43,6 +43,24 @@ static PyArray_Descr * _use_inherit(PyArray_Descr *type, PyObject *newobj, int *errflag); static PyArray_Descr * +_arraydescr_run_converter(PyObject *arg, int align) +{ + PyArray_Descr *type = NULL; + if (align) { + if (PyArray_DescrAlignConverter(arg, &type) == NPY_FAIL) { + return NULL; + } + } + else { + if (PyArray_DescrConverter(arg, &type) == NPY_FAIL) { + return NULL; + } + } + assert(type != NULL); + return type; +} + +static PyArray_Descr * _arraydescr_from_ctypes_type(PyTypeObject *type) { PyObject *_numpy_dtype_ctypes; @@ -232,15 +250,9 @@ _convert_from_tuple(PyObject *obj, int align) if (PyTuple_GET_SIZE(obj) != 2) { return NULL; } - if (align) { - if (!PyArray_DescrAlignConverter(PyTuple_GET_ITEM(obj, 0), &type)) { - return NULL; - } - } - else { - if (!PyArray_DescrConverter(PyTuple_GET_ITEM(obj, 0), &type)) { - return NULL; - } + type = _arraydescr_run_converter(PyTuple_GET_ITEM(obj, 0), align); + if (type == NULL) { + return NULL; } val = PyTuple_GET_ITEM(obj,1); /* try to interpret next item as a type */ @@ -411,7 +423,6 @@ static PyArray_Descr * _convert_from_array_descr(PyObject *obj, int align) { int n, i, totalsize; - int ret; PyObject *fields, *item, *newobj; PyObject *name, *tup, *title; PyObject *nameslist; @@ -491,31 +502,22 @@ _convert_from_array_descr(PyObject *obj, int align) /* Process rest */ if (PyTuple_GET_SIZE(item) == 2) { - if (align) { - ret = PyArray_DescrAlignConverter(PyTuple_GET_ITEM(item, 1), - &conv); - } - else { - ret = PyArray_DescrConverter(PyTuple_GET_ITEM(item, 1), &conv); + conv = _arraydescr_run_converter(PyTuple_GET_ITEM(item, 1), align); + if (conv == NULL) { + goto fail; } } else if (PyTuple_GET_SIZE(item) == 3) { newobj = PyTuple_GetSlice(item, 1, 3); - if (align) { - ret = PyArray_DescrAlignConverter(newobj, &conv); - } - else { - ret = PyArray_DescrConverter(newobj, &conv); - } + conv = _arraydescr_run_converter(newobj, align); Py_DECREF(newobj); + if (conv == NULL) { + goto fail; + } } else { goto fail; } - if (ret == NPY_FAIL) { - goto fail; - } - if ((PyDict_GetItem(fields, name) != NULL) || (title && PyBaseString_Check(title) @@ -616,7 +618,6 @@ _convert_from_list(PyObject *obj, int align) PyArray_Descr *new; PyObject *key, *tup; PyObject *nameslist = NULL; - int ret; int maxalign = 0; /* Types with fields need the Python C API for field access */ char dtypeflags = NPY_NEEDS_PYAPI; @@ -643,13 +644,8 @@ _convert_from_list(PyObject *obj, int align) for (i = 0; i < n; i++) { tup = PyTuple_New(2); key = PyUString_FromFormat("f%d", i); - if (align) { - ret = PyArray_DescrAlignConverter(PyList_GET_ITEM(obj, i), &conv); - } - else { - ret = PyArray_DescrConverter(PyList_GET_ITEM(obj, i), &conv); - } - if (ret == NPY_FAIL) { + conv = _arraydescr_run_converter(PyList_GET_ITEM(obj, i), align); + if (conv == NULL) { Py_DECREF(tup); Py_DECREF(key); goto fail; @@ -1091,7 +1087,7 @@ _convert_from_dict(PyObject *obj, int align) totalsize = 0; for (i = 0; i < n; i++) { PyObject *tup, *descr, *ind, *title, *name, *off; - int len, ret, _align = 1; + int len, _align = 1; PyArray_Descr *newdescr; /* Build item to insert (descr, offset, [title])*/ @@ -1115,14 +1111,9 @@ _convert_from_dict(PyObject *obj, int align) Py_DECREF(ind); goto fail; } - if (align) { - ret = PyArray_DescrAlignConverter(descr, &newdescr); - } - else { - ret = PyArray_DescrConverter(descr, &newdescr); - } + newdescr = _arraydescr_run_converter(descr, align); Py_DECREF(descr); - if (ret == NPY_FAIL) { + if (newdescr == NULL) { Py_DECREF(tup); Py_DECREF(ind); goto fail; @@ -1168,7 +1159,9 @@ _convert_from_dict(PyObject *obj, int align) "not divisible by the field alignment %d " "with align=True", offset, newdescr->alignment); - ret = NPY_FAIL; + Py_DECREF(ind); + Py_DECREF(tup); + goto fail; } else if (offset + newdescr->elsize > totalsize) { totalsize = offset + newdescr->elsize; @@ -1181,11 +1174,6 @@ _convert_from_dict(PyObject *obj, int align) PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(totalsize)); totalsize += newdescr->elsize; } - if (ret == NPY_FAIL) { - Py_DECREF(ind); - Py_DECREF(tup); - goto fail; - } if (len == 3) { PyTuple_SET_ITEM(tup, 2, title); } @@ -1223,9 +1211,6 @@ _convert_from_dict(PyObject *obj, int align) } } Py_DECREF(tup); - if (ret == NPY_FAIL) { - goto fail; - } dtypeflags |= (newdescr->flags & NPY_FROM_FIELDS); } @@ -2292,12 +2277,8 @@ arraydescr_new(PyTypeObject *NPY_UNUSED(subtype), return NULL; } - if (align) { - if (!PyArray_DescrAlignConverter(odescr, &conv)) { - return NULL; - } - } - else if (!PyArray_DescrConverter(odescr, &conv)) { + conv = _arraydescr_run_converter(odescr, align); + if (conv == NULL) { return NULL; } @@ -2980,32 +2961,13 @@ PyArray_DescrAlignConverter(PyObject *obj, PyArray_Descr **at) NPY_NO_EXPORT int PyArray_DescrAlignConverter2(PyObject *obj, PyArray_Descr **at) { - if (PyDict_Check(obj) || PyDictProxy_Check(obj)) { - *at = _convert_from_dict(obj, 1); - } - else if (PyBytes_Check(obj)) { - *at = _convert_from_commastring(obj, 1); - } - else if (PyUnicode_Check(obj)) { - PyObject *tmp; - tmp = PyUnicode_AsASCIIString(obj); - *at = _convert_from_commastring(tmp, 1); - Py_DECREF(tmp); - } - else if (PyList_Check(obj)) { - *at = _convert_from_array_descr(obj, 1); + if (obj == Py_None) { + *at = NULL; + return NPY_SUCCEED; } else { - return PyArray_DescrConverter2(obj, at); - } - if (*at == NULL) { - if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_ValueError, - "data-type-descriptor not understood"); - } - return NPY_FAIL; + return PyArray_DescrAlignConverter(obj, at); } - return NPY_SUCCEED; } @@ -3304,10 +3266,6 @@ static PyNumberMethods descr_as_number = { (binaryfunc)0, /* nb_add */ (binaryfunc)0, /* nb_subtract */ (binaryfunc)0, /* nb_multiply */ - #if defined(NPY_PY3K) - #else - (binaryfunc)0, /* nb_divide */ - #endif (binaryfunc)0, /* nb_remainder */ (binaryfunc)0, /* nb_divmod */ (ternaryfunc)0, /* nb_power */ diff --git a/numpy/core/src/multiarray/methods.c b/numpy/core/src/multiarray/methods.c index ae26bbd4a..55c74eeb2 100644 --- a/numpy/core/src/multiarray/methods.c +++ b/numpy/core/src/multiarray/methods.c @@ -2641,51 +2641,6 @@ array_complex(PyArrayObject *self, PyObject *NPY_UNUSED(args)) return c; } -#ifndef NPY_PY3K - -static PyObject * -array_getslice(PyArrayObject *self, PyObject *args) -{ - PyObject *start, *stop, *slice, *result; - if (!PyArg_ParseTuple(args, "OO:__getslice__", &start, &stop)) { - return NULL; - } - - slice = PySlice_New(start, stop, NULL); - if (slice == NULL) { - return NULL; - } - - /* Deliberately delegate to subclasses */ - result = PyObject_GetItem((PyObject *)self, slice); - Py_DECREF(slice); - return result; -} - -static PyObject * -array_setslice(PyArrayObject *self, PyObject *args) -{ - PyObject *start, *stop, *value, *slice; - if (!PyArg_ParseTuple(args, "OOO:__setslice__", &start, &stop, &value)) { - return NULL; - } - - slice = PySlice_New(start, stop, NULL); - if (slice == NULL) { - return NULL; - } - - /* Deliberately delegate to subclasses */ - if (PyObject_SetItem((PyObject *)self, slice, value) < 0) { - Py_DECREF(slice); - return NULL; - } - Py_DECREF(slice); - Py_RETURN_NONE; -} - -#endif - NPY_NO_EXPORT PyMethodDef array_methods[] = { /* for subtypes */ @@ -2705,12 +2660,6 @@ NPY_NO_EXPORT PyMethodDef array_methods[] = { (PyCFunction)array_function, METH_VARARGS | METH_KEYWORDS, NULL}, -#ifndef NPY_PY3K - {"__unicode__", - (PyCFunction)array_unicode, - METH_NOARGS, NULL}, -#endif - /* for the sys module */ {"__sizeof__", (PyCFunction) array_sizeof, @@ -2749,23 +2698,6 @@ NPY_NO_EXPORT PyMethodDef array_methods[] = { (PyCFunction) array_format, METH_VARARGS, NULL}, -#ifndef NPY_PY3K - /* - * While we could put these in `tp_sequence`, its' easier to define them - * in terms of PyObject* arguments. - * - * We must provide these for compatibility with code that calls them - * directly. They are already deprecated at a language level in python 2.7, - * but are removed outright in python 3. - */ - {"__getslice__", - (PyCFunction) array_getslice, - METH_VARARGS, NULL}, - {"__setslice__", - (PyCFunction) array_setslice, - METH_VARARGS, NULL}, -#endif - /* Original and Extended methods added 2005 */ {"all", (PyCFunction)array_all, diff --git a/numpy/core/src/multiarray/number.c b/numpy/core/src/multiarray/number.c index dabc866ff..b19cdce55 100644 --- a/numpy/core/src/multiarray/number.c +++ b/numpy/core/src/multiarray/number.c @@ -32,10 +32,6 @@ static PyObject * array_inplace_subtract(PyArrayObject *m1, PyObject *m2); static PyObject * array_inplace_multiply(PyArrayObject *m1, PyObject *m2); -#if !defined(NPY_PY3K) -static PyObject * -array_inplace_divide(PyArrayObject *m1, PyObject *m2); -#endif static PyObject * array_inplace_true_divide(PyArrayObject *m1, PyObject *m2); static PyObject * @@ -353,20 +349,6 @@ array_multiply(PyArrayObject *m1, PyObject *m2) return PyArray_GenericBinaryFunction(m1, m2, n_ops.multiply); } -#if !defined(NPY_PY3K) -static PyObject * -array_divide(PyArrayObject *m1, PyObject *m2) -{ - PyObject *res; - - BINOP_GIVE_UP_IF_NEEDED(m1, m2, nb_divide, array_divide); - if (try_binary_elide(m1, m2, &array_inplace_divide, &res, 0)) { - return res; - } - return PyArray_GenericBinaryFunction(m1, m2, n_ops.divide); -} -#endif - static PyObject * array_remainder(PyArrayObject *m1, PyObject *m2) { @@ -381,7 +363,6 @@ array_divmod(PyArrayObject *m1, PyObject *m2) return PyArray_GenericBinaryFunction(m1, m2, n_ops.divmod); } -#if PY_VERSION_HEX >= 0x03050000 /* Need this to be version dependent on account of the slot check */ static PyObject * array_matrix_multiply(PyArrayObject *m1, PyObject *m2) @@ -399,7 +380,6 @@ array_inplace_matrix_multiply( "Use 'a = a @ b' instead of 'a @= b'."); return NULL; } -#endif /* * Determine if object is a scalar and if so, convert the object @@ -728,16 +708,6 @@ array_inplace_multiply(PyArrayObject *m1, PyObject *m2) return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.multiply); } -#if !defined(NPY_PY3K) -static PyObject * -array_inplace_divide(PyArrayObject *m1, PyObject *m2) -{ - INPLACE_GIVE_UP_IF_NEEDED( - m1, m2, nb_inplace_divide, array_inplace_divide); - return PyArray_GenericInplaceBinaryFunction(m1, m2, n_ops.divide); -} -#endif - static PyObject * array_inplace_remainder(PyArrayObject *m1, PyObject *m2) { @@ -1008,9 +978,6 @@ NPY_NO_EXPORT PyNumberMethods array_as_number = { (binaryfunc)array_add, /*nb_add*/ (binaryfunc)array_subtract, /*nb_subtract*/ (binaryfunc)array_multiply, /*nb_multiply*/ -#if !defined(NPY_PY3K) - (binaryfunc)array_divide, /*nb_divide*/ -#endif (binaryfunc)array_remainder, /*nb_remainder*/ (binaryfunc)array_divmod, /*nb_divmod*/ (ternaryfunc)array_power, /*nb_power*/ @@ -1046,9 +1013,6 @@ NPY_NO_EXPORT PyNumberMethods array_as_number = { (binaryfunc)array_inplace_add, /*nb_inplace_add*/ (binaryfunc)array_inplace_subtract, /*nb_inplace_subtract*/ (binaryfunc)array_inplace_multiply, /*nb_inplace_multiply*/ -#if !defined(NPY_PY3K) - (binaryfunc)array_inplace_divide, /*nb_inplace_divide*/ -#endif (binaryfunc)array_inplace_remainder, /*nb_inplace_remainder*/ (ternaryfunc)array_inplace_power, /*nb_inplace_power*/ (binaryfunc)array_inplace_left_shift, /*nb_inplace_lshift*/ @@ -1062,8 +1026,7 @@ NPY_NO_EXPORT PyNumberMethods array_as_number = { (binaryfunc)array_inplace_floor_divide, /*nb_inplace_floor_divide*/ (binaryfunc)array_inplace_true_divide, /*nb_inplace_true_divide*/ (unaryfunc)array_index, /*nb_index */ -#if PY_VERSION_HEX >= 0x03050000 + (binaryfunc)array_matrix_multiply, /*nb_matrix_multiply*/ (binaryfunc)array_inplace_matrix_multiply, /*nb_inplace_matrix_multiply*/ -#endif }; diff --git a/numpy/core/src/multiarray/scalarapi.c b/numpy/core/src/multiarray/scalarapi.c index b669a3e76..ecbf0218f 100644 --- a/numpy/core/src/multiarray/scalarapi.c +++ b/numpy/core/src/multiarray/scalarapi.c @@ -656,7 +656,6 @@ PyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base) itemsize = (((itemsize - 1) >> 2) + 1) << 2; } } -#if PY_VERSION_HEX >= 0x03030000 if (type_num == NPY_UNICODE) { PyObject *u, *args; int byteorder; @@ -684,7 +683,6 @@ PyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base) Py_DECREF(args); return obj; } -#endif if (type->tp_itemsize != 0) { /* String type */ obj = type->tp_alloc(type, itemsize); @@ -716,79 +714,6 @@ PyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base) memcpy(destptr, data, itemsize); return obj; } -#if PY_VERSION_HEX < 0x03030000 - else if (type_num == NPY_UNICODE) { - /* tp_alloc inherited from Python PyBaseObject_Type */ - PyUnicodeObject *uni = (PyUnicodeObject*)obj; - size_t length = itemsize >> 2; - Py_UNICODE *dst; -#ifndef Py_UNICODE_WIDE - char *buffer; - Py_UNICODE *tmp; - int alloc = 0; - - length *= 2; -#endif - /* Set uni->str so that object can be deallocated on failure */ - uni->str = NULL; - uni->defenc = NULL; - uni->hash = -1; - dst = PyObject_MALLOC(sizeof(Py_UNICODE) * (length + 1)); - if (dst == NULL) { - Py_DECREF(obj); - PyErr_NoMemory(); - return NULL; - } -#ifdef Py_UNICODE_WIDE - memcpy(dst, data, itemsize); - if (swap) { - byte_swap_vector(dst, length, 4); - } - uni->str = dst; - uni->str[length] = 0; - uni->length = length; -#else - /* need aligned data buffer */ - if ((swap) || ((((npy_intp)data) % descr->alignment) != 0)) { - buffer = malloc(itemsize); - if (buffer == NULL) { - PyObject_FREE(dst); - Py_DECREF(obj); - PyErr_NoMemory(); - } - alloc = 1; - memcpy(buffer, data, itemsize); - if (swap) { - byte_swap_vector(buffer, itemsize >> 2, 4); - } - } - else { - buffer = data; - } - - /* - * Allocated enough for 2-characters per itemsize. - * Now convert from the data-buffer - */ - length = PyUCS2Buffer_FromUCS4(dst, - (npy_ucs4 *)buffer, itemsize >> 2); - if (alloc) { - free(buffer); - } - /* Resize the unicode result */ - tmp = PyObject_REALLOC(dst, sizeof(Py_UNICODE)*(length + 1)); - if (tmp == NULL) { - PyObject_FREE(dst); - Py_DECREF(obj); - return NULL; - } - uni->str = tmp; - uni->str[length] = 0; - uni->length = length; -#endif - return obj; - } -#endif /* PY_VERSION_HEX < 0x03030000 */ else { PyVoidScalarObject *vobj = (PyVoidScalarObject *)obj; vobj->base = NULL; diff --git a/numpy/core/src/multiarray/scalartypes.c.src b/numpy/core/src/multiarray/scalartypes.c.src index 4cef01f89..4ce214429 100644 --- a/numpy/core/src/multiarray/scalartypes.c.src +++ b/numpy/core/src/multiarray/scalartypes.c.src @@ -226,20 +226,6 @@ gentype_@name@(PyObject *m1, PyObject *m2) /**end repeat**/ -#if !defined(NPY_PY3K) -/**begin repeat - * - * #name = divide# - */ -static PyObject * -gentype_@name@(PyObject *m1, PyObject *m2) -{ - BINOP_GIVE_UP_IF_NEEDED(m1, m2, nb_@name@, gentype_@name@); - return PyArray_Type.tp_as_number->nb_@name@(m1, m2); -} -/**end repeat**/ -#endif - /* Get a nested slot, or NULL if absent */ #define GET_NESTED_SLOT(type, group, slot) \ ((type)->group == NULL ? NULL : (type)->group->slot) @@ -1104,9 +1090,6 @@ static PyNumberMethods gentype_as_number = { (binaryfunc)gentype_add, /*nb_add*/ (binaryfunc)gentype_subtract, /*nb_subtract*/ (binaryfunc)gentype_multiply, /*nb_multiply*/ -#if !defined(NPY_PY3K) - (binaryfunc)gentype_divide, /*nb_divide*/ -#endif (binaryfunc)gentype_remainder, /*nb_remainder*/ (binaryfunc)gentype_divmod, /*nb_divmod*/ (ternaryfunc)gentype_power, /*nb_power*/ @@ -1137,9 +1120,6 @@ static PyNumberMethods gentype_as_number = { 0, /*inplace_add*/ 0, /*inplace_subtract*/ 0, /*inplace_multiply*/ -#if !defined(NPY_PY3K) - 0, /*inplace_divide*/ -#endif 0, /*inplace_remainder*/ 0, /*inplace_power*/ 0, /*inplace_lshift*/ @@ -1152,10 +1132,8 @@ static PyNumberMethods gentype_as_number = { 0, /*nb_inplace_floor_divide*/ 0, /*nb_inplace_true_divide*/ (unaryfunc)NULL, /*nb_index*/ -#if PY_VERSION_HEX >= 0x03050000 0, /*np_matmul*/ 0, /*np_inplace_matmul*/ -#endif }; @@ -1659,6 +1637,11 @@ gentype_itemset(PyObject *NPY_UNUSED(self), PyObject *NPY_UNUSED(args)) return NULL; } +/* This function matches the Python 2.7 PyBufferProcs.bf_getreadbuffer + * interface, but no longer needs to. In the future we could consider + * rewriting callers to use `gentype_getbuffer`, or inline the function body + * at the caller. + */ static Py_ssize_t gentype_getreadbuf(PyObject *, Py_ssize_t, void **); @@ -2588,48 +2571,7 @@ gentype_getreadbuf(PyObject *self, Py_ssize_t segment, void **ptrptr) return numbytes; } -#if !defined(NPY_PY3K) -static Py_ssize_t -gentype_getsegcount(PyObject *self, Py_ssize_t *lenp) -{ - PyArray_Descr *outcode; - - outcode = PyArray_DescrFromScalar(self); - if (lenp) { - *lenp = outcode->elsize; -#ifndef Py_UNICODE_WIDE - if (outcode->type_num == NPY_UNICODE) { - *lenp >>= 1; - } -#endif - } - Py_DECREF(outcode); - return 1; -} - -static Py_ssize_t -gentype_getcharbuf(PyObject *self, Py_ssize_t segment, constchar **ptrptr) -{ - if (PyArray_IsScalar(self, String) || - PyArray_IsScalar(self, Unicode)) { - return gentype_getreadbuf(self, segment, (void **)ptrptr); - } - else { - PyErr_SetString(PyExc_TypeError, - "Non-character array cannot be interpreted "\ - "as character buffer."); - return -1; - } -} -#endif /* !defined(NPY_PY3K) */ - static PyBufferProcs gentype_as_buffer = { -#if !defined(NPY_PY3K) - gentype_getreadbuf, /* bf_getreadbuffer*/ - NULL, /* bf_getwritebuffer*/ - gentype_getsegcount, /* bf_getsegcount*/ - gentype_getcharbuf, /* bf_getcharbuffer*/ -#endif gentype_getbuffer, /* bf_getbuffer */ NULL, /* bf_releasebuffer */ }; @@ -2877,11 +2819,7 @@ finish: *((npy_@name@ *)dest) = *((npy_@name@ *)src); #elif @default@ == 1 /* unicode and strings */ if (itemsize == 0) { /* unicode */ -#if PY_VERSION_HEX >= 0x03030000 itemsize = PyUnicode_GetLength(robj) * PyUnicode_KIND(robj); -#else - itemsize = ((PyUnicodeObject *)robj)->length * sizeof(Py_UNICODE); -#endif } memcpy(dest, src, itemsize); /* @default@ == 2 won't get here */ @@ -3070,10 +3008,6 @@ NPY_NO_EXPORT PyNumberMethods bool_arrtype_as_number = { 0, /* nb_add */ 0, /* nb_subtract */ 0, /* nb_multiply */ -#if defined(NPY_PY3K) -#else - 0, /* nb_divide */ -#endif 0, /* nb_remainder */ 0, /* nb_divmod */ 0, /* nb_power */ @@ -3107,10 +3041,6 @@ NPY_NO_EXPORT PyNumberMethods bool_arrtype_as_number = { 0, /* nb_inplace_add */ 0, /* nb_inplace_subtract */ 0, /* nb_inplace_multiply */ -#if defined(NPY_PY3K) -#else - 0, /* nb_inplace_divide */ -#endif 0, /* nb_inplace_remainder */ 0, /* nb_inplace_power */ 0, /* nb_inplace_lshift */ diff --git a/numpy/core/src/multiarray/strfuncs.c b/numpy/core/src/multiarray/strfuncs.c index 33f3a6543..b570aec08 100644 --- a/numpy/core/src/multiarray/strfuncs.c +++ b/numpy/core/src/multiarray/strfuncs.c @@ -226,34 +226,3 @@ array_format(PyArrayObject *self, PyObject *args) } } -#ifndef NPY_PY3K - -NPY_NO_EXPORT PyObject * -array_unicode(PyArrayObject *self) -{ - PyObject *uni; - - if (PyArray_NDIM(self) == 0) { - PyObject *item = PyArray_ToScalar(PyArray_DATA(self), self); - if (item == NULL){ - return NULL; - } - - /* defer to invoking `unicode` on the scalar */ - uni = PyObject_CallFunctionObjArgs( - (PyObject *)&PyUnicode_Type, item, NULL); - Py_DECREF(item); - } - else { - /* Do what unicode(self) would normally do */ - PyObject *str = PyObject_Str((PyObject *)self); - if (str == NULL){ - return NULL; - } - uni = PyUnicode_FromObject(str); - Py_DECREF(str); - } - return uni; -} - -#endif diff --git a/numpy/core/src/multiarray/strfuncs.h b/numpy/core/src/multiarray/strfuncs.h index 7e869d926..5dd661a20 100644 --- a/numpy/core/src/multiarray/strfuncs.h +++ b/numpy/core/src/multiarray/strfuncs.h @@ -13,9 +13,4 @@ array_str(PyArrayObject *self); NPY_NO_EXPORT PyObject * array_format(PyArrayObject *self, PyObject *args); -#ifndef NPY_PY3K - NPY_NO_EXPORT PyObject * - array_unicode(PyArrayObject *self); -#endif - #endif diff --git a/numpy/core/src/multiarray/typeinfo.c b/numpy/core/src/multiarray/typeinfo.c index 14c4f27cb..1fbdc6c41 100644 --- a/numpy/core/src/multiarray/typeinfo.c +++ b/numpy/core/src/multiarray/typeinfo.c @@ -104,10 +104,8 @@ PyArray_typeinforanged( return entry; } -/* Python version only needed for backport to 2.7 */ -#if (PY_VERSION_HEX < 0x03040000) \ - || (defined(PYPY_VERSION_NUM) && (PYPY_VERSION_NUM < 0x07020000)) - +/* Python version needed for older PyPy */ +#if (defined(PYPY_VERSION_NUM) && (PYPY_VERSION_NUM < 0x07020000)) static int PyStructSequence_InitType2(PyTypeObject *type, PyStructSequence_Desc *desc) { PyStructSequence_InitType(type, desc); diff --git a/numpy/core/src/umath/funcs.inc.src b/numpy/core/src/umath/funcs.inc.src index 9c59cc8fb..4c0a86c1d 100644 --- a/numpy/core/src/umath/funcs.inc.src +++ b/numpy/core/src/umath/funcs.inc.src @@ -197,8 +197,7 @@ npy_ObjectGCD(PyObject *i1, PyObject *i2) { PyObject *gcd = NULL; - /* use math.gcd if available, and valid on the provided types */ -#if PY_VERSION_HEX >= 0x03050000 + /* use math.gcd if valid on the provided types */ { static PyObject *math_gcd_func = NULL; @@ -213,7 +212,6 @@ npy_ObjectGCD(PyObject *i1, PyObject *i2) /* silence errors, and fall back on pure-python gcd */ PyErr_Clear(); } -#endif /* otherwise, use our internal one, written in python */ { diff --git a/numpy/core/src/umath/scalarmath.c.src b/numpy/core/src/umath/scalarmath.c.src index d5d8d659b..7f115974d 100644 --- a/numpy/core/src/umath/scalarmath.c.src +++ b/numpy/core/src/umath/scalarmath.c.src @@ -744,56 +744,50 @@ _@name@_convert2_to_ctypes(PyObject *a, @type@ *arg1, /**end repeat**/ -#if defined(NPY_PY3K) -#define CODEGEN_SKIP_divide_FLAG -#endif - /**begin repeat * * #name = (byte, ubyte, short, ushort, int, uint, - * long, ulong, longlong, ulonglong)*13, + * long, ulong, longlong, ulonglong)*12, * (half, float, double, longdouble, - * cfloat, cdouble, clongdouble)*6, + * cfloat, cdouble, clongdouble)*5, * (half, float, double, longdouble)*2# * #Name = (Byte, UByte, Short, UShort, Int, UInt, - * Long, ULong,LongLong,ULongLong)*13, + * Long, ULong,LongLong,ULongLong)*12, * (Half, Float, Double, LongDouble, - * CFloat, CDouble, CLongDouble)*6, + * CFloat, CDouble, CLongDouble)*5, * (Half, Float, Double, LongDouble)*2# * #type = (npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint, - * npy_long, npy_ulong, npy_longlong, npy_ulonglong)*13, + * npy_long, npy_ulong, npy_longlong, npy_ulonglong)*12, * (npy_half, npy_float, npy_double, npy_longdouble, - * npy_cfloat, npy_cdouble, npy_clongdouble)*6, + * npy_cfloat, npy_cdouble, npy_clongdouble)*5, * (npy_half, npy_float, npy_double, npy_longdouble)*2# * - * #oper = add*10, subtract*10, multiply*10, divide*10, remainder*10, + * #oper = add*10, subtract*10, multiply*10, remainder*10, * divmod*10, floor_divide*10, lshift*10, rshift*10, and*10, * or*10, xor*10, true_divide*10, - * add*7, subtract*7, multiply*7, divide*7, floor_divide*7, true_divide*7, + * add*7, subtract*7, multiply*7, floor_divide*7, true_divide*7, * divmod*4, remainder*4# * - * #fperr = 1*70,0*50,1*10, - * 1*42, + * #fperr = 1*60,0*50,1*10, + * 1*35, * 1*8# - * #twoout = 0*50,1*10,0*70, - * 0*42, + * #twoout = 0*40,1*10,0*70, + * 0*35, * 1*4,0*4# * #otype = (npy_byte, npy_ubyte, npy_short, npy_ushort, npy_int, npy_uint, - * npy_long, npy_ulong, npy_longlong, npy_ulonglong)*12, + * npy_long, npy_ulong, npy_longlong, npy_ulonglong)*11, * npy_float*4, npy_double*6, * (npy_half, npy_float, npy_double, npy_longdouble, - * npy_cfloat, npy_cdouble, npy_clongdouble)*6, + * npy_cfloat, npy_cdouble, npy_clongdouble)*5, * (npy_half, npy_float, npy_double, npy_longdouble)*2# * #OName = (Byte, UByte, Short, UShort, Int, UInt, - * Long, ULong, LongLong, ULongLong)*12, + * Long, ULong, LongLong, ULongLong)*11, * Float*4, Double*6, * (Half, Float, Double, LongDouble, - * CFloat, CDouble, CLongDouble)*6, + * CFloat, CDouble, CLongDouble)*5, * (Half, Float, Double, LongDouble)*2# */ -#if !defined(CODEGEN_SKIP_@oper@_FLAG) - static PyObject * @name@_@oper@(PyObject *a, PyObject *b) { @@ -904,12 +898,9 @@ static PyObject * #endif return ret; } -#endif /**end repeat**/ -#undef CODEGEN_SKIP_divide_FLAG - #define _IS_ZERO(x) (x == 0) /**begin repeat @@ -1597,9 +1588,6 @@ static PyNumberMethods @name@_as_number = { (binaryfunc)@name@_add, /*nb_add*/ (binaryfunc)@name@_subtract, /*nb_subtract*/ (binaryfunc)@name@_multiply, /*nb_multiply*/ -#if !defined(NPY_PY3K) - (binaryfunc)@name@_divide, /*nb_divide*/ -#endif (binaryfunc)@name@_remainder, /*nb_remainder*/ (binaryfunc)@name@_divmod, /*nb_divmod*/ (ternaryfunc)@name@_power, /*nb_power*/ @@ -1634,9 +1622,6 @@ static PyNumberMethods @name@_as_number = { 0, /*inplace_add*/ 0, /*inplace_subtract*/ 0, /*inplace_multiply*/ -#if !defined(NPY_PY3K) - 0, /*inplace_divide*/ -#endif 0, /*inplace_remainder*/ 0, /*inplace_power*/ 0, /*inplace_lshift*/ diff --git a/numpy/core/tests/test_indexing.py b/numpy/core/tests/test_indexing.py index 56bcf0177..237e381a7 100644 --- a/numpy/core/tests/test_indexing.py +++ b/numpy/core/tests/test_indexing.py @@ -648,40 +648,6 @@ class TestSubclasses: assert_array_equal(new_s.finalize_status, new_s) assert_array_equal(new_s.old, s) - @pytest.mark.skipif(not HAS_REFCOUNT, reason="Python lacks refcounts") - def test_slice_decref_getsetslice(self): - # See gh-10066, a temporary slice object should be discarted. - # This test is only really interesting on Python 2 since - # it goes through `__set/getslice__` here and can probably be - # removed. Use 0:7 to make sure it is never None:7. - class KeepIndexObject(np.ndarray): - def __getitem__(self, indx): - self.indx = indx - if indx == slice(0, 7): - raise ValueError - - def __setitem__(self, indx, val): - self.indx = indx - if indx == slice(0, 4): - raise ValueError - - k = np.array([1]).view(KeepIndexObject) - k[0:5] - assert_equal(k.indx, slice(0, 5)) - assert_equal(sys.getrefcount(k.indx), 2) - with assert_raises(ValueError): - k[0:7] - assert_equal(k.indx, slice(0, 7)) - assert_equal(sys.getrefcount(k.indx), 2) - - k[0:3] = 6 - assert_equal(k.indx, slice(0, 3)) - assert_equal(sys.getrefcount(k.indx), 2) - with assert_raises(ValueError): - k[0:4] = 2 - assert_equal(k.indx, slice(0, 4)) - assert_equal(sys.getrefcount(k.indx), 2) - class TestFancyIndexingCast: def test_boolean_index_cast_assign(self): diff --git a/numpy/f2py/src/fortranobject.c b/numpy/f2py/src/fortranobject.c index 456e64893..81fc50f2e 100644 --- a/numpy/f2py/src/fortranobject.c +++ b/numpy/f2py/src/fortranobject.c @@ -1017,8 +1017,6 @@ int copy_ND_array(const PyArrayObject *arr, PyArrayObject *out) /* Compatibility functions for Python >= 3.0 */ /*********************************************/ -#if PY_VERSION_HEX >= 0x03000000 - PyObject * F2PyCapsule_FromVoidPtr(void *ptr, void (*dtor)(PyObject *)) { @@ -1045,29 +1043,6 @@ F2PyCapsule_Check(PyObject *ptr) return PyCapsule_CheckExact(ptr); } -#else - -PyObject * -F2PyCapsule_FromVoidPtr(void *ptr, void (*dtor)(void *)) -{ - return PyCObject_FromVoidPtr(ptr, dtor); -} - -void * -F2PyCapsule_AsVoidPtr(PyObject *ptr) -{ - return PyCObject_AsVoidPtr(ptr); -} - -int -F2PyCapsule_Check(PyObject *ptr) -{ - return PyCObject_Check(ptr); -} - -#endif - - #ifdef __cplusplus } #endif diff --git a/numpy/testing/_private/nosetester.py b/numpy/testing/_private/nosetester.py index 73f5b3d35..4ca5267ce 100644 --- a/numpy/testing/_private/nosetester.py +++ b/numpy/testing/_private/nosetester.py @@ -454,8 +454,6 @@ class NoseTester: # This is very specific, so using the fragile module filter # is fine import threading - sup.filter(DeprecationWarning, message=r"in 3\.x, __setslice__") - sup.filter(DeprecationWarning, message=r"in 3\.x, __getslice__") sup.filter(DeprecationWarning, message=r"buffer\(\) not supported in 3\.x") sup.filter(DeprecationWarning, message=r"CObject type is not supported in 3\.x") sup.filter(DeprecationWarning, message=r"comparing unequal types not supported in 3\.x") |