Skip to content

Commit

Permalink
[3.7] bpo-36523: Add docstring to io.IOBase.writelines (pythonGH-12683).
Browse files Browse the repository at this point in the history
(cherry picked from commit ab86521)

Co-authored-by: Marcin Niemira <[email protected]>
  • Loading branch information
n0npax committed Apr 22, 2019
1 parent 8c49d71 commit ef8b791
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Lib/_pyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,11 @@ def readlines(self, hint=None):
return 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()
for line in lines:
self.write(line)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add docstring for io.IOBase.writelines().
8 changes: 6 additions & 2 deletions Modules/_io/clinic/iobase.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ _io__IOBase_readlines(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
PyDoc_STRVAR(_io__IOBase_writelines__doc__,
"writelines($self, lines, /)\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 \
{"writelines", (PyCFunction)_io__IOBase_writelines, METH_O, _io__IOBase_writelines__doc__},
Expand Down Expand Up @@ -279,4 +283,4 @@ _io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored))
{
return _io__RawIOBase_readall_impl(self);
}
/*[clinic end generated code: output=64989ec3dbf44a7c input=a9049054013a1b77]*/
/*[clinic end generated code: output=61b6ea7153ef9940 input=a9049054013a1b77]*/
7 changes: 6 additions & 1 deletion Modules/_io/iobase.c
Original file line number Diff line number Diff line change
Expand Up @@ -738,11 +738,16 @@ _io__IOBase_readlines_impl(PyObject *self, Py_ssize_t hint)
_io._IOBase.writelines
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]*/

static PyObject *
_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;

Expand Down

0 comments on commit ef8b791

Please sign in to comment.