[vim] 86/139: patch 7.4.1769 Problem: No "closed", "errors" and "encoding" attribute on Python output. Solution: Add attributes and more tests. (Roland Puntaier, closes #622)

James McCoy jamessan at debian.org
Fri May 6 04:00:08 UTC 2016


This is an automated email from the git hooks/post-receive script.

jamessan pushed a commit to branch debian/sid
in repository vim.

commit 6d4431e7b675ba7a0194c0b8eb84b7d92e4e7953
Author: Bram Moolenaar <Bram at vim.org>
Date:   Thu Apr 21 20:00:56 2016 +0200

    patch 7.4.1769
    Problem:    No "closed", "errors" and "encoding" attribute on Python output.
    Solution:   Add attributes and more tests. (Roland Puntaier, closes #622)
---
 src/if_py_both.h      | 1 +
 src/if_python.c       | 5 ++++-
 src/if_python3.c      | 4 ++++
 src/testdir/test86.in | 5 +++++
 src/testdir/test86.ok | 7 ++++++-
 src/testdir/test87.in | 5 +++++
 src/testdir/test87.ok | 7 ++++++-
 src/version.c         | 2 ++
 8 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/src/if_py_both.h b/src/if_py_both.h
index de3e868..a0385f9 100644
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -503,6 +503,7 @@ static struct PyMethodDef OutputMethods[] = {
     {"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}
 };
diff --git a/src/if_python.c b/src/if_python.c
index a54a0e2..622634d 100644
--- a/src/if_python.c
+++ b/src/if_python.c
@@ -1195,7 +1195,10 @@ OutputGetattr(PyObject *self, char *name)
 	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);
 }
 
diff --git a/src/if_python3.c b/src/if_python3.c
index d2f6066..10984cd 100644
--- a/src/if_python3.c
+++ b/src/if_python3.c
@@ -1100,6 +1100,10 @@ OutputGetattro(PyObject *self, PyObject *nameobj)
 
     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);
 }
diff --git a/src/testdir/test86.in b/src/testdir/test86.in
index 6f47ff6..71fe920 100644
--- a/src/testdir/test86.in
+++ b/src/testdir/test86.in
@@ -1289,6 +1289,11 @@ 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('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)')
diff --git a/src/testdir/test86.ok b/src/testdir/test86.ok
index fe27c05..8529040 100644
--- a/src/testdir/test86.ok
+++ b/src/testdir/test86.ok
@@ -449,7 +449,7 @@ range:__dir__,__members__,append,end,start
 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
+output:__dir__,__members__,close,closed,flush,isatty,readable,seekable,softspace,writable,write,writelines
 {}
 {'a': 1}
 {'a': 1}
@@ -600,6 +600,11 @@ 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
+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",)
diff --git a/src/testdir/test87.in b/src/testdir/test87.in
index e3bc994..0df002f 100644
--- a/src/testdir/test87.in
+++ b/src/testdir/test87.in
@@ -1283,6 +1283,11 @@ 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('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)')
diff --git a/src/testdir/test87.ok b/src/testdir/test87.ok
index 25c0b51..10069b9 100644
--- a/src/testdir/test87.ok
+++ b/src/testdir/test87.ok
@@ -449,7 +449,7 @@ range:__dir__,append,end,start
 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
+output:__dir__,close,closed,flush,isatty,readable,seekable,softspace,writable,write,writelines
 {}
 {'a': 1}
 {'a': 1}
@@ -600,6 +600,11 @@ 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
+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):(<class 'TypeError'>, TypeError("Can't convert 'NoneType' object to str implicitly",))
 >> OutputWriteLines
 sys.stdout.writelines(None):(<class 'TypeError'>, TypeError("'NoneType' object is not iterable",))
diff --git a/src/version.c b/src/version.c
index 9c03872..4599f88 100644
--- a/src/version.c
+++ b/src/version.c
@@ -749,6 +749,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1769,
+/**/
     1768,
 /**/
     1767,

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-vim/vim.git



More information about the pkg-vim-maintainers mailing list