updated for version 7.3.996
Problem: Python: Can't check types of what is returned by bindeval().
Solution: Add vim.List, vim.Dictionary and vim.Function types. (ZyX)
diff --git a/src/if_py_both.h b/src/if_py_both.h
index 09bb0c0..957d6d5 100644
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -4245,6 +4245,15 @@
{"windows", (PyObject *)(void *)&TheWindowList},
{"tabpages", (PyObject *)(void *)&TheTabPageList},
{"current", (PyObject *)(void *)&TheCurrent},
+
+ {"Buffer", (PyObject *)&BufferType},
+ {"Range", (PyObject *)&RangeType},
+ {"Window", (PyObject *)&WindowType},
+ {"TabPage", (PyObject *)&TabPageType},
+ {"Dictionary", (PyObject *)&DictionaryType},
+ {"List", (PyObject *)&ListType},
+ {"Function", (PyObject *)&FunctionType},
+ {"Options", (PyObject *)&OptionsType},
};
typedef int (*object_adder)(PyObject *, const char *, PyObject *);
diff --git a/src/testdir/test86.in b/src/testdir/test86.in
index 6a10bd7..c49eb3b 100644
--- a/src/testdir/test86.in
+++ b/src/testdir/test86.in
@@ -631,10 +631,26 @@
cb.append('Current line: ' + repr(vim.current.line))
for b in vim.buffers:
if b is not cb:
- vim.command('bwipeout! ' + b.number)
+ vim.command('bwipeout! ' + str(b.number))
EOF
:tabonly!
:only!
+:"
+:" Test types
+py << EOF
+for expr, attr in (
+ ('vim.vars', 'Dictionary'),
+ ('vim.options', 'Options'),
+ ('vim.bindeval("{}")', 'Dictionary'),
+ ('vim.bindeval("[]")', 'List'),
+ ('vim.bindeval("function(\'tr\')")', 'Function'),
+ ('vim.current.buffer', 'Buffer'),
+ ('vim.current.range', 'Range'),
+ ('vim.current.window', 'Window'),
+ ('vim.current.tabpage', 'TabPage'),
+):
+ cb.append(expr + ':' + attr + ':' + repr(type(eval(expr)) is getattr(vim, attr)))
+EOF
:endfun
:"
:call Test()
diff --git a/src/testdir/test86.ok b/src/testdir/test86.ok
index 8defc5a..c91f741 100644
--- a/src/testdir/test86.ok
+++ b/src/testdir/test86.ok
@@ -333,7 +333,7 @@
Current tab pages:
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
Windows:
- <window object (unknown)>(1): displays buffer <buffer test86.in>; cursor is at (954, 0)
+ <window object (unknown)>(1): displays buffer <buffer test86.in>; cursor is at (970, 0)
<tabpage 1>(2): 1 windows, current is <window object (unknown)>
Windows:
<window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
@@ -359,3 +359,12 @@
Current window: <window 0>
Current buffer: <buffer test86.in>
Current line: 'Type error at assigning None to vim.current.buffer'
+vim.vars:Dictionary:True
+vim.options:Options:True
+vim.bindeval("{}"):Dictionary:True
+vim.bindeval("[]"):List:True
+vim.bindeval("function('tr')"):Function:True
+vim.current.buffer:Buffer:True
+vim.current.range:Range:True
+vim.current.window:Window:True
+vim.current.tabpage:TabPage:True
diff --git a/src/testdir/test87.in b/src/testdir/test87.in
index c7f0920..94c1ab5 100644
--- a/src/testdir/test87.in
+++ b/src/testdir/test87.in
@@ -622,6 +622,22 @@
EOF
:tabonly!
:only!
+:"
+:" Test types
+py3 << EOF
+for expr, attr in (
+ ('vim.vars', 'Dictionary'),
+ ('vim.options', 'Options'),
+ ('vim.bindeval("{}")', 'Dictionary'),
+ ('vim.bindeval("[]")', 'List'),
+ ('vim.bindeval("function(\'tr\')")', 'Function'),
+ ('vim.current.buffer', 'Buffer'),
+ ('vim.current.range', 'Range'),
+ ('vim.current.window', 'Window'),
+ ('vim.current.tabpage', 'TabPage'),
+):
+ cb.append(expr + ':' + attr + ':' + repr(type(eval(expr)) is getattr(vim, attr)))
+EOF
:endfun
:"
:call Test()
diff --git a/src/testdir/test87.ok b/src/testdir/test87.ok
index bee93f9..08cd590 100644
--- a/src/testdir/test87.ok
+++ b/src/testdir/test87.ok
@@ -322,7 +322,7 @@
Current tab pages:
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
Windows:
- <window object (unknown)>(1): displays buffer <buffer test87.in>; cursor is at (930, 0)
+ <window object (unknown)>(1): displays buffer <buffer test87.in>; cursor is at (946, 0)
<tabpage 1>(2): 1 windows, current is <window object (unknown)>
Windows:
<window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
@@ -348,3 +348,12 @@
Current window: <window 0>
Current buffer: <buffer test87.in>
Current line: 'Type error at assigning None to vim.current.buffer'
+vim.vars:Dictionary:True
+vim.options:Options:True
+vim.bindeval("{}"):Dictionary:True
+vim.bindeval("[]"):List:True
+vim.bindeval("function('tr')"):Function:True
+vim.current.buffer:Buffer:True
+vim.current.range:Range:True
+vim.current.window:Window:True
+vim.current.tabpage:TabPage:True
diff --git a/src/version.c b/src/version.c
index 2349425..8171124 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 996,
+/**/
995,
/**/
994,