ceval.c's GETITEM should have asserts, not set exceptions (GH-96518)

This commit is contained in:
Dennis Sweeney 2022-09-04 19:00:24 -04:00 committed by GitHub
parent 9e55685782
commit ac18665472
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 */