From 80c2fa60aef3831001c887d969c7543e0549ee18 Mon Sep 17 00:00:00 2001 From: Brian Crowell Date: Tue, 16 Oct 2012 22:58:14 -0500 Subject: [PATCH] py3k: Sort by key, not cmp Py3k only supports key because it's more efficient. Not even sure 2to3 checks for this. --- PIL/ImageFile.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PIL/ImageFile.py b/PIL/ImageFile.py index 31c904742..60c732384 100644 --- a/PIL/ImageFile.py +++ b/PIL/ImageFile.py @@ -56,9 +56,9 @@ def raise_ioerror(error): # -------------------------------------------------------------------- # Helpers -def _tilesort(t1, t2): +def _tilesort(t): # sort on offset - return cmp(t1[2], t2[2]) + return t[2] # # -------------------------------------------------------------------- @@ -178,7 +178,7 @@ class ImageFile(Image.Image): if not self.map: # sort tiles in file order - self.tile.sort(_tilesort) + self.tile.sort(key=_tilesort) try: # FIXME: This is a hack to handle TIFF's JpegTables tag. @@ -470,7 +470,7 @@ def _save(im, fp, tile): im.load() if not hasattr(im, "encoderconfig"): im.encoderconfig = () - tile.sort(_tilesort) + tile.sort(key=_tilesort) # FIXME: make MAXBLOCK a configuration parameter bufsize = max(MAXBLOCK, im.size[0] * 4) # see RawEncode.c try: