mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-07 06:33:10 +03:00
replaced pydict_next with a for loop, due to py_ssize_t warning and issues on 64bit system
This commit is contained in:
parent
03dcb5c557
commit
455304a78c
23
encode.c
23
encode.c
|
@ -678,9 +678,13 @@ PyImaging_LibTiffEncoderNew(PyObject* self, PyObject* args)
|
|||
|
||||
PyObject *dir;
|
||||
PyObject *key, *value;
|
||||
int pos = 0;
|
||||
Py_ssize_t pos = 0;
|
||||
int status;
|
||||
|
||||
Py_ssize_t d_size;
|
||||
PyObject *keys, *values;
|
||||
|
||||
|
||||
if (! PyArg_ParseTuple(args, "sssisO", &mode, &rawmode, &compname, &fp, &filename, &dir)) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -688,7 +692,17 @@ PyImaging_LibTiffEncoderNew(PyObject* self, PyObject* args)
|
|||
if (!PyDict_Check(dir)) {
|
||||
PyErr_SetString(PyExc_ValueError, "Invalid Dictionary");
|
||||
return NULL;
|
||||
} else {
|
||||
d_size = PyDict_Size(dir);
|
||||
TRACE(("dict size: %d\n", (int)d_size));
|
||||
keys = PyDict_Keys(dir);
|
||||
values = PyDict_Values(dir);
|
||||
for (pos=0;pos<d_size;pos++){
|
||||
TRACE((" key: %d\n", (int)PyInt_AsLong(PyList_GetItem(keys,pos))));
|
||||
}
|
||||
pos = 0;
|
||||
}
|
||||
|
||||
|
||||
TRACE(("new tiff encoder %s fp: %d, filename: %s \n", compname, fp, filename));
|
||||
|
||||
|
@ -728,8 +742,13 @@ PyImaging_LibTiffEncoderNew(PyObject* self, PyObject* args)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
while (PyDict_Next(dir, &pos, &key, &value)) {
|
||||
// While failes on 64 bit machines, complains that pos is an int instead of a Py_ssize_t
|
||||
// while (PyDict_Next(dir, &pos, &key, &value)) {
|
||||
for (pos=0;pos<d_size;pos++){
|
||||
key = PyList_GetItem(keys,pos);
|
||||
value = PyList_GetItem(values,pos);
|
||||
status = 0;
|
||||
TRACE(("Attempting to set key: %d", (int)PyInt_AsLong(key)));
|
||||
if (PyInt_Check(value)) {
|
||||
TRACE(("Setting from Int: %d %ld \n", (int)PyInt_AsLong(key),PyInt_AsLong(value)));
|
||||
status = ImagingLibTiffSetField(&encoder->state,
|
||||
|
|
Loading…
Reference in New Issue
Block a user