10000 Merge pull request #15229 from jdufresne/int_asbuffer · numpy/numpy@1d9595f · GitHub
[go: up one dir, main page]

Skip to content

Commit 1d9595f

Browse files
authored
Merge pull request #15229 from jdufresne/int_asbuffer
MAINT: Remove unused int_asbuffer
2 parents b7c27bd + 963692d commit 1d9595f

File tree

6 files changed

+10
-111
lines changed

6 files changed

+10
-111
lines changed

doc/Py3K.rst.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -396,14 +396,6 @@ There are a couple of places that need further attention:
396396
In some cases, this returns a buffer object on Python 2. On Python 3,
397397
there is no stand-alone buffer object, so we return a byte array instead.
398398

399-
- multiarray.int_asbuffer
400-
401-
Converts an integer to a void* pointer -- in Python.
402-
403-
Should we just remove this for Py3? It doesn't seem like it is used
404-
anywhere, and it doesn't sound very useful.
405-
406-
407399
The Py2/Py3 compatible PyBufferMethods definition looks like::
408400

409401
NPY_NO_EXPORT PyBufferProcs array_as_buffer = {
@@ -430,10 +422,6 @@ The Py2/Py3 compatible PyBufferMethods definition looks like::
430422

431423
Produce PEP 3118 format strings for array scalar objects.
432424

433-
.. todo::
434-
435-
Figure out what to do with int_asbuffer
436-
437425
.. todo::
438426

439427
There's stuff to clean up in numarray/_capi.c
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Removed ``multiarray.int_asbuffer``
2+
-----------------------------------
3+
4+
As part of the continued removal of Python 2 compatibility,
5+
``multiarray.int_asbuffer`` was removed. On Python 3, it threw a
6+
``NotImplementedError`` and was unused internally. It is expected that there
7+
are no downstream use cases for this method with Python 3.

numpy/core/multiarray.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
'digitize', 'dot', 'dragon4_positional', 'dragon4_scientific', 'dtype',
3434
'empty', 'empty_like', 'error', 'flagsobj', 'flatiter', 'format_longfloat',
3535
'frombuffer', 'fromfile', 'fromiter', 'fromstring', 'inner',
36-
'int_asbuffer', 'interp', 'interp_complex', 'is_busday', 'lexsort',
36+
'interp', 'interp_complex', 'is_busday', 'lexsort',
3737
'matmul', 'may_share_memory', 'min_scalar_type', 'ndarray', 'nditer',
3838
'nested_iters', 'normalize_axis_index', 'packbits',
3939
'promote_types', 'putmask', 'ravel_multi_index', 'result_type', 'scalar',

numpy/core/numeric.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
WRAP, arange, array, broadcast, can_cast, compare_chararrays,
1616
concatenate, copyto, dot, dtype, empty,
1717
empty_like, flatiter, frombuffer, fromfile, fromiter, fromstring,
18-
inner, int_asbuffer, lexsort, matmul, may_share_memory,
18+
inner, lexsort, matmul, may_share_memory,
1919
min_scalar_type, ndarray, nditer, nested_iters, promote_types,
2020
putmask, result_type, set_numeric_ops, shares_memory, vdot, where,
2121
zeros, normalize_axis_index)
@@ -50,7 +50,7 @@
5050
__all__ = [
5151
'newaxis', 'ndarray', 'flatiter', 'nditer', 'nested_iters', 'ufunc',
5252
'arange', 'array', 'zeros', 'count_nonzero', 'empty', 'broadcast', 'dtype',
53-
'fromstring', 'fromfile', 'frombuffer', 'int_asbuffer', 'where',
53+
'fromstring', 'fromfile', 'frombuffer', 'where',
5454
'argwhere', 'copyto', 'concatenate', 'fastCopyAndTranspose', 'lexsort',
5555
'set_numeric_ops', 'can_cast', 'promote_types', 'min_scalar_type',
5656
'result_type', 'isfortran', 'empty_like', 'zeros_like', 'ones_like',

numpy/core/src/multiarray/multiarraymodule.c

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -3329,98 +3329,6 @@ buffer_buffer(PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds)
33293329
}
33303330
#endif
33313331

