[NumPy-Tickets] [NumPy] #1910: Check buffer bounds in ndarray creation
NumPy Trac
numpy-tickets@scipy....
Mon Jul 18 05:51:01 CDT 2011
#1910: Check buffer bounds in ndarray creation
------------------------+---------------------------------------------------
Reporter: pv | Owner: somebody
Type: defect | Status: new
Priority: low | Milestone: Unscheduled
Component: numpy.core | Version: 1.6.0
Keywords: |
------------------------+---------------------------------------------------
Forwarded from Stefan Krah:
----------------------------------------
With a recent NumPy clone + Python3.3, I get this invalid access:
{{{
Python 3.3.0a0 (default:1dd6908df8f5, Jul 16 2011, 11:16:00)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from numpy import *
>>> x = ndarray(buffer=bytearray([1,2,3,4,5,6,7,8,9,10]), shape=[2,3],
strides=[-3, -2], dtype="B", offset=5)
>>> x
array([[ 6, 4, 2],
[ 3, 1, 251]], dtype='uint8')
>>> x[1][2]
251
>>>
}}}
I think NumPy should probably refuse to create such an array, like here:
{{{
>>> x = ndarray(buffer=bytearray([1,2,3,4,5,6,7,8,9,10]), shape=[2,3],
strides=[-3, -2], dtype="B", offset=0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: strides is incompatible with shape of requested array and size
of buffer
}}}
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1910>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list