More Py_ssize_t changes

This commit is contained in:
wiredfool 2013-12-04 22:07:11 -08:00
parent 28f22fc908
commit f987d74695

View File

@ -1234,7 +1234,8 @@ static PyObject*
_putdata(ImagingObject* self, PyObject* args)
{
Imaging image;
int n, i, x, y;
// i & n are # pixels, require py_ssize_t. x can be as large as n. y, just because.
Py_ssize_t n, i, x, y;
PyObject* data;
double scale = 1.0;
@ -1244,17 +1245,16 @@ _putdata(ImagingObject* self, PyObject* args)
return NULL;
if (!PySequence_Check(data)) {
PyErr_SetString(PyExc_TypeError, must_be_sequence);
return NULL;
PyErr_SetString(PyExc_TypeError, must_be_sequence);
return NULL;
}
image = self->image;
// UNDONE Py_ssize_t 2Gpix image issue
n = PyObject_Length(data);
if (n > (int) (image->xsize * image->ysize)) {
PyErr_SetString(PyExc_TypeError, "too many data entries");
return NULL;
if (n > (Py_ssize_t) (image->xsize * image->ysize)) {
PyErr_SetString(PyExc_TypeError, "too many data entries");
return NULL;
}
if (image->image8) {
@ -1649,7 +1649,7 @@ _stretch(ImagingObject* self, PyObject* args)
imIn = self->image;
/* two-pass resize: minimize size of intermediate image */
if (imIn->xsize * ysize < xsize * imIn->ysize)
if ((Py_ssize_t) imIn->xsize * ysize < (Py_ssize_t) xsize * imIn->ysize)
imTemp = ImagingNew(imIn->mode, imIn->xsize, ysize);
else
imTemp = ImagingNew(imIn->mode, xsize, imIn->ysize);