Patch 8.2.1150
Problem:    ml_get error when using Python. (Yegappan Lakshmanan)
Solution:   Check the line number is not out of range.  Call "Check" with
            "fromObj" instead of "from".
Files:      src/if_py_both.h, src/testdir/test_python2.vim,
            src/testdir/test_python3.vim


*** ../vim-8.2.1149/src/if_py_both.h    2020-07-06 21:03:02.589331536 +0200
--- src/if_py_both.h    2020-07-07 20:02:04.662755855 +0200
***************
*** 3374,3380 ****
      char_u    *stringval;
      PyObject  *todecref;
  
!     if (self->Check(self->from))
        return NULL;
  
      if (!(key = StringToChars(keyObject, &todecref)))
--- 3374,3380 ----
      char_u    *stringval;
      PyObject  *todecref;
  
!     if (self->Check(self->fromObj))
        return NULL;
  
      if (!(key = StringToChars(keyObject, &todecref)))
***************
*** 3565,3571 ****
      int               ret = 0;
      PyObject  *todecref;
  
!     if (self->Check(self->from))
        return -1;
  
      if (!(key = StringToChars(keyObject, &todecref)))
--- 3565,3571 ----
      int               ret = 0;
      PyObject  *todecref;
  
!     if (self->Check(self->fromObj))
        return -1;
  
      if (!(key = StringToChars(keyObject, &todecref)))
***************
*** 4334,4343 ****
  
      for (i = 0; i < n; ++i)
      {
!       PyObject        *string = LineToString(
!               (char *)ml_get_buf(buf, (linenr_T)(lo+i), FALSE));
  
!       // Error check - was the Python string creation OK?
        if (string == NULL)
        {
            Py_DECREF(list);
--- 4334,4348 ----
  
      for (i = 0; i < n; ++i)
      {
!       linenr_T        lnum = (linenr_T)(lo + i);
!       char            *text;
!       PyObject        *string;
  
!       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);
*** ../vim-8.2.1149/src/testdir/test_python2.vim        2020-07-06 
21:03:02.589331536 +0200
--- src/testdir/test_python2.vim        2020-07-07 20:10:14.525188346 +0200
***************
*** 278,286 ****
    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[:]')
  
    " Non-existing range attribute
    call AssertException(["let x = pyeval('r.abc')"],
--- 278,286 ----
    py r[1:0] = ["d"]
    call assert_equal(['c', 'd', 'a', 'two', 'three', 'b'], getline(1, '$'))
  
!   " 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,340 ****
    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')
    call assert_match('<window object (deleted)', pyeval("repr(w)"))
    %bw!
  endfunc
--- 332,340 ----
    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
!   " 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
*** ../vim-8.2.1149/src/testdir/test_python3.vim        2020-07-06 
21:03:02.589331536 +0200
--- src/testdir/test_python3.vim        2020-07-07 20:11:54.344867341 +0200
***************
*** 462,470 ****
    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[:]')
  
    " Non-existing range attribute
    call AssertException(["let x = py3eval('r.abc')"],
--- 462,470 ----
    py3 r[1:0] = ["d"]
    call assert_equal(['c', 'd', 'a', 'two', 'three', 'b'], getline(1, '$'))
  
!   " 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,524 ****
    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')
    call assert_match('<window object (deleted)', py3eval("repr(w)"))
    %bw!
  endfunc
--- 516,524 ----
    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
!   " 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
*** ../vim-8.2.1149/src/version.c       2020-07-06 23:04:44.829229830 +0200
--- src/version.c       2020-07-07 19:29:59.613117342 +0200
***************
*** 756,757 ****
--- 756,759 ----
  {   /* Add new patch number below this line */
+ /**/
+     1150,
  /**/

-- 
Sometimes you can protect millions of dollars in your budget simply by buying
a bag of cookies, dropping it on the budget anylyst's desk, and saying
something deeply personal such as "How was your weekend, big guy?"
                                (Scott Adams - The Dilbert principle)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202007071813.067IDT9l1142980%40masaka.moolenaar.net.

Raspunde prin e-mail lui