mirror of
https://github.com/vim/vim.git
synced 2025-09-26 04:04:07 -04:00
updated for version 7.3.1003
Problem: Python interface does not compile with Python 2.2 Solution: Fix thread issues and True/False. (ZyX)
This commit is contained in:
@@ -31,7 +31,11 @@ typedef int Py_ssize_t; /* Python 2.4 and earlier don't have this type. */
|
|||||||
#define INVALID_TABPAGE_VALUE ((tabpage_T *)(-1))
|
#define INVALID_TABPAGE_VALUE ((tabpage_T *)(-1))
|
||||||
|
|
||||||
typedef void (*rangeinitializer)(void *);
|
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 *);
|
||||||
static int _ConvertFromPyObject(PyObject *, typval_T *, PyObject *);
|
static int _ConvertFromPyObject(PyObject *, typval_T *, PyObject *);
|
||||||
@@ -3489,7 +3493,11 @@ init_range_eval(typval_T *rettv UNUSED)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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);
|
PyRun_SimpleString((char *) cmd);
|
||||||
}
|
}
|
||||||
@@ -3498,7 +3506,11 @@ static const char *code_hdr = "def " DOPY_FUNC "(line, linenr):\n ";
|
|||||||
static int code_hdr_len = 30;
|
static int code_hdr_len = 30;
|
||||||
|
|
||||||
static void
|
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;
|
PyInt lnum;
|
||||||
size_t len;
|
size_t len;
|
||||||
@@ -3528,13 +3540,17 @@ run_do(const char *cmd, void *arg UNUSED, PyGILState_STATE *pygilstate)
|
|||||||
status = 0;
|
status = 0;
|
||||||
pymain = PyImport_AddModule("__main__");
|
pymain = PyImport_AddModule("__main__");
|
||||||
pyfunc = PyObject_GetAttrString(pymain, DOPY_FUNC);
|
pyfunc = PyObject_GetAttrString(pymain, DOPY_FUNC);
|
||||||
|
#ifdef PY_CAN_RECURSE
|
||||||
PyGILState_Release(*pygilstate);
|
PyGILState_Release(*pygilstate);
|
||||||
|
#endif
|
||||||
|
|
||||||
for (lnum = RangeStart; lnum <= RangeEnd; ++lnum)
|
for (lnum = RangeStart; lnum <= RangeEnd; ++lnum)
|
||||||
{
|
{
|
||||||
PyObject *line, *linenr, *ret;
|
PyObject *line, *linenr, *ret;
|
||||||
|
|
||||||
|
#ifdef PY_CAN_RECURSE
|
||||||
*pygilstate = PyGILState_Ensure();
|
*pygilstate = PyGILState_Ensure();
|
||||||
|
#endif
|
||||||
if (!(line = GetBufferLine(curbuf, lnum)))
|
if (!(line = GetBufferLine(curbuf, lnum)))
|
||||||
goto err;
|
goto err;
|
||||||
if (!(linenr = PyInt_FromLong((long) lnum)))
|
if (!(linenr = PyInt_FromLong((long) lnum)))
|
||||||
@@ -3554,17 +3570,23 @@ run_do(const char *cmd, void *arg UNUSED, PyGILState_STATE *pygilstate)
|
|||||||
|
|
||||||
Py_XDECREF(ret);
|
Py_XDECREF(ret);
|
||||||
PythonIO_Flush();
|
PythonIO_Flush();
|
||||||
|
#ifdef PY_CAN_RECURSE
|
||||||
PyGILState_Release(*pygilstate);
|
PyGILState_Release(*pygilstate);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
goto out;
|
goto out;
|
||||||
err:
|
err:
|
||||||
|
#ifdef PY_CAN_RECURSE
|
||||||
*pygilstate = PyGILState_Ensure();
|
*pygilstate = PyGILState_Ensure();
|
||||||
|
#endif
|
||||||
PyErr_PrintEx(0);
|
PyErr_PrintEx(0);
|
||||||
PythonIO_Flush();
|
PythonIO_Flush();
|
||||||
status = 1;
|
status = 1;
|
||||||
out:
|
out:
|
||||||
|
#ifdef PY_CAN_RECURSE
|
||||||
if (!status)
|
if (!status)
|
||||||
*pygilstate = PyGILState_Ensure();
|
*pygilstate = PyGILState_Ensure();
|
||||||
|
#endif
|
||||||
Py_DECREF(pyfunc);
|
Py_DECREF(pyfunc);
|
||||||
PyObject_SetAttrString(pymain, DOPY_FUNC, NULL);
|
PyObject_SetAttrString(pymain, DOPY_FUNC, NULL);
|
||||||
if (status)
|
if (status)
|
||||||
@@ -3574,7 +3596,11 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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;
|
PyObject *r;
|
||||||
|
|
||||||
|
@@ -641,7 +641,7 @@ static int initialised = 0;
|
|||||||
#define DICTKEY_UNREF
|
#define DICTKEY_UNREF
|
||||||
#define DICTKEY_DECL
|
#define DICTKEY_DECL
|
||||||
|
|
||||||
#define DESTRUCTOR_FINISH(self) Py_TYPE(self)->tp_free((PyObject*)self);
|
#define DESTRUCTOR_FINISH(self) self->ob_type->tp_free((PyObject*)self);
|
||||||
|
|
||||||
#define WIN_PYTHON_REF(win) win->w_python_ref
|
#define WIN_PYTHON_REF(win) win->w_python_ref
|
||||||
#define BUF_PYTHON_REF(buf) buf->b_python_ref
|
#define BUF_PYTHON_REF(buf) buf->b_python_ref
|
||||||
@@ -656,6 +656,15 @@ static PyObject *DictionaryGetattr(PyObject *, char*);
|
|||||||
static PyObject *ListGetattr(PyObject *, char *);
|
static PyObject *ListGetattr(PyObject *, char *);
|
||||||
static PyObject *FunctionGetattr(PyObject *, char *);
|
static PyObject *FunctionGetattr(PyObject *, char *);
|
||||||
|
|
||||||
|
#ifndef Py_VISIT
|
||||||
|
# define Py_VISIT(obj) visit(obj, arg)
|
||||||
|
#endif
|
||||||
|
#ifndef Py_CLEAR
|
||||||
|
# define Py_CLEAR(obj) \
|
||||||
|
Py_XDECREF(obj); \
|
||||||
|
obj = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Include the code shared with if_python3.c
|
* Include the code shared with if_python3.c
|
||||||
*/
|
*/
|
||||||
@@ -881,7 +890,11 @@ DoPyCommand(const char *cmd, rangeinitializer init_range, runner run, void *arg)
|
|||||||
Python_RestoreThread(); /* enter python */
|
Python_RestoreThread(); /* enter python */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
run((char *) cmd, arg, &pygilstate);
|
run((char *) cmd, arg
|
||||||
|
#ifdef PY_CAN_RECURSE
|
||||||
|
, &pygilstate
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
#ifdef PY_CAN_RECURSE
|
#ifdef PY_CAN_RECURSE
|
||||||
PyGILState_Release(pygilstate);
|
PyGILState_Release(pygilstate);
|
||||||
|
@@ -693,6 +693,8 @@ static PyObject *FunctionGetattro(PyObject *, PyObject *);
|
|||||||
|
|
||||||
static struct PyModuleDef vimmodule;
|
static struct PyModuleDef vimmodule;
|
||||||
|
|
||||||
|
#define PY_CAN_RECURSE
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Include the code shared with if_python.c
|
* Include the code shared with if_python.c
|
||||||
*/
|
*/
|
||||||
|
@@ -518,6 +518,10 @@ EOF
|
|||||||
:edit c
|
:edit c
|
||||||
:buffer #
|
:buffer #
|
||||||
py << EOF
|
py << EOF
|
||||||
|
try:
|
||||||
|
from __builtin__ import next
|
||||||
|
except ImportError:
|
||||||
|
next = lambda o: o.next()
|
||||||
# Check GCing iterator that was not fully exhausted
|
# Check GCing iterator that was not fully exhausted
|
||||||
i = iter(vim.buffers)
|
i = iter(vim.buffers)
|
||||||
cb.append('i:' + str(next(i)))
|
cb.append('i:' + str(next(i)))
|
||||||
@@ -577,15 +581,22 @@ py << EOF
|
|||||||
cb.append('Number of tabs: ' + str(len(vim.tabpages)))
|
cb.append('Number of tabs: ' + str(len(vim.tabpages)))
|
||||||
cb.append('Current tab pages:')
|
cb.append('Current tab pages:')
|
||||||
def W(w):
|
def W(w):
|
||||||
if '(unknown)' in repr(w):
|
if repr(w).find('(unknown)') != -1:
|
||||||
return '<window object (unknown)>'
|
return '<window object (unknown)>'
|
||||||
else:
|
else:
|
||||||
return repr(w)
|
return repr(w)
|
||||||
|
|
||||||
|
def Cursor(w, start=len(cb)):
|
||||||
|
if w.buffer is cb:
|
||||||
|
return repr((start - w.cursor[0], w.cursor[1]))
|
||||||
|
else:
|
||||||
|
return repr(w.cursor)
|
||||||
|
|
||||||
for t in vim.tabpages:
|
for t in vim.tabpages:
|
||||||
cb.append(' ' + repr(t) + '(' + str(t.number) + ')' + ': ' + str(len(t.windows)) + ' windows, current is ' + W(t.window))
|
cb.append(' ' + repr(t) + '(' + str(t.number) + ')' + ': ' + str(len(t.windows)) + ' windows, current is ' + W(t.window))
|
||||||
cb.append(' Windows:')
|
cb.append(' Windows:')
|
||||||
for w in t.windows:
|
for w in t.windows:
|
||||||
cb.append(' ' + W(w) + '(' + str(w.number) + ')' + ': displays buffer ' + repr(w.buffer) + '; cursor is at ' + repr(w.cursor))
|
cb.append(' ' + W(w) + '(' + str(w.number) + ')' + ': displays buffer ' + repr(w.buffer) + '; cursor is at ' + Cursor(w))
|
||||||
# Other values depend on the size of the terminal, so they are checked partly:
|
# Other values depend on the size of the terminal, so they are checked partly:
|
||||||
for attr in ('height', 'row', 'width', 'col'):
|
for attr in ('height', 'row', 'width', 'col'):
|
||||||
try:
|
try:
|
||||||
|
@@ -333,7 +333,7 @@ Number of tabs: 4
|
|||||||
Current tab pages:
|
Current tab pages:
|
||||||
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
|
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
|
||||||
Windows:
|
Windows:
|
||||||
<window object (unknown)>(1): displays buffer <buffer test86.in>; cursor is at (990, 0)
|
<window object (unknown)>(1): displays buffer <buffer test86.in>; cursor is at (27, 0)
|
||||||
<tabpage 1>(2): 1 windows, current is <window object (unknown)>
|
<tabpage 1>(2): 1 windows, current is <window object (unknown)>
|
||||||
Windows:
|
Windows:
|
||||||
<window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
|
<window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
|
||||||
|
@@ -561,18 +561,26 @@ EOF
|
|||||||
:vnew b.2
|
:vnew b.2
|
||||||
:vnew c.2
|
:vnew c.2
|
||||||
py3 << EOF
|
py3 << EOF
|
||||||
|
cb.append('Number of tabs: ' + str(len(vim.tabpages)))
|
||||||
|
cb.append('Current tab pages:')
|
||||||
|
|
||||||
def W(w):
|
def W(w):
|
||||||
if '(unknown)' in repr(w):
|
if '(unknown)' in repr(w):
|
||||||
return '<window object (unknown)>'
|
return '<window object (unknown)>'
|
||||||
else:
|
else:
|
||||||
return repr(w)
|
return repr(w)
|
||||||
cb.append('Number of tabs: ' + str(len(vim.tabpages)))
|
|
||||||
cb.append('Current tab pages:')
|
def Cursor(w, start=len(cb)):
|
||||||
|
if w.buffer is cb:
|
||||||
|
return repr((start - w.cursor[0], w.cursor[1]))
|
||||||
|
else:
|
||||||
|
return repr(w.cursor)
|
||||||
|
|
||||||
for t in vim.tabpages:
|
for t in vim.tabpages:
|
||||||
cb.append(' ' + repr(t) + '(' + str(t.number) + ')' + ': ' + str(len(t.windows)) + ' windows, current is ' + W(t.window))
|
cb.append(' ' + repr(t) + '(' + str(t.number) + ')' + ': ' + str(len(t.windows)) + ' windows, current is ' + W(t.window))
|
||||||
cb.append(' Windows:')
|
cb.append(' Windows:')
|
||||||
for w in t.windows:
|
for w in t.windows:
|
||||||
cb.append(' ' + W(w) + '(' + str(w.number) + ')' + ': displays buffer ' + repr(w.buffer) + '; cursor is at ' + repr(w.cursor))
|
cb.append(' ' + W(w) + '(' + str(w.number) + ')' + ': displays buffer ' + repr(w.buffer) + '; cursor is at ' + Cursor(w))
|
||||||
# Other values depend on the size of the terminal, so they are checked partly:
|
# Other values depend on the size of the terminal, so they are checked partly:
|
||||||
for attr in ('height', 'row', 'width', 'col'):
|
for attr in ('height', 'row', 'width', 'col'):
|
||||||
try:
|
try:
|
||||||
|
@@ -322,7 +322,7 @@ Number of tabs: 4
|
|||||||
Current tab pages:
|
Current tab pages:
|
||||||
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
|
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
|
||||||
Windows:
|
Windows:
|
||||||
<window object (unknown)>(1): displays buffer <buffer test87.in>; cursor is at (966, 0)
|
<window object (unknown)>(1): displays buffer <buffer test87.in>; cursor is at (27, 0)
|
||||||
<tabpage 1>(2): 1 windows, current is <window object (unknown)>
|
<tabpage 1>(2): 1 windows, current is <window object (unknown)>
|
||||||
Windows:
|
Windows:
|
||||||
<window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
|
<window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
|
||||||
|
@@ -728,6 +728,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1003,
|
||||||
/**/
|
/**/
|
||||||
1002,
|
1002,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user