diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-07-19 17:12:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-19 17:12:39 (GMT) |
commit | 9487e8d250783b48eec1d240eddac809584e11a0 (patch) | |
tree | ffa7c82293503d235d501bd2c7b7d7ec2495c60e /Modules | |
parent | d2be44230eaade5c367af6ec9df649502b574dac (diff) | |
download | cpython-9487e8d250783b48eec1d240eddac809584e11a0.zip cpython-9487e8d250783b48eec1d240eddac809584e11a0.tar.gz cpython-9487e8d250783b48eec1d240eddac809584e11a0.tar.bz2 |
GH-91153: Handle mutating __index__ methods in bytearray item assignment (GH-94891)
(cherry picked from commit f36589510b8708fa224d799d5b328deab558aa4e)
Co-authored-by: Brandt Bucher <brandtbucher@microsoft.com>
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 3467c04..9aa7fca 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -5489,6 +5489,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. * @@ -6272,6 +6287,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}, |