Author: Armin Rigo <[email protected]>
Branch:
Changeset: r1153:94d3a3cf5895
Date: 2013-02-13 09:46 +0100
http://bitbucket.org/cffi/cffi/changeset/94d3a3cf5895/
Log: test and fix
diff --git a/c/_cffi_backend.c b/c/_cffi_backend.c
--- a/c/_cffi_backend.c
+++ b/c/_cffi_backend.c
@@ -1730,9 +1730,9 @@
"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
--- a/c/test_c.py
+++ b/c/test_c.py
@@ -2683,6 +2683,8 @@
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 @@
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"))
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit