Merge remote-tracking branch 'vim/master'

This commit is contained in:
ichizok
2020-07-08 15:55:45 +09:00
6 changed files with 115 additions and 18 deletions
+10 -5
View File
@@ -3374,7 +3374,7 @@ OptionsItem(OptionsObject *self, PyObject *keyObject)
char_u *stringval;
PyObject *todecref;
if (self->Check(self->from))
if (self->Check(self->fromObj))
return NULL;
if (!(key = StringToChars(keyObject, &todecref)))
@@ -3565,7 +3565,7 @@ OptionsAssItem(OptionsObject *self, PyObject *keyObject, PyObject *valObject)
int ret = 0;
PyObject *todecref;
if (self->Check(self->from))
if (self->Check(self->fromObj))
return -1;
if (!(key = StringToChars(keyObject, &todecref)))
@@ -4334,10 +4334,15 @@ GetBufferLineList(buf_T *buf, PyInt lo, PyInt hi)
for (i = 0; i < n; ++i)
{
PyObject *string = LineToString(
(char *)ml_get_buf(buf, (linenr_T)(lo+i), FALSE));
linenr_T lnum = (linenr_T)(lo + i);
char *text;
PyObject *string;
// Error check - was the Python string creation OK?
if (lnum > buf->b_ml.ml_line_count)
text = "";
else
text = (char *)ml_get_buf(buf, lnum, FALSE);
string = LineToString(text);
if (string == NULL)
{
Py_DECREF(list);
+31 -6
View File
@@ -278,9 +278,9 @@ func Test_python_range()
py r[1:0] = ["d"]
call assert_equal(['c', 'd', 'a', 'two', 'three', 'b'], getline(1, '$'))
" FIXME: The following code triggers ml_get errors
" %d
" let x = pyeval('r[:]')
" The following code used to trigger an ml_get error
%d
let x = pyeval('r[:]')
" Non-existing range attribute
call AssertException(["let x = pyeval('r.abc')"],
@@ -332,9 +332,9 @@ func Test_python_window()
call AssertException(["py vim.current.window = w"],
\ 'Vim(python):vim.error: attempt to refer to deleted window')
" Try to set one of the options of the closed window
" FIXME: The following causes ASAN failure
"call AssertException(["py wopts['list'] = False"],
" \ 'vim.error: problem while switching windows')
" The following caused an ASAN failure
call AssertException(["py wopts['list'] = False"],
\ 'vim.error: attempt to refer to deleted window')
call assert_match('<window object (deleted)', pyeval("repr(w)"))
%bw!
endfunc
@@ -623,6 +623,9 @@ func Test_python_slice_assignment()
py l = vim.bindeval('l')
py l[2:2:1] = ()
call assert_equal([0, 1, 2, 3, 4, 5, 6, 7], l)
call AssertException(["py x = l[10:11:0]"],
\ "Vim(python):ValueError: slice step cannot be zero")
endfunc
" Locked variables
@@ -809,6 +812,10 @@ func Test_python_vim_bindeval()
call assert_equal(0, pyeval("vim.bindeval('v:false')"))
call assert_equal(v:none, pyeval("vim.bindeval('v:null')"))
call assert_equal(v:none, pyeval("vim.bindeval('v:none')"))
" channel/job
call assert_equal(v:none, pyeval("vim.bindeval('test_null_channel()')"))
call assert_equal(v:none, pyeval("vim.bindeval('test_null_job()')"))
endfunc
" threading
@@ -1402,6 +1409,20 @@ func Test_python_buffer()
call assert_equal([], pyeval('b[2:0]'))
call assert_equal([], pyeval('b[10:12]'))
call assert_equal([], pyeval('b[-10:-8]'))
call AssertException(["py x = b[0:3:0]"],
\ "Vim(python):TypeError: sequence index must be integer, not 'slice'")
call AssertException(["py b[0:3:0] = 'abc'"],
\ "Vim(python):TypeError: sequence index must be integer, not 'slice'")
call AssertException(["py x = b[{}]"],
\ "Vim(python):TypeError: sequence index must be integer, not 'dict'")
call AssertException(["py b[{}] = 'abc'"],
\ "Vim(python):TypeError: sequence index must be integer, not 'dict'")
" Test for getting lines using a range
call AssertException(["py x = b.range(0,3)[0:2:0]"],
\ "Vim(python):TypeError: sequence index must be integer, not 'slice'")
call AssertException(["py b.range(0,3)[0:2:0] = 'abc'"],
\ "Vim(python):TypeError: sequence index must be integer, not 'slice'")
" Tests BufferAppend and BufferItem
py cb.append(b[0])
@@ -1512,6 +1533,9 @@ func Test_python_buffer()
py vim.current.buffer[:] = []
call assert_equal([''], getline(1, '$'))
" Test for buffer marks
call assert_equal(v:none, pyeval("vim.current.buffer.mark('r')"))
" Test for modifying a 'nomodifiable' buffer
setlocal nomodifiable
call AssertException(["py vim.current.buffer[0] = 'abc'"],
@@ -2408,6 +2432,7 @@ func Test_python_chdir()
call assert_equal(['testdir', 'Xfile', 'src', 'testdir/Xfile', 'testdir',
\ 'Xfile'], getline(2, '$'))
close!
call AssertException(["py vim.chdir(None)"], "Vim(python):TypeError:")
endfunc
" Test errors
+31 -6
View File
@@ -462,9 +462,9 @@ func Test_python3_range2()
py3 r[1:0] = ["d"]
call assert_equal(['c', 'd', 'a', 'two', 'three', 'b'], getline(1, '$'))
" FIXME: The following code triggers ml_get errors
" %d
" let x = py3eval('r[:]')
" The following code used to trigger an ml_get error
%d
let x = py3eval('r[:]')
" Non-existing range attribute
call AssertException(["let x = py3eval('r.abc')"],
@@ -516,9 +516,9 @@ func Test_python3_window()
call AssertException(["py3 vim.current.window = w"],
\ 'Vim(py3):vim.error: attempt to refer to deleted window')
" Try to set one of the options of the closed window
" FIXME: The following causes ASAN failure
"call AssertException(["py3 wopts['list'] = False"],
" \ 'Vim(py3):vim.error: problem while switching windows')
" The following caused ASAN failure
call AssertException(["py3 wopts['list'] = False"],
\ 'Vim(py3):vim.error: attempt to refer to deleted window')
call assert_match('<window object (deleted)', py3eval("repr(w)"))
%bw!
endfunc
@@ -798,6 +798,9 @@ func Test_python3_slice_assignment()
py3 l = vim.bindeval('l')
py3 l[2:2:1] = ()
call assert_equal([0, 1, 2, 3, 4, 5, 6, 7], l)
call AssertException(["py3 x = l[10:11:0]"],
\ "Vim(py3):ValueError: slice step cannot be zero")
endfunc
" Locked variables
@@ -987,6 +990,10 @@ func Test_python3_vim_bindeval()
call assert_equal(0, py3eval("vim.bindeval('v:false')"))
call assert_equal(v:none, py3eval("vim.bindeval('v:null')"))
call assert_equal(v:none, py3eval("vim.bindeval('v:none')"))
" channel/job
call assert_equal(v:none, py3eval("vim.bindeval('test_null_channel()')"))
call assert_equal(v:none, py3eval("vim.bindeval('test_null_job()')"))
endfunc
" threading
@@ -1580,6 +1587,20 @@ func Test_python3_buffer()
call assert_equal([], py3eval('b[2:0]'))
call assert_equal([], py3eval('b[10:12]'))
call assert_equal([], py3eval('b[-10:-8]'))
call AssertException(["py3 x = b[0:3:0]"],
\ 'Vim(py3):ValueError: slice step cannot be zero')
call AssertException(["py3 b[0:3:0] = 'abc'"],
\ 'Vim(py3):ValueError: slice step cannot be zero')
call AssertException(["py3 x = b[{}]"],
\ 'Vim(py3):TypeError: index must be int or slice, not dict')
call AssertException(["py3 b[{}] = 'abc'"],
\ 'Vim(py3):TypeError: index must be int or slice, not dict')
" Test for getting lines using a range
call AssertException(["py3 x = b.range(0,3)[0:2:0]"],
\ "Vim(py3):ValueError: slice step cannot be zero")
call AssertException(["py3 b.range(0,3)[0:2:0] = 'abc'"],
\ "Vim(py3):ValueError: slice step cannot be zero")
" Tests BufferAppend and BufferItem
py3 cb.append(b[0])
@@ -1690,6 +1711,9 @@ func Test_python3_buffer()
py3 vim.current.buffer[:] = []
call assert_equal([''], getline(1, '$'))
" Test for buffer marks
call assert_equal(v:none, py3eval("vim.current.buffer.mark('r')"))
" Test for modifying a 'nomodifiable' buffer
setlocal nomodifiable
call AssertException(["py3 vim.current.buffer[0] = 'abc'"],
@@ -2578,6 +2602,7 @@ func Test_python3_chdir()
call assert_equal(["b'testdir'", 'Xfile', "b'src'", 'testdir/Xfile',
\"b'testdir'", 'Xfile'], getline(2, '$'))
close!
call AssertException(["py3 vim.chdir(None)"], "Vim(py3):TypeError:")
endfunc
" Test errors
+33
View File
@@ -980,6 +980,39 @@ def Test_vim9script_reload_import()
delete('Ximport.vim')
enddef
" Not exported function that is referenced needs to be accessed by the
" script-local name.
def Test_vim9script_funcref()
let sortlines =<< trim END
vim9script
def Compare(i1: number, i2: number): number
return i2 - i1
enddef
export def FastSort(): list<number>
return range(5)->sort(Compare)
enddef
END
writefile(sortlines, 'Xsort.vim')
let lines =<< trim END
vim9script
import FastSort from './Xsort.vim'
def Test()
g:result = FastSort()
enddef
Test()
END
writefile(lines, 'Xscript.vim')
source Xscript.vim
assert_equal([4, 3, 2, 1, 0], g:result)
unlet g:result
delete('Xsort.vim')
delete('Xscript.vim')
enddef
def Test_vim9script_reload_delfunc()
let first_lines =<< trim END
vim9script
+8
View File
@@ -769,6 +769,14 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1153,
/**/
1152,
/**/
1151,
/**/
1150,
/**/
1149,
/**/
+2 -1
View File
@@ -2676,7 +2676,8 @@ generate_funcref(cctx_T *cctx, char_u *name)
if (ufunc == NULL)
return FAIL;
return generate_PUSHFUNC(cctx, vim_strsave(name), ufunc->uf_func_type);
return generate_PUSHFUNC(cctx, vim_strsave(ufunc->uf_name),
ufunc->uf_func_type);
}
/*