static int Color_ass_subscript(ColorObject *self, PyObject *item, PyObject *value) { if (PyIndex_Check(item)) { Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError); if (i == -1 && PyErr_Occurred()) return -1; if (i < 0) i += COLOR_SIZE; return Color_ass_item(self, i, value); } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; if (PySlice_GetIndicesEx((void *)item, COLOR_SIZE, &start, &stop, &step, &slicelength) < 0) return -1; if (step == 1) return Color_ass_slice(self, start, stop, value); else { PyErr_SetString(PyExc_IndexError, "slice steps not supported with color"); return -1; } } else { PyErr_Format(PyExc_TypeError, "color indices must be integers, not %.200s", Py_TYPE(item)->tp_name); return -1; } }
static int Color_channel_set(ColorObject *self, PyObject *value, void *type) { return Color_ass_item(self, GET_INT_FROM_POINTER(type), value); }