summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2020-01-04 17:52:01 +0200
committerGitHub <noreply@github.com>2020-01-04 17:52:01 +0200
commit1d9595fc5fadaf81b8d7e2f19f62d29c476d9c45 (patch)
tree36565b2978b9925e8d7eb3863aa8083c0792c82f /numpy
parentb7c27bd2a3817f59c84b004b87bba5db57d9a9b0 (diff)
parent963692da48ac8baf692357b453e2945122fd4eb5 (diff)
downloadnumpy-1d9595fc5fadaf81b8d7e2f19f62d29c476d9c45.tar.gz
Merge pull request #15229 from jdufresne/int_asbuffer
MAINT: Remove unused int_asbuffer
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/multiarray.py2
-rw-r--r--numpy/core/numeric.py4
-rw-r--r--numpy/core/src/multiarray/multiarraymodule.c95
-rw-r--r--numpy/tests/test_public_api.py1
4 files changed, 3 insertions, 99 deletions
diff --git a/numpy/core/multiarray.py b/numpy/core/multiarray.py
index c0fcc10ff..01fca1df5 100644
--- a/numpy/core/multiarray.py
+++ b/numpy/core/multiarray.py
@@ -33,7 +33,7 @@ __all__ = [
'digitize', 'dot', 'dragon4_positional', 'dragon4_scientific', 'dtype',
'empty', 'empty_like', 'error', 'flagsobj', 'flatiter', 'format_longfloat',
'frombuffer', 'fromfile', 'fromiter', 'fromstring', 'inner',
- 'int_asbuffer', 'interp', 'interp_complex', 'is_busday', 'lexsort',
+ 'interp', 'interp_complex', 'is_busday', 'lexsort',
'matmul', 'may_share_memory', 'min_scalar_type', 'ndarray', 'nditer',
'nested_iters', 'normalize_axis_index', 'packbits',
'promote_types', 'putmask', 'ravel_multi_index', 'result_type', 'scalar',
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index af289ca3d..ae3dcd07a 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -15,7 +15,7 @@ from .multiarray import (
WRAP, arange, array, broadcast, can_cast, compare_chararrays,
concatenate, copyto, dot, dtype, empty,
empty_like, flatiter, frombuffer, fromfile, fromiter, fromstring,
- inner, int_asbuffer, lexsort, matmul, may_share_memory,
+ inner, lexsort, matmul, may_share_memory,
min_scalar_type, ndarray, nditer, nested_iters, promote_types,
putmask, result_type, set_numeric_ops, shares_memory, vdot, where,
zeros, normalize_axis_index)
@@ -50,7 +50,7 @@ array_function_dispatch = functools.partial(
__all__ = [
'newaxis', 'ndarray', 'flatiter', 'nditer', 'nested_iters', 'ufunc',
'arange', 'array', 'zeros', 'count_nonzero', 'empty', 'broadcast', 'dtype',
- 'fromstring', 'fromfile', 'frombuffer', 'int_asbuffer', 'where',
+ 'fromstring', 'fromfile', 'frombuffer', 'where',
'argwhere', 'copyto', 'concatenate', 'fastCopyAndTranspose', 'lexsort',
'set_numeric_ops', 'can_cast', 'promote_types', 'min_scalar_type',
'result_type', 'isfortran', 'empty_like', 'zeros_like', 'ones_like',
diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c
index eb593bdb5..58f64f0bb 100644
--- a/numpy/core/src/multiarray/multiarraymodule.c
+++ b/numpy/core/src/multiarray/multiarraymodule.c
@@ -3329,98 +3329,6 @@ buffer_buffer(PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds)
}
#endif
-#ifndef _MSC_VER
-#include <setjmp.h>
-#include <signal.h>
-jmp_buf _NPY_SIGSEGV_BUF;
-static void
-_SigSegv_Handler(int signum)
-{
- longjmp(_NPY_SIGSEGV_BUF, signum);
-}
-#endif
-
-#define _test_code() { \
- test = *((char*)memptr); \
- if (!ro) { \
- *((char *)memptr) = '\0'; \
- *((char *)memptr) = test; \
- } \
- test = *((char*)memptr+size-1); \
- if (!ro) { \
- *((char *)memptr+size-1) = '\0'; \
- *((char *)memptr+size-1) = test; \
- } \
- }
-
-static PyObject *
-as_buffer(PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds)
-{
- PyObject *mem;
- Py_ssize_t size;
- npy_bool ro = NPY_FALSE, check = NPY_TRUE;
- void *memptr;
- static char *kwlist[] = {"mem", "size", "readonly", "check", NULL};
-
- if (!PyArg_ParseTupleAndKeywords(args, kwds,
- "O" NPY_SSIZE_T_PYFMT "|O&O&:int_asbuffer", kwlist,
- &mem, &size, PyArray_BoolConverter, &ro,
- PyArray_BoolConverter, &check)) {
- return NULL;
- }
- memptr = PyLong_AsVoidPtr(mem);
- if (memptr == NULL) {
- return NULL;
- }
- if (check) {
- /*
- * Try to dereference the start and end of the memory region
- * Catch segfault and report error if it occurs
- */
- char test;
- int err = 0;
-
-#ifdef _MSC_VER
- __try {
- _test_code();
- }
- __except(1) {
- err = 1;
- }
-#else
- PyOS_sighandler_t _npy_sig_save;
- _npy_sig_save = PyOS_setsig(SIGSEGV, _SigSegv_Handler);
- if (setjmp(_NPY_SIGSEGV_BUF) == 0) {
- _test_code();
- }
- else {
- err = 1;
- }
- PyOS_setsig(SIGSEGV, _npy_sig_save);
-#endif
- if (err) {
- PyErr_SetString(PyExc_ValueError,
- "cannot use memory location as a buffer.");
- return NULL;
- }
- }
-
-
-#if defined(NPY_PY3K)
- PyErr_SetString(PyExc_RuntimeError,
- "XXX -- not implemented!");
- return NULL;
-#else
- if (ro) {
- return PyBuffer_FromMemory(memptr, size);
- }
- return PyBuffer_FromReadWriteMemory(memptr, size);
-#endif
-}
-
-#undef _test_code
-
-
/*
* Prints floating-point scalars using the Dragon4 algorithm, scientific mode.
* See docstring of `np.format_float_scientific` for description of arguments.
@@ -4237,9 +4145,6 @@ static struct PyMethodDef array_module_methods[] = {
(PyCFunction)buffer_buffer,
METH_VARARGS | METH_KEYWORDS, NULL},
#endif
- {"int_asbuffer",
- (PyCFunction)as_buffer,
- METH_VARARGS | METH_KEYWORDS, NULL},
{"format_longfloat",
(PyCFunction)format_longfloat,
METH_VARARGS | METH_KEYWORDS, NULL},
diff --git a/numpy/tests/test_public_api.py b/numpy/tests/test_public_api.py
index 9f5ae8a92..4ee84034d 100644
--- a/numpy/tests/test_public_api.py
+++ b/numpy/tests/test_public_api.py
@@ -48,7 +48,6 @@ def test_numpy_namespace():
'fastCopyAndTranspose': 'numpy.core._multiarray_umath._fastCopyAndTranspose',
'get_array_wrap': 'numpy.lib.shape_base.get_array_wrap',
'get_include': 'numpy.lib.utils.get_include',
- 'int_asbuffer': 'numpy.core._multiarray_umath.int_asbuffer',
'mafromtxt': 'numpy.lib.npyio.mafromtxt',
'ndfromtxt': 'numpy.lib.npyio.ndfromtxt',
'recfromcsv': 'numpy.lib.npyio.recfromcsv',