Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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=6f8d078401fb9d48 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