0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

updated for version 7.3.943

Problem:    Python: Negative indices were failing.
Solution:   Fix negative indices. Add tests. (ZyX)
This commit is contained in:
Bram Moolenaar
2013-05-12 21:16:23 +02:00
parent 8f1723de47
commit bd80f35bc5
7 changed files with 120 additions and 4 deletions

View File

@@ -2394,6 +2394,9 @@ RBItem(BufferObject *self, PyInt n, PyInt start, PyInt end)
if (end == -1)
end = self->buf->b_ml.ml_line_count;
if (n < 0)
n += end - start + 1;
if (n < 0 || n > end - start)
{
PyErr_SetString(PyExc_IndexError, _("line number out of range"));
@@ -2441,6 +2444,9 @@ RBAsItem(BufferObject *self, PyInt n, PyObject *val, PyInt start, PyInt end, PyI
if (end == -1)
end = self->buf->b_ml.ml_line_count;
if (n < 0)
n += end - start + 1;
if (n < 0 || n > end - start)
{
PyErr_SetString(PyExc_IndexError, _("line number out of range"));