From: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com> Date: Sun, 4 Sep 2022 23:00:24 +0000 (-0400) Subject: ceval.c's GETITEM should have asserts, not set exceptions (GH-96518) X-Git-Tag: v3.12.0a1~482 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ac1866547243ade5392ed9bc6e7989f4d4346594;p=thirdparty%2FPython%2Fcpython.git ceval.c's GETITEM should have asserts, not set exceptions (GH-96518) --- diff --git a/Python/ceval.c b/Python/ceval.c index 76a81185e76d..c2fa90853592 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -733,9 +733,15 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) /* Tuple access macros */ #ifndef Py_DEBUG -#define GETITEM(v, i) PyTuple_GET_ITEM((PyTupleObject *)(v), (i)) +#define GETITEM(v, i) PyTuple_GET_ITEM((v), (i)) #else -#define GETITEM(v, i) PyTuple_GetItem((v), (i)) +static inline PyObject * +GETITEM(PyObject *v, Py_ssize_t i) { + assert(PyTuple_Check(v)); + assert(i >= 0); + assert(i < PyTuple_GET_SIZE(v)); + return PyTuple_GET_ITEM(v, i); +} #endif /* Code access macros */