diff options
| author | Sergey Fedoseev <fedoseev.sergey@gmail.com> | 2019-09-09 16:28:34 (GMT) |
|---|---|---|
| committer | T. Wouters <thomas@python.org> | 2019-09-09 16:28:34 (GMT) |
| commit | 92709a263e9cec0bc646ccc1ea051fc528800d8d (patch) | |
| tree | 50dfa3690e7112d46de23e0f372f4c427304774d /Modules/_testcapimodule.c | |
| parent | 915cd3f0696cb8a7206754a8fc34d4cd865a1b4a (diff) | |
| download | cpython-92709a263e9cec0bc646ccc1ea051fc528800d8d.zip cpython-92709a263e9cec0bc646ccc1ea051fc528800d8d.tar.gz cpython-92709a263e9cec0bc646ccc1ea051fc528800d8d.tar.bz2 | |
bpo-37840: Fix handling of negative indices in bytearray_getitem() (GH-15250)
Diffstat (limited to 'Modules/_testcapimodule.c')
| -rw-r--r-- | Modules/_testcapimodule.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 640ec59..147008b 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -5164,6 +5164,18 @@ test_write_unraisable_exc(PyObject *self, PyObject *args) } +static PyObject * +sequence_getitem(PyObject *self, PyObject *args) +{ + PyObject *seq; + Py_ssize_t i; + if (!PyArg_ParseTuple(args, "On", &seq, &i)) { + return NULL; + } + return PySequence_GetItem(seq, i); +} + + static PyMethodDef TestMethods[] = { {"raise_exception", raise_exception, METH_VARARGS}, {"raise_memoryerror", raise_memoryerror, METH_NOARGS}, @@ -5413,6 +5425,7 @@ static PyMethodDef TestMethods[] = { {"negative_refcount", negative_refcount, METH_NOARGS}, #endif {"write_unraisable_exc", test_write_unraisable_exc, METH_VARARGS}, + {"sequence_getitem", sequence_getitem, METH_VARARGS}, {NULL, NULL} /* sentinel */ }; |
