diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-04-21 23:48:11 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2017-04-21 23:48:11 (GMT) |
commit | 1a5856bf9295fa73995898d576e0bedf016aee1f (patch) | |
tree | 32c1f6c2ad33c8374bc5753f520e609339962fd2 /Include | |
parent | a36e939aeb3b5a2c56561eb24f0e339eee9f3f9d (diff) | |
download | cpython-1a5856bf9295fa73995898d576e0bedf016aee1f.zip cpython-1a5856bf9295fa73995898d576e0bedf016aee1f.tar.gz cpython-1a5856bf9295fa73995898d576e0bedf016aee1f.tar.bz2 |
bpo-29867: Add asserts in PyTuple_GET_SIZE, PyList_GET_SIZE and PySet_GET_SIZE. (#751)
Diffstat (limited to 'Include')
-rw-r--r-- | Include/listobject.h | 2 | ||||
-rw-r--r-- | Include/setobject.h | 2 | ||||
-rw-r--r-- | Include/tupleobject.h | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/Include/listobject.h b/Include/listobject.h index 31843b5..6057279 100644 --- a/Include/listobject.h +++ b/Include/listobject.h @@ -71,7 +71,7 @@ PyAPI_FUNC(void) _PyList_DebugMallocStats(FILE *out); #ifndef Py_LIMITED_API #define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i]) #define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v)) -#define PyList_GET_SIZE(op) Py_SIZE(op) +#define PyList_GET_SIZE(op) (assert(PyList_Check(op)),Py_SIZE(op)) #define _PyList_ITEMS(op) (((PyListObject *)(op))->ob_item) #endif diff --git a/Include/setobject.h b/Include/setobject.h index 87ec1c8..fc0ea83 100644 --- a/Include/setobject.h +++ b/Include/setobject.h @@ -64,7 +64,7 @@ typedef struct { PyObject *weakreflist; /* List of weak references */ } PySetObject; -#define PySet_GET_SIZE(so) (((PySetObject *)(so))->used) +#define PySet_GET_SIZE(so) (assert(PyAnySet_Check(so)),(((PySetObject *)(so))->used)) PyAPI_DATA(PyObject *) _PySet_Dummy; diff --git a/Include/tupleobject.h b/Include/tupleobject.h index c273ce7..98c2622 100644 --- a/Include/tupleobject.h +++ b/Include/tupleobject.h @@ -56,7 +56,7 @@ PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *); /* Macro, trading safety for speed */ #ifndef Py_LIMITED_API #define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i]) -#define PyTuple_GET_SIZE(op) Py_SIZE(op) +#define PyTuple_GET_SIZE(op) (assert(PyTuple_Check(op)),Py_SIZE(op)) /* Macro, *only* to be used to fill in brand new tuples */ #define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v) |