Mercurial > vim
diff src/if_py_both.h @ 7191:692dac7183de v7.4.905
commit https://github.com/vim/vim/commit/d424747d5821c2873e24d25d3407d08b25ea3443
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Nov 2 13:28:59 2015 +0100
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)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 02 Nov 2015 13:30:04 +0100 |
parents | 4b1e3b3aa78a |
children | de43f10a3850 |
line wrap: on
line diff
--- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -465,20 +465,41 @@ OutputWritelines(OutputObject *self, PyO } static PyObject * -OutputFlush(PyObject *self UNUSED) +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)OutputFlush, METH_NOARGS, ""}, + {"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} };