updated for version 7.3.1003
Problem: Python interface does not compile with Python 2.2
Solution: Fix thread issues and True/False. (ZyX)
diff --git a/src/if_py_both.h b/src/if_py_both.h
index 384aea9..b658ce3 100644
--- a/src/if_py_both.h
+++ b/src/if_py_both.h
@@ -31,7 +31,11 @@
#define INVALID_TABPAGE_VALUE ((tabpage_T *)(-1))
typedef void (*rangeinitializer)(void *);
-typedef void (*runner)(const char *, void *, PyGILState_STATE *);
+typedef void (*runner)(const char *, void *
+#ifdef PY_CAN_RECURSE
+ , PyGILState_STATE *
+#endif
+ );
static int ConvertFromPyObject(PyObject *, typval_T *);
static int _ConvertFromPyObject(PyObject *, typval_T *, PyObject *);
@@ -3489,7 +3493,11 @@
}
static void
-run_cmd(const char *cmd, void *arg UNUSED, PyGILState_STATE *pygilstate UNUSED)
+run_cmd(const char *cmd, void *arg UNUSED
+#ifdef PY_CAN_RECURSE
+ , PyGILState_STATE *pygilstate UNUSED
+#endif
+ )
{
PyRun_SimpleString((char *) cmd);
}
@@ -3498,7 +3506,11 @@
static int code_hdr_len = 30;
static void
-run_do(const char *cmd, void *arg UNUSED, PyGILState_STATE *pygilstate)
+run_do(const char *cmd, void *arg UNUSED
+#ifdef PY_CAN_RECURSE
+ , PyGILState_STATE *pygilstate
+#endif
+ )
{
PyInt lnum;
size_t len;
@@ -3528,13 +3540,17 @@
status = 0;
pymain = PyImport_AddModule("__main__");
pyfunc = PyObject_GetAttrString(pymain, DOPY_FUNC);
+#ifdef PY_CAN_RECURSE
PyGILState_Release(*pygilstate);
+#endif
for (lnum = RangeStart; lnum <= RangeEnd; ++lnum)
{
PyObject *line, *linenr, *ret;
+#ifdef PY_CAN_RECURSE
*pygilstate = PyGILState_Ensure();
+#endif
if (!(line = GetBufferLine(curbuf, lnum)))
goto err;
if (!(linenr = PyInt_FromLong((long) lnum)))
@@ -3554,17 +3570,23 @@
Py_XDECREF(ret);
PythonIO_Flush();
+#ifdef PY_CAN_RECURSE
PyGILState_Release(*pygilstate);
+#endif
}
goto out;
err:
+#ifdef PY_CAN_RECURSE
*pygilstate = PyGILState_Ensure();
+#endif
PyErr_PrintEx(0);
PythonIO_Flush();
status = 1;
out:
+#ifdef PY_CAN_RECURSE
if (!status)
*pygilstate = PyGILState_Ensure();
+#endif
Py_DECREF(pyfunc);
PyObject_SetAttrString(pymain, DOPY_FUNC, NULL);
if (status)
@@ -3574,7 +3596,11 @@
}
static void
-run_eval(const char *cmd, typval_T *rettv, PyGILState_STATE *pygilstate UNUSED)
+run_eval(const char *cmd, typval_T *rettv
+#ifdef PY_CAN_RECURSE
+ , PyGILState_STATE *pygilstate UNUSED
+#endif
+ )
{
PyObject *r;