Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Format the macro by PEP7
  • Loading branch information
aisk committed Dec 27, 2025
commit b3617c861e8a7aa423963b88c320e1a5d40ca228
34 changes: 19 additions & 15 deletions Modules/arraymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,23 +209,27 @@ in bounds; that's the responsibility of the caller.
user-defined methods (like __index__ or __float__) that might modify
the array during the call.
*/
#define CHECK_ARRAY_BOUNDS(ap, i) \
do { \
if ((i) >= 0 && ((ap)->ob_item == NULL || (i) >= Py_SIZE((ap)))) { \
PyErr_SetString(PyExc_IndexError, "array assignment index out of range"); \
return -1; \
} \
#define CHECK_ARRAY_BOUNDS(OP, IDX) \
do { \
if ((IDX) >= 0 && ((OP)->ob_item == NULL || \
(IDX) >= Py_SIZE((OP)))) { \
PyErr_SetString(PyExc_IndexError, \
"array assignment index out of range"); \
return -1; \
} \
} while (0)

#define CHECK_ARRAY_BOUNDS_WITH_CLEANUP(ap, i, v, cleanup) \
do { \
if ((i) >= 0 && ((ap)->ob_item == NULL || (i) >= Py_SIZE((ap)))) { \
PyErr_SetString(PyExc_IndexError, "array assignment index out of range"); \
if (cleanup) { \
Py_DECREF(v); \
} \
return -1; \
} \
#define CHECK_ARRAY_BOUNDS_WITH_CLEANUP(OP, IDX, VAL, CLEANUP) \
do { \
if ((IDX) >= 0 && ((OP)->ob_item == NULL || \
(IDX) >= Py_SIZE((OP)))) { \
PyErr_SetString(PyExc_IndexError, \
"array assignment index out of range"); \
if (CLEANUP) { \
Py_DECREF(VAL); \
} \
return -1; \
} \
} while (0)

static PyObject *
Expand Down
Loading