diff options
author | Matti Picus <matti.picus@gmail.com> | 2019-10-29 23:13:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-29 23:13:11 +0200 |
commit | 6ed9365aadf992087b26ec30214dfec151ac22a1 (patch) | |
tree | 7c335a248cd2035935e47aca6f7a34fe258e4f5b | |
parent | 5839fae4844fe10304aa137b570f7fa75d03e86f (diff) | |
parent | af36784b2b38577a87208003d6827d02dc0c0fc2 (diff) | |
download | numpy-6ed9365aadf992087b26ec30214dfec151ac22a1.tar.gz |
Merge pull request #14769 from mwhudson/issue-14767
BUG: fix integer size confusion in handling array's ndmin argument
-rw-r--r-- | numpy/core/src/multiarray/multiarraymodule.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c index 441567049..9693275e7 100644 --- a/numpy/core/src/multiarray/multiarraymodule.c +++ b/numpy/core/src/multiarray/multiarraymodule.c @@ -1562,8 +1562,7 @@ _array_fromobject(PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kws) PyArrayObject *oparr = NULL, *ret = NULL; npy_bool subok = NPY_FALSE; npy_bool copy = NPY_TRUE; - int nd; - npy_intp ndmin = 0; + int ndmin = 0, nd; PyArray_Descr *type = NULL; PyArray_Descr *oldtype = NULL; NPY_ORDER order = NPY_KEEPORDER; @@ -1625,13 +1624,14 @@ _array_fromobject(PyObject *NPY_UNUSED(ignored), PyObject *args, PyObject *kws) ndmin_obj = PyDict_GetItem(kws, npy_ma_str_ndmin); if (ndmin_obj) { - ndmin = PyLong_AsLong(ndmin_obj); - if (error_converting(ndmin)) { + long t = PyLong_AsLong(ndmin_obj); + if (error_converting(t)) { goto clean_type; } - else if (ndmin > NPY_MAXDIMS) { + else if (t > NPY_MAXDIMS) { goto full_path; } + ndmin = t; } /* copy=False with default dtype, order (any is OK) and ndim */ |