diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-11-05 17:32:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-05 17:32:46 (GMT) |
commit | d8c11b75e2669c28f2a020883783f281f29864a4 (patch) | |
tree | 46012adcba7af95ef5be618fa8f8e23969d25ccc /Modules | |
parent | 07734a42dbea13900199334ff9cee4af0e2ce2fc (diff) | |
download | cpython-d8c11b75e2669c28f2a020883783f281f29864a4.zip cpython-d8c11b75e2669c28f2a020883783f281f29864a4.tar.gz cpython-d8c11b75e2669c28f2a020883783f281f29864a4.tar.bz2 |
gh-94808: add tests covering `PySequence_{Set,Del}Slice` (GH-99123)
(cherry picked from commit c5c40773cbadc8c35212877ea315a375f3bfaa4b)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_testcapimodule.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 3ec91bf..1291eff 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -5382,6 +5382,37 @@ mapping_has_key(PyObject* self, PyObject *args) return PyLong_FromLong(PyMapping_HasKey(context, key)); } +static PyObject * +sequence_set_slice(PyObject* self, PyObject *args) +{ + PyObject *sequence, *obj; + Py_ssize_t i1, i2; + if (!PyArg_ParseTuple(args, "OnnO", &sequence, &i1, &i2, &obj)) { + return NULL; + } + + int res = PySequence_SetSlice(sequence, i1, i2, obj); + if (res == -1) { + return NULL; + } + Py_RETURN_NONE; +} + +static PyObject * +sequence_del_slice(PyObject* self, PyObject *args) +{ + PyObject *sequence; + Py_ssize_t i1, i2; + if (!PyArg_ParseTuple(args, "Onn", &sequence, &i1, &i2)) { + return NULL; + } + + int res = PySequence_DelSlice(sequence, i1, i2); + if (res == -1) { + return NULL; + } + Py_RETURN_NONE; +} static PyObject * test_pythread_tss_key_state(PyObject *self, PyObject *args) @@ -6424,6 +6455,8 @@ static PyMethodDef TestMethods[] = { {"get_mapping_items", get_mapping_items, METH_O}, {"test_mapping_has_key_string", test_mapping_has_key_string, METH_NOARGS}, {"mapping_has_key", mapping_has_key, METH_VARARGS}, + {"sequence_set_slice", sequence_set_slice, METH_VARARGS}, + {"sequence_del_slice", sequence_del_slice, METH_VARARGS}, {"test_pythread_tss_key_state", test_pythread_tss_key_state, METH_VARARGS}, {"hamt", new_hamt, METH_NOARGS}, {"bad_get", _PyCFunction_CAST(bad_get), METH_FASTCALL}, |