bpo-36523: Add docstring to io.IOBase.writelines (GH-12683) · python/cpython@1100ae8

File tree

4 files changed

lines changed

  • Misc/NEWS.d/next/Documentation

4 files changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -546,6 +546,11 @@ def readlines(self, hint=None):

546546

return lines

547547
548548

def writelines(self, lines):

549+

"""Write a list of lines to the stream.

550+
551+

Line separators are not added, so it is usual for each of the lines

552+

provided to have a line separator at the end.

553+

"""

549554

self._checkClosed()

550555

for line in lines:

551556

self.write(line)

Original file line numberDiff line numberDiff line change

@@ -0,0 +1 @@

1+

Add docstring for io.IOBase.writelines().

Original file line numberDiff line numberDiff line change

@@ -230,7 +230,11 @@ _io__IOBase_readlines(PyObject *self, PyObject *const *args, Py_ssize_t nargs)

230230

PyDoc_STRVAR(_io__IOBase_writelines__doc__,

231231

"writelines($self, lines, /)\n"

232232

"--\n"

233-

"\n");

233+

"\n"

234+

"Write a list of lines to stream.\n"

235+

"\n"

236+

"Line separators are not added, so it is usual for each of the\n"

237+

"lines provided to have a line separator at the end.");

234238
235239

#define _IO__IOBASE_WRITELINES_METHODDEF \

236240

{"writelines", (PyCFunction)_io__IOBase_writelines, METH_O, _io__IOBase_writelines__doc__},

@@ -279,4 +283,4 @@ _io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored))

279283

{

280284

return _io__RawIOBase_readall_impl(self);

281285

}

282-

/*[clinic end generated code: output=64989ec3dbf44a7c input=a9049054013a1b77]*/

286+

/*[clinic end generated code: output=6f8d078401fb9d48 input=a9049054013a1b77]*/

Original file line numberDiff line numberDiff line change

@@ -738,11 +738,16 @@ _io__IOBase_readlines_impl(PyObject *self, Py_ssize_t hint)

738738

_io._IOBase.writelines

739739

lines: object

740740

/

741+
742+

Write a list of lines to stream.

743+
744+

Line separators are not added, so it is usual for each of the

745+

lines provided to have a line separator at the end.

741746

[clinic start generated code]*/

742747
743748

static PyObject *

744749

_io__IOBase_writelines(PyObject *self, PyObject *lines)

745-

/*[clinic end generated code: output=976eb0a9b60a6628 input=432e729a8450b3cb]*/

750+

/*[clinic end generated code: output=976eb0a9b60a6628 input=cac3fc8864183359]*/

746751

{

747752

PyObject *iter, *res;

748753