mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
FIX: Handle long values in _imaging getink
This gets the putdata test case to run correctly under 2.6/2.7. It fixes an issue where the value 0xFFFFFFFF (which is long in old Python) isn't recognized and putdata tries to parse it as a tuple. The original fix comes from Christoph Gohlke. It was adapted to work in both 2.* and 3.*.
This commit is contained in:
parent
197885164b
commit
c8ce29c239
12
_imaging.c
12
_imaging.c
|
@ -510,8 +510,17 @@ getink(PyObject* color, Imaging im, char* ink)
|
||||||
ink[1] = ink[2] = ink[3] = 0;
|
ink[1] = ink[2] = ink[3] = 0;
|
||||||
} else {
|
} else {
|
||||||
a = 255;
|
a = 255;
|
||||||
if (PyInt_Check(color)) {
|
#if PY_VERSION_HEX >= 0x03000000
|
||||||
|
if (PyLong_Check(color)) {
|
||||||
|
r = (int) PyLong_AsLong(color);
|
||||||
|
#else
|
||||||
|
if (PyInt_Check(color) || PyLong_Check(color)) {
|
||||||
|
if (PyInt_Check(color))
|
||||||
r = PyInt_AS_LONG(color);
|
r = PyInt_AS_LONG(color);
|
||||||
|
else
|
||||||
|
r = (int) PyLong_AsLong(color);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* compatibility: ABGR */
|
/* compatibility: ABGR */
|
||||||
a = (UINT8) (r >> 24);
|
a = (UINT8) (r >> 24);
|
||||||
b = (UINT8) (r >> 16);
|
b = (UINT8) (r >> 16);
|
||||||
|
@ -1205,6 +1214,7 @@ _putdata(ImagingObject* self, PyObject* args)
|
||||||
PyObject* data;
|
PyObject* data;
|
||||||
double scale = 1.0;
|
double scale = 1.0;
|
||||||
double offset = 0.0;
|
double offset = 0.0;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O|dd", &data, &scale, &offset))
|
if (!PyArg_ParseTuple(args, "O|dd", &data, &scale, &offset))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user