Merge pull request #3573 from jdufresne/del

Python del is a statement not a function
This commit is contained in:
Hugo 2019-01-13 10:57:45 +02:00 committed by GitHub
commit 032efc2b23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -195,7 +195,7 @@ class TestFileLibTiff(LibTiffTestCase):
im = Image.open('Tests/images/hopper_g4.tif') im = Image.open('Tests/images/hopper_g4.tif')
for tag in im.tag_v2: for tag in im.tag_v2:
try: try:
del(core_items[tag]) del core_items[tag]
except KeyError: except KeyError:
pass pass
@ -223,7 +223,7 @@ class TestFileLibTiff(LibTiffTestCase):
for _ in range(info.length)) for _ in range(info.length))
# Extra samples really doesn't make sense in this application. # Extra samples really doesn't make sense in this application.
del(new_ifd[338]) del new_ifd[338]
out = self.tempfile("temp.tif") out = self.tempfile("temp.tif")
TiffImagePlugin.WRITE_LIBTIFF = True TiffImagePlugin.WRITE_LIBTIFF = True

View File

@ -958,7 +958,7 @@ class Image(object):
# color to an alpha channel. # color to an alpha channel.
new_im = self._new(self.im.convert_transparent( new_im = self._new(self.im.convert_transparent(
mode, self.info['transparency'])) mode, self.info['transparency']))
del(new_im.info['transparency']) del new_im.info['transparency']
return new_im return new_im
elif self.mode in ('L', 'RGB', 'P') and mode in ('L', 'RGB', 'P'): elif self.mode in ('L', 'RGB', 'P') and mode in ('L', 'RGB', 'P'):
t = self.info['transparency'] t = self.info['transparency']
@ -1010,14 +1010,14 @@ class Image(object):
if delete_trns: if delete_trns:
# This could possibly happen if we requantize to fewer colors. # This could possibly happen if we requantize to fewer colors.
# The transparency would be totally off in that case. # The transparency would be totally off in that case.
del(new.info['transparency']) del new.info['transparency']
if trns is not None: if trns is not None:
try: try:
new.info['transparency'] = new.palette.getcolor(trns) new.info['transparency'] = new.palette.getcolor(trns)
except Exception: except Exception:
# if we can't make a transparent color, don't leave the old # if we can't make a transparent color, don't leave the old
# transparency hanging around to mess us up. # transparency hanging around to mess us up.
del(new.info['transparency']) del new.info['transparency']
warnings.warn("Couldn't allocate palette entry " + warnings.warn("Couldn't allocate palette entry " +
"for transparency") "for transparency")
return new return new
@ -1039,13 +1039,13 @@ class Image(object):
new_im = self._new(im) new_im = self._new(im)
if delete_trns: if delete_trns:
# crash fail if we leave a bytes transparency in an rgb/l mode. # 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 trns is not None:
if new_im.mode == 'P': if new_im.mode == 'P':
try: try:
new_im.info['transparency'] = new_im.palette.getcolor(trns) new_im.info['transparency'] = new_im.palette.getcolor(trns)
except Exception: except Exception:
del(new_im.info['transparency']) del new_im.info['transparency']
warnings.warn("Couldn't allocate palette entry " + warnings.warn("Couldn't allocate palette entry " +
"for transparency") "for transparency")
else: else: