diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-01-20 23:25:44 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-01-20 23:25:44 +0000 |
commit | 6b724c9e4798b919858c3a980c3e865eb4a055c1 (patch) | |
tree | 7573aa5a81f78e5c1b1045ba603307a06e63e9e2 | |
parent | a0a42fce29c83184f730b08cf48828edd35bb99b (diff) | |
download | numpy-6b724c9e4798b919858c3a980c3e865eb4a055c1.tar.gz |
A few safety checks for platforms where SIZEOF_LONG < SIZEOF_INTP -- windows 64-bit I think
-rw-r--r-- | numpy/core/src/arrayobject.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index af302feff..40cfbafbb 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -3338,15 +3338,27 @@ PyArray_IntpFromSequence(PyObject *seq, intp *vals, int maxvals) or, can be made into one */ if ((nd=PySequence_Length(seq)) == -1) { if (PyErr_Occurred()) PyErr_Clear(); +#if SIZEOF_LONG >= SIZEOF_INTP if (!(op = PyNumber_Int(seq))) return -1; +#else + if (!(op = PyNumber_Long(seq))) return -1; +#endif nd = 1; +#if SIZEOF_LONG >= SIZEOF_INTP vals[0] = (intp ) PyInt_AsLong(op); +#else + vals[0] = (intp ) PyLong_AsLongLong(op); +#endif Py_DECREF(op); } else { for(i=0; i < MIN(nd,maxvals); i++) { op = PySequence_GetItem(seq, i); if (op == NULL) return -1; +#if SIZEOF_LONG >= SIZEOF_INTP vals[i]=(intp )PyInt_AsLong(op); +#else + vals[i]=(intp )PyLong_AsLongLong(op); +#endif Py_DECREF(op); if(PyErr_Occurred()) return -1; } |