From 3e28ba3b7d7f1b89e074862277cb9fbf44e4ae22 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sat, 12 Jan 2019 18:24:27 -0800 Subject: [PATCH] Python del is a statement not a function https://docs.python.org/3/reference/simple_stmts.html#the-del-statement --- Tests/test_file_libtiff.py | 4 ++-- src/PIL/Image.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py index 6834b7256..63dc49cde 100644 --- a/Tests/test_file_libtiff.py +++ b/Tests/test_file_libtiff.py @@ -195,7 +195,7 @@ class TestFileLibTiff(LibTiffTestCase): im = Image.open('Tests/images/hopper_g4.tif') for tag in im.tag_v2: try: - del(core_items[tag]) + del core_items[tag] except KeyError: pass @@ -223,7 +223,7 @@ class TestFileLibTiff(LibTiffTestCase): for _ in range(info.length)) # Extra samples really doesn't make sense in this application. - del(new_ifd[338]) + del new_ifd[338] out = self.tempfile("temp.tif") TiffImagePlugin.WRITE_LIBTIFF = True diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 5c1b2a2a7..a67d3288f 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -958,7 +958,7 @@ class Image(object): # color to an alpha channel. new_im = self._new(self.im.convert_transparent( mode, self.info['transparency'])) - del(new_im.info['transparency']) + del new_im.info['transparency'] return new_im elif self.mode in ('L', 'RGB', 'P') and mode in ('L', 'RGB', 'P'): t = self.info['transparency'] @@ -1010,14 +1010,14 @@ class Image(object): if delete_trns: # This could possibly happen if we requantize to fewer colors. # The transparency would be totally off in that case. - del(new.info['transparency']) + del new.info['transparency'] if trns is not None: try: new.info['transparency'] = new.palette.getcolor(trns) except Exception: # if we can't make a transparent color, don't leave the old # transparency hanging around to mess us up. - del(new.info['transparency']) + del new.info['transparency'] warnings.warn("Couldn't allocate palette entry " + "for transparency") return new @@ -1039,13 +1039,13 @@ class Image(object): new_im = self._new(im) if delete_trns: # crash fail if we leave a bytes transparency in an rgb/l mode. - del(new_im.info['transparency']) + del new_im.info['transparency'] if trns is not None: if new_im.mode == 'P': try: new_im.info['transparency'] = new_im.palette.getcolor(trns) except Exception: - del(new_im.info['transparency']) + del new_im.info['transparency'] warnings.warn("Couldn't allocate palette entry " + "for transparency") else: