diff --git a/src/if_py_both.h b/src/if_py_both.h index c7df93be2a..5bd6a0e677 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -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); diff --git a/src/testdir/test_python2.vim b/src/testdir/test_python2.vim index f0b9b06c72..42fadaab69 100644 --- a/src/testdir/test_python2.vim +++ b/src/testdir/test_python2.vim @@ -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(' + 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 diff --git a/src/version.c b/src/version.c index 7fcc76e244..ad698f9bc0 100644 --- a/src/version.c +++ b/src/version.c @@ -769,6 +769,14 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1153, +/**/ + 1152, +/**/ + 1151, +/**/ + 1150, /**/ 1149, /**/ diff --git a/src/vim9compile.c b/src/vim9compile.c index ff6668fe46..07e0d27277 100644 --- a/src/vim9compile.c +++ b/src/vim9compile.c @@ -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); } /*