Convert list to tuple in Python instead of C

This commit is contained in:
Andrew Murray 2023-08-28 22:43:20 +10:00
parent d8c3135b6b
commit 69a81dd867
2 changed files with 5 additions and 7 deletions

View File

@ -1565,6 +1565,8 @@ class Image:
self.load()
if self.pyaccess:
return self.pyaccess.getpixel(xy)
if isinstance(xy, list):
xy = tuple(xy)
return self.im.getpixel(xy)
def getprojection(self):

View File

@ -1146,15 +1146,11 @@ static inline int
_getxy(PyObject *xy, int *x, int *y) {
PyObject *value;
int tuple = PyTuple_Check(xy);
if (
!(tuple && PyTuple_GET_SIZE(xy) == 2) &&
!(PyList_Check(xy) && PyList_GET_SIZE(xy) == 2)
) {
if (!PyTuple_Check(xy) || PyTuple_GET_SIZE(xy) != 2) {
goto badarg;
}
value = tuple ? PyTuple_GET_ITEM(xy, 0) : PyList_GET_ITEM(xy, 0);
value = PyTuple_GET_ITEM(xy, 0);
if (PyLong_Check(value)) {
*x = PyLong_AS_LONG(value);
} else if (PyFloat_Check(value)) {
@ -1168,7 +1164,7 @@ _getxy(PyObject *xy, int *x, int *y) {
}
}
value = tuple ? PyTuple_GET_ITEM(xy, 1) : PyList_GET_ITEM(xy, 1);
value = PyTuple_GET_ITEM(xy, 1);
if (PyLong_Check(value)) {
*y = PyLong_AS_LONG(value);
} else if (PyFloat_Check(value)) {