From b1c469843ff56e1704108324bce3ebb87aa753a6 Mon Sep 17 00:00:00 2001 From: Tim Peters Date: Fri, 5 Oct 2001 20:41:38 +0000 Subject: Introduced the oddly-missing PyList_CheckExact(), and used it to replace a hard-coded type check. --- Include/listobject.h | 1 + Python/ceval.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Include/listobject.h b/Include/listobject.h index af1368c..1befe86 100644 --- a/Include/listobject.h +++ b/Include/listobject.h @@ -27,6 +27,7 @@ typedef struct { extern DL_IMPORT(PyTypeObject) PyList_Type; #define PyList_Check(op) PyObject_TypeCheck(op, &PyList_Type) +#define PyList_CheckExact(op) ((op)->ob_type == &PyList_Type) extern DL_IMPORT(PyObject *) PyList_New(int size); extern DL_IMPORT(int) PyList_Size(PyObject *); diff --git a/Python/ceval.c b/Python/ceval.c index b3e35c2..25ba4a0 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -989,7 +989,7 @@ eval_frame(PyFrameObject *f) case BINARY_SUBSCR: w = POP(); v = POP(); - if (v->ob_type == &PyList_Type && PyInt_CheckExact(w)) { + if (PyList_CheckExact(v) && PyInt_CheckExact(w)) { /* INLINE: list[int] */ long i = PyInt_AsLong(w); if (i < 0) -- cgit v0.12