3332-
#ifndef _MSC_VER
3333-
#include <setjmp.h>
3334-
#include <signal.h>
3335-
jmp_buf _NPY_SIGSEGV_BUF;
3336-
static void
3337-
_SigSegv_Handler(int signum)
3338-
{
3339-
longjmp(_NPY_SIGSEGV_BUF, signum);
3340-
}
3341-
#endif
3342-
3343-
#define _test_code() { \
3344-
test = *((char*)memptr); \
3345-
if (!ro) { \
3346-
*((char *)memptr) = '\0'; \
3347-
*((char *)memptr) = test; \
3348-
} \
3349-
test = *((char*)memptr+size-1); \
3350-
if (!ro) { \
3351-
*((char *)memptr+size-1) = '\0'; \
3352-
*((char *)memptr+size-1) = test; \
3353-
} \
3354-
}
3355-
3356-
static PyObject *
3357-
as_buffer(PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds)
3358-
{
3359-
PyObject *mem;
3360-
Py_ssize_t size;
3361-
npy_bool ro = NPY_FALSE, check = NPY_TRUE;
3362-
void *memptr;
3363-
static char *kwlist[] = {"mem", "size", "readonly", "check", NULL};
3364-
3365-
if (!PyArg_ParseTupleAndKeywords(args, kwds,
3366-
"O" NPY_SSIZE_T_PYFMT "|O&O&:int_asbuffer", kwlist,
3367-
&mem, &size, PyArray_BoolConverter, &ro,
3368-
PyArray_BoolConverter, &check)) {
3369-
return NULL;
3370-
}
3371-
memptr = PyLong_AsVoidPtr(mem);
3372-
if (memptr == NULL) {
3373-
return NULL;
3374-
}
3375-
if (check) {
3376-
/*
3377-
* Try to dereference the start and end of the memory region
3378-
* Catch segfault and report error if it occurs
3379-
*/
3380-
char test;
3381-
int err = 0;
3382-
3383-
#ifdef _MSC_VER
3384-
__try {
3385-
_test_code();
3386-
}
3387-
__except(1) {
3388-
err = 1;
3389-
}
3390-
#else
3391-
PyOS_sighandler_t _npy_sig_save;
3392-
_npy_sig_save = PyOS_setsig(SIGSEGV, _SigSegv_Handler);
3393-
if (setjmp(_NPY_SIGSEGV_BUF) == 0) {
3394-
_test_code();
3395-
}
3396-
else {
3397-
err = 1;
3398-
}
3399-
PyOS_setsig(SIGSEGV, _npy_sig_save);
3400-
#endif
3401-
if (err) {
3402-
PyErr_SetString(PyExc_ValueError,
3403-
"cannot use memory location as a buffer.");
3404-
return NULL;
3405-
}
3406-
}
3407-
3408-
3409-
#if defined(NPY_PY3K)
3410-
PyErr_SetString(PyExc_RuntimeError,
3411-
"XXX -- not implemented!");
3412-
return NULL;
3413-
#else
3414-
if (ro) {
3415-
return PyBuffer_FromMemory(memptr, size);
3416-
}
3417-
return PyBuffer_FromReadWriteMemory(memptr, size);
3418-
#endif
3419-
}
3420-
3421-
#undef _test_code
3422-
3423-
34243332
/*
34253333
* Prints floating-point scalars using the Dragon4 algorithm, scientific mode.
34263334
* See docstring of `np.format_float_scientific` for description of arguments.
@@ -4237,9 +4145,6 @@ static struct PyMethodDef array_module_methods[] = {
42374145
(PyCFunction)buffer_buffer,
42384146
METH_VARARGS | METH_KEYWORDS, NULL},
42394147
#endif
4240-
{"int_asbuffer",
4241-
(PyCFunction)as_buffer,
4242-
METH_VARARGS | METH_KEYWORDS, NULL},
42434148
{"format_longfloat",
42444149
(PyCFunction)format_longfloat,
42454150
METH_VARARGS | METH_KEYWORDS, NULL},

numpy/tests/test_public_api.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ def test_numpy_namespace():
4848
'fastCopyAndTranspose': 'numpy.core._multiarray_umath._fastCopyAndTranspose',
4949
'get_array_wrap': 'numpy.lib.shape_base.get_array_wrap',
5050
'get_include': 'numpy.lib.utils.get_include',
51-
'int_asbuffer': 'numpy.core._multiarray_umath.int_asbuffer',
5251
'mafromtxt': 'numpy.lib.npyio.mafromtxt',
5352
'ndfromtxt': 'numpy.lib.npyio.ndfromtxt',
5453
'recfromcsv': 'numpy.lib.npyio.recfromcsv',

0 commit comments

Comments
 (0)
0