diff options
Diffstat (limited to 'Objects/clinic')
-rw-r--r-- | Objects/clinic/bytearrayobject.c.h | 92 | ||||
-rw-r--r-- | Objects/clinic/bytesobject.c.h | 62 | ||||
-rw-r--r-- | Objects/clinic/dictobject.c.h | 87 | ||||
-rw-r--r-- | Objects/clinic/enumobject.c.h | 71 | ||||
-rw-r--r-- | Objects/clinic/odictobject.c.h | 134 | ||||
-rw-r--r-- | Objects/clinic/unicodeobject.c.h | 931 |
6 files changed, 1316 insertions, 61 deletions
diff --git a/Objects/clinic/bytearrayobject.c.h b/Objects/clinic/bytearrayobject.c.h index c75acb75cf..a181d9a99b 100644 --- a/Objects/clinic/bytearrayobject.c.h +++ b/Objects/clinic/bytearrayobject.c.h @@ -66,7 +66,7 @@ bytearray_translate(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyObject *table; PyObject *deletechars = NULL; - if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, &table, &deletechars)) { goto exit; } @@ -88,22 +88,26 @@ PyDoc_STRVAR(bytearray_maketrans__doc__, "The bytes objects frm and to must be of the same length."); #define BYTEARRAY_MAKETRANS_METHODDEF \ - {"maketrans", (PyCFunction)bytearray_maketrans, METH_VARARGS|METH_STATIC, bytearray_maketrans__doc__}, + {"maketrans", (PyCFunction)bytearray_maketrans, METH_FASTCALL|METH_STATIC, bytearray_maketrans__doc__}, static PyObject * bytearray_maketrans_impl(Py_buffer *frm, Py_buffer *to); static PyObject * -bytearray_maketrans(void *null, PyObject *args) +bytearray_maketrans(void *null, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; Py_buffer frm = {NULL, NULL}; Py_buffer to = {NULL, NULL}; - if (!PyArg_ParseTuple(args, "y*y*:maketrans", + if (!_PyArg_ParseStack(args, nargs, "y*y*:maketrans", &frm, &to)) { goto exit; } + + if (!_PyArg_NoStackKeywords("maketrans", kwnames)) { + goto exit; + } return_value = bytearray_maketrans_impl(&frm, &to); exit: @@ -133,24 +137,28 @@ PyDoc_STRVAR(bytearray_replace__doc__, "replaced."); #define BYTEARRAY_REPLACE_METHODDEF \ - {"replace", (PyCFunction)bytearray_replace, METH_VARARGS, bytearray_replace__doc__}, + {"replace", (PyCFunction)bytearray_replace, METH_FASTCALL, bytearray_replace__doc__}, static PyObject * bytearray_replace_impl(PyByteArrayObject *self, Py_buffer *old, Py_buffer *new, Py_ssize_t count); static PyObject * -bytearray_replace(PyByteArrayObject *self, PyObject *args) +bytearray_replace(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; Py_buffer old = {NULL, NULL}; Py_buffer new = {NULL, NULL}; Py_ssize_t count = -1; - if (!PyArg_ParseTuple(args, "y*y*|n:replace", + if (!_PyArg_ParseStack(args, nargs, "y*y*|n:replace", &old, &new, &count)) { goto exit; } + + if (!_PyArg_NoStackKeywords("replace", kwnames)) { + goto exit; + } return_value = bytearray_replace_impl(self, &old, &new, count); exit: @@ -196,7 +204,7 @@ bytearray_split(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyOb PyObject *sep = Py_None; Py_ssize_t maxsplit = -1; - if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, &sep, &maxsplit)) { goto exit; } @@ -270,7 +278,7 @@ bytearray_rsplit(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyO PyObject *sep = Py_None; Py_ssize_t maxsplit = -1; - if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, &sep, &maxsplit)) { goto exit; } @@ -310,22 +318,26 @@ PyDoc_STRVAR(bytearray_insert__doc__, " The item to be inserted."); #define BYTEARRAY_INSERT_METHODDEF \ - {"insert", (PyCFunction)bytearray_insert, METH_VARARGS, bytearray_insert__doc__}, + {"insert", (PyCFunction)bytearray_insert, METH_FASTCALL, bytearray_insert__doc__}, static PyObject * bytearray_insert_impl(PyByteArrayObject *self, Py_ssize_t index, int item); static PyObject * -bytearray_insert(PyByteArrayObject *self, PyObject *args) +bytearray_insert(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; Py_ssize_t index; int item; - if (!PyArg_ParseTuple(args, "nO&:insert", + if (!_PyArg_ParseStack(args, nargs, "nO&:insert", &index, _getbytevalue, &item)) { goto exit; } + + if (!_PyArg_NoStackKeywords("insert", kwnames)) { + goto exit; + } return_value = bytearray_insert_impl(self, index, item); exit: @@ -387,21 +399,25 @@ PyDoc_STRVAR(bytearray_pop__doc__, "If no index argument is given, will pop the last item."); #define BYTEARRAY_POP_METHODDEF \ - {"pop", (PyCFunction)bytearray_pop, METH_VARARGS, bytearray_pop__doc__}, + {"pop", (PyCFunction)bytearray_pop, METH_FASTCALL, bytearray_pop__doc__}, static PyObject * bytearray_pop_impl(PyByteArrayObject *self, Py_ssize_t index); static PyObject * -bytearray_pop(PyByteArrayObject *self, PyObject *args) +bytearray_pop(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; Py_ssize_t index = -1; - if (!PyArg_ParseTuple(args, "|n:pop", + if (!_PyArg_ParseStack(args, nargs, "|n:pop", &index)) { goto exit; } + + if (!_PyArg_NoStackKeywords("pop", kwnames)) { + goto exit; + } return_value = bytearray_pop_impl(self, index); exit: @@ -447,22 +463,26 @@ PyDoc_STRVAR(bytearray_strip__doc__, "If the argument is omitted or None, strip leading and trailing ASCII whitespace."); #define BYTEARRAY_STRIP_METHODDEF \ - {"strip", (PyCFunction)bytearray_strip, METH_VARARGS, bytearray_strip__doc__}, + {"strip", (PyCFunction)bytearray_strip, METH_FASTCALL, bytearray_strip__doc__}, static PyObject * bytearray_strip_impl(PyByteArrayObject *self, PyObject *bytes); static PyObject * -bytearray_strip(PyByteArrayObject *self, PyObject *args) +bytearray_strip(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; PyObject *bytes = Py_None; - if (!PyArg_UnpackTuple(args, "strip", + if (!_PyArg_UnpackStack(args, nargs, "strip", 0, 1, &bytes)) { goto exit; } + + if (!_PyArg_NoStackKeywords("strip", kwnames)) { + goto exit; + } return_value = bytearray_strip_impl(self, bytes); exit: @@ -478,22 +498,26 @@ PyDoc_STRVAR(bytearray_lstrip__doc__, "If the argument is omitted or None, strip leading ASCII whitespace."); #define BYTEARRAY_LSTRIP_METHODDEF \ - {"lstrip", (PyCFunction)bytearray_lstrip, METH_VARARGS, bytearray_lstrip__doc__}, + {"lstrip", (PyCFunction)bytearray_lstrip, METH_FASTCALL, bytearray_lstrip__doc__}, static PyObject * bytearray_lstrip_impl(PyByteArrayObject *self, PyObject *bytes); static PyObject * -bytearray_lstrip(PyByteArrayObject *self, PyObject *args) +bytearray_lstrip(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; PyObject *bytes = Py_None; - if (!PyArg_UnpackTuple(args, "lstrip", + if (!_PyArg_UnpackStack(args, nargs, "lstrip", 0, 1, &bytes)) { goto exit; } + + if (!_PyArg_NoStackKeywords("lstrip", kwnames)) { + goto exit; + } return_value = bytearray_lstrip_impl(self, bytes); exit: @@ -509,22 +533,26 @@ PyDoc_STRVAR(bytearray_rstrip__doc__, "If the argument is omitted or None, strip trailing ASCII whitespace."); #define BYTEARRAY_RSTRIP_METHODDEF \ - {"rstrip", (PyCFunction)bytearray_rstrip, METH_VARARGS, bytearray_rstrip__doc__}, + {"rstrip", (PyCFunction)bytearray_rstrip, METH_FASTCALL, bytearray_rstrip__doc__}, static PyObject * bytearray_rstrip_impl(PyByteArrayObject *self, PyObject *bytes); static PyObject * -bytearray_rstrip(PyByteArrayObject *self, PyObject *args) +bytearray_rstrip(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; PyObject *bytes = Py_None; - if (!PyArg_UnpackTuple(args, "rstrip", + if (!_PyArg_UnpackStack(args, nargs, "rstrip", 0, 1, &bytes)) { goto exit; } + + if (!_PyArg_NoStackKeywords("rstrip", kwnames)) { + goto exit; + } return_value = bytearray_rstrip_impl(self, bytes); exit: @@ -562,7 +590,7 @@ bytearray_decode(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyO const char *encoding = NULL; const char *errors = NULL; - if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, &encoding, &errors)) { goto exit; } @@ -608,7 +636,7 @@ bytearray_splitlines(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, static _PyArg_Parser _parser = {"|i:splitlines", _keywords, 0}; int keepends = 0; - if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, &keepends)) { goto exit; } @@ -673,21 +701,25 @@ PyDoc_STRVAR(bytearray_reduce_ex__doc__, "Return state information for pickling."); #define BYTEARRAY_REDUCE_EX_METHODDEF \ - {"__reduce_ex__", (PyCFunction)bytearray_reduce_ex, METH_VARARGS, bytearray_reduce_ex__doc__}, + {"__reduce_ex__", (PyCFunction)bytearray_reduce_ex, METH_FASTCALL, bytearray_reduce_ex__doc__}, static PyObject * bytearray_reduce_ex_impl(PyByteArrayObject *self, int proto); static PyObject * -bytearray_reduce_ex(PyByteArrayObject *self, PyObject *args) +bytearray_reduce_ex(PyByteArrayObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; int proto = 0; - if (!PyArg_ParseTuple(args, "|i:__reduce_ex__", + if (!_PyArg_ParseStack(args, nargs, "|i:__reduce_ex__", &proto)) { goto exit; } + + if (!_PyArg_NoStackKeywords("__reduce_ex__", kwnames)) { + goto exit; + } return_value = bytearray_reduce_ex_impl(self, proto); exit: @@ -711,4 +743,4 @@ bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored)) { return bytearray_sizeof_impl(self); } -/*[clinic end generated code: output=225342a680391b9c input=a9049054013a1b77]*/ +/*[clinic end generated code: output=f5c364927425fae8 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/bytesobject.c.h b/Objects/clinic/bytesobject.c.h index a11ebd2774..c73b56023d 100644 --- a/Objects/clinic/bytesobject.c.h +++ b/Objects/clinic/bytesobject.c.h @@ -31,7 +31,7 @@ bytes_split(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kw PyObject *sep = Py_None; Py_ssize_t maxsplit = -1; - if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, &sep, &maxsplit)) { goto exit; } @@ -150,7 +150,7 @@ bytes_rsplit(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject *k PyObject *sep = Py_None; Py_ssize_t maxsplit = -1; - if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, &sep, &maxsplit)) { goto exit; } @@ -184,22 +184,26 @@ PyDoc_STRVAR(bytes_strip__doc__, "If the argument is omitted or None, strip leading and trailing ASCII whitespace."); #define BYTES_STRIP_METHODDEF \ - {"strip", (PyCFunction)bytes_strip, METH_VARARGS, bytes_strip__doc__}, + {"strip", (PyCFunction)bytes_strip, METH_FASTCALL, bytes_strip__doc__}, static PyObject * bytes_strip_impl(PyBytesObject *self, PyObject *bytes); static PyObject * -bytes_strip(PyBytesObject *self, PyObject *args) +bytes_strip(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; PyObject *bytes = Py_None; - if (!PyArg_UnpackTuple(args, "strip", + if (!_PyArg_UnpackStack(args, nargs, "strip", 0, 1, &bytes)) { goto exit; } + + if (!_PyArg_NoStackKeywords("strip", kwnames)) { + goto exit; + } return_value = bytes_strip_impl(self, bytes); exit: @@ -215,22 +219,26 @@ PyDoc_STRVAR(bytes_lstrip__doc__, "If the argument is omitted or None, strip leading ASCII whitespace."); #define BYTES_LSTRIP_METHODDEF \ - {"lstrip", (PyCFunction)bytes_lstrip, METH_VARARGS, bytes_lstrip__doc__}, + {"lstrip", (PyCFunction)bytes_lstrip, METH_FASTCALL, bytes_lstrip__doc__}, static PyObject * bytes_lstrip_impl(PyBytesObject *self, PyObject *bytes); static PyObject * -bytes_lstrip(PyBytesObject *self, PyObject *args) +bytes_lstrip(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; PyObject *bytes = Py_None; - if (!PyArg_UnpackTuple(args, "lstrip", + if (!_PyArg_UnpackStack(args, nargs, "lstrip", 0, 1, &bytes)) { goto exit; } + + if (!_PyArg_NoStackKeywords("lstrip", kwnames)) { + goto exit; + } return_value = bytes_lstrip_impl(self, bytes); exit: @@ -246,22 +254,26 @@ PyDoc_STRVAR(bytes_rstrip__doc__, "If the argument is omitted or None, strip trailing ASCII whitespace."); #define BYTES_RSTRIP_METHODDEF \ - {"rstrip", (PyCFunction)bytes_rstrip, METH_VARARGS, bytes_rstrip__doc__}, + {"rstrip", (PyCFunction)bytes_rstrip, METH_FASTCALL, bytes_rstrip__doc__}, static PyObject * bytes_rstrip_impl(PyBytesObject *self, PyObject *bytes); static PyObject * -bytes_rstrip(PyBytesObject *self, PyObject *args) +bytes_rstrip(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; PyObject *bytes = Py_None; - if (!PyArg_UnpackTuple(args, "rstrip", + if (!_PyArg_UnpackStack(args, nargs, "rstrip", 0, 1, &bytes)) { goto exit; } + + if (!_PyArg_NoStackKeywords("rstrip", kwnames)) { + goto exit; + } return_value = bytes_rstrip_impl(self, bytes); exit: @@ -296,7 +308,7 @@ bytes_translate(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject PyObject *table; PyObject *deletechars = NULL; - if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, &table, &deletechars)) { goto exit; } @@ -318,22 +330,26 @@ PyDoc_STRVAR(bytes_maketrans__doc__, "The bytes objects frm and to must be of the same length."); #define BYTES_MAKETRANS_METHODDEF \ - {"maketrans", (PyCFunction)bytes_maketrans, METH_VARARGS|METH_STATIC, bytes_maketrans__doc__}, + {"maketrans", (PyCFunction)bytes_maketrans, METH_FASTCALL|METH_STATIC, bytes_maketrans__doc__}, static PyObject * bytes_maketrans_impl(Py_buffer *frm, Py_buffer *to); static PyObject * -bytes_maketrans(void *null, PyObject *args) +bytes_maketrans(void *null, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; Py_buffer frm = {NULL, NULL}; Py_buffer to = {NULL, NULL}; - if (!PyArg_ParseTuple(args, "y*y*:maketrans", + if (!_PyArg_ParseStack(args, nargs, "y*y*:maketrans", &frm, &to)) { goto exit; } + + if (!_PyArg_NoStackKeywords("maketrans", kwnames)) { + goto exit; + } return_value = bytes_maketrans_impl(&frm, &to); exit: @@ -363,24 +379,28 @@ PyDoc_STRVAR(bytes_replace__doc__, "replaced."); #define BYTES_REPLACE_METHODDEF \ - {"replace", (PyCFunction)bytes_replace, METH_VARARGS, bytes_replace__doc__}, + {"replace", (PyCFunction)bytes_replace, METH_FASTCALL, bytes_replace__doc__}, static PyObject * bytes_replace_impl(PyBytesObject *self, Py_buffer *old, Py_buffer *new, Py_ssize_t count); static PyObject * -bytes_replace(PyBytesObject *self, PyObject *args) +bytes_replace(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; Py_buffer old = {NULL, NULL}; Py_buffer new = {NULL, NULL}; Py_ssize_t count = -1; - if (!PyArg_ParseTuple(args, "y*y*|n:replace", + if (!_PyArg_ParseStack(args, nargs, "y*y*|n:replace", &old, &new, &count)) { goto exit; } + + if (!_PyArg_NoStackKeywords("replace", kwnames)) { + goto exit; + } return_value = bytes_replace_impl(self, &old, &new, count); exit: @@ -427,7 +447,7 @@ bytes_decode(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObject *k const char *encoding = NULL; const char *errors = NULL; - if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, &encoding, &errors)) { goto exit; } @@ -460,7 +480,7 @@ bytes_splitlines(PyBytesObject *self, PyObject **args, Py_ssize_t nargs, PyObjec static _PyArg_Parser _parser = {"|i:splitlines", _keywords, 0}; int keepends = 0; - if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser, + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, &keepends)) { goto exit; } @@ -499,4 +519,4 @@ bytes_fromhex(PyTypeObject *type, PyObject *arg) exit: return return_value; } -/*[clinic end generated code: output=2dc3c93cfd2dc440 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=2504c1225108d348 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/dictobject.c.h b/Objects/clinic/dictobject.c.h index d0cdfc3eda..97918e82a7 100644 --- a/Objects/clinic/dictobject.c.h +++ b/Objects/clinic/dictobject.c.h @@ -6,26 +6,30 @@ PyDoc_STRVAR(dict_fromkeys__doc__, "fromkeys($type, iterable, value=None, /)\n" "--\n" "\n" -"Returns a new dict with keys from iterable and values equal to value."); +"Create a new dictionary with keys from iterable and values set to value."); #define DICT_FROMKEYS_METHODDEF \ - {"fromkeys", (PyCFunction)dict_fromkeys, METH_VARARGS|METH_CLASS, dict_fromkeys__doc__}, + {"fromkeys", (PyCFunction)dict_fromkeys, METH_FASTCALL|METH_CLASS, dict_fromkeys__doc__}, static PyObject * dict_fromkeys_impl(PyTypeObject *type, PyObject *iterable, PyObject *value); static PyObject * -dict_fromkeys(PyTypeObject *type, PyObject *args) +dict_fromkeys(PyTypeObject *type, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; PyObject *iterable; PyObject *value = Py_None; - if (!PyArg_UnpackTuple(args, "fromkeys", + if (!_PyArg_UnpackStack(args, nargs, "fromkeys", 1, 2, &iterable, &value)) { goto exit; } + + if (!_PyArg_NoStackKeywords("fromkeys", kwnames)) { + goto exit; + } return_value = dict_fromkeys_impl(type, iterable, value); exit: @@ -36,8 +40,79 @@ PyDoc_STRVAR(dict___contains____doc__, "__contains__($self, key, /)\n" "--\n" "\n" -"True if D has a key k, else False."); +"True if the dictionary has a specified key, else False."); #define DICT___CONTAINS___METHODDEF \ {"__contains__", (PyCFunction)dict___contains__, METH_O|METH_COEXIST, dict___contains____doc__}, -/*[clinic end generated code: output=926326109e3d9839 input=a9049054013a1b77]*/ + +PyDoc_STRVAR(dict_get__doc__, +"get($self, key, default=None, /)\n" +"--\n" +"\n" +"Return the value for key if key is in the dictionary, else default."); + +#define DICT_GET_METHODDEF \ + {"get", (PyCFunction)dict_get, METH_FASTCALL, dict_get__doc__}, + +static PyObject * +dict_get_impl(PyDictObject *self, PyObject *key, PyObject *default_value); + +static PyObject * +dict_get(PyDictObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + PyObject *key; + PyObject *default_value = Py_None; + + if (!_PyArg_UnpackStack(args, nargs, "get", + 1, 2, + &key, &default_value)) { + goto exit; + } + + if (!_PyArg_NoStackKeywords("get", kwnames)) { + goto exit; + } + return_value = dict_get_impl(self, key, default_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(dict_setdefault__doc__, +"setdefault($self, key, default=None, /)\n" +"--\n" +"\n" +"Insert key with a value of default if key is not in the dictionary.\n" +"\n" +"Return the value for key if key is in the dictionary, else default."); + +#define DICT_SETDEFAULT_METHODDEF \ + {"setdefault", (PyCFunction)dict_setdefault, METH_FASTCALL, dict_setdefault__doc__}, + +static PyObject * +dict_setdefault_impl(PyDictObject *self, PyObject *key, + PyObject *default_value); + +static PyObject * +dict_setdefault(PyDictObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + PyObject *key; + PyObject *default_value = Py_None; + + if (!_PyArg_UnpackStack(args, nargs, "setdefault", + 1, 2, + &key, &default_value)) { + goto exit; + } + + if (!_PyArg_NoStackKeywords("setdefault", kwnames)) { + goto exit; + } + return_value = dict_setdefault_impl(self, key, default_value); + +exit: + return return_value; +} +/*[clinic end generated code: output=91aa6a9f3c402b1b input=a9049054013a1b77]*/ diff --git a/Objects/clinic/enumobject.c.h b/Objects/clinic/enumobject.c.h new file mode 100644 index 0000000000..0f05cf84cb --- /dev/null +++ b/Objects/clinic/enumobject.c.h @@ -0,0 +1,71 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(enum_new__doc__, +"enumerate(iterable, start=0)\n" +"--\n" +"\n" +"Return an enumerate object.\n" +"\n" +" iterable\n" +" an object supporting iteration\n" +"\n" +"The enumerate object yields pairs containing a count (from start, which\n" +"defaults to zero) and a value yielded by the iterable argument.\n" +"\n" +"enumerate is useful for obtaining an indexed list:\n" +" (0, seq[0]), (1, seq[1]), (2, seq[2]), ..."); + +static PyObject * +enum_new_impl(PyTypeObject *type, PyObject *iterable, PyObject *start); + +static PyObject * +enum_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"iterable", "start", NULL}; + static _PyArg_Parser _parser = {"O|O:enumerate", _keywords, 0}; + PyObject *iterable; + PyObject *start = 0; + + if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser, + &iterable, &start)) { + goto exit; + } + return_value = enum_new_impl(type, iterable, start); + +exit: + return return_value; +} + +PyDoc_STRVAR(reversed_new__doc__, +"reversed(sequence, /)\n" +"--\n" +"\n" +"Return a reverse iterator over the values of the given sequence."); + +static PyObject * +reversed_new_impl(PyTypeObject *type, PyObject *seq); + +static PyObject * +reversed_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + PyObject *seq; + + if ((type == &PyReversed_Type) && + !_PyArg_NoKeywords("reversed", kwargs)) { + goto exit; + } + if (!PyArg_UnpackTuple(args, "reversed", + 1, 1, + &seq)) { + goto exit; + } + return_value = reversed_new_impl(type, seq); + +exit: + return return_value; +} +/*[clinic end generated code: output=9008c36999c57218 input=a9049054013a1b77]*/ diff --git a/Objects/clinic/odictobject.c.h b/Objects/clinic/odictobject.c.h new file mode 100644 index 0000000000..0e5092cf7a --- /dev/null +++ b/Objects/clinic/odictobject.c.h @@ -0,0 +1,134 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(OrderedDict_fromkeys__doc__, +"fromkeys($type, /, iterable, value=None)\n" +"--\n" +"\n" +"Create a new ordered dictionary with keys from iterable and values set to value."); + +#define ORDEREDDICT_FROMKEYS_METHODDEF \ + {"fromkeys", (PyCFunction)OrderedDict_fromkeys, METH_FASTCALL|METH_CLASS, OrderedDict_fromkeys__doc__}, + +static PyObject * +OrderedDict_fromkeys_impl(PyTypeObject *type, PyObject *seq, PyObject *value); + +static PyObject * +OrderedDict_fromkeys(PyTypeObject *type, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"iterable", "value", NULL}; + static _PyArg_Parser _parser = {"O|O:fromkeys", _keywords, 0}; + PyObject *seq; + PyObject *value = Py_None; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + &seq, &value)) { + goto exit; + } + return_value = OrderedDict_fromkeys_impl(type, seq, value); + +exit: + return return_value; +} + +PyDoc_STRVAR(OrderedDict_setdefault__doc__, +"setdefault($self, /, key, default=None)\n" +"--\n" +"\n" +"Insert key with a value of default if key is not in the dictionary.\n" +"\n" +"Return the value for key if key is in the dictionary, else default."); + +#define ORDEREDDICT_SETDEFAULT_METHODDEF \ + {"setdefault", (PyCFunction)OrderedDict_setdefault, METH_FASTCALL, OrderedDict_setdefault__doc__}, + +static PyObject * +OrderedDict_setdefault_impl(PyODictObject *self, PyObject *key, + PyObject *default_value); + +static PyObject * +OrderedDict_setdefault(PyODictObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"key", "default", NULL}; + static _PyArg_Parser _parser = {"O|O:setdefault", _keywords, 0}; + PyObject *key; + PyObject *default_value = Py_None; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + &key, &default_value)) { + goto exit; + } + return_value = OrderedDict_setdefault_impl(self, key, default_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(OrderedDict_popitem__doc__, +"popitem($self, /, last=True)\n" +"--\n" +"\n" +"Remove and return a (key, value) pair from the dictionary.\n" +"\n" +"Pairs are returned in LIFO order if last is true or FIFO order if false."); + +#define ORDEREDDICT_POPITEM_METHODDEF \ + {"popitem", (PyCFunction)OrderedDict_popitem, METH_FASTCALL, OrderedDict_popitem__doc__}, + +static PyObject * +OrderedDict_popitem_impl(PyODictObject *self, int last); + +static PyObject * +OrderedDict_popitem(PyODictObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"last", NULL}; + static _PyArg_Parser _parser = {"|p:popitem", _keywords, 0}; + int last = 1; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + &last)) { + goto exit; + } + return_value = OrderedDict_popitem_impl(self, last); + +exit: + return return_value; +} + +PyDoc_STRVAR(OrderedDict_move_to_end__doc__, +"move_to_end($self, /, key, last=True)\n" +"--\n" +"\n" +"Move an existing element to the end (or beginning if last is false).\n" +"\n" +"Raise KeyError if the element does not exist."); + +#define ORDEREDDICT_MOVE_TO_END_METHODDEF \ + {"move_to_end", (PyCFunction)OrderedDict_move_to_end, METH_FASTCALL, OrderedDict_move_to_end__doc__}, + +static PyObject * +OrderedDict_move_to_end_impl(PyODictObject *self, PyObject *key, int last); + +static PyObject * +OrderedDict_move_to_end(PyODictObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"key", "last", NULL}; + static _PyArg_Parser _parser = {"O|p:move_to_end", _keywords, 0}; + PyObject *key; + int last = 1; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + &key, &last)) { + goto exit; + } + return_value = OrderedDict_move_to_end_impl(self, key, last); + +exit: + return return_value; +} +/*[clinic end generated code: output=a19a24ac37b42e5e input=a9049054013a1b77]*/ diff --git a/Objects/clinic/unicodeobject.c.h b/Objects/clinic/unicodeobject.c.h index 891e90c312..509405e527 100644 --- a/Objects/clinic/unicodeobject.c.h +++ b/Objects/clinic/unicodeobject.c.h @@ -2,6 +2,816 @@ preserve [clinic start generated code]*/ +PyDoc_STRVAR(unicode_title__doc__, +"title($self, /)\n" +"--\n" +"\n" +"Return a version of the string where each word is titlecased.\n" +"\n" +"More specifically, words start with uppercased characters and all remaining\n" +"cased characters have lower case."); + +#define UNICODE_TITLE_METHODDEF \ + {"title", (PyCFunction)unicode_title, METH_NOARGS, unicode_title__doc__}, + +static PyObject * +unicode_title_impl(PyObject *self); + +static PyObject * +unicode_title(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_title_impl(self); +} + +PyDoc_STRVAR(unicode_capitalize__doc__, +"capitalize($self, /)\n" +"--\n" +"\n" +"Return a capitalized version of the string.\n" +"\n" +"More specifically, make the first character have upper case and the rest lower\n" +"case."); + +#define UNICODE_CAPITALIZE_METHODDEF \ + {"capitalize", (PyCFunction)unicode_capitalize, METH_NOARGS, unicode_capitalize__doc__}, + +static PyObject * +unicode_capitalize_impl(PyObject *self); + +static PyObject * +unicode_capitalize(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_capitalize_impl(self); +} + +PyDoc_STRVAR(unicode_casefold__doc__, +"casefold($self, /)\n" +"--\n" +"\n" +"Return a version of the string suitable for caseless comparisons."); + +#define UNICODE_CASEFOLD_METHODDEF \ + {"casefold", (PyCFunction)unicode_casefold, METH_NOARGS, unicode_casefold__doc__}, + +static PyObject * +unicode_casefold_impl(PyObject *self); + +static PyObject * +unicode_casefold(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_casefold_impl(self); +} + +PyDoc_STRVAR(unicode_center__doc__, +"center($self, width, fillchar=\' \', /)\n" +"--\n" +"\n" +"Return a centered string of length width.\n" +"\n" +"Padding is done using the specified fill character (default is a space)."); + +#define UNICODE_CENTER_METHODDEF \ + {"center", (PyCFunction)unicode_center, METH_FASTCALL, unicode_center__doc__}, + +static PyObject * +unicode_center_impl(PyObject *self, Py_ssize_t width, Py_UCS4 fillchar); + +static PyObject * +unicode_center(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t width; + Py_UCS4 fillchar = ' '; + + if (!_PyArg_ParseStack(args, nargs, "n|O&:center", + &width, convert_uc, &fillchar)) { + goto exit; + } + + if (!_PyArg_NoStackKeywords("center", kwnames)) { + goto exit; + } + return_value = unicode_center_impl(self, width, fillchar); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_encode__doc__, +"encode($self, /, encoding=\'utf-8\', errors=\'strict\')\n" +"--\n" +"\n" +"Encode the string using the codec registered for encoding.\n" +"\n" +" encoding\n" +" The encoding in which to encode the string.\n" +" errors\n" +" The error handling scheme to use for encoding errors.\n" +" The default is \'strict\' meaning that encoding errors raise a\n" +" UnicodeEncodeError. Other possible values are \'ignore\', \'replace\' and\n" +" \'xmlcharrefreplace\' as well as any other name registered with\n" +" codecs.register_error that can handle UnicodeEncodeErrors."); + +#define UNICODE_ENCODE_METHODDEF \ + {"encode", (PyCFunction)unicode_encode, METH_FASTCALL, unicode_encode__doc__}, + +static PyObject * +unicode_encode_impl(PyObject *self, const char *encoding, const char *errors); + +static PyObject * +unicode_encode(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"encoding", "errors", NULL}; + static _PyArg_Parser _parser = {"|ss:encode", _keywords, 0}; + const char *encoding = NULL; + const char *errors = NULL; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + &encoding, &errors)) { + goto exit; + } + return_value = unicode_encode_impl(self, encoding, errors); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_expandtabs__doc__, +"expandtabs($self, /, tabsize=8)\n" +"--\n" +"\n" +"Return a copy where all tab characters are expanded using spaces.\n" +"\n" +"If tabsize is not given, a tab size of 8 characters is assumed."); + +#define UNICODE_EXPANDTABS_METHODDEF \ + {"expandtabs", (PyCFunction)unicode_expandtabs, METH_FASTCALL, unicode_expandtabs__doc__}, + +static PyObject * +unicode_expandtabs_impl(PyObject *self, int tabsize); + +static PyObject * +unicode_expandtabs(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"tabsize", NULL}; + static _PyArg_Parser _parser = {"|i:expandtabs", _keywords, 0}; + int tabsize = 8; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + &tabsize)) { + goto exit; + } + return_value = unicode_expandtabs_impl(self, tabsize); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_islower__doc__, +"islower($self, /)\n" +"--\n" +"\n" +"Return True if the string is a lowercase string, False otherwise.\n" +"\n" +"A string is lowercase if all cased characters in the string are lowercase and\n" +"there is at least one cased character in the string."); + +#define UNICODE_ISLOWER_METHODDEF \ + {"islower", (PyCFunction)unicode_islower, METH_NOARGS, unicode_islower__doc__}, + +static PyObject * +unicode_islower_impl(PyObject *self); + +static PyObject * +unicode_islower(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_islower_impl(self); +} + +PyDoc_STRVAR(unicode_isupper__doc__, +"isupper($self, /)\n" +"--\n" +"\n" +"Return True if the string is an uppercase string, False otherwise.\n" +"\n" +"A string is uppercase if all cased characters in the string are uppercase and\n" +"there is at least one cased character in the string."); + +#define UNICODE_ISUPPER_METHODDEF \ + {"isupper", (PyCFunction)unicode_isupper, METH_NOARGS, unicode_isupper__doc__}, + +static PyObject * +unicode_isupper_impl(PyObject *self); + +static PyObject * +unicode_isupper(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_isupper_impl(self); +} + +PyDoc_STRVAR(unicode_istitle__doc__, +"istitle($self, /)\n" +"--\n" +"\n" +"Return True if the string is a title-cased string, False otherwise.\n" +"\n" +"In a title-cased string, upper- and title-case characters may only\n" +"follow uncased characters and lowercase characters only cased ones."); + +#define UNICODE_ISTITLE_METHODDEF \ + {"istitle", (PyCFunction)unicode_istitle, METH_NOARGS, unicode_istitle__doc__}, + +static PyObject * +unicode_istitle_impl(PyObject *self); + +static PyObject * +unicode_istitle(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_istitle_impl(self); +} + +PyDoc_STRVAR(unicode_isspace__doc__, +"isspace($self, /)\n" +"--\n" +"\n" +"Return True if the string is a whitespace string, False otherwise.\n" +"\n" +"A string is whitespace if all characters in the string are whitespace and there\n" +"is at least one character in the string."); + +#define UNICODE_ISSPACE_METHODDEF \ + {"isspace", (PyCFunction)unicode_isspace, METH_NOARGS, unicode_isspace__doc__}, + +static PyObject * +unicode_isspace_impl(PyObject *self); + +static PyObject * +unicode_isspace(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_isspace_impl(self); +} + +PyDoc_STRVAR(unicode_isalpha__doc__, +"isalpha($self, /)\n" +"--\n" +"\n" +"Return True if the string is an alphabetic string, False otherwise.\n" +"\n" +"A string is alphabetic if all characters in the string are alphabetic and there\n" +"is at least one character in the string."); + +#define UNICODE_ISALPHA_METHODDEF \ + {"isalpha", (PyCFunction)unicode_isalpha, METH_NOARGS, unicode_isalpha__doc__}, + +static PyObject * +unicode_isalpha_impl(PyObject *self); + +static PyObject * +unicode_isalpha(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_isalpha_impl(self); +} + +PyDoc_STRVAR(unicode_isalnum__doc__, +"isalnum($self, /)\n" +"--\n" +"\n" +"Return True if the string is an alpha-numeric string, False otherwise.\n" +"\n" +"A string is alpha-numeric if all characters in the string are alpha-numeric and\n" +"there is at least one character in the string."); + +#define UNICODE_ISALNUM_METHODDEF \ + {"isalnum", (PyCFunction)unicode_isalnum, METH_NOARGS, unicode_isalnum__doc__}, + +static PyObject * +unicode_isalnum_impl(PyObject *self); + +static PyObject * +unicode_isalnum(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_isalnum_impl(self); +} + +PyDoc_STRVAR(unicode_isdecimal__doc__, +"isdecimal($self, /)\n" +"--\n" +"\n" +"Return True if the string is a decimal string, False otherwise.\n" +"\n" +"A string is a decimal string if all characters in the string are decimal and\n" +"there is at least one character in the string."); + +#define UNICODE_ISDECIMAL_METHODDEF \ + {"isdecimal", (PyCFunction)unicode_isdecimal, METH_NOARGS, unicode_isdecimal__doc__}, + +static PyObject * +unicode_isdecimal_impl(PyObject *self); + +static PyObject * +unicode_isdecimal(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_isdecimal_impl(self); +} + +PyDoc_STRVAR(unicode_isdigit__doc__, +"isdigit($self, /)\n" +"--\n" +"\n" +"Return True if the string is a digit string, False otherwise.\n" +"\n" +"A string is a digit string if all characters in the string are digits and there\n" +"is at least one character in the string."); + +#define UNICODE_ISDIGIT_METHODDEF \ + {"isdigit", (PyCFunction)unicode_isdigit, METH_NOARGS, unicode_isdigit__doc__}, + +static PyObject * +unicode_isdigit_impl(PyObject *self); + +static PyObject * +unicode_isdigit(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_isdigit_impl(self); +} + +PyDoc_STRVAR(unicode_isnumeric__doc__, +"isnumeric($self, /)\n" +"--\n" +"\n" +"Return True if the string is a numeric string, False otherwise.\n" +"\n" +"A string is numeric if all characters in the string are numeric and there is at\n" +"least one character in the string."); + +#define UNICODE_ISNUMERIC_METHODDEF \ + {"isnumeric", (PyCFunction)unicode_isnumeric, METH_NOARGS, unicode_isnumeric__doc__}, + +static PyObject * +unicode_isnumeric_impl(PyObject *self); + +static PyObject * +unicode_isnumeric(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_isnumeric_impl(self); +} + +PyDoc_STRVAR(unicode_isidentifier__doc__, +"isidentifier($self, /)\n" +"--\n" +"\n" +"Return True if the string is a valid Python identifier, False otherwise.\n" +"\n" +"Use keyword.iskeyword() to test for reserved identifiers such as \"def\" and\n" +"\"class\"."); + +#define UNICODE_ISIDENTIFIER_METHODDEF \ + {"isidentifier", (PyCFunction)unicode_isidentifier, METH_NOARGS, unicode_isidentifier__doc__}, + +static PyObject * +unicode_isidentifier_impl(PyObject *self); + +static PyObject * +unicode_isidentifier(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_isidentifier_impl(self); +} + +PyDoc_STRVAR(unicode_isprintable__doc__, +"isprintable($self, /)\n" +"--\n" +"\n" +"Return True if the string is printable, False otherwise.\n" +"\n" +"A string is printable if all of its characters are considered printable in\n" +"repr() or if it is empty."); + +#define UNICODE_ISPRINTABLE_METHODDEF \ + {"isprintable", (PyCFunction)unicode_isprintable, METH_NOARGS, unicode_isprintable__doc__}, + +static PyObject * +unicode_isprintable_impl(PyObject *self); + +static PyObject * +unicode_isprintable(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_isprintable_impl(self); +} + +PyDoc_STRVAR(unicode_join__doc__, +"join($self, iterable, /)\n" +"--\n" +"\n" +"Concatenate any number of strings.\n" +"\n" +"The string whose method is called is inserted in between each given string.\n" +"The result is returned as a new string.\n" +"\n" +"Example: \'.\'.join([\'ab\', \'pq\', \'rs\']) -> \'ab.pq.rs\'"); + +#define UNICODE_JOIN_METHODDEF \ + {"join", (PyCFunction)unicode_join, METH_O, unicode_join__doc__}, + +PyDoc_STRVAR(unicode_ljust__doc__, +"ljust($self, width, fillchar=\' \', /)\n" +"--\n" +"\n" +"Return a left-justified string of length width.\n" +"\n" +"Padding is done using the specified fill character (default is a space)."); + +#define UNICODE_LJUST_METHODDEF \ + {"ljust", (PyCFunction)unicode_ljust, METH_FASTCALL, unicode_ljust__doc__}, + +static PyObject * +unicode_ljust_impl(PyObject *self, Py_ssize_t width, Py_UCS4 fillchar); + +static PyObject * +unicode_ljust(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t width; + Py_UCS4 fillchar = ' '; + + if (!_PyArg_ParseStack(args, nargs, "n|O&:ljust", + &width, convert_uc, &fillchar)) { + goto exit; + } + + if (!_PyArg_NoStackKeywords("ljust", kwnames)) { + goto exit; + } + return_value = unicode_ljust_impl(self, width, fillchar); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_lower__doc__, +"lower($self, /)\n" +"--\n" +"\n" +"Return a copy of the string converted to lowercase."); + +#define UNICODE_LOWER_METHODDEF \ + {"lower", (PyCFunction)unicode_lower, METH_NOARGS, unicode_lower__doc__}, + +static PyObject * +unicode_lower_impl(PyObject *self); + +static PyObject * +unicode_lower(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_lower_impl(self); +} + +PyDoc_STRVAR(unicode_strip__doc__, +"strip($self, chars=None, /)\n" +"--\n" +"\n" +"Return a copy of the string with leading and trailing whitespace remove.\n" +"\n" +"If chars is given and not None, remove characters in chars instead."); + +#define UNICODE_STRIP_METHODDEF \ + {"strip", (PyCFunction)unicode_strip, METH_FASTCALL, unicode_strip__doc__}, + +static PyObject * +unicode_strip_impl(PyObject *self, PyObject *chars); + +static PyObject * +unicode_strip(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + PyObject *chars = Py_None; + + if (!_PyArg_UnpackStack(args, nargs, "strip", + 0, 1, + &chars)) { + goto exit; + } + + if (!_PyArg_NoStackKeywords("strip", kwnames)) { + goto exit; + } + return_value = unicode_strip_impl(self, chars); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_lstrip__doc__, +"lstrip($self, chars=None, /)\n" +"--\n" +"\n" +"Return a copy of the string with leading whitespace removed.\n" +"\n" +"If chars is given and not None, remove characters in chars instead."); + +#define UNICODE_LSTRIP_METHODDEF \ + {"lstrip", (PyCFunction)unicode_lstrip, METH_FASTCALL, unicode_lstrip__doc__}, + +static PyObject * +unicode_lstrip_impl(PyObject *self, PyObject *chars); + +static PyObject * +unicode_lstrip(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + PyObject *chars = NULL; + + if (!_PyArg_UnpackStack(args, nargs, "lstrip", + 0, 1, + &chars)) { + goto exit; + } + + if (!_PyArg_NoStackKeywords("lstrip", kwnames)) { + goto exit; + } + return_value = unicode_lstrip_impl(self, chars); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_rstrip__doc__, +"rstrip($self, chars=None, /)\n" +"--\n" +"\n" +"Return a copy of the string with trailing whitespace removed.\n" +"\n" +"If chars is given and not None, remove characters in chars instead."); + +#define UNICODE_RSTRIP_METHODDEF \ + {"rstrip", (PyCFunction)unicode_rstrip, METH_FASTCALL, unicode_rstrip__doc__}, + +static PyObject * +unicode_rstrip_impl(PyObject *self, PyObject *chars); + +static PyObject * +unicode_rstrip(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + PyObject *chars = NULL; + + if (!_PyArg_UnpackStack(args, nargs, "rstrip", + 0, 1, + &chars)) { + goto exit; + } + + if (!_PyArg_NoStackKeywords("rstrip", kwnames)) { + goto exit; + } + return_value = unicode_rstrip_impl(self, chars); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_replace__doc__, +"replace($self, old, new, count=-1, /)\n" +"--\n" +"\n" +"Return a copy with all occurrences of substring old replaced by new.\n" +"\n" +" count\n" +" Maximum number of occurrences to replace.\n" +" -1 (the default value) means replace all occurrences.\n" +"\n" +"If the optional argument count is given, only the first count occurrences are\n" +"replaced."); + +#define UNICODE_REPLACE_METHODDEF \ + {"replace", (PyCFunction)unicode_replace, METH_FASTCALL, unicode_replace__doc__}, + +static PyObject * +unicode_replace_impl(PyObject *self, PyObject *old, PyObject *new, + Py_ssize_t count); + +static PyObject * +unicode_replace(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + PyObject *old; + PyObject *new; + Py_ssize_t count = -1; + + if (!_PyArg_ParseStack(args, nargs, "UU|n:replace", + &old, &new, &count)) { + goto exit; + } + + if (!_PyArg_NoStackKeywords("replace", kwnames)) { + goto exit; + } + return_value = unicode_replace_impl(self, old, new, count); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_rjust__doc__, +"rjust($self, width, fillchar=\' \', /)\n" +"--\n" +"\n" +"Return a right-justified string of length width.\n" +"\n" +"Padding is done using the specified fill character (default is a space)."); + +#define UNICODE_RJUST_METHODDEF \ + {"rjust", (PyCFunction)unicode_rjust, METH_FASTCALL, unicode_rjust__doc__}, + +static PyObject * +unicode_rjust_impl(PyObject *self, Py_ssize_t width, Py_UCS4 fillchar); + +static PyObject * +unicode_rjust(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + Py_ssize_t width; + Py_UCS4 fillchar = ' '; + + if (!_PyArg_ParseStack(args, nargs, "n|O&:rjust", + &width, convert_uc, &fillchar)) { + goto exit; + } + + if (!_PyArg_NoStackKeywords("rjust", kwnames)) { + goto exit; + } + return_value = unicode_rjust_impl(self, width, fillchar); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_split__doc__, +"split($self, /, sep=None, maxsplit=-1)\n" +"--\n" +"\n" +"Return a list of the words in the string, using sep as the delimiter string.\n" +"\n" +" sep\n" +" The delimiter according which to split the string.\n" +" None (the default value) means split according to any whitespace,\n" +" and discard empty strings from the result.\n" +" maxsplit\n" +" Maximum number of splits to do.\n" +" -1 (the default value) means no limit."); + +#define UNICODE_SPLIT_METHODDEF \ + {"split", (PyCFunction)unicode_split, METH_FASTCALL, unicode_split__doc__}, + +static PyObject * +unicode_split_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit); + +static PyObject * +unicode_split(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"sep", "maxsplit", NULL}; + static _PyArg_Parser _parser = {"|On:split", _keywords, 0}; + PyObject *sep = Py_None; + Py_ssize_t maxsplit = -1; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + &sep, &maxsplit)) { + goto exit; + } + return_value = unicode_split_impl(self, sep, maxsplit); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_partition__doc__, +"partition($self, sep, /)\n" +"--\n" +"\n" +"Partition the string into three parts using the given separator.\n" +"\n" +"This will search for the separator in the string. If the separator is found,\n" +"returns a 3-tuple containing the part before the separator, the separator\n" +"itself, and the part after it.\n" +"\n" +"If the separator is not found, returns a 3-tuple containing the original string\n" +"and two empty strings."); + +#define UNICODE_PARTITION_METHODDEF \ + {"partition", (PyCFunction)unicode_partition, METH_O, unicode_partition__doc__}, + +PyDoc_STRVAR(unicode_rpartition__doc__, +"rpartition($self, sep, /)\n" +"--\n" +"\n" +"Partition the string into three parts using the given separator.\n" +"\n" +"This will search for the separator in the string, starting and the end. If\n" +"the separator is found, returns a 3-tuple containing the part before the\n" +"separator, the separator itself, and the part after it.\n" +"\n" +"If the separator is not found, returns a 3-tuple containing two empty strings\n" +"and the original string."); + +#define UNICODE_RPARTITION_METHODDEF \ + {"rpartition", (PyCFunction)unicode_rpartition, METH_O, unicode_rpartition__doc__}, + +PyDoc_STRVAR(unicode_rsplit__doc__, +"rsplit($self, /, sep=None, maxsplit=-1)\n" +"--\n" +"\n" +"Return a list of the words in the string, using sep as the delimiter string.\n" +"\n" +" sep\n" +" The delimiter according which to split the string.\n" +" None (the default value) means split according to any whitespace,\n" +" and discard empty strings from the result.\n" +" maxsplit\n" +" Maximum number of splits to do.\n" +" -1 (the default value) means no limit.\n" +"\n" +"Splits are done starting at the end of the string and working to the front."); + +#define UNICODE_RSPLIT_METHODDEF \ + {"rsplit", (PyCFunction)unicode_rsplit, METH_FASTCALL, unicode_rsplit__doc__}, + +static PyObject * +unicode_rsplit_impl(PyObject *self, PyObject *sep, Py_ssize_t maxsplit); + +static PyObject * +unicode_rsplit(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"sep", "maxsplit", NULL}; + static _PyArg_Parser _parser = {"|On:rsplit", _keywords, 0}; + PyObject *sep = Py_None; + Py_ssize_t maxsplit = -1; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + &sep, &maxsplit)) { + goto exit; + } + return_value = unicode_rsplit_impl(self, sep, maxsplit); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_splitlines__doc__, +"splitlines($self, /, keepends=False)\n" +"--\n" +"\n" +"Return a list of the lines in the string, breaking at line boundaries.\n" +"\n" +"Line breaks are not included in the resulting list unless keepends is given and\n" +"true."); + +#define UNICODE_SPLITLINES_METHODDEF \ + {"splitlines", (PyCFunction)unicode_splitlines, METH_FASTCALL, unicode_splitlines__doc__}, + +static PyObject * +unicode_splitlines_impl(PyObject *self, int keepends); + +static PyObject * +unicode_splitlines(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + static const char * const _keywords[] = {"keepends", NULL}; + static _PyArg_Parser _parser = {"|i:splitlines", _keywords, 0}; + int keepends = 0; + + if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, + &keepends)) { + goto exit; + } + return_value = unicode_splitlines_impl(self, keepends); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_swapcase__doc__, +"swapcase($self, /)\n" +"--\n" +"\n" +"Convert uppercase characters to lowercase and lowercase characters to uppercase."); + +#define UNICODE_SWAPCASE_METHODDEF \ + {"swapcase", (PyCFunction)unicode_swapcase, METH_NOARGS, unicode_swapcase__doc__}, + +static PyObject * +unicode_swapcase_impl(PyObject *self); + +static PyObject * +unicode_swapcase(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_swapcase_impl(self); +} + PyDoc_STRVAR(unicode_maketrans__doc__, "maketrans(x, y=None, z=None, /)\n" "--\n" @@ -17,26 +827,139 @@ PyDoc_STRVAR(unicode_maketrans__doc__, "must be a string, whose characters will be mapped to None in the result."); #define UNICODE_MAKETRANS_METHODDEF \ - {"maketrans", (PyCFunction)unicode_maketrans, METH_VARARGS|METH_STATIC, unicode_maketrans__doc__}, + {"maketrans", (PyCFunction)unicode_maketrans, METH_FASTCALL|METH_STATIC, unicode_maketrans__doc__}, static PyObject * unicode_maketrans_impl(PyObject *x, PyObject *y, PyObject *z); static PyObject * -unicode_maketrans(void *null, PyObject *args) +unicode_maketrans(void *null, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) { PyObject *return_value = NULL; PyObject *x; PyObject *y = NULL; PyObject *z = NULL; - if (!PyArg_ParseTuple(args, "O|UU:maketrans", + if (!_PyArg_ParseStack(args, nargs, "O|UU:maketrans", &x, &y, &z)) { goto exit; } + + if (!_PyArg_NoStackKeywords("maketrans", kwnames)) { + goto exit; + } return_value = unicode_maketrans_impl(x, y, z); exit: return return_value; } -/*[clinic end generated code: output=4a86dd108d92d104 input=a9049054013a1b77]*/ + +PyDoc_STRVAR(unicode_translate__doc__, +"translate($self, table, /)\n" +"--\n" +"\n" +"Replace each character in the string using the given translation table.\n" +"\n" +" table\n" +" Translation table, which must be a mapping of Unicode ordinals to\n" +" Unicode ordinals, strings, or None.\n" +"\n" +"The table must implement lookup/indexing via __getitem__, for instance a\n" +"dictionary or list. If this operation raises LookupError, the character is\n" +"left untouched. Characters mapped to None are deleted."); + +#define UNICODE_TRANSLATE_METHODDEF \ + {"translate", (PyCFunction)unicode_translate, METH_O, unicode_translate__doc__}, + +PyDoc_STRVAR(unicode_upper__doc__, +"upper($self, /)\n" +"--\n" +"\n" +"Return a copy of the string converted to uppercase."); + +#define UNICODE_UPPER_METHODDEF \ + {"upper", (PyCFunction)unicode_upper, METH_NOARGS, unicode_upper__doc__}, + +static PyObject * +unicode_upper_impl(PyObject *self); + +static PyObject * +unicode_upper(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_upper_impl(self); +} + +PyDoc_STRVAR(unicode_zfill__doc__, +"zfill($self, width, /)\n" +"--\n" +"\n" +"Pad a numeric string with zeros on the left, to fill a field of the given width.\n" +"\n" +"The string is never truncated."); + +#define UNICODE_ZFILL_METHODDEF \ + {"zfill", (PyCFunction)unicode_zfill, METH_O, unicode_zfill__doc__}, + +static PyObject * +unicode_zfill_impl(PyObject *self, Py_ssize_t width); + +static PyObject * +unicode_zfill(PyObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + Py_ssize_t width; + + if (!PyArg_Parse(arg, "n:zfill", &width)) { + goto exit; + } + return_value = unicode_zfill_impl(self, width); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode___format____doc__, +"__format__($self, format_spec, /)\n" +"--\n" +"\n" +"Return a formatted version of the string as described by format_spec."); + +#define UNICODE___FORMAT___METHODDEF \ + {"__format__", (PyCFunction)unicode___format__, METH_O, unicode___format____doc__}, + +static PyObject * +unicode___format___impl(PyObject *self, PyObject *format_spec); + +static PyObject * +unicode___format__(PyObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + PyObject *format_spec; + + if (!PyArg_Parse(arg, "U:__format__", &format_spec)) { + goto exit; + } + return_value = unicode___format___impl(self, format_spec); + +exit: + return return_value; +} + +PyDoc_STRVAR(unicode_sizeof__doc__, +"__sizeof__($self, /)\n" +"--\n" +"\n" +"Return the size of the string in memory, in bytes."); + +#define UNICODE_SIZEOF_METHODDEF \ + {"__sizeof__", (PyCFunction)unicode_sizeof, METH_NOARGS, unicode_sizeof__doc__}, + +static PyObject * +unicode_sizeof_impl(PyObject *self); + +static PyObject * +unicode_sizeof(PyObject *self, PyObject *Py_UNUSED(ignored)) +{ + return unicode_sizeof_impl(self); +} +/*[clinic end generated code: output=88b06f61edd282f9 input=a9049054013a1b77]*/ |