summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numpy/core/src/multiarray/ctors.c6
-rw-r--r--numpy/core/tests/test_multiarray.py3
2 files changed, 6 insertions, 3 deletions
diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c
index c37ce5ad6..d7c17e8ad 100644
--- a/numpy/core/src/multiarray/ctors.c
+++ b/numpy/core/src/multiarray/ctors.c
@@ -3610,10 +3610,10 @@ PyArray_FromBuffer(PyObject *buf, PyArray_Descr *type,
}
}
- if ((offset < 0) || (offset >= ts)) {
+ if ((offset < 0) || (offset > ts)) {
PyErr_Format(PyExc_ValueError,
- "offset must be non-negative and smaller than buffer "\
- "lenth (%" INTP_FMT ")", (npy_intp)ts);
+ "offset must be non-negative and no greater than buffer "\
+ "length (%" INTP_FMT ")", (npy_intp)ts);
Py_DECREF(buf);
Py_DECREF(type);
return NULL;
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index f1a7a2b65..e478de7e0 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -1350,6 +1350,9 @@ class TestFromBuffer(object):
buf = x.tostring()
yield self.tst_basic,buf,x.flat,{'dtype':dt}
+ def test_empty(self):
+ yield self.tst_basic, '', np.array([]), {}
+
class TestResize(TestCase):
def test_basic(self):