mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 04:07:21 +03:00
Only call PyTuple_Check once in getink
This commit is contained in:
parent
d84e227204
commit
59d67fa68a
|
@ -502,13 +502,10 @@ getink(PyObject *color, Imaging im, char *ink) {
|
||||||
be cast to either UINT8 or INT32 */
|
be cast to either UINT8 or INT32 */
|
||||||
|
|
||||||
int rIsInt = 0;
|
int rIsInt = 0;
|
||||||
int tupleSize = 0;
|
int tupleSize = PyTuple_Check(color) ? PyTuple_GET_SIZE(color) : -1;
|
||||||
if (PyTuple_Check(color)) {
|
|
||||||
tupleSize = PyTuple_GET_SIZE(color);
|
|
||||||
if (tupleSize == 1) {
|
if (tupleSize == 1) {
|
||||||
color = PyTuple_GetItem(color, 0);
|
color = PyTuple_GetItem(color, 0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (im->type == IMAGING_TYPE_UINT8 || im->type == IMAGING_TYPE_INT32 ||
|
if (im->type == IMAGING_TYPE_UINT8 || im->type == IMAGING_TYPE_INT32 ||
|
||||||
im->type == IMAGING_TYPE_SPECIAL) {
|
im->type == IMAGING_TYPE_SPECIAL) {
|
||||||
if (PyLong_Check(color)) {
|
if (PyLong_Check(color)) {
|
||||||
|
@ -521,7 +518,7 @@ getink(PyObject *color, Imaging im, char *ink) {
|
||||||
PyErr_SetString(
|
PyErr_SetString(
|
||||||
PyExc_TypeError, "color must be int or single-element tuple");
|
PyExc_TypeError, "color must be int or single-element tuple");
|
||||||
return NULL;
|
return NULL;
|
||||||
} else if (!PyTuple_Check(color)) {
|
} else if (tupleSize == -1) {
|
||||||
PyErr_SetString(PyExc_TypeError, "color must be int or tuple");
|
PyErr_SetString(PyExc_TypeError, "color must be int or tuple");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user