summaryrefslogtreecommitdiffstats
path: root/Objects/clinic/bytearrayobject.c.h
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/clinic/bytearrayobject.c.h')
-rw-r--r--Objects/clinic/bytearrayobject.c.h150
1 files changed, 134 insertions, 16 deletions
diff --git a/Objects/clinic/bytearrayobject.c.h b/Objects/clinic/bytearrayobject.c.h
index a4669f5..da1dc6a 100644
--- a/Objects/clinic/bytearrayobject.c.h
+++ b/Objects/clinic/bytearrayobject.c.h
@@ -62,14 +62,22 @@ bytearray_translate(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t n
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"", "delete", NULL};
- static _PyArg_Parser _parser = {"O|O:translate", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "translate", 0};
+ PyObject *argsbuf[2];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
PyObject *table;
PyObject *deletechars = NULL;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &table, &deletechars)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
+ if (!args) {
goto exit;
}
+ table = args[0];
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ deletechars = args[1];
+skip_optional_pos:
return_value = bytearray_translate_impl(self, table, deletechars);
exit:
@@ -239,14 +247,43 @@ bytearray_split(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t nargs
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"sep", "maxsplit", NULL};
- static _PyArg_Parser _parser = {"|On:split", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "split", 0};
+ PyObject *argsbuf[2];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
PyObject *sep = Py_None;
Py_ssize_t maxsplit = -1;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &sep, &maxsplit)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ if (args[0]) {
+ sep = args[0];
+ if (!--noptargs) {
+ goto skip_optional_pos;
+ }
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = PyNumber_Index(args[1]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ maxsplit = ival;
+ }
+skip_optional_pos:
return_value = bytearray_split_impl(self, sep, maxsplit);
exit:
@@ -314,14 +351,43 @@ bytearray_rsplit(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t narg
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"sep", "maxsplit", NULL};
- static _PyArg_Parser _parser = {"|On:rsplit", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "rsplit", 0};
+ PyObject *argsbuf[2];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
PyObject *sep = Py_None;
Py_ssize_t maxsplit = -1;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &sep, &maxsplit)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ if (args[0]) {
+ sep = args[0];
+ if (!--noptargs) {
+ goto skip_optional_pos;
+ }
+ }
+ if (PyFloat_Check(args[1])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
goto exit;
}
+ {
+ Py_ssize_t ival = -1;
+ PyObject *iobj = PyNumber_Index(args[1]);
+ if (iobj != NULL) {
+ ival = PyLong_AsSsize_t(iobj);
+ Py_DECREF(iobj);
+ }
+ if (ival == -1 && PyErr_Occurred()) {
+ goto exit;
+ }
+ maxsplit = ival;
+ }
+skip_optional_pos:
return_value = bytearray_rsplit_impl(self, sep, maxsplit);
exit:
@@ -654,14 +720,51 @@ bytearray_decode(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t narg
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"encoding", "errors", NULL};
- static _PyArg_Parser _parser = {"|ss:decode", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "decode", 0};
+ PyObject *argsbuf[2];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
const char *encoding = NULL;
const char *errors = NULL;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &encoding, &errors)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf);
+ if (!args) {
goto exit;
}
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ if (args[0]) {
+ if (!PyUnicode_Check(args[0])) {
+ _PyArg_BadArgument("decode", 1, "str", args[0]);
+ goto exit;
+ }
+ Py_ssize_t encoding_length;
+ encoding = PyUnicode_AsUTF8AndSize(args[0], &encoding_length);
+ if (encoding == NULL) {
+ goto exit;
+ }
+ if (strlen(encoding) != (size_t)encoding_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+ if (!--noptargs) {
+ goto skip_optional_pos;
+ }
+ }
+ if (!PyUnicode_Check(args[1])) {
+ _PyArg_BadArgument("decode", 2, "str", args[1]);
+ goto exit;
+ }
+ Py_ssize_t errors_length;
+ errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
+ if (errors == NULL) {
+ goto exit;
+ }
+ if (strlen(errors) != (size_t)errors_length) {
+ PyErr_SetString(PyExc_ValueError, "embedded null character");
+ goto exit;
+ }
+skip_optional_pos:
return_value = bytearray_decode_impl(self, encoding, errors);
exit:
@@ -701,13 +804,28 @@ bytearray_splitlines(PyByteArrayObject *self, PyObject *const *args, Py_ssize_t
{
PyObject *return_value = NULL;
static const char * const _keywords[] = {"keepends", NULL};
- static _PyArg_Parser _parser = {"|i:splitlines", _keywords, 0};
+ static _PyArg_Parser _parser = {NULL, _keywords, "splitlines", 0};
+ PyObject *argsbuf[1];
+ Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
int keepends = 0;
- if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
- &keepends)) {
+ args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
+ if (!args) {
+ goto exit;
+ }
+ if (!noptargs) {
+ goto skip_optional_pos;
+ }
+ if (PyFloat_Check(args[0])) {
+ PyErr_SetString(PyExc_TypeError,
+ "integer argument expected, got float" );
+ goto exit;
+ }
+ keepends = _PyLong_AsInt(args[0]);
+ if (keepends == -1 && PyErr_Occurred()) {
goto exit;
}
+skip_optional_pos:
return_value = bytearray_splitlines_impl(self, keepends);
exit:
@@ -824,4 +942,4 @@ bytearray_sizeof(PyByteArrayObject *self, PyObject *Py_UNUSED(ignored))
{
return bytearray_sizeof_impl(self);
}
-/*[clinic end generated code: output=f4353c27dcb4a13d input=a9049054013a1b77]*/
+/*[clinic end generated code: output=272fcb836b92da32 input=a9049054013a1b77]*/