From a0f1f6692c303f9d10e12ddcdf7718d5bdb34634 Mon Sep 17 00:00:00 2001 From: Christoph Gohlke Date: Wed, 13 Feb 2013 18:36:09 -0800 Subject: [PATCH 1/8] Use Py_ssize_t instead of long --- _imagingcms.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_imagingcms.c b/_imagingcms.c index b29203471..a1512a425 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; From 2feb481ca210cc00468bc15f205c8cd8007b0bc6 Mon Sep 17 00:00:00 2001 From: Christoph Gohlke Date: Wed, 13 Feb 2013 18:38:45 -0800 Subject: [PATCH 2/8] Use Py_ssize_t instead of long --- _imagingtk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From 803022d93fb8c8a061e01994a889a30ce3e8aff5 Mon Sep 17 00:00:00 2001 From: Christoph Gohlke Date: Wed, 13 Feb 2013 18:40:39 -0800 Subject: [PATCH 3/8] Use Py_ssize_t instead of long --- _imagingmath.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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; From c334626b8bc71147e9ede186b6a1379f9577f7a0 Mon Sep 17 00:00:00 2001 From: Christoph Gohlke Date: Wed, 13 Feb 2013 18:42:46 -0800 Subject: [PATCH 4/8] Use Py_ssize_t instead of long --- _imagingft.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From d711d8ef82a910dc1067236ed49c484fbdfbc378 Mon Sep 17 00:00:00 2001 From: Christoph Gohlke Date: Wed, 13 Feb 2013 18:47:32 -0800 Subject: [PATCH 5/8] Use Py_ssize_t instead of long --- _imaging.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_imaging.c b/_imaging.c index 986f221e4..6785578c6 100644 --- a/_imaging.c +++ b/_imaging.c @@ -2985,7 +2985,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* From 007a4405de911452a0368c0c07d556e6ed74d064 Mon Sep 17 00:00:00 2001 From: Christoph Gohlke Date: Wed, 13 Feb 2013 18:48:46 -0800 Subject: [PATCH 6/8] Use Py_ssize_t instead of long --- Tk/tkImaging.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); From 8b70b2fb791529afe5b0909e025306782d8b00e7 Mon Sep 17 00:00:00 2001 From: Christoph Gohlke Date: Wed, 13 Feb 2013 18:52:41 -0800 Subject: [PATCH 7/8] Use Py_ssize_t instead of long --- display.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/display.c b/display.c index 3751b0a2b..830dd3fe9 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 ); @@ -743,7 +743,7 @@ PyImaging_CreateWindowWin32(PyObject* self, PyObject* args) 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* From 4e981b2ef60c9ae150d74ed5a1b6ec503e9f3570 Mon Sep 17 00:00:00 2001 From: Christoph Gohlke Date: Wed, 13 Feb 2013 19:10:28 -0800 Subject: [PATCH 8/8] Use SetWindowLongPtr instead of SetWindowLong --- display.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/display.c b/display.c index 830dd3fe9..b88ef7aaa 100644 --- a/display.c +++ b/display.c @@ -735,8 +735,8 @@ 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);