From da5ca4caeafdecbe538e751c4ae7dd63fa8a1e71 Mon Sep 17 00:00:00 2001 From: Brian Crowell Date: Sat, 20 Oct 2012 16:05:13 -0500 Subject: [PATCH] py3k: Change apply() to unpacking syntax apply() is no longer available in py3k. --- PIL/Image.py | 14 +++++++------- PIL/ImageFilter.py | 2 +- PIL/ImageTk.py | 4 ++-- PIL/ImageWin.py | 2 +- Scripts/pilconvert.py | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/PIL/Image.py b/PIL/Image.py index f2a7de141..bc7c742f5 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -372,8 +372,8 @@ def _getdecoder(mode, decoder_name, args, extra=()): try: # get decoder decoder = getattr(core, decoder_name + "_decoder") - # print decoder, (mode,) + args + extra - return apply(decoder, (mode,) + args + extra) + # print(decoder, mode, args + extra) + return decoder(mode, *args + extra) except AttributeError: raise IOError("decoder %s not available" % decoder_name) @@ -388,8 +388,8 @@ def _getencoder(mode, encoder_name, args, extra=()): try: # get encoder encoder = getattr(core, encoder_name + "_encoder") - # print encoder, (mode,) + args + extra - return apply(encoder, (mode,) + args + extra) + # print(encoder, mode, args + extra) + return encoder(mode, *args + extra) except AttributeError: raise IOError("encoder %s not available" % encoder_name) @@ -601,7 +601,7 @@ class Image: "Explicitly load pixel data." if self.im and self.palette and self.palette.dirty: # realize palette - apply(self.im.putpalette, self.palette.getdata()) + self.im.putpalette(*self.palette.getdata()) self.palette.dirty = 0 self.palette.mode = "RGB" self.palette.rawmode = None @@ -2129,8 +2129,8 @@ def register_extension(id, extension): def _show(image, **options): # override me, as necessary - apply(_showxv, (image,), options) + _showxv(image, **options) def _showxv(image, title=None, **options): from . import ImageShow - apply(ImageShow.show, (image, title), options) + ImageShow.show(image, title, **options) diff --git a/PIL/ImageFilter.py b/PIL/ImageFilter.py index cfdad5fc5..f4f98be79 100644 --- a/PIL/ImageFilter.py +++ b/PIL/ImageFilter.py @@ -54,7 +54,7 @@ class Kernel(Filter): def filter(self, image): if image.mode == "P": raise ValueError("cannot filter palette images") - return apply(image.filter, self.filterargs) + return image.filter(*self.filterargs) class BuiltinFilter(Kernel): def __init__(self): diff --git a/PIL/ImageTk.py b/PIL/ImageTk.py index 8f3b4c3e5..34832d8d9 100644 --- a/PIL/ImageTk.py +++ b/PIL/ImageTk.py @@ -117,7 +117,7 @@ class PhotoImage: self.__mode = mode self.__size = size - self.__photo = apply(tkinter.PhotoImage, (), kw) + self.__photo = tkinter.PhotoImage(**kw) self.tk = self.__photo.tk if image: self.paste(image) @@ -239,7 +239,7 @@ class BitmapImage: else: # slow but safe way kw["data"] = image.tobitmap() - self.__photo = apply(tkinter.BitmapImage, (), kw) + self.__photo = tkinter.BitmapImage(**kw) def __del__(self): name = self.__photo.name diff --git a/PIL/ImageWin.py b/PIL/ImageWin.py index 8e0cd9728..c2d72b959 100644 --- a/PIL/ImageWin.py +++ b/PIL/ImageWin.py @@ -179,7 +179,7 @@ class Window: ) def __dispatcher(self, action, *args): - return apply(getattr(self, "ui_handle_" + action), args) + return getattr(self, "ui_handle_" + action)(*args) def ui_handle_clear(self, dc, x0, y0, x1, y1): pass diff --git a/Scripts/pilconvert.py b/Scripts/pilconvert.py index 64900db8a..949d277c3 100644 --- a/Scripts/pilconvert.py +++ b/Scripts/pilconvert.py @@ -90,9 +90,9 @@ try: im.draft(convert, im.size) im = im.convert(convert) if format: - apply(im.save, (argv[1], format), options) + im.save(argv[1], format, **options) else: - apply(im.save, (argv[1],), options) + im.save(argv[1], **options) except: print("cannot convert image", end=' ') print("(%s:%s)" % (sys.exc_info()[0], sys.exc_info()[1]))