Patch 7.4.905
Problem:    Python interface can produce error "vim.message' object has no
            attribute 'isatty'".
Solution:   Add dummy isatty(), readable(), etc. (closes #464)
Files:      src/if_py_both.h, src/testdir/test86.in, src/testdir/test86.ok,
            src/testdir/test87.in, src/testdir/test87.ok


*** ../vim-7.4.904/src/if_py_both.h     2015-02-10 18:41:53.006111926 +0100
--- src/if_py_both.h    2015-11-02 13:21:24.911033469 +0100
***************
*** 465,484 ****
  }
  
      static PyObject *
! OutputFlush(PyObject *self UNUSED)
  {
      /* do nothing */
      Py_INCREF(Py_None);
      return Py_None;
  }
  
  /***************/
  
  static struct PyMethodDef OutputMethods[] = {
      /* name,      function,                           calling,        doc */
      {"write",     (PyCFunction)OutputWrite,           METH_O,         ""},
      {"writelines",  (PyCFunction)OutputWritelines,    METH_O,         ""},
!     {"flush",     (PyCFunction)OutputFlush,           METH_NOARGS,    ""},
      {"__dir__",           (PyCFunction)OutputDir,             METH_NOARGS,    
""},
      { NULL,       NULL,                               0,              NULL}
  };
--- 465,505 ----
  }
  
      static PyObject *
! AlwaysNone(PyObject *self UNUSED)
  {
      /* do nothing */
      Py_INCREF(Py_None);
      return Py_None;
  }
  
+     static PyObject *
+ AlwaysFalse(PyObject *self UNUSED)
+ {
+     /* do nothing */
+     Py_INCREF(Py_False);
+     return Py_False;
+ }
+ 
+     static PyObject *
+ AlwaysTrue(PyObject *self UNUSED)
+ {
+     /* do nothing */
+     Py_INCREF(Py_True);
+     return Py_True;
+ }
+ 
  /***************/
  
  static struct PyMethodDef OutputMethods[] = {
      /* name,      function,                           calling,        doc */
      {"write",     (PyCFunction)OutputWrite,           METH_O,         ""},
      {"writelines",  (PyCFunction)OutputWritelines,    METH_O,         ""},
!     {"flush",     (PyCFunction)AlwaysNone,            METH_NOARGS,    ""},
!     {"close",     (PyCFunction)AlwaysNone,            METH_NOARGS,    ""},
!     {"isatty",            (PyCFunction)AlwaysFalse,           METH_NOARGS,    
""},
!     {"readable",    (PyCFunction)AlwaysFalse,         METH_NOARGS,    ""},
!     {"seekable",    (PyCFunction)AlwaysFalse,         METH_NOARGS,    ""},
!     {"writable",    (PyCFunction)AlwaysTrue,          METH_NOARGS,    ""},
      {"__dir__",           (PyCFunction)OutputDir,             METH_NOARGS,    
""},
      { NULL,       NULL,                               0,              NULL}
  };
*** ../vim-7.4.904/src/testdir/test86.in        2014-09-29 18:08:54.587952270 
+0200
--- src/testdir/test86.in       2015-11-02 13:19:04.276680955 +0100
***************
*** 1094,1101 ****
--- 1094,1113 ----
  ee('del sys.stdout.softspace')
  number_test('sys.stdout.softspace = %s', unsigned=True)
  number_test('sys.stderr.softspace = %s', unsigned=True)
+ ee('assert sys.stdout.isatty()==False')
+ ee('assert sys.stdout.seekable()==False')
+ ee('sys.stdout.close()')
+ ee('sys.stdout.flush()')
+ ee('assert sys.stderr.isatty()==False')
+ ee('assert sys.stderr.seekable()==False')
+ ee('sys.stderr.close()')
+ ee('sys.stderr.flush()')
  ee('sys.stdout.attr = None')
  cb.append(">> OutputWrite")
+ ee('assert sys.stdout.writable()==True')
+ ee('assert sys.stdout.readable()==False')
+ ee('assert sys.stderr.writable()==True')
+ ee('assert sys.stderr.readable()==False')
  ee('sys.stdout.write(None)')
  cb.append(">> OutputWriteLines")
  ee('sys.stdout.writelines(None)')
*** ../vim-7.4.904/src/testdir/test86.ok        2014-03-12 15:26:36.428714415 
+0100
--- src/testdir/test86.ok       2015-11-02 13:19:04.280680909 +0100
***************
*** 447,453 ****
  
dictionary:__dir__,__members__,get,has_key,items,keys,locked,pop,popitem,scope,update,values
  list:__dir__,__members__,extend,locked
  function:__dir__,__members__,softspace
! output:__dir__,__members__,flush,softspace,write,writelines
  {}
  {'a': 1}
  {'a': 1}
--- 447,453 ----
  
dictionary:__dir__,__members__,get,has_key,items,keys,locked,pop,popitem,scope,update,values
  list:__dir__,__members__,extend,locked
  function:__dir__,__members__,softspace
! 
output:__dir__,__members__,close,flush,isatty,readable,seekable,softspace,writable,write,writelines
  {}
  {'a': 1}
  {'a': 1}
