From ef8b79112b4c1b777649542a2907d4365dbfc547 Mon Sep 17 00:00:00 2001 From: Marcin Niemira Date: Mon, 22 Apr 2019 21:13:51 +1000 Subject: [PATCH 1/2] [3.7] bpo-36523: Add docstring to io.IOBase.writelines (GH-12683). (cherry picked from commit ab86521a9d9999731e39bd9056420bb7774fd144) Co-authored-by: Marcin Niemira --- Lib/_pyio.py | 5 +++++ .../2019-04-04-19-11-47.bpo-36523.sG1Tr4.rst | 1 + Modules/_io/clinic/iobase.c.h | 8 ++++++-- Modules/_io/iobase.c | 7 ++++++- 4 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 Misc/NEWS.d/next/Documentation/2019-04-04-19-11-47.bpo-36523.sG1Tr4.rst diff --git a/Lib/_pyio.py b/Lib/_pyio.py index 0c0cb84a48e21de..afbd48e0005d64b 100644 --- a/Lib/_pyio.py +++ b/Lib/_pyio.py @@ -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) diff --git a/Misc/NEWS.d/next/Documentation/2019-04-04-19-11-47.bpo-36523.sG1Tr4.rst b/Misc/NEWS.d/next/Documentation/2019-04-04-19-11-47.bpo-36523.sG1Tr4.rst new file mode 100644 index 000000000000000..9355f607d760adc --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2019-04-04-19-11-47.bpo-36523.sG1Tr4.rst @@ -0,0 +1 @@ +Add docstring for io.IOBase.writelines(). diff --git a/Modules/_io/clinic/iobase.c.h b/Modules/_io/clinic/iobase.c.h index e6f72cd5ff9e634..a574c3de42ee680 100644 --- a/Modules/_io/clinic/iobase.c.h +++ b/Modules/_io/clinic/iobase.c.h @@ -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__}, @@ -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]*/ diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c index 5b71732ef19c652..6995c1570cdf3ff 100644 --- a/Modules/_io/iobase.c +++ b/Modules/_io/iobase.c @@ -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; From 42de9e9330a148643c74ce05a2156431549dc017 Mon Sep 17 00:00:00 2001 From: Marcin Niemira Date: Mon, 22 Apr 2019 21:52:12 +1000 Subject: [PATCH 2/2] regenerate clinic checksum --- Modules/_io/clinic/iobase.c.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/_io/clinic/iobase.c.h b/Modules/_io/clinic/iobase.c.h index a574c3de42ee680..66836bfdf45c7d7 100644 --- a/Modules/_io/clinic/iobase.c.h +++ b/Modules/_io/clinic/iobase.c.h @@ -283,4 +283,4 @@ _io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored)) { return _io__RawIOBase_readall_impl(self); } -/*[clinic end generated code: output=61b6ea7153ef9940 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=6f8d078401fb9d48 input=a9049054013a1b77]*/