diff options
author | Christolph Gohlke <cgohlke@uci.edu> | 2011-04-23 16:52:18 -0600 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2011-04-23 16:52:18 -0600 |
commit | a2e81731463448d87fb8c4282595a386532f3aee (patch) | |
tree | 3bbb3e2b74819c3b782a86fdb74b9e9f5a851ad3 | |
parent | ad76bb546940dfd4f95adb3d01e6742a34fb1de1 (diff) | |
download | numpy-a2e81731463448d87fb8c4282595a386532f3aee.tar.gz |
BUG: Fix regression in checking array size from dimensions.
-rw-r--r-- | numpy/core/src/multiarray/ctors.c | 6 | ||||
-rw-r--r-- | numpy/core/tests/test_regression.py | 3 |
2 files changed, 5 insertions, 4 deletions
diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c index 261e6754b..a026ecb4d 100644 --- a/numpy/core/src/multiarray/ctors.c +++ b/numpy/core/src/multiarray/ctors.c @@ -978,14 +978,14 @@ PyArray_NewFromDescr(PyTypeObject *subtype, PyArray_Descr *descr, int nd, return NULL; } - size *= dim; - - if (size > largest) { + if (dim > largest) { PyErr_SetString(PyExc_ValueError, "array is too big."); Py_DECREF(descr); return NULL; } + size *= dim; + largest /= dim; } self = (PyArrayObject *) subtype->tp_alloc(subtype, 0); diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py index cb65c8cef..281342bbf 100644 --- a/numpy/core/tests/test_regression.py +++ b/numpy/core/tests/test_regression.py @@ -1152,7 +1152,8 @@ class TestRegression(TestCase): def test_array_too_big(self): """Ticket #1080.""" - assert_raises(ValueError, np.zeros, [2**10]*10) + assert_raises(ValueError, np.zeros, [2**10]*10, np.int8) + assert_raises(MemoryError, np.zeros, [2**30]*2, np.int8) def test_dtype_keyerrors_(self): """Ticket #1106.""" |