bpo-36523: Add docstring to io.IOBase.writelines (GH-12683)

This commit is contained in:
Marcin Niemira 2019-04-22 21:13:51 +10:00 committed by Inada Naoki
parent 662ebd2ab2
commit ab86521a9d
4 changed files with 18 additions and 3 deletions

View File

@ -551,6 +551,11 @@ class IOBase(metaclass=abc.ABCMeta):
return lines return lines
def writelines(self, lines): def writelines(self, lines):
"""Write a list of lines to the stream.
Line separators are not added, so it is usual for each of the lines
provided to have a line separator at the end.
"""
self._checkClosed() self._checkClosed()
for line in lines: for line in lines:
self.write(line) self.write(line)

View File

@ -0,0 +1 @@
Add docstring for io.IOBase.writelines().

View File

@ -242,7 +242,11 @@ exit:
PyDoc_STRVAR(_io__IOBase_writelines__doc__, PyDoc_STRVAR(_io__IOBase_writelines__doc__,
"writelines($self, lines, /)\n" "writelines($self, lines, /)\n"
"--\n" "--\n"
"\n"); "\n"
"Write a list of lines to stream.\n"
"\n"
"Line separators are not added, so it is usual for each of the\n"
"lines provided to have a line separator at the end.");
#define _IO__IOBASE_WRITELINES_METHODDEF \ #define _IO__IOBASE_WRITELINES_METHODDEF \
{"writelines", (PyCFunction)_io__IOBase_writelines, METH_O, _io__IOBase_writelines__doc__}, {"writelines", (PyCFunction)_io__IOBase_writelines, METH_O, _io__IOBase_writelines__doc__},
@ -311,4 +315,4 @@ _io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored))
{ {
return _io__RawIOBase_readall_impl(self); return _io__RawIOBase_readall_impl(self);
} }
/*[clinic end generated code: output=60e43a7cbd9f314e input=a9049054013a1b77]*/ /*[clinic end generated code: output=61b6ea7153ef9940 input=a9049054013a1b77]*/

View File

@ -751,11 +751,16 @@ _io__IOBase_readlines_impl(PyObject *self, Py_ssize_t hint)
_io._IOBase.writelines _io._IOBase.writelines
lines: object lines: object
/ /
Write a list of lines to stream.
Line separators are not added, so it is usual for each of the
lines provided to have a line separator at the end.
[clinic start generated code]*/ [clinic start generated code]*/
static PyObject * static PyObject *
_io__IOBase_writelines(PyObject *self, PyObject *lines) _io__IOBase_writelines(PyObject *self, PyObject *lines)
/*[clinic end generated code: output=976eb0a9b60a6628 input=432e729a8450b3cb]*/ /*[clinic end generated code: output=976eb0a9b60a6628 input=cac3fc8864183359]*/
{ {
PyObject *iter, *res; PyObject *iter, *res;