***************
*** 488,495 ****
--- 488,507 ----
  sys.stderr.softspace = None:TypeError:('expected int(), long() or something 
supporting coercing to long(), but got NoneType',)
  sys.stderr.softspace = -1:ValueError:('number must be greater or equal to 
zero',)
  <<< Finished
+ assert sys.stdout.isatty()==False:NOT FAILED
+ assert sys.stdout.seekable()==False:NOT FAILED
+ sys.stdout.close():NOT FAILED
+ sys.stdout.flush():NOT FAILED
+ assert sys.stderr.isatty()==False:NOT FAILED
+ assert sys.stderr.seekable()==False:NOT FAILED
+ sys.stderr.close():NOT FAILED
+ sys.stderr.flush():NOT FAILED
  sys.stdout.attr = None:AttributeError:('invalid attribute: attr',)
  >> OutputWrite
+ assert sys.stdout.writable()==True:NOT FAILED
+ assert sys.stdout.readable()==False:NOT FAILED
+ assert sys.stderr.writable()==True:NOT FAILED
+ assert sys.stderr.readable()==False:NOT FAILED
  sys.stdout.write(None):TypeError:('coercing to Unicode: need string or 
buffer, NoneType found',)
  >> OutputWriteLines
  sys.stdout.writelines(None):TypeError:("'NoneType' object is not iterable",)
*** ../vim-7.4.904/src/testdir/test87.in        2014-09-29 18:08:54.591952271 
+0200
--- src/testdir/test87.in       2015-11-02 13:19:04.280680909 +0100
***************
*** 1071,1078 ****
--- 1071,1090 ----
  ee('del sys.stdout.softspace')
  number_test('sys.stdout.softspace = %s', unsigned=True)
  number_test('sys.stderr.softspace = %s', unsigned=True)
+ ee('assert sys.stdout.isatty()==False')
+ ee('assert sys.stdout.seekable()==False')
+ ee('sys.stdout.close()')
+ ee('sys.stdout.flush()')
+ ee('assert sys.stderr.isatty()==False')
+ ee('assert sys.stderr.seekable()==False')
+ ee('sys.stderr.close()')
+ ee('sys.stderr.flush()')
  ee('sys.stdout.attr = None')
  cb.append(">> OutputWrite")
+ ee('assert sys.stdout.writable()==True')
+ ee('assert sys.stdout.readable()==False')
+ ee('assert sys.stderr.writable()==True')
+ ee('assert sys.stderr.readable()==False')
  ee('sys.stdout.write(None)')
  cb.append(">> OutputWriteLines")
  ee('sys.stdout.writelines(None)')
*** ../vim-7.4.904/src/testdir/test87.ok        2014-03-12 15:26:36.432714415 
+0100
--- src/testdir/test87.ok       2015-11-02 13:19:04.280680909 +0100
***************
*** 447,453 ****
  
dictionary:__dir__,get,has_key,items,keys,locked,pop,popitem,scope,update,values
  list:__dir__,extend,locked
  function:__dir__,softspace
! output:__dir__,flush,softspace,write,writelines
  {}
  {'a': 1}
  {'a': 1}
--- 447,453 ----
  
dictionary:__dir__,get,has_key,items,keys,locked,pop,popitem,scope,update,values
  list:__dir__,extend,locked
  function:__dir__,softspace
! 
output:__dir__,close,flush,isatty,readable,seekable,softspace,writable,write,writelines
  {}
  {'a': 1}
  {'a': 1}
***************
*** 488,495 ****
--- 488,507 ----
  sys.stderr.softspace = None:(<class 'TypeError'>, TypeError('expected int() 
or something supporting coercing to int(), but got NoneType',))
  sys.stderr.softspace = -1:(<class 'ValueError'>, ValueError('number must be 
greater or equal to zero',))
  <<< Finished
+ assert sys.stdout.isatty()==False:NOT FAILED
+ assert sys.stdout.seekable()==False:NOT FAILED
+ sys.stdout.close():NOT FAILED
+ sys.stdout.flush():NOT FAILED
+ assert sys.stderr.isatty()==False:NOT FAILED
+ assert sys.stderr.seekable()==False:NOT FAILED
+ sys.stderr.close():NOT FAILED
+ sys.stderr.flush():NOT FAILED
  sys.stdout.attr = None:(<class 'AttributeError'>, AttributeError('invalid 
attribute: attr',))
  >> OutputWrite
+ assert sys.stdout.writable()==True:NOT FAILED
+ assert sys.stdout.readable()==False:NOT FAILED
+ assert sys.stderr.writable()==True:NOT FAILED
+ assert sys.stderr.readable()==False:NOT FAILED
  sys.stdout.write(None):(<class 'TypeError'>, TypeError("Can't convert 
'NoneType' object to str implicitly",))
  >> OutputWriteLines
  sys.stdout.writelines(None):(<class 'TypeError'>, TypeError("'NoneType' 
object is not iterable",))
*** ../vim-7.4.904/src/version.c        2015-11-02 12:50:49.760534351 +0100
--- src/version.c       2015-11-02 13:27:03.923061723 +0100
***************
*** 743,744 ****
--- 743,746 ----
  {   /* Add new patch number below this line */
+ /**/
+     905,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
78. You find yourself dialing IP numbers on the phone.

 /// 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].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui