diff options
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r-- | Modules/_testcapimodule.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index f57176d..67488e7 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -1560,6 +1560,29 @@ getargs_et_hash(PyObject *self, PyObject *args) } static PyObject * +get_indices(PyObject *self, PyObject *args) +{ + int result; + PySliceObject *slice; + Py_ssize_t length, start, stop, step; + + if (!PyArg_ParseTuple(args, "On", &slice, &length)) + return NULL; + + result = PySlice_GetIndices(slice, length, &start, &stop, &step); + + if (PyErr_Occurred()) { + assert(result == -1); + return NULL; + } + + if (result == -1) { + Py_RETURN_NONE; + } + return Py_BuildValue("innn", result, start, stop, step); +} + +static PyObject * parse_tuple_and_keywords(PyObject *self, PyObject *args) { PyObject *sub_args; @@ -2664,6 +2687,7 @@ static PyMethodDef TestMethods[] = { #ifdef Py_USING_UNICODE {"test_empty_argparse", (PyCFunction)test_empty_argparse,METH_NOARGS}, #endif + {"get_indices", get_indices, METH_VARARGS}, {"parse_tuple_and_keywords", parse_tuple_and_keywords, METH_VARARGS}, {"test_null_strings", (PyCFunction)test_null_strings, METH_NOARGS}, {"test_string_from_format", (PyCFunction)test_string_from_format, METH_NOARGS}, |