|
Karsten Hopp |
790b10 |
To: vim_dev@googlegroups.com
|
|
Karsten Hopp |
790b10 |
Subject: Patch 7.3.1226
|
|
Karsten Hopp |
790b10 |
Fcc: outbox
|
|
Karsten Hopp |
790b10 |
From: Bram Moolenaar <Bram@moolenaar.net>
|
|
Karsten Hopp |
790b10 |
Mime-Version: 1.0
|
|
Karsten Hopp |
790b10 |
Content-Type: text/plain; charset=UTF-8
|
|
Karsten Hopp |
790b10 |
Content-Transfer-Encoding: 8bit
|
|
Karsten Hopp |
790b10 |
------------
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
Patch 7.3.1226
|
|
Karsten Hopp |
790b10 |
Problem: Python: duplicate code.
|
|
Karsten Hopp |
790b10 |
Solution: Share code between OutputWrite() and OutputWritelines(). (ZyX)
|
|
Karsten Hopp |
790b10 |
Files: src/if_py_both.h, src/testdir/test86.ok, src/testdir/test87.ok
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
*** ../vim-7.3.1225/src/if_py_both.h 2013-06-16 14:25:53.000000000 +0200
|
|
Karsten Hopp |
790b10 |
--- src/if_py_both.h 2013-06-23 12:46:03.000000000 +0200
|
|
Karsten Hopp |
790b10 |
***************
|
|
Karsten Hopp |
790b10 |
*** 281,295 ****
|
|
Karsten Hopp |
790b10 |
}
|
|
Karsten Hopp |
790b10 |
}
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
! static PyObject *
|
|
Karsten Hopp |
790b10 |
! OutputWrite(OutputObject *self, PyObject *args)
|
|
Karsten Hopp |
790b10 |
{
|
|
Karsten Hopp |
790b10 |
! Py_ssize_t len = 0;
|
|
Karsten Hopp |
790b10 |
! char *str = NULL;
|
|
Karsten Hopp |
790b10 |
! int error = self->error;
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
! if (!PyArg_ParseTuple(args, "et#", ENC_OPT, &str, &len))
|
|
Karsten Hopp |
790b10 |
! return NULL;
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
Py_BEGIN_ALLOW_THREADS
|
|
Karsten Hopp |
790b10 |
Python_Lock_Vim();
|
|
Karsten Hopp |
790b10 |
--- 281,295 ----
|
|
Karsten Hopp |
790b10 |
}
|
|
Karsten Hopp |
790b10 |
}
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
! static int
|
|
Karsten Hopp |
790b10 |
! write_output(OutputObject *self, PyObject *string)
|
|
Karsten Hopp |
790b10 |
{
|
|
Karsten Hopp |
790b10 |
! Py_ssize_t len = 0;
|
|
Karsten Hopp |
790b10 |
! char *str = NULL;
|
|
Karsten Hopp |
790b10 |
! int error = self->error;
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
! if (!PyArg_Parse(string, "et#", ENC_OPT, &str, &len))
|
|
Karsten Hopp |
790b10 |
! return -1;
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
Py_BEGIN_ALLOW_THREADS
|
|
Karsten Hopp |
790b10 |
Python_Lock_Vim();
|
|
Karsten Hopp |
790b10 |
***************
|
|
Karsten Hopp |
790b10 |
*** 298,341 ****
|
|
Karsten Hopp |
790b10 |
Py_END_ALLOW_THREADS
|
|
Karsten Hopp |
790b10 |
PyMem_Free(str);
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
Py_INCREF(Py_None);
|
|
Karsten Hopp |
790b10 |
return Py_None;
|
|
Karsten Hopp |
790b10 |
}
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
static PyObject *
|
|
Karsten Hopp |
790b10 |
! OutputWritelines(OutputObject *self, PyObject *args)
|
|
Karsten Hopp |
790b10 |
{
|
|
Karsten Hopp |
790b10 |
- PyObject *seq;
|
|
Karsten Hopp |
790b10 |
PyObject *iterator;
|
|
Karsten Hopp |
790b10 |
PyObject *item;
|
|
Karsten Hopp |
790b10 |
- int error = self->error;
|
|
Karsten Hopp |
790b10 |
-
|
|
Karsten Hopp |
790b10 |
- if (!PyArg_ParseTuple(args, "O", &seq))
|
|
Karsten Hopp |
790b10 |
- return NULL;
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
if (!(iterator = PyObject_GetIter(seq)))
|
|
Karsten Hopp |
790b10 |
return NULL;
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
while ((item = PyIter_Next(iterator)))
|
|
Karsten Hopp |
790b10 |
{
|
|
Karsten Hopp |
790b10 |
! char *str = NULL;
|
|
Karsten Hopp |
790b10 |
! PyInt len;
|
|
Karsten Hopp |
790b10 |
!
|
|
Karsten Hopp |
790b10 |
! if (!PyArg_Parse(item, "et#", ENC_OPT, &str, &len))
|
|
Karsten Hopp |
790b10 |
{
|
|
Karsten Hopp |
790b10 |
- PyErr_SetString(PyExc_TypeError, _("writelines() requires list of strings"));
|
|
Karsten Hopp |
790b10 |
Py_DECREF(iterator);
|
|
Karsten Hopp |
790b10 |
Py_DECREF(item);
|
|
Karsten Hopp |
790b10 |
return NULL;
|
|
Karsten Hopp |
790b10 |
}
|
|
Karsten Hopp |
790b10 |
Py_DECREF(item);
|
|
Karsten Hopp |
790b10 |
-
|
|
Karsten Hopp |
790b10 |
- Py_BEGIN_ALLOW_THREADS
|
|
Karsten Hopp |
790b10 |
- Python_Lock_Vim();
|
|
Karsten Hopp |
790b10 |
- writer((writefn)(error ? emsg : msg), (char_u *)str, len);
|
|
Karsten Hopp |
790b10 |
- Python_Release_Vim();
|
|
Karsten Hopp |
790b10 |
- Py_END_ALLOW_THREADS
|
|
Karsten Hopp |
790b10 |
- PyMem_Free(str);
|
|
Karsten Hopp |
790b10 |
}
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
Py_DECREF(iterator);
|
|
Karsten Hopp |
790b10 |
--- 298,334 ----
|
|
Karsten Hopp |
790b10 |
Py_END_ALLOW_THREADS
|
|
Karsten Hopp |
790b10 |
PyMem_Free(str);
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
+ return 0;
|
|
Karsten Hopp |
790b10 |
+ }
|
|
Karsten Hopp |
790b10 |
+
|
|
Karsten Hopp |
790b10 |
+ static PyObject *
|
|
Karsten Hopp |
790b10 |
+ OutputWrite(OutputObject *self, PyObject *string)
|
|
Karsten Hopp |
790b10 |
+ {
|
|
Karsten Hopp |
790b10 |
+ if (write_output(self, string))
|
|
Karsten Hopp |
790b10 |
+ return NULL;
|
|
Karsten Hopp |
790b10 |
+
|
|
Karsten Hopp |
790b10 |
Py_INCREF(Py_None);
|
|
Karsten Hopp |
790b10 |
return Py_None;
|
|
Karsten Hopp |
790b10 |
}
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
static PyObject *
|
|
Karsten Hopp |
790b10 |
! OutputWritelines(OutputObject *self, PyObject *seq)
|
|
Karsten Hopp |
790b10 |
{
|
|
Karsten Hopp |
790b10 |
PyObject *iterator;
|
|
Karsten Hopp |
790b10 |
PyObject *item;
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
if (!(iterator = PyObject_GetIter(seq)))
|
|
Karsten Hopp |
790b10 |
return NULL;
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
while ((item = PyIter_Next(iterator)))
|
|
Karsten Hopp |
790b10 |
{
|
|
Karsten Hopp |
790b10 |
! if (write_output(self, item))
|
|
Karsten Hopp |
790b10 |
{
|
|
Karsten Hopp |
790b10 |
Py_DECREF(iterator);
|
|
Karsten Hopp |
790b10 |
Py_DECREF(item);
|
|
Karsten Hopp |
790b10 |
return NULL;
|
|
Karsten Hopp |
790b10 |
}
|
|
Karsten Hopp |
790b10 |
Py_DECREF(item);
|
|
Karsten Hopp |
790b10 |
}
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
Py_DECREF(iterator);
|
|
Karsten Hopp |
790b10 |
***************
|
|
Karsten Hopp |
790b10 |
*** 360,367 ****
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
static struct PyMethodDef OutputMethods[] = {
|
|
Karsten Hopp |
790b10 |
/* name, function, calling, doc */
|
|
Karsten Hopp |
790b10 |
! {"write", (PyCFunction)OutputWrite, METH_VARARGS, ""},
|
|
Karsten Hopp |
790b10 |
! {"writelines", (PyCFunction)OutputWritelines, METH_VARARGS, ""},
|
|
Karsten Hopp |
790b10 |
{"flush", (PyCFunction)OutputFlush, METH_NOARGS, ""},
|
|
Karsten Hopp |
790b10 |
{"__dir__", (PyCFunction)OutputDir, METH_NOARGS, ""},
|
|
Karsten Hopp |
790b10 |
{ NULL, NULL, 0, NULL}
|
|
Karsten Hopp |
790b10 |
--- 353,360 ----
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
static struct PyMethodDef OutputMethods[] = {
|
|
Karsten Hopp |
790b10 |
/* name, function, calling, doc */
|
|
Karsten Hopp |
790b10 |
! {"write", (PyCFunction)OutputWrite, METH_O, ""},
|
|
Karsten Hopp |
790b10 |
! {"writelines", (PyCFunction)OutputWritelines, METH_O, ""},
|
|
Karsten Hopp |
790b10 |
{"flush", (PyCFunction)OutputFlush, METH_NOARGS, ""},
|
|
Karsten Hopp |
790b10 |
{"__dir__", (PyCFunction)OutputDir, METH_NOARGS, ""},
|
|
Karsten Hopp |
790b10 |
{ NULL, NULL, 0, NULL}
|
|
Karsten Hopp |
790b10 |
***************
|
|
Karsten Hopp |
790b10 |
*** 3009,3015 ****
|
|
Karsten Hopp |
790b10 |
return NULL;
|
|
Karsten Hopp |
790b10 |
}
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
! /* Window object
|
|
Karsten Hopp |
790b10 |
*/
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
typedef struct
|
|
Karsten Hopp |
790b10 |
--- 3002,3009 ----
|
|
Karsten Hopp |
790b10 |
return NULL;
|
|
Karsten Hopp |
790b10 |
}
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
! /*
|
|
Karsten Hopp |
790b10 |
! * Window object
|
|
Karsten Hopp |
790b10 |
*/
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
typedef struct
|
|
Karsten Hopp |
790b10 |
*** ../vim-7.3.1225/src/testdir/test86.ok 2013-06-12 14:26:20.000000000 +0200
|
|
Karsten Hopp |
790b10 |
--- src/testdir/test86.ok 2013-06-23 12:43:55.000000000 +0200
|
|
Karsten Hopp |
790b10 |
***************
|
|
Karsten Hopp |
790b10 |
*** 444,450 ****
|
|
Karsten Hopp |
790b10 |
sys.stdout.write(None):TypeError:('coercing to Unicode: need string or buffer, NoneType found',)
|
|
Karsten Hopp |
790b10 |
>> OutputWriteLines
|
|
Karsten Hopp |
790b10 |
sys.stdout.writelines(None):TypeError:("'NoneType' object is not iterable",)
|
|
Karsten Hopp |
790b10 |
! sys.stdout.writelines([1]):TypeError:('writelines() requires list of strings',)
|
|
Karsten Hopp |
790b10 |
> VimCommand
|
|
Karsten Hopp |
790b10 |
vim.command(1):TypeError:('must be string, not int',)
|
|
Karsten Hopp |
790b10 |
> VimToPython
|
|
Karsten Hopp |
790b10 |
--- 444,450 ----
|
|
Karsten Hopp |
790b10 |
sys.stdout.write(None):TypeError:('coercing to Unicode: need string or buffer, NoneType found',)
|
|
Karsten Hopp |
790b10 |
>> OutputWriteLines
|
|
Karsten Hopp |
790b10 |
sys.stdout.writelines(None):TypeError:("'NoneType' object is not iterable",)
|
|
Karsten Hopp |
790b10 |
! sys.stdout.writelines([1]):TypeError:('coercing to Unicode: need string or buffer, int found',)
|
|
Karsten Hopp |
790b10 |
> VimCommand
|
|
Karsten Hopp |
790b10 |
vim.command(1):TypeError:('must be string, not int',)
|
|
Karsten Hopp |
790b10 |
> VimToPython
|
|
Karsten Hopp |
790b10 |
*** ../vim-7.3.1225/src/testdir/test87.ok 2013-06-12 14:20:15.000000000 +0200
|
|
Karsten Hopp |
790b10 |
--- src/testdir/test87.ok 2013-06-23 12:44:00.000000000 +0200
|
|
Karsten Hopp |
790b10 |
***************
|
|
Karsten Hopp |
790b10 |
*** 433,439 ****
|
|
Karsten Hopp |
790b10 |
sys.stdout.write(None):(<class 'TypeError'>, TypeError("Can't convert 'NoneType' object to str implicitly",))
|
|
Karsten Hopp |
790b10 |
>> OutputWriteLines
|
|
Karsten Hopp |
790b10 |
sys.stdout.writelines(None):(<class 'TypeError'>, TypeError("'NoneType' object is not iterable",))
|
|
Karsten Hopp |
790b10 |
! sys.stdout.writelines([1]):(<class 'TypeError'>, TypeError('writelines() requires list of strings',))
|
|
Karsten Hopp |
790b10 |
>>> Testing *Iter* using sys.stdout.writelines(%s)
|
|
Karsten Hopp |
790b10 |
sys.stdout.writelines(FailingIter()):(<class 'NotImplementedError'>, NotImplementedError())
|
|
Karsten Hopp |
790b10 |
sys.stdout.writelines(FailingIterNext()):(<class 'NotImplementedError'>, NotImplementedError())
|
|
Karsten Hopp |
790b10 |
--- 433,439 ----
|
|
Karsten Hopp |
790b10 |
sys.stdout.write(None):(<class 'TypeError'>, TypeError("Can't convert 'NoneType' object to str implicitly",))
|
|
Karsten Hopp |
790b10 |
>> OutputWriteLines
|
|
Karsten Hopp |
790b10 |
sys.stdout.writelines(None):(<class 'TypeError'>, TypeError("'NoneType' object is not iterable",))
|
|
Karsten Hopp |
790b10 |
! sys.stdout.writelines([1]):(<class 'TypeError'>, TypeError("Can't convert 'int' object to str implicitly",))
|
|
Karsten Hopp |
790b10 |
>>> Testing *Iter* using sys.stdout.writelines(%s)
|
|
Karsten Hopp |
790b10 |
sys.stdout.writelines(FailingIter()):(<class 'NotImplementedError'>, NotImplementedError())
|
|
Karsten Hopp |
790b10 |
sys.stdout.writelines(FailingIterNext()):(<class 'NotImplementedError'>, NotImplementedError())
|
|
Karsten Hopp |
790b10 |
*** ../vim-7.3.1225/src/version.c 2013-06-22 13:00:14.000000000 +0200
|
|
Karsten Hopp |
790b10 |
--- src/version.c 2013-06-23 12:45:35.000000000 +0200
|
|
Karsten Hopp |
790b10 |
***************
|
|
Karsten Hopp |
790b10 |
*** 730,731 ****
|
|
Karsten Hopp |
790b10 |
--- 730,733 ----
|
|
Karsten Hopp |
790b10 |
{ /* Add new patch number below this line */
|
|
Karsten Hopp |
790b10 |
+ /**/
|
|
Karsten Hopp |
790b10 |
+ 1226,
|
|
Karsten Hopp |
790b10 |
/**/
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
--
|
|
Karsten Hopp |
790b10 |
We're knights of the round table
|
|
Karsten Hopp |
790b10 |
We dance whene'er we're able
|
|
Karsten Hopp |
790b10 |
We do routines and chorus scenes
|
|
Karsten Hopp |
790b10 |
With footwork impeccable.
|
|
Karsten Hopp |
790b10 |
We dine well here in Camelot
|
|
Karsten Hopp |
790b10 |
We eat ham and jam and spam a lot.
|
|
Karsten Hopp |
790b10 |
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
|
|
Karsten Hopp |
790b10 |
|
|
Karsten Hopp |
790b10 |
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
|
|
Karsten Hopp |
790b10 |
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
|
|
Karsten Hopp |
790b10 |
\\\ an exciting new programming language -- http://www.Zimbu.org ///
|
|
Karsten Hopp |
790b10 |
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
|