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

Unified Diff: Objects/bytesobject.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 | « Objects/bytearrayobject.c ('k') | Objects/stringlib/find.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Objects/bytesobject.c Sun Feb 26 18:09:50 2012 +0100
+++ b/Objects/bytesobject.c Sun Feb 26 20:28:46 2012 +0100
@@ -1220,7 +1220,8 @@
}
Py_LOCAL_INLINE(Py_ssize_t)
-bytes_find_internal(PyBytesObject *self, PyObject *args, int dir)
+bytes_find_internal(PyBytesObject *self, PyObject *args, PyObject *kwds,
+ int dir)
{
PyObject *subobj;
char byte;
@@ -1231,7 +1232,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) {
@@ -1272,9 +1274,9 @@
Return -1 on failure.");
static PyObject *
-bytes_find(PyBytesObject *self, PyObject *args)
+bytes_find(PyBytesObject *self, PyObject *args, PyObject *kwds)
{
- Py_ssize_t result = bytes_find_internal(self, args, +1);
+ Py_ssize_t result = bytes_find_internal(self, args, kwds, +1);
if (result == -2)
return NULL;
return PyLong_FromSsize_t(result);
@@ -1287,9 +1289,9 @@
Like B.find() but raise ValueError when the substring is not found.");
static PyObject *
-bytes_index(PyBytesObject *self, PyObject *args)
+bytes_index(PyBytesObject *self, PyObject *args, PyObject *kwds)
{
- Py_ssize_t result = bytes_find_internal(self, args, +1);
+ Py_ssize_t result = bytes_find_internal(self, args, kwds, +1);
if (result == -2)
return NULL;
if (result == -1) {
@@ -1311,9 +1313,9 @@
Return -1 on failure.");
static PyObject *
-bytes_rfind(PyBytesObject *self, PyObject *args)
+bytes_rfind(PyBytesObject *self, PyObject *args, PyObject *kwds)
{
- Py_ssize_t result = bytes_find_internal(self, args, -1);
+ Py_ssize_t result = bytes_find_internal(self, args, kwds, -1);
if (result == -2)
return NULL;
return PyLong_FromSsize_t(result);
@@ -1326,9 +1328,9 @@
Like B.rfind() but raise ValueError when the substring is not found.");
static PyObject *
-bytes_rindex(PyBytesObject *self, PyObject *args)
+bytes_rindex(PyBytesObject *self, PyObject *args, PyObject *kwds)
{
- Py_ssize_t result = bytes_find_internal(self, args, -1);
+ Py_ssize_t result = bytes_find_internal(self, args, kwds, -1);
if (result == -2)
return NULL;
if (result == -1) {
@@ -1479,7 +1481,7 @@
as in slice notation.");
static PyObject *
-bytes_count(PyBytesObject *self, PyObject *args)
+bytes_count(PyBytesObject *self, PyObject *args, PyObject *kwds)
{
PyObject *sub_obj;
const char *str = PyBytes_AS_STRING(self), *sub;
@@ -1490,7 +1492,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;
@@ -2212,14 +2214,15 @@
prefix can also be a tuple of bytes to try.");
static PyObject *
-bytes_startswith(PyBytesObject *self, PyObject *args)
+bytes_startswith(PyBytesObject *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;
@@ -2256,14 +2259,15 @@
suffix can also be a tuple of bytes to try.");
static PyObject *
-bytes_endswith(PyBytesObject *self, PyObject *args)
+bytes_endswith(PyBytesObject *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;
@@ -2437,16 +2441,16 @@
{"capitalize", (PyCFunction)stringlib_capitalize, METH_NOARGS,
_Py_capitalize__doc__},
{"center", (PyCFunction)stringlib_center, METH_VARARGS, center__doc__},
- {"count", (PyCFunction)bytes_count, METH_VARARGS, count__doc__},
+ {"count", (PyCFunction)bytes_count, METH_VARARGS | METH_KEYWORDS, count__doc__},
{"decode", (PyCFunction)bytes_decode, METH_VARARGS | METH_KEYWORDS, decode__doc__},
- {"endswith", (PyCFunction)bytes_endswith, METH_VARARGS,
+ {"endswith", (PyCFunction)bytes_endswith, METH_VARARGS | METH_KEYWORDS,
endswith__doc__},
{"expandtabs", (PyCFunction)stringlib_expandtabs, METH_VARARGS,
expandtabs__doc__},
- {"find", (PyCFunction)bytes_find, METH_VARARGS, find__doc__},
+ {"find", (PyCFunction)bytes_find, METH_VARARGS | METH_KEYWORDS, find__doc__},
{"fromhex", (PyCFunction)bytes_fromhex, METH_VARARGS|METH_CLASS,
fromhex_doc},
- {"index", (PyCFunction)bytes_index, METH_VARARGS, index__doc__},
+ {"index", (PyCFunction)bytes_index, METH_VARARGS | METH_KEYWORDS, index__doc__},
{"isalnum", (PyCFunction)stringlib_isalnum, METH_NOARGS,
_Py_isalnum__doc__},
{"isalpha", (PyCFunction)stringlib_isalpha, METH_NOARGS,
@@ -2469,8 +2473,8 @@
_Py_maketrans__doc__},
{"partition", (PyCFunction)bytes_partition, METH_O, partition__doc__},
{"replace", (PyCFunction)bytes_replace, METH_VARARGS, replace__doc__},
- {"rfind", (PyCFunction)bytes_rfind, METH_VARARGS, rfind__doc__},
- {"rindex", (PyCFunction)bytes_rindex, METH_VARARGS, rindex__doc__},
+ {"rfind", (PyCFunction)bytes_rfind, METH_VARARGS | METH_KEYWORDS, rfind__doc__},
+ {"rindex", (PyCFunction)bytes_rindex, METH_VARARGS | METH_KEYWORDS, rindex__doc__},
{"rjust", (PyCFunction)stringlib_rjust, METH_VARARGS, rjust__doc__},
{"rpartition", (PyCFunction)bytes_rpartition, METH_O,
rpartition__doc__},
@@ -2479,7 +2483,7 @@
{"split", (PyCFunction)bytes_split, METH_VARARGS | METH_KEYWORDS, split__doc__},
{"splitlines", (PyCFunction)bytes_splitlines, METH_VARARGS | METH_KEYWORDS,
splitlines__doc__},
- {"startswith", (PyCFunction)bytes_startswith, METH_VARARGS,
+ {"startswith", (PyCFunction)bytes_startswith, METH_VARARGS | METH_KEYWORDS,
startswith__doc__},
{"strip", (PyCFunction)bytes_strip, METH_VARARGS, strip__doc__},
{"swapcase", (PyCFunction)stringlib_swapcase, METH_NOARGS,
« no previous file with comments | « Objects/bytearrayobject.c ('k') | Objects/stringlib/find.h » ('j') | no next file with comments »

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