summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2013-02-13 09:46:13 +0100
committerArmin Rigo <arigo@tunes.org>2013-02-13 09:46:13 +0100
commit8c72bdd379a1c1117e2e62ba93a425fced69859f (patch)
treebf38cace57b2a0162c874ee71464da0f21eab4cd
parent7207ca4a89eea526ab71a66a9083fa73f02d1ee5 (diff)
downloadcffi-8c72bdd379a1c1117e2e62ba93a425fced69859f.tar.gz
test and fix
-rw-r--r--c/_cffi_backend.c4
-rw-r--r--c/test_c.py4
2 files changed, 5 insertions, 3 deletions
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
index e32dfa5..ef1fbec 100644
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -1730,9 +1730,9 @@ _cdata_getslicearg(CDataObject *cd, PySliceObject *slice, Py_ssize_t bounds[])
"negative index not supported");
return NULL;
}
- if (stop >= get_array_length(cd)) {
+ if (stop > get_array_length(cd)) {
PyErr_Format(PyExc_IndexError,
- "index too large (expected %zd < %zd)",
+ "index too large (expected %zd <= %zd)",
stop, get_array_length(cd));
return NULL;
}
diff --git a/c/test_c.py b/c/test_c.py
index e0b92b7..2bbe10d 100644
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -2683,6 +2683,8 @@ def test_slice_array_checkbounds():
BIntP = new_pointer_type(new_primitive_type("int"))
BIntArray = new_array_type(BIntP, None)
c = newp(BIntArray, 5)
+ c[0:5]
+ assert len(c[5:5]) == 0
py.test.raises(IndexError, "c[-1:1]")
cp = c + 0
cp[-1:1]
@@ -2702,7 +2704,7 @@ def test_nonstandard_slice():
e = py.test.raises(IndexError, "c[4:2]")
assert str(e.value) == "slice start > stop"
e = py.test.raises(IndexError, "c[6:6]")
- assert str(e.value) == "index too large (expected 6 < 5)"
+ assert str(e.value) == "index too large (expected 6 <= 5)"
def test_setslice():
BIntP = new_pointer_type(new_primitive_type("int"))