summaryrefslogtreecommitdiff
path: root/numpy/core/src/arrayobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core/src/arrayobject.c')
-rw-r--r--numpy/core/src/arrayobject.c45
1 files changed, 31 insertions, 14 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c
index 836fa2e8b..854a848a2 100644
--- a/numpy/core/src/arrayobject.c
+++ b/numpy/core/src/arrayobject.c
@@ -4702,7 +4702,7 @@ _IsWriteable(PyArrayObject *ap)
{
PyObject *base=ap->base;
void *dummy;
- int n;
+ Py_ssize_t n;
/* If we own our own data, then no-problem */
if ((base == NULL) || (ap->flags & OWNDATA)) return TRUE;
@@ -5565,8 +5565,8 @@ array_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
dims.ptr[0] = (buffer.len-(intp)offset) / itemsize;
}
else if ((strides.ptr == NULL) && \
- buffer.len < itemsize* \
- PyArray_MultiplyList(dims.ptr, dims.len)) {
+ (buffer.len < ((intp)itemsize)* \
+ PyArray_MultiplyList(dims.ptr, dims.len))) {
PyErr_SetString(PyExc_TypeError,
"buffer is too small for " \
"requested array");
@@ -5684,7 +5684,7 @@ array_strides_set(PyArrayObject *self, PyObject *obj)
PyArrayObject *new;
intp numbytes=0;
intp offset=0;
- int buf_len;
+ Py_ssize_t buf_len;
char *buf;
if (!PyArray_IntpConverter(obj, &newstrides) || \
@@ -5874,7 +5874,7 @@ static int
array_data_set(PyArrayObject *self, PyObject *op)
{
void *buf;
- int buf_len;
+ Py_ssize_t buf_len;
int writeable=1;
if (PyObject_AsWriteBuffer(op, &buf, &buf_len) < 0) {
@@ -7832,7 +7832,7 @@ PyArray_FromInterface(PyObject *input)
PyArrayObject *ret;
PyArray_Descr *type=NULL;
char *data;
- int buffer_len;
+ Py_ssize_t buffer_len;
int res, i, n;
intp dims[MAX_DIMS], strides[MAX_DIMS];
int dataflags = BEHAVED;
@@ -7867,7 +7867,7 @@ PyArray_FromInterface(PyObject *input)
}
attr = PyDict_GetItemString(inter, "offset");
if (attr) {
- long num = PyInt_AsLong(attr);
+ longlong num = PyLong_AsLongLong(attr);
if (error_converting(num)) {
PyErr_SetString(PyExc_TypeError,
"offset "\
@@ -10445,13 +10445,30 @@ arraydescr_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
conv = _convert_from_dict(odescr, 1);
else if PyList_Check(odescr) {
conv = _convert_from_list(odescr, 1, 0);
- if ((conv == NULL) &&
- (!PyErr_Occurred())) {
- PyErr_SetString(PyExc_ValueError,
- "cannot specify align=1 "\
- "with array_descriptor "\
- "specification of the data-"\
- "type.");
+ if (conv == NULL) {
+ /* There is an errror. Possibly it's
+ because we have an array_descriptor.
+ Try converting from an array_descriptor.
+ If that fails then raise the old error.
+ */
+ PyObject *type, *value, *traceback;
+ PyArray_Descr *temp;
+ PyErr_Fetch(&type, &value, &traceback);
+ temp = _convert_from_array_descr(odescr);
+ if (!PyErr_Occurred()) {
+ Py_DECREF(temp);
+ Py_XDECREF(type);
+ Py_XDECREF(value);
+ Py_XDECREF(traceback);
+ PyErr_SetString(PyExc_ValueError,
+ "align cannot be True" \
+ " with array_descriptor " \
+ "specification.");
+ }
+ else {
+ PyErr_Restore(type, value, traceback);
+ }
+ return NULL;
}
}
else if PyString_Check(odescr)