MAINT: make Py_SET_SIZE and Py_SET_TYPE macros a bit safer (#16501) · numpy/numpy@f167107 (original) (raw)

Original file line number Diff line number Diff line change
@@ -62,9 +62,9 @@ static NPY_INLINE int PyInt_Check(PyObject *op) {
62 62
63 63 #if PY_VERSION_HEX < 0x030900a4
64 64 /* Introduced in https://github.com/python/cpython/commit/d2ec81a8c99796b51fb8c49b77a7fe369863226f */
65 -#define Py_SET_TYPE(obj, typ) (Py_TYPE(obj) = typ)
65 +#define Py_SET_TYPE(obj, type) ((Py_TYPE(obj) = (type)), (void)0)
66 66 /* Introduced in https://github.com/python/cpython/commit/b10dc3e7a11fcdb97e285882eba6da92594f90f9 */
67 -#define Py_SET_SIZE(obj, size) (Py_SIZE(obj) = size)
67 +#define Py_SET_SIZE(obj, size) ((Py_SIZE(obj) = (size)), (void)0)
68 68 #endif
69 69
70 70