From 8eafe024ed3133227eed42f77b3cdca6a4c75d0a Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 27 Aug 2026 19:04:42 +1000 Subject: [PATCH 1/2] Remove unused C convert method Co-authored-by: Alexander Karpinsky --- src/_imaging.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/_imaging.c b/src/_imaging.c index 9bdb6328782..100fa7fc8bb 100644 --- a/src/_imaging.c +++ b/src/_imaging.c @@ -4218,9 +4218,6 @@ static PyMethodDef functions[] = { {"new_arrow", (PyCFunction)_new_arrow, METH_VARARGS}, {"merge", (PyCFunction)_merge, METH_VARARGS}, - /* Functions */ - {"convert", (PyCFunction)_convert2, METH_VARARGS}, - /* Codecs */ {"bcn_decoder", (PyCFunction)PyImaging_BcnDecoderNew, METH_VARARGS}, {"bcn_encoder", (PyCFunction)PyImaging_BcnEncoderNew, METH_VARARGS}, From 55422bfe6bdc8b2feb0b4a0a1ab672250e61a74a Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 27 Aug 2026 19:05:15 +1000 Subject: [PATCH 2/2] Simplified code Co-authored-by: Alexander Karpinsky --- src/PIL/ImageTk.py | 2 +- src/_imaging.c | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/PIL/ImageTk.py b/src/PIL/ImageTk.py index fb02b0211ca..a837cf77a51 100644 --- a/src/PIL/ImageTk.py +++ b/src/PIL/ImageTk.py @@ -183,7 +183,7 @@ def paste(self, im: Image.Image) -> None: image = im.im if not image.isblock() or im.mode != self.__mode: block = Image.core.new_block(self.__mode, im.size) - image.convert2(block, image) # convert directly between buffers + image.convert2(block) # convert directly between buffers ptr = block.ptr _pyimagingtkcall("PyImagingPhoto", self.__photo, ptr) diff --git a/src/_imaging.c b/src/_imaging.c index 100fa7fc8bb..04b5da3f68c 100644 --- a/src/_imaging.c +++ b/src/_imaging.c @@ -1029,15 +1029,12 @@ _convert(ImagingObject *self, PyObject *args) { static PyObject * _convert2(ImagingObject *self, PyObject *args) { - ImagingObject *imagep1; - ImagingObject *imagep2; - if (!PyArg_ParseTuple( - args, "O!O!", &Imaging_Type, &imagep1, &Imaging_Type, &imagep2 - )) { + ImagingObject *imagep; + if (!PyArg_ParseTuple(args, "O!", &Imaging_Type, &imagep)) { return NULL; } - if (!ImagingConvert2(imagep1->image, imagep2->image)) { + if (!ImagingConvert2(imagep->image, self->image)) { return NULL; }