Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(8)

Unified Diff: Objects/bytearrayobject.c

Issue 8706: accept keyword arguments on all base type methods and builtins
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/test/test_userstring.py ('k') | Objects/bytesobject.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Objects/bytearrayobject.c Sun Feb 26 18:09:50 2012 +0100
+++ b/Objects/bytearrayobject.c Sun Feb 26 20:28:46 2012 +0100
@@ -1068,7 +1068,8 @@
}
Py_LOCAL_INLINE(Py_ssize_t)
-bytearray_find_internal(PyByteArrayObject *self, PyObject *args, int dir)
+bytearray_find_internal(PyByteArrayObject *self, PyObject *args, PyObject *kwds,
+ int dir)
{
PyObject *subobj;
char byte;
@@ -1079,7 +1080,8 @@
Py_ssize_t res;
if (!stringlib_parse_args_finds_byte("find/rfind/index/rindex",
- args, &subobj, &byte, &start, &end))
+ args, kwds, &subobj, &byte, &start,
+ &end))
return -2;
if (subobj) {
@@ -1119,9 +1121,9 @@
Return -1 on failure.");
static PyObject *
-bytearray_find(PyByteArrayObject *self, PyObject *args)
+bytearray_find(PyByteArrayObject *self, PyObject *args, PyObject *kwds)
{
- Py_ssize_t result = bytearray_find_internal(self, args, +1);
+ Py_ssize_t result = bytearray_find_internal(self, args, kwds, +1);
if (result == -2)
return NULL;
return PyLong_FromSsize_t(result);
@@ -1135,7 +1137,7 @@
as in slice notation.");
static PyObject *
-bytearray_count(PyByteArrayObject *self, PyObject *args)
+bytearray_count(PyByteArrayObject *self, PyObject *args, PyObject *kwds)
{
PyObject *sub_obj;
const char *str = PyByteArray_AS_STRING(self), *sub;
@@ -1146,7 +1148,7 @@
Py_buffer vsub;
PyObject *count_obj;
- if (!stringlib_parse_args_finds_byte("count", args, &sub_obj, &byte,
+ if (!stringlib_parse_args_finds_byte("count", args, kwds, &sub_obj, &byte,
&start, &end))
return NULL;
@@ -1205,9 +1207,9 @@
Like B.find() but raise ValueError when the subsection is not found.");
static PyObject *
-bytearray_index(PyByteArrayObject *self, PyObject *args)
+bytearray_index(PyByteArrayObject *self, PyObject *args, PyObject *kwds)
{
- Py_ssize_t result = bytearray_find_internal(self, args, +1);
+ Py_ssize_t result = bytearray_find_internal(self, args, kwds, +1);
if (result == -2)
return NULL;
if (result == -1) {
@@ -1229,9 +1231,9 @@
Return -1 on failure.");
static PyObject *
-bytearray_rfind(PyByteArrayObject *self, PyObject *args)
+bytearray_rfind(PyByteArrayObject *self, PyObject *args, PyObject *kwds)
{
- Py_ssize_t result = bytearray_find_internal(self, args, -1);
+ Py_ssize_t result = bytearray_find_internal(self, args, kwds, -1);
if (result == -2)
return NULL;
return PyLong_FromSsize_t(result);
@@ -1244,9 +1246,9 @@
Like B.rfind() but raise ValueError when the subsection is not found.");
static PyObject *
-bytearray_rindex(PyByteArrayObject *self, PyObject *args)
+bytearray_rindex(PyByteArrayObject *self, PyObject *args, PyObject *kwds)
{
- Py_ssize_t result = bytearray_find_internal(self, args, -1);
+ Py_ssize_t result = bytearray_find_internal(self, args, kwds, -1);
if (result == -2)
return NULL;
if (result == -1) {
@@ -1334,14 +1336,15 @@
prefix can also be a tuple of bytes to try.");
static PyObject *
-bytearray_startswith(PyByteArrayObject *self, PyObject *args)
+bytearray_startswith(PyByteArrayObject *self, PyObject *args, PyObject *kwds)
{
Py_ssize_t start = 0;
Py_ssize_t end = PY_SSIZE_T_MAX;
PyObject *subobj;
int result;
- if (!stringlib_parse_args_finds("startswith", args, &subobj, &start, &end))
+ if (!stringlib_parse_args_finds("startswith", args, kwds, &subobj, &start,
+ &end))
return NULL;
if (PyTuple_Check(subobj)) {
Py_ssize_t i;
@@ -1377,14 +1380,15 @@
suffix can also be a tuple of bytes to try.");
static PyObject *
-bytearray_endswith(PyByteArrayObject *self, PyObject *args)
+bytearray_endswith(PyByteArrayObject *self, PyObject *args, PyObject *kwds)
{
Py_ssize_t start = 0;
Py_ssize_t end = PY_SSIZE_T_MAX;
PyObject *subobj;
int result;
- if (!stringlib_parse_args_finds("endswith", args, &subobj, &start, &end))
+ if (!stringlib_parse_args_finds("endswith", args, kwds, &subobj, &start,
+ &end))
return NULL;
if (PyTuple_Check(subobj)) {
Py_ssize_t i;
@@ -2833,16 +2837,16 @@
{"center", (PyCFunction)stringlib_center, METH_VARARGS, center__doc__},
{"clear", (PyCFunction)bytearray_clear, METH_NOARGS, clear__doc__},
{"copy", (PyCFunction)bytearray_copy, METH_NOARGS, copy__doc__},
- {"count", (PyCFunction)bytearray_count, METH_VARARGS, count__doc__},
+ {"count", (PyCFunction)bytearray_count, METH_VARARGS | METH_KEYWORDS, count__doc__},
{"decode", (PyCFunction)bytearray_decode, METH_VARARGS | METH_KEYWORDS, decode_doc},
- {"endswith", (PyCFunction)bytearray_endswith, METH_VARARGS, endswith__doc__},
+ {"endswith", (PyCFunction)bytearray_endswith, METH_VARARGS | METH_KEYWORDS, endswith__doc__},
{"expandtabs", (PyCFunction)stringlib_expandtabs, METH_VARARGS,
expandtabs__doc__},
{"extend", (PyCFunction)bytearray_extend, METH_O, extend__doc__},
- {"find", (PyCFunction)bytearray_find, METH_VARARGS, find__doc__},
+ {"find", (PyCFunction)bytearray_find, METH_VARARGS | METH_KEYWORDS, find__doc__},
{"fromhex", (PyCFunction)bytearray_fromhex, METH_VARARGS|METH_CLASS,
fromhex_doc},
- {"index", (PyCFunction)bytearray_index, METH_VARARGS, index__doc__},
+ {"index", (PyCFunction)bytearray_index, METH_VARARGS | METH_KEYWORDS, index__doc__},
{"insert", (PyCFunction)bytearray_insert, METH_VARARGS, insert__doc__},
{"isalnum", (PyCFunction)stringlib_isalnum, METH_NOARGS,
_Py_isalnum__doc__},
@@ -2869,8 +2873,8 @@
{"remove", (PyCFunction)bytearray_remove, METH_O, remove__doc__},
{"replace", (PyCFunction)bytearray_replace, METH_VARARGS, replace__doc__},
{"reverse", (PyCFunction)bytearray_reverse, METH_NOARGS, reverse__doc__},
- {"rfind", (PyCFunction)bytearray_rfind, METH_VARARGS, rfind__doc__},
- {"rindex", (PyCFunction)bytearray_rindex, METH_VARARGS, rindex__doc__},
+ {"rfind", (PyCFunction)bytearray_rfind, METH_VARARGS | METH_KEYWORDS, rfind__doc__},
+ {"rindex", (PyCFunction)bytearray_rindex, METH_VARARGS | METH_KEYWORDS, rindex__doc__},
{"rjust", (PyCFunction)stringlib_rjust, METH_VARARGS, rjust__doc__},
{"rpartition", (PyCFunction)bytearray_rpartition, METH_O, rpartition__doc__},
{"rsplit", (PyCFunction)bytearray_rsplit, METH_VARARGS | METH_KEYWORDS, rsplit__doc__},
@@ -2878,7 +2882,7 @@
{"split", (PyCFunction)bytearray_split, METH_VARARGS | METH_KEYWORDS, split__doc__},
{"splitlines", (PyCFunction)bytearray_splitlines,
METH_VARARGS | METH_KEYWORDS, splitlines__doc__},
- {"startswith", (PyCFunction)bytearray_startswith, METH_VARARGS ,
+ {"startswith", (PyCFunction)bytearray_startswith, METH_VARARGS | METH_KEYWORDS,
startswith__doc__},
{"strip", (PyCFunction)bytearray_strip, METH_VARARGS, strip__doc__},
{"swapcase", (PyCFunction)stringlib_swapcase, METH_NOARGS,
« no previous file with comments | « Lib/test/test_userstring.py ('k') | Objects/bytesobject.c » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+