Tests are failing with python-2.2 for the reason explained previously: no
working threads and 0/1 in place of True/False.
# HG changeset patch
# User ZyX <[email protected]>
# Date 1368992601 -14400
# Branch python-extended-2
# Node ID a7dc5bbc1f98a715d046ec1163b13fca17a195f0
# Parent ae6c6a2f0d15539131afa603c873c35d8b673247
Some fixes for python-2.2
diff -r ae6c6a2f0d15 -r a7dc5bbc1f98 src/if_py_both.h
--- a/src/if_py_both.h Sun May 19 22:51:40 2013 +0400
+++ b/src/if_py_both.h Sun May 19 23:43:21 2013 +0400
@@ -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 *);
@@ -3490,7 +3494,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);
}
@@ -3499,7 +3507,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;
@@ -3529,13 +3541,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)))
@@ -3555,17 +3571,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)
@@ -3575,7 +3597,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;
diff -r ae6c6a2f0d15 -r a7dc5bbc1f98 src/if_python.c
--- a/src/if_python.c Sun May 19 22:51:40 2013 +0400
+++ b/src/if_python.c Sun May 19 23:43:21 2013 +0400
@@ -641,7 +641,7 @@
#define DICTKEY_UNREF
#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 BUF_PYTHON_REF(buf) buf->b_python_ref
@@ -656,6 +656,15 @@
static PyObject *ListGetattr(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
*/
@@ -881,7 +890,11 @@
Python_RestoreThread(); /* enter python */
#endif
- run((char *) cmd, arg, &pygilstate);
+ run((char *) cmd, arg
+#ifdef PY_CAN_RECURSE
+ , &pygilstate
+#endif
+ );
#ifdef PY_CAN_RECURSE
PyGILState_Release(pygilstate);
diff -r ae6c6a2f0d15 -r a7dc5bbc1f98 src/if_python3.c
--- a/src/if_python3.c Sun May 19 22:51:40 2013 +0400
+++ b/src/if_python3.c Sun May 19 23:43:21 2013 +0400
@@ -693,6 +693,8 @@
static struct PyModuleDef vimmodule;
+#define PY_CAN_RECURSE
+
/*
* Include the code shared with if_python.c
*/
diff -r ae6c6a2f0d15 -r a7dc5bbc1f98 src/testdir/test86.in
--- a/src/testdir/test86.in Sun May 19 22:51:40 2013 +0400
+++ b/src/testdir/test86.in Sun May 19 23:43:21 2013 +0400
@@ -518,6 +518,10 @@
:edit c
:buffer #
py << EOF
+try:
+ from __builtin__ import next
+except ImportError:
+ next = lambda o: o.next()
# Check GCing iterator that was not fully exhausted
i = iter(vim.buffers)
cb.append('i:' + str(next(i)))
@@ -577,15 +581,22 @@
cb.append('Number of tabs: ' + str(len(vim.tabpages)))
cb.append('Current tab pages:')
def W(w):
- if '(unknown)' in repr(w):
+ if repr(w).find('(unknown)') != -1:
return '<window object (unknown)>'
else:
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:
cb.append(' ' + repr(t) + '(' + str(t.number) + ')' + ': ' +
str(len(t.windows)) + ' windows, current is ' + W(t.window))
cb.append(' 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:
for attr in ('height', 'row', 'width', 'col'):
try:
diff -r ae6c6a2f0d15 -r a7dc5bbc1f98 src/testdir/test86.ok
--- a/src/testdir/test86.ok Sun May 19 22:51:40 2013 +0400
+++ b/src/testdir/test86.ok Sun May 19 23:43:21 2013 +0400
@@ -333,7 +333,7 @@
Current tab pages:
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
Windows:
- <window object (unknown)>(1): displays buffer <buffer test86.in>; cursor
is at (971, 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)>
Windows:
<window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1,
0)
diff -r ae6c6a2f0d15 -r a7dc5bbc1f98 src/testdir/test87.in
--- a/src/testdir/test87.in Sun May 19 22:51:40 2013 +0400
+++ b/src/testdir/test87.in Sun May 19 23:43:21 2013 +0400
@@ -561,18 +561,26 @@
:vnew b.2
:vnew c.2
py3 << EOF
+cb.append('Number of tabs: ' + str(len(vim.tabpages)))
+cb.append('Current tab pages:')
+
def W(w):
if '(unknown)' in repr(w):
return '<window object (unknown)>'
else:
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:
cb.append(' ' + repr(t) + '(' + str(t.number) + ')' + ': ' +
str(len(t.windows)) + ' windows, current is ' + W(t.window))
cb.append(' 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:
for attr in ('height', 'row', 'width', 'col'):
try:
diff -r ae6c6a2f0d15 -r a7dc5bbc1f98 src/testdir/test87.ok
--- a/src/testdir/test87.ok Sun May 19 22:51:40 2013 +0400
+++ b/src/testdir/test87.ok Sun May 19 23:43:21 2013 +0400
@@ -322,7 +322,7 @@
Current tab pages:
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
Windows:
- <window object (unknown)>(1): displays buffer <buffer test87.in>; cursor
is at (947, 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)>
Windows:
<window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1,
0)
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.
diff -cr vim.ae6c6a2f0d15/src/if_py_both.h vim.a7dc5bbc1f98/src/if_py_both.h
*** vim.ae6c6a2f0d15/src/if_py_both.h 2013-05-20 00:42:17.041144090 +0400
--- vim.a7dc5bbc1f98/src/if_py_both.h 2013-05-20 00:42:17.054143961 +0400
***************
*** 31,37 ****
#define INVALID_TABPAGE_VALUE ((tabpage_T *)(-1))
typedef void (*rangeinitializer)(void *);
! typedef void (*runner)(const char *, void *, PyGILState_STATE *);
static int ConvertFromPyObject(PyObject *, typval_T *);
static int _ConvertFromPyObject(PyObject *, typval_T *, PyObject *);
--- 31,41 ----
#define INVALID_TABPAGE_VALUE ((tabpage_T *)(-1))
typedef void (*rangeinitializer)(void *);
! 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 *);
***************
*** 3490,3496 ****
}
static void
! run_cmd(const char *cmd, void *arg UNUSED, PyGILState_STATE *pygilstate UNUSED)
{
PyRun_SimpleString((char *) cmd);
}
--- 3494,3504 ----
}
static void
! run_cmd(const char *cmd, void *arg UNUSED
! #ifdef PY_CAN_RECURSE
! , PyGILState_STATE *pygilstate UNUSED
! #endif
! )
{
PyRun_SimpleString((char *) cmd);
}
***************
*** 3499,3505 ****
static int code_hdr_len = 30;
static void
! run_do(const char *cmd, void *arg UNUSED, PyGILState_STATE *pygilstate)
{
PyInt lnum;
size_t len;
--- 3507,3517 ----
static int code_hdr_len = 30;
static void
! run_do(const char *cmd, void *arg UNUSED
! #ifdef PY_CAN_RECURSE
! , PyGILState_STATE *pygilstate
! #endif
! )
{
PyInt lnum;
size_t len;
***************
*** 3529,3541 ****
--- 3541,3557 ----
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)))
***************
*** 3555,3571 ****
--- 3571,3593 ----
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)
***************
*** 3575,3581 ****
}
static void
! run_eval(const char *cmd, typval_T *rettv, PyGILState_STATE *pygilstate UNUSED)
{
PyObject *r;
--- 3597,3607 ----
}
static void
! run_eval(const char *cmd, typval_T *rettv
! #ifdef PY_CAN_RECURSE
! , PyGILState_STATE *pygilstate UNUSED
! #endif
! )
{
PyObject *r;
diff -cr vim.ae6c6a2f0d15/src/if_python3.c vim.a7dc5bbc1f98/src/if_python3.c
*** vim.ae6c6a2f0d15/src/if_python3.c 2013-05-20 00:42:17.044144061 +0400
--- vim.a7dc5bbc1f98/src/if_python3.c 2013-05-20 00:42:17.057143932 +0400
***************
*** 693,698 ****
--- 693,700 ----
static struct PyModuleDef vimmodule;
+ #define PY_CAN_RECURSE
+
/*
* Include the code shared with if_python.c
*/
diff -cr vim.ae6c6a2f0d15/src/if_python.c vim.a7dc5bbc1f98/src/if_python.c
*** vim.ae6c6a2f0d15/src/if_python.c 2013-05-20 00:42:17.047144031 +0400
--- vim.a7dc5bbc1f98/src/if_python.c 2013-05-20 00:42:17.060143902 +0400
***************
*** 641,647 ****
#define DICTKEY_UNREF
#define DICTKEY_DECL
! #define DESTRUCTOR_FINISH(self) Py_TYPE(self)->tp_free((PyObject*)self);
#define WIN_PYTHON_REF(win) win->w_python_ref
#define BUF_PYTHON_REF(buf) buf->b_python_ref
--- 641,647 ----
#define DICTKEY_UNREF
#define DICTKEY_DECL
! #define DESTRUCTOR_FINISH(self) self->ob_type->tp_free((PyObject*)self);
#define WIN_PYTHON_REF(win) win->w_python_ref
#define BUF_PYTHON_REF(buf) buf->b_python_ref
***************
*** 656,661 ****
--- 656,670 ----
static PyObject *ListGetattr(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
*/
***************
*** 881,887 ****
Python_RestoreThread(); /* enter python */
#endif
! run((char *) cmd, arg, &pygilstate);
#ifdef PY_CAN_RECURSE
PyGILState_Release(pygilstate);
--- 890,900 ----
Python_RestoreThread(); /* enter python */
#endif
! run((char *) cmd, arg
! #ifdef PY_CAN_RECURSE
! , &pygilstate
! #endif
! );
#ifdef PY_CAN_RECURSE
PyGILState_Release(pygilstate);
diff -cr vim.ae6c6a2f0d15/src/testdir/test86.in vim.a7dc5bbc1f98/src/testdir/test86.in
*** vim.ae6c6a2f0d15/src/testdir/test86.in 2013-05-20 00:42:17.042144081 +0400
--- vim.a7dc5bbc1f98/src/testdir/test86.in 2013-05-20 00:42:17.054143961 +0400
***************
*** 518,523 ****
--- 518,527 ----
:edit c
:buffer #
py << EOF
+ try:
+ from __builtin__ import next
+ except ImportError:
+ next = lambda o: o.next()
# Check GCing iterator that was not fully exhausted
i = iter(vim.buffers)
cb.append('i:' + str(next(i)))
***************
*** 577,591 ****
cb.append('Number of tabs: ' + str(len(vim.tabpages)))
cb.append('Current tab pages:')
def W(w):
! if '(unknown)' in repr(w):
return '<window object (unknown)>'
else:
return repr(w)
for t in vim.tabpages:
cb.append(' ' + repr(t) + '(' + str(t.number) + ')' + ': ' + str(len(t.windows)) + ' windows, current is ' + W(t.window))
cb.append(' Windows:')
for w in t.windows:
! cb.append(' ' + W(w) + '(' + str(w.number) + ')' + ': displays buffer ' + repr(w.buffer) + '; cursor is at ' + repr(w.cursor))
# Other values depend on the size of the terminal, so they are checked partly:
for attr in ('height', 'row', 'width', 'col'):
try:
--- 581,602 ----
cb.append('Number of tabs: ' + str(len(vim.tabpages)))
cb.append('Current tab pages:')
def W(w):
! if repr(w).find('(unknown)') != -1:
return '<window object (unknown)>'
else:
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:
cb.append(' ' + repr(t) + '(' + str(t.number) + ')' + ': ' + str(len(t.windows)) + ' windows, current is ' + W(t.window))
cb.append(' Windows:')
for w in t.windows:
! 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:
for attr in ('height', 'row', 'width', 'col'):
try:
diff -cr vim.ae6c6a2f0d15/src/testdir/test86.ok vim.a7dc5bbc1f98/src/testdir/test86.ok
*** vim.ae6c6a2f0d15/src/testdir/test86.ok 2013-05-20 00:42:17.042144081 +0400
--- vim.a7dc5bbc1f98/src/testdir/test86.ok 2013-05-20 00:42:17.055143951 +0400
***************
*** 333,339 ****
Current tab pages:
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
Windows:
! <window object (unknown)>(1): displays buffer <buffer test86.in>; cursor is at (971, 0)
<tabpage 1>(2): 1 windows, current is <window object (unknown)>
Windows:
<window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
--- 333,339 ----
Current tab pages:
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
Windows:
! <window object (unknown)>(1): displays buffer <buffer test86.in>; cursor is at (27, 0)
<tabpage 1>(2): 1 windows, current is <window object (unknown)>
Windows:
<window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
diff -cr vim.ae6c6a2f0d15/src/testdir/test87.in vim.a7dc5bbc1f98/src/testdir/test87.in
*** vim.ae6c6a2f0d15/src/testdir/test87.in 2013-05-20 00:42:17.037144131 +0400
--- vim.a7dc5bbc1f98/src/testdir/test87.in 2013-05-20 00:42:17.050144001 +0400
***************
*** 561,578 ****
:vnew b.2
:vnew c.2
py3 << EOF
def W(w):
if '(unknown)' in repr(w):
return '<window object (unknown)>'
else:
return repr(w)
! cb.append('Number of tabs: ' + str(len(vim.tabpages)))
! cb.append('Current tab pages:')
for t in vim.tabpages:
cb.append(' ' + repr(t) + '(' + str(t.number) + ')' + ': ' + str(len(t.windows)) + ' windows, current is ' + W(t.window))
cb.append(' Windows:')
for w in t.windows:
! cb.append(' ' + W(w) + '(' + str(w.number) + ')' + ': displays buffer ' + repr(w.buffer) + '; cursor is at ' + repr(w.cursor))
# Other values depend on the size of the terminal, so they are checked partly:
for attr in ('height', 'row', 'width', 'col'):
try:
--- 561,586 ----
:vnew b.2
:vnew c.2
py3 << EOF
+ cb.append('Number of tabs: ' + str(len(vim.tabpages)))
+ cb.append('Current tab pages:')
+
def W(w):
if '(unknown)' in repr(w):
return '<window object (unknown)>'
else:
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:
cb.append(' ' + repr(t) + '(' + str(t.number) + ')' + ': ' + str(len(t.windows)) + ' windows, current is ' + W(t.window))
cb.append(' Windows:')
for w in t.windows:
! 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:
for attr in ('height', 'row', 'width', 'col'):
try:
diff -cr vim.ae6c6a2f0d15/src/testdir/test87.ok vim.a7dc5bbc1f98/src/testdir/test87.ok
*** vim.ae6c6a2f0d15/src/testdir/test87.ok 2013-05-20 00:42:17.037144131 +0400
--- vim.a7dc5bbc1f98/src/testdir/test87.ok 2013-05-20 00:42:17.050144001 +0400
***************
*** 322,328 ****
Current tab pages:
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
Windows:
! <window object (unknown)>(1): displays buffer <buffer test87.in>; cursor is at (947, 0)
<tabpage 1>(2): 1 windows, current is <window object (unknown)>
Windows:
<window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)
--- 322,328 ----
Current tab pages:
<tabpage 0>(1): 1 windows, current is <window object (unknown)>
Windows:
! <window object (unknown)>(1): displays buffer <buffer test87.in>; cursor is at (27, 0)
<tabpage 1>(2): 1 windows, current is <window object (unknown)>
Windows:
<window object (unknown)>(1): displays buffer <buffer 0>; cursor is at (1, 0)