test_popup \
test_profile \
test_put \
+ test_python2 \
+ test_python3 \
test_pyx2 \
test_pyx3 \
test_quickfix \
int status;
PyObject *pyfunc, *pymain;
PyObject *run_ret;
+ buf_T *was_curbuf = curbuf;
if (u_save((linenr_T)RangeStart - 1, (linenr_T)RangeEnd + 1) != OK)
{
#ifdef PY_CAN_RECURSE
*pygilstate = PyGILState_Ensure();
#endif
- if (!(line = GetBufferLine(curbuf, lnum)))
+ /* Check the line number, the command my have deleted lines. */
+ if (lnum > curbuf->b_ml.ml_line_count
+ || !(line = GetBufferLine(curbuf, lnum)))
goto err;
if (!(linenr = PyInt_FromLong((long) lnum)))
{
if (!ret)
goto err;
+ /* Check that the command didn't switch to another buffer. */
+ if (curbuf != was_curbuf)
+ {
+ Py_XDECREF(ret);
+ goto err;
+ }
+
if (ret != Py_None)
if (SetBufferLine(curbuf, lnum, ret, NULL) == FAIL)
+ {
+ Py_XDECREF(ret);
goto err;
+ }
Py_XDECREF(ret);
PythonIO_Flush();
test_packadd.res \
test_perl.res \
test_profile.res \
+ test_python2.res \
+ test_python3.res \
test_pyx2.res \
test_pyx3.res \
test_quickfix.res \
--- /dev/null
+" Test for python 2 commands.
+" TODO: move tests from test87.in here.
+
+if !has('python')
+ finish
+endif
+
+func Test_pydo()
+ " Check deleting lines does not trigger ml_get error.
+ py import vim
+ new
+ call setline(1, ['one', 'two', 'three'])
+ pydo vim.command("%d_")
+ bwipe!
+
+ " Check switching to another buffer does not trigger ml_get error.
+ new
+ let wincount = winnr('$')
+ call setline(1, ['one', 'two', 'three'])
+ pydo vim.command("new")
+ call assert_equal(wincount + 1, winnr('$'))
+ bwipe!
+ bwipe!
+endfunc
--- /dev/null
+" Test for python 2 commands.
+" TODO: move tests from test88.in here.
+
+if !has('python3')
+ finish
+endif
+
+func Test_py3do()
+ " Check deleting lines does not trigger an ml_get error.
+ py3 import vim
+ new
+ call setline(1, ['one', 'two', 'three'])
+ py3do vim.command("%d_")
+ bwipe!
+
+ " Check switching to another buffer does not trigger an ml_get error.
+ new
+ let wincount = winnr('$')
+ call setline(1, ['one', 'two', 'three'])
+ py3do vim.command("new")
+ call assert_equal(wincount + 1, winnr('$'))
+ bwipe!
+ bwipe!
+endfunc
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 265,
/**/
264,
/**/