Issue #13012: Allow 'keepends' to be passed as a keyword argument in str.splitlines, bytes.splitlines and bytearray.splitlines.

This commit is contained in:
Mark Dickinson 2011-09-24 09:14:39 +01:00
parent a61b053e61
commit 0d5f6adbb3
7 changed files with 40 additions and 16 deletions

View file

@ -8881,11 +8881,13 @@ Line breaks are not included in the resulting list unless keepends\n\
is given and true.");
static PyObject*
unicode_splitlines(PyUnicodeObject *self, PyObject *args)
unicode_splitlines(PyUnicodeObject *self, PyObject *args, PyObject *kwds)
{
static char *kwlist[] = {"keepends", 0};
int keepends = 0;
if (!PyArg_ParseTuple(args, "|i:splitlines", &keepends))
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i:splitlines",
kwlist, &keepends))
return NULL;
return PyUnicode_Splitlines((PyObject *)self, keepends);
@ -9273,7 +9275,7 @@ static PyMethodDef unicode_methods[] = {
{"rjust", (PyCFunction) unicode_rjust, METH_VARARGS, rjust__doc__},
{"rstrip", (PyCFunction) unicode_rstrip, METH_VARARGS, rstrip__doc__},
{"rpartition", (PyCFunction) unicode_rpartition, METH_O, rpartition__doc__},
{"splitlines", (PyCFunction) unicode_splitlines, METH_VARARGS, splitlines__doc__},
{"splitlines", (PyCFunction) unicode_splitlines, METH_VARARGS | METH_KEYWORDS, splitlines__doc__},
{"strip", (PyCFunction) unicode_strip, METH_VARARGS, strip__doc__},
{"swapcase", (PyCFunction) unicode_swapcase, METH_NOARGS, swapcase__doc__},
{"translate", (PyCFunction) unicode_translate, METH_O, translate__doc__},