diff --git a/Tk/tkImaging.c b/Tk/tkImaging.c index 5963ee24c..4234a7d2b 100644 --- a/Tk/tkImaging.c +++ b/Tk/tkImaging.c @@ -58,7 +58,7 @@ static Imaging ImagingFind(const char* name) { - long id; + Py_ssize_t id; /* FIXME: use CObject instead? */ id = atol(name); diff --git a/_imaging.c b/_imaging.c index 8adbe3b16..5c429aba6 100644 --- a/_imaging.c +++ b/_imaging.c @@ -2995,7 +2995,7 @@ _getattr_bands(ImagingObject* self, void* closure) static PyObject* _getattr_id(ImagingObject* self, void* closure) { - return PyInt_FromLong((long) self->image); + return PyInt_FromSsize_t((Py_ssize_t) self->image); } static PyObject* diff --git a/_imagingcms.c b/_imagingcms.c index 84ee8d824..946b8c691 100644 --- a/_imagingcms.c +++ b/_imagingcms.c @@ -376,14 +376,14 @@ buildProofTransform(PyObject *self, PyObject *args) static PyObject * cms_transform_apply(CmsTransformObject *self, PyObject *args) { - long idIn; - long idOut; + Py_ssize_t idIn; + Py_ssize_t idOut; Imaging im; Imaging imOut; int result; - if (!PyArg_ParseTuple(args, "ll:apply", &idIn, &idOut)) + if (!PyArg_ParseTuple(args, "nn:apply", &idIn, &idOut)) return NULL; im = (Imaging) idIn; diff --git a/_imagingft.c b/_imagingft.c index f54e38553..7028293ec 100644 --- a/_imagingft.c +++ b/_imagingft.c @@ -293,9 +293,9 @@ font_render(FontObject* self, PyObject* args) /* render string into given buffer (the buffer *must* have the right size, or this will crash) */ PyObject* string; - long id; + Py_ssize_t id; int mask = 0; - if (!PyArg_ParseTuple(args, "Ol|i:render", &string, &id, &mask)) + if (!PyArg_ParseTuple(args, "On|i:render", &string, &id, &mask)) return NULL; #if PY_VERSION_HEX >= 0x03000000 diff --git a/_imagingmath.c b/_imagingmath.c index c21dac1de..4f377e9ac 100644 --- a/_imagingmath.c +++ b/_imagingmath.c @@ -174,8 +174,8 @@ _unop(PyObject* self, PyObject* args) Imaging im1; void (*unop)(Imaging, Imaging); - long op, i0, i1; - if (!PyArg_ParseTuple(args, "lll", &op, &i0, &i1)) + Py_ssize_t op, i0, i1; + if (!PyArg_ParseTuple(args, "nnn", &op, &i0, &i1)) return NULL; out = (Imaging) i0; @@ -197,8 +197,8 @@ _binop(PyObject* self, PyObject* args) Imaging im2; void (*binop)(Imaging, Imaging, Imaging); - long op, i0, i1, i2; - if (!PyArg_ParseTuple(args, "llll", &op, &i0, &i1, &i2)) + Py_ssize_t op, i0, i1, i2; + if (!PyArg_ParseTuple(args, "nnnn", &op, &i0, &i1, &i2)) return NULL; out = (Imaging) i0; diff --git a/_imagingtk.c b/_imagingtk.c index b29cfdca8..cb6f21009 100644 --- a/_imagingtk.c +++ b/_imagingtk.c @@ -35,9 +35,9 @@ _tkinit(PyObject* self, PyObject* args) { Tcl_Interp* interp; - long arg; + Py_ssize_t arg; int is_interp; - if (!PyArg_ParseTuple(args, "li", &arg, &is_interp)) + if (!PyArg_ParseTuple(args, "ni", &arg, &is_interp)) return NULL; if (is_interp) diff --git a/display.c b/display.c index 81ad329f9..bf00e49fe 100644 --- a/display.c +++ b/display.c @@ -399,7 +399,7 @@ static BOOL CALLBACK list_windows_callback(HWND hwnd, LPARAM lParam) GetWindowRect(hwnd, &outer); item = Py_BuildValue( - "lN(iiii)(iiii)", (long) hwnd, title, + "nN(iiii)(iiii)", (Py_ssize_t) hwnd, title, inner.left, inner.top, inner.right, inner.bottom, outer.left, outer.top, outer.right, outer.bottom ); @@ -735,15 +735,15 @@ PyImaging_CreateWindowWin32(PyObject* self, PyObject* args) /* register window callback */ Py_INCREF(callback); - SetWindowLong(wnd, 0, (LONG) callback); - SetWindowLong(wnd, sizeof(callback), (LONG) PyThreadState_Get()); + SetWindowLongPtr(wnd, 0, (LONG_PTR) callback); + SetWindowLongPtr(wnd, sizeof(callback), (LONG_PTR) PyThreadState_Get()); Py_BEGIN_ALLOW_THREADS ShowWindow(wnd, SW_SHOWNORMAL); SetForegroundWindow(wnd); /* to make sure it's visible */ Py_END_ALLOW_THREADS - return Py_BuildValue("l", (long) wnd); + return Py_BuildValue("n", (Py_ssize_t) wnd); } PyObject*