diff src/if_py_both.h @ 2727:62e8d93241cd v7.3.142

updated for version 7.3.142 Problem: Python stdout doesn't have a flush() method, causing an import to fail. Solution: Add a dummy flush() method. (Tobias Columbus)
author Bram Moolenaar <bram@vim.org>
date Tue, 22 Mar 2011 15:47:44 +0100
parents c6fe65c000d2
children fe9c7da98b5e
line wrap: on
line diff
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -33,6 +33,7 @@ Python_Release_Vim(void)
 
 static PyObject *OutputWrite(PyObject *, PyObject *);
 static PyObject *OutputWritelines(PyObject *, PyObject *);
+static PyObject *OutputFlush(PyObject *, PyObject *);
 
 /* Function to write a line, points to either msg() or emsg(). */
 typedef void (*writefn)(char_u *);
@@ -47,9 +48,10 @@ typedef struct
 
 static struct PyMethodDef OutputMethods[] = {
     /* name,	    function,		calling,    documentation */
-    {"write",	    OutputWrite,	1,	    "" },
-    {"writelines",  OutputWritelines,	1,	    "" },
-    { NULL,	    NULL,		0,	    NULL }
+    {"write",	    OutputWrite,	1,	    ""},
+    {"writelines",  OutputWritelines,	1,	    ""},
+    {"flush",       OutputFlush,        1,          ""},
+    { NULL,	    NULL,		0,	    NULL}
 };
 
 #define PyErr_SetVim(str) PyErr_SetString(VimError, str)
@@ -123,6 +125,15 @@ OutputWritelines(PyObject *self, PyObjec
     return Py_None;
 }
 
+    static PyObject *
+OutputFlush(PyObject *self UNUSED, PyObject *args UNUSED)
+{
+    /* do nothing */
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+
+
 /* Buffer IO, we write one whole line at a time. */
 static garray_T io_ga = {0, 0, 1, 80, NULL};
 static writefn old_fn = NULL;