To: vim_dev@googlegroups.com Subject: Patch 7.4.1769 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.1769 Problem: No "closed", "errors" and "encoding" attribute on Python output. Solution: Add attributes and more tests. (Roland Puntaier, closes #622) Files: src/if_py_both.h, src/if_python.c, src/if_python3.c, src/testdir/test86.in, src/testdir/test86.ok, src/testdir/test87.in, src/testdir/test87.ok *** ../vim-7.4.1768/src/if_py_both.h 2016-04-15 21:47:50.724171696 +0200 --- src/if_py_both.h 2016-04-21 19:52:10.368357260 +0200 *************** *** 503,508 **** --- 503,509 ---- {"readable", (PyCFunction)AlwaysFalse, METH_NOARGS, ""}, {"seekable", (PyCFunction)AlwaysFalse, METH_NOARGS, ""}, {"writable", (PyCFunction)AlwaysTrue, METH_NOARGS, ""}, + {"closed", (PyCFunction)AlwaysFalse, METH_NOARGS, ""}, {"__dir__", (PyCFunction)OutputDir, METH_NOARGS, ""}, { NULL, NULL, 0, NULL} }; *** ../vim-7.4.1768/src/if_python.c 2016-04-14 15:55:58.401348489 +0200 --- src/if_python.c 2016-04-21 19:52:10.368357260 +0200 *************** *** 1195,1201 **** return PyInt_FromLong(((OutputObject *)(self))->softspace); else if (strcmp(name, "__members__") == 0) return ObjectDir(NULL, OutputAttrs); ! return Py_FindMethod(OutputMethods, self, name); } --- 1195,1204 ---- return PyInt_FromLong(((OutputObject *)(self))->softspace); else if (strcmp(name, "__members__") == 0) return ObjectDir(NULL, OutputAttrs); ! else if (strcmp(name, "errors") == 0) ! return PyString_FromString("strict"); ! else if (strcmp(name, "encoding") == 0) ! return PyString_FromString(ENC_OPT); return Py_FindMethod(OutputMethods, self, name); } *** ../vim-7.4.1768/src/if_python3.c 2016-04-14 15:55:58.405348448 +0200 --- src/if_python3.c 2016-04-21 19:52:10.368357260 +0200 *************** *** 1100,1105 **** --- 1100,1109 ---- if (strcmp(name, "softspace") == 0) return PyLong_FromLong(((OutputObject *)(self))->softspace); + else if (strcmp(name, "errors") == 0) + return PyString_FromString("strict"); + else if (strcmp(name, "encoding") == 0) + return PyString_FromString(ENC_OPT); return PyObject_GenericGetAttr(self, nameobj); } *** ../vim-7.4.1768/src/testdir/test86.in 2016-04-14 15:55:58.405348448 +0200 --- src/testdir/test86.in 2016-04-21 19:52:10.372357218 +0200 *************** *** 1289,1294 **** --- 1289,1299 ---- ee('assert sys.stdout.readable()==False') ee('assert sys.stderr.writable()==True') ee('assert sys.stderr.readable()==False') + ee('assert sys.stdout.closed()==False') + ee('assert sys.stderr.closed()==False') + ee('assert sys.stdout.errors=="strict"') + ee('assert sys.stderr.errors=="strict"') + ee('assert sys.stdout.encoding==sys.stderr.encoding') ee('sys.stdout.write(None)') cb.append(">> OutputWriteLines") ee('sys.stdout.writelines(None)') *** ../vim-7.4.1768/src/testdir/test86.ok 2016-04-14 15:55:58.405348448 +0200 --- src/testdir/test86.ok 2016-04-21 19:55:10.078471581 +0200 *************** *** 449,455 **** dictionary:__dir__,__members__,get,has_key,items,keys,locked,pop,popitem,scope,update,values list:__dir__,__members__,extend,locked function:__dir__,__members__,args,self,softspace ! output:__dir__,__members__,close,flush,isatty,readable,seekable,softspace,writable,write,writelines {} {'a': 1} {'a': 1} --- 449,455 ---- dictionary:__dir__,__members__,get,has_key,items,keys,locked,pop,popitem,scope,update,values list:__dir__,__members__,extend,locked function:__dir__,__members__,args,self,softspace ! output:__dir__,__members__,close,closed,flush,isatty,readable,seekable,softspace,writable,write,writelines {} {'a': 1} {'a': 1} *************** *** 600,605 **** --- 600,610 ---- assert sys.stdout.readable()==False:NOT FAILED assert sys.stderr.writable()==True:NOT FAILED assert sys.stderr.readable()==False:NOT FAILED + assert sys.stdout.closed()==False:NOT FAILED + assert sys.stderr.closed()==False:NOT FAILED + assert sys.stdout.errors=="strict":NOT FAILED + assert sys.stderr.errors=="strict":NOT FAILED + assert sys.stdout.encoding==sys.stderr.encoding: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.1768/src/testdir/test87.in 2016-04-14 15:55:58.405348448 +0200 --- src/testdir/test87.in 2016-04-21 19:52:10.372357218 +0200 *************** *** 1283,1288 **** --- 1283,1293 ---- ee('assert sys.stdout.readable()==False') ee('assert sys.stderr.writable()==True') ee('assert sys.stderr.readable()==False') + ee('assert sys.stdout.closed()==False') + ee('assert sys.stderr.closed()==False') + ee('assert sys.stdout.errors=="strict"') + ee('assert sys.stderr.errors=="strict"') + ee('assert sys.stdout.encoding==sys.stderr.encoding') ee('sys.stdout.write(None)') cb.append(">> OutputWriteLines") ee('sys.stdout.writelines(None)') *** ../vim-7.4.1768/src/testdir/test87.ok 2016-04-14 15:55:58.405348448 +0200 --- src/testdir/test87.ok 2016-04-21 19:55:56.853981006 +0200 *************** *** 449,455 **** dictionary:__dir__,get,has_key,items,keys,locked,pop,popitem,scope,update,values list:__dir__,extend,locked function:__dir__,args,self,softspace ! output:__dir__,close,flush,isatty,readable,seekable,softspace,writable,write,writelines {} {'a': 1} {'a': 1} --- 449,455 ---- dictionary:__dir__,get,has_key,items,keys,locked,pop,popitem,scope,update,values list:__dir__,extend,locked function:__dir__,args,self,softspace ! output:__dir__,close,closed,flush,isatty,readable,seekable,softspace,writable,write,writelines {} {'a': 1} {'a': 1} *************** *** 600,605 **** --- 600,610 ---- assert sys.stdout.readable()==False:NOT FAILED assert sys.stderr.writable()==True:NOT FAILED assert sys.stderr.readable()==False:NOT FAILED + assert sys.stdout.closed()==False:NOT FAILED + assert sys.stderr.closed()==False:NOT FAILED + assert sys.stdout.errors=="strict":NOT FAILED + assert sys.stderr.errors=="strict":NOT FAILED + assert sys.stdout.encoding==sys.stderr.encoding:NOT FAILED sys.stdout.write(None):(, TypeError("Can't convert 'NoneType' object to str implicitly",)) >> OutputWriteLines sys.stdout.writelines(None):(, TypeError("'NoneType' object is not iterable",)) *** ../vim-7.4.1768/src/version.c 2016-04-21 19:38:00.409290982 +0200 --- src/version.c 2016-04-21 20:00:03.927414557 +0200 *************** *** 750,751 **** --- 750,753 ---- { /* Add new patch number below this line */ + /**/ + 1769, /**/ -- There are 2 kinds of people in my world: those who know Unix, Perl, Vim, GNU, Linux, etc, and those who know COBOL. It gets very difficult for me at parties, not knowing which group to socialise with :-) Sitaram Chamarty /// Bram Moolenaar -- Bram@Moolenaar.net -- 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 ///