summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2011-09-24 08:14:39 (GMT)
committerMark Dickinson <mdickinson@enthought.com>2011-09-24 08:14:39 (GMT)
commit0d5f6adbb3e5d829a64ef1b431f7ac76dd258c1e (patch)
treed07d766085d981b7021696af28b0ea7bf4dd8ecc /Objects
parenta61b053e611dd97258231913b79fafe0a9a16125 (diff)
downloadcpython-0d5f6adbb3e5d829a64ef1b431f7ac76dd258c1e.zip
cpython-0d5f6adbb3e5d829a64ef1b431f7ac76dd258c1e.tar.gz
cpython-0d5f6adbb3e5d829a64ef1b431f7ac76dd258c1e.tar.bz2
Issue #13012: Allow 'keepends' to be passed as a keyword argument in str.splitlines, bytes.splitlines and bytearray.splitlines.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/bytearrayobject.c10
-rw-r--r--Objects/bytesobject.c8
-rw-r--r--Objects/unicodeobject.c8
3 files changed, 16 insertions, 10 deletions
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index d365fbc..11a0101 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -2608,11 +2608,13 @@ Line breaks are not included in the resulting list unless keepends\n\
is given and true.");
static PyObject*
-bytearray_splitlines(PyObject *self, PyObject *args)
+bytearray_splitlines(PyObject *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 stringlib_splitlines(
@@ -2801,8 +2803,8 @@ bytearray_methods[] = {
{"rsplit", (PyCFunction)bytearray_rsplit, METH_VARARGS, rsplit__doc__},
{"rstrip", (PyCFunction)bytearray_rstrip, METH_VARARGS, rstrip__doc__},
{"split", (PyCFunction)bytearray_split, METH_VARARGS, split__doc__},
- {"splitlines", (PyCFunction)bytearray_splitlines, METH_VARARGS,
- splitlines__doc__},
+ {"splitlines", (PyCFunction)bytearray_splitlines,
+ METH_VARARGS | METH_KEYWORDS, splitlines__doc__},
{"startswith", (PyCFunction)bytearray_startswith, METH_VARARGS ,
startswith__doc__},
{"strip", (PyCFunction)bytearray_strip, METH_VARARGS, strip__doc__},
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 43d8381..a286646 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -2312,11 +2312,13 @@ Line breaks are not included in the resulting list unless keepends\n\
is given and true.");
static PyObject*
-bytes_splitlines(PyObject *self, PyObject *args)
+bytes_splitlines(PyObject *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 stringlib_splitlines(
@@ -2458,7 +2460,7 @@ bytes_methods[] = {
{"rsplit", (PyCFunction)bytes_rsplit, METH_VARARGS, rsplit__doc__},
{"rstrip", (PyCFunction)bytes_rstrip, METH_VARARGS, rstrip__doc__},
{"split", (PyCFunction)bytes_split, METH_VARARGS, split__doc__},
- {"splitlines", (PyCFunction)bytes_splitlines, METH_VARARGS,
+ {"splitlines", (PyCFunction)bytes_splitlines, METH_VARARGS | METH_KEYWORDS,
splitlines__doc__},
{"startswith", (PyCFunction)bytes_startswith, METH_VARARGS,
startswith__doc__},
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 174455f..8c2ce6a 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -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__},