summaryrefslogtreecommitdiffstats
path: root/contrib/tools/python3/src/Modules/clinic/arraymodule.c.h
diff options
context:
space:
mode:
authorshadchin <[email protected]>2022-04-18 12:39:32 +0300
committershadchin <[email protected]>2022-04-18 12:39:32 +0300
commitd4be68e361f4258cf0848fc70018dfe37a2acc24 (patch)
tree153e294cd97ac8b5d7a989612704a0c1f58e8ad4 /contrib/tools/python3/src/Modules/clinic/arraymodule.c.h
parent260c02f5ccf242d9d9b8a873afaf6588c00237d6 (diff)
IGNIETFERRO-1816 Update Python 3 from 3.9.12 to 3.10.4
ref:9f96be6d02ee8044fdd6f124b799b270c20ce641
Diffstat (limited to 'contrib/tools/python3/src/Modules/clinic/arraymodule.c.h')
-rw-r--r--contrib/tools/python3/src/Modules/clinic/arraymodule.c.h94
1 files changed, 66 insertions, 28 deletions
diff --git a/contrib/tools/python3/src/Modules/clinic/arraymodule.c.h b/contrib/tools/python3/src/Modules/clinic/arraymodule.c.h
index 005c7ffce4d..c46cc738de9 100644
--- a/contrib/tools/python3/src/Modules/clinic/arraymodule.c.h
+++ b/contrib/tools/python3/src/Modules/clinic/arraymodule.c.h
@@ -39,13 +39,50 @@ PyDoc_STRVAR(array_array_count__doc__,
{"count", (PyCFunction)array_array_count, METH_O, array_array_count__doc__},
PyDoc_STRVAR(array_array_index__doc__,
-"index($self, v, /)\n"
+"index($self, v, start=0, stop=sys.maxsize, /)\n"
"--\n"
"\n"
-"Return index of first occurrence of v in the array.");
+"Return index of first occurrence of v in the array.\n"
+"\n"
+"Raise ValueError if the value is not present.");
#define ARRAY_ARRAY_INDEX_METHODDEF \
- {"index", (PyCFunction)array_array_index, METH_O, array_array_index__doc__},
+ {"index", (PyCFunction)(void(*)(void))array_array_index, METH_FASTCALL, array_array_index__doc__},
+
+static PyObject *
+array_array_index_impl(arrayobject *self, PyObject *v, Py_ssize_t start,
+ Py_ssize_t stop);
+
+static PyObject *
+array_array_index(arrayobject *self, PyObject *const *args, Py_ssize_t nargs)
+{
+ PyObject *return_value = NULL;
+ PyObject *v;
+ Py_ssize_t start = 0;
+ Py_ssize_t stop = PY_SSIZE_T_MAX;
+
+ if (!_PyArg_CheckPositional("index", nargs, 1, 3)) {
+ goto exit;
+ }
+ v = args[0];
+ if (nargs < 2) {
+ goto skip_optional;
+ }
+ if (!_PyEval_SliceIndexNotNone(args[1], &start)) {
+ goto exit;
+ }
+ if (nargs < 3) {
+ goto skip_optional;
+ }
+ if (!_PyEval_SliceIndexNotNone(args[2], &stop)) {
+ goto exit;
+ }
+skip_optional:
+ return_value = array_array_index_impl(self, v, start, stop);
+
+exit:
+ return return_value;
+}
PyDoc_STRVAR(array_array_remove__doc__,
"remove($self, v, /)\n"
@@ -82,14 +119,9 @@ array_array_pop(arrayobject *self, PyObject *const *args, Py_ssize_t nargs)
if (nargs < 1) {
goto skip_optional;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
Py_ssize_t ival = -1;
- PyObject *iobj = PyNumber_Index(args[0]);
+ PyObject *iobj = _PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
@@ -113,7 +145,28 @@ PyDoc_STRVAR(array_array_extend__doc__,
"Append items to the end of the array.");
#define ARRAY_ARRAY_EXTEND_METHODDEF \
- {"extend", (PyCFunction)array_array_extend, METH_O, array_array_extend__doc__},
+ {"extend", (PyCFunction)(void(*)(void))array_array_extend, METH_METHOD|METH_FASTCALL|METH_KEYWORDS, array_array_extend__doc__},
+
+static PyObject *
+array_array_extend_impl(arrayobject *self, PyTypeObject *cls, PyObject *bb);
+
+static PyObject *
+array_array_extend(arrayobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
+{
+ PyObject *return_value = NULL;
+ static const char * const _keywords[] = {"", NULL};
+ static _PyArg_Parser _parser = {"O:extend", _keywords, 0};
+ PyObject *bb;
+
+ if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
+ &bb)) {
+ goto exit;
+ }
+ return_value = array_array_extend_impl(self, cls, bb);
+
+exit:
+ return return_value;
+}
PyDoc_STRVAR(array_array_insert__doc__,
"insert($self, i, v, /)\n"
@@ -137,14 +190,9 @@ array_array_insert(arrayobject *self, PyObject *const *args, Py_ssize_t nargs)
if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) {
goto exit;
}
- if (PyFloat_Check(args[0])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
{
Py_ssize_t ival = -1;
- PyObject *iobj = PyNumber_Index(args[0]);
+ PyObject *iobj = _PyNumber_Index(args[0]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
@@ -253,14 +301,9 @@ array_array_fromfile(arrayobject *self, PyObject *const *args, Py_ssize_t nargs)
goto exit;
}
f = args[0];
- 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]);
+ PyObject *iobj = _PyNumber_Index(args[1]);
if (iobj != NULL) {
ival = PyLong_AsSsize_t(iobj);
Py_DECREF(iobj);
@@ -483,11 +526,6 @@ array__array_reconstructor(PyObject *module, PyObject *const *args, Py_ssize_t n
goto exit;
}
typecode = PyUnicode_READ_CHAR(args[1], 0);
- if (PyFloat_Check(args[2])) {
- PyErr_SetString(PyExc_TypeError,
- "integer argument expected, got float" );
- goto exit;
- }
mformat_code = _PyLong_AsInt(args[2]);
if (mformat_code == -1 && PyErr_Occurred()) {
goto exit;
@@ -534,4 +572,4 @@ PyDoc_STRVAR(array_arrayiterator___setstate____doc__,
#define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \
{"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__},
-/*[clinic end generated code: output=485e848d1f3d05e7 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=f130a994f98f1227 input=a9049054013a1b77]*/