Rearranged code to limit line length

This commit is contained in:
Andrew Murray 2021-06-23 19:37:56 +10:00
parent 1606d9adf3
commit 59a3e3bc60

View File

@ -977,6 +977,7 @@ class Image:
if self.mode == "P": if self.mode == "P":
trns_im.putpalette(self.palette) trns_im.putpalette(self.palette)
if isinstance(t, tuple): if isinstance(t, tuple):
err = "Couldn't allocate a palette color for transparency"
try: try:
t = trns_im.palette.getcolor(t, self) t = trns_im.palette.getcolor(t, self)
except ValueError as e: except ValueError as e:
@ -985,9 +986,7 @@ class Image:
# then there is no need for transparency # then there is no need for transparency
t = None t = None
else: else:
raise ValueError( raise ValueError(err) from e
"Couldn't allocate a palette color for transparency"
) from e
if t is None: if t is None:
trns = None trns = None
else: else: