diff options
author | Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com> | 2022-09-04 23:00:24 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-04 23:00:24 (GMT) |
commit | ac1866547243ade5392ed9bc6e7989f4d4346594 (patch) | |
tree | 927f5771472f9da97c16fc331f083654d96884d7 /Python | |
parent | 9e5568578234f0ecd003247c8a2deaeb69976b4b (diff) | |
download | cpython-ac1866547243ade5392ed9bc6e7989f4d4346594.zip cpython-ac1866547243ade5392ed9bc6e7989f4d4346594.tar.gz cpython-ac1866547243ade5392ed9bc6e7989f4d4346594.tar.bz2 |
ceval.c's GETITEM should have asserts, not set exceptions (GH-96518)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 10 |
1 files 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 */ |