From ac1866547243ade5392ed9bc6e7989f4d4346594 Mon Sep 17 00:00:00 2001 From: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com> Date: Sun, 4 Sep 2022 19:00:24 -0400 Subject: ceval.c's GETITEM should have asserts, not set exceptions (GH-96518) --- Python/ceval.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index 76a8118..c2fa908 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 */ -- cgit v0.12