if_python: vimlist[start:end] returns wrong result.
Steps to reproduce:
:py l = vim.bindeval("[0, 1, 2, 3, 4, 5]")
:py print(l[2:4])
[0, 2]
Expected:
[2, 3]
Please check the following patch.
diff -r d2571e334983 src/if_py_both.h
--- a/src/if_py_both.h Tue Mar 19 18:31:49 2013 +0100
+++ b/src/if_py_both.h Thu Mar 28 15:43:25 2013 +0900
@@ -1139,7 +1139,7 @@
for (i = 0; i < n; ++i)
{
- PyObject *item = ListItem(self, i);
+ PyObject *item = ListItem(self, first + i);
if (item == NULL)
{
Py_DECREF(list);
diff -r d2571e334983 src/testdir/test86.in
--- a/src/testdir/test86.in Tue Mar 19 18:31:49 2013 +0100
+++ b/src/testdir/test86.in Thu Mar 28 15:43:25 2013 +0900
@@ -321,6 +321,31 @@
:py trace_main()
:py sys.settrace(None)
:$put =string(l)
+:"
+:" Slice
+:py ll = vim.bindeval('[0, 1, 2, 3, 4, 5]')
+:py l = ll[:4]
+:$put =string(pyeval('l'))
+:py l = ll[2:]
+:$put =string(pyeval('l'))
+:py l = ll[:-4]
+:$put =string(pyeval('l'))
+:py l = ll[-2:]
+:$put =string(pyeval('l'))
+:py l = ll[2:4]
+:$put =string(pyeval('l'))
+:py l = ll[4:2]
+:$put =string(pyeval('l'))
+:py l = ll[-4:-2]
+:$put =string(pyeval('l'))
+:py l = ll[-2:-4]
+:$put =string(pyeval('l'))
+:py l = ll[:]
+:$put =string(pyeval('l'))
+:py l = ll[0:6]
+:$put =string(pyeval('l'))
+:py l = ll[-10:10]
+:$put =string(pyeval('l'))
:endfun
:"
:call Test()
diff -r d2571e334983 src/testdir/test86.ok
--- a/src/testdir/test86.ok Tue Mar 19 18:31:49 2013 +0100
+++ b/src/testdir/test86.ok Thu Mar 28 15:43:25 2013 +0900
@@ -65,3 +65,14 @@
vim: Vim(let):E859:
[1]
[1, 10, 11, 10, 11, 10, 11, 10, 11, 10, 11, 10, 1]
+[0, 1, 2, 3]
+[2, 3, 4, 5]
+[0, 1]
+[4, 5]
+[2, 3]
+[]
+[2, 3]
+[]
+[0, 1, 2, 3, 4, 5]
+[0, 1, 2, 3, 4, 5]
+[0, 1, 2, 3, 4, 5]
--
Yukihiro Nakadaira - [email protected]
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.