Skip to content

Commit f167107

Browse files
MAINT: make Py_SET_SIZE and Py_SET_TYPE macros a bit safer (#16501)
This is the spelling of the compatibility macro that CPython is recommending. Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
1 parent a5d021a commit f167107

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎numpy/core/include/numpy/npy_3kcompat.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ static NPY_INLINE int PyInt_Check(PyObject *op) {
6262

6363
#if PY_VERSION_HEX < 0x030900a4
6464
/* 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)
6666
/* 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)
6868
#endif
6969

7070

0 commit comments

Comments
 (0)