mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Prefer 'except Exception:' to bare 'except:'
This commit is contained in:
parent
e10b22aca2
commit
c353225851
|
@ -84,7 +84,7 @@ class PillowTestCase(unittest.TestCase):
|
|||
self.assertTrue(
|
||||
all(x == y for x, y in zip(a, b)),
|
||||
msg or "got %s, expected %s" % (a, b))
|
||||
except:
|
||||
except Exception:
|
||||
self.assertEqual(a, b, msg)
|
||||
|
||||
def assert_image(self, im, mode, size, msg=None):
|
||||
|
@ -149,7 +149,7 @@ class PillowTestCase(unittest.TestCase):
|
|||
try:
|
||||
url = test_image_results.upload(a, b)
|
||||
logger.error("Url for test images: %s" % url)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
raise e
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ def _mp_compile(self, sources, output_dir=None, macros=None,
|
|||
pool = Pool(MAX_PROCS)
|
||||
try:
|
||||
print("Building using %d processes" % pool._processes)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
arr = [(self, obj, build, cc_args, extra_postargs, pp_opts)
|
||||
for obj in objects]
|
||||
|
|
|
@ -971,7 +971,7 @@ class Image(object):
|
|||
if isinstance(t, tuple):
|
||||
try:
|
||||
t = trns_im.palette.getcolor(t)
|
||||
except:
|
||||
except Exception:
|
||||
raise ValueError("Couldn't allocate a palette "
|
||||
"color for transparency")
|
||||
trns_im.putpixel((0, 0), t)
|
||||
|
@ -1008,7 +1008,7 @@ class Image(object):
|
|||
if trns is not None:
|
||||
try:
|
||||
new.info['transparency'] = new.palette.getcolor(trns)
|
||||
except:
|
||||
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'])
|
||||
|
@ -1038,7 +1038,7 @@ class Image(object):
|
|||
if new_im.mode == 'P':
|
||||
try:
|
||||
new_im.info['transparency'] = new_im.palette.getcolor(trns)
|
||||
except:
|
||||
except Exception:
|
||||
del(new_im.info['transparency'])
|
||||
warnings.warn("Couldn't allocate palette entry " +
|
||||
"for transparency")
|
||||
|
|
|
@ -72,7 +72,7 @@ class ImageFont(object):
|
|||
try:
|
||||
fullname = os.path.splitext(filename)[0] + ext
|
||||
image = Image.open(fullname)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
if image and image.mode in ("1", "L"):
|
||||
|
|
|
@ -124,7 +124,7 @@ class PhotoImage(object):
|
|||
self.__photo.name = None
|
||||
try:
|
||||
self.__photo.tk.call("image", "delete", name)
|
||||
except:
|
||||
except Exception:
|
||||
pass # ignore internal errors
|
||||
|
||||
def __str__(self):
|
||||
|
@ -244,7 +244,7 @@ class BitmapImage(object):
|
|||
self.__photo.name = None
|
||||
try:
|
||||
self.__photo.tk.call("image", "delete", name)
|
||||
except:
|
||||
except Exception:
|
||||
pass # ignore internal errors
|
||||
|
||||
def width(self):
|
||||
|
|
|
@ -181,14 +181,14 @@ class Jpeg2KImageFile(ImageFile.ImageFile):
|
|||
try:
|
||||
fd = self.fp.fileno()
|
||||
length = os.fstat(fd).st_size
|
||||
except:
|
||||
except Exception:
|
||||
fd = -1
|
||||
try:
|
||||
pos = self.fp.tell()
|
||||
self.fp.seek(0, 2)
|
||||
length = self.fp.tell()
|
||||
self.fp.seek(pos, 0)
|
||||
except:
|
||||
except Exception:
|
||||
length = -1
|
||||
|
||||
self.tile = [('jpeg2k', (0, 0) + self.size, 0,
|
||||
|
@ -250,7 +250,7 @@ def _save(im, fp, filename):
|
|||
if hasattr(fp, "fileno"):
|
||||
try:
|
||||
fd = fp.fileno()
|
||||
except:
|
||||
except Exception:
|
||||
fd = -1
|
||||
|
||||
im.encoderconfig = (
|
||||
|
|
|
@ -75,7 +75,7 @@ def APP(self, marker):
|
|||
try:
|
||||
jfif_unit = i8(s[7])
|
||||
jfif_density = i16(s, 8), i16(s, 10)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
if jfif_unit == 1:
|
||||
|
@ -107,7 +107,7 @@ def APP(self, marker):
|
|||
# extract Adobe custom properties
|
||||
try:
|
||||
adobe_transform = i8(s[1])
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
else:
|
||||
self.info["adobe_transform"] = adobe_transform
|
||||
|
@ -441,7 +441,7 @@ def _fixup_dict(src_dict):
|
|||
try:
|
||||
if len(value) == 1 and not isinstance(value, dict):
|
||||
return value[0]
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
return value
|
||||
|
||||
|
@ -512,7 +512,7 @@ def _getmp(self):
|
|||
info = TiffImagePlugin.ImageFileDirectory_v2(head)
|
||||
info.load(file_contents)
|
||||
mp = dict(info)
|
||||
except:
|
||||
except Exception:
|
||||
raise SyntaxError("malformed MP Index (unreadable directory)")
|
||||
# it's an error not to have a number of images
|
||||
try:
|
||||
|
|
|
@ -340,7 +340,7 @@ class PngStream(ChunkStream):
|
|||
self.im_size = i32(s), i32(s[4:])
|
||||
try:
|
||||
self.im_mode, self.im_rawmode = _MODES[(i8(s[8]), i8(s[9]))]
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
if i8(s[12]):
|
||||
self.im_info["interlace"] = 1
|
||||
|
|
|
@ -231,7 +231,7 @@ class _PyAccessI16_B(PyAccess):
|
|||
pixel = self.pixels[y][x]
|
||||
try:
|
||||
color = min(color, 65535)
|
||||
except:
|
||||
except Exception:
|
||||
color = min(color[0], 65535)
|
||||
|
||||
pixel.l = color >> 8
|
||||
|
|
|
@ -210,7 +210,7 @@ def loadImageSeries(filelist=None):
|
|||
continue
|
||||
try:
|
||||
im = Image.open(img).convert2byte()
|
||||
except:
|
||||
except Exception:
|
||||
if not isSpiderImage(img):
|
||||
print(img + " is not a Spider image file")
|
||||
continue
|
||||
|
|
|
@ -1413,7 +1413,7 @@ def _save(im, fp, filename):
|
|||
ifd[key] = info.get(key)
|
||||
try:
|
||||
ifd.tagtype[key] = info.tagtype[key]
|
||||
except:
|
||||
except Exception:
|
||||
pass # might not be an IFD, Might not have populated type
|
||||
|
||||
# additions written by Greg Couch, gregc@cgl.ucsf.edu
|
||||
|
|
|
@ -119,7 +119,7 @@ endlocal
|
|||
def clean():
|
||||
try:
|
||||
shutil.rmtree('../build')
|
||||
except:
|
||||
except Exception:
|
||||
# could already be removed
|
||||
pass
|
||||
run_script(('virtualenvs', setup_vms()))
|
||||
|
|
Loading…
Reference in New Issue
Block a user