Commits

Armin Rigo committed 94d3a3c

test and fix

Comments (0)

Files changed (2)

c/_cffi_backend.c

                             "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;
         }
     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]
     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"))