diff options
author | Brandt Bucher <brandtbucher@microsoft.com> | 2022-07-19 16:42:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-19 16:42:40 (GMT) |
commit | f36589510b8708fa224d799d5b328deab558aa4e (patch) | |
tree | 3a6268e6af9ad9984dbb6a52d13e454582742cab /Modules | |
parent | 3f738600f623b88bc90ec12587f75babb6f1025e (diff) | |
download | cpython-f36589510b8708fa224d799d5b328deab558aa4e.zip cpython-f36589510b8708fa224d799d5b328deab558aa4e.tar.gz cpython-f36589510b8708fa224d799d5b328deab558aa4e.tar.bz2 |
GH-91153: Handle mutating __index__ methods in bytearray item assignment (GH-94891)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_testcapimodule.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 6b9afe2..02635c4 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -5484,6 +5484,21 @@ sequence_getitem(PyObject *self, PyObject *args) } +static PyObject * +sequence_setitem(PyObject *self, PyObject *args) +{ + Py_ssize_t i; + PyObject *seq, *val; + if (!PyArg_ParseTuple(args, "OnO", &seq, &i, &val)) { + return NULL; + } + if (PySequence_SetItem(seq, i, val)) { + return NULL; + } + Py_RETURN_NONE; +} + + /* Functions for testing C calling conventions (METH_*) are named meth_*, * e.g. "meth_varargs" for METH_VARARGS. * @@ -6303,6 +6318,7 @@ static PyMethodDef TestMethods[] = { #endif {"write_unraisable_exc", test_write_unraisable_exc, METH_VARARGS}, {"sequence_getitem", sequence_getitem, METH_VARARGS}, + {"sequence_setitem", sequence_setitem, METH_VARARGS}, {"meth_varargs", meth_varargs, METH_VARARGS}, {"meth_varargs_keywords", _PyCFunction_CAST(meth_varargs_keywords), METH_VARARGS|METH_KEYWORDS}, {"meth_o", meth_o, METH_O}, |